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


Java Listener类代码示例

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


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

示例1: createTestArchive

import org.jboss.weld.environment.servlet.Listener; //导入依赖的package包/类
@Deployment
public static Archive<?> createTestArchive() {
    return ShrinkWrap.create(WebArchive.class)
        // TODO: understand why this is duplicated in the Archive and fails since Weld 2.2.5.Final
        /* .addAsLibraries(
            Maven.configureResolver()
                .workOffline()
                .loadPomFromFile("pom.xml")
                .resolve("io.astefanutti.metrics.cdi:metrics-cdi", "org.jboss.weld.servlet:weld-servlet")
                .withTransitivity()
                .as(JavaArchive.class)) */
        .addClass(TimedMethodBean.class)
        .addClass(TimedMethodServlet.class)
        .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
        .setWebXML(new StringAsset(Descriptors.create(WebAppDescriptor.class)
            .version("3.1")
            .createServlet()
                .servletClass(TimedMethodServlet.class.getName())
                .servletName("TimedMethod").up()
            .createServletMapping()
                .servletName("TimedMethod")
                .urlPattern("/timedMethod").up()
            .createListener()
                .listenerClass(Listener.class.getName()).up()
            .exportAsString()));
}
 
开发者ID:astefanutti,项目名称:metrics-cdi,代码行数:27,代码来源:TimedMethodBeanTestJava8.java

示例2: createDeployment

import org.jboss.weld.environment.servlet.Listener; //导入依赖的package包/类
@Deployment(testable = false)
public static Archive<WebArchive> createDeployment() {

    return ShrinkWrap.create(UndertowWebArchive.class).from(
            deployment()
                    .setClassLoader(Application.class.getClassLoader())
                    .setContextPath("/")
                    .addListeners(listener(Listener.class))
                    .addServlets(
                            Servlets.servlet("jerseyServlet", ServletContainer.class)
                                    .setLoadOnStartup(1)
                                    .addInitParam("javax.ws.rs.Application", JerseyConfig.class.getName())
                                    .addMapping("/api/*"))
                    .setDeploymentName("application.war"));
}
 
开发者ID:cassiomolin,项目名称:jersey-jwt,代码行数:16,代码来源:ArquillianTest.java

示例3: startContainer

import org.jboss.weld.environment.servlet.Listener; //导入依赖的package包/类
public static void startContainer(int port) throws ServletException {
    DeploymentInfo servletBuilder = Servlets.deployment();

    servletBuilder
            .setClassLoader(Application.class.getClassLoader())
            .setContextPath("/mss")
            .setDeploymentName("mss.war")
            .addListeners(listener(Listener.class))
            .addServlets(servlet("jerseyServlet", ServletContainer.class)
                    .setLoadOnStartup(1)
                    .addInitParam("javax.ws.rs.Application", JerseyApp.class.getName())
                    .addMapping("/api/*"));

    DeploymentManager manager = Servlets.defaultContainer().addDeployment(servletBuilder);
    manager.deploy();
    PathHandler path = Handlers.path(Handlers.redirect("/mss"))
            .addPrefixPath("/mss", manager.start());

    server =
            Undertow
                    .builder()
                    .addHttpListener(port, "localhost")
                    .setHandler(path)
                    .build();

    server.start();
}
 
开发者ID:gabfssilva,项目名称:microservices-sample-undertow-cdi-jaxrs,代码行数:28,代码来源:Application.java

示例4: main

import org.jboss.weld.environment.servlet.Listener; //导入依赖的package包/类
public static void main(final String[] args) throws Exception {

        // use system property first
        String port = System.getProperty("server.port");
        if (port == null) {
            // and fallback to use environment variable
            port = System.getenv("FABRIC8_HTTP_PORT");
        }
        if (port == null) {
            // and use port 8585 by default
            port = "8585";
        }
        Integer num = Integer.parseInt(port);

        System.out.println("Starting REST server on port: " + port);
        final Server server = new Server(num);

        // Register and map the dispatcher servlet
        final ServletHolder servletHolder = new ServletHolder(new CXFCdiServlet());
        final ServletContextHandler context = new ServletContextHandler();
        context.setContextPath("/");
        context.addEventListener(new Listener());
        context.addEventListener(new BeanManagerResourceBindingListener());
        context.addServlet(servletHolder, "/cxfcdi/*");

        server.setHandler(context);
        server.start();
        server.join();
    }
 
开发者ID:fabric8io,项目名称:jube,代码行数:30,代码来源:ApplicationStarter.java

示例5: run

import org.jboss.weld.environment.servlet.Listener; //导入依赖的package包/类
public static void run(Class<?> clazz, String applicationRoot, int port, boolean join) {
    try {
        if(isRunning()){
            throw new IllegalStateException("Server already running!");
        }

        server = new Server(port);

        ProtectionDomain domain = clazz.getProtectionDomain();
        URL location = domain.getCodeSource().getLocation();

        WebAppContext webAppContext = new WebAppContext();
        webAppContext.setContextPath(applicationRoot);
        webAppContext.setWar(location.toExternalForm());

        webAppContext.addEventListener(new ConfigureListener());
        webAppContext.addEventListener(new BeanManagerResourceBindingListener());
        webAppContext.addEventListener(new Listener());

        server.setHandler(webAppContext);

        server.start();

        if (join) {
            server.join();
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:gabfssilva,项目名称:deltaspike-jpa-jsf,代码行数:31,代码来源:ApplicationRunner.java

示例6: configure

import org.jboss.weld.environment.servlet.Listener; //导入依赖的package包/类
@Override
public void configure(WebServer webServer) {
    BeanManagerImpl beanManagerImpl = BeanManagerProxy.unwrap(CDI.current().getBeanManager());
    webServer.addServletContextAttribute(WeldServletLifecycle.BEAN_MANAGER_ATTRIBUTE_NAME, beanManagerImpl);
    webServer.addServletContextAttribute(org.jboss.weld.Container.CONTEXT_ID_KEY, beanManagerImpl.getContextId());
    webServer.addInitParameter(CONTEXT_PARAM_CONTAINER_CLASS, HammockContainer.class.getName());
    webServer.addListener(Listener.class);
}
 
开发者ID:hammock-project,项目名称:hammock,代码行数:9,代码来源:Weld3Bootstrapper.java

示例7: run

import org.jboss.weld.environment.servlet.Listener; //导入依赖的package包/类
@Override
public void run(final Environment environment) {
    environment.getApplicationContext().addEventListener(new BeanManagerResourceBindingListener());
    environment.getApplicationContext().addEventListener(new Listener());
}
 
开发者ID:PaperCutSoftware,项目名称:dust-api,代码行数:6,代码来源:WeldBundle.java

示例8: startServer

import org.jboss.weld.environment.servlet.Listener; //导入依赖的package包/类
/**
 * Start server on the given port.
 *
 * @param port
 */
public static void startServer(int port) {

    LOGGER.info(String.format("Starting server on port %d", port));

    PathHandler path = Handlers.path();

    server = Undertow.builder()
            .addHttpListener(port, "localhost")
            .setHandler(path)
            .build();

    server.start();

    LOGGER.info(String.format("Server started on port %d", port));

    DeploymentInfo servletBuilder = Servlets.deployment()
            .setClassLoader(Application.class.getClassLoader())
            .setContextPath("/")
            .addListeners(listener(Listener.class))
            .setResourceManager(new ClassPathResourceManager(Application.class.getClassLoader()))
            .addServlets(
                    Servlets.servlet("jerseyServlet", ServletContainer.class)
                            .setLoadOnStartup(1)
                            .addInitParam("javax.ws.rs.Application", JerseyConfig.class.getName())
                            .addMapping("/api/*"))
            .setDeploymentName("application.war");

    LOGGER.info("Starting application deployment");

    deploymentManager = Servlets.defaultContainer().addDeployment(servletBuilder);
    deploymentManager.deploy();

    try {
        path.addPrefixPath("/", deploymentManager.start());
    } catch (ServletException e) {
        throw new RuntimeException(e);
    }

    LOGGER.info("Application deployed");
}
 
开发者ID:cassiomolin,项目名称:jersey-jwt,代码行数:46,代码来源:Application.java

示例9: startWebServer

import org.jboss.weld.environment.servlet.Listener; //导入依赖的package包/类
private static void startWebServer(String[] args)
{
    String host = "0.0.0.0";
    int port = 8080;
    if (args.length > 0)
    {
        host = args[0];
    }
    if (args.length > 1)
    {
        port = Integer.parseInt(args[1]);
    }

    ResteasyDeployment deployment = new ResteasyDeployment();
    deployment.setProviderClasses(Arrays.asList(OrientDBJacksonProvider.class.getName()));
    deployment.setInjectorFactoryClass("org.jboss.resteasy.cdi.CdiInjectorFactory");
    deployment.setApplicationClass(MyApplication.class.getName());

    Undertow.Builder builder = Undertow
            .builder()
            .addHttpListener(port, host);

    UndertowJaxrsServer server = new UndertowJaxrsServer().start(builder);
    DeploymentInfo deploymentInfo = server
            .undertowDeployment(deployment)
            .setClassLoader(Main.class.getClassLoader())
            .addListener(Servlets.listener(OrientDBServletContextListener.class))
            .addFilter(Servlets.filter(METRICS_LISTENER, MetricsListener.class))
            .addFilterUrlMapping(METRICS_LISTENER, "/*", DispatcherType.REQUEST)
            .addListeners(Servlets.listener(Listener.class))
            .addServlets(
                    Servlets.servlet(com.codahale.metrics.servlets.MetricsServlet.class)
                            .addMapping("/metrics"))
            .addFilter(new FilterInfo(ORIENTDB_FILTER, OrientDBFilter.class))
            .addFilterUrlMapping(ORIENTDB_FILTER, "/*", DispatcherType.REQUEST)
            .addFilter(new FilterInfo(CORRELATION_ID_FILTER, CorrelationIdFilter.class))
            .addFilterUrlMapping(CORRELATION_ID_FILTER, "/*", DispatcherType.REQUEST)
            .setContextPath("/api")
            .setDeploymentName("${artifactId}");
                    
    server.deploy(deploymentInfo);

}
 
开发者ID:jesty,项目名称:orientdb-microservices,代码行数:44,代码来源:Main.java

示例10: addModulesToJetty

import org.jboss.weld.environment.servlet.Listener; //导入依赖的package包/类
/**
 * @see org.overlord.commons.dev.server.DevServer#addModulesToJetty(org.overlord.commons.dev.server.DevServerEnvironment, org.eclipse.jetty.server.handler.ContextHandlerCollection)
 */
@Override
protected void addModulesToJetty(DevServerEnvironment environment, ContextHandlerCollection handlers) throws Exception {
    super.addModulesToJetty(environment, handlers);
    /* *********
     * RTGov UI
     * ********* */
    ServletContextHandler rtgovUI = new ServletContextHandler(ServletContextHandler.SESSIONS);
    rtgovUI.setContextPath("/rtgov-ui");
    rtgovUI.setWelcomeFiles(new String[] { "index.html" });
    rtgovUI.setResourceBase(environment.getModuleDir("rtgov-ui").getCanonicalPath());
    rtgovUI.setInitParameter("errai.properties", "/WEB-INF/errai.properties");
    rtgovUI.setInitParameter("login.config", "/WEB-INF/login.config");
    rtgovUI.setInitParameter("users.properties", "/WEB-INF/users.properties");
    rtgovUI.addEventListener(new Listener());
    rtgovUI.addEventListener(new BeanManagerResourceBindingListener());
    rtgovUI.addFilter(GWTCacheControlFilter.class, "/app/*", EnumSet.of(DispatcherType.REQUEST));
    rtgovUI.addFilter(ResourceCacheControlFilter.class, "/css/*", EnumSet.of(DispatcherType.REQUEST));
    rtgovUI.addFilter(ResourceCacheControlFilter.class, "/images/*", EnumSet.of(DispatcherType.REQUEST));
    rtgovUI.addFilter(ResourceCacheControlFilter.class, "/js/*", EnumSet.of(DispatcherType.REQUEST));
    rtgovUI.addFilter(org.overlord.rtgov.ui.server.filters.LocaleFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
    // Servlets
    ServletHolder erraiServlet = new ServletHolder(DefaultBlockingServlet.class);
    erraiServlet.setInitOrder(1);
    rtgovUI.addServlet(erraiServlet, "*.erraiBus");
    ServletHolder headerDataServlet = new ServletHolder(OverlordHeaderDataJS.class);
    headerDataServlet.setInitParameter("app-id", "rtgov-ui");
    rtgovUI.addServlet(headerDataServlet, "/js/overlord-header-data.js");
    // File resources
    ServletHolder resources = new ServletHolder(new MultiDefaultServlet());
    resources.setInitParameter("resourceBase", "/");
    resources.setInitParameter("resourceBases", environment.getModuleDir("rtgov-ui").getCanonicalPath()
            + "|" + environment.getModuleDir("overlord-commons-uiheader").getCanonicalPath());
    resources.setInitParameter("dirAllowed", "true");
    resources.setInitParameter("pathInfoOnly", "false");
    String[] fileTypes = new String[] { "html", "js", "css", "png", "gif" };
    for (String fileType : fileTypes) {
        rtgovUI.addServlet(resources, "*." + fileType);
    }

    rtgovUI.setSecurityHandler(createSecurityHandler());
    handlers.addHandler(rtgovUI);
}
 
开发者ID:Governance,项目名称:rtgov-ui,代码行数:46,代码来源:RTGovUIDevServer.java

示例11: addModulesToJetty

import org.jboss.weld.environment.servlet.Listener; //导入依赖的package包/类
/**
 * Configure the web application(s).
 * @param handlers
 * @throws Exception
 */
protected void addModulesToJetty(HandlerCollection handlers) throws Exception {
	/* *************
     * Manager API
     * ************* */
    ServletContextHandler apiManServer = new ServletContextHandler(ServletContextHandler.SESSIONS);
    addSecurityHandler(apiManServer);
    apiManServer.setContextPath("/apiman");
    apiManServer.addEventListener(new Listener());
    apiManServer.addEventListener(new BeanManagerResourceBindingListener());
    apiManServer.addEventListener(new ResteasyBootstrap());
    apiManServer.addFilter(LocaleFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
    apiManServer.addFilter(ApimanCorsFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
    apiManServer.addFilter(DisableCachingFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
    addAuthFilter(apiManServer);
    apiManServer.addFilter(DefaultSecurityContextFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
    apiManServer.addFilter(RootResourceFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
    apiManServer.addFilter(ManagerApiMicroServiceTxWatchdogFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
    ServletHolder resteasyServlet = new ServletHolder(new HttpServletDispatcher());
    resteasyServlet.setInitParameter("javax.ws.rs.Application", ManagerApiMicroServiceApplication.class.getName());
    apiManServer.addServlet(resteasyServlet, "/*");

    apiManServer.setInitParameter("resteasy.injector.factory", "org.jboss.resteasy.cdi.CdiInjectorFactory");
    apiManServer.setInitParameter("resteasy.scan", "true");
    apiManServer.setInitParameter("resteasy.servlet.mapping.prefix", "");

    handlers.addHandler(apiManServer);

    /* ********** *
     * Manager UI *
     * ********** */
    ResourceHandler apimanUiServer = new ResourceHandler() {
        /**
         * @see org.eclipse.jetty.server.handler.ResourceHandler#getResource(java.lang.String)
         */
        @Override
        public Resource getResource(String path) throws MalformedURLException {
            Resource resource = null;

            if (path == null || path.equals("/") || path.equals("/index.html")) {
                path = "/index.html";
            }
            if (path.startsWith("/apimanui/api-manager") || path.equals("/apimanui") || path.equals("/apimanui/")) {
                path = "/apimanui/index.html";
            }
            if (path.equals("/apimanui/apiman/config.js")) {
                resource = getConfigResource(path);
            }
            if (path.equals("/apimanui/apiman/translations.js")) {
                resource = getTranslationsResource(path);
            }

            if (resource == null) {
                URL url = getClass().getResource(path);
                if (url != null) {
                    resource = new ApimanResource(url);
                }
            }

            return resource;
        }
    };
    apimanUiServer.setResourceBase("/apimanui/");
    apimanUiServer.setWelcomeFiles(new String[] { "index.html" });
    handlers.addHandler(apimanUiServer);
}
 
开发者ID:apiman,项目名称:apiman,代码行数:71,代码来源:ManagerApiMicroService.java

示例12: addModulesToJetty

import org.jboss.weld.environment.servlet.Listener; //导入依赖的package包/类
/**
     * Configure the web application(s).
     * @param handlers
     * @throws Exception
     */
    protected void addModulesToJetty(ContextHandlerCollection handlers) throws Exception {
        /* *************
         * Manager API
         * ************* */
        ServletContextHandler apiManServer = new ServletContextHandler(ServletContextHandler.SESSIONS);
        apiManServer.setSecurityHandler(createSecurityHandler());
        apiManServer.setContextPath("/apiman");
        apiManServer.addEventListener(new Listener());
        apiManServer.addEventListener(new BeanManagerResourceBindingListener());
        apiManServer.addEventListener(new ResteasyBootstrap());
        apiManServer.addFilter(DatabaseSeedFilter.class, "/db-seeder", EnumSet.of(DispatcherType.REQUEST));
//        apiManServer.addFilter(LocaleFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
        apiManServer.addFilter(ApimanCorsFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
        apiManServer.addFilter(DisableCachingFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
        configureAuthentication(apiManServer);
        apiManServer.addFilter(DefaultSecurityContextFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
        apiManServer.addFilter(TransactionWatchdogFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
        apiManServer.addFilter(RootResourceFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
        ServletHolder resteasyServlet = new ServletHolder(new HttpServletDispatcher());
        resteasyServlet.setInitParameter("javax.ws.rs.Application", TestManagerApiApplication.class.getName());
        apiManServer.addServlet(resteasyServlet, "/*");

        apiManServer.setInitParameter("resteasy.injector.factory", "org.jboss.resteasy.cdi.CdiInjectorFactory");
        apiManServer.setInitParameter("resteasy.scan", "true");
        apiManServer.setInitParameter("resteasy.servlet.mapping.prefix", "");

        // Add the web contexts to jetty
        handlers.addHandler(apiManServer);

        /* *************
         * Mock Gateway (to test publishing of APIs from dt to rt)
         * ************* */
        ServletContextHandler mockGatewayServer = new ServletContextHandler(ServletContextHandler.SESSIONS);
        mockGatewayServer.setSecurityHandler(createSecurityHandler());
        mockGatewayServer.setContextPath("/mock-gateway");
        ServletHolder mockGatewayServlet = new ServletHolder(new MockGatewayServlet());
        mockGatewayServer.addServlet(mockGatewayServlet, "/*");

        // Add the web contexts to jetty
        handlers.addHandler(mockGatewayServer);
    }
 
开发者ID:apiman,项目名称:apiman,代码行数:47,代码来源:ManagerApiTestServer.java


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