Java Code Examples for org.apache.catalina.Context#getAvailable()

The following examples show how to use org.apache.catalina.Context#getAvailable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VirtualHostClusterUtil.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public static void removeVirtualHost(String hostName) {
    Engine engine = DataHolder.getInstance().getCarbonTomcatService().getTomcat().getEngine();
    Host host = (Host) engine.findChild(hostName);
    Context context = (Context) host.findChild("/");
    try {
        if (host.getState().isAvailable()) {
            if (context != null && context.getAvailable()) {
                context.setRealm(null);
                context.stop();
                context.destroy();
                log.info("Unloaded webapp from the host: " + host
                        + " as the context of: " + context);
            }
            host.removeChild(context);
            host.setRealm(null);
            host.stop();
            host.destroy();
            engine.removeChild(host);
        }
    }catch (LifecycleException e) {
        log.error("error while removing host from tomcat", e);
    }
    URLMappingHolder.getInstance().removeUrlMappingMap(
            host.getName());
    log.info("Unloaded host from the engine: " + host);

}