Interface Server
- All Superinterfaces:
Lifecycle
- All Known Implementing Classes:
StandardServer
A
Server element represents the entire Catalina servlet container. Its attributes represent the
characteristics of the servlet container as a whole. A Server may contain one or more
Services, and the top level set of naming resources.
Normally, an implementation of this interface will also implement Lifecycle, such that when the
start() and stop() methods are called, all of the defined Services are also
started or stopped.
In between, the implementation must open a server socket on the port number specified by the port
property. When a connection is accepted, the first line is read and compared with the specified shutdown command. If
the command matches, shutdown of the server is initiated.
-
Nested Class Summary
Nested classes/interfaces inherited from interface Lifecycle
Lifecycle.SingleUse -
Field Summary
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidaddService(Service service) Add a new Service to the set of defined Services.voidawait()Wait until a proper shutdown command is received, then return.findService(String name) Find the specified ServiceService[]Returns the array of all Services defined within this Server.Returns the address on which the server listens for shutdown commands.Returns the outer Catalina startup/shutdown component, if one has been set.Returns the configured base (instance) directory.Returns the configured home (binary) directory.Returns the global JNDI naming context for this server.Returns the global naming resources for this server.Returns the token required for performing operations on the associated JNDI naming context.Returns the parent class loader for this server component.intgetPort()Returns the port number on which the server listens for shutdown commands.intGet the number that offsets the port used for shutdown commands.intGet the actual port on which server is listening for the shutdown commands.Returns the shutdown command string the server is waiting for.Returns the utility executor managed by the server for background tasks.intGet the utility thread count.voidremoveService(Service service) Remove the specified Service from the set associated from this Server.voidsetAddress(String address) Set the address on which we listen to for shutdown commands.voidsetCatalina(Catalina catalina) Set the outer Catalina startup/shutdown component if present.voidsetCatalinaBase(File catalinaBase) Set the configured base (instance) directory.voidsetCatalinaHome(File catalinaHome) Set the configured home (binary) directory.voidsetGlobalNamingResources(NamingResourcesImpl globalNamingResources) Set the global naming resources.voidsetParentClassLoader(ClassLoader parent) Set the parent class loader for this server.voidsetPort(int port) Set the port number we listen to for shutdown commands.voidsetPortOffset(int portOffset) Set the number that offsets the server port used for shutdown commands.voidsetShutdown(String shutdown) Set the shutdown command we are waiting for.voidsetUtilityThreads(int utilityThreads) Set the utility thread count.Methods inherited from interface Lifecycle
addLifecycleListener, destroy, findLifecycleListeners, getState, getStateName, init, removeLifecycleListener, start, stop
-
Method Details
-
getGlobalNamingResources
NamingResourcesImpl getGlobalNamingResources()Returns the global naming resources for this server.- Returns:
- the global naming resources
-
setGlobalNamingResources
Set the global naming resources.- Parameters:
globalNamingResources- The new global naming resources
-
getGlobalNamingContext
Context getGlobalNamingContext()Returns the global JNDI naming context for this server.- Returns:
- the global naming context
-
getPort
int getPort()Returns the port number on which the server listens for shutdown commands.- Returns:
- the port number for shutdown commands
- See Also:
-
setPort
void setPort(int port) Set the port number we listen to for shutdown commands.- Parameters:
port- The new port number- See Also:
-
getPortOffset
int getPortOffset()Get the number that offsets the port used for shutdown commands. For example, if port is 8005, and portOffset is 1000, the server listens at 9005.- Returns:
- the port offset
-
setPortOffset
void setPortOffset(int portOffset) Set the number that offsets the server port used for shutdown commands. For example, if port is 8005, and you set portOffset to 1000, connector listens at 9005.- Parameters:
portOffset- sets the port offset
-
getPortWithOffset
int getPortWithOffset()Get the actual port on which server is listening for the shutdown commands. If you do not set port offset, port is returned. If you set port offset, port offset + port is returned.- Returns:
- the port with offset
-
getAddress
String getAddress()Returns the address on which the server listens for shutdown commands.- Returns:
- the address for shutdown commands
-
setAddress
Set the address on which we listen to for shutdown commands.- Parameters:
address- The new address
-
getShutdown
String getShutdown()Returns the shutdown command string the server is waiting for.- Returns:
- the shutdown command string
-
setShutdown
Set the shutdown command we are waiting for.- Parameters:
shutdown- The new shutdown command
-
getParentClassLoader
ClassLoader getParentClassLoader()Returns the parent class loader for this server component. If not explicitly set, returns the parent class loader fromgetCatalina(). If Catalina has not been set, returns the system class loader.- Returns:
- the parent class loader
-
setParentClassLoader
Set the parent class loader for this server.- Parameters:
parent- The new parent class loader
-
getCatalina
Catalina getCatalina()Returns the outer Catalina startup/shutdown component, if one has been set.- Returns:
- the Catalina component, or
nullif not set
-
setCatalina
Set the outer Catalina startup/shutdown component if present.- Parameters:
catalina- the outer Catalina component
-
getCatalinaBase
File getCatalinaBase()Returns the configured base (instance) directory. If not set, the value fromgetCatalinaHome()is used. Note that home and base may be the same (and are by default).- Returns:
- the configured base directory
-
setCatalinaBase
Set the configured base (instance) directory. Note that home and base may be the same (and are by default).- Parameters:
catalinaBase- the configured base directory
-
getCatalinaHome
File getCatalinaHome()Returns the configured home (binary) directory. Note that home and base may be the same (and are by default).- Returns:
- the configured home directory
-
setCatalinaHome
Set the configured home (binary) directory. Note that home and base may be the same (and are by default).- Parameters:
catalinaHome- the configured home directory
-
getUtilityThreads
int getUtilityThreads()Get the utility thread count.- Returns:
- the thread count
-
setUtilityThreads
void setUtilityThreads(int utilityThreads) Set the utility thread count.- Parameters:
utilityThreads- the new thread count
-
addService
Add a new Service to the set of defined Services.- Parameters:
service- The Service to be added
-
await
void await()Wait until a proper shutdown command is received, then return. -
findService
-
findServices
Service[] findServices()Returns the array of all Services defined within this Server.- Returns:
- the array of Services, or an empty array if none are defined
-
removeService
Remove the specified Service from the set associated from this Server.- Parameters:
service- The Service to be removed
-
getNamingToken
Object getNamingToken()Returns the token required for performing operations on the associated JNDI naming context.- Returns:
- the JNDI naming context token
-
getUtilityExecutor
ScheduledExecutorService getUtilityExecutor()Returns the utility executor managed by the server for background tasks.- Returns:
- the utility executor service
-