Java 类javax.servlet.annotation.WebListener 实例源码

项目:spring-boot-jee-web-example    文件:JeeComponentsBeanFactoryPostProcessor.java   
private void registerJeeComponents(ConfigurableListableBeanFactory beanFactory, ClassLoader cl,
        Set<BeanDefinition> candiates) {

    for (BeanDefinition bd : candiates) {

        try {
            Class<?> beanClass = ClassUtils.forName(bd.getBeanClassName(), cl);
            WebServlet webServlet = beanClass.getDeclaredAnnotation(WebServlet.class);
            WebFilter webFilter = beanClass.getDeclaredAnnotation(WebFilter.class);
            WebListener webListener = beanClass.getDeclaredAnnotation(WebListener.class);

            DefaultListableBeanFactory targetBeanFactory = (DefaultListableBeanFactory) beanFactory;

            if (webServlet != null) {
                createAndRegisterServletBean(targetBeanFactory, bd, beanClass, webServlet);
            } else if (webFilter != null) {
                createAndRegisterServletFilterBean(targetBeanFactory, bd, beanClass, webFilter);
            } else if (webListener != null) {
                createAndRegisterWebListenerBean(targetBeanFactory, bd, beanClass, webListener);
            }

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
项目:pebble-spring-boot-starter    文件:WebListenerHandler.java   
WebListenerHandler() {
    super(WebListener.class);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:WebListenerHandler.java   
WebListenerHandler() {
    super(WebListener.class);
}
项目:spring-boot-concourse    文件:WebListenerHandler.java   
WebListenerHandler() {
    super(WebListener.class);
}
项目:contestparser    文件:WebListenerHandler.java   
WebListenerHandler() {
    super(WebListener.class);
}
项目:dropwizard-guicey    文件:WebListenerInstaller.java   
@Override
public boolean matches(final Class<?> type) {
    return FeatureUtils.is(type, EventListener.class)
            && FeatureUtils.hasAnnotation(type, WebListener.class)
            && hasMatch(type, SUPPORTED);
}
项目:jax-rs-linker    文件:ContextPathHolderWriter.java   
public void write(ClassName linkers) throws IOException {
    TypeSpec.Builder typeBuilder = TypeSpec.classBuilder(linkers.className())
        .addModifiers(PUBLIC, FINAL)
        .addSuperinterface(ServletContextListener.class)
        .addAnnotation(AnnotationSpec.builder(WebListener.class).build())
        .addAnnotation(AnnotationSpec.builder(Generated.class)
                .addMember("value", "$S", LinkerAnnotationProcessor.class.getName())
                .build()
        )
        .addField(FieldSpec.builder(String.class, "contextPath", PRIVATE, STATIC)
            .initializer("\"\"")
            .build())
        .addField(FieldSpec.builder(String.class, "applicationName", PRIVATE, STATIC)
            .initializer("$T.get()", get("fr.vidal.oss.jax_rs_linker", "ApplicationName"))
            .build())
        .addMethod(MethodSpec.methodBuilder("contextInitialized")
            .addModifiers(PUBLIC)
            .addAnnotation(Override.class)
            .returns(void.class)
            .addParameter(ServletContextEvent.class, "sce")
            .addCode(
                "$L = $T.contextPath($L.getServletContext(), $L);\n",
                "contextPath",
                ContextPaths.class,
                "sce",
                "applicationName")
            .build())
        .addMethod(MethodSpec.methodBuilder("contextDestroyed")
            .addModifiers(PUBLIC)
            .addAnnotation(Override.class)
            .returns(void.class)
            .addParameter(ServletContextEvent.class, "sce")
            .build())
        .addMethod(MethodSpec.methodBuilder("getContextPath")
            .addModifiers(PUBLIC, STATIC)
            .returns(String.class)
            .addCode(
                "return contextPath;\n")
            .build());


    JavaFile.builder(linkers.packageName(), typeBuilder.build())
        .indent("\t")
        .build()
        .writeTo(filer);
}
项目:hammock    文件:WebServerExtension.java   
public void findListeners(@Observes @WithAnnotations({WebListener.class})
                          ProcessAnnotatedType<? extends ServletContextListener> pat) {
    listeners.add(pat.getAnnotatedType().getJavaClass());
}
项目:spring-boot-jee-web-example    文件:JeeComponentsBeanFactoryPostProcessor.java   
private void createAndRegisterWebListenerBean(DefaultListableBeanFactory beanFactory, BeanDefinition bd,
        Class<?> beanClass, WebListener webListener) {

    BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(ServletListenerRegistrationBean.class);
    builder.addPropertyValue("listener", bd);

    String beanName = StringUtils.uncapitalize(beanClass.getSimpleName());

    beanFactory.registerBeanDefinition(beanName, builder.getBeanDefinition());
}