[jboss-user] [EJB/JBoss] - Re: Accessing correct bean version if multiple EARs deployed
jaikiran
do-not-reply at jboss.com
Tue Jul 25 08:53:54 EDT 2006
You can add it to the web.xml file. Here's an extract from the dtd of the web.xml:
<!--
| The env-entry element contains the declaration of a web application's
| environment entry. The declaration consists of an optional
| description, the name of the environment entry, and an optional
| value. If a value is not specified, one must be supplied
| during deployment.
| -->
| <!ELEMENT env-entry (description?, env-entry-name, env-entry-value?,
| env-entry-type)>
|
| <!--
| The env-entry-name element contains the name of a web applications's
| environment entry. The name is a JNDI name relative to the
| java:comp/env context. The name must be unique within a web application.
|
| Example:
|
| <env-entry-name>minAmount</env-entry-name>
|
| Used in: env-entry
| -->
| <!ELEMENT env-entry-name (#PCDATA)>
|
| <!--
| The env-entry-type element contains the fully-qualified Java type of
| the environment entry value that is expected by the web application's
| code.
|
| The following are the legal values of env-entry-type:
|
| java.lang.Boolean
| java.lang.Byte
| java.lang.Character
| java.lang.String
| java.lang.Short
| java.lang.Integer
| java.lang.Long
| java.lang.Float
| java.lang.Double
|
| Used in: env-entry
| -->
| <!ELEMENT env-entry-type (#PCDATA)>
|
| <!--
| The env-entry-value element contains the value of a web application's
| environment entry. The value must be a String that is valid for the
| constructor of the specified type that takes a single String
| parameter, or for java.lang.Character, a single character.
|
| Example:
|
| <env-entry-value>100.00</env-entry-value>
|
| Used in: env-entry
| -->
| <!ELEMENT env-entry-value (#PCDATA)>
For more information, you can find the dtd at:
http://java.sun.com/dtd/web-app_2_3.dtd
So your entry will look like, in Apicio1-1-11.ear :
<env-entry>
| <description>Name of my application ear</description>
| <env-entry-name>earName</env-entry-name>
| <env-entry-value>Apicio1-1-11<env-entry-value>
| <env-entry-type>java.lang.String</env-entry-type>
| </env-entry>
And in Apicio1-2-0.ear it would be:
<env-entry>
| <description>Name of my application ear</description>
| <env-entry-name>earName</env-entry-name>
| <env-entry-value>Apicio1-2-0<env-entry-value>
| <env-entry-type>java.lang.String</env-entry-type>
| </env-entry>
You will have to change the value of this env-entry for each application ear, when you are deploying the application.
Your code, however would remain the same:
String earName = ctx.lookup("java:comp/env/earName");
| ctx.lookup(earName + "BeanClassName/local");
So for Apicio1-2-0.ear, the lookup of env-entry would return the value Apicio1-2-0 and for Apicio1-1-11.ear, it would return Apicio1-1-11
Try it out.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3960667#3960667
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3960667
More information about the jboss-user
mailing list