當前位置: 首頁>>代碼示例>>Java>>正文


Java WebAppContext.setWar方法代碼示例

本文整理匯總了Java中org.eclipse.jetty.webapp.WebAppContext.setWar方法的典型用法代碼示例。如果您正苦於以下問題:Java WebAppContext.setWar方法的具體用法?Java WebAppContext.setWar怎麽用?Java WebAppContext.setWar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jetty.webapp.WebAppContext的用法示例。


在下文中一共展示了WebAppContext.setWar方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: beforeClass

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
@BeforeClass
public static void beforeClass() throws Exception {
    jettyServer = new Server(0);

    WebAppContext webApp = new WebAppContext();
    webApp.setServer(jettyServer);
    webApp.setContextPath(CONTEXT_PATH);
    webApp.setWar("src/test/webapp");

    jettyServer.setHandler(webApp);
    jettyServer.start();
    serverPort = ((ServerConnector)jettyServer.getConnectors()[0]).getLocalPort();

    testRestTemplate = new TestRestTemplate(new RestTemplateBuilder()
            .rootUri("http://localhost:" + serverPort + CONTEXT_PATH));
}
 
開發者ID:opentracing-contrib,項目名稱:java-spring-web,代碼行數:17,代碼來源:MVCJettyITest.java

示例2: startServer

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
public static void startServer(String[] args) throws Exception {
	Server server = new Server(8080);
	
	WebAppContext ctx = new WebAppContext();
	ctx.setContextPath("/");
	ctx.setWar("src/main/webapp/");
	HandlerCollection hc = new HandlerCollection();
	hc.setHandlers(new Handler[] {ctx});
	
	server.setHandler(hc);
	server.setStopAtShutdown(true);
	server.start();
	
	server.join();
	
	// server.removeBean(o);
	// server.addBean(o);
}
 
開發者ID:ForJ-Latech,項目名稱:fwm,代碼行數:19,代碼來源:ScratchPad.java

示例3: startJettyServer

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
/**
 * 啟動jetty服務,加載server.war
 */
public static void startJettyServer(String path) throws  Exception{
    String configPath=path+ File.separator+"conf"+File.separator+"conf.properties";
    InputStream is = new FileInputStream(configPath);;
    Properties properties =new Properties();
    properties.load(is);
    is.close();
    int serverPort = Integer.parseInt(properties.getProperty("server.port"));
    Server server = new Server(serverPort);
    WebAppContext context = new WebAppContext();
    context.setContextPath("/");
    context.setWar(path+"/bin/service.war");
    server.setHandler(context);
    server.start();
    server.join();
}
 
開發者ID:elves-project,項目名稱:openapi,代碼行數:19,代碼來源:ProgramEntrance.java

示例4: start

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
public void start() throws Exception
{
    String relativelyPath = System.getProperty("user.dir");

    server = new Server(port);
    WebAppContext webAppContext = new WebAppContext();
    webAppContext.setContextPath("/");
    webAppContext.setWar(relativelyPath + "\\rainbow-web\\target\\rainbow-web.war");
    webAppContext.setParentLoaderPriority(true);
    webAppContext.setServer(server);
    webAppContext.setClassLoader(ClassLoader.getSystemClassLoader());
    webAppContext.getSessionHandler().getSessionManager()
            .setMaxInactiveInterval(10);
    server.setHandler(webAppContext);
    server.start();
}
 
開發者ID:dbiir,項目名稱:rainbow,代碼行數:17,代碼來源:RwServer.java

示例5: addWebApplication

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
public static Server addWebApplication(final Server jetty, final String webAppContext,
    final String warFilePath) {
  WebAppContext webapp = new WebAppContext();
  webapp.setContextPath(webAppContext);
  webapp.setWar(warFilePath);
  webapp.setParentLoaderPriority(false);
  webapp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");

  File tmpPath = new File(getWebAppBaseDirectory(webAppContext));
  tmpPath.mkdirs();
  webapp.setTempDirectory(tmpPath);

  ((HandlerCollection) jetty.getHandler()).addHandler(webapp);

  return jetty;
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:17,代碼來源:JettyHelper.java

示例6: createWebAppContext

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
private WebAppContext createWebAppContext(URL webXml, Configuration[] configurations) {
    WebAppContext context = new WebAppContext();
    String war = webXml == null
            ? "src/main/webapp"
            : MY_URL.toExternalForm();

    context.setWar(war);
    context.setContextPath(prefix);
    if (webXml != null) {
        context.getMetaData().setWebInfClassesDirs(
                Arrays.asList(Resource.newResource(MY_URL)));
    }
    context.setConfigurations(configurations);

    return context;
}
 
開發者ID:otsecbsol,項目名稱:linkbinder,代碼行數:17,代碼來源:Application.java

示例7: setupWebAppContext

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
private static WebAppContext setupWebAppContext(
    ZeppelinConfiguration conf) {

  WebAppContext webApp = new WebAppContext();
  webApp.setContextPath(conf.getServerContextPath());
  File warPath = new File(conf.getString(ConfVars.ZEPPELIN_WAR));
  if (warPath.isDirectory()) {
    // Development mode, read from FS
    // webApp.setDescriptor(warPath+"/WEB-INF/web.xml");
    webApp.setResourceBase(warPath.getPath());
    webApp.setParentLoaderPriority(true);
  } else {
    // use packaged WAR
    webApp.setWar(warPath.getAbsolutePath());
    File warTempDirectory = new File(conf.getRelativeDir(ConfVars.ZEPPELIN_WAR_TEMPDIR));
    warTempDirectory.mkdir();
    LOG.info("ZeppelinServer Webapp path: {}", warTempDirectory.getPath());
    webApp.setTempDirectory(warTempDirectory);
  }
  // Explicit bind to root
  webApp.addServlet(new ServletHolder(new DefaultServlet()), "/*");
  return webApp;
}
 
開發者ID:lorthos,項目名稱:incubator-zeppelin-druid,代碼行數:24,代碼來源:ZeppelinServer.java

示例8: Olingo2SampleServer

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
/**
 * 
 * @param port
 * @param resourcePath
 */
public Olingo2SampleServer(int port, String resourcePath) {
    this.port = port;
    server = new org.eclipse.jetty.server.Server(port);

    WebAppContext webappcontext = new WebAppContext();
    String contextPath = null;
    try {
        contextPath = Olingo2SampleServer.class.getResource(resourcePath).toURI().getPath();
    } catch (URISyntaxException e) {
        LOG.error("Unable to read the resource at {}", resourcePath, e);
    }
    webappcontext.setContextPath("/");

    webappcontext.setWar(contextPath);

    HandlerCollection handlers = new HandlerCollection();
    handlers.setHandlers(new Handler[] {webappcontext, new DefaultHandler()});
    server.setHandler(handlers);
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:25,代碼來源:Olingo2SampleServer.java

示例9: main

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {

        SLF4JBridgeHandler.removeHandlersForRootLogger();
        SLF4JBridgeHandler.install();

        Server server = new Server();
        ServerConnector connector = new ServerConnector(server);
        connector.setPort(8080);
        server.setConnectors(new Connector[]{connector});

        WebAppContext context = new WebAppContext();
        context.setServer(server);
        context.setContextPath("/");
        context.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*/[^/]*taglibs.*\\.jar$");
        context.setAttribute("org.eclipse.jetty.containerInitializers", jspInitializers());
        context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
        context.addBean(new ServletContainerInitializersStarter(context), true);

        // Prevent loading of logging classes
        context.getSystemClasspathPattern().add("org.apache.log4j.");
        context.getSystemClasspathPattern().add("org.slf4j.");
        context.getSystemClasspathPattern().add("org.apache.commons.logging.");

        ProtectionDomain protectionDomain = EmbeddedJettyServer.class.getProtectionDomain();
        URL location = protectionDomain.getCodeSource().getLocation();
        context.setWar(location.toExternalForm());

        server.setHandler(context);
        try {
            server.start();
            server.join();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }
 
開發者ID:stevespringett,項目名稱:Alpine,代碼行數:37,代碼來源:EmbeddedJettyServer.java

示例10: start

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
public void start() throws Exception
{
    server = new Server(port);

    WebAppContext webAppContext = new WebAppContext();
    webAppContext.setContextPath("/");
    webAppContext.setWar("/Users/Jelly/Developer/paraflow/paraflow-http-server/target/paraflow-server.war");
    webAppContext.setParentLoaderPriority(true);
    webAppContext.setServer(server);
    webAppContext.setClassLoader(ClassLoader.getSystemClassLoader());
    webAppContext.getSessionHandler().getSessionManager()
            .setMaxInactiveInterval(10);
    server.setHandler(webAppContext);
    server.start();
}
 
開發者ID:dbiir,項目名稱:paraflow,代碼行數:16,代碼來源:DataServer.java

示例11: startServer

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
/**
 * Method for starting the Jetty server with the ATS Agent webapp.
 * @param port the port on which to start the server.
 * @return the started server.
 * @throws IOException
 */
private static Server startServer() throws IOException {

    addAppender();

    final int agentPort = getAgentDefaultPort();
    log.info("Starting ATS agent at port: " + agentPort);

    final String jettyHome = getJettyHome();

    logSystemInformation(jettyHome);

    // start the server
    Connector connector = new SelectChannelConnector();
    connector.setPort(agentPort);

    Server server = new Server();
    server.setConnectors(new Connector[]{ connector });

    WebAppContext webApp = new WebAppContext();
    webApp.setContextPath("/agentapp");
    webApp.setWar(jettyHome + "/webapp/agentapp.war");

    server.setHandler(webApp);
    server.setStopAtShutdown(true);

    setExtraClasspath(webApp, jettyHome);

    try {
        server.start();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }

    log.info("ATS agent started");
    return server;
}
 
開發者ID:Axway,項目名稱:ats-framework,代碼行數:44,代碼來源:ContainerStarter.java

示例12: createWebApp

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
/**
     * Creates a web-app deployment for a war file gives as path
     * @param webappWar
     *  path to the war file
     * @return
     *  a webApplication context that can be deployed on the jetty server.
     */
    private static WebAppContext createWebApp(final Path webappWar) throws IOException {

//        Path tempWar = Files.createTempFile("bdj-", webappWar.getFileName().toString());
//        LOG.info("Creating temporary copy of war " + tempWar);
//        Files.copy(webappWar, tempWar, StandardCopyOption.REPLACE_EXISTING);
//        LOG.info("Deploying web app from " + tempWar);

        final WebAppContext webapp = new WebAppContext();
        webapp.setSystemClasses(new String[] {
                Configuration.class.getName(), ConfigChangeListener.class.getName()
        });
        webapp.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
                            ".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/[^/]*taglibs.*\\.jar$");

		/*
         * Configure the application to support the compilation of JSP files.
		 * We need a new class loader and some stuff so that Jetty can call the
		 * onStartup() methods as required.
		 */
        webapp.setAttribute("org.eclipse.jetty.containerInitializers", jspInitializers());
        webapp.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
        webapp.addBean(new ServletContainerInitializersStarter(webapp), true);
        webapp.setContextPath("/");
        webapp.setWar(webappWar.toString());
        return webapp;
    }
 
開發者ID:gmuecke,項目名稱:boutique-de-jus,代碼行數:34,代碼來源:BoutiqueDeJusWebServer.java

示例13: main

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    SLF4JBridgeHandler.removeHandlersForRootLogger();
    SLF4JBridgeHandler.install();

    int port = 8888;
    if (args.length > 0) {
        port = Integer.parseInt(args[0]);
    }
    if (port == 80) {
        System.out.println("Dorset web demo running on http://localhost/");            
    } else {
        System.out.println("Dorset web demo running on http://localhost:" 
                        + String.valueOf(port) + "/");
    }
    Server server = new Server(port);

    WebAppContext context = new WebAppContext();
    context.setServer(server);
    context.setContextPath("/");
    // turn off class loading from WEB-INF due to logging
    context.setParentLoaderPriority(true);

    ProtectionDomain protectionDomain = Runner.class.getProtectionDomain();
    URL location = protectionDomain.getCodeSource().getLocation();
    context.setWar(location.toExternalForm());

    server.setHandler(context);
    server.start();
    server.join();
}
 
開發者ID:NEStock,項目名稱:Voice_Activated_EV3_Robot,代碼行數:31,代碼來源:Runner.java

示例14: initOldWebApp

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
private void initOldWebApp() {
    try {
        javax.naming.Context context = new InitialContext();
        context.bind("java:/DefaultDS", dataSource);
    } catch (Exception error) {
        Log.warning(error);
    }

    WebAppContext app = new WebAppContext();
    app.setContextPath("/");
    app.getSessionHandler().setSessionManager(sessionManager);
    app.setWar(config.getString("web.application"));
    handlers.addHandler(app);
}
 
開發者ID:bamartinezd,項目名稱:traccar-service,代碼行數:15,代碼來源:WebServer.java

示例15: startJettyServer

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
/**
 * 啟動jetty服務,加載server.war
 */
public static void startJettyServer(String path) throws  Exception{
    String configPath=path+ File.separator+"conf"+File.separator+"conf.properties";
    InputStream is = new FileInputStream(configPath);;
    Properties properties =new Properties();
    properties.load(is);
    is.close();
    int serverPort = Integer.parseInt(properties.getProperty("server.port"));
    Server server = new Server(serverPort);
    WebAppContext context = new WebAppContext();
    context.setWar(path+"/bin/ROOT.war");
    server.setHandler(context);
    server.start();
    server.join();
}
 
開發者ID:elves-project,項目名稱:supervisor,代碼行數:18,代碼來源:ProgramEntrance.java


注:本文中的org.eclipse.jetty.webapp.WebAppContext.setWar方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。