当前位置: 首页>>代码示例>>Java>>正文


Java WebAppContext.setContextPath方法代码示例

本文整理汇总了Java中org.eclipse.jetty.webapp.WebAppContext.setContextPath方法的典型用法代码示例。如果您正苦于以下问题:Java WebAppContext.setContextPath方法的具体用法?Java WebAppContext.setContextPath怎么用?Java WebAppContext.setContextPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jetty.webapp.WebAppContext的用法示例。


在下文中一共展示了WebAppContext.setContextPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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,项目名称:cmdbproxy,代码行数:19,代码来源:ProgramEntrance.java

示例5: run

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public void run( ) {
	logger.info(masterConfig.toString());
	try {
		Server server = new Server(masterConfig.getWebServerPort());

		WebAppContext context = new WebAppContext();
		context.setDescriptor( masterConfig.getWebServerContentPath() + "/WEB-INF/web.xml" );
		context.setResourceBase( masterConfig.getWebServerContentPath() );
		context.setContextPath( masterConfig.getWebServerContextPath() );
		context.setParentLoaderPriority(true);
		server.setHandler(context);
		logger.info("Starting");
		server.start();
		logger.info("Started");
		server.join();
	} catch( Exception e ) {
		logger.error(e.getMessage(), e);
	}
}
 
开发者ID:petezybrick,项目名称:iote2e,代码行数:20,代码来源:ThreadEntryPointWeb.java

示例6: 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

示例7: main

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
	Properties p = PropertyUtil.loadProperties("/ws.properties");
	System.out.println(JsonUtil.toJsonStr(p));
	Server server = new Server(Integer.parseInt(p
			.getProperty("webSocketPort")));
	try {
		HandlerList handlerList = new HandlerList();

		/* websocket */
		ServletContextHandler context = new ServletContextHandler(
				ServletContextHandler.SESSIONS);
		context.setContextPath("/");
		context.addServlet(
				new ServletHolder(new Jwservlet(p
						.getProperty("handlerClass"))), p
						.getProperty("webSocketPath"));

		/* webapp */
		WebAppContext c = new WebAppContext();
		c.setContextPath("/w");
		c.setDescriptor("../websockets/WebRoot/WEB-INF/web.xml");
		c.setResourceBase("../websockets/WebRoot");

		handlerList.addHandler(c);
		handlerList.addHandler(context);
		handlerList.addHandler(new DefaultHandler());
		server.setHandler(handlerList);
		server.start();
		server.join();
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:Sunature,项目名称:websocket,代码行数:37,代码来源:Jetty9Ws.java

示例8: 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

示例9: createDevServer

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public static Server createDevServer() {
	PlatformServerConfig.DEV_MODE = true;
	Path projectPath = Paths.get(System.getProperty("user.dir")).toAbsolutePath();
	Server jettyServer = new Server(8080);  
    WebAppContext context = new WebAppContext();  
    context.setContextPath("/BIMplatform");
    context.setDescriptor(projectPath.resolve("WebContent/WEB-INF/web.xml").toAbsolutePath().toString()); // 指定web.xml配置文件 
    context.setResourceBase(projectPath.resolve("WebContent/").toAbsolutePath().toString());// 指定webapp目录  
    context.setParentLoaderPriority(true); 
    jettyServer.setHandler(context);  

    return jettyServer;
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:14,代码来源:PlatformServerStarter.java

示例10: run

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
@Override
public void run() {

  try {
    Server server = new Server(port);
    URL warUrl = DoctorKafkaWebServer.class.getClassLoader().getResource(WEBAPP_DIR);
    if (warUrl == null) {
      LOG.error("warUrl is null");
    }

    String warUrlString = warUrl.toExternalForm();
    WebAppContext webapp = new WebAppContext();
    webapp.addServlet(ClusterInfoServlet.class, "/servlet/clusterinfo");
    webapp.addServlet(KafkaTopicStatsServlet.class, "/servlet/topicstats");
    webapp.addServlet(DoctorKafkaActionsServlet.class, "/servlet/actions");
    webapp.addServlet(DoctorKafkaInfoServlet.class, "/servlet/info");
    webapp.addServlet(DoctorKafkaBrokerStatsServlet.class, "/servlet/brokerstats");
    webapp.addServlet(UnderReplicatedPartitionsServlet.class, "/servlet/urp");
    webapp.addServlet(OperatorIndexServlet.class, "/");
    webapp.setContextPath("/");
    webapp.setServer(server);
    webapp.setWar(warUrlString);

    server.setHandler(webapp);
    server.start();
    if (LOG.isDebugEnabled()) {
      server.dumpStdErr();
    }
    server.join();
  } catch (Exception e) {
    LOG.error("Exception in KafkaOperatorWebServer.", e);
  }
}
 
开发者ID:pinterest,项目名称:doctorkafka,代码行数:34,代码来源:DoctorKafkaWebServer.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: createServer

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public static Server createServer(int port) {
	
	WebAppContext context = new WebAppContext();
	context.setContextPath("/");
	context.setResourceBase(WEBAPP);
	context.setConfigurations(new Configuration[] { new JettyAnnotationConfiguration() });
	
	// Create server and configure it
	final Server server = new Server(port);
	server.setHandler(context);

	return server;
}
 
开发者ID:activeviam,项目名称:autopivot,代码行数:14,代码来源:AutoPivotLauncher.java

示例13: beforeClass

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
	/*
	 * This runs under maven, and I'm not sure how else to figure out the target directory from code..
	 */
	String path = ExampleServerIT.class.getClassLoader().getResource(".keep_hapi-fhir-jpaserver-example").getPath();
	path = new File(path).getParent();
	path = new File(path).getParent();
	path = new File(path).getParent();

	ourLog.info("Project base path is: {}", path);

	ourPort = RandomServerPortProvider.findFreePort();
	ourServer = new Server(ourPort);

	WebAppContext webAppContext = new WebAppContext();
	webAppContext.setContextPath("/");
	webAppContext.setDescriptor(path + "/src/main/webapp/WEB-INF/web.xml");
	webAppContext.setResourceBase(path + "/target/hapi-fhir-jpaserver-example");
	webAppContext.setParentLoaderPriority(true);

	ourServer.setHandler(webAppContext);
	ourServer.start();

	ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
	ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000);
	ourServerBase = "http://localhost:" + ourPort + "/baseDstu2";
	ourClient = ourCtx.newRestfulGenericClient(ourServerBase);
	ourClient.registerInterceptor(new LoggingInterceptor(true));

}
 
开发者ID:gerard-bisama,项目名称:DHIS2-fhir-lab-app,代码行数:32,代码来源:ExampleServerIT.java

示例14: 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

示例15: loadWar

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
private WebAppContext loadWar(final File warFile, final String contextPath) throws IOException {
    final WebAppContext webappContext = new WebAppContext(warFile.getPath(), contextPath);
    webappContext.setContextPath(contextPath);
    webappContext.setDisplayName(contextPath);

    // remove slf4j server class to allow WAR files to have slf4j dependencies in WEB-INF/lib
    List<String> serverClasses = new ArrayList<>(Arrays.asList(webappContext.getServerClasses()));
    serverClasses.remove("org.slf4j.");
    webappContext.setServerClasses(serverClasses.toArray(new String[0]));
    webappContext.setDefaultsDescriptor(WEB_DEFAULTS_XML);

    // get the temp directory for this webapp
    final File webWorkingDirectory = properties.getWebWorkingDirectory();
    final File tempDir = new File(webWorkingDirectory, warFile.getName());
    if (tempDir.exists() && !tempDir.isDirectory()) {
        throw new RuntimeException(tempDir.getAbsolutePath() + " is not a directory");
    } else if (!tempDir.exists()) {
        final boolean made = tempDir.mkdirs();
        if (!made) {
            throw new RuntimeException(tempDir.getAbsolutePath() + " could not be created");
        }
    }
    if (!(tempDir.canRead() && tempDir.canWrite())) {
        throw new RuntimeException(tempDir.getAbsolutePath() + " directory does not have read/write privilege");
    }

    // configure the temp dir
    webappContext.setTempDirectory(tempDir);

    // configure the max form size (3x the default)
    webappContext.setMaxFormContentSize(600000);

    webappContext.setClassLoader(new WebAppClassLoader(ClassLoader.getSystemClassLoader(), webappContext));

    logger.info("Loading WAR: " + warFile.getAbsolutePath() + " with context path set to " + contextPath);
    return webappContext;
}
 
开发者ID:apache,项目名称:nifi-registry,代码行数:38,代码来源:JettyServer.java


注:本文中的org.eclipse.jetty.webapp.WebAppContext.setContextPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。