5 Replies Latest reply on May 20, 2004 1:51 PM by bill.burke

    Can JBoss AOP work on Entity EJB?

    bensench

      I tried to use JBoss AOP on Entity EJB. It doesn't work on the getter/setter
      of entity EJB possibly due to the fact that they are public abstract methods.

      Is there any way to make it work on these public abstract getter/setter method?

      Thanks in advance.

      Bensen

        • 1. Re: Can JBoss AOP work on Entity EJB?
          bill.burke

          Not possible at this time as in JBoss, entity class implementations are generated at runtime and that classloader isn't set up for dynamic loadtime transformations at this time.

          $instanceof would work, except for the above problem. Sorry.

          What you can do is do traditional JBoss interceptors. see standardjboss.xml and you'll see both client and serverside stacks.

          Bill

          • 2. Re: Can JBoss AOP work on Entity EJB?
            bensench

            Thanks. Maybe I should AOPize the EntityEJB cache instead of AOPizing the entityEJB itself.

            I am trying to manipulate some attributes of certain entityEJBs of a J2EE application in a way transparent to the J2EE application. For example, when a CreditCard entityEJB is created the first time, its credit card attribute is encrypted before being storing to database. When the credit card owner or other authorized user accesses the credit card info, the credit card attribute is decrypted.

            I am thinking of AOPizing the entityInstancePool or any cache used for entity EJBs. But I am not sure whether it's feasible or it will violate any spec.

            By the way, I check the latest JBoss source code and 3.0.x document trying to understand how the entity EJBs are initialized and put in the cache. I don't quite understand the process and classes used by EJB container. Can anyone give me a direction where to look?

            Thanks in advance.

            Ben. C.

            • 3. Re: Can JBoss AOP work on Entity EJB?
              bill.burke

              This can be solved with an EJB entity bean server-side interceptor. Just have a specific interceptor that checks wither it is a setCCNum or getCCNum and do your thing.

              Or maybe you need to be App Server agnostic? Then you're probably screwed.

              • 4. Re: Can JBoss AOP work on Entity EJB?
                bensench

                Bill,

                But these entityEJB setter/getter methods are abstract methods and are not
                AOPized now. Is there any other Interceptor which can intercept any setter/getter methods of entity EJB?

                Thanks,

                Ben C.

                • 5. Re: Can JBoss AOP work on Entity EJB?
                  bill.burke

                  Again, look in:

                  jboss-X.X/server/default/conf/standardjboss.xml

                  Search for interceptor

                  Server side interpceptors for Entity beans have been available since JBoss 2.0.

                  Our forpay doco should also have examples of implementing an interceptor. (I know there is at least a lab in our advanced training for this).

                  But, if you're stuck with trying to implement a appserver agnostic solution, you are screwed.

                  Bill