DevPortal

How do I Create Server Startup Hooks?


To create and use Server Startup Hooks, do the following:

  1. Provide an implementation for the com.pramati.services.j2ee.spi.StartupHook interface.
  2. Register the implementation class with the Server by specifying it in the deploy-config.xml located in the <install_dir>/server/nodes/<node_name>/config directory. For example:

    <startup-hooks>
    <class-name>com.pramati.test.MyStartupHook<class-name>
    <startup-hooks>
    
  3. Place the implemented class (.jar) in <install_dir>/server/lib/ext directory. In case the class is not in a jar, it has to be placed in a classes directory under the <install_dir>/server/lib/ext directory. The classes directory can be created manually under the lib/ext directory, if not present.
  4. Restart the Server.

Creating the Server hook requires you to implement the com.pramati.services.j2ee.spi.StartupHook interface. This interface should implement the following methods:

Here is a sample of a class that implements StartupHook interface:

package com.server.hooks.ServerHook;
import com.pramati.services.j2ee.spi.StartupHook;

public class ServerHook implements StartupHook
{
	public void start()
        {System.out.println("Server Startup Hook Started");}
	public void stop()
        {System.out.println("Server Startup Hook Stopped");}
	public void postAutoStartAppsStart()
        {System.out.println("Server Startup Hook Post Startup of Apps");}
	public void preAppsShutdown()
        {System.out.println("Server Shutdown...");}
}

How do I Compile Server Hook Implemented Class?

To compile the Server Hook implementation you need to have pramati_spi.jar in your classpath. This library is available in <install_dir>/server/lib/pramati.

How do I Edit deploy-config.xml?

The implemented class should be specified in the deploy-config.xml. This class is picked up by the Deploy Service. The tag looks as below:
<startup-hooks>
  <class-name>com.server.hooks.ServerHook<class-name>
</startup-hooks>

© Pramati Technologies 2007 Runs on Pramati Server | Feedback | Legal