本文整理汇总了Java中io.undertow.servlet.api.ListenerInfo类的典型用法代码示例。如果您正苦于以下问题:Java ListenerInfo类的具体用法?Java ListenerInfo怎么用?Java ListenerInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ListenerInfo类属于io.undertow.servlet.api包,在下文中一共展示了ListenerInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addListener
import io.undertow.servlet.api.ListenerInfo; //导入依赖的package包/类
@Override
public void addListener(final Class<? extends EventListener> listenerClass) {
ensureNotInitialized();
ensureNotProgramaticListener();
if (ApplicationListeners.listenerState() != NO_LISTENER &&
ServletContextListener.class.isAssignableFrom(listenerClass)) {
throw UndertowServletMessages.MESSAGES.cannotAddServletContextListener();
}
InstanceFactory<? extends EventListener> factory = null;
try {
factory = deploymentInfo.getClassIntrospecter().createInstanceFactory(listenerClass);
} catch (Exception e) {
throw new IllegalArgumentException(e);
}
final ListenerInfo listener = new ListenerInfo(listenerClass, factory);
deploymentInfo.addListener(listener);
deployment.getApplicationListeners().addListener(new ManagedListener(listener, true));
}
示例2: getInjector
import io.undertow.servlet.api.ListenerInfo; //导入依赖的package包/类
public Injector getInjector() {
for (ListenerInfo listener : fathomDeploymentManager.getDeployment().getDeploymentInfo().getListeners()) {
if (ServletContextListener.class == listener.getListenerClass()) {
try {
ServletContextListener servletContextListener = (ServletContextListener) listener
.getInstanceFactory().createInstance().getInstance();
Injector injector = servletContextListener.getInjector();
return injector;
} catch (Exception e) {
log.error("Failed to get Guice injector!", e);
return null;
}
}
}
return null;
}
示例3: deployApplications
import io.undertow.servlet.api.ListenerInfo; //导入依赖的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;
}
示例4: getDeploymentInfo
import io.undertow.servlet.api.ListenerInfo; //导入依赖的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;
}
示例5: testUndertowLoading
import io.undertow.servlet.api.ListenerInfo; //导入依赖的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();
}
示例6: createListeners
import io.undertow.servlet.api.ListenerInfo; //导入依赖的package包/类
private ApplicationListeners createListeners() {
final List<ManagedListener> managedListeners = new ArrayList<>();
for (final ListenerInfo listener : deployment.getDeploymentInfo().getListeners()) {
managedListeners.add(new ManagedListener(listener, false));
}
return new ApplicationListeners(managedListeners, deployment.getServletContext());
}
示例7: createFathomDeploymentManager
import io.undertow.servlet.api.ListenerInfo; //导入依赖的package包/类
protected DeploymentManager createFathomDeploymentManager() throws ServletException {
DeploymentInfo info = Servlets.deployment();
info.setDeploymentName("Fathom");
info.setClassLoader(this.getClass().getClassLoader());
info.setContextPath(settings.getContextPath());
info.setIgnoreFlush(true);
info.setDefaultEncoding("UTF-8");
FilterInfo guiceFilter = new FilterInfo("GuiceFilter", GuiceFilter.class);
guiceFilter.setAsyncSupported(true);
info.addFilterUrlMapping("GuiceFilter", "/*", DispatcherType.REQUEST);
info.addFilters(guiceFilter);
ServletInfo defaultServlet = new ServletInfo("DefaultServlet", DefaultServlet.class);
defaultServlet.setAsyncSupported(true);
defaultServlet.addMapping("/");
ServletContextListener fathomListener = new ServletContextListener(settings);
info.addListeners(new ListenerInfo(ServletContextListener.class, new ImmediateInstanceFactory<>(fathomListener)));
MultipartConfigElement multipartConfig = new MultipartConfigElement(settings.getUploadFilesLocation(), settings.getUploadFilesMaxSize(), -1L, 0);
defaultServlet.setMultipartConfig(multipartConfig);
info.addServlets(defaultServlet);
DeploymentManager deploymentManager = Servlets.defaultContainer().addDeployment(info);
deploymentManager.deploy();
return deploymentManager;
}
示例8: main
import io.undertow.servlet.api.ListenerInfo; //导入依赖的package包/类
public static void main(String[] args) {
UIOptions.uiOptionsFromArgs(args).ifPresent(options -> {
try {
DeploymentInfo servletBuilder = Servlets.deployment()
.setClassLoader(Main.class.getClassLoader())
.setContextPath("/ui")
.setDeploymentName("ipp-ui.war")
.addListener(new ListenerInfo(ServletInit.class))
.addServlet(Servlets.servlet("UIServlet", UIServlet.class)
.addInitParam("config", options.getConfigFile().toString())
.addInitParam("databaseUri", options.getDatabaseUri().toString())
.addInitParam("redisUri", options.getRedisUri().toString())
.setAsyncSupported(true)
.addMapping("/*"));
DeploymentManager manager = Servlets.defaultContainer().addDeployment(servletBuilder);
manager.deploy();
PathHandler path = Handlers.path(
Handlers.resource(new ClassPathResourceManager(Main.class.getClassLoader(), "WebRoot")))
.addExactPath("/", Handlers.redirect("/ui"))
.addPrefixPath("/ui", manager.start());
Undertow server = Undertow.builder()
.addHttpListener(options.getPort(), options.getHost())
.setHandler(path)
.build();
server.start();
} catch (ServletException e) {
throw new RuntimeException(e);
}
});
}
示例9: handleDeployment
import io.undertow.servlet.api.ListenerInfo; //导入依赖的package包/类
@Override
public void handleDeployment(DeploymentInfo deploymentInfo, ServletContext servletContext) {
String componentName = "";
String resourceName = "";
Pattern insecureEndpointPattern = null;
Pattern postQueryPattern = null;
// file to contain configurations options for this Servlet Extension
InputStream is = servletContext.getResourceAsStream(PROPERTY_FILE);
if (is != null) {
try {
Properties props = new Properties();
props.load(is);
componentName = props.getProperty("component");
resourceName = props.getProperty("resource-name");
String insecurePatternString = props.getProperty("unsecure-endpoints");
String postQueryPatternString = props.getProperty("post-query");
if (insecurePatternString != null) {
insecureEndpointPattern = Pattern.compile(insecurePatternString);
}
if (postQueryPatternString != null) {
postQueryPattern = Pattern.compile(postQueryPatternString);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
if (componentName == null || componentName.isEmpty()) {
throw new RuntimeException("Missing or empty 'component' key from the " + PROPERTY_FILE + " configuration file.");
}
if (resourceName == null || resourceName.isEmpty()) {
throw new RuntimeException("Missing or empty 'resource-name' key from the " + PROPERTY_FILE + " configuratin file.");
}
final String cName = componentName;
final String rName = resourceName;
final Pattern insecurePattern = insecureEndpointPattern;
final Pattern postQuery = postQueryPattern;
if (DISABLE_NAMESPACE_FILTER.equalsIgnoreCase("true")) {
log.info("The OpenShift Namespace Filter has been disabled via the 'DISABLE_NAMESPACE_FILTER' system property.");
}
else {
log.info("Enabling the OpenShift Namespace Filter.");
deploymentInfo.addInitialHandlerChainWrapper(containerHandler -> {
namespaceHandler = new NamespaceHandler(containerHandler);
return namespaceHandler;
});
}
ImmediateInstanceFactory<EventListener> instanceFactory = new ImmediateInstanceFactory<>(new SCListener());
deploymentInfo.addListener(new ListenerInfo(SCListener.class, instanceFactory));
deploymentInfo.addInitialHandlerChainWrapper(containerHandler -> {
openshiftAuthHandler = new OpenshiftAuthHandler(containerHandler, cName, rName, insecurePattern, postQuery);
return openshiftAuthHandler;
});
}
示例10: createPippoDeploymentManager
import io.undertow.servlet.api.ListenerInfo; //导入依赖的package包/类
protected DeploymentManager createPippoDeploymentManager() throws ServletException {
DeploymentInfo info = Servlets.deployment();
info.setDeploymentName("Pippo");
info.setClassLoader(this.getClass().getClassLoader());
info.setContextPath(getSettings().getContextPath());
info.setIgnoreFlush(true);
// inject application as context attribute
info.addServletContextAttribute(PIPPO_APPLICATION, getApplication());
// add pippo filter
addPippoFilter(info);
// add initializers
info.addListener(new ListenerInfo(PippoServletContextListener.class));
// add listeners
listeners.forEach(listener -> info.addListener(new ListenerInfo(listener)));
ServletInfo defaultServlet = new ServletInfo("DefaultServlet", DefaultServlet.class);
defaultServlet.addMapping("/");
MultipartConfigElement multipartConfig = createMultipartConfigElement();
defaultServlet.setMultipartConfig(multipartConfig);
info.addServlets(defaultServlet);
DeploymentManager deploymentManager = Servlets.defaultContainer().addDeployment(info);
deploymentManager.deploy();
return deploymentManager;
}
示例11: start
import io.undertow.servlet.api.ListenerInfo; //导入依赖的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;
}
示例12: listener
import io.undertow.servlet.api.ListenerInfo; //导入依赖的package包/类
public static ListenerInfo listener(final Class<? extends EventListener> listenerClass, final InstanceFactory<? extends EventListener> instanceFactory) {
return new ListenerInfo(listenerClass, instanceFactory);
}
示例13: ManagedListener
import io.undertow.servlet.api.ListenerInfo; //导入依赖的package包/类
public ManagedListener(final ListenerInfo listenerInfo, final boolean programatic) {
this.listenerInfo = listenerInfo;
this.programatic = programatic;
}
示例14: getListenerInfo
import io.undertow.servlet.api.ListenerInfo; //导入依赖的package包/类
public ListenerInfo getListenerInfo() {
return listenerInfo;
}
示例15: main
import io.undertow.servlet.api.ListenerInfo; //导入依赖的package包/类
public static void main(String[] args) {
DeploymentInfo servletBuilder
= Servlets.deployment()
.setClassLoader(Main.class.getClassLoader())
.setContextPath(CONTEXT_PATH)
.setDeploymentName("ROOT.war")
.setDefaultEncoding("UTF-8")
.addListener(new ListenerInfo(EnvironmentLoaderListener.class))
.addFilter(new FilterInfo(SHIRO_FILTER, ShiroFilter.class))
.addFilterUrlMapping(SHIRO_FILTER, SHIRO_FILTER_MAPPING, REQUEST)
.addFilterUrlMapping(SHIRO_FILTER, SHIRO_FILTER_MAPPING, FORWARD)
.addFilterUrlMapping(SHIRO_FILTER, SHIRO_FILTER_MAPPING, INCLUDE)
.addFilterUrlMapping(SHIRO_FILTER, SHIRO_FILTER_MAPPING, ERROR)
.addServlets(
servlet(
MainServlet.class.getSimpleName(),
MainServlet.class).addMapping(SHIRO_FILTER_MAPPING)
);
DeploymentManager manager = Servlets
.defaultContainer()
.addDeployment(servletBuilder);
manager.deploy();
try {
HttpHandler httpHandler = manager.start();
PathHandler path = Handlers.path(redirect(CONTEXT_PATH))
.addPrefixPath(CONTEXT_PATH, httpHandler);
Undertow undertowServer = Undertow.builder()
.addHttpListener(8080, "0.0.0.0")
.setHandler(path)
.build();
undertowServer.start();
undertowOptional = Optional.of(undertowServer);
undertowServer.getListenerInfo().forEach(System.out::println);
} catch (ServletException e) {
e.printStackTrace();
undertowOptional = Optional.empty();
}
}