6 Replies Latest reply on Jun 16, 2004 9:19 AM by Bill Burke

    AOPtize a SessionBean

    pipo Newbie

      Hi all,
      I am trying to intercept a call to a stateless session bean under jboss dr4 but it don't work.

      I describe my environment:

      * Simple.jar
      Simple.class
      SimpleHome.class
      SimpleLocal.home
      SimpleLocalHome.class
      LoggingInterceptor.class
      META-INF
      jboss.xml
      ejb-jar.xml
      jboss-aop.xml

      jboss-aop.xml

      ?xml version="1.0" encoding="UTF-8"?
      aop
      interceptor name="LoggingInterceptor" class="LoggingInterceptor"/
      bind pointcut="execution(* com.idecnet.wsr.SimpleEJB->*(..))"
      interceptor-ref name="LoggingInterceptor"/
      /bind
      /aop


      LoggingInterceptor.java

      public class LoggingInterceptor implements Interceptor {
      public String getName() {
      return LoggingInterceptor.class.getName();
      }
      public Object invoke(Invocation invocation) throws Throwable {
      System.out.println("FromAOP");
      return null;
      }
      }

        • 1. Re: AOPtize a SessionBean
          Bill Burke Master

          This is a packaging issue:

          http://www.jboss.org/wiki/Wiki.jsp?page=RunningWithJBossApplicationServer

          Also, there is a server/xxx/conf/base-aop.xml file in which you can put AOP definitions as well.

          • 2. Re: AOPtize a SessionBean
            pipo Newbie

            I have read your link and don't undertand somethings.

            1. I must have 2 files Simple.jar and Simple.aop or all can be contained in only one file.
            2.- "You can either deploy an XML file directly in the deploy/ directory with the signature *-aop.xml..." ok i put my Simple-aop.xml in deply dir but where do i put the class file, packaged with Simple.jar (ejb), alone...?
            3.- "The JAR format must have the file extension .aop and a jboss-aop.xml file must be contained in a META-INF directory..." this mean tha I create a jar with aop extension and I include the class files too, right?

            Very thank you for your help and sorry for my bad english....

            • 3. Re: AOPtize a SessionBean
              pipo Newbie

              After read your post and I was thinking a little and I believe that two files with .aop and .jar extension is the correct way. Correct me if don't?

              In order to clarify the things I show you an unpack of my jar and aop file.

              # unzip Simple.jar
              Archive: Simple.jar
              creating: META-INF/
              inflating: META-INF/MANIFEST.MF
              inflating: META-INF/ejb-jar.xml
              inflating: META-INF/jboss.xml
              inflating: BaseSessionBean.class
              inflating: Simple.class
              inflating: SimpleEJB.class
              inflating: SimpleHome.class
              inflating: SimpleLocal.class
              inflating: SimpleLocalHome.class

              # unzip Simple.aop
              Archive: Simple.aop
              creating: META-INF/
              inflating: META-INF/MANIFEST.MF
              inflating: META-INF/jboss-aop.xml
              inflating: LoggingInterceptor.class


              But when I deploy the .aop file nothing happens and my example don't work, no interceprot code is executed.

              • 4. Re: AOPtize a SessionBean
                Bill Burke Master

                Are you doing load time or precompiled aspects?

                if you are doing load-time then you must set the EnableTransformer attribute to true within the AspectManagerService MBEAN within

                jboss/server/xxx/conf/jboss-service.xml

                It is turned off by default because JBoss boots up a little slower.

                Let me know if this is your problem.

                Sorry for the trouble.

                Bill

                • 5. Re: AOPtize a SessionBean
                  pipo Newbie

                  Hello again!!
                  ok, EnableTransformer was turned off (false) I have turned it on (true) and certainly the server is a bit slow but the result is the same, my LoggingInterceptor code is not executed.

                  Are my packages right? (see avove package structure)
                  Are my jboss-aop.xml correct? (see it avove)
                  What can I do to help you.. to help?

                  Very Very thank you?

                  • 6. Re: AOPtize a SessionBean
                    Bill Burke Master

                    Can you send me your example?

                    bill@jboss.org