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


Java ListenerInfo类代码示例

本文整理汇总了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));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:ServletContextImpl.java

示例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;
}
 
开发者ID:gitblit,项目名称:fathom,代码行数:18,代码来源:Server.java

示例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;
}
 
开发者ID:stokesdrift,项目名称:stokesdrift,代码行数:26,代码来源:Server.java

示例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;
}
 
开发者ID:stokesdrift,项目名称:stokesdrift,代码行数:16,代码来源:RackApplication.java

示例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();

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

示例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());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:DeploymentManagerImpl.java

示例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;
    }
 
开发者ID:gitblit,项目名称:fathom,代码行数:33,代码来源:Server.java

示例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);
        }
    });
}
 
开发者ID:ULYSSIS-KUL,项目名称:ipp,代码行数:33,代码来源:Main.java

示例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;
    });

}
 
开发者ID:hawkular,项目名称:hawkular-metrics,代码行数:63,代码来源:OpenshiftAuthServletExtension.java

示例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;
}
 
开发者ID:decebals,项目名称:pippo,代码行数:32,代码来源:UndertowServer.java

示例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;
}
 
开发者ID:johnament,项目名称:microservices-tutorial,代码行数:35,代码来源:WebServerLauncher.java

示例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);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:Servlets.java

示例13: ManagedListener

import io.undertow.servlet.api.ListenerInfo; //导入依赖的package包/类
public ManagedListener(final ListenerInfo listenerInfo, final boolean programatic) {
    this.listenerInfo = listenerInfo;
    this.programatic = programatic;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:ManagedListener.java

示例14: getListenerInfo

import io.undertow.servlet.api.ListenerInfo; //导入依赖的package包/类
public ListenerInfo getListenerInfo() {
    return listenerInfo;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:ManagedListener.java

示例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();
  }
}
 
开发者ID:Java-Publications,项目名称:vaadin-016-helloworld-14,代码行数:46,代码来源:Main.java


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