This content has been marked as final.
Show 1 reply
-
1. Re: locate services with service locator?
rheydenr02 Dec 17, 2008 4:23 AM (in response to rheydenr02)I found my own solution:
@SuppressWarnings("unchecked") public <T> T lookup(Class<T> 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; }
Errorhandling has to be improved, but this version works for me.