Wednesday, December 17, 2008

a good lookup snippet

    @SuppressWarnings("unchecked")
public T lookup(Class clazz, final String pJndiName) {
T cs = null;
String jndiName = (pJndiName == null)
? jndiPrefix + clazz.getSimpleName() + "Bean/remote"
: pJndiName;

LOG.debug("Looking for "+jndiName);
try {
Object o = context.lookup(jndiName);
if (o == null) {
System.err.println("unable to find " + jndiName);
} else {
System.out.println("retrieved instance of "
+ o.getClass().getName());
}
cs = (T) PortableRemoteObject.narrow(o, clazz);

} catch (NamingException e) {
e.printStackTrace();
}
return cs;
}

Tuesday, December 16, 2008

Ouch!!! Dependency injection is incomplete!!!

i've found this blog post about remote ejb injection, and it makes me sad :_(