cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/naming ContextBindings.java
glenn 2002/11/12 18:23:11 Modified:catalina/src/share/org/apache/catalina/core NamingContextListener.java StandardContext.java catalina/src/share/org/apache/naming ContextBindings.java Log: Bug fix for BUG #13364 A Web Application Context reload by the manager web application was causing named JNDI resources to disappear. A webapp reload needs to dump the webapp classloader, then recreate. The CL is bound to the naming context so the reload was issing a NamingContext STOP_EVENT and then a START_EVENT. This removed all the JNDI named resources but the code which runs at webapp startup which creates the JNDI named resources is not run on a reload. I fixed this by removing the START and STOP events and adding BEFORE_STOP_EVENT and AFTER_START_EVENT lifecycle events whose only purpose is to bind or unbind the ClassLoader to the JNDI context. Defined JNDI resources are now preserved on a web app reload. Revision ChangesPath 1.20 +43 -18 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/NamingContextListener.java Index: NamingContextListener.java === RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/NamingContextListener.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- NamingContextListener.java25 Jun 2002 22:29:23 - 1.19 +++ NamingContextListener.java13 Nov 2002 02:23:10 - 1.20 -293,26 +293,13 log(sm.getString(naming.namingContextCreationFailed, e)); } -// Binding the naming context to the class loader -if (container instanceof Context) { -// Setting the context in read only mode -ContextAccessController.setReadOnly(getName()); -try { -ContextBindings.bindClassLoader -(container, container, - ((Container) container).getLoader().getClassLoader()); -} catch (NamingException e) { -log(sm.getString(naming.bindFailed, e)); -} -} - if (container instanceof Server) { namingResources.addPropertyChangeListener(this); org.apache.naming.factory.ResourceLinkFactory.setGlobalContext (namingContext); try { ContextBindings.bindClassLoader -(container, container, +(container, container, this.getClass().getClassLoader()); } catch (NamingException e) { log(sm.getString(naming.bindFailed, e)); -321,9 +308,47 ((StandardServer) container).setGlobalNamingContext (namingContext); } +} else if (container instanceof Context) { +// Setting the context in read only mode +ContextAccessController.setReadOnly(getName()); +try { +ContextBindings.bindClassLoader +(container, container, + ((Container) container).getLoader().getClassLoader()); +} catch (NamingException e) { +log(sm.getString(naming.bindFailed, e)); +} } initialized = true; + +} else if (event.getType() == Lifecycle.AFTER_START_EVENT ) { +// Used at end of a Web Application Context reload +if (container instanceof Context) { +// Setting the context in read only mode +ContextAccessController.setReadOnly(getName()); +try { +ContextBindings.bindClassLoader +(container, container, + ((Container) container).getLoader().getClassLoader()); +} catch (NamingException e) { +log(sm.getString(naming.bindFailed, e)); +} +} + +} else if (event.getType() == Lifecycle.BEFORE_STOP_EVENT) { +// Used when starting a Web Application Context reload +if (!initialized) +return; + +// Setting the context in read/write mode +ContextAccessController.setWritable(getName(), container); + +if (container instanceof Context) { +ContextBindings.unbindClassLoader +(container, container, + ((Container) container).getLoader().getClassLoader()); +} } else if
cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/naming ContextBindings.java
remm2002/05/30 19:55:21 Modified:catalina/src/share/org/apache/naming ContextBindings.java Log: - Make the JNDI context available from webapp created CL (as long as one of the parents in the hierarchy is the webapp CL). - Patch submitted by David Haraburda david-tomcat at haraburda.com Revision ChangesPath 1.7 +31 -18 jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/ContextBindings.java Index: ContextBindings.java === RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/ContextBindings.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- ContextBindings.java 16 Apr 2002 00:42:10 - 1.6 +++ ContextBindings.java 31 May 2002 02:55:21 - 1.7 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/ContextBindings.java,v 1.6 2002/04/16 00:42:10 remm Exp $ - * $Revision: 1.6 $ - * $Date: 2002/04/16 00:42:10 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/ContextBindings.java,v 1.7 2002/05/31 02:55:21 remm Exp $ + * $Revision: 1.7 $ + * $Date: 2002/05/31 02:55:21 $ * * * @@ -76,7 +76,7 @@ * /ul * * @author Remy Maucherat - * @version $Revision: 1.6 $ $Date: 2002/04/16 00:42:10 $ + * @version $Revision: 1.7 $ $Date: 2002/05/31 02:55:21 $ */ public class ContextBindings { @@ -361,12 +361,16 @@ */ public static Context getClassLoader() throws NamingException { -Context context = (Context) clBindings.get -(Thread.currentThread().getContextClassLoader()); -if (context == null) -throw new NamingException -(sm.getString(contextBindings.noContextBoundToCL)); -return context; +ClassLoader cl = Thread.currentThread().getContextClassLoader(); +Context context = null; +do { +context = (Context) clBindings.get(cl); +if (context != null) { +return context; +} +} while ((cl = cl.getParent()) != null); +throw new NamingException +(sm.getString(contextBindings.noContextBoundToCL)); } @@ -375,12 +379,16 @@ */ static Object getClassLoaderName() throws NamingException { -Object name = -clNameBindings.get(Thread.currentThread().getContextClassLoader()); -if (name == null) -throw new NamingException -(sm.getString(contextBindings.noContextBoundToCL)); -return name; +ClassLoader cl = Thread.currentThread().getContextClassLoader(); +Object name = null; +do { +name = clNameBindings.get(cl); +if (name != null) { +return name; +} +} while ((cl = cl.getParent()) != null); +throw new NamingException +(sm.getString(contextBindings.noContextBoundToCL)); } @@ -388,8 +396,13 @@ * Tests if current class loader is bound to a context. */ public static boolean isClassLoaderBound() { -return (clBindings.containsKey -(Thread.currentThread().getContextClassLoader())); +ClassLoader cl = Thread.currentThread().getContextClassLoader(); +do { +if (clBindings.containsKey(cl)) { +return true; +} +} while ((cl = cl.getParent()) != null); +return false; } -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/naming ContextBindings.java
remm02/04/15 17:37:52 Modified:catalina/src/share/org/apache/naming ContextBindings.java Log: - Add unbindCL method allowing to specify the CL. Revision ChangesPath 1.5 +23 -7 jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/ContextBindings.java Index: ContextBindings.java === RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/ContextBindings.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ContextBindings.java 22 May 2001 20:10:36 - 1.4 +++ ContextBindings.java 16 Apr 2002 00:37:52 - 1.5 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/ContextBindings.java,v 1.4 2001/05/22 20:10:36 remm Exp $ - * $Revision: 1.4 $ - * $Date: 2001/05/22 20:10:36 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/ContextBindings.java,v 1.5 2002/04/16 00:37:52 remm Exp $ + * $Revision: 1.5 $ + * $Date: 2002/04/16 00:37:52 $ * * * @@ -76,7 +76,7 @@ * /ul * * @author Remy Maucherat - * @version $Revision: 1.4 $ $Date: 2001/05/22 20:10:36 $ + * @version $Revision: 1.5 $ $Date: 2002/04/16 00:37:52 $ */ public class ContextBindings { @@ -332,10 +332,26 @@ * @param token Security token */ public static void unbindClassLoader(Object name, Object token) { +unbindClassLoader(name, token, + Thread.currentThread().getContextClassLoader()); +} + + +/** + * Unbinds a naming context to a class loader. + * + * @param name Name of the context + * @param token Security token + */ +public static void unbindClassLoader(Object name, Object token, + ClassLoader classLoader) { if (ContextAccessController.checkSecurityToken(name, token)) { -clBindings.remove(Thread.currentThread().getContextClassLoader()); -clNameBindings.remove -(Thread.currentThread().getContextClassLoader()); +Object cl = clBindings.get(name); +if (cl != classLoader) { +return; +} +clBindings.remove(classLoader); +clNameBindings.remove(classLoader); } } -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/naming ContextBindings.java
remm02/04/15 17:42:10 Modified:catalina/src/share/org/apache/naming ContextBindings.java Log: - Fix incorrect check. Revision ChangesPath 1.6 +6 -6 jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/ContextBindings.java Index: ContextBindings.java === RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/ContextBindings.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ContextBindings.java 16 Apr 2002 00:37:52 - 1.5 +++ ContextBindings.java 16 Apr 2002 00:42:10 - 1.6 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/ContextBindings.java,v 1.5 2002/04/16 00:37:52 remm Exp $ - * $Revision: 1.5 $ - * $Date: 2002/04/16 00:37:52 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/ContextBindings.java,v 1.6 2002/04/16 00:42:10 remm Exp $ + * $Revision: 1.6 $ + * $Date: 2002/04/16 00:42:10 $ * * * @@ -76,7 +76,7 @@ * /ul * * @author Remy Maucherat - * @version $Revision: 1.5 $ $Date: 2002/04/16 00:37:52 $ + * @version $Revision: 1.6 $ $Date: 2002/04/16 00:42:10 $ */ public class ContextBindings { @@ -346,8 +346,8 @@ public static void unbindClassLoader(Object name, Object token, ClassLoader classLoader) { if (ContextAccessController.checkSecurityToken(name, token)) { -Object cl = clBindings.get(name); -if (cl != classLoader) { +Object n = clNameBindings.get(classLoader); +if (!(n.equals(name))) { return; } clBindings.remove(classLoader); -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/naming ContextBindings.java
remm01/05/22 13:10:42 Modified:catalina/src/share/org/apache/naming ContextBindings.java Log: - unbindThread(name) was inappropriately calling itself, instead of calling unbindThread(Object name, Object token). Patch submitted by Michael Amster (mamster at webeasy.com) Revision ChangesPath 1.4 +5 -5 jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/ContextBindings.java Index: ContextBindings.java === RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/ContextBindings.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ContextBindings.java 2001/01/25 18:35:15 1.3 +++ ContextBindings.java 2001/05/22 20:10:36 1.4 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/ContextBindings.java,v 1.3 2001/01/25 18:35:15 remm Exp $ - * $Revision: 1.3 $ - * $Date: 2001/01/25 18:35:15 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/ContextBindings.java,v 1.4 2001/05/22 20:10:36 remm Exp $ + * $Revision: 1.4 $ + * $Date: 2001/05/22 20:10:36 $ * * * @@ -76,7 +76,7 @@ * /ul * * @author Remy Maucherat - * @version $Revision: 1.3 $ $Date: 2001/01/25 18:35:15 $ + * @version $Revision: 1.4 $ $Date: 2001/05/22 20:10:36 $ */ public class ContextBindings { @@ -218,7 +218,7 @@ * @param name Name of the context */ public static void unbindThread(Object name) { -unbindThread(null); +unbindThread(name, null); }
cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/naming ContextBindings.java LocalStrings.properties SelectorContext.java
remm00/11/10 17:47:48 Modified:catalina/src/share/org/apache/naming ContextBindings.java LocalStrings.properties SelectorContext.java Log: - Adds the capability to bind the class loader associated with the current thread to a Context. - The current thread binding will still be checked first. Revision ChangesPath 1.2 +112 -7 jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/ContextBindings.java Index: ContextBindings.java === RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/ContextBindings.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ContextBindings.java 2000/11/02 06:14:16 1.1 +++ ContextBindings.java 2000/11/11 01:47:47 1.2 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/ContextBindings.java,v 1.1 2000/11/02 06:14:16 remm Exp $ - * $Revision: 1.1 $ - * $Date: 2000/11/02 06:14:16 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/ContextBindings.java,v 1.2 2000/11/11 01:47:47 remm Exp $ + * $Revision: 1.2 $ + * $Date: 2000/11/11 01:47:47 $ * * * @@ -76,7 +76,7 @@ * /ul * * @author Remy Maucherat - * @version $Revision: 1.1 $ $Date: 2000/11/02 06:14:16 $ + * @version $Revision: 1.2 $ $Date: 2000/11/11 01:47:47 $ */ public class ContextBindings { @@ -86,7 +86,7 @@ /** - * Bindings Catalina context name - naming context. Keyed by context name. + * Bindings name - naming context. Keyed by name. */ private static Hashtable contextNameBindings = new Hashtable(); @@ -104,6 +104,18 @@ /** + * Bindings class loader - naming context. Keyed by CL id. + */ +private static Hashtable clBindings = new Hashtable(); + + +/** + * Bindings class loader - name. Keyed by CL id. + */ +private static Hashtable clNameBindings = new Hashtable(); + + +/** * The string manager for this package. */ protected static StringManager sm = @@ -174,7 +186,6 @@ * Binds a naming context to a thread. * * @param name Name of the context - * @param token Security token */ public static void bindThread(String name) throws NamingException { @@ -186,6 +197,7 @@ * Binds a naming context to a thread. * * @param name Name of the context + * @param token Security token */ public static void bindThread(String name, Object token) throws NamingException { @@ -193,8 +205,7 @@ Context context = (Context) contextNameBindings.get(name); if (context == null) throw new NamingException -(sm.getString("contextBindings.unknownContext", - name)); +(sm.getString("contextBindings.unknownContext", name)); threadBindings.put(Thread.currentThread(), context); threadNameBindings.put(Thread.currentThread(), name); } @@ -258,6 +269,100 @@ */ public static boolean isThreadBound() { return (threadBindings.containsKey(Thread.currentThread())); +} + + +/** + * Binds a naming context to a class loader. + * + * @param name Name of the context + */ +public static void bindClassLoader(String name) +throws NamingException { +bindClassLoader(name, null); +} + + +/** + * Binds a naming context to a thread. + * + * @param name Name of the context + * @param token Security token + */ +public static void bindClassLoader(String name, Object token) +throws NamingException { +if (ContextAccessController.checkSecurityToken(name, token)) { +Context context = (Context) contextNameBindings.get(name); +if (context == null) +throw new NamingException +(sm.getString("contextBindings.unknownContext", name)); +clBindings.put(Thread.currentThread().getContextClassLoader(), + context); +clNameBindings.put(Thread.currentThread().getContextClassLoader(), + name); +} +} + + +/** + * Unbinds a naming context to a class loader. + * + * @param name Name of the context + */ +public static void unbindClassLoader(String name) { +unbindClassLoader(null); +} + + +/** + * Unbinds a naming context to a class loader. + * +