Customising application layers using AspectWerkz

Create a file META-INF/aop.xml that can be loaded by the Classloader which loads the application. For a WAR web application, this can be put in WEB-INF/classes (so that we have the file WEB-INF/classes/META-INF/aop.xml). For an EAR application in Weblogic, this can be put in APP-INF/classes (so that we have the file APP-INF/classes/META-INF/aop.xml). For an EAR application in JBoss, this has to be put in the META-INF dir in the root of the ear.

This is a regular AspectWerkz aspect definition file, but contents of this determine the layers of the application that would be identified by InfraRED. A sample is give below.

                       
<!DOCTYPE aspectwerkz PUBLIC
    "-//AspectWerkz//DTD//EN"
    "http://aspectwerkz.codehaus.org/dtd/aspectwerkz2.dtd">

<aspectwerkz>
    <system id="my.app">      
        <exclude package="net.sf.infared.*"/>        
        
        <!-- 
            All executions in com.my.app.layer1 package and its subpackages
            will be recorded as LayerOne
        -->
        <aspect class="net.sf.infrared.aspects.api.ApiAspect"
                deployment-model="perClass" name="LayerOne"> 
            <param name="layer" value="LayerOne"/>
            <pointcut name="methodExecution" 
                      expression="execution(public * com.my.app.layer1.*...*(..))"/>
            <advice name="collectMetrics(StaticJoinPoint sjp)" type="around" bind-to="methodExecution"/>
        </aspect>
    
        <!-- 
            All executions in com.my.app.layer2 package and its subpackages
            will be recorded as LayerTwo
        -->
        <aspect class="net.sf.infrared.aspects.api.ApiAspect"
                deployment-model="perClass" name="LayerTwo"> 
            <param name="layer" value="LayerTwo"/>
            <pointcut name="methodExecution" 
                      expression="execution(public * com.my.app.layer1.*...*(..))"/>
            <advice name="collectMetrics(StaticJoinPoint sjp)" type="around" bind-to="methodExecution"/>
        </aspect>
    </system>
</aspectwerkz>      
 
                        

Layers are typically identified by packages.

More details on how to identify various layers are given in the Configuration page