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 Details

    • sm

      protected static final StringManager sm
    • name

      protected String name
      Name of the associated naming context.
    • container

      protected 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 Context compCtx
      Comp context.
    • envCtx

      protected Context envCtx
      Env context.
    • objectNames

      protected HashMap<String,ObjectName> objectNames
      Objectnames Map.
  • Constructor Details

    • NamingContextListener

      public NamingContextListener()
  • Method Details

    • 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()
      Returns:
      the "name" property.
    • setName

      public void setName(String name)
      Set the "name" property.
      Parameters:
      name - The new name
    • getEnvContext

      public 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(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.
      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(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(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(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(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(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(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(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(String name)
      Remove the specified resource link from the naming context.
      Parameters:
      name - the name of the resource link which should be removed