NamingContextListener (Apache Tomcat 8.5.43 API Documentation)

org.apache.catalina.core

## Class NamingContextListener

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

- All Implemented Interfaces:
    java.beans.PropertyChangeListener, java.util.EventListener, ContainerListener, LifecycleListener

      public class NamingContextListener
      extends java.lang.Object
      implements LifecycleListener, ContainerListener, java.beans.PropertyChangeListener

  Helper class used to initialize and populate the JNDI context associated with each context and server.
  Author:
    Remy Maucherat

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected javax.naming.Context` | `compCtx` Comp context.
    `protected java.lang.Object` | `container` Associated container.
    `protected javax.naming.Context` | `envCtx` Env context.
    `protected boolean` | `initialized` Initialized flag.
    `protected java.lang.String` | `name` Name of the associated naming context.
    `protected NamingContext` | `namingContext` Associated JNDI context.
    `protected NamingResourcesImpl` | `namingResources` Associated naming resources.
    `protected java.util.HashMap<java.lang.String,javax.management.ObjectName>` | `objectNames` Objectnames hashtable.
    `protected static StringManager` | `sm` The string manager for this package.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `NamingContextListener()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `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` | `addMessageDestinationRef(MessageDestinationRef mdr)` Set the specified message destination refs 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)` Deprecated. The `ContainerListener` interface and implementing methods will be removed from this class for Tomcat 10 onwards.
    `protected javax.management.ObjectName` | `createObjectName(ContextResource resource)` Create an `ObjectName` for this `ContextResource` object.
    `javax.naming.Context` | `getEnvContext()`
    `boolean` | `getExceptionOnFailedWrite()`
    `java.lang.String` | `getName()`
    `void` | `lifecycleEvent(LifecycleEvent event)` Acknowledge the occurrence of the specified event.
    `void` | `propertyChange(java.beans.PropertyChangeEvent event)` Process property change events.
    `void` | `removeEjb(java.lang.String name)` Remove the specified EJB from the naming context.
    `void` | `removeEnvironment(java.lang.String name)` Remove the specified environment entry from the naming context.
    `void` | `removeLocalEjb(java.lang.String name)` Remove the specified local EJB from the naming context.
    `void` | `removeMessageDestinationRef(java.lang.String name)` Remove the specified message destination ref from the naming context.
    `void` | `removeResource(java.lang.String name)` Remove the specified resource from the naming context.
    `void` | `removeResourceEnvRef(java.lang.String name)` Remove the specified resource environment reference from the naming context.
    `void` | `removeResourceLink(java.lang.String name)` Remove the specified resource link from the naming context.
    `void` | `removeService(java.lang.String name)` Remove the specified web service from 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(java.lang.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

    - #### name

          protected java.lang.String name

      Name of the associated naming context.

    - #### container

          protected java.lang.Object container

      Associated container.

    - #### initialized

          protected boolean initialized

      Initialized flag.

    - #### namingResources

          protected NamingResourcesImpl namingResources

      Associated naming resources.

    - #### namingContext

          protected NamingContext namingContext

      Associated JNDI context.

    - #### compCtx

          protected javax.naming.Context compCtx

      Comp context.

    - #### envCtx

          protected javax.naming.Context envCtx

      Env context.

    - #### objectNames

          protected java.util.HashMap<java.lang.String,javax.management.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 java.lang.String getName()

      Returns:
        the "name" property.

    - #### setName

          public void setName(java.lang.String name)

      Set the "name" property.
      Parameters:
        `name` - The new name

    - #### getEnvContext

          public javax.naming.Context getEnvContext()

      Returns:
        the naming environment 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

          @Deprecated
          public void containerEvent(ContainerEvent event)

      Deprecated. The `ContainerListener` interface and implementing methods will be removed from this class for Tomcat 10 onwards.
      NO-OP.
      Specified by:
        `containerEvent` in interface `ContainerListener`
      Parameters:
        `event` - ContainerEvent that has occurred

    - #### propertyChange

          public void propertyChange(java.beans.PropertyChangeEvent event)

      Process property change events.
      Specified by:
        `propertyChange` in interface `java.beans.PropertyChangeListener`
      Parameters:
        `event` - The property change event that has occurred

    - #### createObjectName

          protected javax.management.ObjectName createObjectName(ContextResource resource)
                                                          throws javax.management.MalformedObjectNameException

      Create an `ObjectName` for this `ContextResource` object.
      Parameters:
        `resource` - The resource
      Returns:
        ObjectName The object name
      Throws:
        `javax.management.MalformedObjectNameException` - if a name cannot be created

    - #### addEjb

          public void addEjb(ContextEjb ejb)

      Set the specified EJBs in the naming context.
      Parameters:
        `ejb` - the EJB descriptor

    - #### addEnvironment

          public void addEnvironment(ContextEnvironment env)

      Set the specified environment entries in the naming context.
      Parameters:
        `env` - the environment entry

    - #### addLocalEjb

          public void addLocalEjb(ContextLocalEjb localEjb)

      Set the specified local EJBs in the naming context.
      Parameters:
        `localEjb` - the local EJB descriptor (unused)

    - #### addMessageDestinationRef

          public void addMessageDestinationRef(MessageDestinationRef mdr)

      Set the specified message destination refs in the naming context.
      Parameters:
        `mdr` - the message destination ref descriptor (unused)

    - #### addService

          public void addService(ContextService service)

      Set the specified web service in the naming context.
      Parameters:
        `service` - the web service descriptor

    - #### addResource

          public void addResource(ContextResource resource)

      Set the specified resources in the naming context.
      Parameters:
        `resource` - the resource descriptor

    - #### addResourceEnvRef

          public void addResourceEnvRef(ContextResourceEnvRef resourceEnvRef)

      Set the specified resources in the naming context.
      Parameters:
        `resourceEnvRef` - the resource reference

    - #### addResourceLink

          public void addResourceLink(ContextResourceLink resourceLink)

      Set the specified resource link in the naming context.
      Parameters:
        `resourceLink` - the resource link

    - #### removeEjb

          public void removeEjb(java.lang.String name)

      Remove the specified EJB from the naming context.
      Parameters:
        `name` - the name of the EJB which should be removed

    - #### removeEnvironment

          public void removeEnvironment(java.lang.String name)

      Remove the specified environment entry from the naming context.
      Parameters:
        `name` - the name of the environment entry which should be removed

    - #### removeLocalEjb

          public void removeLocalEjb(java.lang.String name)

      Remove the specified local EJB from the naming context.
      Parameters:
        `name` - the name of the EJB which should be removed

    - #### removeMessageDestinationRef

          public void removeMessageDestinationRef(java.lang.String name)

      Remove the specified message destination ref from the naming context.
      Parameters:
        `name` - the name of the message destination ref which should be removed

    - #### removeService

          public void removeService(java.lang.String name)

      Remove the specified web service from the naming context.
      Parameters:
        `name` - the name of the web service which should be removed

    - #### removeResource

          public void removeResource(java.lang.String name)

      Remove the specified resource from the naming context.
      Parameters:
        `name` - the name of the resource which should be removed

    - #### removeResourceEnvRef

          public void removeResourceEnvRef(java.lang.String name)

      Remove the specified resource environment reference from the naming context.
      Parameters:
        `name` - the name of the resource environment reference which should be removed

    - #### removeResourceLink

          public void removeResourceLink(java.lang.String name)

      Remove the specified resource link from the naming context.
      Parameters:
        `name` - the name of the resource link which should be removed

Copyright © 2000-2019 Apache Software Foundation. All Rights Reserved.