This documentation is for WSO2 Carbon 4.4.3. View documentation for the latest release.
Server Startup Observer - Carbon 4.4.3 - WSO2 Documentation
Due to a known issue do not use JDK1.8.0_151 with WSO2 products. Use JDK 1.8.0_144 until JDK 1.8.0_162-ea is released.
Skip to end of metadata
Go to start of metadata

The server startup observer is an extension point that can be used to execute any custom code during server startup. This allows a developer to perform any work before and/or after server startup (i.e. starting all the transports), as required. The ServerStartupObserver interface needs to be implemented in order to use this extension and it includes two methods to be overridden. The completingServerStartup() method could contain the implementation of any task that needs to be performed before starting all the transports. The completedServerStartup() method could contain the implementation of any task that needs to be performed after all the transports are completely started.


A sample implementation of the org.wso2.carbon.core.ServerStartupObserver interface is as follows:

package org.example.handlers;

import org.wso2.carbon.core.ServerStartupObserver;

public class SampleServerStartupObserver implements ServerStartupObserver{

   public void completingServerStartup() {
       // Any work that needs to be performed before starting all the transports


   public void completedServerStartup() {
       // Any work that needs to be performed after completion of starting all the transports

The following Maven dependency will be needed for the above implementation:


After implementing the ServerStartupObserver interface, the implementation class needs to be registered as an OSGI service for the server to recognize it. Following is a sample bundle activator inside which the service is registered.

package org.example.handlers.internal;

import org.example.handlers.SampleServerStartupObserver;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.wso2.carbon.core.ServerStartupObserver;

public class SampleActivator implements BundleActivator {
   @Override public void start(BundleContext bundleContext) throws Exception {
       bundleContext.registerService(ServerStartupObserver.class.getName(), new SampleServerStartupObserver() , null);


   @Override public void stop(BundleContext bundleContext) throws Exception {

Your custom ServerStartupObserver should be packaged in an OSGi bundle and added to the <PRODUCT_HOME>/repository/components/dropins directory.

  • No labels