Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mortbay.naming
Class ContextFactory

    java.lang.Object
      org.mortbay.naming.ContextFactory

All Implemented Interfaces:
  javax.naming.spi.ObjectFactory

    public class ContextFactory

extends java.lang.Object
implements javax.naming.spi.ObjectFactory

ContextFactory.java This is an object factory that produces a jndi naming context based on a classloader. It is used for the java:comp context. This object factory is bound at java:comp. When a lookup arrives for java:comp, this object factory is invoked and will return a context specific to the caller's environment (so producing the java:comp/env specific to a webapp). The context selected is based on classloaders. First we try looking in at the classloader that is associated with the current webapp context (if there is one). If not, we use the thread context classloader. Created: Fri Jun 27 09:26:40 2003

Author:
  Jan Bartel

Constructor Summary
`ContextFactory()`

Method Summary
`java.lang.Object` | `getObjectInstance(java.lang.Object obj, javax.naming.Name name, javax.naming.Context nameCtx, java.util.Hashtable env)` Find or create a context which pertains to a classloader.
`javax.naming.Context` | `getParentClassLoaderContext(java.lang.ClassLoader loader)` Keep trying ancestors of the given classloader to find one to which the context is bound.
`static void` | `resetComponentContext(javax.naming.Context ctx)` Set back the context with the given value.
`static javax.naming.Context` | `setComponentContext(javax.naming.Context ctx)` Associate the given Context with the current thread.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ContextFactory

    public ContextFactory()

Method Detail

### getObjectInstance

    public java.lang.Object getObjectInstance(java.lang.Object obj,
                                              javax.naming.Name name,
                                              javax.naming.Context nameCtx,
                                              java.util.Hashtable env)
                                       throws java.lang.Exception

  Find or create a context which pertains to a classloader. We use either the classloader for the current ContextHandler if we are handling a request, OR we use the thread context classloader if we are not processing a request.

  Specified by:
    `getObjectInstance` in interface `javax.naming.spi.ObjectFactory`
  Throws:
    `java.lang.Exception`
  See Also:
    `ObjectFactory.getObjectInstance(java.lang.Object, javax.naming.Name, javax.naming.Context, java.util.Hashtable)`

### getParentClassLoaderContext

    public javax.naming.Context getParentClassLoaderContext(java.lang.ClassLoader loader)

  Keep trying ancestors of the given classloader to find one to which the context is bound.

  Parameters:
    `loader` -
  Returns:

### setComponentContext

    public static javax.naming.Context setComponentContext(javax.naming.Context ctx)

  Associate the given Context with the current thread. resetComponentContext method should be called to reset the context.

  Parameters:
    `ctx` - the context to associate to the current thread.
  Returns:
    the previous context associated on the thread (can be null)

### resetComponentContext

    public static void resetComponentContext(javax.naming.Context ctx)

  Set back the context with the given value. Don't return the previous context, use setComponentContext() method for this.

  Parameters:
    `ctx` - the context to associate to the current thread.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1995-2010 Mort Bay Consulting. All Rights Reserved.