Class StandardServer

  • All Implemented Interfaces:
    javax.management.MBeanRegistration, JmxEnabled, Lifecycle, Server

    public final class StandardServer
    extends LifecycleMBeanBase
    implements Server
    Standard implementation of the Server interface, available for use (but not required) when deploying and starting Catalina.
    Author:
    Craig R. McClanahan
    • Field Detail

      • utilityThreads

        protected int utilityThreads
        The number of threads available to process utility tasks in this service.
      • utilityThreadsAsDaemon

        protected boolean utilityThreadsAsDaemon
        The utility threads daemon flag.
      • periodicEventDelay

        protected int periodicEventDelay
        The lifecycle event period in seconds.
    • Constructor Detail

      • StandardServer

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

      • getNamingToken

        public java.lang.Object getNamingToken()
        Specified by:
        getNamingToken in interface Server
        Returns:
        the token necessary for operations on the associated JNDI naming context.
      • getGlobalNamingContext

        public javax.naming.Context getGlobalNamingContext()
        Return the global naming resources context.
        Specified by:
        getGlobalNamingContext in interface Server
        Returns:
        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
      • setGlobalNamingResources

        public void setGlobalNamingResources​(NamingResourcesImpl globalNamingResources)
        Set the global naming resources.
        Specified by:
        setGlobalNamingResources in interface Server
        Parameters:
        globalNamingResources - The new global naming resources
      • getServerInfo

        public java.lang.String getServerInfo()
        Report the current Tomcat Server Release number
        Returns:
        Tomcat release identifier
      • getServerBuilt

        public java.lang.String getServerBuilt()
        Return the current server built timestamp
        Returns:
        server built timestamp.
      • getServerNumber

        public java.lang.String getServerNumber()
        Return the current server's version number.
        Returns:
        server's version number.
      • 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
        See Also:
        Server.setPortOffset(int)
      • getPortOffset

        public int getPortOffset()
        Description copied from interface: Server
        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.
        Specified by:
        getPortOffset in interface Server
        Returns:
        the port offset
      • setPortOffset

        public void setPortOffset​(int portOffset)
        Description copied from interface: Server
        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.
        Specified by:
        setPortOffset in interface Server
        Parameters:
        portOffset - sets the port offset
      • getPortWithOffset

        public int getPortWithOffset()
        Description copied from interface: Server
        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.
        Specified by:
        getPortWithOffset in interface Server
        Returns:
        the port with offset
      • getAddress

        public java.lang.String getAddress()
        Return the address on which we listen to for shutdown commands.
        Specified by:
        getAddress in interface Server
        Returns:
        the address on which we listen to for shutdown commands.
      • 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
        Returns:
        the shutdown command string we are waiting for.
      • 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
      • getCatalina

        public Catalina getCatalina()
        Return the outer Catalina startup/shutdown component if present.
        Specified by:
        getCatalina in interface Server
        Returns:
        the outer Catalina startup/shutdown component if present.
      • setCatalina

        public void setCatalina​(Catalina catalina)
        Set the outer Catalina startup/shutdown component if present.
        Specified by:
        setCatalina in interface Server
        Parameters:
        catalina - the outer Catalina component
      • getUtilityThreads

        public int getUtilityThreads()
        Description copied from interface: Server
        Get the utility thread count.
        Specified by:
        getUtilityThreads in interface Server
        Returns:
        the thread count
      • setUtilityThreads

        public void setUtilityThreads​(int utilityThreads)
        Description copied from interface: Server
        Set the utility thread count.
        Specified by:
        setUtilityThreads in interface Server
        Parameters:
        utilityThreads - the new thread count
      • getUtilityThreadsAsDaemon

        public boolean getUtilityThreadsAsDaemon()
        Get if the utility threads are daemon threads.
        Returns:
        the threads daemon flag
      • setUtilityThreadsAsDaemon

        public void setUtilityThreadsAsDaemon​(boolean utilityThreadsAsDaemon)
        Set the utility threads daemon flag. The default value is true.
        Parameters:
        utilityThreadsAsDaemon - the new thread daemon flag
      • getPeriodicEventDelay

        public final int getPeriodicEventDelay()
        Returns:
        The period between two lifecycle events, in seconds
      • setPeriodicEventDelay

        public final void setPeriodicEventDelay​(int periodicEventDelay)
        Set the new period between two lifecycle events in seconds.
        Parameters:
        periodicEventDelay - The period in seconds, negative or zero will disable events
      • 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)
        Description copied from interface: Server
        Find the specified Service
        Specified by:
        findService in interface Server
        Parameters:
        name - Name of the Service to be returned
        Returns:
        the specified Service (if it exists); otherwise return null.
      • findServices

        public Service[] findServices()
        Specified by:
        findServices in interface Server
        Returns:
        the set of Services defined within this Server.
      • getServiceNames

        public javax.management.ObjectName[] getServiceNames()
        Returns:
        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
      • getCatalinaBase

        public java.io.File getCatalinaBase()
        Specified by:
        getCatalinaBase in interface Server
        Returns:
        the configured base (instance) directory. Note that home and base may be the same (and are by default). If this is not set the value returned by Server.getCatalinaHome() will be used.
      • setCatalinaBase

        public void setCatalinaBase​(java.io.File catalinaBase)
        Description copied from interface: Server
        Set the configured base (instance) directory. Note that home and base may be the same (and are by default).
        Specified by:
        setCatalinaBase in interface Server
        Parameters:
        catalinaBase - the configured base directory
      • getCatalinaHome

        public java.io.File getCatalinaHome()
        Specified by:
        getCatalinaHome in interface Server
        Returns:
        the configured home (binary) directory. Note that home and base may be the same (and are by default).
      • setCatalinaHome

        public void setCatalinaHome​(java.io.File catalinaHome)
        Description copied from interface: Server
        Set the configured home (binary) directory. Note that home and base may be the same (and are by default).
        Specified by:
        setCatalinaHome in interface Server
        Parameters:
        catalinaHome - the configured home directory
      • 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 javax.management.InstanceNotFoundException,
                                javax.management.MBeanException
        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
      • storeContext

        public void storeContext​(Context context)
                          throws javax.management.InstanceNotFoundException,
                                 javax.management.MBeanException
        Write the configuration information for Context out to the specified configuration file.
        Parameters:
        context - the context which should save its configuration
        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
      • startPeriodicLifecycleEvent

        protected void startPeriodicLifecycleEvent()
      • setParentClassLoader

        public void setParentClassLoader​(java.lang.ClassLoader parent)
        Set the parent class loader for this server.
        Specified by:
        setParentClassLoader in interface Server
        Parameters:
        parent - The new parent class loader
      • getDomainInternal

        protected java.lang.String getDomainInternal()
        Obtain the MBean domain for this server. The domain is obtained using the following search order:
        1. Name of first Engine.
        2. Name of first Service.
        Specified by:
        getDomainInternal in class LifecycleMBeanBase
        Returns:
        The name of the domain to use to register MBeans.
      • getObjectNameKeyProperties

        protected final java.lang.String getObjectNameKeyProperties()
        Description copied from class: LifecycleMBeanBase
        Allow sub-classes 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
      • getUtilityExecutor

        public java.util.concurrent.ScheduledExecutorService getUtilityExecutor()
        Specified by:
        getUtilityExecutor in interface Server
        Returns:
        the utility executor managed by the Service.