Ok... So the thing I dont get is why people feel the need to create a completly
new Properties object... Instead use the SystemProperties, and insepect it for
adequate default values. This will allow people to set up environment variables
to populate the correct thing making changing the JNDI stuff transparent to
code... This is what we do in our code, and it works very nicely:
public static Context getInitialContext() {
if (initialContext==null) {
synchronized(theInitialContextMonitor) {
if (initialContext==null) {
Properties env = System.getProperties();
if (env.get("java.naming.factory.initial")==null) {
env.put("java.naming.factory.initial",
"com.sun.jndi.rmi.registry.RegistryContextFactory");
}
if (env.get("java.naming.provider.url")==null) {
env.put("java.naming.provider.url", "rmi://localhost:1099");
}
try{
initialContext = new InitialContext(env);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
return initialContext;
}
So it assumes that things are running locally if given no other informaiton,
otherwise, it uses the system properties to set stuff up...
Here's an example of setting things up so that it will talk to a remote machine:
java -Djava.naming.provider.url=rmi://192.168.0.2:1099
com.kovair.webdialog.manager.session.SessionList
As far as the narrow stuff goes, thats the new way to do things that makes it
compatible with both RMI/JRMP and RMI/IIOP... I suppose at some point we'll move
our code over to useing that exclusively...
-gabe
Javier Borrajo wrote:
> >Thanks for the nice piece of code, but it still doesn't solve the problem
> if
> >the EJB vendor requires initial context properties beyond just the factory
> >name and url. That's the core of the problem. There appears to be no spec
> >on how vendor's implement JNDI interfaces to their servers.
>
> It is true you cannot have 100% portable EJB clients.
> There are ways to mitigate the problem, as that code shows.
> Anyway EJB clients are "more" portable than what you get
> with any other server-side component framework.
>
> Regards
>
> Javier
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff EJB-INTEREST". For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
begin: vcard
fn: Gabriel Lawrence
n: Lawrence;Gabriel
org: Kovair<br>The power to .wow your customers.
adr: 2 North First Street ;;Suite 212;San Jose;Ca;95113-1202;USA
email;internet: [EMAIL PROTECTED]
title: Architect
tel;work: (408) 491-9731
note: The power to .wow your customers.
x-mozilla-cpt: ;0
x-mozilla-html: FALSE
version: 2.1
end: vcard