Creating custom services
You can create one or more custom services for an application server. Each custom services defines a class that is loaded and initialized whenever the server starts and shuts down. Each of these classes must implement the com.ibm.websphere.runtime.CustomService interface. After you create a custom service, use the administrative console to configure that custom service for your application servers.
About this task
Following is a list of restrictions
that apply to the product custom services implementation. Most of
these restrictions apply only to the initialize method:
- The initialize and shutdown methods must return control to the runtime.
- No work is dispatched into the server instance until all custom service initialize methods return.
- The initialize and shutdown methods are called only once on each service, and once for each operating system process that makes up the server instance.
- Initialization of process level static data, without leaving the process, is supported.
- Only JDBC RMLT (resource manager local transaction) operations are supported. Every unit of work (UOW) must be completed before the methods return.
- Creation of threads is not supported.
- Creation of sockets and I/O, other than file I/O, is not supported.
- Running standard Java™ Platform, Enterprise Edition (Java EE) code, such as client code, servlets, and enterprise beans, is not supported.
- The Java Transaction API (JTA) interface is not available.
- This feature is available in Java EE server processes and distributed generic server processes only.
- While the runtime makes an effort to call shutdown, there is no guarantee that shutdown will be called prior to process termination.
- JNDI operations that request resources are not supported.
Procedure
Results
![[AIX Solaris HP-UX Linux Windows]](../images/dist.gif)
The
custom service loads and initializes whenever the server starts and
shuts down.
Example
public class ServerInit implements com.ibm.websphere.runtime.CustomService
{
/**
* The initialize method is called by the application server runtime when the
* server starts. The Properties object that the application server passes
* to this method must contain all of the configuration information that this
* service needs to initialize properly.
*
* @param configProperties java.util.Properties
*/
static final java.lang.String externalConfigURLKey =
"com.ibm.websphere.runtime.CustomService.externalConfigURLKey";
static String ConfigFileName="";
public void initialize(java.util.Properties configProperties) throws Exception
{
if (configProperties.getProperty(externalConfigURLKey) != null)
{
ConfigFileName = configProperties.getProperty(externalConfigURLKey);
}
// Implement rest of initialize method
}
/**
* The shutdown method is called by the application server runtime when the
* server begins its shutdown processing.
*
public void shutdown() throws Exception
{
// Implement shutdown method
}
What to do next
![[AIX Solaris HP-UX Linux Windows]](../images/dist.gif)
Check the application server to verify
that the initialize and shutdown methods of the custom service run
the way that you want them to run.
作業主題