<pointcut name="tracingScope" expression="within(org.maw.*)"/>
</concrete-aspect>
- <!-- Of the set of aspects known to the weaver, use aspects matching
- the type pattern "com..*" for weaving. -->
+ <!-- Of the set of aspects declared in this sole aop.xml,
+ use aspects matching the type pattern "com..*" for weaving. -->
<include within="com..*"/>
- <!-- Do not use any aspects with the @CoolAspect annotation for weaving -->
+ <!-- Of the set of aspects declared in this sole aop.xml,
+ do not use any aspects with the @CoolAspect annotation for weaving -->
<exclude within="@CoolAspect *"/>
</aspects>
</para>
<para>
- The aspects element may optionally contain one or more include and
- exclude elements (by default, all defined aspects are used for weaving).
+ The <literal>aspects</literal> element may optionally contain one or more <literal>include</literal> and
+ <literal>exclude</literal> elements (by default, all defined aspects are used for weaving).
Specifying include or exclude elements restricts the set of defined
aspects to be used for weaving to those that are matched by an include
- pattern, but not by an exclude pattern. The 'within' attribute accepts
+ pattern, but not by an exclude pattern. The <literal>within</literal> attribute accepts
a type pattern of the same form as a within pcd, except that &&
and || are replaced by 'AND' and 'OR'.
</para>
+ <para>
+ Note that <literal>include</literal> and <literal>exclude</literal> affects the declared list of aspects (or concrete-aspect) defined in this
+ sole aop.xml and has no side effect on other aop.xml files.
+ Also note it is required to use <literal>aspect</literal> or <literal>concrete-aspect</literal> elements and that include does not
+ mean "pick any aspect you 'll find" - as the aspect list must be known by the weaver.
+ </para>
<para>
The weaver element is used to pass options to the weaver and to specify
Note that dynamic proxy representations are exposed to the LTW infrastructure and are not considered
a special case.
</para>
+
+ <para>
+ Some lint options behave differently when used under load-time weaving. The <literal>adviceDidNotMatch</literal>
+ won't be handled as a warn (as during compile time) but as an info message.
+ </para>
</sect1>
<sect1 id="ltw-packaging">
aspects
*********************************************************************************************************************************
[aspects] defines a set of aspects
-TODO we were about to use include but it is already used for weaver scope with "within" which is not relevant
-for aspects. I (AV) decided to use only aspect and provide include= thru name, and exclude= as exclude.
-see sample.
+Note: include only include among Union{aspect, concrete-aspect} WITHIN THIS SOLE aop.xml
******************************************************************************************************************************-->
<!ELEMENT aspects (
- (aspect | exclude | concrete-aspect)*
+ (aspect | exclude | include | concrete-aspect)*
)>
<!--*****************************************************************************************************************************
aspect
-TODO: did not used include since already used in weaver/include@within and @within does not makes sense
*********************************************************************************************************************************
[aspect] defines an aspect to include
@name FQN of the aspect, nested class must use $
private List m_excludeStartsWith = new ArrayList();
private List m_aspectExcludeTypePattern = new ArrayList();
private List m_aspectExcludeStartsWith = new ArrayList();
+ private List m_aspectIncludeTypePattern = new ArrayList();
+ private List m_aspectIncludeStartsWith = new ArrayList();
private StringBuffer namespace;
private IWeavingContext weavingContext;
public ClassLoaderWeavingAdaptor(final ClassLoader loader, IWeavingContext wContext) {
super(null);
}
-
+
void initialize(final ClassLoader loader, IWeavingContext wContext) {
//super(null);// at this stage we don't have yet a generatedClassHandler to define to the VM the closures
this.generatedClassHandler = new GeneratedClassHandler() {
Aj.defineClass(loader, name, bytes);// could be done lazily using the hook
}
};
-
+
if(wContext==null){
weavingContext = new DefaultWeavingContext(loader);
}else{
definitions.add(DocumentParser.parse((new File(file)).toURL()));
}
}
-
+
String resourcePath = System.getProperty("org.aspectj.weaver.loadtime.configuration",AOP_XML);
StringTokenizer st = new StringTokenizer(resourcePath,";");
// AV - see #113511
if (!definitions.isEmpty()) {
registerAspectExclude(weaver, loader, definitions);
+ registerAspectInclude(weaver, loader, definitions);
registerAspects(weaver, loader, definitions);
registerIncludeExclude(weaver, loader, definitions);
registerDump(weaver, loader, definitions);
world.setPinpointMode(weaverOption.pinpoint);
weaver.setReweavableMode(weaverOption.notReWeavable);
world.setXnoInline(weaverOption.noInline);
- //world.setBehaveInJava5Way(weaverOption.java5);//TODO should be autodetected ?
// AMC - autodetect as per line below, needed for AtAjLTWTests.testLTWUnweavable
world.setBehaveInJava5Way(LangUtil.is15VMOrGreater());
//-Xlintfile: first so that lint wins
}
}
+ private void registerAspectInclude(final BcelWeaver weaver, final ClassLoader loader, final List definitions) {
+ String fastMatchInfo = null;
+ for (Iterator iterator = definitions.iterator(); iterator.hasNext();) {
+ Definition definition = (Definition) iterator.next();
+ for (Iterator iterator1 = definition.getAspectIncludePatterns().iterator(); iterator1.hasNext();) {
+ String include = (String) iterator1.next();
+ TypePattern includePattern = new PatternParser(include).parseTypePattern();
+ m_aspectIncludeTypePattern.add(includePattern);
+ fastMatchInfo = looksLikeStartsWith(include);
+ if (fastMatchInfo != null) {
+ m_aspectIncludeStartsWith.add(fastMatchInfo);
+ }
+ }
+ }
+ }
+
/**
* Register the aspect, following include / exclude rules
*
return accept;
}
+ //FIXME we don't use include/exclude of others aop.xml
+ //this can be nice but very dangerous as well to change that
private boolean acceptAspect(String aspectClassName) {
// avoid ResolvedType if not needed
- if (m_aspectExcludeTypePattern.isEmpty()) {
+ if (m_aspectExcludeTypePattern.isEmpty() && m_aspectIncludeTypePattern.isEmpty()) {
return true;
}
// still try to avoid ResolvedType if we have simple patterns
+ // EXCLUDE: if one match then reject
String fastClassName = aspectClassName.replace('/', '.').replace('.', '$');
for (int i = 0; i < m_aspectExcludeStartsWith.size(); i++) {
if (fastClassName.startsWith((String)m_aspectExcludeStartsWith.get(i))) {
return false;
}
}
+ //INCLUDE: if one match then accept
+ for (int i = 0; i < m_aspectIncludeStartsWith.size(); i++) {
+ if (fastClassName.startsWith((String)m_aspectIncludeStartsWith.get(i))) {
+ return true;
+ }
+ }
// needs further analysis
ResolvedType classInfo = weaver.getWorld().resolve(UnresolvedType.forName(aspectClassName), true);
return false;
}
}
- return true;
+ //include are "OR"ed
+ boolean accept = true;//defaults to true if no include
+ for (Iterator iterator = m_aspectIncludeTypePattern.iterator(); iterator.hasNext();) {
+ TypePattern typePattern = (TypePattern) iterator.next();
+ accept = typePattern.matchesStatically(classInfo);
+ if (accept) {
+ break;
+ }
+ // goes on if this include did not match ("OR"ed)
+ }
+ return accept;
}
public boolean shouldDump(String className) {
}
return false;
}
-
+
/*
* shared classes methods
*/
-
+
/**
* @return Returns the key.
*/
}
return false;
}
-
+
/**
* Flush the generated classes cache
*/