# Class StandardService

java.lang.Object
org.apache.catalina.util.LifecycleBase
org.apache.catalina.util.LifecycleMBeanBase
org.apache.catalina.core.StandardService

All Implemented Interfaces:
  `MBeanRegistration, JmxEnabled, Lifecycle, Service`

public class StandardService extends LifecycleMBeanBase implements Service
Standard implementation of the `Service` interface. The associated Container is generally an instance of Engine, but this is not required.

## Nested Class Summary

### Nested classes/interfaces inherited from interface Lifecycle

`Lifecycle.SingleUse`

## Field Summary

Fields
Modifier and Type
Field
Description
`protected Connector[]`
`connectors`
The set of Connectors associated with this Service.
`protected final ArrayList<Executor>`
`executors`
The list of executors held by the service.
`protected final Mapper`
`mapper`
Mapper.
`protected final MapperListener`
`mapperListener`
Mapper listener.
`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
`StandardService()`

## Method Summary

Modifier and Type
Method
Description
`void`
`addConnector(Connector connector)`
Add a new Connector to the set of defined Connectors, and associate it with this Service's Container.
`void`
`addExecutor(Executor ex)`
Adds a named executor to the service
`void`
`addPropertyChangeListener(PropertyChangeListener listener)`
Add a property change listener to this component.
`protected void`
`destroyInternal()`
Subclasses implement this method to perform any instance destruction required.
`Connector[]`
`findConnectors()`
Find and return the set of Connectors associated with this Service.
`Executor[]`
`findExecutors()`
Retrieves all executors
`ObjectName[]`
`getConnectorNames()`
`Engine`
`getContainer()`
`protected String`
`getDomainInternal()`
Method implemented by subclasses to identify the domain in which MBeans should be registered.
`Executor`
`getExecutor(String executorName)`
Retrieves executor by name, null if not found
`long`
`getGracefulStopAwaitMillis()`
`Mapper`
`getMapper()`
`String`
`getName()`
`final String`
`getObjectNameKeyProperties()`
Allow subclasses to specify the key properties component of the `ObjectName` that will be used to register this component.
`ClassLoader`
`getParentClassLoader()`
`Server`
`getServer()`
`protected void`
`initInternal()`
Invoke a pre-startup initialization.
`void`
`removeConnector(Connector connector)`
Remove the specified Connector from the set associated from this Service.
`void`
`removeExecutor(Executor ex)`
Removes an executor from the service
`void`
`removePropertyChangeListener(PropertyChangeListener listener)`
Remove a property change listener from this component.
`void`
`setContainer(Engine engine)`
Set the `Engine` that handles requests for all `Connectors` associated with this Service.
`void`
`setGracefulStopAwaitMillis(long gracefulStopAwaitMillis)`
`void`
`setName(String name)`
Set the name of this Service.
`void`
`setParentClassLoader(ClassLoader parent)`
Set the parent class loader for this service.
`void`
`setServer(Server server)`
Set the `Server` with which we are associated (if any).
`protected void`
`startInternal()`
Start nested components (`Executor`s, `Connector`s and `Container`s) and implement the requirements of `LifecycleBase.startInternal()`.
`protected void`
`stopInternal()`
Stop nested components (`Executor`s, `Connector`s and `Container`s) and implement the requirements of `LifecycleBase.stopInternal()`.
`String`
`toString()`

### 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, wait, wait, wait`

### Methods inherited from interface Lifecycle

`addLifecycleListener, destroy, findLifecycleListeners, getState, getStateName, init, removeLifecycleListener, start, stop`

### Methods inherited from interface Service

`getDomain`

## Field Details

### support

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

### connectors

protected Connector[] connectors
The set of Connectors associated with this Service.

### executors

protected final ArrayList<Executor> executors
The list of executors held by the service.

### mapper

protected final Mapper mapper
Mapper.

### mapperListener

protected final MapperListener mapperListener
Mapper listener.

## Constructor Details

### StandardService

public StandardService()

## Method Details

### getGracefulStopAwaitMillis

public long getGracefulStopAwaitMillis()

### setGracefulStopAwaitMillis

public void setGracefulStopAwaitMillis(long gracefulStopAwaitMillis)

### getMapper

public Mapper getMapper()

Specified by:
  `getMapper` in interface `Service`
Returns:
  the mapper associated with this Service.

### getContainer

public Engine getContainer()

Specified by:
  `getContainer` in interface `Service`
Returns:
  the `Engine` that handles requests for all `Connectors` associated with this Service.

### setContainer

public void setContainer(Engine engine)
Description copied from interface: `Service`
Set the `Engine` that handles requests for all `Connectors` associated with this Service.

Specified by:
  `setContainer` in interface `Service`
Parameters:
  `engine` - The new Engine

### getName

public String getName()

Specified by:
  `getName` in interface `Service`
Returns:
  the name of this Service.

### setName

public void setName(String name)
Description copied from interface: `Service`
Set the name of this Service.

Specified by:
  `setName` in interface `Service`
Parameters:
  `name` - The new service name

### getServer

public Server getServer()

Specified by:
  `getServer` in interface `Service`
Returns:
  the `Server` with which we are associated (if any).

### setServer

public void setServer(Server server)
Description copied from interface: `Service`
Set the `Server` with which we are associated (if any).

Specified by:
  `setServer` in interface `Service`
Parameters:
  `server` - The server that owns this Service

### addConnector

public void addConnector(Connector connector)
Description copied from interface: `Service`
Add a new Connector to the set of defined Connectors, and associate it with this Service's Container.

Specified by:
  `addConnector` in interface `Service`
Parameters:
  `connector` - The Connector to be added

### getConnectorNames

public ObjectName[] getConnectorNames()

### addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Add a property change listener to this component.

Parameters:
  `listener` - The listener to add

### findConnectors

public Connector[] findConnectors()
Description copied from interface: `Service`
Find and return the set of Connectors associated with this Service.

Specified by:
  `findConnectors` in interface `Service`
Returns:
  the array of associated Connectors

### removeConnector

public void removeConnector(Connector connector)
Description copied from interface: `Service`
Remove the specified Connector from the set associated from this Service. The removed Connector will also be disassociated from our Container.

Specified by:
  `removeConnector` in interface `Service`
Parameters:
  `connector` - The Connector to be removed

### removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Remove a property change listener from this component.

Parameters:
  `listener` - The listener to remove

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### addExecutor

public void addExecutor(Executor ex)
Description copied from interface: `Service`
Adds a named executor to the service

Specified by:
  `addExecutor` in interface `Service`
Parameters:
  `ex` - Executor

### findExecutors

public Executor[] findExecutors()
Description copied from interface: `Service`
Retrieves all executors

Specified by:
  `findExecutors` in interface `Service`
Returns:
  Executor[]

### getExecutor

public Executor getExecutor(String executorName)
Description copied from interface: `Service`
Retrieves executor by name, null if not found

Specified by:
  `getExecutor` in interface `Service`
Parameters:
  `executorName` - String
Returns:
  Executor

### removeExecutor

public void removeExecutor(Executor ex)
Description copied from interface: `Service`
Removes an executor from the service

Specified by:
  `removeExecutor` in interface `Service`
Parameters:
  `ex` - Executor

### startInternal

protected void startInternal() throws LifecycleException
Start nested components (`Executor`s, `Connector`s and `Container`s) and implement the requirements of `LifecycleBase.startInternal()`.

Specified by:
  `startInternal` in class `LifecycleBase`
Throws:
  `LifecycleException` - if this component detects a fatal error that prevents this component from being used

### stopInternal

protected void stopInternal() throws LifecycleException
Stop nested components (`Executor`s, `Connector`s and `Container`s) and implement the requirements of `LifecycleBase.stopInternal()`.

Specified by:
  `stopInternal` in class `LifecycleBase`
Throws:
  `LifecycleException` - if this component detects a fatal error that needs to be reported

### initInternal

protected void initInternal() throws LifecycleException
Invoke a pre-startup initialization. This is used to allow connectors to bind to restricted ports under Unix operating environments.

Overrides:
  `initInternal` in class `LifecycleMBeanBase`
Throws:
  `LifecycleException` - if this component detects a fatal error that needs to be reported

### 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

### getParentClassLoader

public ClassLoader getParentClassLoader()

Specified by:
  `getParentClassLoader` in interface `Service`
Returns:
  the parent class loader for this component. If not set, return `Service.getServer()` `Server.getParentClassLoader()`. If no server has been set, return the system class loader.

### setParentClassLoader

public void setParentClassLoader(ClassLoader parent)
Description copied from interface: `Service`
Set the parent class loader for this service.

Specified by:
  `setParentClassLoader` in interface `Service`
Parameters:
  `parent` - The new parent class loader

### 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

public final 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`