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

The following examples show how to use org.eclipse.jetty.webapp.WebAppContext#start() . 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: GatewayServer.java    From hadoop-mini-clusters with Apache License 2.0 6 votes vote down vote up
private synchronized void internalActivateArchive(Topology topology, File warDir) throws IOException, ZipException, ParserConfigurationException, TransformerException, SAXException {
    log.activatingTopologyArchive(topology.getName(), warDir.getName());
    try {
        WebAppContext newContext = createWebAppContext(topology, warDir, Urls.decode(warDir.getName()));
        WebAppContext oldContext = deployments.get(newContext.getContextPath());
        deployments.put(newContext.getContextPath(), newContext);
        if (oldContext != null) {
            contexts.removeHandler(oldContext);
        }
        contexts.addHandler(newContext);
        if (contexts.isRunning() && !newContext.isRunning()) {
            newContext.start();
        }
    } catch (Exception e) {
        auditor.audit(Action.DEPLOY, topology.getName(), ResourceType.TOPOLOGY, ActionOutcome.FAILURE);
        log.failedToDeployTopology(topology.getName(), e);
    }
}
 
Example 2
Source File: ContextHandlerCollectionHotSwappable.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
public synchronized void updateHandler(WebAppContext context) throws Exception {
    Handler[] hl0 = getHandlers();
    List<Handler> hl = hl0!=null ? new ArrayList<Handler>(Arrays.asList(hl0)) : new ArrayList<Handler>();
    // remove any previous version
    removeContextFromList(hl, context.getContextPath());
    // have to add before the root war (remove root war then add back)
    Handler oldRoot = removeContextFromList(hl, "/");
    // now add and add back any root
    hl.add(context);
    if (oldRoot!=null) hl.add(oldRoot);
    setHandlers(hl.toArray(new Handler[0]));
    
    // and if we are already running, start the new context
    if (isRunning()) {
        context.start();
    }
}
 
Example 3
Source File: GatewayServer.java    From knox with Apache License 2.0 6 votes vote down vote up
private synchronized void internalActivateArchive( Topology topology, File warDir ) {
  log.activatingTopologyArchive( topology.getName(), warDir.getName() );
  try {
    WebAppContext newContext = createWebAppContext( topology, warDir, Urls.decode( warDir.getName() ) );
    WebAppContext oldContext = deployments.get( newContext.getContextPath() );
    deployments.put( newContext.getContextPath(), newContext );
    if( oldContext != null ) {
      contexts.removeHandler( oldContext );
    }
    contexts.addHandler( newContext );
    if( contexts.isRunning() && !newContext.isRunning() ) {
      newContext.start();
      if(!newContext.isAvailable()) {
        throw newContext.getUnavailableException();
      }
    }

  } catch( Throwable e ) {
    auditor.audit( Action.DEPLOY, topology.getName(), ResourceType.TOPOLOGY, ActionOutcome.FAILURE );
    log.failedToDeployTopology( topology.getName(), e );
  }
}
 
Example 4
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 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: 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 11
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 12
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");
}