@ -1,5 +1,5 @@
/ *
/ *
* Copyright 2002 - 2012 the original author or authors .
* Copyright 2002 - 2014 the original author or authors .
*
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* you may not use this file except in compliance with the License .
@ -41,12 +41,15 @@ import org.springframework.context.event.SourceFilteringListener;
import org.springframework.context.i18n.LocaleContext ;
import org.springframework.context.i18n.LocaleContext ;
import org.springframework.context.i18n.LocaleContextHolder ;
import org.springframework.context.i18n.LocaleContextHolder ;
import org.springframework.context.i18n.SimpleLocaleContext ;
import org.springframework.context.i18n.SimpleLocaleContext ;
import org.springframework.core.env.ConfigurableEnvironment ;
import org.springframework.web.context.request.RequestAttributes ;
import org.springframework.web.context.request.RequestAttributes ;
import org.springframework.web.context.request.RequestContextHolder ;
import org.springframework.web.context.request.RequestContextHolder ;
import org.springframework.web.context.request.ServletRequestAttributes ;
import org.springframework.web.portlet.context.ConfigurablePortletApplicationContext ;
import org.springframework.web.portlet.context.ConfigurablePortletApplicationContext ;
import org.springframework.web.portlet.context.PortletApplicationContextUtils ;
import org.springframework.web.portlet.context.PortletApplicationContextUtils ;
import org.springframework.web.portlet.context.PortletRequestAttributes ;
import org.springframework.web.portlet.context.PortletRequestAttributes ;
import org.springframework.web.portlet.context.PortletRequestHandledEvent ;
import org.springframework.web.portlet.context.PortletRequestHandledEvent ;
import org.springframework.web.portlet.context.StandardPortletEnvironment ;
import org.springframework.web.portlet.context.XmlPortletApplicationContext ;
import org.springframework.web.portlet.context.XmlPortletApplicationContext ;
/ * *
/ * *
@ -353,6 +356,14 @@ public abstract class FrameworkPortlet extends GenericPortletBean
pac . setConfigLocation ( getContextConfigLocation ( ) ) ;
pac . setConfigLocation ( getContextConfigLocation ( ) ) ;
pac . addApplicationListener ( new SourceFilteringListener ( pac , this ) ) ;
pac . addApplicationListener ( new SourceFilteringListener ( pac , this ) ) ;
// The wac environment's #initPropertySources will be called in any case when the context
// is refreshed; do it eagerly here to ensure portlet property sources are in place for
// use in any post-processing or initialization that occurs below prior to #refresh
ConfigurableEnvironment env = pac . getEnvironment ( ) ;
if ( env instanceof StandardPortletEnvironment ) {
( ( StandardPortletEnvironment ) env ) . initPropertySources ( pac . getServletContext ( ) , getPortletContext ( ) , getPortletConfig ( ) ) ;
}
postProcessPortletApplicationContext ( pac ) ;
postProcessPortletApplicationContext ( pac ) ;
pac . refresh ( ) ;
pac . refresh ( ) ;
@ -506,7 +517,8 @@ public abstract class FrameworkPortlet extends GenericPortletBean
// Expose current RequestAttributes to current thread.
// Expose current RequestAttributes to current thread.
RequestAttributes previousRequestAttributes = RequestContextHolder . getRequestAttributes ( ) ;
RequestAttributes previousRequestAttributes = RequestContextHolder . getRequestAttributes ( ) ;
PortletRequestAttributes requestAttributes = null ;
PortletRequestAttributes requestAttributes = null ;
if ( previousRequestAttributes = = null | | previousRequestAttributes . getClass ( ) . equals ( PortletRequestAttributes . class ) ) {
if ( previousRequestAttributes = = null | | previousRequestAttributes . getClass ( ) . equals ( PortletRequestAttributes . class ) | |
previousRequestAttributes . getClass ( ) . equals ( ServletRequestAttributes . class ) ) {
requestAttributes = new PortletRequestAttributes ( request ) ;
requestAttributes = new PortletRequestAttributes ( request ) ;
RequestContextHolder . setRequestAttributes ( requestAttributes , this . threadContextInheritable ) ;
RequestContextHolder . setRequestAttributes ( requestAttributes , this . threadContextInheritable ) ;
}
}