[jboss-user] [JBoss AOP] - Mark all Stateless EJBs as part of cluster using ejb3-interceptors-aop.xml

Nitin Jain do-not-reply at jboss.com
Thu Jul 7 01:32:52 EDT 2011


Nitin Jain [http://community.jboss.org/people/nitin_jain] created the discussion

"Mark all Stateless EJBs as part of cluster using ejb3-interceptors-aop.xml"

To view the discussion, visit: http://community.jboss.org/message/613833#613833

--------------------------------------------------------------
Hello Forum,

I am running my application in a clustered environment. I would like to avoid annotating every stateless EJB with @Clustered annotation and rather make use of "ejb3-interceptors-aop.xml".

When I use @Clustered annotation, the annotated EJB is logged by JBoss in the following manner.

2011-07-07 10:06:18,251 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main) Added bean(jboss.j2ee:ear=myapp.ear,jar=platform-services-ejbs.jar,name=NotificationProcessorBean,service=EJB3) to KernelDeployment of: platform-services-ejbs.jar
2011-07-07 10:06:18,251 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main) installing bean: jboss.j2ee:ear=myapp.ear,jar=platform-services-ejbs.jar,name=RequestDispatcherBean,service=EJB3
2011-07-07 10:06:18,251 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main)   with dependencies:
2011-07-07 10:06:18,251 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main)   and demands:
2011-07-07 10:06:18,251 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main)  jboss.ejb:service=EJBTimerService
2011-07-07 10:06:18,251 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main)  partition:partitionName=MyCluster
2011-07-07 10:06:18,251 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main)   and supplies:
2011-07-07 10:06:18,251 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main)  Class:com.myapp.platform.bs.SampleEJB
2011-07-07 10:06:18,251 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main)  jndi:myapp/SampleEJBBean/remote-com.myapp.platform.bs.SampleEJB
2011-07-07 10:06:18,251 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main)  jndi:myapp/SampleEJBBean/remote
>From the log it can be understood that "SampleEJBBean" is part of "MyCluster".

Is it possible to add annotation element for @Clustered annotation in "ejb3-interceptors-aop.xml" and achieve similar functionality?

To give it a try I added the following elements in the "ejb3-interceptors-aop.xml" file present at "\server\all\deploy" with no success. 

   <domain name="Stateless Bean" extends="Intercepted Bean" inheritBindings="true">
      <bind pointcut="execution(public * *->*(..))>
         <interceptor-ref name="org.jboss.ejb3.ENCPropagationInterceptor"/>
         <interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
      </bind>
      <bind pointcut="execution(public * @org.jboss.ejb3.annotation.SecurityDomain->*(..))>
         <interceptor-ref name="Basic Authorization"/>
      </bind>
      <bind pointcut="execution(public * *->*(..))>
         <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
      </bind>
      <bind pointcut="execution(public * @org.jboss.ejb3.annotation.Clustered->*(..))>
         <interceptor-ref name="org.jboss.ejb3.remoting.ReplicantsManagerInterceptorFactory"/>
      </bind>
      <bind pointcut="execution(public * *->*(..))>
         <interceptor-ref name="org.jboss.aspects.tx.TxPropagationInterceptor"/>
         <interceptor-ref name="org.jboss.ejb3.tx.CMTTxInterceptorFactory"/>
         <interceptor-ref name="org.jboss.ejb3.stateless.StatelessInstanceInterceptor"/>
         <interceptor-ref name="org.jboss.ejb3.tx.BMTTxInterceptorFactory"/>
         <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
         <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
         <!-- interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/ -->
         <stack-ref name="EJBInterceptors"/>
      </bind>
      <annotation expr="class(*) AND !class(@org.jboss.ejb3.annotation.Pool)">
         @org.jboss.ejb3.annotation.Pool (value=ThreadlocalPool, maxSize=30, timeout=10000)
      </annotation>
      <annotation expr="class(@javax.ejb.Remote) AND !class(@org.jboss.annotation.ejb.Clustered)">
      

     @org.jboss.annotation.ejb.Clustered(partition=MyCluster, loadBalancePolicy=org.jboss.ha.framework.interfaces.RandomRobin")

      </annotation>
   </domain>


I have tried other possiblities like 
   <annotation expr="class(*) AND !class(@org.jboss.annotation.ejb.Clustered)">
       @org.jboss.annotation.ejb.Clustered(partition=MyCluster, loadBalancePolicy=org.jboss.ha.framework.interfaces.RandomRobin)
   </annotation>


and 
   <annotation expr="!class(@org.jboss.annotation.ejb.Clustered)">          @org.jboss.annotation.ejb.Clustered(partition=MyCluster, loadBalancePolicy=org.jboss.ha.framework.interfaces.RandomRobin)
   </annotation>

 but with no success. I do not see any of my other stateless EJB with a similar log as depicted for "SampleEJBBean".

Please advise on how to fix this issue.

Regards,
Nitin
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/613833#613833]

Start a new discussion in JBoss AOP at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2027]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110707/bb5bd4a2/attachment-0001.html 


More information about the jboss-user mailing list