Java Code Examples for org.eclipse.jetty.webapp.WebAppContext#stop()

The following examples show how to use org.eclipse.jetty.webapp.WebAppContext#stop() . 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: ClusteredBounceProxyWithDispatcher.java    From joynr with Apache License 2.0 6 votes vote down vote up
@Override
public void stopServers() throws Exception {

    // stop bounceproxies first as they want to de-register
    for (WebAppContext bpContext : bounceProxyContexts) {
        bpContext.stop();
    }

    Thread.sleep(1000l);
    try {
        server.stop();
    } catch (Exception e) {
        // do nothing as we don't want tests to fail only because
        // stopping of the server did not work
    }
}
 
Example 2
Source File: JettyFactory.java    From base-framework with Apache License 2.0 6 votes vote down vote up
/**
 * 快速重新启动application,重载target/classes与target/test-classes.
 */
public static void reloadContext(Server server) throws Exception {
	WebAppContext context = (WebAppContext) server.getHandler();

	System.out.println("[INFO] Application reloading");
	context.stop();

	WebAppClassLoader classLoader = new WebAppClassLoader(context);
	classLoader.addClassPath("target/classes");
	classLoader.addClassPath("target/test-classes");
	context.setClassLoader(classLoader);

	context.start();

	System.out.println("[INFO] Application reloaded");
}
 
Example 3
Source File: JettyFactory.java    From java-tutorial with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
public static void reloadWebAppContext(Server server) throws Exception {
	WebAppContext webAppContext = (WebAppContext) server.getHandler();
	System.out.println("[INFO] Application reloading");
	webAppContext.stop();
	WebAppClassLoader classLoader = new WebAppClassLoader(webAppContext);
	classLoader.addClassPath(getAbsolutePath() + "target/classes");
	classLoader.addClassPath(getAbsolutePath() + "target/test-classes");
	webAppContext.setClassLoader(classLoader);
	webAppContext.start();
	System.out.println("[INFO] Application reloaded");
}
 
Example 4
Source File: JettyFactory.java    From java-tutorial with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
public static void reloadWebAppContext(Server server) throws Exception {
	WebAppContext webAppContext = (WebAppContext) server.getHandler();
	System.out.println("[INFO] Application reloading");
	webAppContext.stop();
	WebAppClassLoader classLoader = new WebAppClassLoader(webAppContext);
	classLoader.addClassPath(getAbsolutePath() + "target/classes");
	classLoader.addClassPath(getAbsolutePath() + "target/test-classes");
	webAppContext.setClassLoader(classLoader);
	webAppContext.start();
	System.out.println("[INFO] Application reloaded");
}
 
Example 5
Source File: JettyFactory.java    From java-tutorial with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
public static void reloadWebAppContext(Server server) throws Exception {
	WebAppContext webAppContext = (WebAppContext) server.getHandler();
	System.out.println("[INFO] Application reloading");
	webAppContext.stop();
	WebAppClassLoader classLoader = new WebAppClassLoader(webAppContext);
	classLoader.addClassPath(getAbsolutePath() + "target/classes");
	classLoader.addClassPath(getAbsolutePath() + "target/test-classes");
	webAppContext.setClassLoader(classLoader);
	webAppContext.start();
	System.out.println("[INFO] Application reloaded");
}
 
Example 6
Source File: JettyFactory.java    From java-tutorial with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
public static void reloadWebAppContext(Server server) throws Exception {
	WebAppContext webAppContext = (WebAppContext) server.getHandler();
	System.out.println("[INFO] Application reloading");
	webAppContext.stop();
	WebAppClassLoader classLoader = new WebAppClassLoader(webAppContext);
	classLoader.addClassPath(getAbsolutePath() + "target/classes");
	classLoader.addClassPath(getAbsolutePath() + "target/test-classes");
	webAppContext.setClassLoader(classLoader);
	webAppContext.start();
	System.out.println("[INFO] Application reloaded");
}
 
Example 7
Source File: JettyFactory.java    From java-tutorial with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
public static void reloadWebAppContext(Server server) throws Exception {
	WebAppContext webAppContext = (WebAppContext) server.getHandler();
	System.out.println("[INFO] Application reloading");
	webAppContext.stop();
	WebAppClassLoader classLoader = new WebAppClassLoader(webAppContext);
	classLoader.addClassPath(getAbsolutePath() + "target/classes");
	classLoader.addClassPath(getAbsolutePath() + "target/test-classes");
	webAppContext.setClassLoader(classLoader);
	webAppContext.start();
	System.out.println("[INFO] Application reloaded");
}
 
Example 8
Source File: JettyFactory.java    From java-tutorial with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
public static void reloadWebAppContext(Server server) throws Exception {
	WebAppContext webAppContext = (WebAppContext) server.getHandler();
	System.out.println("[INFO] Application reloading");
	webAppContext.stop();
	WebAppClassLoader classLoader = new WebAppClassLoader(webAppContext);
	classLoader.addClassPath(getAbsolutePath() + "target/classes");
	classLoader.addClassPath(getAbsolutePath() + "target/test-classes");
	webAppContext.setClassLoader(classLoader);
	webAppContext.start();
	System.out.println("[INFO] Application reloaded");
}
 
Example 9
Source File: JettyFactory.java    From java-tutorial with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
public static void reloadWebAppContext(Server server) throws Exception {
	WebAppContext webAppContext = (WebAppContext) server.getHandler();
	System.out.println("[INFO] Application reloading");
	webAppContext.stop();
	WebAppClassLoader classLoader = new WebAppClassLoader(webAppContext);
	classLoader.addClassPath(getAbsolutePath() + "target/classes");
	classLoader.addClassPath(getAbsolutePath() + "target/test-classes");
	webAppContext.setClassLoader(classLoader);
	webAppContext.start();
	System.out.println("[INFO] Application reloaded");
}
 
Example 10
Source File: DevServer.java    From java-tutorial with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
private static void reloadWebAppContext(Server server) throws Exception {
    WebAppContext webAppContext = (WebAppContext) server.getHandler();
    System.out.println("[INFO] Application reloading");
    webAppContext.stop();
    WebAppClassLoader classLoader = new WebAppClassLoader(webAppContext);
    classLoader.addClassPath(getAbsolutePath() + "target/classes");
    classLoader.addClassPath(getAbsolutePath() + "target/test-classes");
    webAppContext.setClassLoader(classLoader);
    webAppContext.start();
    System.out.println("[INFO] Application reloaded");
}
 
Example 11
Source File: GatewayServer.java    From hadoop-mini-clusters with Apache License 2.0 5 votes vote down vote up
private synchronized void internalDeactivateTopology(Topology topology) {

        log.deactivatingTopology(topology.getName());

        String topoName = topology.getName();
        String topoPath = "/" + Urls.trimLeadingAndTrailingSlashJoin(config.getGatewayPath(), topoName);
        String topoPathSlash = topoPath + "/";

        ServiceRegistry sr = getGatewayServices().getService(GatewayServices.SERVICE_REGISTRY_SERVICE);
        if (sr != null) {
            sr.removeClusterServices(topoName);
        }

        // Find all the deployed contexts we need to deactivate.
        List<WebAppContext> deactivate = new ArrayList<WebAppContext>();
        if (deployments != null) {
            for (WebAppContext app : deployments.values()) {
                String appPath = app.getContextPath();
                if (appPath.equals(topoPath) || appPath.startsWith(topoPathSlash)) {
                    deactivate.add(app);
                }
            }
        }
        // Deactivate the required deployed contexts.
        for (WebAppContext context : deactivate) {
            String contextPath = context.getContextPath();
            deployments.remove(contextPath);
            contexts.removeHandler(context);
            try {
                context.stop();
            } catch (Exception e) {
                auditor.audit(Action.UNDEPLOY, topology.getName(), ResourceType.TOPOLOGY, ActionOutcome.FAILURE);
                log.failedToUndeployTopology(topology.getName(), e);
            }
        }
        deactivate.clear();

    }
 
Example 12
Source File: GatewayServer.java    From knox with Apache License 2.0 5 votes vote down vote up
private synchronized void internalDeactivateTopology( Topology topology ) {

    log.deactivatingTopology( topology.getName() );

    String topoName = topology.getName();
    String topoPath = "/" + Urls.trimLeadingAndTrailingSlashJoin( config.getGatewayPath(), topoName );
    String topoPathSlash = topoPath + "/";

    ServiceRegistry sr = getGatewayServices().getService(ServiceType.SERVICE_REGISTRY_SERVICE);
    if (sr != null) {
      sr.removeClusterServices( topoName );
    }

    // Find all the deployed contexts we need to deactivate.
    if( deployments != null ) {
      List<WebAppContext> deactivate = new ArrayList<>();
      for( WebAppContext app : deployments.values() ) {
        String appPath = app.getContextPath();
        if( appPath.equals( topoPath ) || appPath.startsWith( topoPathSlash ) ) {
          deactivate.add( app );
        }
      }

      // Deactivate the required deployed contexts.
      for( WebAppContext context : deactivate ) {
        String contextPath = context.getContextPath();
        deployments.remove( contextPath );
        contexts.removeHandler( context );
        try {
          context.stop();
        } catch( Exception e ) {
          auditor.audit(Action.UNDEPLOY, topology.getName(), ResourceType.TOPOLOGY, ActionOutcome.FAILURE);
          log.failedToUndeployTopology( topology.getName(), e );
        }
      }
      deactivate.clear();
    }
  }