Package org.apache.naming.java

# Class javaURLContextFactory

java.lang.Object
org.apache.naming.java.javaURLContextFactory

All Implemented Interfaces:
  `InitialContextFactory`, `ObjectFactory`

public class javaURLContextFactory extends Object implements ObjectFactory, InitialContextFactory
Context factory for the "java:" namespace.

Important note : This factory MUST be associated with the "java" URL prefix, which can be done by either :

- Adding a java.naming.factory.url.pkgs=org.apache.naming property to the JNDI properties file
- Setting an environment variable named Context.URL_PKG_PREFIXES with its value including the org.apache.naming package name. More detail about this can be found in the JNDI documentation : `NamingManager.getURLContext(String, java.util.Hashtable)`.

Author:
  Remy Maucherat

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected static Context`
  `initialContext`
  Initial context.
  `static final String`
  `MAIN`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `javaURLContextFactory()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Context`
  `getInitialContext(Hashtable<?,?> environment)`
  Get a new (writable) initial context.
  `Object`
  `getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment)`
  Create a new Context's instance.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### MAIN

    public static final String MAIN
    See Also:
      - Constant Field Values

  - ### initialContext

    protected static volatile Context initialContext
    Initial context.

- ## Constructor Details

  - ### javaURLContextFactory

    public javaURLContextFactory()

- ## Method Details

  - ### getObjectInstance

    public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment) throws NamingException
    Create a new Context's instance.
    Specified by:
      `getObjectInstance` in interface `ObjectFactory`
    Parameters:
      `obj` - unused
      `name` - unused
      `nameCtx` - unused
      `environment` - the environment used
    Returns:
      a selector context if the thread or classloader are bound, and null otherwise
    Throws:
      `NamingException` - not thrown by this implementationm

  - ### getInitialContext

    public Context getInitialContext(Hashtable<?,?> environment) throws NamingException
    Get a new (writable) initial context.
    Specified by:
      `getInitialContext` in interface `InitialContextFactory`
    Parameters:
      `environment` - the environment used
    Returns:
      a selector context if the thread or classloader are bound, and a shared writable context otherwise
    Throws:
      `NamingException` - not thrown by this implementationm