This content has been marked as final.
Show 1 reply
-
1. Re: deploying beans with the same name
jamesstrachan Aug 2, 2004 9:08 AM (in response to captrespect)Jon,
You obviously have to deploy the beans with different names and JNDI names to avoid conflict. Providing that you use a consistent naming structure such as :-ejb/customer1/bean1 ejb/customer1/bean2
with, for the second customer,ejb/customer2/bean1 ejb/customer2/bean2
then it is relatively easy to edit the DeploymentDescriptor for each customer with a global search and replace. Within the J2EE world, mapping to the new customer can be done by changing references in jboss.xml :-<session> <ejb-name>customer1/bean1</ejb-name> <ejb-ref> <ejb-ref-name>ejb/bean2</ejb-ref-name> <jndi-name>ejb/customer2/bean2</jndi-name> </ejb-ref> </session>
The other half of the problem is to produce the required JNDI name for access to different customers from a client outside the EJB world. I normally use a name factory for this, and enclose a partial code sample below :-public class myJndiNameFactory { public static final int BEAN1 = 1; public static final int BEAN2 = 2; private static String customerJndiRoot; public myJndiNameFactory() { customerJndiRoot = System.getProperty("customer.root"); } public String getJndiName( int logicalName ) throws InvalidLogicalNameException { switch ( logicalName ) { case BEAN1: { return "ejb/" + customerJndiRoot + "/bean1"; } // switch statements follow for each logical name. } } } None of this is a "magic wand", and does require consistency in the use of naming conventions and alterations to your existing codebase. But it's about the best that can be done. James