Aspect selection due to caller (newbe)

View: New views
1 Messages — Rating Filter:   Alert me  

Aspect selection due to caller (newbe)

by titöf :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi!

I have two aspects (A1 and A2) which both derive from a base class. Is it possible to define these aspects in a way that depending on the calling class A1 or A2 is used? I tried several things in the pointcut definition but always the first aspect mentioned in the aop.xml file gets used...

So for beeing in class "myotherpackage.Sample_AOPConfiguration" I want to use aspect "A1" and for the the second class "myotheroackage.TestCase_AOPConfiguration" I want to use "A2". Consider this like an attempt to use a different aspect implementation in testing/mocking than production or something similar.

My "aop.xml"


<aspectwerkz>
    <system id="MySystem">
        <package name="mypackage">
            <aspect class="A1">
                <pointcut name="pcn1"
                          expression="within(myotherpackage.Sample_AOPConfiguration) and
                          execution(@mypackage.MyInject mypackage.ResultData *.*.get(..))"/>
            </aspect>

            <aspect class="A2">
                <pointcut name="pcn2" expression="within(myotherpackage.TestCase_AOPConfiguration) and
                          execution(@mypackage.MyInject myPackage.ResultData *.*.get(..))"/>
            </aspect>
        </package>
    </system>
</aspectwerkz>


Thanks in advance

Jens
LightInTheBox - Buy quality products at wholesale price!