Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] aop.xml

That is a good question and I had to go and try something out to remind myself of how I thought it worked !

I presume you are referring to concrete-aspect definitions in aop.xml rather than just aspect references to turn them on and off? (Because with simple references it works fine and the aop.xml files are merged to determine the set of aspects that are ‘live’).

If I have two aop.xml files like this on a class path:

<aspectj>
<aspects>

        <concrete-aspect name="ConcreteAspect" extends="AbstractAspect">
         <pointcut name="p" _expression_="within(XXX)"/>
        </concrete-aspect>

</aspects>
        <weaver options="-debug -showWeaveInfo"/>
</aspectj>


<aspectj>
<aspects>

        <concrete-aspect name="ConcreteAspect" extends="AbstractAspect">
         <pointcut name="p" _expression_=“within(YYY)"/>
        </concrete-aspect>

</aspects>
        <weaver options="-debug -showWeaveInfo"/>
</aspectj>

which define the same aspect but differing point cuts, you will get an error. There is no precedence/override behaviour among concrete aspects like that - the error will be:

[AppClassLoader@18b4aac2] error Attempt to concretize but chosen aspect name already defined: <concrete-aspect name='ConcreteAspect' extends='AbstractAspect' perclause='null'/> in aop.xml
[AppClassLoader@18b4aac2] error Concrete-aspect 'ConcreteAspect' could not be registered
[AppClassLoader@18b4aac2] warning failure(s) registering aspects. Disabling weaver for class loader sun.misc.Launcher$AppClassLoader@18b4aac2

Could it be made to work, yep, but that’d be a new feature.  What are the other options? You could do it in code, if the concrete aspects were written as code:

aspect ConcreteAspect extends AbstractAspect {
  pointccut p(): within(XXX);
}


aspect ConcreteAspect extends AbstractAspect {
  pointccut p(): within(YYY);
}

Then compiled and included in jars, then whichever one is on the class path first will be used if you’re aop.xml specifics <aspect name=“ConcreteAspect”/>


Cheers,
Andy

On Nov 20, 2018, at 8:44 AM, Mikael Petterson <mikaelpetterson@xxxxxxxxxxx> wrote:

Hi,

I was not clear of how the content of the aop.xml are treated if we have more than one in classpath?
Is there some kind of precedence for anything.
I was thinking if we have defined an aspect in one aop.xml and then we have another aop.xml with the same aspect name but with different pointcuts. Which pointcuts will be valid? 

br,

//mikael



 
 
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/aspectj-users


Back to the top