users@glassfish.java.net

Re: Pass params to Message Driven Bean (MDB)

From: <glassfish_at_javadesktop.org>
Date: Mon, 17 Nov 2008 23:48:20 PST

Here goes code snippet:

public class GenericControlManagerImpl implements MpccStartPoint, MessageDrivenBean {
    private static final Logger log = Logger.getLogger(GenericControlManagerImpl.class);
    private AppMultiPartyCallControlFacadeConfig config;

    public GenericControlManagerImpl() {
        config = new AppMultiPartyCallControlFacadeConfig();
        log.info("GenericControlManagerImpl created successfully");
    }
....
}

constructor of AppMultiPartyCallControlFacadeConfig:

    public AppMultiPartyCallControlFacadeConfig() {
        try{
        Context initCtx = new InitialContext();
        Context myEnv = (Context) initCtx.lookup("java:comp/env");

        statementsPerConnection.setValue((Integer) myEnv.lookup(statementsPerConnection.getValueName()));
 ...
        connectionString.setValue((String) myEnv.lookup(connectionString.getValueName()));
        } catch(NamingException e){
            log.error("Can not read configuration, using defaults", e);
        }
        log.info("Configuration of ejb application readed successfully");
    }

Names are silly a bit, I know :)

Examples in specification was related to session beans only...
full code attached
[Message sent by forum member 'theme_theme' (theme_theme)]

http://forums.java.net/jive/thread.jspa?messageID=317183