View Javadoc

1   /***************************************************************************************
2    * Copyright (c) Jonas Bonér, Alexandre Vasseur. All rights reserved.                 *
3    * http://aspectwerkz.codehaus.org                                                    *
4    * ---------------------------------------------------------------------------------- *
5    * The software in this package is published under the terms of the LGPL license      *
6    * a copy of which has been included with this distribution in the license.txt file.  *
7    **************************************************************************************/
8   package org.codehaus.aspectwerkz.annotation;
9   
10  import org.codehaus.aspectwerkz.util.Strings;
11  
12  /***
13   * The aspect annotation proxy.
14   * <br/>
15   * Note: this untyped annotation is like @Aspect perXXX name=foo [name is optional etc]
16   * ie perXX is sort of anonymous and name as well, but without defaullt, hence the setter.
17   * 
18   * @author <a href="mailto:jboner@codehaus.org">Jonas Bonér </a>
19   */
20  public class AspectAnnotationProxy extends UntypedAnnotationProxy {
21      private String m_deploymentModel = "perJVM";
22  
23      private String m_aspectName = null;
24  
25      public String deploymentModel() {
26          return m_deploymentModel;
27      }
28  
29      public String aspectName() {
30          return m_aspectName;
31      }
32  
33      public void setAspectName(String aspectName) {
34          m_aspectName = aspectName;
35          // update m_value for proper serialization
36          m_value = "name="+aspectName+" "+m_deploymentModel;
37      }
38  
39      public void setValue(final String value) {
40          String[] parts = Strings.splitString(value, " ");
41          StringBuffer deploymentModel = new StringBuffer();
42          for (int i = 0; i < parts.length; i++) {
43              String part = parts[i];
44              int equals = part.indexOf('=');
45              if (equals > 0) {
46                  String name = part.substring(0, equals);
47                  String param = part.substring(equals + 1, part.length());
48                  if (name.equalsIgnoreCase("name")) {
49                      m_aspectName = param;
50                  }
51              } else {
52                  deploymentModel.append(' ');
53                  deploymentModel.append(part);
54              }
55          }
56          String tmp = deploymentModel.toString().trim();
57          if ((tmp != null) && !tmp.equals("")) {
58              m_deploymentModel = tmp.trim();
59          }
60      }
61  }