Dear all,

I am developing an application using Tuscany 2.0 using java components in which I would like to use AOP for cross-cutting concerns like register exceptions and timing and logging some method calls, among other things. However, I don't have a clear idea about how I can do it. I have read a guide article (http://tuscany.apache.org/logging-tracing-and-timing-in-tuscany.html) which describes a module that use AspectJ in Tuscany.

I would like to create my own aspects and define their point cuts in the aop.xml file. My question is, how Tuscany is aware of the existence of the aop.xml in order to create the advices? Are the aspects loaded when the Tuscany Runtime start up (like Spring) or do I need to specified it from the command line?

My aop.xml is very simple, one aspect for logging and another for exception management

<aspectj>
<aspects>
<aspect name="com.mystore.aspects.LoggingAspect" />
<concrete-aspect name="org.apache.tuscany.sca.aspectj.ExceptionManagementAspect">
<pointcut name="methodCall"
              expression="call(* com.mystore.services..*(..))"/>
</concrete-aspect>
</aspects>

<weaver options="-verbose">
<include within="org.apache.tuscany.sca..*" />
</weaver>
</aspectj>

Ant the structure of my project is:

MyStore
    -->src/main/java/com/mystore/aspects
        -->ExceptionManagementAspect.java
        -->LoggingAspect.java
    -->src/main/java/com/mystore/services
        -->AccountantImpl.java
        -->AccountService.java
        -->CatalogService.java
        -->StoreImpl.java
    -->src/main/resources
        -->META-INF
            -->aop.xml
        -->MyStore.composite
    -->Lib
        ...
        M2_REPO\org\aspectj\aspectjrt\1.6.8\aspectjrt-1.6.8.jar
        M2_REPO\org\aspectj\aspectjweaver\1.6.8\aspectjweaver-1.6.8.jar
        ...

If it's not possible to loaded them when the app start up, can I get the same goal using other things like applying policies?

Thanks,
Fran

Reply via email to