Handling lifecycle events

You can write a class that handles events from the application lifecycle.

Your lifecycle class implements the interface com.jivesoftware.base.plugin.Plugin, which has two methods: init and destroy.

  • Use the init method to perform actions (such as create connections to resources) that your plugin will likely need throughout its life.
  • Use the destroy method to release resources and perform actions that are the last things your plugin should do.

You specify the presence of a lifecycle class with the plugin.xml class element:

<class>com.example.plugin.MyPluginLifecycle</class>