[jboss-user] [JBoss AOP] New message: "Client Interceptor for EJB3"

Karl Koster do-not-reply at jboss.com
Mon Jan 25 16:46:04 EST 2010


User development,

A new message was posted in the thread "Client Interceptor for EJB3":

http://community.jboss.org/message/522166#522166

Author  : Karl Koster
Profile : http://community.jboss.org/people/kkoster

Message:
--------------------------------------------------------------
I am trying to deploy a pair of client and server side interceptors for EJB3. I am using JBoss 5.1.0.GA. I have followed the directions found at http://www.jboss.org/ejb3/docs/tutorial/configuration/configuration.html. The interceptors are packaged in the EAR for the application. I first altered the ejb-intercetpors-aop.xml to create new customized stacks with the following additions (existing content is removed for brevity):
 

   <!-- KDR Additions -->
   <interceptor class="org.kdr.interceptor.security.KDRClientSecurityInterceptor" scope="PER_VM"/>
   <interceptor class="org.kdr.interceptor.security.KDRServerSecurityInterceptor" scope="PER_VM"/>
   <!-- End KDR Additions -->

   <!-- KDR Additions -->
   <stack name="KDRServiceClientInterceptors">
      <interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>
      <interceptor-ref name="org.jboss.ejb3.security.client.SecurityClientInterceptor"/>
      <interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
      <interceptor-ref name="org.kdr.interceptor.security.KDRClientSecurityInterceptor"/>
      <interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
   </stack>

   <stack name="KDRStatelessSessionClientInterceptors">
      <interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>
      <interceptor-ref name="org.jboss.ejb3.security.client.SecurityClientInterceptor"/>
      <interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
      <interceptor-ref name="org.kdr.interceptor.security.KDRClientSecurityInterceptor"/>
      <interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
   </stack>

   <stack name="KDRStatefulSessionClientInterceptors">
      <interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>
      <interceptor-ref name="org.jboss.ejb3.security.client.SecurityClientInterceptor"/>
      <interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
      <interceptor-ref name="org.kdr.interceptor.security.KDRClientSecurityInterceptor"/>
      <interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
   </stack>

   <stack name="KDRClusteredStatelessSessionClientInterceptors">
      <interceptor-ref name="org.jboss.ejb3.remoting.ClusteredIsLocalInterceptor"/>
      <interceptor-ref name="org.jboss.ejb3.security.client.SecurityClientInterceptor"/>
      <interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
      <interceptor-ref name="org.jboss.aspects.remoting.ClusterChooserInterceptor"/>
      <interceptor-ref name="org.kdr.interceptor.security.KDRClientSecurityInterceptor"/>
      <interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
   </stack>

   <stack name="KDRClusteredStatefulSessionClientInterceptors">
      <interceptor-ref name="org.jboss.ejb3.remoting.ClusteredIsLocalInterceptor"/>
      <interceptor-ref name="org.jboss.ejb3.security.client.SecurityClientInterceptor"/>
      <interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
      <interceptor-ref name="org.jboss.aspects.remoting.ClusterChooserInterceptor"/>
      <interceptor-ref name="org.kdr.interceptor.security.KDRClientSecurityInterceptor"/>
      <interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
   </stack>
   <!-- End KDR Additions -->


 
I also added the following entries for the server side interceptor (copies of the existing domains with the addition of the custom server side interceptor):
 

   <!-- KDR Additions -->
   <domain name="KDR 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.kdr.interceptor.security.KDRServerSecurityInterceptor"/>
      </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>
      <bind pointcut="execution(public * *->*(..))">
         <interceptor-ref name="org.kdr.interceptor.security.KDRServerSecurityInterceptor"/>
      </bind>
      <annotation expr="class(*) AND !class(@org.jboss.ejb3.annotation.Pool)">
         @org.jboss.ejb3.annotation.Pool (value="ThreadlocalPool", maxSize=30, timeout=10000)
      </annotation>
   </domain>

   <domain name="KDR JACC 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="JACC 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.kdr.interceptor.security.KDRServerSecurityInterceptor"/>
      </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>
   </domain>

   <domain name="KDR Base Stateful 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"/>
      </bind>
      <bind pointcut="execution(public * *->@javax.ejb.Remove(..))">
         <interceptor-ref name="org.jboss.ejb3.stateful.StatefulRemoveFactory"/>
      </bind>
      <bind pointcut="execution(public * *->*(..))">
         <interceptor-ref name="org.jboss.ejb3.stateful.StatefulInstanceInterceptor"/>
         <interceptor-ref name="org.jboss.ejb3.tx.BMTTxInterceptorFactory"/>
         <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
      </bind>
      <bind pointcut="execution(public * $instanceof{javax.ejb.SessionSynchronization}->*(..))">
         <interceptor-ref name="org.jboss.ejb3.stateful.SessionSynchronizationInterceptor"/>
      </bind>
      <bind pointcut="execution(public * *->*(..))">
         <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
         <interceptor-ref name="org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor"/>
      </bind>

      <bind pointcut="execution(public * *->*(..))">
         <interceptor-ref name="org.kdr.interceptor.security.KDRServerSecurityInterceptor"/>
      </bind>

      <bind pointcut="execution(public * @org.jboss.ejb3.annotation.Clustered->*(..)) AND !execution(public * *->@javax.ejb.Remove(..))">
         <interceptor-ref name="org.jboss.ejb3.cache.StatefulReplicationInterceptor"/>
      </bind>

      <bind pointcut="execution(public * *->*(..))">
         <!-- 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>
   </domain>

   <domain name="KDR Stateful Bean" extends="KDR Base Stateful Bean" inheritBindings="true">
      <!-- NON Clustered cache configuration -->
      <annotation expr="class(*) AND !class(@org.jboss.ejb3.annotation.Cache) AND !class(@org.jboss.ejb3.annotation.Clustered)">
         @org.jboss.ejb3.annotation.Cache ("SimpleStatefulCache")
      </annotation>
      <annotation expr="class(*) AND !class(@org.jboss.ejb3.annotation.PersistenceManager) AND !class(@org.jboss.ejb3.annotation.Clustered)">
         @org.jboss.ejb3.annotation.PersistenceManager ("StatefulSessionFilePersistenceManager")
      </annotation>
      <annotation expr="class(*) AND !class(@org.jboss.ejb3.annotation.CacheConfig) AND !class(@org.jboss.ejb3.annotation.Clustered)">
         @org.jboss.ejb3.annotation.CacheConfig (maxSize=100000, idleTimeoutSeconds=300, removalTimeoutSeconds=0)
      </annotation>

      <!-- Clustered cache configuration -->
      <annotation expr="class(*) AND !class(@org.jboss.ejb3.annotation.Cache) AND class(@org.jboss.ejb3.annotation.Clustered)">
         @org.jboss.ejb3.annotation.Cache ("StatefulTreeCache")
      </annotation>
      <annotation expr="class(*) AND !class(@org.jboss.ejb3.annotation.CacheConfig) AND class(@org.jboss.ejb3.annotation.Clustered)">
         @org.jboss.ejb3.annotation.CacheConfig (name="sfsb-cache", maxSize=100000, idleTimeoutSeconds=300, removalTimeoutSeconds=0)
      </annotation>
   </domain>

   <domain name="KDR JACC Stateful 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="JACC 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"/>
      </bind>
      <bind pointcut="execution(public * *->@javax.ejb.Remove(..))">
         <interceptor-ref name="org.jboss.ejb3.stateful.StatefulRemoveFactory"/>
      </bind>
      <bind pointcut="execution(public * *->*(..))">
         <interceptor-ref name="org.jboss.ejb3.stateful.StatefulInstanceInterceptor"/>
         <interceptor-ref name="org.jboss.ejb3.tx.BMTTxInterceptorFactory"/>
         <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
      </bind>
      <bind pointcut="execution(public * $instanceof{javax.ejb.SessionSynchronization}->*(..))">
         <interceptor-ref name="org.jboss.ejb3.stateful.SessionSynchronizationInterceptor"/>
      </bind>

      <bind pointcut="execution(public * *->*(..))">
         <interceptor-ref name="org.kdr.interceptor.security.KDRServerSecurityInterceptor"/>
      </bind>

      <bind pointcut="execution(public * *->*(..))">
         <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
         <interceptor-ref name="org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor"/>
         <!-- interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/ -->
         <stack-ref name="EJBInterceptors"/>
      </bind>

      <bind pointcut="execution(public * @org.jboss.ejb3.annotation.Clustered->*(..)) AND !execution(public * *->@javax.ejb.Remove(..))">
         <interceptor-ref name="org.jboss.ejb3.cache.StatefulReplicationInterceptor"/>
      </bind>

      <annotation expr="class(*) AND !class(@org.jboss.ejb3.annotation.Pool)">
         @org.jboss.ejb3.annotation.Pool (value="ThreadlocalPool", maxSize=30, timeout=10000)
      </annotation>

      <!-- NON Clustered cache configuration -->
      <annotation expr="class(*) AND !class(@org.jboss.ejb3.annotation.Cache) AND !class(@org.jboss.ejb3.annotation.Clustered)">
         @org.jboss.ejb3.annotation.Cache ("SimpleStatefulCache")
      </annotation>
      <annotation expr="class(*) AND !class(@org.jboss.ejb3.annotation.PersistenceManager) AND !class(@org.jboss.ejb3.annotation.Clustered)">
         @org.jboss.ejb3.annotation.PersistenceManager ("StatefulSessionFilePersistenceManager")
      </annotation>
      <annotation expr="class(*) AND !class(@org.jboss.ejb3.annotation.CacheConfig) AND !class(@org.jboss.ejb3.annotation.Clustered)">
         @org.jboss.ejb3.annotation.CacheConfig (maxSize=100000, idleTimeoutSeconds=300, removalTimeoutSeconds=0)
      </annotation>

      <!-- Clustered cache configuration -->
      <annotation expr="class(*) AND !class(@org.jboss.ejb3.annotation.Cache) AND class(@org.jboss.ejb3.annotation.Clustered)">
         @org.jboss.ejb3.annotation.Cache ("StatefulTreeCache")
      </annotation>
      <annotation expr="class(*) AND !class(@org.jboss.ejb3.annotation.CacheConfig) AND class(@org.jboss.ejb3.annotation.Clustered)">
         @org.jboss.ejb3.annotation.CacheConfig (name="sfsb-cache", maxSize=100000, idleTimeoutSeconds=300, removalTimeoutSeconds=0)
      </annotation>
   </domain>

   <domain name="KDR Embedded Stateful Bean" extends="KDR Base Stateful Bean" inheritBindings="true">
      <!-- NON Clustered cache configuration -->
      <annotation expr="class(*) AND !class(@org.jboss.ejb3.annotation.Cache)">
         @org.jboss.ejb3.annotation.Cache ("NoPassivationCache")
      </annotation>

   </domain>

   <domain name="KDR Message Driven Bean" extends="Intercepted Bean" inheritBindings="true">
      <bind pointcut="execution(public * *->*(..))">
         <interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
         <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
      </bind>

      <bind pointcut="execution(public * *->*(..))">
         <interceptor-ref name="org.kdr.interceptor.security.KDRServerSecurityInterceptor"/>
      </bind>

      <!-- TODO: Authorization? -->
      <bind pointcut="execution(public * *->*(..))">
         <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="StrictMaxPool", maxSize=15, timeout=10000)
      </annotation>
   </domain>

   <domain name="KDR Consumer Bean" extends="Intercepted Bean" inheritBindings="true">
      <bind pointcut="execution(public * *->*(..))">
         <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
      </bind>
      <bind pointcut="execution(public * *->*(..))">
         <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"/>
      </bind>
      <bind pointcut="execution(public * *->*(..)) AND (has(* *->@org.jboss.ejb3.annotation.CurrentMessage(..)) OR hasfield(* *->@org.jboss.ejb3.annotation.CurrentMessage))">
         <interceptor-ref name="org.jboss.ejb3.mdb.CurrentMessageInjectorInterceptorFactory"/>
      </bind>

      <bind pointcut="execution(public * *->*(..))">
         <interceptor-ref name="org.kdr.interceptor.security.KDRServerSecurityInterceptor"/>
      </bind>

      <bind pointcut="execution(public * *->*(..))">
         <!-- 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="StrictMaxPool", maxSize=15, timeout=10000)
      </annotation>
   </domain>

   <domain name="KDR Service Bean" extends="Intercepted Bean" inheritBindings="true">
      <bind pointcut="execution(public * *->*(..))">
         <interceptor-ref name="org.jboss.ejb3.ENCPropagationInterceptor"/>
      </bind>
      <bind pointcut="!execution(* *->create()) AND !execution(* *->start()) AND !execution(*->new(..)) AND !execution(* *->stop()) AND !execution(* *->destroy())">
         <interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
      </bind>
      <bind pointcut="execution(public * @org.jboss.ejb3.annotation.SecurityDomain->*(..)) AND !execution(* *->create()) AND !execution(* *->start()) AND !execution(* *->stop()) AND !execution(* *->destroy())">
         <interceptor-ref name="Basic Authorization"/>
      </bind>
      <bind pointcut="execution(public * *->*(..)) AND !execution(* *->create()) AND !execution(* *->start()) AND !execution(* *->stop()) AND !execution(* *->destroy())">
         <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
      </bind>

      <bind pointcut="execution(public * *->*(..))">
         <interceptor-ref name="org.kdr.interceptor.security.KDRServerSecurityInterceptor"/>
      </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.tx.BMTTxInterceptorFactory"/>
         <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
         <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
      </bind>

      <bind pointcut="execution(public * *->*(..)) AND !execution(* *->create()) AND !execution(* *->start()) AND !execution(* *->stop())">
         <!-- interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/ -->
         <stack-ref name="EJBInterceptors"/>
      </bind>
   </domain>

   <domain name="KDR JACC Service Bean" extends="Intercepted Bean" inheritBindings="true">
      <bind pointcut="execution(public * *->*(..))">
         <interceptor-ref name="org.jboss.ejb3.ENCPropagationInterceptor"/>
      </bind>
      <bind pointcut="!execution(* *->create()) AND !execution(* *->start()) AND !execution(*->new(..)) AND !execution(* *->stop()) AND !execution(* *->destroy())">
         <interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
      </bind>
      <bind pointcut="execution(public * @org.jboss.ejb3.annotation.SecurityDomain->*(..)) AND !execution(* *->create()) AND !execution(* *->start()) AND !execution(* *->stop()) AND !execution(* *->destroy())">
         <interceptor-ref name="Basic Authorization"/>
      </bind>
      <bind pointcut="execution(public * *->*(..)) AND !execution(* *->create()) AND !execution(* *->start()) AND !execution(* *->destroy())">
         <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
      </bind>

      <bind pointcut="execution(public * *->*(..))">
         <interceptor-ref name="org.kdr.interceptor.security.KDRServerSecurityInterceptor"/>
      </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.tx.BMTTxInterceptorFactory"/>
         <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
         <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
      </bind>
      <bind pointcut="execution(public * *->*(..)) AND !execution(* *->create()) AND !execution(* *->start())">
         <!-- interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/ -->
         <stack-ref name="EJBInterceptors"/>
      </bind>
   </domain>
   
   <!-- End KDR Additions -->


 
The client side interceptor: 
 
import java.io.Serializable;
import org.apache.commons.discovery.tools.DiscoverSingleton;
import org.jboss.aop.advice.Interceptor;
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.util.PayloadKey;
import org.kdr.resource.ResourceCache;
import org.kdr.security.SecurityUtils;
import org.kdr.security.user.UserContext;
 
public class KDRClientSecurityInterceptor implements Interceptor, Serializable {
 
     private static final long serialVersionUID = 1L;
 
     public String getName() {
          return getClass().getSimpleName();
     }
 
     public Object invoke(Invocation invocation) throws Throwable {
          ResourceCache cache = (ResourceCache) DiscoverSingleton
                    .find(ResourceCache.class);
          UserContext context = (UserContext) cache
                    .getResource(SecurityUtils.USER_CTX_KEY);
          invocation.getMetaData().addMetaData("KDR", SecurityUtils.USER_CTX_KEY, //$NON-NLS-1$
                    context.getName(), PayloadKey.AS_IS);
          return invocation.invokeNext();
     }
 
}
 

 
The server side interceptor:
 
import java.io.Serializable;
import org.jboss.aop.advice.Interceptor;
import org.jboss.aop.joinpoint.Invocation;
import org.kdr.security.SecurityUtils;
 
public class KDRServerSecurityInterceptor implements Interceptor, Serializable {
 
     private static final long serialVersionUID = 1L;
 
     public String getName() {
          return getClass().getSimpleName();
     }
 
     public Object invoke(Invocation invocation) throws Throwable {
          String name = (String) invocation.getMetaData("KDR", //$NON-NLS-1$
                    SecurityUtils.USER_CTX_KEY);
          SecurityToken.setUserContextName(name);
          return invocation.invokeNext();
     }
 
}
 

 
I am testing this out on an existing SLSB that contains the following annotations:
 
@Stateless
@Clustered(loadBalancePolicy = "org.jboss.ha.client.loadbalance.RandomRobin", partition = "KDR")
@Local( { LocationManagementLocal.class })
@LocalBinding(jndiBinding = "kdr/local/LocationManagement")
@Remote( { LocationManagementRemote.class })
@RemoteBinding(interceptorStack = "KDRClusteredStatelessSessionClientInterceptors", jndiBinding = "kdr/remote/LocationManagement")
@AspectDomain("KDR Stateless Bean")
public class LocationManagementBean implements LocationManagementLocal,
          LocationManagementRemote, Serializable {
 

 
On the first attempt, it seems that the custom client interceptor stack's binding is being ignored by JBoss. When I inspected it on the proxy in the client it contained the ClusteredStatelessSessionClientInterceptors stack.The server side configuration worked with the new configuration.
 
I then copied the interceptor-ref for the custom interceptor to that stack and had no difficulties. Is this a known issue? I would prefer to create a custom client side interceptor stack so I don't interfere with anything deployed that is not associated with my application.

--------------------------------------------------------------

To reply to this message visit the message page: http://community.jboss.org/message/522166#522166




More information about the jboss-user mailing list