}
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 > >*/();
PageflowActionInterceptors 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.
//
PageflowActionInterceptors.Global globalInterceptors = config.getGlobal();
if ( globalInterceptors != null )
{
addInterceptors( globalInterceptors.getActionInterceptorArray(), interceptorsList, ActionInterceptor.class );
addSimpleInterceptors( globalInterceptors.getSimpleActionInterceptorArray(), interceptorsList );
}
//
// Per-pageflow and per-action interceptors.
//
String pageFlowURI = getPageFlow().getURI();
PageflowActionInterceptors.PerPageflow[] perPageFlowInterceptorsConfig = config.getPerPageflowArray();
if ( perPageFlowInterceptorsConfig != null )
{
for ( int i = 0; i < perPageFlowInterceptorsConfig.length; i++ )
{
PageflowActionInterceptors.PerPageflow ppfi = perPageFlowInterceptorsConfig[i];
if ( ppfi != null && pageFlowURI.equals( ppfi.getPageflowUri() ) )
{
//
// This is a matching page flow -- add per-pageflow interceptors.
//
addInterceptors( perPageFlowInterceptorsConfig[i].getActionInterceptorArray(), interceptorsList,
ActionInterceptor.class );
addSimpleInterceptors( perPageFlowInterceptorsConfig[i].getSimpleActionInterceptorArray(),
interceptorsList );
PageflowActionInterceptors.PerPageflow.PerAction[] perActionConfigs =
perPageFlowInterceptorsConfig[i].getPerActionArray();
if ( perActionConfigs != null )
{
for ( int j = 0; j < perActionConfigs.length; j++ )
{
PageflowActionInterceptors.PerPageflow.PerAction perActionConfig = perActionConfigs[j];
if ( perActionConfig != null && actionName.equals( perActionConfig.getActionName() ) )
{
//
// This is a matching action -- add per-action interceptors.
//
addInterceptors( perActionConfig.getActionInterceptorArray(), interceptorsList,
ActionInterceptor.class );
addSimpleInterceptors( perActionConfig.getSimpleActionInterceptorArray(),
interceptorsList );
}
}
}
}
}
}
cacheByPageFlow.put( actionName, interceptorsList );
cache.put( modulePath, cacheByPageFlow );
return interceptorsList;
}