2 Replies Latest reply on Dec 22, 2005 4:21 PM by William DeCoste

    Configuration injection in EJB3

    Jonn Beames Newbie

      I've got a happily working EJB3 MBD set up via the @MessageDriven and @ActivationConfigProperty annotations. I'm also using an @EJB annotation to inject a stateless session bean for entity access. Once again, EJB 3 has proven itself very easy to work with.

      The only unmet requirement of my MDB at this time is an externally configurable string variable. This variable tells the bean where to create a file it will write out data to. The location the file is written to needs to be different between dev, test, and stage environments, so I'd like to place the value in a config or property file.

      What's the best way to do this in EJB3? I'm hoping there is a simple spring app-context like way to do this. I have no previous EJB experience, but I understand there is an ejb-jar.xml file used in the older specs for configuring beans. I'm guessing there is something similar in EJB3 but I haven't found a description of how to use it in JBoss-EJB3.

      Would ejb-jar.xml be the best way to add an injectable string value to my MDB in EJB3? If so, can someone point me to instructions or documentation on doing this? If using the ejb-jar.xml file, do I loose the ability to use the @ActivationConfigProperty annotation inside the bean (either annotation or xml configuration, but not both?)?

      Or is there another recommended way to inject configuration into an ejb3 bean?

      Thanks for the help,