Skip to content

Instantly share code, notes, and snippets.

@mifrazmurthaja
Created April 30, 2020 16:33
Show Gist options
  • Save mifrazmurthaja/8e302dd62f0ab5587eda55d4637ec83f to your computer and use it in GitHub Desktop.
Save mifrazmurthaja/8e302dd62f0ab5587eda55d4637ec83f to your computer and use it in GitHub Desktop.
custom-carbon-health-check
package org.wso2.carbon.custom.healthcheck.internal;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.healthcheck.api.core.HealthChecker;
import org.wso2.carbon.custom.healthcheck.WebAppHealthChecker;
public class Activator implements BundleActivator {
private static final Log log = LogFactory.getLog(Activator.class);
/**
* This is called when the bundle is started.
*
* @param bundleContext BundleContext of this bundle
* @throws Exception Could be thrown while bundle starting
*/
public void start(BundleContext bundleContext) throws Exception {
try {
bundleContext.registerService(HealthChecker.class.getName(),
new WebAppHealthChecker(), null);
log.info("Web App health monitoring service is activated..");
} catch (Throwable e) {
// Catching throwable to avoid retrying to initiate component.
log.error("Failed to activate Web App health check bundle", e);
}
}
/**
* This is called when the bundle is stopped.
*
* @param bundleContext BundleContext of this bundle
* @throws Exception Could be thrown while bundle stopping
*/
public void stop(BundleContext bundleContext) throws Exception {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment