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


Java Servlets.listener方法代码示例

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


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

示例1: deployApplications

import io.undertow.servlet.Servlets; //导入方法依赖的package包/类
/**
 * Setup the deployment managers for a given set of applications
 *
 * @param apps
 * @return list of deployment managers
 */
public List<DeploymentManager> deployApplications(List<Application> apps) {
	List<DeploymentManager> deployManagers = new ArrayList<DeploymentManager>();
	for (Application app : apps) {
		DeploymentInfo deployInfo = app.getDeploymentInfo();

		// Add default listeners
		ListenerInfo cdiListener = Servlets.listener(CdiServletRequestListener.class);
		deployInfo.addListener(cdiListener);

		DeploymentManager deploymentManager = Servlets.defaultContainer().addDeployment(deployInfo);
		try {
			deploymentManager.deploy();
			deployManagers.add(deploymentManager);
		} catch (Exception e) {
			logger.log(Level.SEVERE, "stokesdrift:server:start[status=app_deploy_fail,app_type=" + app.getClass().getSimpleName() + "]", e);
		}
	}
	return deployManagers;
}
 
开发者ID:stokesdrift,项目名称:stokesdrift,代码行数:26,代码来源:Server.java

示例2: getDeploymentInfo

import io.undertow.servlet.Servlets; //导入方法依赖的package包/类
@Override
public DeploymentInfo getDeploymentInfo() {
	FilterInfo filter = Servlets.filter(RACK_FILTER, RackFilter.class);
	// TODO extend listener and setup the jruby env based on reloaded gems
	// and jars
	// Override appfactory?

	ListenerInfo listenerInfo = Servlets.listener(ServletContextListener.class);

	DeploymentInfo di = new DeploymentInfo().addListener(listenerInfo).setContextPath(config.getRootUrlPath()).addFilter(filter)
			.addFilterUrlMapping(RACK_FILTER, "/*", DispatcherType.REQUEST).setDeploymentName(config.getName())
			.setClassLoader(ClassLoader.getSystemClassLoader());
	setupInitParams(di);
	return di;
}
 
开发者ID:stokesdrift,项目名称:stokesdrift,代码行数:16,代码来源:RackApplication.java

示例3: testUndertowLoading

import io.undertow.servlet.Servlets; //导入方法依赖的package包/类
@Test
public void testUndertowLoading() throws Exception {
	int port = 8888;
	FilterInfo filter = Servlets.filter("RackFilter", RackFilter.class);
	ListenerInfo listenerInfo = Servlets.listener(RackServletContextListener.class);
	DeploymentInfo di = new DeploymentInfo()
			.addListener(listenerInfo)
	        .setContextPath("/")
	        // .addInitParameter(name, value)
	        .addFilter(filter)
	        .addFilterUrlMapping("RackFilter", "/*", DispatcherType.ASYNC)
	        // .addServlet(servletInfo)
	        .setDeploymentName("RackServlet")
	        .setClassLoader(ClassLoader.getSystemClassLoader());
	DeploymentManager deploymentManager = Servlets.defaultContainer().addDeployment(di);
	deploymentManager.deploy();
	Undertow server = Undertow.builder()
	        .addHttpListener(port, "localhost")
	        .setHandler(deploymentManager.start())
	        .build();
	Assert.assertNotNull(server);
	//	server.start();

}
 
开发者ID:stokesdrift,项目名称:stokesdrift,代码行数:25,代码来源:UndertowTest.java

示例4: start

import io.undertow.servlet.Servlets; //导入方法依赖的package包/类
public void start() {
    ResteasyDeployment deployment = new ResteasyDeployment();
    deployment.getActualResourceClasses().addAll(restMonitorExtension.getRestEndpointClasses());
    deployment.getActualProviderClasses().addAll(restMonitorExtension.getProviderClasses());
    deployment.setInjectorFactoryClass(CdiInjectorFactory.class.getName());

    ListenerInfo listener = Servlets.listener(CDIListener.class);

    ServletInfo resteasyServlet = Servlets.servlet("ResteasyServlet", HttpServlet30Dispatcher.class)
            .setAsyncSupported(true)
            .setLoadOnStartup(1)
            .addMapping("/*");

    DeploymentInfo di = new DeploymentInfo()
            .addListener(listener)
            .setContextPath(configurationManager.getContextRoot())
            .addServletContextAttribute(ResteasyDeployment.class.getName(), deployment)
            .addServlet(resteasyServlet).setDeploymentName("ResteasyUndertow")
            .setClassLoader(ClassLoader.getSystemClassLoader());

    DeploymentManager deploymentManager = Servlets.defaultContainer().addDeployment(di);
    deploymentManager.deploy();
    Undertow server = null;
    try {
        server = Undertow.builder()
                .addHttpListener(configurationManager.getPort(), configurationManager.getBindAddress())
                .setHandler(deploymentManager.start())
                .build();
    } catch (ServletException e) {
        catchEvent.fire(new ExceptionToCatchEvent(e));
    }
    server.start();
    this.undertow = server;
}
 
开发者ID:johnament,项目名称:microservices-tutorial,代码行数:35,代码来源:WebServerLauncher.java

示例5: start

import io.undertow.servlet.Servlets; //导入方法依赖的package包/类
/**
    * Start the management interface.
    *
    */
public void start() {
	
	Builder builder = Undertow.builder();
	
	// add listener
	builder.addHttpListener(this.managementPort, this.managementInterface);
	
	// set up resource handler
	ClassPathResourceManager classPathManager = new ClassPathResourceManager(Thread.currentThread().getContextClassLoader(), "web");
	ResourceHandler resources = Handlers.resource(classPathManager);
	resources.setWelcomeFiles("index.html");
	resources.setDirectoryListingEnabled(false);
	
	// set up servlet handler
	DeploymentInfo servletBuilder = Servlets.deployment()
			.setClassLoader(Thread.currentThread().getContextClassLoader())
			.setContextPath("/services")
			.setDeploymentName("pincushion-services.war")
			;
	
	// add context parameters
	//servletBuilder.addInitParameter(ResteasyContextParameters.RESTEASY_SERVLET_MAPPING_PREFIX, "/");
	
	// add context listener for bootstrap
	ListenerInfo restBootstrapListener = Servlets.listener(ResteasyBootstrap.class, new ResteasyBootstrapInstanceFactory(this.manager));
	servletBuilder.addListener(restBootstrapListener);
	
	// create and add servlet to servlet handler
	ServletInfo restServletInfo = Servlets.servlet("restEasyHandler", HttpServletDispatcher.class);
	restServletInfo.addInitParam("javax.ws.rs.Application", ManagementApplication.class.getName());
	restServletInfo.addMapping("/*");
	restServletInfo.setLoadOnStartup(1);
	servletBuilder.addServlet(restServletInfo);
	
	// deploy servlets
	DeploymentManager deploymentManager = Servlets.defaultContainer().addDeployment(servletBuilder);
	
	deploymentManager.deploy();
	HttpHandler services = null;
	try {
		services = deploymentManager.start();
	} catch (ServletException e) {
		this.logger.error("Could not start services deployment: {}", e.getLocalizedMessage());
	}

	// create paths
	PathHandler path = Handlers.path(resources);
	if(services != null) {
		path.addPrefixPath("/services", services);
	}
	
	// create encoding repository
	ContentEncodingRepository repo = new ContentEncodingRepository();

       // permit gzip and deflate
	repo.addEncodingHandler("gzip", new GzipEncodingProvider(), 1000);
	repo.addEncodingHandler("deflate", new DeflateEncodingProvider(), 10);
	
	// ensure that everything can be encoded with appropriate compression
	EncodingHandler encoder = new EncodingHandler(path, repo);
	
	// add path handler to server
	builder.setHandler(encoder);
	
	// start undertow server
	this.server = builder.build();
	this.server.start();
	
	this.logger.info("Started undertow management interface at {} on port {}", this.managementInterface, this.managementPort);
}
 
开发者ID:chrisruffalo,项目名称:pincushion,代码行数:75,代码来源:ManagementInterface.java


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