org.apache.catalina.core
Class StandardServer

java.lang.Object
  extended by org.apache.catalina.core.StandardServer
All Implemented Interfaces:
javax.management.MBeanRegistration, Lifecycle, Server

public final class StandardServer
extends java.lang.Object
implements Lifecycle, Server, javax.management.MBeanRegistration

Standard implementation of the Server interface, available for use (but not required) when deploying and starting Catalina.

Version:
$Revision: 1237 $ $Date: 2009-11-03 02:55:48 +0100 (Tue, 03 Nov 2009) $
Author:
Craig R. McClanahan

Field Summary
protected  java.lang.String domain
           
protected  javax.management.MBeanServer mserver
           
protected  javax.management.ObjectName oname
           
protected  java.lang.String suffix
           
protected  java.beans.PropertyChangeSupport support
          The property change support for this component.
protected  java.lang.String type
           
 
Fields inherited from interface org.apache.catalina.Lifecycle
AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, DESTROY_EVENT, INIT_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
 
Constructor Summary
StandardServer()
          Construct a default instance of this class.
 
Method Summary
 void addLifecycleListener(LifecycleListener listener)
          Add a LifecycleEvent listener to this component.
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Add a property change listener to this component.
 void addService(Service service)
          Add a new Service to the set of defined Services.
 void await()
          Wait until a proper shutdown command is received, then return.
 LifecycleListener[] findLifecycleListeners()
          Get the lifecycle listeners associated with this lifecycle.
 Service findService(java.lang.String name)
          Return the specified Service (if it exists); otherwise return null.
 Service[] findServices()
          Return the set of Services defined within this Server.
 java.lang.String getAddress()
          Return the address on which we listen to for shutdown commands.
 java.lang.String getDomain()
           
 javax.naming.Context getGlobalNamingContext()
          Return the global naming resources context.
 NamingResources getGlobalNamingResources()
          Return the global naming resources.
 java.lang.String getInfo()
          Return descriptive information about this Server implementation and the corresponding version number, in the format <description>/<version>.
 javax.management.ObjectName getObjectName()
           
 int getPort()
          Return the port number we listen to for shutdown commands.
 java.lang.String getServerInfo()
          Report the current Tomcat Server Release number
 javax.management.ObjectName[] getServiceNames()
          Return the JMX service names.
 java.lang.String getShutdown()
          Return the shutdown command string we are waiting for.
 void init()
           
 void initialize()
          Invoke a pre-startup initialization.
 void postDeregister()
           
 void postRegister(java.lang.Boolean registrationDone)
           
 void preDeregister()
           
 javax.management.ObjectName preRegister(javax.management.MBeanServer server, javax.management.ObjectName name)
           
 void removeLifecycleListener(LifecycleListener listener)
          Remove a LifecycleEvent listener from this component.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Remove a property change listener from this component.
 void removeService(Service service)
          Remove the specified Service from the set associated from this Server.
 void setAddress(java.lang.String address)
          Set the address on which we listen to for shutdown commands.
 void setGlobalNamingContext(javax.naming.Context globalNamingContext)
          Set the global naming resources context.
 void setGlobalNamingResources(NamingResources globalNamingResources)
          Set the global naming resources.
 void setPort(int port)
          Set the port number we listen to for shutdown commands.
 void setShutdown(java.lang.String shutdown)
          Set the shutdown command we are waiting for.
 void start()
          Prepare for the beginning of active use of the public methods of this component.
 void stop()
          Gracefully terminate the active use of the public methods of this component.
 void stopAwait()
           
 void storeConfig()
          Write the configuration information for this entire Server out to the server.xml configuration file.
 void storeContext(Context context)
          Write the configuration information for Context out to the specified configuration file.
 java.lang.String toString()
          Return a String representation of this component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

support

protected java.beans.PropertyChangeSupport support
The property change support for this component.


type

protected java.lang.String type

domain

protected java.lang.String domain

suffix

protected java.lang.String suffix

oname

protected javax.management.ObjectName oname

mserver

protected javax.management.MBeanServer mserver
Constructor Detail

StandardServer

public StandardServer()
Construct a default instance of this class.

Method Detail

getGlobalNamingContext

public javax.naming.Context getGlobalNamingContext()
Return the global naming resources context.


setGlobalNamingContext

public void setGlobalNamingContext(javax.naming.Context globalNamingContext)
Set the global naming resources context.

Parameters:
globalNamingContext - The new global naming resource context

getGlobalNamingResources

public NamingResources getGlobalNamingResources()
Return the global naming resources.

Specified by:
getGlobalNamingResources in interface Server

setGlobalNamingResources

public void setGlobalNamingResources(NamingResources globalNamingResources)
Set the global naming resources.

Specified by:
setGlobalNamingResources in interface Server
Parameters:
globalNamingResources - The new global naming resources

getInfo

public java.lang.String getInfo()
Return descriptive information about this Server implementation and the corresponding version number, in the format <description>/<version>.

Specified by:
getInfo in interface Server

getServerInfo

public java.lang.String getServerInfo()
Report the current Tomcat Server Release number

Returns:
Tomcat release identifier

getPort

public int getPort()
Return the port number we listen to for shutdown commands.

Specified by:
getPort in interface Server

setPort

public void setPort(int port)
Set the port number we listen to for shutdown commands.

Specified by:
setPort in interface Server
Parameters:
port - The new port number

getAddress

public java.lang.String getAddress()
Return the address on which we listen to for shutdown commands.

Specified by:
getAddress in interface Server

setAddress

public void setAddress(java.lang.String address)
Set the address on which we listen to for shutdown commands.

Specified by:
setAddress in interface Server
Parameters:
address - The new address

getShutdown

public java.lang.String getShutdown()
Return the shutdown command string we are waiting for.

Specified by:
getShutdown in interface Server

setShutdown

public void setShutdown(java.lang.String shutdown)
Set the shutdown command we are waiting for.

Specified by:
setShutdown in interface Server
Parameters:
shutdown - The new shutdown command

addService

public void addService(Service service)
Add a new Service to the set of defined Services.

Specified by:
addService in interface Server
Parameters:
service - The Service to be added

stopAwait

public void stopAwait()

await

public void await()
Wait until a proper shutdown command is received, then return. This keeps the main thread alive - the thread pool listening for http connections is daemon threads.

Specified by:
await in interface Server

findService

public Service findService(java.lang.String name)
Return the specified Service (if it exists); otherwise return null.

Specified by:
findService in interface Server
Parameters:
name - Name of the Service to be returned

findServices

public Service[] findServices()
Return the set of Services defined within this Server.

Specified by:
findServices in interface Server

getServiceNames

public javax.management.ObjectName[] getServiceNames()
Return the JMX service names.


removeService

public void removeService(Service service)
Remove the specified Service from the set associated from this Server.

Specified by:
removeService in interface Server
Parameters:
service - The Service to be removed

addPropertyChangeListener

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

Parameters:
listener - The listener to add

removePropertyChangeListener

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

Parameters:
listener - The listener to remove

toString

public java.lang.String toString()
Return a String representation of this component.

Overrides:
toString in class java.lang.Object

storeConfig

public void storeConfig()
                 throws java.lang.Exception
Write the configuration information for this entire Server out to the server.xml configuration file.

Throws:
javax.management.InstanceNotFoundException - if the managed resource object cannot be found
javax.management.MBeanException - if the initializer of the object throws an exception, or persistence is not supported
javax.management.RuntimeOperationsException - if an exception is reported by the persistence mechanism
java.lang.Exception

storeContext

public void storeContext(Context context)
                  throws java.lang.Exception
Write the configuration information for Context out to the specified configuration file.

Throws:
javax.management.InstanceNotFoundException - if the managed resource object cannot be found
javax.management.MBeanException - if the initializer of the object throws an exception, or persistence is not supported
javax.management.RuntimeOperationsException - if an exception is reported by the persistence mechanism
java.lang.Exception

addLifecycleListener

public void addLifecycleListener(LifecycleListener listener)
Add a LifecycleEvent listener to this component.

Specified by:
addLifecycleListener in interface Lifecycle
Parameters:
listener - The listener to add

findLifecycleListeners

public LifecycleListener[] findLifecycleListeners()
Get the lifecycle listeners associated with this lifecycle. If this Lifecycle has no listeners registered, a zero-length array is returned.

Specified by:
findLifecycleListeners in interface Lifecycle

removeLifecycleListener

public void removeLifecycleListener(LifecycleListener listener)
Remove a LifecycleEvent listener from this component.

Specified by:
removeLifecycleListener in interface Lifecycle
Parameters:
listener - The listener to remove

start

public void start()
           throws LifecycleException
Prepare for the beginning of active use of the public methods of this component. This method should be called before any of the public methods of this component are utilized. It should also send a LifecycleEvent of type START_EVENT to any registered listeners.

Specified by:
start in interface Lifecycle
Throws:
LifecycleException - if this component detects a fatal error that prevents this component from being used

stop

public void stop()
          throws LifecycleException
Gracefully terminate the active use of the public methods of this component. This method should be the last one called on a given instance of this component. It should also send a LifecycleEvent of type STOP_EVENT to any registered listeners.

Specified by:
stop in interface Lifecycle
Throws:
LifecycleException - if this component detects a fatal error that needs to be reported

init

public void init()
          throws java.lang.Exception
Throws:
java.lang.Exception

initialize

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

Specified by:
initialize in interface Server
Throws:
LifecycleException - If this server was already initialized.

getObjectName

public javax.management.ObjectName getObjectName()

getDomain

public java.lang.String getDomain()

preRegister

public javax.management.ObjectName preRegister(javax.management.MBeanServer server,
                                               javax.management.ObjectName name)
                                        throws java.lang.Exception
Specified by:
preRegister in interface javax.management.MBeanRegistration
Throws:
java.lang.Exception

postRegister

public void postRegister(java.lang.Boolean registrationDone)
Specified by:
postRegister in interface javax.management.MBeanRegistration

preDeregister

public void preDeregister()
                   throws java.lang.Exception
Specified by:
preDeregister in interface javax.management.MBeanRegistration
Throws:
java.lang.Exception

postDeregister

public void postDeregister()
Specified by:
postDeregister in interface javax.management.MBeanRegistration


Copyright © 2000-2009 Apache Software Foundation. All Rights Reserved.