Lifecycle notification
From Resin 3.0
Resin's <server>, <host>, and <web-app> send JMX Notifications when the server starts, stops or restarts.
Notification Events
The notification events are:
notification type | description |
---|---|
caucho.lifecycle.after-start | called after the server starts |
caucho.lifecycle.before-stop | called before the server stops |
resin.conf configuration
The resin.conf provides a straightforward way of configuring MBean listeners. An MBean listener is a <bean> that listens for events. Because the bean is an MBean, it needs to have an mbean-name.
<resin xmlns:resin="http://caucho.com/ns/resin"> <server> <bean mbean-name="type=MyListener,name=test" type="example.MyListenerMBean"> <mbean-listener mbean-name="resin:type=Server,name=default"/> </bean> ... </server> </resin>
The <mbean-listener> tag registers MyListener as a listener of the MBean with the given mbean-name, i.e. the <server>. The <server> has an MBean name of "default" because it has no @id attribute.
Sample Listener
To listen for notification events, create a JMX NotificationListener and register it with the <server>. The notification listener will look like:
package example; import javax.management.*; public class MyListener implements MyListenerMBean { public void handleNotification(Notification notif, Object handback) { System.out.println(notif.getType()); } }
And the corresponding MBean is
package example; public interface MyListenerMBean extends NotificationListener { }