# Class NamingResourcesImpl

java.lang.Object
org.apache.catalina.util.LifecycleBase
org.apache.catalina.util.LifecycleMBeanBase
org.apache.catalina.deploy.NamingResourcesImpl

All Implemented Interfaces:
  `Serializable, MBeanRegistration, JmxEnabled, Lifecycle, NamingResources`

public class NamingResourcesImpl extends LifecycleMBeanBase implements Serializable, NamingResources
Holds and manages the naming resources defined in the J2EE Enterprise Naming Context and their associated JNDI context.

See Also:
  - Serialized Form

- ## Nested Class Summary

  ### Nested classes/interfaces inherited from interface Lifecycle

  `Lifecycle.SingleUse`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final PropertyChangeSupport`
  `support`
  The property change support for this component.

  ### Fields inherited from class LifecycleMBeanBase

  `mserver`

  ### Fields inherited from interface Lifecycle

  `AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `NamingResourcesImpl()`
  Create a new NamingResources instance.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addEjb(ContextEjb ejb)`
  Add an EJB resource reference for this web application.
  `void`
  `addEnvironment(ContextEnvironment environment)`
  Add an environment entry for this web application.
  `void`
  `addLocalEjb(ContextLocalEjb ejb)`
  Add a local EJB resource reference for this web application.
  `void`
  `addMessageDestinationRef(MessageDestinationRef mdr)`
  Add a message destination reference for this web application.
  `void`
  `addPropertyChangeListener(PropertyChangeListener listener)`
  Add a property change listener to this component.
  `void`
  `addResource(ContextResource resource)`
  Add a resource reference for this web application.
  `void`
  `addResourceEnvRef(ContextResourceEnvRef resource)`
  Add a resource environment reference for this web application.
  `void`
  `addResourceLink(ContextResourceLink resourceLink)`
  Add a resource link for this web application.
  `void`
  `addService(ContextService service)`
  Add a web service reference for this web application.
  `protected void`
  `destroyInternal()`
  Subclasses implement this method to perform any instance destruction required.
  `ContextEjb`
  `findEjb(String name)`
  Return the EJB resource reference with the specified name.
  `ContextEjb[]`
  `findEjbs()`
  Return the defined EJB resource references for this application.
  `ContextEnvironment`
  `findEnvironment(String name)`
  Return the environment entry with the specified name.
  `ContextEnvironment[]`
  `findEnvironments()`
  Return the array of defined environment entries for this web application.
  `ContextLocalEjb`
  `findLocalEjb(String name)`
  Return the local EJB resource reference with the specified name.
  `ContextLocalEjb[]`
  `findLocalEjbs()`
  Return the defined local EJB resource references for this application.
  `MessageDestinationRef`
  `findMessageDestinationRef(String name)`
  Return the message destination reference with the specified name.
  `MessageDestinationRef[]`
  `findMessageDestinationRefs()`
  Return the defined message destination references for this application.
  `ContextResource`
  `findResource(String name)`
  Return the resource reference with the specified name.
  `ContextResourceEnvRef`
  `findResourceEnvRef(String name)`
  Return the resource environment reference type for the specified name.
  `ContextResourceEnvRef[]`
  `findResourceEnvRefs()`
  Return the array of resource environment reference names for this web application.
  `ContextResourceLink`
  `findResourceLink(String name)`
  Return the resource link with the specified name.
  `ContextResourceLink[]`
  `findResourceLinks()`
  Return the defined resource links for this application.
  `ContextResource[]`
  `findResources()`
  Return the defined resource references for this application.
  `ContextService`
  `findService(String name)`
  Return the web service reference for the specified name.
  `ContextService[]`
  `findServices()`
  Return the defined web service references for this application.
  `Object`
  `getContainer()`
  Returns the container with which the naming resources are associated.
  `protected String`
  `getDomainInternal()`
  Method implemented by subclasses to identify the domain in which MBeans should be registered.
  `protected String`
  `getObjectNameKeyProperties()`
  Allow subclasses to specify the key properties component of the `ObjectName` that will be used to register this component.
  `ContextTransaction`
  `getTransaction()`
  Return the transaction object.
  `protected void`
  `initInternal()`
  Subclasses implement this method to perform any instance initialisation required.
  `void`
  `removeEjb(String name)`
  Remove any EJB resource reference with the specified name.
  `void`
  `removeEnvironment(String name)`
  Remove any environment entry with the specified name.
  `void`
  `removeLocalEjb(String name)`
  Remove any local EJB resource reference with the specified name.
  `void`
  `removeMessageDestinationRef(String name)`
  Remove any message destination reference with the specified name.
  `void`
  `removePropertyChangeListener(PropertyChangeListener listener)`
  Remove a property change listener from this component.
  `void`
  `removeResource(String name)`
  Remove any resource reference with the specified name.
  `void`
  `removeResourceEnvRef(String name)`
  Remove any resource environment reference with the specified name.
  `void`
  `removeResourceLink(String name)`
  Remove any resource link with the specified name.
  `void`
  `removeService(String name)`
  Remove any web service reference with the specified name.
  `void`
  `setContainer(Object container)`
  Set the container with which the naming resources are associated.
  `void`
  `setTransaction(ContextTransaction transaction)`
  Set the transaction object.
  `protected void`
  `startInternal()`
  Subclasses must ensure that the state is changed to `LifecycleState.STARTING` during the execution of this method.
  `protected void`
  `stopInternal()`
  Subclasses must ensure that the state is changed to `LifecycleState.STOPPING` during the execution of this method.

  ### Methods inherited from class LifecycleMBeanBase

  `getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister, unregister`

  ### Methods inherited from class LifecycleBase

  `addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### support

    protected final PropertyChangeSupport support
    The property change support for this component.

- ## Constructor Details

  - ### NamingResourcesImpl

    public NamingResourcesImpl()
    Create a new NamingResources instance.

- ## Method Details

  - ### getContainer

    public Object getContainer()
    Description copied from interface: `NamingResources`
    Returns the container with which the naming resources are associated.
    Specified by:
      `getContainer` in interface `NamingResources`
    Returns:
      the container with which the naming resources are associated

  - ### setContainer

    public void setContainer(Object container)
    Set the container with which the naming resources are associated.
    Parameters:
      `container` - the associated with the resources

  - ### setTransaction

    public void setTransaction(ContextTransaction transaction)
    Set the transaction object.
    Parameters:
      `transaction` - the transaction descriptor

  - ### getTransaction

    public ContextTransaction getTransaction()
    Return the transaction object.
    Returns:
      the transaction object

  - ### addEjb

    public void addEjb(ContextEjb ejb)
    Add an EJB resource reference for this web application.
    Parameters:
      `ejb` - New EJB resource reference

  - ### addEnvironment

    public void addEnvironment(ContextEnvironment environment)
    Description copied from interface: `NamingResources`
    Add an environment entry for this web application.
    Specified by:
      `addEnvironment` in interface `NamingResources`
    Parameters:
      `environment` - New environment entry

  - ### addLocalEjb

    public void addLocalEjb(ContextLocalEjb ejb)
    Add a local EJB resource reference for this web application.
    Parameters:
      `ejb` - New EJB resource reference

  - ### addMessageDestinationRef

    public void addMessageDestinationRef(MessageDestinationRef mdr)
    Add a message destination reference for this web application.
    Parameters:
      `mdr` - New message destination reference

  - ### addPropertyChangeListener

    public void addPropertyChangeListener(PropertyChangeListener listener)
    Add a property change listener to this component.
    Parameters:
      `listener` - The listener to add

  - ### addResource

    public void addResource(ContextResource resource)
    Description copied from interface: `NamingResources`
    Add a resource reference for this web application.
    Specified by:
      `addResource` in interface `NamingResources`
    Parameters:
      `resource` - New resource reference

  - ### addResourceEnvRef

    public void addResourceEnvRef(ContextResourceEnvRef resource)
    Add a resource environment reference for this web application.
    Parameters:
      `resource` - The resource

  - ### addResourceLink

    public void addResourceLink(ContextResourceLink resourceLink)
    Description copied from interface: `NamingResources`
    Add a resource link for this web application.
    Specified by:
      `addResourceLink` in interface `NamingResources`
    Parameters:
      `resourceLink` - New resource link

  - ### addService

    public void addService(ContextService service)
    Add a web service reference for this web application.
    Parameters:
      `service` - New web service reference

  - ### findEjb

    public ContextEjb findEjb(String name)
    Return the EJB resource reference with the specified name.
    Parameters:
      `name` - Name of the desired EJB resource reference
    Returns:
      the EJB resource reference, or `null` if not found

  - ### findEjbs

    public ContextEjb[] findEjbs()
    Return the defined EJB resource references for this application.
    Returns:
      the EJB resource references, or a zero-length array if none

  - ### findEnvironment

    public ContextEnvironment findEnvironment(String name)
    Return the environment entry with the specified name.
    Parameters:
      `name` - Name of the desired environment entry
    Returns:
      the environment entry, or `null` if not found

  - ### findEnvironments

    public ContextEnvironment[] findEnvironments()
    Return the array of defined environment entries for this web application.
    Returns:
      the environment entries, or a zero-length array if none

  - ### findLocalEjb

    public ContextLocalEjb findLocalEjb(String name)
    Return the local EJB resource reference with the specified name.
    Parameters:
      `name` - Name of the desired EJB resource reference
    Returns:
      the local EJB resource reference, or `null` if not found

  - ### findLocalEjbs

    public ContextLocalEjb[] findLocalEjbs()
    Return the defined local EJB resource references for this application.
    Returns:
      the local EJB resource references, or a zero-length array if none

  - ### findMessageDestinationRef

    public MessageDestinationRef findMessageDestinationRef(String name)
    Return the message destination reference with the specified name.
    Parameters:
      `name` - Name of the desired message destination reference
    Returns:
      the message destination reference, or `null` if not found

  - ### findMessageDestinationRefs

    public MessageDestinationRef[] findMessageDestinationRefs()
    Return the defined message destination references for this application.
    Returns:
      the message destination references, or a zero-length array if none

  - ### findResource

    public ContextResource findResource(String name)
    Return the resource reference with the specified name.
    Parameters:
      `name` - Name of the desired resource reference
    Returns:
      the resource reference, or `null` if not found

  - ### findResourceLink

    public ContextResourceLink findResourceLink(String name)
    Return the resource link with the specified name.
    Parameters:
      `name` - Name of the desired resource link
    Returns:
      the resource link, or `null` if not found

  - ### findResourceLinks

    public ContextResourceLink[] findResourceLinks()
    Return the defined resource links for this application.
    Returns:
      the resource links, or a zero-length array if none

  - ### findResources

    public ContextResource[] findResources()
    Return the defined resource references for this application.
    Returns:
      the resource references, or a zero-length array if none

  - ### findResourceEnvRef

    public ContextResourceEnvRef findResourceEnvRef(String name)
    Return the resource environment reference type for the specified name.
    Parameters:
      `name` - Name of the desired resource environment reference
    Returns:
      the resource environment reference, or `null` if not found

  - ### findResourceEnvRefs

    public ContextResourceEnvRef[] findResourceEnvRefs()
    Return the array of resource environment reference names for this web application.
    Returns:
      the resource environment references, or a zero-length array if none

  - ### findService

    public ContextService findService(String name)
    Return the web service reference for the specified name.
    Parameters:
      `name` - Name of the desired web service
    Returns:
      the web service reference, or `null` if not found

  - ### findServices

    public ContextService[] findServices()
    Return the defined web service references for this application.
    Returns:
      the web service references, or a zero-length array if none

  - ### removeEjb

    public void removeEjb(String name)
    Remove any EJB resource reference with the specified name.
    Parameters:
      `name` - Name of the EJB resource reference to remove

  - ### removeEnvironment

    public void removeEnvironment(String name)
    Description copied from interface: `NamingResources`
    Remove any environment entry with the specified name.
    Specified by:
      `removeEnvironment` in interface `NamingResources`
    Parameters:
      `name` - Name of the environment entry to remove

  - ### removeLocalEjb

    public void removeLocalEjb(String name)
    Remove any local EJB resource reference with the specified name.
    Parameters:
      `name` - Name of the EJB resource reference to remove

  - ### removeMessageDestinationRef

    public void removeMessageDestinationRef(String name)
    Remove any message destination reference with the specified name.
    Parameters:
      `name` - Name of the message destination resource reference to remove

  - ### removePropertyChangeListener

    public void removePropertyChangeListener(PropertyChangeListener listener)
    Remove a property change listener from this component.
    Parameters:
      `listener` - The listener to remove

  - ### removeResource

    public void removeResource(String name)
    Description copied from interface: `NamingResources`
    Remove any resource reference with the specified name.
    Specified by:
      `removeResource` in interface `NamingResources`
    Parameters:
      `name` - Name of the resource reference to remove

  - ### removeResourceEnvRef

    public void removeResourceEnvRef(String name)
    Remove any resource environment reference with the specified name.
    Parameters:
      `name` - Name of the resource environment reference to remove

  - ### removeResourceLink

    public void removeResourceLink(String name)
    Description copied from interface: `NamingResources`
    Remove any resource link with the specified name.
    Specified by:
      `removeResourceLink` in interface `NamingResources`
    Parameters:
      `name` - Name of the resource link to remove

  - ### removeService

    public void removeService(String name)
    Remove any web service reference with the specified name.
    Parameters:
      `name` - Name of the web service reference to remove

  - ### initInternal

    protected void initInternal() throws LifecycleException
    Description copied from class: `LifecycleBase`
    Subclasses implement this method to perform any instance initialisation required.
    Overrides:
      `initInternal` in class `LifecycleMBeanBase`
    Throws:
      `LifecycleException` - If the initialisation fails

  - ### startInternal

    protected void startInternal() throws LifecycleException
    Description copied from class: `LifecycleBase`
    Subclasses 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 `LifecycleBase.stop()` will be called on the failed component but the parent component will continue to start normally.
    Specified by:
      `startInternal` in class `LifecycleBase`
    Throws:
      `LifecycleException` - Start error occurred

  - ### stopInternal

    protected void stopInternal() throws LifecycleException
    Description copied from class: `LifecycleBase`
    Subclasses 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.
    Specified by:
      `stopInternal` in class `LifecycleBase`
    Throws:
      `LifecycleException` - Stop error occurred

  - ### destroyInternal

    protected void destroyInternal() throws LifecycleException
    Description copied from class: `LifecycleBase`
    Subclasses implement this method to perform any instance destruction required.
    Overrides:
      `destroyInternal` in class `LifecycleMBeanBase`
    Throws:
      `LifecycleException` - If the destruction fails

  - ### getDomainInternal

    protected String getDomainInternal()
    Description copied from class: `LifecycleMBeanBase`
    Method implemented by subclasses to identify the domain in which MBeans should be registered.
    Specified by:
      `getDomainInternal` in class `LifecycleMBeanBase`
    Returns:
      The name of the domain to use to register MBeans.

  - ### getObjectNameKeyProperties

    protected String getObjectNameKeyProperties()
    Description copied from class: `LifecycleMBeanBase`
    Allow subclasses to specify the key properties component of the `ObjectName` that will be used to register this component.
    Specified by:
      `getObjectNameKeyProperties` in class `LifecycleMBeanBase`
    Returns:
      The string representation of the key properties component of the desired `ObjectName`