remm        01/05/03 17:30:02

  Modified:    catalina/src/share/org/apache/naming/resources
                        DirContextURLStreamHandler.java
  Log:
  - Add possibility to bind threads in addition to classloaders.
  
  Revision  Changes    Path
  1.4       +37 -6     
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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DirContextURLStreamHandler.java   2001/03/21 05:05:44     1.3
  +++ DirContextURLStreamHandler.java   2001/05/04 00:30:01     1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/DirContextURLStreamHandler.java,v
 1.3 2001/03/21 05:05:44 remm Exp $
  - * $Revision: 1.3 $
  - * $Date: 2001/03/21 05:05:44 $
  + * $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 $
    *
    * ====================================================================
    *
  @@ -75,7 +75,7 @@
    * Stream handler to a JNDI directory context.
    * 
    * @author <a href="mailto:[EMAIL PROTECTED]";>Remy Maucherat</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   public class DirContextURLStreamHandler 
       extends URLStreamHandler {
  @@ -102,6 +102,12 @@
       private static Hashtable clBindings = new Hashtable();
       
       
  +    /**
  +     * Bindings thread - directory context. Keyed by thread id.
  +     */
  +    private static Hashtable threadBindings = new Hashtable();
  +    
  +    
       // ----------------------------------------------------- Instance Variables
       
       
  @@ -156,12 +162,29 @@
       
       
       /**
  +     * Binds a directory context to a thread.
  +     */
  +    public static void bindThread(DirContext dirContext) {
  +        threadBindings.put(Thread.currentThread(), dirContext);
  +    }
  +    
  +    
  +    /**
  +     * Unbinds a directory context to a thread.
  +     */
  +    public static void unbindThread() {
  +        threadBindings.remove(Thread.currentThread());
  +    }
  +    
  +    
  +    /**
        * Get the bound context.
        */
       public static DirContext get() {
  -        ClassLoader currentCL = 
  -            Thread.currentThread().getContextClassLoader();
           DirContext result = null;
  +        Thread currentThread = Thread.currentThread();
  +        result = (DirContext) threadBindings.get(currentThread);
  +        ClassLoader currentCL = currentThread.getContextClassLoader();
           while ((result == null) && (currentCL != null)) {
               result = (DirContext) clBindings.get(currentCL);
               if (result == null)
  @@ -194,6 +217,14 @@
        */
       public static DirContext get(ClassLoader cl) {
           return (DirContext) clBindings.get(cl);
  +    }
  +    
  +    
  +    /**
  +     * Get the bound context.
  +     */
  +    public static DirContext get(Thread thread) {
  +        return (DirContext) threadBindings.get(thread);
       }
       
       
  
  
  

Reply via email to