public void restartWebApp() throws Exception { webAppContext.stop(); logger.info("JettyServer restart..."); webAppContext.start(); } }
httpServer.start(); } else { webapp.start();
@ManagementOperation(description = "Start the web app") public void startWebApp() throws Exception { super.start(); }
@ManagementOperation(description = "Start the web app") public void startWebApp() throws Exception { super.start(); }
String webroot = getWarRootPath(); WebAppContext webapp = new WebAppContext(webroot, "/"); server.setHandler(webapp); scanner.setMonitorDirectory(webroot); scanner.addListener(this); ... public void onScannerEvent(ScannerEvent evt) { if(!evt.path.isFile()) { return; // no point restarting on directory only event } webapp.stop(); if(evt.isNew() || evt.wasDeleted()) { reconfigureScanner(); } webapp.start(); }
public void onChange() { try { System.err.println("\nLoading changes ......"); webApp.stop(); JFinalClassLoader loader = new JFinalClassLoader(webApp, getClassPath()); webApp.setClassLoader(loader); webApp.start(); System.err.println("Loading complete."); } catch (Exception e) { System.err.println("Error reconfiguring/restarting webapp after change in watched files"); e.printStackTrace(); } } };
public void onChange() { try { System.err.println("\nLoading changes ......"); webApp.stop(); IceRestClassLoader loader = new IceRestClassLoader(webApp, getClassPath()); webApp.setClassLoader(loader); webApp.start(); System.err.println("Loading complete."); } catch (Exception e) { System.err.println("Error reconfiguring/restarting webapp after change in watched files"); logger.error(e.getMessage(), e); } } };
public void onChange() { try { System.err.println("\nLoading changes ......"); webApp.stop(); IceRestClassLoader loader = new IceRestClassLoader(webApp, getClassPath()); webApp.setClassLoader(loader); webApp.start(); System.err.println("Loading complete."); } catch (Exception e) { System.err.println("Error reconfiguring/restarting webapp after change in watched files"); logger.error(e.getMessage(), e); } } };
public void onChange() { try { System.err.println("\nLoading changes ......"); webApp.stop(); JFinalClassLoader loader = new JFinalClassLoader(webApp, getClassPath()); webApp.setClassLoader(loader); webApp.start(); System.err.println("Loading complete (^_^)"); } catch (Exception e) { System.err.println("Error reconfiguring/restarting webapp after change in watched files"); LogKit.error(e.getMessage(), e); } } };
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(); } }
public void reloadWebApp(String prefix) { WebAppContext webApp = this.webapps.get(prefix); if (webApp != null) { try { webApp.stop(); webApp.start(); } catch (Exception e) { throw new WinstoneException("Failed to redeploy "+prefix,e); } } else { throw new WinstoneException(Launcher.RESOURCES.getString("HostConfig.PrefixUnknown", prefix)); } }
private static void createWebapp(HandlerCollection handlers, Set<String> foundURLs, Integer port, String war) { if (foundURLs.add(war)) { String contextPath = createContextPath(war); String filePath = createFilePath(war); if (contextPath.equals("hawtio")) { System.out.println(); System.out.println("=================================================="); System.out.println("hawtio is running on http://" + ApiMasterService.getHostName() + ":" + port + "/" + contextPath + "/"); System.out.println("=================================================="); System.out.println(); hawtioEnabled = true; } else { System.out.println("adding web context path: /" + contextPath + " war: " + filePath); } WebAppContext webapp = new WebAppContext(); webapp.setContextPath("/" + contextPath); webapp.setWar("file://" + filePath); handlers.addHandler(webapp); webapp.setThrowUnavailableOnStartupException(true); try { System.out.println("Starting web app: " + contextPath); webapp.start(); System.out.println("Started web app: " + contextPath + " without any exceptions!"); } catch (Throwable e) { logException(e); } } }
/** * 快速重新启动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"); } }
restContext.start();
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); } }
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(); if(!newContext.isAvailable()) { throw newContext.getUnavailableException(); } } } catch( Throwable e ) { auditor.audit( Action.DEPLOY, topology.getName(), ResourceType.TOPOLOGY, ActionOutcome.FAILURE ); log.failedToDeployTopology( topology.getName(), e ); } }
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 ); } }
wctx.start(); webAppContextProducer.set(wctx); servletContextInstanceProducer.set(wctx.getServletContext());