本文整理汇总了Java中org.springframework.web.context.request.RequestContextListener类的典型用法代码示例。如果您正苦于以下问题:Java RequestContextListener类的具体用法?Java RequestContextListener怎么用?Java RequestContextListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RequestContextListener类属于org.springframework.web.context.request包,在下文中一共展示了RequestContextListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startServer
import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
private static void startServer() throws Exception, InterruptedException {
Server server = new Server(port);
Context context = new Context(server, "/", Context.SESSIONS);
context.addServlet(DefaultServlet.class, "/*");
context.addEventListener(new ContextLoaderListener(getContext()));
context.addEventListener(new RequestContextListener());
WicketFilter filter = new WicketFilter();
filter.setFilterPath("/");
FilterHolder holder = new FilterHolder(filter);
holder.setInitParameter("applicationFactoryClassName", APP_FACTORY_NAME);
context.addFilter(holder, "/*", Handler.DEFAULT);
server.setHandler(context);
server.start();
server.join();
}
示例2: onStartup
import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
super.onStartup(servletContext);
servletContext.addListener(new RequestContextListener());
// verifying configs for features activation
Set<String> profiles = new HashSet<String>();
if (isEmailFeaturesEnabled()) {
profiles.add("email");
}
if (isCdnFeaturesEnabled()) {
profiles.add("cdn");
}
if (isSslFeaturesEnabled()) {
profiles.add("ssl");
}
servletContext.setInitParameter("spring.profiles.active", StringUtils.arrayToCommaDelimitedString(profiles.toArray()));
}
示例3: onStartup
import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
//create a new Spring webapp context and add core listeners for requests and lifecycle events
AnnotationConfigWebApplicationContext webAppContext = new AnnotationConfigWebApplicationContext();
servletContext.addListener(RequestContextListener.class);
servletContext.addListener(new ContextLoaderListener(webAppContext));
//tell Spring where to find @Configuration classes for further Spring config
webAppContext.setConfigLocation(SPRING_CONFIG_PACKAGE);
//create Spring's Dispatcher servlet and tell the servletContext it is present
DispatcherServlet dispatcherServlet = new DispatcherServlet(webAppContext);
dispatcherServlet.setThrowExceptionIfNoHandlerFound(true);
ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcherServlet", dispatcherServlet);
//perform additional dispatcher servlet config
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/");
}
示例4: testGetPage
import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
/**
* Test of getPage method, of class fr.paris.lutece.portal.web.search.SearchApp.
*
* @throws SiteMessageException
*/
public void testGetPage( ) throws SiteMessageException
{
System.out.println( "getPage" );
MockHttpServletRequest request = new MockHttpServletRequest( );
request.addParameter( "query", "lutece" );
request.addParameter( "items_per_page", "5" );
RequestContextListener listener = new RequestContextListener( );
ServletContext context = new MockServletContext( );
listener.requestInitialized( new ServletRequestEvent( context, request ) );
int nMode = 0;
Plugin plugin = null;
SearchApp instance = SpringContextService.getBean( "core.xpage.search" );
XPage result = instance.getPage( request, nMode, plugin );
listener.requestDestroyed( new ServletRequestEvent( context, request ) );
}
示例5: startServer
import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
public static void startServer(int port) throws Exception {
final DeploymentInfo deployment = Servlets.deployment().setClassLoader(WebServer.class.getClassLoader());
deployment.setContextPath("");
deployment.setDeploymentName("membrane");
deployment.addInitParameter("contextConfigLocation", "classpath:context/application-context.xml");
deployment.setResourceManager(new FileResourceManager(new File("."), 0));
deployment.addListener(Servlets.listener(ContextLoaderListener.class));
deployment.addListener(Servlets.listener(RequestContextListener.class));
deployment.addServlet(Servlets.servlet("dispatcher", DispatcherServlet.class).addMapping("/*")
.addInitParam("contextConfigLocation", "classpath:context/dispatcher-servlet.xml"));
deployment.addFilter(Servlets.filter(CharacterEncodingFilter.class).addInitParam("forceEncoding", "true")
.addInitParam("encoding", "UTF-8"));
final DeploymentManager manager = Servlets.defaultContainer().addDeployment(deployment);
manager.deploy();
final Undertow server = Undertow.builder().addHttpListener(port, "0.0.0.0").setHandler(manager.start()).build();
server.start();
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
// graceful shutdown of everything
server.stop();
try {
manager.stop();
} catch (ServletException e) {
}
manager.undeploy();
}
});
}
示例6: onStartup
import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
System.out.println("****** Application Context Initialization ******");
initSecurityFilter(servletContext);
servletContext.addListener(new RequestContextListener());
servletContext.getSessionCookieConfig().setName(SecurityConstants.SESSION_COOKIE_NAME);
super.onStartup(servletContext);
}
示例7: onStartup
import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) // Define qual é o contexto ativo no momento
throws ServletException {
super.onStartup(servletContext);
servletContext.addListener(RequestContextListener.class);
servletContext.setInitParameter(
AbstractEnvironment.DEFAULT_PROFILES_PROPERTY_NAME, "dev");
}
示例8: requestContextListener
import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
/**
* 自定义,并注册 listener 演示
* 直接用 Bean ,也可以用 ServletListenerRegistrationBean
*
* @return
*/
// 向系统注册一个 RequestContextListener Bean ,这样在其他组件中就可以使用了
// CustomUserDetailsService 用到,用于截获 HttpServletRequest
// @Autowired
// private HttpServletRequest request;
@Bean
public RequestContextListener requestContextListener() {
return new RequestContextListener();
}
示例9: onStartup
import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
super.onStartup(servletContext);
registerProxyFilter(servletContext, "springSecurityFilterChain");
registerProxyFilter(servletContext, "oauth2ClientContextFilter");
registerProxyFilter(servletContext, "customOauth2ClientContextFilter");
servletContext.addListener(RequestContextListener.class);
}
示例10: onStartup
import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
System.out.println("Version: " + VersionUtils.getCurrentVersion());
properties = loadProperties();
LogUtils.initLogging(getConfigDir(false), (TypedProperties) properties);
AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
applicationContext.scan("org.jumpmind.metl");
MutablePropertySources sources = applicationContext.getEnvironment().getPropertySources();
sources.addLast(new PropertiesPropertySource("passed in properties", properties));
servletContext.addListener(new ContextLoaderListener(applicationContext));
servletContext.addListener(this);
servletContext.addListener(new RequestContextListener());
AnnotationConfigWebApplicationContext dispatchContext = new AnnotationConfigWebApplicationContext();
dispatchContext.setParent(applicationContext);
ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(dispatchContext));
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/api/*");
applicationContextRef.set(dispatchContext);
ServletRegistration.Dynamic apidocs = servletContext.addServlet("docs", DefaultServlet.class);
apidocs.addMapping("/api.html", "/ws-api.html", "/doc/*", "/ace/*");
ServletRegistration.Dynamic vaadin = servletContext.addServlet("vaadin", AppServlet.class);
vaadin.setAsyncSupported(true);
vaadin.setInitParameter("org.atmosphere.cpr.asyncSupport", JSR356AsyncSupport.class.getName());
vaadin.setInitParameter("beanName", "appUI");
vaadin.addMapping("/*");
}
示例11: onStartup
import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
@Override
public void onStartup(ServletContext servletContext)
throws ServletException {
super.onStartup(servletContext);
Dynamic faces = servletContext.addServlet("Faces Servlet",
"javax.faces.webapp.FacesServlet");
faces.addMapping("*.html");
//ConfigureListener listener = new ConfigureListener();
//servletContext.addListener(listener);
servletContext.addListener(new RequestContextListener());
Dynamic elResolverInitializer = servletContext.addServlet(
"elResolverInit", new ELResolverInitializerServlet());
elResolverInitializer.setLoadOnStartup(2);
}
示例12: createWebApplicationContext
import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
protected void createWebApplicationContext(ServletContext servletContext, Class clazz) {
log.info("Creating Web Application Context started");
List<Class> configClasses = new ArrayList<>();
configClasses.add(clazz);
// let's determine if this is a cloud based server
Cloud cloud = getCloud();
String activeProfiles = System.getProperty(SPRING_PROFILES_ACTIVE);
if (StringUtils.isEmpty(activeProfiles)) {
if (cloud == null) {
// if no active profiles are specified, we default to these profiles
activeProfiles = String.format("%s,%s,%s,%s,%s", MONGODB_LOCAL,REDIS_LOCAL,RABBIT_LOCAL,ELASTICSEARCH_LOCAL,LOCAL);
} else {
activeProfiles = String.format("%s,%s,%s,%s,%s", MONGODB_CLOUD,REDIS_CLOUD,RABBIT_CLOUD,ELASTICSEARCH_CLOUD,CLOUD);
}
}
log.info("Active spring profiles: " + activeProfiles);
// load local or cloud based configs
if (cloud != null) {
// list available service - fail servlet initializing if we are missing one that we require below
printAvailableCloudServices(cloud.getServiceInfos());
}
AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext();
appContext.register(configClasses.toArray(new Class[configClasses.size()]));
servletContext.addListener(new ContextLoaderListener(appContext));
servletContext.addListener(new RequestContextListener());
// log.info("Creating Web Application Context completed");
}
示例13: onStartup
import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
/* Setting the configuration classes */
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.setConfigLocation("qa.qcri.aidr.data.config");
/*Configuring error handler filter for errors out isde the controllers
FilterRegistration.Dynamic errorHandlerFilter = servletContext.addFilter("errorHandlerFilter", new ErrorHandlerFilter());
errorHandlerFilter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*");
*/
FilterRegistration.Dynamic encodingFilter = servletContext.addFilter("encodingFilter", new org.springframework.web.filter.CharacterEncodingFilter());
encodingFilter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*");
encodingFilter.setInitParameter("encoding", "UTF-8");
encodingFilter.setInitParameter("forceEncoding", "true");
/* Adding context listener */
servletContext.addListener(new ContextLoaderListener(context));
/* Adding request listener */
servletContext.addListener(new RequestContextListener());
/* Configuring dispatcher servlet for spring mvc */
/*CustomDispatcherServlet servlet = new CustomDispatcherServlet(context); */
ServletRegistration.Dynamic appServlet = servletContext.addServlet("dispatcher", new DispatcherServlet(context));
appServlet.setLoadOnStartup(1);
appServlet.addMapping("/*");
}
示例14: requestContextListener
import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(RequestContextListener.class)
public RequestContextListener requestContextListener() {
return new RequestContextListener();
}
示例15: requestContextListener
import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
@Bean
public RequestContextListener requestContextListener() {
return new RequestContextListener();
}