Well, there are many ways to do. Historically, and still heavily used, you have env entries.
Check out those 2 samples http://tomee.apache.org/examples-trunk/injection-of-env-entry/README.html http://tomee.apache.org/examples-trunk/custom-injection/README.html You can also define any custom resource in the tomee.xml file (TomEE will just do a new and inject it). Finally, as for the snippet you sent, I would recommend to use CDI and even better Deltaspike. It's also an Apache project and you can use it on TomEE because it's based on CDI. Check out that page which seems to be what you are looking for http://deltaspike.apache.org/configuration.html Hope that helps JLouis 2013/12/14 Radhakrishna Kalyan <[email protected]> > 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> > -- Jean-Louis
