Package 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 SummaryFields Modifier and Type Field Description protected javax.naming.ContextcompCtxComp context.protected java.lang.ObjectcontainerAssociated container.protected javax.naming.ContextenvCtxEnv context.protected booleaninitializedInitialized flag.protected java.lang.StringnameName of the associated naming context.protected NamingContextnamingContextAssociated JNDI context.protected NamingResourcesImplnamingResourcesAssociated naming resources.protected java.util.HashMap<java.lang.String,javax.management.ObjectName>objectNamesObjectnames Map.protected static StringManagersm
 - 
Constructor SummaryConstructors Constructor Description NamingContextListener()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddEjb(ContextEjb ejb)Set the specified EJBs in the naming context.voidaddEnvironment(ContextEnvironment env)Set the specified environment entries in the naming context.voidaddLocalEjb(ContextLocalEjb localEjb)Set the specified local EJBs in the naming context.voidaddMessageDestinationRef(MessageDestinationRef mdr)Set the specified message destination refs in the naming context.voidaddResource(ContextResource resource)Set the specified resources in the naming context.voidaddResourceEnvRef(ContextResourceEnvRef resourceEnvRef)Set the specified resources in the naming context.voidaddResourceLink(ContextResourceLink resourceLink)Set the specified resource link in the naming context.voidaddService(ContextService service)Set the specified web service in the naming context.voidcontainerEvent(ContainerEvent event)Deprecated.TheContainerListenerinterface and implementing methods will be removed from this class for Tomcat 10 onwards.protected javax.management.ObjectNamecreateObjectName(ContextResource resource)Create anObjectNamefor thisContextResourceobject.javax.naming.ContextgetEnvContext()booleangetExceptionOnFailedWrite()java.lang.StringgetName()voidlifecycleEvent(LifecycleEvent event)Acknowledge the occurrence of the specified event.voidpropertyChange(java.beans.PropertyChangeEvent event)Process property change events.voidremoveEjb(java.lang.String name)Remove the specified EJB from the naming context.voidremoveEnvironment(java.lang.String name)Remove the specified environment entry from the naming context.voidremoveLocalEjb(java.lang.String name)Remove the specified local EJB from the naming context.voidremoveMessageDestinationRef(java.lang.String name)Remove the specified message destination ref from the naming context.voidremoveResource(java.lang.String name)Remove the specified resource from the naming context.voidremoveResourceEnvRef(java.lang.String name)Remove the specified resource environment reference from the naming context.voidremoveResourceLink(java.lang.String name)Remove the specified resource link from the naming context.voidremoveService(java.lang.String name)Remove the specified web service from the naming context.voidsetExceptionOnFailedWrite(boolean exceptionOnFailedWrite)Controls whether or not an attempt to modify the JNDI context will trigger an exception or if the request will be ignored.voidsetName(java.lang.String name)Set the "name" property.
 
- 
- 
- 
Field Detail- 
smprotected static final StringManager sm 
 - 
nameprotected java.lang.String name Name of the associated naming context.
 - 
containerprotected java.lang.Object container Associated container.
 - 
initializedprotected boolean initialized Initialized flag.
 - 
namingResourcesprotected NamingResourcesImpl namingResources Associated naming resources.
 - 
namingContextprotected NamingContext namingContext Associated JNDI context.
 - 
compCtxprotected javax.naming.Context compCtx Comp context.
 - 
envCtxprotected javax.naming.Context envCtx Env context.
 - 
objectNamesprotected java.util.HashMap<java.lang.String,javax.management.ObjectName> objectNames Objectnames Map.
 
- 
 - 
Method Detail- 
getExceptionOnFailedWritepublic boolean getExceptionOnFailedWrite() - Returns:
- whether or not an attempt to modify the JNDI context will trigger an exception or if the request will be ignored.
 
 - 
setExceptionOnFailedWritepublic 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
 
 - 
getNamepublic java.lang.String getName() - Returns:
- the "name" property.
 
 - 
setNamepublic void setName(java.lang.String name) Set the "name" property.- Parameters:
- name- The new name
 
 - 
getEnvContextpublic javax.naming.Context getEnvContext() - Returns:
- the naming environment context.
 
 - 
lifecycleEventpublic void lifecycleEvent(LifecycleEvent event) Acknowledge the occurrence of the specified event.- Specified by:
- lifecycleEventin interface- LifecycleListener
- Parameters:
- event- LifecycleEvent that has occurred
 
 - 
containerEvent@Deprecated public void containerEvent(ContainerEvent event) Deprecated.TheContainerListenerinterface and implementing methods will be removed from this class for Tomcat 10 onwards.NO-OP.- Specified by:
- containerEventin interface- ContainerListener
- Parameters:
- event- ContainerEvent that has occurred
 
 - 
propertyChangepublic void propertyChange(java.beans.PropertyChangeEvent event) Process property change events.- Specified by:
- propertyChangein interface- java.beans.PropertyChangeListener
- Parameters:
- event- The property change event that has occurred
 
 - 
createObjectNameprotected javax.management.ObjectName createObjectName(ContextResource resource) throws javax.management.MalformedObjectNameException Create anObjectNamefor thisContextResourceobject.- Parameters:
- resource- The resource
- Returns:
- ObjectName The object name
- Throws:
- javax.management.MalformedObjectNameException- if a name cannot be created
 
 - 
addEjbpublic void addEjb(ContextEjb ejb) Set the specified EJBs in the naming context.- Parameters:
- ejb- the EJB descriptor
 
 - 
addEnvironmentpublic void addEnvironment(ContextEnvironment env) Set the specified environment entries in the naming context.- Parameters:
- env- the environment entry
 
 - 
addLocalEjbpublic void addLocalEjb(ContextLocalEjb localEjb) Set the specified local EJBs in the naming context.- Parameters:
- localEjb- the local EJB descriptor (unused)
 
 - 
addMessageDestinationRefpublic void addMessageDestinationRef(MessageDestinationRef mdr) Set the specified message destination refs in the naming context.- Parameters:
- mdr- the message destination ref descriptor (unused)
 
 - 
addServicepublic void addService(ContextService service) Set the specified web service in the naming context.- Parameters:
- service- the web service descriptor
 
 - 
addResourcepublic void addResource(ContextResource resource) Set the specified resources in the naming context.- Parameters:
- resource- the resource descriptor
 
 - 
addResourceEnvRefpublic void addResourceEnvRef(ContextResourceEnvRef resourceEnvRef) Set the specified resources in the naming context.- Parameters:
- resourceEnvRef- the resource reference
 
 - 
addResourceLinkpublic void addResourceLink(ContextResourceLink resourceLink) Set the specified resource link in the naming context.- Parameters:
- resourceLink- the resource link
 
 - 
removeEjbpublic 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
 
 - 
removeEnvironmentpublic 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
 
 - 
removeLocalEjbpublic 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
 
 - 
removeMessageDestinationRefpublic 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
 
 - 
removeServicepublic 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
 
 - 
removeResourcepublic 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
 
 - 
removeResourceEnvRefpublic 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
 
 - 
removeResourceLinkpublic 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
 
 
- 
 
-