Package 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
Modifier and TypeFieldDescriptionprotected Context
Comp context.protected Object
Associated container.protected Context
Env context.protected boolean
Initialized flag.protected String
Name of the associated naming context.protected NamingContext
Associated JNDI context.protected NamingResourcesImpl
Associated naming resources.protected HashMap<String,
ObjectName> Objectnames Map.protected static final StringManager
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addEjb
(ContextEjb ejb) Set the specified EJBs in the naming context.void
Set the specified environment entries in the naming context.void
addLocalEjb
(ContextLocalEjb localEjb) Set the specified local EJBs in the naming context.void
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.protected ObjectName
createObjectName
(ContextResource resource) Create anObjectName
for thisContextResource
object.boolean
getName()
void
lifecycleEvent
(LifecycleEvent event) Acknowledge the occurrence of the specified event.void
void
Remove the specified EJB from the naming context.void
removeEnvironment
(String name) Remove the specified environment entry from the naming context.void
removeLocalEjb
(String name) Remove the specified local EJB from the naming context.void
Remove the specified message destination ref from the naming context.void
removeResource
(String name) Remove the specified resource from the naming context.void
removeResourceEnvRef
(String name) Remove the specified resource environment reference from the naming context.void
removeResourceLink
(String name) Remove the specified resource link from the naming context.void
removeService
(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
Set the "name" property.
-
Field Details
-
sm
-
name
Name of the associated naming context. -
container
Associated container. -
initialized
protected boolean initializedInitialized flag. -
namingResources
Associated naming resources. -
namingContext
Associated JNDI context. -
compCtx
Comp context. -
envCtx
Env context. -
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
- Returns:
- the "name" property.
-
setName
Set the "name" property.- Parameters:
name
- The new name
-
getEnvContext
- Returns:
- the naming environment context.
-
lifecycleEvent
Description copied from interface:LifecycleListener
Acknowledge the occurrence of the specified event.- Specified by:
lifecycleEvent
in interfaceLifecycleListener
- Parameters:
event
- LifecycleEvent that has occurred
-
containerEvent
Deprecated.TheContainerListener
interface and implementing methods will be removed from this class for Tomcat 10 onwards.NO-OP.- Specified by:
containerEvent
in interfaceContainerListener
- Parameters:
event
- ContainerEvent that has occurred
-
propertyChange
- Specified by:
propertyChange
in interfacePropertyChangeListener
-
createObjectName
Create anObjectName
for thisContextResource
object.- Parameters:
resource
- The resource- Returns:
- ObjectName The object name
- Throws:
MalformedObjectNameException
- if a name cannot be created
-
addEjb
Set the specified EJBs in the naming context.- Parameters:
ejb
- the EJB descriptor
-
addEnvironment
Set the specified environment entries in the naming context.- Parameters:
env
- the environment entry
-
addLocalEjb
Set the specified local EJBs in the naming context.- Parameters:
localEjb
- the local EJB descriptor (unused)
-
addMessageDestinationRef
Set the specified message destination refs in the naming context.- Parameters:
mdr
- the message destination ref descriptor (unused)
-
addService
Set the specified web service in the naming context.- Parameters:
service
- the web service descriptor
-
addResource
Set the specified resources in the naming context.- Parameters:
resource
- the resource descriptor
-
addResourceEnvRef
Set the specified resources in the naming context.- Parameters:
resourceEnvRef
- the resource reference
-
addResourceLink
Set the specified resource link in the naming context.- Parameters:
resourceLink
- the resource link
-
removeEjb
Remove the specified EJB from the naming context.- Parameters:
name
- the name of the EJB which should be removed
-
removeEnvironment
Remove the specified environment entry from the naming context.- Parameters:
name
- the name of the environment entry which should be removed
-
removeLocalEjb
Remove the specified local EJB from the naming context.- Parameters:
name
- the name of the EJB which should be removed
-
removeMessageDestinationRef
Remove the specified message destination ref from the naming context.- Parameters:
name
- the name of the message destination ref which should be removed
-
removeService
Remove the specified web service from the naming context.- Parameters:
name
- the name of the web service which should be removed
-
removeResource
Remove the specified resource from the naming context.- Parameters:
name
- the name of the resource which should be removed
-
removeResourceEnvRef
Remove the specified resource environment reference from the naming context.- Parameters:
name
- the name of the resource environment reference which should be removed
-
removeResourceLink
Remove the specified resource link from the naming context.- Parameters:
name
- the name of the resource link which should be removed
-
ContainerListener
interface and implementing methods will be removed from this class for Tomcat 10 onwards.