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


Java WebApplicationInitializer类代码示例

本文整理汇总了Java中org.springframework.web.WebApplicationInitializer的典型用法代码示例。如果您正苦于以下问题:Java WebApplicationInitializer类的具体用法?Java WebApplicationInitializer怎么用?Java WebApplicationInitializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: start

import org.springframework.web.WebApplicationInitializer; //导入依赖的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: deployConfig

import org.springframework.web.WebApplicationInitializer; //导入依赖的package包/类
public void deployConfig(Class<? extends WebApplicationInitializer>... initializers) {

  this.context = this.tomcatServer.addContext("", System.getProperty("java.io.tmpdir"));

  // Add Tomcat's DefaultServlet
  Wrapper defaultServlet = this.context.createWrapper();
  defaultServlet.setName("default");
  defaultServlet.setServletClass("org.apache.catalina.servlets.DefaultServlet");
  this.context.addChild(defaultServlet);

  // Ensure WebSocket support
  this.context.addApplicationListener(WS_APPLICATION_LISTENER);

  this.context.addServletContainerInitializer(
          new SpringServletContainerInitializer(), new HashSet<Class<?>>(Arrays.asList(initializers)));
 }
 
开发者ID:Appverse,项目名称:appverse-server,代码行数:17,代码来源:TomcatWebSocketTestServer.java

示例3: deployConfig

import org.springframework.web.WebApplicationInitializer; //导入依赖的package包/类
public void deployConfig(Class<? extends WebApplicationInitializer>... initializers) {

        this.context = this.tomcatServer.addContext("", System.getProperty("java.io.tmpdir"));

		// Add Tomcat's DefaultServlet
		Wrapper defaultServlet = this.context.createWrapper();
		defaultServlet.setName("default");
		defaultServlet.setServletClass("org.apache.catalina.servlets.DefaultServlet");
		this.context.addChild(defaultServlet);

		// Ensure WebSocket support
		this.context.addApplicationListener(WS_APPLICATION_LISTENER);

		this.context.addServletContainerInitializer(
				new SpringServletContainerInitializer(), new HashSet<Class<?>>(Arrays.asList(initializers)));
	}
 
开发者ID:wieden-kennedy,项目名称:composite-framework,代码行数:17,代码来源:TomcatWebSocketTestServer.java

示例4: deployConfig

import org.springframework.web.WebApplicationInitializer; //导入依赖的package包/类
public void deployConfig(Class<? extends WebApplicationInitializer>... initializers) {

        this.context = this.tomcatServer.addContext("", System.getProperty("java.io.tmpdir"));

		// Add Tomcat's DefaultServlet
		Wrapper defaultServlet = this.context.createWrapper();
		defaultServlet.setName("default");
		defaultServlet.setServletClass("org.apache.catalina.servlets.DefaultServlet");
		this.context.addChild(defaultServlet);

		// Ensure WebSocket support
		this.context.addApplicationListener(WsContextListener.class.getName());

		this.context.addServletContainerInitializer(
				new SpringServletContainerInitializer(), new HashSet<Class<?>>(Arrays.asList(initializers)));
	}
 
开发者ID:bjornharvold,项目名称:bearchoke,代码行数:17,代码来源:TomcatWebSocketTestServer.java

示例5: preConfigure

import org.springframework.web.WebApplicationInitializer; //导入依赖的package包/类
@Override
public void preConfigure(WebAppContext context) throws Exception {
	final Set<String> set = Collections.singleton(AutoPivotWebAppInitializer.class.getName());
	final Map<String, Set<String>> map = new ClassInheritanceMap();
	map.put(WebApplicationInitializer.class.getName(), set);
	context.setAttribute(CLASS_INHERITANCE_MAP, map);
	_classInheritanceHandler = new ClassInheritanceHandler(map);
}
 
开发者ID:activeviam,项目名称:autopivot,代码行数:9,代码来源:AutoPivotLauncher.java

示例6: getAwsProxyHandler

import org.springframework.web.WebApplicationInitializer; //导入依赖的package包/类
/**
 * Creates a default SpringLambdaContainerHandler initialized with the `AwsProxyRequest` and `AwsProxyResponse` objects
 * @param springBootInitializer {@code SpringBootServletInitializer} class
 * @return An initialized instance of the `SpringLambdaContainerHandler`
 * @throws ContainerInitializationException If an error occurs while initializing the Spring framework
 */
public static SpringBootLambdaContainerHandler<AwsProxyRequest, AwsProxyResponse> getAwsProxyHandler(Class<? extends WebApplicationInitializer> springBootInitializer)
        throws ContainerInitializationException {
    return new SpringBootLambdaContainerHandler<>(
            new AwsProxyHttpServletRequestReader(),
            new AwsProxyHttpServletResponseWriter(),
            new AwsProxySecurityContextWriter(),
            new AwsProxyExceptionHandler(),
            springBootInitializer
    );
}
 
开发者ID:awslabs,项目名称:aws-serverless-java-container,代码行数:17,代码来源:SpringBootLambdaContainerHandler.java

示例7: WebApplicationInitializersConfiguration

import org.springframework.web.WebApplicationInitializer; //导入依赖的package包/类
public WebApplicationInitializersConfiguration(Class<?> webApplicationInitializer,
		Class<?>... webApplicationInitializers) {
	this.webApplicationInitializers = new Class<?>[webApplicationInitializers.length + 1];
	this.webApplicationInitializers[0] = webApplicationInitializer;
	System.arraycopy(webApplicationInitializers, 0, this.webApplicationInitializers,
			1, webApplicationInitializers.length);
	for (Class<?> i : webApplicationInitializers) {
		Assert.notNull(i, "WebApplicationInitializer must not be null");
		Assert.isAssignable(WebApplicationInitializer.class, i);
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:WebApplicationInitializersConfiguration.java

示例8: WebServer

import org.springframework.web.WebApplicationInitializer; //导入依赖的package包/类
public WebServer(int port, String hostname, Class<? extends WebApplicationInitializer> initializer, File resourceBaseDirectory, String contextPath) {
    this.port = port;
    this.hostname = hostname;
    this.initializer = initializer;
    this.resourceBaseDirectory = resourceBaseDirectory;
    this.contextPath = contextPath;
}
 
开发者ID:mattprovis,项目名称:uitest,代码行数:8,代码来源:WebServer.java

示例9: startServer

import org.springframework.web.WebApplicationInitializer; //导入依赖的package包/类
public static void startServer(JettyConfig jettyConfig) throws Exception {
	
	if(!jettyConfig.isQuietMode())
	{
		System.out.println();
		System.out.println("Starting embedded jetty...");
	}
	
	//create the server
	Server server = new Server();
	ServerConnector c = new ServerConnector(server);
	
	//set the context path
     WebAppContext webAppContext = new WebAppContext();
     webAppContext.setContextPath("/");
     webAppContext.setWelcomeFiles(new String[] {"/static/test.html"});
     
     //tell the webApp about our Spring MVC web initializer. The hoops I jump through here are because
     //Jetty 9 AnnotationConfiguration doesn't scan non-jar classpath locations for a class that implements WebApplicationInitializer.
     //The code below explicitly tells Jetty about our implementation of WebApplicationInitializer.
     
     //this Jetty bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=404176  and the discussion around it defines the issue best. I decided
     //I would not rely on the potentially buggy solution put into Jetty 9 (discussed in the bug thread) and just go for a fix I know would work.  
     webAppContext.setConfigurations(new Configuration[] { 
    		 new AnnotationConfiguration() {
    		        @Override
    		        public void preConfigure(WebAppContext context) throws Exception {
    		        	ClassInheritanceMap map = new ClassInheritanceMap();
    		            ConcurrentHashSet<String> hashSet = new  ConcurrentHashSet<String>();
    		            hashSet.add(SpringMvcInitializer.class.getName());
    		            map.put(WebApplicationInitializer.class.getName(), hashSet);
    		            context.setAttribute(CLASS_INHERITANCE_MAP, map);
    		            _classInheritanceHandler = new ClassInheritanceHandler(map);
    		        }
    		    } 
	 });
     server.setHandler(webAppContext);
	
	//core server configuration
	c.setIdleTimeout(jettyConfig.getIdleTimeout());
	c.setAcceptQueueSize(jettyConfig.getAcceptQueueSize());
	c.setPort(jettyConfig.getPort());
	c.setHost(jettyConfig.getHost());
	server.addConnector(c);
	
	//start the server and make it available when initialization is complete
	server.start();
	server.join();
}
 
开发者ID:orb15,项目名称:embeddedjetty9-spring4,代码行数:50,代码来源:EmbeddedJetty.java

示例10: createHandlers

import org.springframework.web.WebApplicationInitializer; //导入依赖的package包/类
private HandlerCollection createHandlers() throws IOException, URISyntaxException {
    webAppContext = new WebAppContext();
    webAppContext.setParentLoaderPriority(true);
    webAppContext.setContextPath(contextPath);
    webAppContext.setResourceBase(resourceBaseDirectory.getAbsolutePath());

    File tempDir = new File(System.getProperty("java.io.tmpdir"));
    File scratchDir = new File(tempDir.toString(), "embedded-jetty-jsp");

    if (!scratchDir.exists()) {
        if (!scratchDir.mkdirs()) {
            throw new IOException("Unable to create scratch directory: " + scratchDir);
        }
    }

    System.setProperty("org.apache.jasper.compiler.disablejsr199", "false");
    ClassLoader jspClassLoader = new URLClassLoader(new URL[0], this.getClass().getClassLoader());
    webAppContext.setClassLoader(jspClassLoader);

    ServletHolder holderJsp = new ServletHolder("jsp", JspServlet.class);
    holderJsp.setInitOrder(0);
    holderJsp.setInitParameter("logVerbosityLevel", "DEBUG");
    holderJsp.setInitParameter("fork", "false");
    holderJsp.setInitParameter("xpoweredBy", "false");
    holderJsp.setInitParameter("compilerTargetVM", "1.7");
    holderJsp.setInitParameter("compilerSourceVM", "1.7");
    holderJsp.setInitParameter("keepgenerated", "true");
    webAppContext.addServlet(holderJsp, "*.jsp");
    webAppContext.addServlet(holderJsp, "*.jspf");
    webAppContext.addServlet(holderJsp, "*.jspx");

    webAppContext.setAttribute("javax.servlet.context.tempdir", scratchDir);

    webAppContext.setConfigurations(new Configuration[]{
            new WebXmlConfiguration(),
            new AnnotationConfiguration() {
                @Override
                public void preConfigure(WebAppContext context) throws Exception {
                    MultiMap<String> map = new MultiMap<>();
                    map.add(WebApplicationInitializer.class.getName(), initializer.getName());
                    context.setAttribute(CLASS_INHERITANCE_MAP, map);
                    _classInheritanceHandler = new ClassInheritanceHandler(map);
                }
            }});

    List<Handler> _handlers = new ArrayList<>();

    _handlers.add(webAppContext);

    HandlerList _contexts = new HandlerList();
    _contexts.setHandlers(_handlers.toArray(new Handler[0]));

    HandlerCollection _result = new HandlerCollection();
    _result.setHandlers(new Handler[]{_contexts});

    return _result;
}
 
开发者ID:mattprovis,项目名称:uitest,代码行数:58,代码来源:WebServer.java

示例11: getTestInitializerClass

import org.springframework.web.WebApplicationInitializer; //导入依赖的package包/类
@Override
protected Class<? extends WebApplicationInitializer> getTestInitializerClass() {
    return TestInitializer.class;
}
 
开发者ID:mattprovis,项目名称:uitest,代码行数:5,代码来源:UITestConfiguration.java

示例12: SpringBootLambdaContainerHandler

import org.springframework.web.WebApplicationInitializer; //导入依赖的package包/类
/**
 * Creates a new container handler with the given reader and writer objects
 *
 * @param requestReader An implementation of `RequestReader`
 * @param responseWriter An implementation of `ResponseWriter`
 * @param securityContextWriter An implementation of `SecurityContextWriter`
 * @param exceptionHandler An implementation of `ExceptionHandler`
 * @param springBootInitializer {@code SpringBootServletInitializer} class
 * @throws ContainerInitializationException If an error occurs while initializing the Spring framework
 */
public SpringBootLambdaContainerHandler(RequestReader<RequestType, AwsProxyHttpServletRequest> requestReader,
                                        ResponseWriter<AwsHttpServletResponse, ResponseType> responseWriter,
                                        SecurityContextWriter<RequestType> securityContextWriter,
                                        ExceptionHandler<ResponseType> exceptionHandler,
                                        Class<? extends WebApplicationInitializer> springBootInitializer)
        throws ContainerInitializationException {
    super(requestReader, responseWriter, securityContextWriter, exceptionHandler);
    this.springBootInitializer = springBootInitializer;
}
 
开发者ID:awslabs,项目名称:aws-serverless-java-container,代码行数:20,代码来源:SpringBootLambdaContainerHandler.java

示例13: getTestInitializerClass

import org.springframework.web.WebApplicationInitializer; //导入依赖的package包/类
/**
 * A class implementing WebApplicationInitializer (typically by extending your Initializer from the production code).
 * It MUST return MocksConfig.class from getRootConfigClasses(), along with at least one @Configuration class of your own that declares a bean of type MocksDefinition to set up the necessary mocks.
 */
protected abstract Class<? extends WebApplicationInitializer> getTestInitializerClass();
 
开发者ID:mattprovis,项目名称:uitest,代码行数:6,代码来源:AbstractUITestConfiguration.java


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