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


Java WebAppContext.setConfigurations方法代碼示例

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


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

示例1: start

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
public void start() {
    // TODO: remove redundant fields from config and move this check to XRE Redirector
    if (! config.getEnableCommunicationEndpoint()) {
        log.warn("skipping Jetty endpoint due to configuration");
        return;
    }

    if (started) {
        log.warn("Jetty is already started");
    }

    started = true;
    Integer port = config.getCommunicationEndpointPort();

    log.info("Starting embedded jetty server (XRERedirector Gateway) on port: {}", port);

    WebAppContext webAppContext = new WebAppContext();
    webAppContext.setConfigurations(new Configuration[]{new AnnotationConfiguration() {
        @Override
        public void preConfigure(WebAppContext context) {
            ClassInheritanceMap map = new ClassInheritanceMap();
            map.put(WebApplicationInitializer.class.getName(), new ConcurrentHashSet<String>() {{
                add(WebAppInitializer.class.getName());
            }});
            context.setAttribute(CLASS_INHERITANCE_MAP, map);
            _classInheritanceHandler = new ClassInheritanceHandler(map);
        }
    }});

    server = new Server(port);
    server.setHandler(webAppContext);

    try {
        server.start();
    } catch (Exception e) {
        log.error("Failed to start embedded jetty server (XRERedirector communication endpoint) on port: " + port, e);
    }

    log.info("Started embedded jetty server (Redirector Gateway) on port: {}", port);
}
 
開發者ID:Comcast,項目名稱:redirector,代碼行數:41,代碼來源:EmbeddedJetty.java

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

示例3: configureWebAppContext

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
/**
 * Configure the given Jetty {@link WebAppContext} for use.
 * @param context the context to configure
 * @param initializers the set of initializers to apply
 */
protected final void configureWebAppContext(WebAppContext context,
		ServletContextInitializer... initializers) {
	Assert.notNull(context, "Context must not be null");
	context.setTempDirectory(getTempDirectory());
	if (this.resourceLoader != null) {
		context.setClassLoader(this.resourceLoader.getClassLoader());
	}
	String contextPath = getContextPath();
	context.setContextPath(StringUtils.hasLength(contextPath) ? contextPath : "/");
	context.setDisplayName(getDisplayName());
	configureDocumentRoot(context);
	if (isRegisterDefaultServlet()) {
		addDefaultServlet(context);
	}
	if (shouldRegisterJspServlet()) {
		addJspServlet(context);
		context.addBean(new JasperInitializer(context), true);
	}
	ServletContextInitializer[] initializersToUse = mergeInitializers(initializers);
	Configuration[] configurations = getWebAppContextConfigurations(context,
			initializersToUse);
	context.setConfigurations(configurations);
	configureSession(context);
	postProcessWebAppContext(context);
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:31,代碼來源:JettyEmbeddedServletContainerFactory.java

示例4: createFrontAppContext

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
protected WebAppContext createFrontAppContext(ClassLoader serverClassLoader, ClassLoader sharedClassLoader) throws URISyntaxException {
    ClassLoader frontClassLoader = new URLClassLoader(pathsToURLs(serverClassLoader, getAppClassesPath(FRONT_PATH_IN_JAR)), sharedClassLoader);

    WebAppContext frontContext = new WebAppContext();
    frontContext.setConfigurations(new Configuration[]{new WebXmlConfiguration()});
    frontContext.setContextPath(frontContextPath);
    frontContext.setClassLoader(frontClassLoader);

    setResourceBase(serverClassLoader, frontContext, FRONT_PATH_IN_JAR);

    System.setProperty("cuba.front.baseUrl", PATH_DELIMITER.equals(frontContextPath) ? frontContextPath :
            frontContextPath + PATH_DELIMITER);
    System.setProperty("cuba.front.apiUrl", PATH_DELIMITER.equals(contextPath) ? "/rest/" :
            contextPath + PATH_DELIMITER + "rest" + PATH_DELIMITER);

    return frontContext;
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:18,代碼來源:CubaJettyServer.java

示例5: configureWebAppContext

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
/**
 * Configure the given Jetty {@link WebAppContext} for use.
 * @param context the context to configure
 * @param initializers the set of initializers to apply
 */
protected final void configureWebAppContext(WebAppContext context,
		ServletContextInitializer... initializers) {
	Assert.notNull(context, "Context must not be null");
	context.setTempDirectory(getTempDirectory());
	if (this.resourceLoader != null) {
		context.setClassLoader(this.resourceLoader.getClassLoader());
	}
	String contextPath = getContextPath();
	context.setContextPath(StringUtils.hasLength(contextPath) ? contextPath : "/");
	context.setDisplayName(getDisplayName());
	configureDocumentRoot(context);
	if (isRegisterDefaultServlet()) {
		addDefaultServlet(context);
	}
	if (shouldRegisterJspServlet()) {
		addJspServlet(context);
	}
	ServletContextInitializer[] initializersToUse = mergeInitializers(initializers);
	Configuration[] configurations = getWebAppContextConfigurations(context,
			initializersToUse);
	context.setConfigurations(configurations);
	configureSession(context);
	postProcessWebAppContext(context);
}
 
開發者ID:philwebb,項目名稱:spring-boot-concourse,代碼行數:30,代碼來源:JettyEmbeddedServletContainerFactory.java

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

示例7: main

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

	WebAppContext webAppContext = new WebAppContext();
	webAppContext.setContextPath("/");
	webAppContext.setConfigurations(new Configuration[] {
			new WebApplicationInitializersConfiguration(SpringInitializer.class) });

	webAppContext.setParentLoaderPriority(true);
	server.setHandler(webAppContext);
	server.start();

	server.join();
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:15,代碼來源:EmbeddedWarStarter.java

示例8: createAppContext

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
protected WebAppContext createAppContext(ClassLoader serverClassLoader, ClassLoader sharedClassLoader,
                                         String appPathInJar, String contextPath) throws URISyntaxException {
    ClassLoader appClassLoader = new URLClassLoader(pathsToURLs(serverClassLoader, getAppClassesPath(appPathInJar)), sharedClassLoader);

    WebAppContext appContext = new WebAppContext();
    appContext.setConfigurations(new Configuration[]{new WebXmlConfiguration(), createEnvConfiguration()});
    appContext.setContextPath(contextPath);
    appContext.setClassLoader(appClassLoader);

    setResourceBase(serverClassLoader, appContext, appPathInJar);

    return appContext;
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:14,代碼來源:CubaJettyServer.java

示例9: main

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
public static void main(final String[] args) {
  InetSocketAddress _inetSocketAddress = new InetSocketAddress("localhost", 8080);
  final Server server = new Server(_inetSocketAddress);
  WebAppContext _webAppContext = new WebAppContext();
  final Procedure1<WebAppContext> _function = (WebAppContext it) -> {
    it.setResourceBase("WebRoot");
    it.setWelcomeFiles(new String[] { "index.html" });
    it.setContextPath("/");
    AnnotationConfiguration _annotationConfiguration = new AnnotationConfiguration();
    WebXmlConfiguration _webXmlConfiguration = new WebXmlConfiguration();
    WebInfConfiguration _webInfConfiguration = new WebInfConfiguration();
    MetaInfConfiguration _metaInfConfiguration = new MetaInfConfiguration();
    it.setConfigurations(new Configuration[] { _annotationConfiguration, _webXmlConfiguration, _webInfConfiguration, _metaInfConfiguration });
    it.setAttribute(WebInfConfiguration.CONTAINER_JAR_PATTERN, ".*/com\\.hribol\\.bromium\\.dsl\\.web/.*,.*\\.jar");
    it.setInitParameter("org.mortbay.jetty.servlet.Default.useFileMappedBuffer", "false");
  };
  WebAppContext _doubleArrow = ObjectExtensions.<WebAppContext>operator_doubleArrow(_webAppContext, _function);
  server.setHandler(_doubleArrow);
  String _name = ServerLauncher.class.getName();
  final Slf4jLog log = new Slf4jLog(_name);
  try {
    server.start();
    URI _uRI = server.getURI();
    String _plus = ("Server started " + _uRI);
    String _plus_1 = (_plus + "...");
    log.info(_plus_1);
    final Runnable _function_1 = () -> {
      try {
        log.info("Press enter to stop the server...");
        final int key = System.in.read();
        if ((key != (-1))) {
          server.stop();
        } else {
          log.warn("Console input is not available. In order to stop the server, you need to cancel process manually.");
        }
      } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
      }
    };
    new Thread(_function_1).start();
    server.join();
  } catch (final Throwable _t) {
    if (_t instanceof Exception) {
      final Exception exception = (Exception)_t;
      log.warn(exception.getMessage());
      System.exit(1);
    } else {
      throw Exceptions.sneakyThrow(_t);
    }
  }
}
 
開發者ID:hristo-vrigazov,項目名稱:bromium,代碼行數:52,代碼來源:ServerLauncher.java

示例10: main

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
public static void main(final String[] args) {
  InetSocketAddress _inetSocketAddress = new InetSocketAddress("localhost", 8080);
  final Server server = new Server(_inetSocketAddress);
  WebAppContext _webAppContext = new WebAppContext();
  final Procedure1<WebAppContext> _function = (WebAppContext it) -> {
    it.setResourceBase("WebRoot");
    it.setWelcomeFiles(new String[] { "index.html" });
    it.setContextPath("/");
    AnnotationConfiguration _annotationConfiguration = new AnnotationConfiguration();
    WebXmlConfiguration _webXmlConfiguration = new WebXmlConfiguration();
    WebInfConfiguration _webInfConfiguration = new WebInfConfiguration();
    MetaInfConfiguration _metaInfConfiguration = new MetaInfConfiguration();
    it.setConfigurations(new Configuration[] { _annotationConfiguration, _webXmlConfiguration, _webInfConfiguration, _metaInfConfiguration });
    it.setAttribute(WebInfConfiguration.CONTAINER_JAR_PATTERN, ".*/org\\.xtext\\.dsl\\.restaurante\\.web/.*,.*\\.jar");
    it.setInitParameter("org.mortbay.jetty.servlet.Default.useFileMappedBuffer", "false");
  };
  WebAppContext _doubleArrow = ObjectExtensions.<WebAppContext>operator_doubleArrow(_webAppContext, _function);
  server.setHandler(_doubleArrow);
  String _name = ServerLauncher.class.getName();
  final Slf4jLog log = new Slf4jLog(_name);
  try {
    server.start();
    URI _uRI = server.getURI();
    String _plus = ("Server started " + _uRI);
    String _plus_1 = (_plus + "...");
    log.info(_plus_1);
    final Runnable _function_1 = () -> {
      try {
        log.info("Press enter to stop the server...");
        final int key = System.in.read();
        if ((key != (-1))) {
          server.stop();
        } else {
          log.warn("Console input is not available. In order to stop the server, you need to cancel process manually.");
        }
      } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
      }
    };
    new Thread(_function_1).start();
    server.join();
  } catch (final Throwable _t) {
    if (_t instanceof Exception) {
      final Exception exception = (Exception)_t;
      log.warn(exception.getMessage());
      System.exit(1);
    } else {
      throw Exceptions.sneakyThrow(_t);
    }
  }
}
 
開發者ID:vicegd,項目名稱:org.xtext.dsl.restaurante,代碼行數:52,代碼來源:ServerLauncher.java

示例11: build

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
/**
 * 創建用於正常運行調試的Jetty Server, 以src/main/webapp為Web應用目錄.
 */
@Override
public Server build(int port, String webApp, String contextPath) throws BindException {
	port = this.getAutoPort(port);

	serverInitializer.run();

	Server server = new Server(port);
	WebAppContext webContext = new WebAppContext(webApp, contextPath);

	if (false) {
		ServletHolder holder = new ServletHolder(new ProxyServlet());
		holder.setInitParameter("proxyTo", "http://localhost:3000/");
		holder.setInitParameter("prefix", "/");

		webContext.addServlet(holder, "/app/");
		webContext.addServlet(new ServletHolder(new IndexServlet()), "/proxy/");
	}

	// webContext.setDefaultsDescriptor("leopard-jetty/webdefault.xml");

	// 問題點:http://stackoverflow.com/questions/13222071/spring-3-1-webapplicationinitializer-embedded-jetty-8-annotationconfiguration

	webContext.setConfigurations(new Configuration[] { //
			new EmbedWebInfConfiguration(), //
			new MetaInfConfiguration(), //
			new AnnotationConfiguration(), //
			new WebXmlConfiguration(), //
			new FragmentConfiguration() //
			// new TagLibConfiguration() //
	});

	// webContext.setConfigurations(new Configuration[] { //
	// new EmbedWebInfConfiguration()//
	// , new EmbedWebXmlConfiguration()//
	// , new EmbedMetaInfConfiguration()//
	// , new EmbedFragmentConfiguration()//
	// , new EmbedAnnotionConfiguration() //
	// // , new PlusConfiguration(),//
	// // new EnvConfiguration()//
	// });

	WebAppClassLoader classLoader = null;
	try {
		// addTldLib(webContext);
		classLoader = new LeopardWebAppClassLoader(webContext);
	}
	catch (IOException e) {
		e.printStackTrace();
	}
	// ClassLoader tldClassLoader = addTldLib(classLoader);
	webContext.setClassLoader(classLoader);

	webContext.setParentLoaderPriority(true);
	// logger.debug(webContext.dump());

	Handler rewriteHandler = ResourcesManager.getHandler();
	if (rewriteHandler == null) {
		server.setHandler(webContext);
	}
	else {
		HandlerCollection handlers = new HandlerCollection();
		handlers.addHandler(rewriteHandler);
		handlers.addHandler(webContext);
		server.setHandler(handlers);
	}
	server.setStopAtShutdown(true);

	return server;
}
 
開發者ID:tanhaichao,項目名稱:leopard,代碼行數:73,代碼來源:WebServerJettyImpl.java


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