org.apache.catalina.core

## Class NamingContextListener

- java.lang.Object
- - org.apache.catalina.core.NamingContextListener

All Implemented Interfaces:
  PropertyChangeListener, EventListener, ContainerListener, LifecycleListener

    public class NamingContextListener
    extends Object
    implements LifecycleListener, ContainerListener, PropertyChangeListener

Helper class used to initialize and populate the JNDI context associated with each context and server.

Author:
  Remy Maucherat

### Field Summary

Fields
`protected Context` `compCtx` Comp context.
`protected Object` `container` Associated container.
`protected Context` `envCtx` Env context.
`protected boolean` `initialized` Initialized flag.
`protected Log` `logger`
`protected String` `name` Name of the associated naming context.
`protected NamingContext` `namingContext` Associated JNDI context.
`protected NamingResources` `namingResources` Associated naming resources.
`protected HashMap<String,ObjectName>` `objectNames` Objectnames hashtable.
`protected static StringManager` `sm` The string manager for this package.

### Constructor Summary

Constructors
Constructor and Description
`NamingContextListener()`

### Method Summary

Methods
`void` `addEjb(ContextEjb ejb)` Set the specified EJBs in the naming context.
`void` `addEnvironment(ContextEnvironment env)` Set the specified environment entries in the naming context.
`void` `addLocalEjb(ContextLocalEjb localEjb)` Set the specified local EJBs in the naming context.
`void` `addResource(ContextResource resource)` Set the specified resources in the naming context.
`void` `addResourceEnvRef(ContextResourceEnvRef resourceEnvRef)` Set the specified resources in the naming context.
`void` `addResourceLink(ContextResourceLink resourceLink)` Set the specified resource link in the naming context.
`void` `addService(ContextService service)` Set the specified web service in the naming context.
`void` `containerEvent(ContainerEvent event)` Acknowledge the occurrence of the specified event.
`protected ObjectName` `createObjectName(ContextResource resource)` Create an `ObjectName` for this `ContextResource` object.
`Context` `getCompContext()` Deprecated.
`Context` `getEnvContext()` Return the env context.
`boolean` `getExceptionOnFailedWrite()` Returns whether or not an attempt to modify the JNDI context will trigger an exception or if the request will be ignored.
`String` `getName()` Return the "name" property.
`NamingContext` `getNamingContext()` Deprecated.
`void` `lifecycleEvent(LifecycleEvent event)` Acknowledge the occurrence of the specified event.
`void` `propertyChange(PropertyChangeEvent event)` Process property change events.
`void` `removeEjb(String name)` Set the specified EJBs in the naming context.
`void` `removeEnvironment(String name)` Set the specified environment entries in the naming context.
`void` `removeLocalEjb(String name)` Set the specified local EJBs in the naming context.
`void` `removeResource(String name)` Set the specified resources in the naming context.
`void` `removeResourceEnvRef(String name)` Set the specified resources in the naming context.
`void` `removeResourceLink(String name)` Set the specified resources in the naming context.
`void` `removeService(String name)` Set the specified web services in the naming context.
`void` `setExceptionOnFailedWrite(boolean exceptionOnFailedWrite)` Controls whether or not an attempt to modify the JNDI context will trigger an exception or if the request will be ignored.
`void` `setName(String name)` Set the "name" property.

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

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

### Field Detail

#### logger

    protected Log logger

#### name

    protected String name

Name of the associated naming context.

#### container

    protected Object container

Associated container.

#### initialized

    protected boolean initialized

Initialized flag.

#### namingResources

    protected NamingResources namingResources

Associated naming resources.

#### namingContext

    protected NamingContext namingContext

Associated JNDI context.

#### compCtx

    protected Context compCtx

Comp context.

#### envCtx

    protected Context envCtx

Env context.

#### objectNames

    protected HashMap<String,ObjectName> objectNames

Objectnames hashtable.

#### sm

    protected static final StringManager sm

The string manager for this package.

### Constructor Detail

#### NamingContextListener

    public NamingContextListener()

### Method Detail

#### getExceptionOnFailedWrite

    public boolean getExceptionOnFailedWrite()

Returns whether or not an attempt to modify the JNDI context will trigger an exception or if the request will be ignored.

#### setExceptionOnFailedWrite

    public void setExceptionOnFailedWrite(boolean exceptionOnFailedWrite)

Controls whether or not an attempt to modify the JNDI context will trigger an exception or if the request will be ignored.

Parameters:
  `exceptionOnFailedWrite` - The new value

#### getName

    public String getName()

Return the "name" property.

#### setName

    public void setName(String name)

Set the "name" property.

Parameters:
  `name` - The new name

#### getCompContext

    @Deprecated
    public Context getCompContext()

Deprecated.
Return the comp context.

#### getEnvContext

    public Context getEnvContext()

Return the env context.

#### getNamingContext

    @Deprecated
    public NamingContext getNamingContext()

Deprecated.
Return the associated naming context.

#### lifecycleEvent

    public void lifecycleEvent(LifecycleEvent event)

Acknowledge the occurrence of the specified event.

Specified by:
  `lifecycleEvent` in interface `LifecycleListener`
Parameters:
  `event` - LifecycleEvent that has occurred

#### containerEvent

    public void containerEvent(ContainerEvent event)

Acknowledge the occurrence of the specified event. Note: Will never be called when the listener is associated to a Server, since it is not a Container.

Specified by:
  `containerEvent` in interface `ContainerListener`
Parameters:
  `event` - ContainerEvent that has occurred

#### propertyChange

    public void propertyChange(PropertyChangeEvent event)

Process property change events.

Specified by:
  `propertyChange` in interface `PropertyChangeListener`
Parameters:
  `event` - The property change event that has occurred

#### createObjectName

    protected ObjectName createObjectName(ContextResource resource)
                                   throws MalformedObjectNameException

Create an `ObjectName` for this `ContextResource` object.

Parameters:
  `resource` - The resource
Returns:
  ObjectName The object name
Throws:
  `MalformedObjectNameException` - if a name cannot be created

#### addEjb

    public void addEjb(ContextEjb ejb)

Set the specified EJBs in the naming context.

#### addEnvironment

    public void addEnvironment(ContextEnvironment env)

Set the specified environment entries in the naming context.

#### addLocalEjb

    public void addLocalEjb(ContextLocalEjb localEjb)

Set the specified local EJBs in the naming context.

#### addService

    public void addService(ContextService service)

Set the specified web service in the naming context.

#### addResource

    public void addResource(ContextResource resource)

Set the specified resources in the naming context.

#### addResourceEnvRef

    public void addResourceEnvRef(ContextResourceEnvRef resourceEnvRef)

Set the specified resources in the naming context.

#### addResourceLink

    public void addResourceLink(ContextResourceLink resourceLink)

Set the specified resource link in the naming context.

#### removeEjb

    public void removeEjb(String name)

Set the specified EJBs in the naming context.

#### removeEnvironment

    public void removeEnvironment(String name)

Set the specified environment entries in the naming context.

#### removeLocalEjb

    public void removeLocalEjb(String name)

Set the specified local EJBs in the naming context.

#### removeService

    public void removeService(String name)

Set the specified web services in the naming context.

#### removeResource

    public void removeResource(String name)

Set the specified resources in the naming context.

#### removeResourceEnvRef

    public void removeResourceEnvRef(String name)

Set the specified resources in the naming context.

#### removeResourceLink

    public void removeResourceLink(String name)

Set the specified resources in the naming context.