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


Java WebListener类代码示例

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


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

示例1: registerJeeComponents

import javax.servlet.annotation.WebListener; //导入依赖的package包/类
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();
		}
	}
}
 
开发者ID:thomasdarimont,项目名称:spring-boot-jee-web-example,代码行数:27,代码来源:JeeComponentsBeanFactoryPostProcessor.java

示例2: WebListenerHandler

import javax.servlet.annotation.WebListener; //导入依赖的package包/类
WebListenerHandler() {
    super(WebListener.class);
}
 
开发者ID:PebbleTemplates,项目名称:pebble-spring-boot-starter,代码行数:4,代码来源:WebListenerHandler.java

示例3: WebListenerHandler

import javax.servlet.annotation.WebListener; //导入依赖的package包/类
WebListenerHandler() {
	super(WebListener.class);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:4,代码来源:WebListenerHandler.java

示例4: matches

import javax.servlet.annotation.WebListener; //导入依赖的package包/类
@Override
public boolean matches(final Class<?> type) {
    return FeatureUtils.is(type, EventListener.class)
            && FeatureUtils.hasAnnotation(type, WebListener.class)
            && hasMatch(type, SUPPORTED);
}
 
开发者ID:xvik,项目名称:dropwizard-guicey,代码行数:7,代码来源:WebListenerInstaller.java

示例5: write

import javax.servlet.annotation.WebListener; //导入依赖的package包/类
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);
}
 
开发者ID:vidal-community,项目名称:jax-rs-linker,代码行数:47,代码来源:ContextPathHolderWriter.java

示例6: findListeners

import javax.servlet.annotation.WebListener; //导入依赖的package包/类
public void findListeners(@Observes @WithAnnotations({WebListener.class})
                          ProcessAnnotatedType<? extends ServletContextListener> pat) {
    listeners.add(pat.getAnnotatedType().getJavaClass());
}
 
开发者ID:hammock-project,项目名称:hammock,代码行数:5,代码来源:WebServerExtension.java

示例7: createAndRegisterWebListenerBean

import javax.servlet.annotation.WebListener; //导入依赖的package包/类
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());
}
 
开发者ID:thomasdarimont,项目名称:spring-boot-jee-web-example,代码行数:11,代码来源:JeeComponentsBeanFactoryPostProcessor.java


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