I do see the same behaviour on 4.2.2. Here's my MDB:

package org.myapp.ejb.impl;
  | 
  | import javax.ejb.ActivationConfigProperty;
  | import javax.ejb.EJB;
  | import javax.ejb.MessageDriven;
  | import javax.jms.Message;
  | import javax.jms.MessageListener;
  | import javax.persistence.PostRemove;
  | 
  | import org.apache.log4j.Logger;
  | import org.myapp.ejb.UserManager;
  | 
  | /**
  |  * MDB for testing injection of EJBs
  |  *  
  |  * @author Jaikiran Pai
  |  * @since
  |  */
  | @MessageDriven(activationConfig =
  | {
  | @ActivationConfigProperty(propertyName="destinationType",
  | propertyValue="javax.jms.Queue"),
  | @ActivationConfigProperty(propertyName="destination",
  | propertyValue="queue/A")
  | })
  | public class MyMDB implements MessageListener {
  | 
  |     private static Logger logger = Logger.getLogger(MyMDB.class);
  |     
  |     
  |     private UserManager userManager;
  |     
  |     public UserManager getUserManager() {
  |             return this.userManager;
  |     }
  |     
  |     @EJB
  |     public void setUserManager(UserManager userManager) {
  |             this.userManager = userManager;
  |     }
  | 
  |     /**
  |      * Default constructor
  |      *
  |      */
  |     public MyMDB() {
  |             System.out.println("In constructor of MDB");
  |     }
  | 
  |     /**
  |      *  
  |      */
  |     public void onMessage(Message arg0) {
  |             System.out.println("onMessage of MyMDB called");
  |             System.out.println("EJB is " + getUserManager());
  |             getUserManager().getUser((long)1);
  |             logger.info("onMessage of MyMDB called");
  |     }
  |     
  |     
  | 
  | }

A new instance of UserManagerBean gets injected everytime the onMessage method 
is invoked. I just glanced through the EJB spec and did not see any mention of 
this behaviour being mandated. You are right, the injection should have 
happened only if a new instance of the MDB was created instead of injecting the 
EJB on every call of onMessage.

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4139296#4139296

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4139296
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to