[jboss-user] [EJB 3.0] - Re: EJB 3.0 String injection at deploying time?
Marco.Pehla
do-not-reply at jboss.com
Tue Dec 12 08:20:35 EST 2006
So, finially it works. I've made a mistake and put the ejb-jar.xml file in the EAR archive instead of the JAR archive.
But I found out that it is much more easy to make a injection with the resource annotation.
inside the EJB3:
| ...
| @Resource(mappedName="java:comp/env/translationURL") private String translationURL;
| ...
| @WebMethod
| public doSomething() {
| System.out.println("injected String: " + translationURL);
| ...
| }//doSomething()
|
inside the ejb-jar.xml:
| ...
| <session>
| <ejb-name>YourClassName</ejb-name>
| <ejb-class>yourpackage.YourClassName</ejb-class>
| <env-entry>
| <env-entry-name>translationURL</env-entry-name>
| <env-entry-type>java.lang.String</env-entry-type>
| <env-entry-value>content of your String</env-entry-value>
| <injection-target>
| <injection-target-class>yourpackage.YourClassName</injection-target-class>
| <injection-target-name>translationURL</injection-target-name>
| </injection-target>
| </env-entry>
| </session>
| ...
|
That's all. Really simple.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3993063#3993063
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3993063
More information about the jboss-user
mailing list