當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。