Top Description Fields Constructors Methods
org.apache.catalina.deploy

public Class NamingResourcesImpl

extends LifecycleMBeanBase
implements Serializable, NamingResources
Class Inheritance
All Implemented Interfaces
org.apache.tomcat.util.descriptor.web.NamingResources, java.io.Serializable
Imports
java.beans.PropertyChangeListener, .PropertyChangeSupport, java.io.Serializable, java.lang.reflect.Field, .InvocationTargetException, .Method, java.util.HashMap, .HashSet, .List, .Map, .Set, javax.naming.NamingException, org.apache.catalina.Container, .Context, .Engine, .JmxEnabled, .LifecycleException, .LifecycleState, .Server, org.apache.catalina.mbeans.MBeanUtils, org.apache.catalina.util.Introspection, .LifecycleMBeanBase, org.apache.juli.logging.Log, .LogFactory, org.apache.naming.ContextBindings, org.apache.tomcat.util.ExceptionUtils, org.apache.tomcat.util.descriptor.web.ContextEjb, .ContextEnvironment, .ContextLocalEjb, .ContextResource, .ContextResourceEnvRef, .ContextResourceLink, .ContextService, .ContextTransaction, .InjectionTarget, .MessageDestinationRef, .NamingResources, .ResourceBase, org.apache.tomcat.util.res.StringManager

Holds and manages the naming resources defined in the Jakarta EE Naming Context and their associated JNDI context.
Author
Remy Maucherat

Field Summary

Modifier and TypeField and Description
private Object
container

Associated container object.

private final Map<String, ContextEjb>
ejbs

The EJB resource references for this web application, keyed by name.

private final Set<String>
entries

Set of naming entries, keyed by name.

private final Map<String, ContextEnvironment>
envs

The environment entries for this web application, keyed by name.

private final Map<String, ContextLocalEjb>
localEjbs

The local EJB resource references for this web application, keyed by name.

private static final Log
private final Map<String, MessageDestinationRef>
mdrs

The message destination references for this web application, keyed by name.

private final HashMap<String, ContextResourceEnvRef>
resourceEnvRefs

The resource environment references for this web application, keyed by name.

private final HashMap<String, ContextResourceLink>
resourceLinks

The resource links for this web application, keyed by name.

private volatile boolean
private final HashMap<String, ContextResource>
resources

The resource references for this web application, keyed by name.

private static final long
private final HashMap<String, ContextService>
services

The web service references for this web application, keyed by name.

private static final StringManager
protected final PropertyChangeSupport
support

The property change support for this component.

private ContextTransaction
transaction

The transaction for this webapp.

Constructor Summary

AccessConstructor and Description
public
NamingResourcesImpl()

Create a new NamingResources instance.

Method Summary

Modifier and TypeMethod and Description
public void
addEjb(ContextEjb
New EJB resource reference
ejb
)

Add an EJB resource reference for this web application.

public void
addEnvironment(ContextEnvironment
New environment entry
environment
)

Implements org.apache.tomcat.util.descriptor.web.NamingResources.addEnvironment.

Add an environment entry for this web application.

public void
addLocalEjb(ContextLocalEjb
New EJB resource reference
ejb
)

Add a local EJB resource reference for this web application.

public void
addMessageDestinationRef(MessageDestinationRef
New message destination reference
mdr
)

Add a message destination reference for this web application.

public void
addPropertyChangeListener(PropertyChangeListener
The listener to add
listener
)

Add a property change listener to this component.

public void
addResource(ContextResource
New resource reference
resource
)

Implements org.apache.tomcat.util.descriptor.web.NamingResources.addResource.

Add a resource reference for this web application.

public void
addResourceEnvRef(ContextResourceEnvRef
The resource
resource
)

Add a resource environment reference for this web application.

public void
addService(ContextService
New web service reference
service
)

Add a web service reference for this web application.

private boolean

Returns:

true if the type for the resource is now valid (if previously null this means it is now set) or false if the current resource type is inconsistent with the injection targets and/or cannot be determined
checkResourceType
(ResourceBase
The resource to check
resource
)

Checks that the configuration of the type for the specified resource is consistent with any injection targets and if the type is not specified, tries to configure the type based on the injection targets

private void
cleanUp()

Close those resources that an explicit close may help clean-up faster.

private void
cleanUp(Object
The resource to close.
resource
,
String name, String closeMethod)

Clean up a resource by calling the defined close method.

protected void
destroyInternal()

Overrides org.apache.catalina.util.LifecycleMBeanBase.destroyInternal.

Sub-classes wishing to perform additional clean-up should override this method, ensuring that super.destroyInternal() is the last call in the overriding method.

public ContextEjb

Returns:

the EJB resource reference with the specified name, if any; otherwise, return null.
findEjb
(String
Name of the desired EJB resource reference
name
)

public ContextEjb[]

Returns:

the defined EJB resource references for this application. If there are none, a zero-length array is returned.
findEjbs
()

public ContextEnvironment

Returns:

the environment entry with the specified name, if any; otherwise, return null.
findEnvironment
(String
Name of the desired environment entry
name
)

public ContextEnvironment[]

Returns:

the set of defined environment entries for this web application. If none have been defined, a zero-length array is returned.
findEnvironments
()

public ContextLocalEjb

Returns:

the local EJB resource reference with the specified name, if any; otherwise, return null.
findLocalEjb
(String
Name of the desired EJB resource reference
name
)

public ContextLocalEjb[]

Returns:

the defined local EJB resource references for this application. If there are none, a zero-length array is returned.
findLocalEjbs
()

public MessageDestinationRef

Returns:

the message destination reference with the specified name, if any; otherwise, return null.
findMessageDestinationRef
(String
Name of the desired message destination reference
name
)

public MessageDestinationRef[]

Returns:

the defined message destination references for this application. If there are none, a zero-length array is returned.
findMessageDestinationRefs
()

public ContextResource

Returns:

the resource reference with the specified name, if any; otherwise return null.
findResource
(String
Name of the desired resource reference
name
)

public ContextResourceEnvRef

Returns:

the resource environment reference type for the specified name, if any; otherwise return null.
findResourceEnvRef
(String
Name of the desired resource environment reference
name
)

public ContextResourceEnvRef[]

Returns:

the set of resource environment reference names for this web application. If none have been specified, a zero-length array is returned.
findResourceEnvRefs
()

public ContextResource[]

Returns:

the defined resource references for this application. If none have been defined, a zero-length array is returned.
findResources
()

public ContextService

Returns:

the web service reference for the specified name, if any; otherwise return null.
findService
(String
Name of the desired web service
name
)

public ContextService[]

Returns:

the defined web service references for this application. If none have been defined, a zero-length array is returned.
findServices
()

private Class<?>
getCompatibleType(Context context, ResourceBase resource, Class<?> typeClass)

public Object

Returns:

the container with which the naming resources are associated.
getContainer
()

Implements org.apache.tomcat.util.descriptor.web.NamingResources.getContainer.

protected String
getDomainInternal()

Implements abstract org.apache.catalina.util.LifecycleMBeanBase.getDomainInternal.

Method implemented by sub-classes to identify the domain in which MBeans should be registered.

private Class<?>
getFieldType(Class<?> clazz, String name)

protected String
getObjectNameKeyProperties()

Implements abstract org.apache.catalina.util.LifecycleMBeanBase.getObjectNameKeyProperties.

Allow sub-classes to specify the key properties component of the ObjectName that will be used to register this component.

private Server
private Class<?>
getSetterType(Class<?> clazz, String name)

public ContextTransaction

Returns:

the transaction object.
getTransaction
()

protected void
initInternal()

Overrides org.apache.catalina.util.LifecycleMBeanBase.initInternal.

Sub-classes wishing to perform additional initialization should override this method, ensuring that super.initInternal() is the first call in the overriding method.

public void
removeEjb(String
Name of the EJB resource reference to remove
name
)

Remove any EJB resource reference with the specified name.

public void
removeEnvironment(String
Name of the environment entry to remove
name
)

Implements org.apache.tomcat.util.descriptor.web.NamingResources.removeEnvironment.

Remove any environment entry with the specified name.

public void
removeLocalEjb(String
Name of the EJB resource reference to remove
name
)

Remove any local EJB resource reference with the specified name.

public void
removeMessageDestinationRef(String
Name of the message destination resource reference to remove
name
)

Remove any message destination reference with the specified name.

public void
removePropertyChangeListener(PropertyChangeListener
The listener to remove
listener
)

Remove a property change listener from this component.

public void
removeResource(String
Name of the resource reference to remove
name
)

Implements org.apache.tomcat.util.descriptor.web.NamingResources.removeResource.

Remove any resource reference with the specified name.

public void
removeResourceEnvRef(String
Name of the resource environment reference to remove
name
)

Remove any resource environment reference with the specified name.

public void
removeService(String
Name of the web service reference to remove
name
)

Remove any web service reference with the specified name.

public void
setContainer(Object
the associated with the resources
container
)

Set the container with which the naming resources are associated.

public void
setTransaction(ContextTransaction
the transaction descriptor
transaction
)

Set the transaction object.

protected void
startInternal()

Implements abstract org.apache.catalina.util.LifecycleBase.startInternal.

Sub-classes must ensure that the state is changed to LifecycleState#STARTING during the execution of this method.

protected void
stopInternal()

Implements abstract org.apache.catalina.util.LifecycleBase.stopInternal.

Sub-classes must ensure that the state is changed to LifecycleState#STOPPING during the execution of this method.

Inherited from org.apache.catalina.util.LifecycleMBeanBase:
getDomaingetObjectNamepostDeregisterpostRegisterpreDeregisterpreRegisterregistersetDomainunregisterunregister

Field Detail

containerback to summary
private Object container

Associated container object.

ejbsback to summary
private final Map<String, ContextEjb> ejbs

The EJB resource references for this web application, keyed by name.

entriesback to summary
private final Set<String> entries

Set of naming entries, keyed by name.

envsback to summary
private final Map<String, ContextEnvironment> envs

The environment entries for this web application, keyed by name.

localEjbsback to summary
private final Map<String, ContextLocalEjb> localEjbs

The local EJB resource references for this web application, keyed by name.

logback to summary
private static final Log log

Hides org.apache.catalina.util.LifecycleMBeanBase.log.

mdrsback to summary
private final Map<String, MessageDestinationRef> mdrs

The message destination references for this web application, keyed by name.

resourceEnvRefsback to summary
private final HashMap<String, ContextResourceEnvRef> resourceEnvRefs

The resource environment references for this web application, keyed by name.

resourceRequireExplicitRegistrationback to summary
private volatile boolean resourceRequireExplicitRegistration
resourcesback to summary
private final HashMap<String, ContextResource> resources

The resource references for this web application, keyed by name.

serialVersionUIDback to summary
private static final long serialVersionUID
servicesback to summary
private final HashMap<String, ContextService> services

The web service references for this web application, keyed by name.

smback to summary
private static final StringManager sm

Hides org.apache.catalina.util.LifecycleMBeanBase.sm.

supportback to summary
protected final PropertyChangeSupport support

The property change support for this component.

transactionback to summary
private ContextTransaction transaction

The transaction for this webapp.

Constructor Detail

NamingResourcesImplback to summary
public NamingResourcesImpl()

Create a new NamingResources instance.

Method Detail

addEjbback to summary
public void addEjb(ContextEjb ejb)

Add an EJB resource reference for this web application.

Parameters
ejb:ContextEjb

New EJB resource reference

addEnvironmentback to summary
public void addEnvironment(ContextEnvironment environment)

Implements org.apache.tomcat.util.descriptor.web.NamingResources.addEnvironment.

Add an environment entry for this web application.

Parameters
environment:ContextEnvironment

New environment entry

Annotations
@Override
addLocalEjbback to summary
public void addLocalEjb(ContextLocalEjb ejb)

Add a local EJB resource reference for this web application.

Parameters
ejb:ContextLocalEjb

New EJB resource reference

addMessageDestinationRefback to summary
public void addMessageDestinationRef(MessageDestinationRef mdr)

Add a message destination reference for this web application.

Parameters
mdr:MessageDestinationRef

New message destination reference

addPropertyChangeListenerback to summary
public void addPropertyChangeListener(PropertyChangeListener listener)

Add a property change listener to this component.

Parameters
listener:PropertyChangeListener

The listener to add

addResourceback to summary
public void addResource(ContextResource resource)

Implements org.apache.tomcat.util.descriptor.web.NamingResources.addResource.

Add a resource reference for this web application.

Parameters
resource:ContextResource

New resource reference

Annotations
@Override
addResourceEnvRefback to summary
public void addResourceEnvRef(ContextResourceEnvRef resource)

Add a resource environment reference for this web application.

Parameters
resource:ContextResourceEnvRef

The resource

addServiceback to summary
public void addService(ContextService service)

Add a web service reference for this web application.

Parameters
service:ContextService

New web service reference

checkResourceTypeback to summary
private boolean checkResourceType(ResourceBase resource)

Checks that the configuration of the type for the specified resource is consistent with any injection targets and if the type is not specified, tries to configure the type based on the injection targets

Parameters
resource:ResourceBase

The resource to check

Returns:boolean

true if the type for the resource is now valid (if previously null this means it is now set) or false if the current resource type is inconsistent with the injection targets and/or cannot be determined

cleanUpback to summary
private void cleanUp()

Close those resources that an explicit close may help clean-up faster.

cleanUpback to summary
private void cleanUp(Object resource, String name, String closeMethod)

Clean up a resource by calling the defined close method. For example, closing a database connection pool will close it's open connections. This will happen on GC but that leaves db connections open that may cause issues.

Parameters
resource:Object

The resource to close.

destroyInternalback to summary
protected void destroyInternal() throws LifecycleException

Overrides org.apache.catalina.util.LifecycleMBeanBase.destroyInternal.

Doc from org.apache.catalina.util.LifecycleMBeanBase.destroyInternal.

Sub-classes wishing to perform additional clean-up should override this method, ensuring that super.destroyInternal() is the last call in the overriding method.

Annotations
@Override
Exceptions
LifecycleException:

Doc from org.apache.catalina.util.LifecycleBase.destroyInternal.

If the destruction fails

findEjbback to summary
public ContextEjb findEjb(String name)
Parameters
name:String

Name of the desired EJB resource reference

Returns:ContextEjb

the EJB resource reference with the specified name, if any; otherwise, return null.

findEjbsback to summary
public ContextEjb[] findEjbs()
Returns:ContextEjb[]

the defined EJB resource references for this application. If there are none, a zero-length array is returned.

findEnvironmentback to summary
public ContextEnvironment findEnvironment(String name)
Parameters
name:String

Name of the desired environment entry

Returns:ContextEnvironment

the environment entry with the specified name, if any; otherwise, return null.

findEnvironmentsback to summary
public ContextEnvironment[] findEnvironments()
Returns:ContextEnvironment[]

the set of defined environment entries for this web application. If none have been defined, a zero-length array is returned.

findLocalEjbback to summary
public ContextLocalEjb findLocalEjb(String name)
Parameters
name:String

Name of the desired EJB resource reference

Returns:ContextLocalEjb

the local EJB resource reference with the specified name, if any; otherwise, return null.

findLocalEjbsback to summary
public ContextLocalEjb[] findLocalEjbs()
Returns:ContextLocalEjb[]

the defined local EJB resource references for this application. If there are none, a zero-length array is returned.

findMessageDestinationRefback to summary
public MessageDestinationRef findMessageDestinationRef(String name)
Parameters
name:String

Name of the desired message destination reference

Returns:MessageDestinationRef

the message destination reference with the specified name, if any; otherwise, return null.

findMessageDestinationRefsback to summary
public MessageDestinationRef[] findMessageDestinationRefs()
Returns:MessageDestinationRef[]

the defined message destination references for this application. If there are none, a zero-length array is returned.

findResourceback to summary
public ContextResource findResource(String name)
Parameters
name:String

Name of the desired resource reference

Returns:ContextResource

the resource reference with the specified name, if any; otherwise return null.

findResourceEnvRefback to summary
public ContextResourceEnvRef findResourceEnvRef(String name)
Parameters
name:String

Name of the desired resource environment reference

Returns:ContextResourceEnvRef

the resource environment reference type for the specified name, if any; otherwise return null.

findResourceEnvRefsback to summary
public ContextResourceEnvRef[] findResourceEnvRefs()
Returns:ContextResourceEnvRef[]

the set of resource environment reference names for this web application. If none have been specified, a zero-length array is returned.

findResourcesback to summary
public ContextResource[] findResources()
Returns:ContextResource[]

the defined resource references for this application. If none have been defined, a zero-length array is returned.

findServiceback to summary
public ContextService findService(String name)
Parameters
name:String

Name of the desired web service

Returns:ContextService

the web service reference for the specified name, if any; otherwise return null.

findServicesback to summary
public ContextService[] findServices()
Returns:ContextService[]

the defined web service references for this application. If none have been defined, a zero-length array is returned.

getCompatibleTypeback to summary
private Class<?> getCompatibleType(Context context, ResourceBase resource, Class<?> typeClass)
getContainerback to summary
public Object getContainer()

Implements org.apache.tomcat.util.descriptor.web.NamingResources.getContainer.

Returns:Object

the container with which the naming resources are associated.

Annotations
@Override
getDomainInternalback to summary
protected String getDomainInternal()

Implements abstract org.apache.catalina.util.LifecycleMBeanBase.getDomainInternal.

Doc from org.apache.catalina.util.LifecycleMBeanBase.getDomainInternal.

Method implemented by sub-classes to identify the domain in which MBeans should be registered.

Returns:String

The name of the domain to use to register MBeans.

Annotations
@Override
getFieldTypeback to summary
private Class<?> getFieldType(Class<?> clazz, String name)
getObjectNameKeyPropertiesback to summary
protected String getObjectNameKeyProperties()

Implements abstract org.apache.catalina.util.LifecycleMBeanBase.getObjectNameKeyProperties.

Doc from org.apache.catalina.util.LifecycleMBeanBase.getObjectNameKeyProperties.

Allow sub-classes to specify the key properties component of the ObjectName that will be used to register this component.

Returns:String

The string representation of the key properties component of the desired ObjectName

Annotations
@Override
getServerback to summary
private Server getServer()
getSetterTypeback to summary
private Class<?> getSetterType(Class<?> clazz, String name)
getTransactionback to summary
public ContextTransaction getTransaction()
Returns:ContextTransaction

the transaction object.

initInternalback to summary
protected void initInternal() throws LifecycleException

Overrides org.apache.catalina.util.LifecycleMBeanBase.initInternal.

Doc from org.apache.catalina.util.LifecycleMBeanBase.initInternal.

Sub-classes wishing to perform additional initialization should override this method, ensuring that super.initInternal() is the first call in the overriding method.

Annotations
@Override
Exceptions
LifecycleException:

Doc from org.apache.catalina.util.LifecycleBase.initInternal.

If the initialisation fails

removeEjbback to summary
public void removeEjb(String name)

Remove any EJB resource reference with the specified name.

Parameters
name:String

Name of the EJB resource reference to remove

removeEnvironmentback to summary
public void removeEnvironment(String name)

Implements org.apache.tomcat.util.descriptor.web.NamingResources.removeEnvironment.

Remove any environment entry with the specified name.

Parameters
name:String

Name of the environment entry to remove

Annotations
@Override
removeLocalEjbback to summary
public void removeLocalEjb(String name)

Remove any local EJB resource reference with the specified name.

Parameters
name:String

Name of the EJB resource reference to remove

removeMessageDestinationRefback to summary
public void removeMessageDestinationRef(String name)

Remove any message destination reference with the specified name.

Parameters
name:String

Name of the message destination resource reference to remove

removePropertyChangeListenerback to summary
public void removePropertyChangeListener(PropertyChangeListener listener)

Remove a property change listener from this component.

Parameters
listener:PropertyChangeListener

The listener to remove

removeResourceback to summary
public void removeResource(String name)

Implements org.apache.tomcat.util.descriptor.web.NamingResources.removeResource.

Remove any resource reference with the specified name.

Parameters
name:String

Name of the resource reference to remove

Annotations
@Override
removeResourceEnvRefback to summary
public void removeResourceEnvRef(String name)

Remove any resource environment reference with the specified name.

Parameters
name:String

Name of the resource environment reference to remove

removeServiceback to summary
public void removeService(String name)

Remove any web service reference with the specified name.

Parameters
name:String

Name of the web service reference to remove

setContainerback to summary
public void setContainer(Object container)

Set the container with which the naming resources are associated.

Parameters
container:Object

the associated with the resources

setTransactionback to summary
public void setTransaction(ContextTransaction transaction)

Set the transaction object.

Parameters
transaction:ContextTransaction

the transaction descriptor

startInternalback to summary
protected void startInternal() throws LifecycleException

Implements abstract org.apache.catalina.util.LifecycleBase.startInternal.

Doc from org.apache.catalina.util.LifecycleBase.startInternal.

Sub-classes must ensure that the state is changed to LifecycleState#STARTING during the execution of this method. Changing state will trigger the Lifecycle#START_EVENT event. If a component fails to start it may either throw a LifecycleException which will cause it's parent to fail to start or it can place itself in the error state in which case stop() will be called on the failed component but the parent component will continue to start normally.

Annotations
@Override
Exceptions
LifecycleException:
Start error occurred
stopInternalback to summary
protected void stopInternal() throws LifecycleException

Implements abstract org.apache.catalina.util.LifecycleBase.stopInternal.

Doc from org.apache.catalina.util.LifecycleBase.stopInternal.

Sub-classes must ensure that the state is changed to LifecycleState#STOPPING during the execution of this method. Changing state will trigger the Lifecycle#STOP_EVENT event.

Annotations
@Override
Exceptions
LifecycleException:
Stop error occurred