remm 01/06/02 13:24:27 Modified: catalina/src/share/org/apache/naming/resources Constants.java DirContextURLStreamHandler.java Log: - Two utility methods : - The first one sets the package sys env valiable for stream handlers - The second one is a check to see if the current thread is bound (either directly or through its context CL) Revision Changes Path 1.2 +5 -2 jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/Constants.java Index: Constants.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/Constants.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Constants.java 2001/01/23 03:41:28 1.1 +++ Constants.java 2001/06/02 20:24:27 1.2 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/Constants.java,v 1.1 2001/01/23 03:41:28 remm Exp $ - * $Revision: 1.1 $ - * $Date: 2001/01/23 03:41:28 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/Constants.java,v 1.2 2001/06/02 20:24:27 remm Exp $ + * $Revision: 1.2 $ + * $Date: 2001/06/02 20:24:27 $ * * ==================================================================== * @@ -70,6 +70,9 @@ */ public final class Constants { + + public static final String PROTOCOL_HANDLER_VARIABLE = + "java.protocol.handler.pkgs"; public static final String Package = "org.apache.naming.resources"; 1.5 +30 -4 jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/DirContextURLStreamHandler.java Index: DirContextURLStreamHandler.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/DirContextURLStreamHandler.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- DirContextURLStreamHandler.java 2001/05/04 00:30:01 1.4 +++ DirContextURLStreamHandler.java 2001/06/02 20:24:27 1.5 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/DirContextURLStreamHandler.java,v 1.4 2001/05/04 00:30:01 remm Exp $ - * $Revision: 1.4 $ - * $Date: 2001/05/04 00:30:01 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/DirContextURLStreamHandler.java,v 1.5 2001/06/02 20:24:27 remm Exp $ + * $Revision: 1.5 $ + * $Date: 2001/06/02 20:24:27 $ * * ==================================================================== * @@ -75,7 +75,7 @@ * Stream handler to a JNDI directory context. * * @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a> - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ */ public class DirContextURLStreamHandler extends URLStreamHandler { @@ -137,6 +137,32 @@ // --------------------------------------------------------- Public Methods + + + /** + * Set the java.protocol.handler.pkgs system property. + */ + public static void setProtocolHandler() { + String value = System.getProperty(Constants.PROTOCOL_HANDLER_VARIABLE); + if (value == null) { + value = Constants.Package; + System.setProperty(Constants.PROTOCOL_HANDLER_VARIABLE, value); + } else if (value.indexOf(Constants.Package) == -1) { + value += "|" + Constants.Package; + System.setProperty(Constants.PROTOCOL_HANDLER_VARIABLE, value); + } + } + + + /** + * Returns true if the thread or the context class loader of the current + * thread is bound. + */ + public static boolean isBound() { + return (clBindings.containsKey + (Thread.currentThread().getContextClassLoader())) + || (threadBindings.containsKey(Thread.currentThread())); + } /**