03 September 2009

WebLogic Server Startup and Shutdown Classes

WebLogic Server supports the use of server level startup and shutdown (SU/SD) classes, which are invoked by the server when it is starting up, and conversely when it is shutting down.

The initial implementation of this functionality (not sure of the release but circa 6.x I believe) required the SU/SD classes to implement proprietary WebLogic Server interfaces:
  • weblogic.common.T3StartupDef
  • weblogic.common.T3ShutdownDef
As of WebLogic Server 9.0, these interfaces were marked as deprecated.

It appears that with the introduction of the new application lifecycle listeners feature at the same time, this has resulted in reduced visbility of the new POJO based SU/SD class approach in the documentation.

So here's a brief explanation.

With the deprecation of the earlier SU/SD interfaces, a new and simpler POJO based was introduced for SU/SD classes. This requires only that a SU/SD class only has to have a static main(String args[]) method, which the server will invoke after instantiating the class. No WLS specific interfaces are needed any longer. Any arguments that were configured for the SU/SD class configuration are passed to it via the String[] args parameter.

The POJO based SU/SD class still follows all the same deployment and configuration steps used by the previous model -- the class needs to be made available on the server classpath, the SU/SD class is configured via the console with the requisite parameters and settings, and ultimately stored as an entry in config.xml.

Startup Class:
package sab.demo.utils;

public class StartupMain {
* @param args
public static void main(String[] args) {

log(StartupMain.class.getName() + "::main");
for(int i=0;args!=null && i<args.length;i++) {
log("  arg[" + i + "]: " + args[i]);

private static void log(String msg) {
System.out.printf("  --> [SAB]: %s\n", msg);

WLS Console:

<arguments>arg1 arg2 arg3</arguments>

1 comment:

Idealista said...

Is an excelent example, I was for the last weekend trying asign with deprecated interfaces, your sample is very util and understable, thank you very much from Mexico