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


Java WebAppContext.addBean方法代码示例

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


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

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

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

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

示例4: start

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public void start(boolean devMode, int port) throws Exception {

        Server server = new Server(new QueuedThreadPool(500));

        WebAppContext appContext = new WebAppContext();

        String resourceBasePath = "";
        //开发者模式
        if (devMode) {
            String artifact = MavenUtils.get(Thread.currentThread().getContextClassLoader()).getArtifactId();
            resourceBasePath = artifact + "/src/main/webapp";
        }
        appContext.setDescriptor(resourceBasePath + "WEB-INF/web.xml");
        appContext.setResourceBase(resourceBasePath);
        appContext.setExtractWAR(true);

        //init param
        appContext.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
        if (CommonUtils.isWindowOs()) {
            appContext.setInitParameter("org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false");
        }

        //for jsp support
        appContext.addBean(new JettyJspParser(appContext));
        appContext.addServlet(JettyJspServlet.class, "*.jsp");

        appContext.setContextPath("/");
        appContext.getServletContext().setExtendedListenerTypes(true);
        appContext.setParentLoaderPriority(true);
        appContext.setThrowUnavailableOnStartupException(true);
        appContext.setConfigurationDiscovered(true);
        appContext.setClassLoader(Thread.currentThread().getContextClassLoader());

        ServerConnector connector = new ServerConnector(server);
        connector.setHost("0.0.0.0");
        connector.setPort(port);
        server.setConnectors(new Connector[]{connector});
        server.setAttribute("org.eclipse.jetty.server.Request.maxFormContentSize", 1024 * 1024 * 1024);
        server.setDumpAfterStart(false);
        server.setDumpBeforeStop(false);
        server.setStopAtShutdown(true);
        server.setHandler(appContext);
        logger.info("[opencron] JettyLauncher starting...");
        server.start();
    }
 
开发者ID:wolfboys,项目名称:opencron,代码行数:46,代码来源:JettyLauncher.java

示例5: initJSP

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
private void initJSP(WebAppContext ctx) throws IOException {
    ctx.setAttribute("org.eclipse.jetty.containerInitializers", jspInitializers());
    ctx.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
    ctx.addBean(new ServletContainerInitializersStarter(ctx), true);
}
 
开发者ID:RWTH-i5-IDSG,项目名称:steve-plugsurfing,代码行数:6,代码来源:SteveAppContext.java

示例6: configure

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
@Override
public void configure(WebAppContext context) throws Exception {
	context.addBean(new Initializer(context), true);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:5,代码来源:ServletContextInitializerConfiguration.java


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