private Object lookup(final String s) throws NamingException { final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class); final Context jndiContext = containerSystem.getJNDIContext(); try { if (s.startsWith("java:") | s.startsWith("openejb:")) { return jndiContext.lookup(s); } else { return jndiContext.lookup("openejb/Resource/" + s); } } catch (final NameNotFoundException e) { return jndiContext.lookup("java:module/" + Strings.lastPart(getClassName(), '.')); } catch (final NamingException e) { throw (NamingException) new NamingException("could not look up " + s).initCause(e); } }
private Object lookup(final String s) throws NamingException { final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class); final Context jndiContext = containerSystem.getJNDIContext(); try { if (s.startsWith("java:") | s.startsWith("openejb:")) { return jndiContext.lookup(s); } else { return jndiContext.lookup("openejb/Resource/" + s); } } catch (final NameNotFoundException e) { return jndiContext.lookup("java:module/" + Strings.lastPart(getClassName(), '.')); } catch (final NamingException e) { throw (NamingException) new NamingException("could not look up " + s).initCause(e); } }
public Object getObject() throws NamingException { final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class); try { return containerSystem.getJNDIContext().lookup(jndiName); } catch (final NameNotFoundException e) { // EE.5.18: try using java:module/<shortName> prefix return containerSystem.getJNDIContext().lookup("java:module/" + Strings.lastPart(getClassName(), '.')); } catch (final NamingException e) { throw (NamingException) new NamingException("could not look up " + jndiName).initCause(e); } }
public Object getObject() throws NamingException { final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class); try { return containerSystem.getJNDIContext().lookup(jndiName); } catch (final NameNotFoundException e) { // EE.5.18: try using java:module/<shortName> prefix return containerSystem.getJNDIContext().lookup("java:module/" + Strings.lastPart(getClassName(), '.')); } catch (final NamingException e) { throw (NamingException) new NamingException("could not look up " + jndiName).initCause(e); } }
final String moduleName = "java:module/" + Strings.lastPart(ref.getClassName(), '.'); try { return new InitialContext().lookup(moduleName);
public Object getObjectInstance(Object object, Name name, Context context, Hashtable environment) throws Exception { Reference ref = (Reference) object; // the jndi context to use for the lookup (usually null which is the default context) String jndiProviderId = NamingUtil.getProperty(ref, NamingUtil.JNDI_PROVIDER_ID); // the jndi name String jndiName = NamingUtil.getProperty(ref, NamingUtil.JNDI_NAME); if (jndiName == null) { jndiName = buildJndiName(ref); } // look up the reference try { return lookup(jndiProviderId, jndiName); } catch (NameNotFoundException nnfe) { // EE.5.18: try using java:module/<shortName> prefix // 2nd try if (jndiName.startsWith("java:")) { try { return new InitialContext().lookup(jndiName); } catch (NameNotFoundException ignored) { } } // 3rd try if (ref.getClassName() != null) { try { return new InitialContext().lookup("java:module/" + Strings.lastPart(ref.getClassName(), '.')); } catch (NameNotFoundException ignored) { } } throw nnfe; } }