For Programmers: Free Programming Magazines  


Home > Archive > Java Beans > March 2004 > ServiceLocator pattern & dynamic Context.PROVIDER_URL









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author ServiceLocator pattern & dynamic Context.PROVIDER_URL
carlo dainese

2004-03-19, 8:45 pm

Hi folks,
my question it's about the service locator pattern.
In this pattern the helper class that does by locator, need to set the
provider url (ie: t3://localhost:7001 in weblogic environment). How is
possible to pass this url without wire it in the code?
I'm thinking about this: properties.put(Context.PROVIDER_URL,
getEjbServer()); Because ServiceLocator's class isn't a ejb but it's
present in the ejb module, is there any specification in the ejb-jar
the permit a reference of a resource for the whole module? Must I use
a System.getProperty approach?
Thank in advance.
Carlo
carlo dainese

2004-03-19, 8:45 pm

carlo.dainese@infocamere.it (carlo dainese) wrote in message news:<444035a0.0402130214.42faf7a2@posting.google.com>...
> Hi folks,
> my question it's about the service locator pattern.
> In this pattern the helper class that does by locator, need to set the
> provider url (ie: t3://localhost:7001 in weblogic environment). How is
> possible to pass this url without wire it in the code?
> I'm thinking about this: properties.put(Context.PROVIDER_URL,
> getEjbServer()); Because ServiceLocator's class isn't a ejb but it's
> present in the ejb module, is there any specification in the ejb-jar
> the permit a reference of a resource for the whole module? Must I use
> a System.getProperty approach?
> Thank in advance.
> Carlo


This is a self-response!
Well, the problem doesn't exist, because the ServiceLocator class is
used by the presentation layer. It's possible to use, in example, the
servlet context to read a init parm from the web.xml deployed in the
application's war.
Daniel Rohe

2004-03-19, 8:45 pm


"carlo dainese" <carlo.dainese@infocamere.it> schrieb im Newsbeitrag
news:444035a0.0402130214.42faf7a2@posting.google.com...
> Hi folks,
> my question it's about the service locator pattern.
> In this pattern the helper class that does by locator, need to set the
> provider url (ie: t3://localhost:7001 in weblogic environment). How is
> possible to pass this url without wire it in the code?
> I'm thinking about this: properties.put(Context.PROVIDER_URL,
> getEjbServer()); Because ServiceLocator's class isn't a ejb but it's
> present in the ejb module, is there any specification in the ejb-jar
> the permit a reference of a resource for the whole module? Must I use
> a System.getProperty approach?
> Thank in advance.
> Carlo


Another approach is to put a jndi.properties into the classpath (i.e default
package) which contains the properties:

java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
java.naming.provider.url=t3://localhost:7001
java.naming.security.principal=<username>
java.naming.security.credentials=<password>

The class InitialContext searches for the properties file and loads the
properties. During deployment you can change the properties.

mfg
Daniel


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com