2 Replies Latest reply on Jun 8, 2010 12:21 PM by sintetik7

    Maven plugin annotations parsing

    sintetik7

      Hi,

       

      I'm new to AOP. I'm trying to create a simple aspect and include it in a war deployed in JBossAS, built with maven.

       

      I've got it working with jboss-aop.xml descriptor but I can't figure out how to do this with annotations.

       

      My pom.xml includes:

      {code:xml}
             <plugin>

               <groupId>org.jboss.maven.plugins</groupId>

               <artifactId>maven-jbossaop-plugin</artifactId>

               <version>2.1.3.GA</version>

              <executions>
                 <execution>
                  <id>compile</id>
                   <configuration>
                     <suppress>false</suppress>
                     <includeProjectDependency>true</includeProjectDependency>
                      <aoppaths><aoppath>${basedir}/src/main/resources/META-INF/jboss-aop.xml</aoppath></aoppaths>
                      <includes><include>com/blah/Blah.class</include></includes>
                   </configuration>
                   <goals><goal>compile</goal></goals>
                 </execution>
              </executions>
             </plugin>
      {code}

       

       

      And my jboss-aop.xml :

       

      {code:xml}

      <aop xmlns="urn:jboss:aop-beans:1.0">
         <aspect scope="PER_VM"/>


       


        <bind pointcut="execution(* com.blah.Blah->*(..))">
           <advice name="trace" aspect="com.blah.MyAspect"/>
         </bind>
      </aop>

      {code}

       

       

      This way it works, I get all the classes weaved at compile-time.

       

      But then I remove jboss-aop.xml and inculde annotations in MysAspect.java:

       

       

      {code}

      @Aspect (scope = Scope.PER_VM)
      public class MyAspect{


       


          @Bind (pointcut="execution(* com.blah.Blah->*(..))")
           public Object trace(Invocation invocation) throws Throwable {


      ....

      {code}

       

       

      As I see it, maven plugin just ignores any annotation processing.

       

      [INFO] [jbossaop:compile {execution: compile}]
      [INFO] [no comp needed] ...

       

      Is there any way to weave classes with annotations with maven-jbossaop-plugin ?

        • 1. Re: Maven plugin annotations parsing
          kabirkhan

          Try using <aopClassPath/> pointing to the directory containing your annotated classes. Here is a snippet from the pom of the annotated-aspects example in the aop distribution

           

           

                    <execution>
                      <id>run</id>
                      <configuration>
                        <aoppaths>
                          <aoppath></aoppath>
                        </aoppaths>
                        <aopClassPath>.</aopClassPath>
                        <!--
                        <aopClassPath>annotated-aspects-1.0.0.jar</aopClassPath>
                        -->
                        <executable>Driver</executable>
                      </configuration>
                      <goals>
                        <goal>run</goal>
                      </goals>
                    </execution>
           
          
          • 2. Re: Maven plugin annotations parsing
            sintetik7

            Thanks, exactly like I needed.