public List/*< Interceptor >*/ getActionInterceptors()
{
ServletContext servletContext = getServletContext();
InternalConcurrentHashMap/*< String, HashMap< String, ArrayList< Interceptor > > >*/ cache =
( InternalConcurrentHashMap ) servletContext.getAttribute( CACHE_ATTR );
if ( cache == null )
{
//
// Don't have to synchronize here. If by some chance two initial requests come in at the same time,
// one of the caches will get overwritten in the ServletContext, but it will just get recreated the
// next time.
//
cache = new InternalConcurrentHashMap/*< String, HashMap< String, ArrayList< Interceptor > > >*/();
servletContext.setAttribute( CACHE_ATTR, cache );
}
String modulePath = getPageFlow().getModulePath();
String actionName = getActionName();
HashMap/*< String, ArrayList< Interceptor > >*/ cacheByPageFlow = ( HashMap ) cache.get( modulePath );
if ( cacheByPageFlow != null )
{
List/*< Interceptor >*/ interceptors = ( List ) cacheByPageFlow.get( actionName );
if ( interceptors != null ) return interceptors;
}
//
// We didn't find it in the cache -- build it.
//
if ( cacheByPageFlow == null ) cacheByPageFlow = new HashMap/*< String, ArrayList< Interceptor > >*/();
PageFlowActionInterceptorsConfig config = ConfigUtil.getConfig().getPageFlowActionInterceptors();
ArrayList/*< Interceptor >*/ interceptorsList = new ArrayList/*< Interceptor >*/();
if ( config == null )
{
cacheByPageFlow.put( actionName, interceptorsList );
cache.put( modulePath, cacheByPageFlow );
return interceptorsList;
}
//
// Global interceptors.
//
GlobalPageFlowActionInterceptorConfig globalInterceptors = config.getGlobalPageFlowActionInterceptors();
if ( globalInterceptors != null )
{
addInterceptors( globalInterceptors.getActionInterceptors(), interceptorsList, ActionInterceptor.class );
addSimpleInterceptors( globalInterceptors.getSimpleActionInterceptors(), interceptorsList );
}
//
// Per-pageflow and per-action interceptors.
//
String pageFlowURI = getPageFlow().getURI();
PerPageFlowActionInterceptorConfig[] perPageFlowInterceptorsConfig = config.getPerPageFlowActionInterceptors();
if ( perPageFlowInterceptorsConfig != null )
{
for ( int i = 0; i < perPageFlowInterceptorsConfig.length; i++ )
{
PerPageFlowActionInterceptorConfig ppfi = perPageFlowInterceptorsConfig[i];
if ( ppfi != null && pageFlowURI.equals( ppfi.getPageFlowUri() ) )
{
//
// This is a matching page flow -- add per-pageflow interceptors.
//
addInterceptors( perPageFlowInterceptorsConfig[i].getActionInterceptors(), interceptorsList,
ActionInterceptor.class );
addSimpleInterceptors( perPageFlowInterceptorsConfig[i].getSimpleActionInterceptors(),
interceptorsList );
PerActionInterceptorConfig[] perActionConfigs =
perPageFlowInterceptorsConfig[i].getPerActionInterceptors();
if ( perActionConfigs != null )
{
for ( int j = 0; j < perActionConfigs.length; j++ )
{
PerActionInterceptorConfig perActionConfig = perActionConfigs[j];
if ( perActionConfig != null && actionName.equals( perActionConfig.getActionName() ) )
{
//
// This is a matching action -- add per-action interceptors.
//
addInterceptors( perActionConfig.getActionInterceptors(), interceptorsList,
ActionInterceptor.class );
addSimpleInterceptors( perActionConfig.getSimpleActionInterceptors(),
interceptorsList );
}
}
}
}
}
}
cacheByPageFlow.put( actionName, interceptorsList );
cache.put( modulePath, cacheByPageFlow );
return interceptorsList;
}