/** * Unbind thread. */ protected void unbindThread(ClassLoader oldContextClassLoader) { Thread.currentThread().setContextClassLoader(oldContextClassLoader); oldContextClassLoader = null; DirContextURLStreamHandler.unbind(); }
public void doStart() throws Exception { // See the note of TomcatContainer::addContext container.addContext(this); // Is it necessary - doesn't Tomcat Embedded take care of it? // super.start(); //register the classloader <> dir context association so that tomcat's jndi based getResources works. DirContext resources = context.getResources(); DirContextURLStreamHandler.bind(classLoader, resources); log.debug("TomcatWebAppContext started for " + path); }
/** * Creates a new URLStreamHandler instance with the specified protocol. * Will return null if the protocol is not <code>jndi</code>. * * @param protocol the protocol (must be "jndi" here) * @return a URLStreamHandler for the jndi protocol, or null if the * protocol is not JNDI */ @Override public URLStreamHandler createURLStreamHandler(String protocol) { if (protocol.equals("jndi")) { return new DirContextURLStreamHandler(); } else { return null; } }
/** * Opens a connection to the object referenced by the <code>URL</code> * argument. */ @Override protected URLConnection openConnection(URL u) throws IOException { DirContext currentContext = this.context; if (currentContext == null) currentContext = get(); return new DirContextURLConnection(currentContext, u); }
/** * Unbind thread. */ protected void unbindThread(ClassLoader oldContextClassLoader) { if (isUseNaming()) { ContextBindings.unbindThread(this, this); } DirContextURLStreamHandler.unbindThread(); Thread.currentThread().setContextClassLoader(oldContextClassLoader); }
/** * Bind current thread, both for CL purposes and for JNDI ENC support * during : startup, shutdown and realoading of the context. * * @return the previous context class loader */ protected ClassLoader bindThread() { ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader(); if (getResources() == null) return oldContextClassLoader; if (getLoader().getClassLoader() != null) { Thread.currentThread().setContextClassLoader (getLoader().getClassLoader()); } DirContextURLStreamHandler.bindThread(getResources()); if (isUseNaming()) { try { ContextBindings.bindThread(this, this); } catch (NamingException e) { // Silent catch, as this is a normal case during the early // startup stages } } return oldContextClassLoader; }
/** * Opens a connection to the object referenced by the <code>URL</code> * argument. */ @Override protected URLConnection openConnection(URL u) throws IOException { DirContext currentContext = this.context; if (currentContext == null) currentContext = get(); return new DirContextURLConnection(currentContext, u); }
/** * Unbind thread. */ protected void unbindThread(ClassLoader oldContextClassLoader) { if (isUseNaming()) { ContextBindings.unbindThread(this, this); } DirContextURLStreamHandler.unbindThread(); Thread.currentThread().setContextClassLoader(oldContextClassLoader); }
/** * Bind current thread, both for CL purposes and for JNDI ENC support * during : startup, shutdown and realoading of the context. * * @return the previous context class loader */ protected ClassLoader bindThread() { ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader(); if (getResources() == null) return oldContextClassLoader; if (getLoader().getClassLoader() != null) { Thread.currentThread().setContextClassLoader (getLoader().getClassLoader()); } DirContextURLStreamHandler.bindThread(getResources()); if (isUseNaming()) { try { ContextBindings.bindThread(this, this); } catch (NamingException e) { // Silent catch, as this is a normal case during the early // startup stages } } return oldContextClassLoader; }
public void doStop() throws Exception { statsProvider = null; container.removeContext(this); DirContextURLStreamHandler.unbind(classLoader); // No more logging will occur for this ClassLoader. Inform the LogFactory to avoid a memory leak. // LogFactory.release(classLoader); log.debug("TomcatWebAppContext stopped"); }
public void doStart() throws Exception { // See the note of TomcatContainer::addContext container.addContext(this); // Is it necessary - doesn't Tomcat Embedded take care of it? // super.start(); //register the classloader <> dir context association so that tomcat's jndi based getResources works. DirContext resources = context.getResources(); if (resources == null) { throw new IllegalStateException("JNDI environment was not set up correctly due to previous error"); } DirContextURLStreamHandler.bind(classLoader, resources); if (context instanceof StandardContext) statsProvider = new ModuleStats((StandardContext)context); log.debug("TomcatWebAppContext started for " + path); }
/** * Creates a new URLStreamHandler instance with the specified protocol. * Will return null if the protocol is not <code>jndi</code>. * * @param protocol the protocol (must be "jndi" here) * @return a URLStreamHandler for the jndi protocol, or null if the * protocol is not JNDI */ public URLStreamHandler createURLStreamHandler(String protocol) { if (protocol.equals("jndi")) { return new DirContextURLStreamHandler(); } else { return null; } }
/** * Opens a connection to the object referenced by the <code>URL</code> * argument. */ protected URLConnection openConnection(URL u) throws IOException { DirContext currentContext = this.context; if (currentContext == null) currentContext = get(); return new DirContextURLConnection(currentContext, u); }
/** * Unbind thread. */ protected void unbindThread(ClassLoader oldContextClassLoader) { if (isUseNaming()) { ContextBindings.unbindThread(this, this); } DirContextURLStreamHandler.unbindThread(); Thread.currentThread().setContextClassLoader(oldContextClassLoader); }
/** * Bind current thread, both for CL purposes and for JNDI ENC support * during : startup, shutdown and realoading of the context. * * @return the previous context class loader */ protected ClassLoader bindThread() { ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader(); if (getResources() == null) return oldContextClassLoader; if (getLoader().getClassLoader() != null) { Thread.currentThread().setContextClassLoader (getLoader().getClassLoader()); } DirContextURLStreamHandler.bindThread(getResources()); if (isUseNaming()) { try { ContextBindings.bindThread(this, this); } catch (NamingException e) { // Silent catch, as this is a normal case during the early // startup stages } } return oldContextClassLoader; }
public void doStop() throws Exception { container.removeContext(this); DirContextURLStreamHandler.unbind(classLoader); // No more logging will occur for this ClassLoader. Inform the LogFactory to avoid a memory leak. // LogFactory.release(classLoader); log.debug("TomcatWebAppContext stopped"); }
/** * Bind current thread, both for CL purposes and for JNDI ENC support * during : startup, shutdown and realoading of the context. * * @return the previous context class loader */ protected ClassLoader bindThread() { ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader(); if (getResources() == null) return oldContextClassLoader; if (getLoader().getClassLoader() != null) { Thread.currentThread().setContextClassLoader (getLoader().getClassLoader()); } DirContextURLStreamHandler.bind(getResources()); return oldContextClassLoader; }
/** * Creates a new URLStreamHandler instance with the specified protocol. * Will return null if the protocol is not <code>jndi</code>. * * @param protocol the protocol (must be "jndi" here) * @return a URLStreamHandler for the jndi protocol, or null if the * protocol is not JNDI */ public URLStreamHandler createURLStreamHandler(String protocol) { if (protocol.equals("jndi")) { return new DirContextURLStreamHandler(); } else { return null; } }
/** * Opens a connection to the object referenced by the <code>URL</code> * argument. */ @Override protected URLConnection openConnection(URL u) throws IOException { DirContext currentContext = this.context; if (currentContext == null) currentContext = get(); return new DirContextURLConnection(currentContext, u); }
/** * Unbind thread. */ protected void unbindThread(ClassLoader oldContextClassLoader) { if (isUseNaming()) { ContextBindings.unbindThread(this, this); } DirContextURLStreamHandler.unbindThread(); Thread.currentThread().setContextClassLoader(oldContextClassLoader); }