/** * {@inheritDoc} */ public Object lookup(String name) throws NamingException { return getThreadContext().lookup(name); }
/** * Creates a new instance. */ public TomcatThreadContextListener() { ContextBindings.bindContext(OPENEJB_CONTEXT, new OpenEJBContext()); try { // someone decided to make the getThreadName package protected so we have to use reflection method = ContextBindings.class.getDeclaredMethod("getThreadName"); method.setAccessible(true); final Field threadNameBindingsField = ContextBindings.class.getDeclaredField("threadObjectBindings"); threadNameBindingsField.setAccessible(true); threadNameBindings = (Hashtable<Thread, Object>) threadNameBindingsField.get(null); } catch (final Exception e) { logger.error("Expected ContextBinding to have the method getThreadName()"); } }
/** * Gets current context deployment context. * * @return context of deployment * @throws NamingException for exception */ private Context getThreadContext() throws NamingException { final ThreadContext threadContext = ThreadContext.getThreadContext(); if (skipEjbContext(threadContext)) { return ContextBindings.getClassLoader(); } final Context context = threadContext.getBeanContext().getJndiEnc(); return context; }
/** * Creates a new instance. */ public TomcatThreadContextListener() { ContextBindings.bindContext(OPENEJB_CONTEXT, new OpenEJBContext()); boolean accessible = false; try { // someone decided to make the getThreadName package protected so we have to use reflection method = ContextBindings.class.getDeclaredMethod("getThreadName"); // accessible = method.isAccessible(); method.setAccessible(true); } catch (NoSuchMethodException e) { logger.error("Expected ContextBinding to have the method getThreadName()"); // } finally { // if (!accessible) { // method.setAccessible(accessible); // } } }
/** * {@inheritDoc} */ public void rebind(String name, Object obj) throws NamingException { getThreadContext().rebind(name, obj); }
/** * {@inheritDoc} */ public void unbind(final Name name) throws NamingException { getThreadContext().unbind(name); }
/** * {@inheritDoc} */ public void unbind(Name name) throws NamingException { getThreadContext().unbind(name); }
/** * {@inheritDoc} */ public Object lookup(final Name name) throws NamingException { return getThreadContext().lookup(name); }
/** * {@inheritDoc} */ public void rebind(final Name name, final Object obj) throws NamingException { getThreadContext().rebind(name, obj); }
/** * {@inheritDoc} */ public void close() throws NamingException { getThreadContext().close(); }
/** * {@inheritDoc} */ public Object lookup(Name name) throws NamingException { return getThreadContext().lookup(name); }
/** * {@inheritDoc} */ public void rebind(Name name, Object obj) throws NamingException { getThreadContext().rebind(name, obj); }
/** * {@inheritDoc} */ public Object lookup(final String name) throws NamingException { return getThreadContext().lookup(name); }
/** * {@inheritDoc} */ public void rebind(final String name, final Object obj) throws NamingException { getThreadContext().rebind(name, obj); }
/** * {@inheritDoc} */ public void bind(String name, Object obj) throws NamingException { getThreadContext().bind(name, obj); }
/** * {@inheritDoc} */ public void unbind(String name) throws NamingException { getThreadContext().unbind(name); }
/** * {@inheritDoc} */ public void close() throws NamingException { getThreadContext().close(); }
/** * {@inheritDoc} */ public void bind(final String name, final Object obj) throws NamingException { getThreadContext().bind(name, obj); }
/** * {@inheritDoc} */ public void bind(Name name, Object obj) throws NamingException { getThreadContext().bind(name, obj); }
/** * {@inheritDoc} */ public void bind(final Name name, final Object obj) throws NamingException { getThreadContext().bind(name, obj); }