Chapter 6: Advanced Tomcat Features Configuring Lifecycle Listeners Many top-level and nested components in the Tomcat 6 architecture (including Server, Service, Realm, and so on) support the configuration of lifecycle listeners. Lifecycle listeners are Java code modules that can be hooked into the server logic and executed during specific moments during the lifecycle of a component. This capability enables new custom functionality to be introduced to the Tomcat 6 server without having to change the core server code base. With Tomcat 6, the only explicit use of a lifecycle listener is to insert code that enables the server to be managed remotely (through JMX support). Using a simple example, the following section shows how this support code is configured. Lifecycle Events Sent by Tomcat Components Lifecycle listeners are customized code that listens to specific lifecycle events. Lifecycle events are sent by a component, to any configured listener, at well-defined points in a component s lifecycle. These points include the following: . Just before component startup . During component startup . Just after component startup . Just before component stop . During component stop . Just after component stop Developers may use lifecycle listeners to add new processing logic to the Tomcat server. As an administrator, you can add these custom listeners by creating a XML element within the associated component. The Element You can add a lifecycle listener to a Tomcat component (if the component supports lifecycle listeners) by configuring a XML element within the XML definition of the component. Most Tomcat 6 architectural components support lifecycle listeners. In Tomcat 6, listeners for the component are used to create JMX MBeans that represent runtime server structures and global resources. JMX MBeans are objects that enable Tomcat components, structures, and resources to be monitored or accessed via an external management system. Chapter 17 provides more extensive coverage of JMX. More specifically, Tomcat 6 uses the following default server.xmlfragment to add JMX MBean support:
For high quality website hosting services please check cheap web hosting website.