本文整理汇总了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;
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}