views:

1597

answers:

1

I am trying to understand some EJB 3 code running in JBoss 4.3.

We've got an ejb3-interceptors-aop.xml file configured in JBoss with some MDB configuration and then we've got the MDB Java class.

What I'd like to understand is when and how does the MDB get "bound" to the MQ? That is, when/how does the MDB start listening to the MQ queue?

Does JBoss at startup read the ejb3-interceptors-aop.xml file and then find the class with the AspectDomain annotation equal to "GatewayMDB" and "bind" to the MQ queue at startup?


XML in ejb3-interceptors-aop.xml:

   <domain name="GatewayMDB">
      <bind pointcut="execution(public * @javax.annotation.security.RunAs->*(..))">
         <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
      </bind>
      <bind pointcut="execution(public * *->*(..))">
         <interceptor-ref name="org.jboss.ejb3.stateless.StatelessInstanceInterceptor"/>
         <interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
         <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
         <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
         <interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
      </bind>
      <annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
         @org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.StrictMaxPool.class, maxSize=30, timeout=10000)
      </annotation>
      <annotation expr="!class(@org.jboss.annotation.ejb.DefaultActivationSpecs)">
         @org.jboss.annotation.ejb.DefaultActivationSpecs ({@javax.ejb.ActivationConfigProperty(propertyName = "channel", propertyValue = "SYSTEM.DEF.SVRCONN"), @javax.ejb.ActivationConfigProperty(propertyName = "hostName", propertyValue = "10.10.10.10"), @javax.ejb.ActivationConfigProperty(propertyName = "queueManager", propertyValue = "QM"), @javax.ejb.ActivationConfigProperty(propertyName = "port", propertyValue = "1419"),@javax.ejb.ActivationConfigProperty(propertyName = "transportType", propertyValue = "CLIENT")})
      </annotation>
   </domain>


MDB class:

@MessageDriven(name = "BridgeMDB", activationConfig = {
        @ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "true"),
        @ActivationConfigProperty(propertyName = "destination", propertyValue = "TO.WLS.LQUEUE.BG"),
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
        @ActivationConfigProperty(propertyName = "maxPoolDepth", propertyValue = "1") })
@ResourceAdapter("wmq.jmsra.rar")
@AspectDomain("GatewayMDB") 
@Interceptors(SpringBeanAutowiringInterceptor.class)
@TransactionManagement(TransactionManagementType.CONTAINER)
public class BridgeMDB implements MessageListener {
    private static Logger logger = Logger.getLogger(BridgeMDB.class);


    @Autowired
    private MessageProcessor messageProcessor;
    @Autowired
    private MessageTranslator messageTranslator;

    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void onMessage(Message message) {
        ...
    }

}
A: 

Disclaimer: this is a supposition, since I don't know the jboss code.


The common way of processing class files in java is to read them through the class path (in this case it would be at load-time) and construct some sort of metadata for each class.

Then, when the application bootstraps the container will read the class's metadatada to wire/inject/configure the appropriate attributes that were defined within the class.

As for the xml, most of the jboss configuration is static AFAIK, ie, you have to restart the app server in order for changes to take effect.

So all in all, I would say that your observation is correct.

Miguel Ping