Hi

I need help wrt injecting other non ejb objects in EJBs.

I have a singleton class(ConfigurationManager) as below:

@Singleton
public class ConfigurationManager {
    private org.apache.commons.configuration.Configuration conf;

    public void setConf(org.apache.commons.configuration.Configuration
aConf) {
        conf = aConf;
    }

    public String getConfigValue(String key) {
        return conf.getString(key);
    }
}

I would like to inject Configuration to the above ConfigurationManager only
once so that I can able to get the value for a given configuration key
anywhere across the application using the getConfigValue(String key) method.

I am using a standalone application with a Main class having a main method.
In the main method I am creating the Configuration object with a helper
method, available in a different 3rd party jar file.
Now my question is, how can I able to inject the Configuration object to
the ConfigurationManager.

One way I am doing for now:

In my Main class I am creating an instance of the Manager i.e
@EJB
    private ConfigurationManager configurationManager;

And in the main method I wrote the following 3 lines.

EJBContainer.createEJBContainer(properties).getContext().bind("inject",
this);
            Configuration aConf = new MapConfiguration(properties);
            configurationManager.setConf(aConf);


Is there any other approach available?


Hope you understood the scenario.
Sorry if I have confused you... :)














-- 
Thanks and Regards
N Radhakrishna Kalyan

P:  +46 733 312 584
http://about.me/nrkkalyan
<http://about.me/nrkkalyan>

Reply via email to