You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by mr...@apache.org on 2005/09/21 21:42:44 UTC
svn commit: r290802 [5/10] - in /struts/sandbox/trunk/ti: ./
jars/core/src/java/org/apache/ti/compiler/internal/
jars/core/src/java/org/apache/ti/compiler/internal/genmodel/
jars/core/src/java/org/apache/ti/compiler/internal/grammar/
jars/core/src/java...
Modified: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/PageFlowRequestProcessor.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/PageFlowRequestProcessor.java?rev=290802&r1=290801&r2=290802&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/PageFlowRequestProcessor.java (original)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/PageFlowRequestProcessor.java Wed Sep 21 12:42:20 2005
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,10 +23,10 @@
import java.io.IOException;
import java.io.Serializable;
+
import java.util.HashMap;
import java.util.Map;
-
/**
* The Page Flow extension of the Struts RequestProcessor, which contains callbacks that are invoked
* during processing of a request to the Struts action servlet. This class is registered as the
@@ -34,27 +34,24 @@
*/
public class PageFlowRequestProcessor
implements Serializable, InternalConstants, PageFlowConstants {
-
private static int requestNumber = 0;
-
private static final Logger _log = Logger.getInstance(PageFlowRequestProcessor.class);
-
private static final String ACTION_OVERRIDE_PARAM_PREFIX = "actionOverride:";
private static final int ACTION_OVERRIDE_PARAM_PREFIX_LEN = ACTION_OVERRIDE_PARAM_PREFIX.length();
private static final String SCHEME_UNSECURE = "http";
private static final String SCHEME_SECURE = "https";
private static final String REDIRECT_REQUEST_ATTRS_PREFIX = InternalConstants.ATTR_PREFIX + "requestAttrs:";
private static final String REDIRECT_REQUEST_ATTRS_PARAM = "forceRedirect";
+ private Map /*< String, Class >*/ _formBeanClasses = new HashMap /*< String, Class >*/();
-
- private Map/*< String, Class >*/ _formBeanClasses = new HashMap/*< String, Class >*/();
// private Map/*< String, List< PageFlowAction > >*/ _overloadedActions = new HashMap/*< String, List< PageFlowAction > >*/();
private ContainerAdapter _containerAdapter;
private Handlers _handlers;
private FlowControllerFactory _flowControllerFactory;
+
//private InternalConcurrentHashMap/*< String, Class >*/ _pageServletClasses = new InternalConcurrentHashMap/*< String, Class >*/();
//private PageFlowPageFilter _pageServletFilter;
-
+
/*
protected void processPopulate( HttpServletRequest request, HttpServletResponse response, Object form,
PageFlowAction mapping )
@@ -90,7 +87,7 @@
PageFlowActionContext requestWrapper = getContext();
boolean alreadyCalledInRequest = requestWrapper.isProcessPopulateAlreadyCalled();
if ( ! alreadyCalledInRequest ) requestWrapper.setProcessPopulateAlreadyCalled( true );
-
+
//
// If this is a forwarded request and the form-bean is null, don't call to ProcessPopulate.
// We don't want to expose errors due to parameters from the original request, which won't
@@ -103,7 +100,7 @@
// no databinding errors when the override action does not use a form bean.
//
if ( form == null && requestWrapper.isForwardedByButton() ) form = NULL_ACTION_FORM;
-
+
ProcessPopulate.populate( request, response, form, alreadyCalledInRequest );
}
}
@@ -112,12 +109,13 @@
/**
* The requested action can be overridden by a request parameter. In this case, we parse the action from
* the request parameter and forward to a URI constructed from it.
- *
+ *
* @return <code>true</code> if the action was overridden by a request parameter, in which case the request
* was forwarded.
* @throws IOException
- * @throws PageFlowException
- */
+ * @throws PageFlowException
+ */
+
/* TODO: re-add this -- it should be in Chain
protected boolean processActionOverride()
throws IOException, PageFlowException
@@ -136,8 +134,8 @@
//
// TODO: re-add multipart support
// HttpServletRequest multipartAwareRequest = processMultipart( request );
-
-
+
+
for ( Iterator i = getContext().getWebContext().getRequestScope().keySet().iterator(); i.hasNext(); )
{
String paramName = ( String ) i.next();
@@ -160,16 +158,16 @@
}
}
}
-
+
return false;
}
-
+
private void processSecurity()
{
- PageFlowActionContext context = PageFlowActionContext.getContext();
+ PageFlowActionContext context = PageFlowActionContext.getContext();
Map requestScope = context.getWebContext().getRequestScope();
String uri = context.getRequestPath();
-
+
//
// Allow the container to do a security check on forwarded requests, if that feature is enabled.
//
@@ -188,11 +186,11 @@
_log.debug( "checkSecurity() caused a redirect. Ending processing for this request "
+ '(' + uri + ')' );
}
-
+
return;
}
}
-
+
//
// If we've come in on a forced redirect due to security constraints, look for request attrs
// that we put into the session.
@@ -201,19 +199,19 @@
if ( hash != null )
{
Map sessionScope = getContext().getSession();
-
+
if ( sessionScope != null )
{
String carryoverAttrName = makeRedirectedRequestAttrsKey( uri, hash );
Map attrs = ( Map ) sessionScope.get( carryoverAttrName );
sessionScope.remove( carryoverAttrName );
-
+
if ( attrs != null )
{
for ( Iterator i = attrs.entrySet().iterator(); i.hasNext(); )
{
Map.Entry entry = ( Map.Entry ) i.next();
-
+
String attrName = ( String ) entry.getKey();
if ( requestScope.get( attrName ) == null )
{
@@ -225,17 +223,18 @@
}
}
*/
-
+
/**
* Process any direct request for a page flow by forwarding to its "begin" action.
- *
+ *
* @param request the current HttpServletRequest
* @param response the current HttpServletResponse
* @param uri the decoded request URI
* @return <code>true</code> if the request was for a page flow, in which case it was forwarded.
* @throws IOException
* @throws PageFlowException
- */
+ */
+
/* TODO: re-add
protected boolean processPageFlowRequest( HttpServletRequest request, HttpServletResponse response, String uri )
throws IOException, PageFlowException
@@ -309,32 +308,33 @@
doForward( uri, request, response );
return true;
- }
-
+ }
+
return false;
}
-
+
protected PageFlowAction getBeginMapping()
{
return ( PageFlowAction ) moduleConfig.findActionConfig( BEGIN_ACTION_PATH );
}
-
+
*/
-
+
/**
* A MultipartRequestWrapper that we cache in the outer request once we've handled the multipart request once.
* It extends the base Struts MultipartRequestWrapper by being aware of ScopedRequests; for ScopedRequests, it
* filters the parameter names accordingly.
- */
+ */
+
/* TODO: re-add
private static class RehydratedMultipartRequestWrapper extends MultipartRequestWrapper
{
public RehydratedMultipartRequestWrapper( HttpServletRequest req )
{
super( req );
-
+
MultipartRequestHandler handler = MultipartRequestUtils.getCachedMultipartHandler( req );
-
+
if ( handler != null )
{
ScopedRequest scopedRequest = ScopedUtils.unwrapRequest( req );
@@ -344,10 +344,11 @@
}
}
*/
-
+
/**
* If this is a multipart request, wrap it with a special wrapper. Otherwise, return the request unchanged.
*/
+
/* TODO: re-add multipart support
protected HttpServletRequest processMultipart( HttpServletRequest request )
{
@@ -357,14 +358,14 @@
if ( contentType != null && contentType.startsWith( "multipart/form-data" ) )
{
PageFlowActionContext pageFlowRequestWrapper = getContext();
-
+
//
// We may have already gotten a multipart wrapper during process(). If so, use that.
//
MultipartRequestWrapper cachedWrapper = pageFlowRequestWrapper.getMultipartRequestWrapper();
-
+
if ( cachedWrapper != null && cachedWrapper.getRequest() == request ) return cachedWrapper;
-
+
try
{
//
@@ -378,7 +379,7 @@
_log.error( "Could not parse multipart request.", e.getRootCause() );
return request;
}
-
+
MultipartRequestWrapper ret = new RehydratedMultipartRequestWrapper( request );
pageFlowRequestWrapper.setMultipartRequestWrapper( ret );
return ret;
@@ -390,7 +391,6 @@
}
*/
-
/*
private boolean isCorrectFormType( Class formBeanClass, PageFlowAction mapping )
{
@@ -398,7 +398,7 @@
Class cachedFormBeanClass = ( Class ) _formBeanClasses.get( mapping.getName() );
return isCorrectFormType( formBeanClass, cachedFormBeanClass, mapping );
}
-
+
private boolean isCorrectFormType( Class formBeanClass, Class actionMappingFormBeanClass, PageFlowAction mapping )
{
if ( actionMappingFormBeanClass != null )
@@ -412,20 +412,19 @@
//
FormBeanConfig mappingFormBean = moduleConfig.findFormBeanConfig( mapping.getName() );
String formClassName = formBeanClass.getName();
-
+
if ( mappingFormBean != null && mappingFormBean.getType().equals( formClassName ) ) return true;
-
+
if ( mapping instanceof PageFlowAction )
{
String desiredType = ( ( PageFlowAction ) mapping ).getFormBeanClass();
if ( formClassName.equals( desiredType ) ) return true;
}
}
-
+
return false;
}
*/
-
/* TODO: re-add tokens, or something like it.
private PageFlowAction checkTransaction( HttpServletRequest request, HttpServletResponse response,
PageFlowAction mapping, String actionPath )
@@ -438,7 +437,7 @@
FlowController currentFC = getContext().getCurrentFlowController();
String actionName = InternalUtils.getActionName( mapping );
DoubleSubmitException ex = new DoubleSubmitException( actionName, currentFC );
-
+
if ( currentFC != null )
{
try
@@ -451,72 +450,69 @@
_log.error( "Exception occurred while handling " + ex.getClass().getName(), servletException );
}
}
-
+
ex.sendResponseErrorCode( response );
return null;
}
}
-
+
return mapping;
}
*/
- public void init()
- throws PageFlowException {
+ public void init() throws PageFlowException {
//
// Cache a list of overloaded actions for each overloaded action path (actions are overloaded by form bean type).
//
// TODO: re-add overloaded action support
-// cacheOverloadedPageFlowActions();
-
+ // cacheOverloadedPageFlowActions();
//
// Cache the form bean Classes by form bean name.
//
// TODO: re-add class caching?
-// cacheFormClasses();
+ // cacheFormClasses();
}
-
+
/* TODO: re-add overloaded action support
private void cacheOverloadedPageFlowActions()
{
ActionConfig[] actionConfigs = moduleConfig.findActionConfigs();
-
+
for ( int i = 0; i < actionConfigs.length; i++ )
{
ActionConfig actionConfig = actionConfigs[i];
-
+
if ( actionConfig instanceof PageFlowAction )
{
PageFlowAction mapping = ( PageFlowAction ) actionConfig;
String unqualifiedActionPath = ( ( PageFlowAction ) actionConfig ).getUnqualifiedActionPath();
-
+
if ( unqualifiedActionPath != null )
{
List overloaded = ( List ) _overloadedActions.get( unqualifiedActionPath );
-
+
if ( overloaded == null )
{
overloaded = new ArrayList();
_overloadedActions.put( unqualifiedActionPath, overloaded );
}
-
+
overloaded.add( mapping );
}
}
}
}
*/
-
/*
private void cacheFormClasses()
{
FormBeanConfig[] formBeans = moduleConfig.findFormBeanConfigs();
ReloadableClassHandler rch = _handlers.getReloadableClassHandler();
-
+
for ( int i = 0; i < formBeans.length; i++ )
{
FormBeanConfig formBeanConfig = formBeans[i];
String formType = InternalUtils.getFormBeanType( formBeanConfig );
-
+
try
{
Class formBeanClass = rch.loadClass( formType );
@@ -535,7 +531,7 @@
* Read component instance mapping configuration file.
* This is where we read files properties.
*/
-
+
/* TODO: re-add Tiles support
protected void initDefinitionsMapping() throws PageFlowException
{
@@ -556,32 +552,31 @@
}
}
*/
-
/* TODO: re-add this. It's code to customize XWork -- to handle shared flow and form-bean-specific actions.
public PageFlowAction processMapping( HttpServletRequest request, HttpServletResponse response, String path )
throws IOException
{
FlowController fc = getContext().getFlowController();
Object forwardedForm = InternalUtils.getForwardedFormBean( false );
-
+
//
// First, see if this is a request for a shared flow action. The shared flow's name (as declared by the
// current page flow) will precede the dot.
//
if ( fc != null && ! processSharedFlowMapping( request, response, path, fc ) ) return null;
-
+
//
// Look for a form-specific action path. This is used when there are two actions with the same
// name, but different forms (in nesting).
//
Class forwardedFormClass = null;
-
+
if ( forwardedForm != null )
{
forwardedFormClass = forwardedForm.getClass();
List possibleMatches = ( List ) _overloadedActions.get( path );
PageFlowAction bestMatch = null;
-
+
//
// Troll through the overloaded actions for the given path. Look for the one whose form bean class is
// exactly the class of the forwarded form; failing that, look for one that's assignable from the class
@@ -591,7 +586,7 @@
{
PageFlowAction possibleMatch = ( PageFlowAction ) possibleMatches.get( i );
Class cachedFormBeanClass = ( Class ) _formBeanClasses.get( possibleMatch.getName() );
-
+
if ( forwardedFormClass.equals( cachedFormBeanClass ) )
{
bestMatch = possibleMatch;
@@ -602,30 +597,30 @@
bestMatch = possibleMatch;
}
}
-
+
if ( bestMatch != null )
{
request.setAttribute( Globals.MAPPING_KEY, bestMatch );
-
+
if ( _log.isDebugEnabled() )
{
_log.debug( "Found form-specific action mapping " + bestMatch.getPath() + " for " + path
+ ", form " + forwardedFormClass.getName() );
}
-
+
return checkTransaction(bestMatch);
}
}
-
+
//
// Look for a directly-defined mapping for this path.
//
PageFlowAction mapping = ( PageFlowAction ) moduleConfig.findActionConfig( path );
-
+
if ( mapping != null )
{
boolean wrongForm = false;
-
+
//
// We're going to bail out if there is a forwarded form and this mapping requires a different form type.
//
@@ -634,7 +629,7 @@
boolean mappingHasNoFormBean = mapping.getName() == null;
wrongForm = mappingHasNoFormBean || ! isCorrectFormType( forwardedFormClass, mapping );
}
-
+
if ( ! wrongForm )
{
request.setAttribute( Globals.MAPPING_KEY, mapping );
@@ -647,7 +642,7 @@
// in a shared flow.
//
String errorServletPath = getContext().getOriginalServletPath();
-
+
//
// If the error action path has a slash in it, then it's not local to the current page flow. Replace
// it with the original servlet path.
@@ -655,7 +650,7 @@
if ( errorServletPath != null && path.indexOf( '/' ) > 0 ) path = errorServletPath;
return processUnresolvedAction( path, request, response, forwardedForm );
}
-
+
protected boolean processSharedFlowMapping( HttpServletRequest request, HttpServletResponse response,
String actionPath, FlowController currentFlowController )
throws IOException
@@ -663,7 +658,7 @@
if ( currentFlowController.isPageFlow() )
{
int dot = actionPath.indexOf( '.' );
-
+
if ( dot != -1 )
{
Map/*< String, SharedFlowController >* sharedFlows = PageFlowUtils.getSharedFlows( request );
@@ -672,7 +667,7 @@
assert actionPath.length() > 0 && actionPath.charAt( 0 ) == '/' : actionPath;
String sharedFlowName = actionPath.substring( 1, dot );
SharedFlowController sf = ( SharedFlowController ) sharedFlows.get( sharedFlowName );
-
+
if ( sf != null )
{
if ( _log.isDebugEnabled() )
@@ -680,13 +675,13 @@
_log.debug( "Forwarding to shared flow " + sf.getDisplayName() + " to handle action \""
+ actionPath + "\"." );
}
-
+
//
// Save the original request URI, so if the action fails on the shared flow, too, then we can
// give an error message that includes *this* URI, not the shared flow URI.
//
getContext().setOriginalServletPath( InternalUtils.getRequestPath( request ) );
-
+
//
// Construct a URI that is [shared flow namespace] + [base action path] + [action-extension (.do)]
//
@@ -696,7 +691,7 @@
uri.append( '/' );
uri.append( actionPath.substring( dot + 1 ) );
uri.append( ACTION_EXTENSION );
-
+
try
{
doForward( uri.toString(), request, response );
@@ -709,10 +704,10 @@
}
}
}
-
+
return true;
}
-
+
protected PageFlowAction processUnresolvedAction( String actionPath, HttpServletRequest request,
HttpServletResponse response, Object returningForm )
throws IOException
@@ -722,14 +717,14 @@
InternalStringBuilder msg = new InternalStringBuilder( "action \"" ).append( actionPath );
_log.info( msg.append( "\" was also unhandled by Global.app." ).toString() );
}
-
+
//
// If there's a PageFlowController for this request, try and let it handle an
// action-not-found exception. Otherwise, let Struts print out its "invalid path"
// message.
//
FlowController fc = PageFlowUtils.getCurrentPageFlow( request );
-
+
try
{
if ( fc != null )
@@ -743,25 +738,24 @@
catch ( PageFlowException e )
{
// ignore this -- just let Struts do its thing.
-
+
if ( _log.isDebugEnabled() )
{
_log.debug( e );
}
}
-
+
if ( _log.isDebugEnabled() )
{
- _log.debug( "Couldn't handle an ActionNotFoundException -- delegating to Struts" );
+ _log.debug( "Couldn't handle an ActionNotFoundException -- delegating to Struts" );
}
-
+
return super.processMapping( request, response, actionPath );
}
*/
-
/*
protected boolean processRoles( HttpServletRequest request, HttpServletResponse response, PageFlowAction mapping )
- throws IOException, PageFlowException
+ throws IOException, PageFlowException
{
//
// If there are no required roles for this action, just return.
@@ -775,7 +769,7 @@
// Check the current user against the list of required roles
FlowController fc = getContext().getCurrentFlowController();
FlowControllerHandlerContext context = new FlowControllerHandlerContext( request, response, fc );
-
+
for ( int i = 0; i < roles.length; i++ )
{
if ( _handlers.getLoginHandler().isUserInRole( context, roles[i] ) )
@@ -784,7 +778,7 @@
{
_log.debug( " User " + request.getRemoteUser() + " has role '" + roles[i] + "', granting access" );
}
-
+
return true;
}
}
@@ -794,7 +788,7 @@
{
_log.debug( " User '" + request.getRemoteUser() + "' does not have any required role, denying access" );
}
-
+
//
// Here, Struts sends an HTTP error. We try to let the current page flow handle a relevant exception.
//
@@ -802,7 +796,7 @@
String actionName = InternalUtils.getActionName( mapping );
FlowController currentFC = getContext().getCurrentFlowController();
FlowControllerException ex;
-
+
if ( loginHandler.getUserPrincipal( context ) == null )
{
ex = currentFC.createNotLoggedInException( actionName, request );
@@ -811,7 +805,7 @@
{
ex = new UnfulfilledRolesException( mapping.getRoleNames(), mapping.getRoles(), actionName, currentFC );
}
-
+
if ( currentFC != null )
{
forward fwd = currentFC.handleException( ex, mapping, null, request, response );
@@ -821,10 +815,10 @@
{
( ( ResponseErrorCodeSender ) ex ).sendResponseErrorCode( response );
}
-
+
return false;
}
-
+
private static String addScopeParams( String url, HttpServletRequest request )
{
//
@@ -840,33 +834,33 @@
return url;
}
}
-
- */
+ */
/**
* Set the no-cache headers. This overrides the base Struts behavior to prevent caching even for the pages.
*/
+
/*
protected void processNoCache( HttpServletRequest request, HttpServletResponse response )
{
//
// Set the no-cache headers if:
// 1) the module is configured for it, or
- // 2) netui-config.xml has an "always" value for <pageflow-config><prevent-cache>, or
- // 3) netui-config.xml has an "inDevMode" value for <pageflow-config><prevent-cache>, and we're not in
+ // 2) struts-ti-config.xml has an "always" value for <pageflow-config><prevent-cache>, or
+ // 3) struts-ti-config.xml has an "inDevMode" value for <pageflow-config><prevent-cache>, and we're not in
// production mode.
//
boolean noCache = moduleConfig.getControllerConfig().getNocache();
-
+
if ( ! noCache )
{
PageflowConfig pfConfig = ConfigUtil.getConfig().getPageflowConfig();
-
+
if ( pfConfig != null )
{
PageflowConfig.PreventCache.Enum preventCache = pfConfig.getPreventCache();
-
+
if ( preventCache != null )
{
switch ( preventCache.intValue() )
@@ -881,7 +875,7 @@
}
}
}
-
+
if ( noCache )
{
//
@@ -894,5 +888,4 @@
}
}
*/
-
}
Modified: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/PageFlowUtils.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/PageFlowUtils.java?rev=290802&r1=290801&r2=290802&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/PageFlowUtils.java (original)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/PageFlowUtils.java Wed Sep 21 12:42:20 2005
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,6 +18,7 @@
package org.apache.ti.pageflow;
import org.apache.commons.chain.web.WebContext;
+
import org.apache.ti.core.ActionMessage;
import org.apache.ti.core.urls.FreezableMutableURI;
import org.apache.ti.core.urls.MutableURI;
@@ -32,41 +33,36 @@
import org.apache.ti.pageflow.internal.InternalUtils;
import org.apache.ti.pageflow.internal.URIContextFactory;
import org.apache.ti.pageflow.xwork.PageFlowActionContext;
-import org.apache.ti.schema.config.UrlConfig;
import org.apache.ti.script.common.ImplicitObjectUtil;
import org.apache.ti.util.config.ConfigUtil;
+import org.apache.ti.util.config.bean.UrlConfig;
import org.apache.ti.util.internal.FileUtils;
import org.apache.ti.util.internal.InternalStringBuilder;
import org.apache.ti.util.internal.concurrent.InternalConcurrentHashMap;
import org.apache.ti.util.logging.Logger;
import java.net.URISyntaxException;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-
/**
* Utility methods related to Page Flow.
*/
public class PageFlowUtils
implements PageFlowConstants, InternalConstants {
-
private static final Logger _log = Logger.getInstance(PageFlowUtils.class);
-
private static final String ACTION_PATH_ATTR = ATTR_PREFIX + "_actionPath";
private static final int PAGEFLOW_EXTENSION_LEN = PAGEFLOW_EXTENSION.length();
- private static final String DEFAULT_AUTORESOLVE_EXTENSIONS[] = new String[]{ACTION_EXTENSION, PAGEFLOW_EXTENSION};
-
+ private static final String[] DEFAULT_AUTORESOLVE_EXTENSIONS = new String[] { ACTION_EXTENSION, PAGEFLOW_EXTENSION };
/**
* Map of Struts module prefix to Map of form-type-name to form-name.
*/
- private static Map/*< String, Map< String, List< String > > >*/ _formNameMaps =
- new InternalConcurrentHashMap/*< String, Map< String, List< String > > >*/();
-
+ private static Map /*< String, Map< String, List< String > > >*/ _formNameMaps = new InternalConcurrentHashMap /*< String, Map< String, List< String > > >*/();
/**
* Get a URI for the "begin" action in the PageFlowController associated with the given
@@ -85,6 +81,7 @@
}
retVal.append('/').append(BEGIN_ACTION_NAME).append(ACTION_EXTENSION);
+
return retVal.toString();
}
@@ -97,8 +94,9 @@
public static PageFlowController getNestingPageFlow() {
PageFlowStack jpfStack = PageFlowStack.get(false);
- if (jpfStack != null && !jpfStack.isEmpty()) {
+ if ((jpfStack != null) && !jpfStack.isEmpty()) {
PageFlowController top = jpfStack.peek().getPageFlow();
+
return top;
}
@@ -113,7 +111,8 @@
*/
public static final PageFlowController getCurrentPageFlow() {
ActionResolver cur = getCurrentActionResolver();
- return cur instanceof PageFlowController ? (PageFlowController) cur : null;
+
+ return (cur instanceof PageFlowController) ? (PageFlowController) cur : null;
}
/**
@@ -123,7 +122,7 @@
*/
public static ActionResolver getCurrentActionResolver() {
StorageHandler sh = Handlers.get().getStorageHandler();
-
+
//
// First see if the current page flow is a long-lived, which is stored in its own attribute.
//
@@ -134,6 +133,7 @@
return getLongLivedPageFlow(currentLongLivedNamespace);
} else {
String currentJpfAttrName = InternalUtils.getScopedAttrName(CURRENT_JPF_ATTR);
+
return (ActionResolver) sh.getAttribute(currentJpfAttrName);
}
}
@@ -146,9 +146,10 @@
*
* @return a Map of shared flow name (string) to shared flow instance ({@link SharedFlowController}).
*/
- public static Map/*< String, SharedFlowController >*/ getSharedFlows() {
- Map/*< String, SharedFlowController >*/ sharedFlows = ImplicitObjectUtil.getSharedFlow();
- return sharedFlows != null ? sharedFlows : Collections.EMPTY_MAP;
+ public static Map /*< String, SharedFlowController >*/ getSharedFlows() {
+ Map /*< String, SharedFlowController >*/ sharedFlows = ImplicitObjectUtil.getSharedFlow();
+
+ return (sharedFlows != null) ? sharedFlows : Collections.EMPTY_MAP;
}
/**
@@ -159,6 +160,7 @@
*/
public static SharedFlowController getSharedFlow(String sharedFlowClassName) {
StorageHandler sh = Handlers.get().getStorageHandler();
+
return (SharedFlowController) sh.getAttribute(SHARED_FLOW_ATTR_PREFIX + sharedFlowClassName);
}
@@ -205,7 +207,9 @@
StorageHandler sh = Handlers.get().getStorageHandler();
String attrName = InternalUtils.getLongLivedFlowAttr(namespace);
attrName = InternalUtils.getScopedAttrName(attrName);
+
PageFlowController retVal = (PageFlowController) sh.getAttribute(attrName);
+
return retVal;
}
@@ -260,29 +264,34 @@
PageFlowActionContext actionContext = PageFlowActionContext.get();
ModuleConfig moduleConfig = actionContext.getModuleConfig();
Class formClass = formBean.getClass();
-
+
//
// Get the names of *all* form beans of the desired type, and blast out this instance under all those names.
//
Map formBeanAttrNames = moduleConfig.getFormBeanAttributeNames();
List formNames = (List) formBeanAttrNames.get(formClass.getName());
List additionalFormNames = null;
-
+
//
// formNames is a statically-scoped list. Below, we create a dynamic list of form names that correspond
// to *implemented interfaces* of the given form bean class.
//
Class[] interfaces = formClass.getInterfaces();
+
for (int i = 0; i < interfaces.length; i++) {
Class formInterface = interfaces[i];
List toAdd = (List) formBeanAttrNames.get(formInterface.getName());
+
if (toAdd != null) {
- if (additionalFormNames == null) additionalFormNames = new ArrayList();
+ if (additionalFormNames == null) {
+ additionalFormNames = new ArrayList();
+ }
+
additionalFormNames.addAll(toAdd);
}
}
- if (formNames == null && additionalFormNames == null) {
+ if ((formNames == null) && (additionalFormNames == null)) {
String formName = generateFormBeanName(formClass);
InternalUtils.setFormInScope(formName, formBean, overwrite);
} else {
@@ -336,7 +345,8 @@
List names = (List) moduleConfig.getFormBeanAttributeNames().get(formBeanClass.getName());
if (names != null) {
- assert names.size() > 0; // getFormNamesFromModuleConfig returns null or a nonempty list
+ assert names.size() > 0; // getFormNamesFromModuleConfig returns null or a nonempty list
+
return (String) names.get(0);
}
@@ -357,7 +367,7 @@
private static String generateFormBeanName(Class formBeanClass) {
ModuleConfig moduleConfig = PageFlowActionContext.get().getModuleConfig();
String formBeanClassName = formBeanClass.getName();
-
+
//
// A form-bean wasn't found for this type, so we'll create a name. First try and create
// name that is a camelcased version of the classname without all of its package/outer-class
@@ -391,9 +401,12 @@
assert uri != null;
assert uri.length() > 0;
- if (uri.charAt(0) == '/') uri = uri.substring(1);
+ if (uri.charAt(0) == '/') {
+ uri = uri.substring(1);
+ }
assert FileUtils.osSensitiveEndsWith(uri, PAGEFLOW_EXTENSION) : uri;
+
if (FileUtils.osSensitiveEndsWith(uri, PAGEFLOW_EXTENSION)) {
uri = uri.substring(0, uri.length() - PAGEFLOW_EXTENSION_LEN);
}
@@ -488,7 +501,8 @@
*/
public static Object getActionOutput(String name) {
Map map = InternalUtils.getActionOutputMap(false);
- return map != null ? map.get(name) : null;
+
+ return (map != null) ? map.get(name) : null;
}
/**
@@ -520,7 +534,7 @@
* @param messageArg an argument to the message
*/
public static void addActionError(String propertyName, String messageKey, Object messageArg) {
- Object[] messageArgs = new Object[]{messageArg};
+ Object[] messageArgs = new Object[] { messageArg };
InternalUtils.addActionError(propertyName, new ActionMessage(messageKey, messageArgs));
}
@@ -533,7 +547,7 @@
* @param messageArg2 the second argument to the message
*/
public static void addActionError(String propertyName, String messageKey, Object messageArg1, Object messageArg2) {
- Object[] messageArgs = new Object[]{messageArg1, messageArg2};
+ Object[] messageArgs = new Object[] { messageArg1, messageArg2 };
InternalUtils.addActionError(propertyName, new ActionMessage(messageKey, messageArgs));
}
@@ -546,8 +560,9 @@
* @param messageArg2 the second argument to the message
* @param messageArg3 the third argument to the message
*/
- public static void addActionError(String propertyName, String messageKey, Object messageArg1, Object messageArg2, Object messageArg3) {
- Object[] messageArgs = new Object[]{messageArg1, messageArg2, messageArg3};
+ public static void addActionError(String propertyName, String messageKey, Object messageArg1, Object messageArg2,
+ Object messageArg3) {
+ Object[] messageArgs = new Object[] { messageArg1, messageArg2, messageArg3 };
InternalUtils.addActionError(propertyName, new ActionMessage(messageKey, messageArgs));
}
@@ -562,12 +577,11 @@
ExpressionMessage msg = new ExpressionMessage(expression, messageArgs);
InternalUtils.addActionError(propertyName, msg);
}
-
+
/**
* Resolve the given action to a URI by running an entire request-processing cycle on the given ScopedRequest
* and ScopedResponse.
- * @exclude
- *
+ *
* @param actionOverride if not <code>null</code>, this qualified action-path is used to construct an action
* URI which is set as the request URI. The action-path <strong>must</strong> begin with '/',
* which makes it qualified from the webapp root.
@@ -575,6 +589,7 @@
* on which this method will be recursively called. If <code>null</code>, the
* default extensions ".do" and ".jpf" will be used.
*/
+
/* TODO: re-add some form of this, for portal/portlet support
public static ActionResult strutsLookup( String actionOverride, String[] autoResolveExtensions )
throws Exception
@@ -583,7 +598,7 @@
ScopedResponse scopedResponse = ScopedUtils.unwrapResponse( response );
assert scopedRequest != null : request.getClass().getName();
assert scopedResponse != null : response.getClass().getName();
-
+
if ( scopedRequest == null )
{
throw new IllegalArgumentException( "request must be of type " + ScopedRequest.class.getName() );
@@ -592,15 +607,15 @@
{
throw new IllegalArgumentException( "response must be of type " + ScopedResponse.class.getName() );
}
-
+
ActionServlet as = InternalUtils.getActionServlet( context );
-
+
if ( as == null )
{
_log.error( "There is no initialized ActionServlet. The ActionServlet must be set to load-on-startup." );
return null;
}
-
+
if ( actionOverride != null )
{
// The action must be fully-qualified with its namespace.
@@ -616,7 +631,7 @@
// will allow us to tell whether processing the request actually forwarded somewhere.
//
scopedRequest.setForwardedURI( null );
-
+
//
// Now process the request. We create a PageFlowRequestWrapper for pageflow-specific request-scoped info.
//
@@ -628,12 +643,12 @@
if ( ! scopedResponse.didRedirect() )
{
returnURI = scopedRequest.getForwardedURI();
-
+
if ( autoResolveExtensions == null )
{
autoResolveExtensions = DEFAULT_AUTORESOLVE_EXTENSIONS;
}
-
+
if ( returnURI != null )
{
for ( int i = 0; i < autoResolveExtensions.length; ++i )
@@ -650,9 +665,9 @@
{
returnURI = scopedResponse.getRedirectURI();
}
-
+
DeferredSessionStorageHandler.applyChanges( scopedRequest, context );
-
+
if ( returnURI != null )
{
return new ActionResultImpl( returnURI, scopedResponse.didRedirect(), scopedResponse.getStatusCode(),
@@ -664,7 +679,7 @@
}
}
*/
-
+
/**
* Create a raw action URI, which can be modified before being sent through the registered URL rewriting chain
* using {@link URLRewriterService#rewriteURL}. Use {@link #getRewrittenActionURI} to get a fully-rewritten URI.
@@ -678,7 +693,9 @@
public static MutableURI getActionURI(String actionName)
throws URISyntaxException {
// TODO: need ActionMapper to be reversible -- it should construct the URI.
- if (actionName.length() < 1) throw new IllegalArgumentException("actionName must be non-empty");
+ if (actionName.length() < 1) {
+ throw new IllegalArgumentException("actionName must be non-empty");
+ }
PageFlowActionContext actionContext = PageFlowActionContext.get();
InternalStringBuilder actionURI = new InternalStringBuilder(actionContext.getRequestContextPath());
@@ -689,12 +706,17 @@
}
actionURI.append(actionName);
- if (!actionName.endsWith(ACTION_EXTENSION)) actionURI.append(ACTION_EXTENSION);
+
+ if (!actionName.endsWith(ACTION_EXTENSION)) {
+ actionURI.append(ACTION_EXTENSION);
+ }
FreezableMutableURI uri = new FreezableMutableURI();
+
// TODO: re-add the following line, using some abstraction
//uri.setEncoding( response.getCharacterEncoding() );
uri.setURI(actionURI.toString(), true);
+
return uri;
}
@@ -714,11 +736,18 @@
public static String getRewrittenActionURI(String actionName, Map params, String fragment, boolean forXML)
throws URISyntaxException {
MutableURI uri = getActionURI(actionName);
- if (params != null) uri.addParameters(params, false);
- if (fragment != null) uri.setFragment(uri.encode(fragment));
+
+ if (params != null) {
+ uri.addParameters(params, false);
+ }
+
+ if (fragment != null) {
+ uri.setFragment(uri.encode(fragment));
+ }
boolean needsToBeSecure = needsToBeSecure(uri.getPath(), true);
URLRewriterService.rewriteURL(uri, URLType.ACTION, needsToBeSecure);
+
String key = getURLTemplateKey(URLType.ACTION, needsToBeSecure);
URIContext uriContext = URIContextFactory.getInstance(forXML);
@@ -739,8 +768,7 @@
* @throws URISyntaxException if there's a problem converting the action URI (derived
* from processing the given action name) into a MutableURI.
*/
- public static String getRewrittenResourceURI(String path, Map params,
- String fragment, boolean forXML)
+ public static String getRewrittenResourceURI(String path, Map params, String fragment, boolean forXML)
throws URISyntaxException {
return rewriteResourceOrHrefURL(path, params, fragment, forXML, URLType.RESOURCE);
}
@@ -769,11 +797,12 @@
boolean encoded = false;
UrlConfig urlConfig = ConfigUtil.getConfig().getUrlConfig();
- if (urlConfig != null && urlConfig.isSetUrlEncodeUrls()) {
- encoded = !urlConfig.getUrlEncodeUrls();
+ if (urlConfig != null) {
+ encoded = !urlConfig.isUrlEncodeUrls();
}
FreezableMutableURI uri = new FreezableMutableURI();
+
// TODO: re-add the following line, using some abstraction
//uri.setEncoding( response.getCharacterEncoding() );
uri.setURI(path, encoded);
@@ -787,11 +816,12 @@
}
URIContext uriContext = URIContextFactory.getInstance(forXML);
+
if (uri.isAbsolute()) {
return uri.getURIString(uriContext);
}
- if (path.length() != 0 && path.charAt(0) != '/') {
+ if ((path.length() != 0) && (path.charAt(0) != '/')) {
PageFlowActionContext actionContext = PageFlowActionContext.get();
String reqPath = actionContext.getRequestPath();
reqPath = reqPath.substring(0, reqPath.lastIndexOf('/') + 1);
@@ -800,6 +830,7 @@
boolean needsToBeSecure = needsToBeSecure(uri.getPath(), true);
URLRewriterService.rewriteURL(uri, urlType, needsToBeSecure);
+
String key = getURLTemplateKey(urlType, needsToBeSecure);
return URLRewriterService.getTemplatedURL(uri, key, uriContext);
@@ -829,23 +860,27 @@
* </ul>
*/
public static boolean needsToBeSecure(String uri, boolean stripContextPath) {
- PageFlowActionContext actionContext = PageFlowActionContext.get();
-
+ PageFlowActionContext actionContext = PageFlowActionContext.get();
+
// Get the web-app relative path for security check
String secureCheck = uri;
+
if (stripContextPath) {
String contextPath = actionContext.getRequestContextPath();
+
if (secureCheck.startsWith(contextPath)) {
secureCheck = secureCheck.substring(contextPath.length());
}
}
boolean secure = false;
+
if (secureCheck.indexOf('?') > -1) {
secureCheck = secureCheck.substring(0, secureCheck.indexOf('?'));
}
SecurityProtocol sp = getSecurityProtocol(secureCheck);
+
if (sp.equals(SecurityProtocol.UNSPECIFIED)) {
secure = actionContext.isRequestSecure();
} else {
@@ -865,6 +900,7 @@
*/
public static String getURLTemplateKey(URLType urlType, boolean needsToBeSecure) {
String key = URLTemplatesFactory.ACTION_TEMPLATE;
+
if (urlType.equals(URLType.ACTION)) {
if (needsToBeSecure) {
key = URLTemplatesFactory.SECURE_ACTION_TEMPLATE;
@@ -881,5 +917,4 @@
return key;
}
-
}
Modified: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/SessionExpiredException.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/SessionExpiredException.java?rev=290802&r1=290801&r2=290802&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/SessionExpiredException.java (original)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/SessionExpiredException.java Wed Sep 21 12:42:20 2005
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,7 +24,7 @@
* <li>The requested session ID is different than the current session ID (or there is no current session), and</li>
* <li>the original exception to be thrown returns <code>true</code> for
* {@link FlowControllerException#causeMayBeSessionExpiration}, and</li>
- * <li>The <code><throw-session-expired-exception></code> element in WEB-INF/beehive-netui-config.xml is
+ * <li>The <code><throw-session-expired-exception></code> element in WEB-INF/struts-ti-config.xml is
* set to <code>true</code> (the default)</li>.
* </ul>
* <p/>
@@ -33,7 +33,6 @@
*/
public class SessionExpiredException
extends FlowControllerException {
-
private FlowControllerException _effect;
public SessionExpiredException(FlowControllerException effect) {
@@ -42,14 +41,11 @@
}
protected Object[] getMessageArgs() {
- return new Object[]{getActionName(), getFlowControllerURI()};
+ return new Object[] { getActionName(), getFlowControllerURI() };
}
protected String[] getMessageParts() {
- return new String[]
- {
- "action ", " on page flow ", " cannot be completed because the user session has expired."
- };
+ return new String[] { "action ", " on page flow ", " cannot be completed because the user session has expired." };
}
/**
Modified: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/SharedFlowController.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/SharedFlowController.java?rev=290802&r1=290801&r2=290802&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/SharedFlowController.java (original)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/SharedFlowController.java Wed Sep 21 12:42:20 2005
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
-*
+*
* http://www.apache.org/licenses/LICENSE-2.0
-*
+*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -42,7 +42,7 @@
* </li>
* <li>
* Any page flow is hit, and the <code><default-shared-flow-refs></code> element in
- * /WEB-INF/beehive-netui-config.xml declares that this shared flow will be used by all page flows in the web
+ * /WEB-INF/struts-ti-config.xml declares that this shared flow will be used by all page flows in the web
* application.
* </li>
* </ul>
@@ -79,7 +79,6 @@
public abstract class SharedFlowController
extends FlowController
implements PageFlowConstants {
-
private static final String CACHED_INFO_KEY = "cachedInfo";
/**
@@ -150,8 +149,8 @@
// Special case: if the given forward has a path to a page in the current pageflow, let that pageflow save
// the info on this page. Otherwise, don't ever save any info on what we're forwarding to.
//
- if (result != null && result.isPath()) // i.e., it's a straight forward to a path, not a navigateTo, etc.
- {
+ if ((result != null) && result.isPath()) // i.e., it's a straight forward to a path, not a navigateTo, etc.
+ {
PageFlowController currentJpf = PageFlowUtils.getCurrentPageFlow();
if (currentJpf != null) {
@@ -171,7 +170,10 @@
// Save this previous-action info in the *current page flow*.
//
PageFlowController currentJpf = PageFlowUtils.getCurrentPageFlow();
- if (currentJpf != null) currentJpf.savePreviousActionInfo();
+
+ if (currentJpf != null) {
+ currentJpf.savePreviousActionInfo();
+ }
}
/**
Modified: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/faces/internal/BackingClassMethodBinding.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/faces/internal/BackingClassMethodBinding.java?rev=290802&r1=290801&r2=290802&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/faces/internal/BackingClassMethodBinding.java (original)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/faces/internal/BackingClassMethodBinding.java Wed Sep 21 12:42:20 2005
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,19 +20,20 @@
import org.apache.ti.pageflow.handler.Handlers;
import org.apache.ti.pageflow.internal.AnnotationReader;
import org.apache.ti.pageflow.internal.InternalUtils;
-import org.apache.ti.schema.annotations.ProcessedAnnotation;
+import org.apache.ti.pageflow.internal.annotationreader.ProcessedAnnotation;
import org.apache.ti.util.internal.cache.FieldCache;
import org.apache.ti.util.internal.cache.MethodCache;
import org.apache.ti.util.logging.Logger;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
import javax.faces.component.StateHolder;
import javax.faces.component.UIComponentBase;
import javax.faces.context.FacesContext;
import javax.faces.el.EvaluationException;
import javax.faces.el.MethodBinding;
import javax.faces.el.MethodNotFoundException;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
/**
* Internal class used in JSF/Page Flow integration. This exists to cause form beans to be submitted to Page Flow
@@ -43,11 +44,9 @@
public class BackingClassMethodBinding
extends MethodBinding
implements StateHolder {
-
private static final Logger _log = Logger.getInstance(BackingClassMethodBinding.class);
private static final FieldCache _fieldCache = new FieldCache();
private static final MethodCache _methodCache = new MethodCache();
-
private String _methodName;
private Class[] _params;
private MethodBinding _delegate;
@@ -62,8 +61,7 @@
_delegate = delegate;
}
- public Class getType(FacesContext context)
- throws MethodNotFoundException {
+ public Class getType(FacesContext context) throws MethodNotFoundException {
return _delegate.getType(context);
}
@@ -76,7 +74,7 @@
* ti.commandHandler. If it is, look through the "raiseActions" annotation array for a form bean member variable
* associated with the action being raised. If one is found, set it in the request so it gets passed to the action.
*/
- public Object invoke(FacesContext context, Object params[])
+ public Object invoke(FacesContext context, Object[] params)
throws EvaluationException, MethodNotFoundException {
Object result = _delegate.invoke(context, params);
@@ -89,13 +87,15 @@
Method method = _methodCache.getMethod(backingClass, _methodName, _params);
- if (method == null) throw new MethodNotFoundException(_methodName);
+ if (method == null) {
+ throw new MethodNotFoundException(_methodName);
+ }
+
AnnotationReader annReader = Handlers.get().getAnnotationHandler().getAnnotationReader(backingClass);
- ProcessedAnnotation ann = annReader.getJpfAnnotation(method, "commandHandler");
+ ProcessedAnnotation ann = annReader.getTiAnnotation(method, "commandHandler");
if (ann != null) {
- ProcessedAnnotation[] raiseActions =
- AnnotationReader.getAnnotationArrayAttribute(ann, "raiseActions");
+ ProcessedAnnotation[] raiseActions = AnnotationReader.getAnnotationArrayAttribute(ann, "raiseActions");
if (raiseActions != null) {
setOutputFormBeans(raiseActions, backingClass, backingBean, action);
@@ -114,22 +114,24 @@
String actionAttr = AnnotationReader.getStringAttribute(raiseAction, "action");
if (actionAttr.equals(action)) {
- String formBeanMember =
- AnnotationReader.getStringAttribute(raiseAction, "outputFormBean");
+ String formBeanMember = AnnotationReader.getStringAttribute(raiseAction, "outputFormBean");
- if (formBeanMember != null && formBeanMember.length() > 0) {
+ if ((formBeanMember != null) && (formBeanMember.length() > 0)) {
try {
Field field = _fieldCache.getDeclaredField(backingClass, formBeanMember);
+
if (field == null) {
- _log.error("Could not find field " + formBeanMember + " specified as the outputFormBean "
- + "for action " + action + " raised by " + backingClass.getName());
+ _log.error("Could not find field " + formBeanMember + " specified as the outputFormBean " +
+ "for action " + action + " raised by " + backingClass.getName());
+
return;
}
+
Object value = field.get(backingBean);
InternalUtils.setForwardedFormBean(value);
} catch (IllegalAccessException e) {
- _log.error("Could not access field " + formBeanMember + " specified as the outputFormBean "
- + "for action " + action + " raised by " + backingClass.getName(), e);
+ _log.error("Could not access field " + formBeanMember + " specified as the outputFormBean " +
+ "for action " + action + " raised by " + backingClass.getName(), e);
}
}
}
@@ -137,7 +139,7 @@
}
public Object saveState(FacesContext context) {
- return new Object[]{_methodName, _params, UIComponentBase.saveAttachedState(context, _delegate)};
+ return new Object[] { _methodName, _params, UIComponentBase.saveAttachedState(context, _delegate) };
}
public void restoreState(FacesContext context, Object state) {
Modified: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/handler/Handlers.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/handler/Handlers.java?rev=290802&r1=290801&r2=290802&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/handler/Handlers.java (original)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/handler/Handlers.java Wed Sep 21 12:42:20 2005
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,16 +18,18 @@
package org.apache.ti.pageflow.handler;
import com.opensymphony.xwork.ActionContext;
+
import org.apache.ti.pageflow.internal.DefaultHandler;
import org.apache.ti.pageflow.internal.InternalConstants;
-import org.apache.ti.schema.config.CustomProperty;
-import org.apache.ti.schema.config.NetuiConfigDocument;
-import org.apache.ti.schema.config.PageflowHandlers;
import org.apache.ti.util.config.ConfigUtil;
+import org.apache.ti.util.config.bean.CustomPropertyConfig;
+import org.apache.ti.util.config.bean.NetUIConfig;
+import org.apache.ti.util.config.bean.PageFlowHandlersConfig;
import org.apache.ti.util.internal.DiscoveryUtils;
import org.apache.ti.util.logging.Logger;
import java.io.Serializable;
+
import java.util.Map;
/**
@@ -35,12 +37,9 @@
*/
public class Handlers
implements Serializable {
-
private static final long serialVersionUID = 1;
private static final Logger _log = Logger.getInstance(Handlers.class);
-
private static final String CONTEXT_ATTR = InternalConstants.ATTR_PREFIX + "_handlers";
-
private ExceptionsHandler _exceptionsHandler = null;
private ForwardRedirectHandler _forwardRedirectHandler = null;
private LoginHandler _loginHandler = null;
@@ -48,7 +47,6 @@
private ReloadableClassHandler _reloadableClassHandler = null;
private ModuleRegistrationHandler _moduleRegistrationHandler = null;
private AnnotationHandler _annotationHandler = null;
-
private DefaultHandler _defaultExceptionsHandler;
private DefaultHandler _defaultForwardRedirectHandler;
private DefaultHandler _defaultLoginHandler;
@@ -61,6 +59,7 @@
ActionContext actionContext = ActionContext.getContext();
Handlers handlers = (Handlers) actionContext.getApplication().get(CONTEXT_ATTR);
assert handlers != null : "Page Flow Handlers not initialized.";
+
return handlers;
}
@@ -68,36 +67,35 @@
//
// Load/create Handlers.
//
- NetuiConfigDocument.NetuiConfig netuiConfig = ConfigUtil.getConfig();
- PageflowHandlers handlers = netuiConfig.getPageflowHandlers();
+ NetUIConfig netuiConfig = ConfigUtil.getConfig();
+ PageFlowHandlersConfig handlers = netuiConfig.getPageFlowHandlers();
+
+ _exceptionsHandler = (ExceptionsHandler) adaptHandler((handlers != null) ? handlers.getExceptionsHandlers() : null,
+ _defaultExceptionsHandler, ExceptionsHandler.class);
- _exceptionsHandler = (ExceptionsHandler)
- adaptHandler(handlers != null ? handlers.getExceptionsHandlerArray() : null, _defaultExceptionsHandler,
- ExceptionsHandler.class);
-
- _forwardRedirectHandler = (ForwardRedirectHandler)
- adaptHandler(handlers != null ? handlers.getForwardRedirectHandlerArray() : null,
- _defaultForwardRedirectHandler, ForwardRedirectHandler.class);
-
- _loginHandler = (LoginHandler)
- adaptHandler(handlers != null ? handlers.getLoginHandlerArray() : null, _defaultLoginHandler,
- LoginHandler.class);
-
- _storageHandler = (StorageHandler)
- adaptHandler(handlers != null ? handlers.getStorageHandlerArray() : null, _defaultStorageHandler,
- StorageHandler.class);
-
- _reloadableClassHandler = (ReloadableClassHandler)
- adaptHandler(handlers != null ? handlers.getReloadableClassHandlerArray() : null,
- _defaultReloadableClassHandler, ReloadableClassHandler.class);
-
- _moduleRegistrationHandler = (ModuleRegistrationHandler)
- adaptHandler(handlers != null ? handlers.getModuleRegistrationHandlerArray() : null,
- _defaultModuleRegistrationHandler, ModuleRegistrationHandler.class);
-
- _annotationHandler = (AnnotationHandler)
- adaptHandler(handlers != null ? handlers.getAnnotationHandlerArray() : null,
- _defaultAnnotationHandler, AnnotationHandler.class);
+ _forwardRedirectHandler = (ForwardRedirectHandler) adaptHandler((handlers != null)
+ ? handlers.getForwardRedirectHandlers() : null,
+ _defaultForwardRedirectHandler,
+ ForwardRedirectHandler.class);
+
+ _loginHandler = (LoginHandler) adaptHandler((handlers != null) ? handlers.getLoginHandlers() : null,
+ _defaultLoginHandler, LoginHandler.class);
+
+ _storageHandler = (StorageHandler) adaptHandler((handlers != null) ? handlers.getStorageHandlers() : null,
+ _defaultStorageHandler, StorageHandler.class);
+
+ _reloadableClassHandler = (ReloadableClassHandler) adaptHandler((handlers != null)
+ ? handlers.getReloadableClassHandlers() : null,
+ _defaultReloadableClassHandler,
+ ReloadableClassHandler.class);
+
+ _moduleRegistrationHandler = (ModuleRegistrationHandler) adaptHandler((handlers != null)
+ ? handlers.getModuleRegistrationHandlers() : null,
+ _defaultModuleRegistrationHandler,
+ ModuleRegistrationHandler.class);
+
+ _annotationHandler = (AnnotationHandler) adaptHandler((handlers != null) ? handlers.getAnnotationHandlers() : null,
+ _defaultAnnotationHandler, AnnotationHandler.class);
appScope.put(CONTEXT_ATTR, this);
}
@@ -130,22 +128,24 @@
return _annotationHandler;
}
- private static Handler adaptHandler(org.apache.ti.schema.config.Handler[] handlerBeanConfigs,
+ private static Handler adaptHandler(org.apache.ti.util.config.bean.HandlerConfig[] handlerBeanConfigs,
DefaultHandler defaultHandler, Class baseClassOrInterface) {
Handler retVal = defaultHandler;
if (handlerBeanConfigs != null) {
for (int i = 0; i < handlerBeanConfigs.length; i++) {
String handlerClass = handlerBeanConfigs[i].getHandlerClass();
- CustomProperty[] props = handlerBeanConfigs[i].getCustomPropertyArray();
+ CustomPropertyConfig[] props = handlerBeanConfigs[i].getCustomProperties();
Handler handler = createHandler(handlerClass, baseClassOrInterface, retVal);
if (handler != null) {
HandlerConfig config = new HandlerConfig(handlerClass);
- for (int j = 0; j < props.length; j++) {
- CustomProperty prop = props[j];
- config.addCustomProperty(prop.getName(), prop.getValue());
+ if (props != null) {
+ for (int j = 0; j < props.length; j++) {
+ CustomPropertyConfig prop = props[j];
+ config.addCustomProperty(prop.getName(), prop.getValue());
+ }
}
handler.init(config, retVal);
@@ -156,6 +156,7 @@
defaultHandler.init(null, null);
defaultHandler.setRegisteredHandler(retVal);
+
return retVal;
}
@@ -167,8 +168,8 @@
* @return an initialized Handler.
*/
private static Handler createHandler(String className, Class baseClassOrInterface, Handler previousHandler) {
- assert Handler.class.isAssignableFrom(baseClassOrInterface)
- : baseClassOrInterface.getName() + " cannot be assigned to " + Handler.class.getName();
+ assert Handler.class.isAssignableFrom(baseClassOrInterface) : baseClassOrInterface.getName() + " cannot be assigned to " +
+ Handler.class.getName();
ClassLoader cl = DiscoveryUtils.getClassLoader();
@@ -176,14 +177,17 @@
Class handlerClass = cl.loadClass(className);
if (!baseClassOrInterface.isAssignableFrom(handlerClass)) {
- _log.error("Handler " + handlerClass.getName() + " does not implement or extend "
- + baseClassOrInterface.getName());
+ _log.error("Handler " + handlerClass.getName() + " does not implement or extend " +
+ baseClassOrInterface.getName());
+
return null;
}
Handler handler = (Handler) handlerClass.newInstance();
+
// TODO: add a way to set custom props on HandlerConfig
handler.init(new HandlerConfig(className), previousHandler);
+
return handler;
} catch (ClassNotFoundException e) {
_log.error("Could not find Handler class " + className, e);
Modified: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/interceptor/InterceptorContext.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/interceptor/InterceptorContext.java?rev=290802&r1=290801&r2=290802&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/interceptor/InterceptorContext.java (original)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/interceptor/InterceptorContext.java Wed Sep 21 12:42:20 2005
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,11 +17,12 @@
*/
package org.apache.ti.pageflow.interceptor;
-import org.apache.ti.schema.config.CustomProperty;
+import org.apache.ti.util.config.bean.CustomPropertyConfig;
import org.apache.ti.util.internal.DiscoveryUtils;
import org.apache.ti.util.logging.Logger;
import java.io.Serializable;
+
import java.util.List;
/**
@@ -29,9 +30,7 @@
*/
public class InterceptorContext
implements Serializable {
-
private static final Logger _log = Logger.getInstance(InterceptorContext.class);
-
private Object _resultOverride;
private Interceptor _overridingInterceptor;
@@ -52,18 +51,18 @@
return _overridingInterceptor;
}
- protected static void addInterceptors(org.apache.ti.schema.config.Interceptor[] configBeans,
- List/*< Interceptor >*/ interceptorsList, Class baseClassOrInterface) {
+ protected static void addInterceptors(org.apache.ti.util.config.bean.InterceptorConfig[] configBeans,
+ List /*< Interceptor >*/ interceptorsList, Class baseClassOrInterface) {
if (configBeans != null) {
for (int i = 0; i < configBeans.length; i++) {
- org.apache.ti.schema.config.Interceptor configBean = configBeans[i];
+ org.apache.ti.util.config.bean.InterceptorConfig configBean = configBeans[i];
String className = configBean.getInterceptorClass();
InterceptorConfig config = new InterceptorConfig(className);
- CustomProperty[] customProps = configBean.getCustomPropertyArray();
+ CustomPropertyConfig[] customProps = configBean.getCustomProperties();
if (customProps != null) {
for (int j = 0; j < customProps.length; j++) {
- CustomProperty customProp = customProps[j];
+ CustomPropertyConfig customProp = customProps[j];
config.addCustomProperty(customProp.getName(), customProp.getValue());
}
}
@@ -83,9 +82,13 @@
* @return an initialized Interceptor, or <code>null</code> if an error occurred.
*/
protected static Interceptor addInterceptor(InterceptorConfig config, Class baseClassOrInterface,
- List/*< Interceptor >*/ interceptors) {
+ List /*< Interceptor >*/ interceptors) {
Interceptor interceptor = createInterceptor(config, baseClassOrInterface);
- if (interceptor != null) interceptors.add(interceptor);
+
+ if (interceptor != null) {
+ interceptors.add(interceptor);
+ }
+
return interceptor;
}
@@ -97,8 +100,8 @@
* @return an initialized Interceptor, or <code>null</code> if an error occurred.
*/
protected static Interceptor createInterceptor(InterceptorConfig config, Class baseClassOrInterface) {
- assert Interceptor.class.isAssignableFrom(baseClassOrInterface)
- : baseClassOrInterface.getName() + " cannot be assigned to " + Interceptor.class.getName();
+ assert Interceptor.class.isAssignableFrom(baseClassOrInterface) : baseClassOrInterface.getName() +
+ " cannot be assigned to " + Interceptor.class.getName();
ClassLoader cl = DiscoveryUtils.getClassLoader();
String className = config.getInterceptorClass();
@@ -107,13 +110,15 @@
Class interceptorClass = cl.loadClass(className);
if (!baseClassOrInterface.isAssignableFrom(interceptorClass)) {
- _log.error("Interceptor " + interceptorClass.getName() + " does not implement or extend "
- + baseClassOrInterface.getName());
+ _log.error("Interceptor " + interceptorClass.getName() + " does not implement or extend " +
+ baseClassOrInterface.getName());
+
return null;
}
Interceptor interceptor = (Interceptor) interceptorClass.newInstance();
interceptor.init(config);
+
return interceptor;
} catch (ClassNotFoundException e) {
_log.error("Could not find interceptor class " + className, e);
@@ -125,5 +130,4 @@
return null;
}
-
}
Modified: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/interceptor/action/ActionInterceptor.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/interceptor/action/ActionInterceptor.java?rev=290802&r1=290801&r2=290802&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/interceptor/action/ActionInterceptor.java (original)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/interceptor/action/ActionInterceptor.java Wed Sep 21 12:42:20 2005
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,11 +22,10 @@
import org.apache.ti.pageflow.interceptor.InterceptorContext;
import org.apache.ti.pageflow.interceptor.InterceptorException;
-
/**
- * Base class for Page Flow action interceptors. These are configured in /WEB-INF/beehive-netui-config.xml like this:
+ * Base class for Page Flow action interceptors. These are configured in /WEB-INF/struts-ti-config.xml like this:
* <pre>
- * <netui-config xmlns="http://beehive.apache.org/netui/2004/server/config">
+ * <ti-config xmlns="http://struts.apache.org/ti/2005/server/config">
* ...
* <p/>
* <pageflow-action-interceptors>
@@ -52,7 +51,7 @@
* </pageflow-action-interceptors>
* <p/>
* ...
- * </netui-config>
+ * </ti-config>
* <p/>
* </pre>
* <p/>
@@ -61,7 +60,6 @@
*/
public abstract class ActionInterceptor
extends AbstractInterceptor {
-
/**
* Callback invoked before the action is processed. During this method, {@link #setOverrideForward} may be called
* to:
@@ -88,7 +86,8 @@
/**
* Callback invoked before the action is processed. {@link #preAction} may be used instead.
*/
- public void preInvoke(InterceptorContext context, InterceptorChain chain) throws InterceptorException {
+ public void preInvoke(InterceptorContext context, InterceptorChain chain)
+ throws InterceptorException {
preAction((ActionInterceptorContext) context, chain);
}
@@ -112,7 +111,8 @@
/**
* Callback invoked after the action is processed. {@link #postAction} may be used instead.
*/
- public void postInvoke(InterceptorContext context, InterceptorChain chain) throws InterceptorException {
+ public void postInvoke(InterceptorContext context, InterceptorChain chain)
+ throws InterceptorException {
postAction((ActionInterceptorContext) context, chain);
}
Modified: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/interceptor/action/ActionInterceptorContext.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/interceptor/action/ActionInterceptorContext.java?rev=290802&r1=290801&r2=290802&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/interceptor/action/ActionInterceptorContext.java (original)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/pageflow/interceptor/action/ActionInterceptorContext.java Wed Sep 21 12:42:20 2005
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,8 +23,11 @@
import org.apache.ti.pageflow.interceptor.request.RequestInterceptorContext;
import org.apache.ti.pageflow.internal.InternalConstants;
import org.apache.ti.pageflow.xwork.PageFlowActionContext;
-import org.apache.ti.schema.config.PageflowActionInterceptors;
import org.apache.ti.util.config.ConfigUtil;
+import org.apache.ti.util.config.bean.GlobalPageFlowActionInterceptorConfig;
+import org.apache.ti.util.config.bean.PageFlowActionInterceptorsConfig;
+import org.apache.ti.util.config.bean.PerActionInterceptorConfig;
+import org.apache.ti.util.config.bean.PerPageFlowActionInterceptorConfig;
import org.apache.ti.util.internal.concurrent.InternalConcurrentHashMap;
import java.util.ArrayList;
@@ -32,21 +35,17 @@
import java.util.List;
import java.util.Map;
-
/**
* Context passed to {@link ActionInterceptor} methods.
*/
public class ActionInterceptorContext
extends RequestInterceptorContext {
-
private static final String ACTIVE_INTERCEPTOR_CONTEXT_ATTR = InternalConstants.ATTR_PREFIX + "interceptorContext";
private static final String CACHE_ATTR = InternalConstants.ATTR_PREFIX + "actionInterceptorConfig";
-
private PageFlowController _pageFlow;
private InterceptorForward _originalForward;
private String _actionName;
-
public ActionInterceptorContext(PageFlowController controller, InterceptorForward originalForward, String actionName) {
super();
_pageFlow = controller;
@@ -83,13 +82,15 @@
*/
public void setOverrideForward(InterceptorForward fwd, ActionInterceptor interceptor) {
setResultOverride(fwd, interceptor);
-
+
//
// If there was no original forward (i.e., this is happening before the action was invoked), create a
// pseudo-forward out of the original request.
//
- if (_originalForward == null) _originalForward = new OriginalForward();
-
+ if (_originalForward == null) {
+ _originalForward = new OriginalForward();
+ }
+
//
// Store this context in the request.
//
@@ -112,17 +113,19 @@
public static ActionInterceptorContext getActiveContext(boolean consume) {
PageFlowActionContext actionContext = PageFlowActionContext.get();
Map requestScope = actionContext.getRequestScope();
- ActionInterceptorContext context =
- (ActionInterceptorContext) requestScope.get(ACTIVE_INTERCEPTOR_CONTEXT_ATTR);
- if (consume) requestScope.remove(ACTIVE_INTERCEPTOR_CONTEXT_ATTR);
+ ActionInterceptorContext context = (ActionInterceptorContext) requestScope.get(ACTIVE_INTERCEPTOR_CONTEXT_ATTR);
+
+ if (consume) {
+ requestScope.remove(ACTIVE_INTERCEPTOR_CONTEXT_ATTR);
+ }
+
return context;
}
-
- public List/*< Interceptor >*/ getActionInterceptors() {
+ public List /*< Interceptor >*/ getActionInterceptors() {
PageFlowActionContext actionContext = PageFlowActionContext.get();
- InternalConcurrentHashMap/*< String, HashMap< String, ArrayList< Interceptor > > >*/ cache =
- (InternalConcurrentHashMap) actionContext.getApplication().get(CACHE_ATTR);
+ InternalConcurrentHashMap /*< String, HashMap< String, ArrayList< Interceptor > > >*/ cache = (InternalConcurrentHashMap) actionContext.getApplication()
+ .get(CACHE_ATTR);
if (cache == null) {
//
@@ -130,75 +133,79 @@
// 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 > > >*/();
+ cache = new InternalConcurrentHashMap /*< String, HashMap< String, ArrayList< Interceptor > > >*/();
actionContext.getApplication().put(CACHE_ATTR, cache);
}
String namespace = getPageFlow().getNamespace();
String actionName = getActionName();
- HashMap/*< String, ArrayList< Interceptor > >*/ cacheByPageFlow = (HashMap) cache.get(namespace);
+ HashMap /*< String, ArrayList< Interceptor > >*/ cacheByPageFlow = (HashMap) cache.get(namespace);
+
if (cacheByPageFlow != null) {
- List/*< Interceptor >*/ interceptors = (List) cacheByPageFlow.get(actionName);
- if (interceptors != null) return interceptors;
+ 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 (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(namespace, cacheByPageFlow);
+
return interceptorsList;
}
-
+
//
// Global interceptors.
//
- PageflowActionInterceptors.Global globalInterceptors = config.getGlobal();
+ GlobalPageFlowActionInterceptorConfig globalInterceptors = config.getGlobalPageFlowActionInterceptors();
if (globalInterceptors != null) {
- addInterceptors(globalInterceptors.getActionInterceptorArray(), interceptorsList, ActionInterceptor.class);
- addSimpleInterceptors(globalInterceptors.getSimpleActionInterceptorArray(), interceptorsList);
+ addInterceptors(globalInterceptors.getActionInterceptors(), interceptorsList, ActionInterceptor.class);
+ addSimpleInterceptors(globalInterceptors.getSimpleActionInterceptors(), interceptorsList);
}
-
+
//
// Per-pageflow and per-action interceptors.
//
String pageFlowURI = getPageFlow().getPath();
- PageflowActionInterceptors.PerPageflow[] perPageFlowInterceptorsConfig = config.getPerPageflowArray();
+ PerPageFlowActionInterceptorConfig[] perPageFlowInterceptorsConfig = config.getPerPageFlowActionInterceptors();
if (perPageFlowInterceptorsConfig != null) {
for (int i = 0; i < perPageFlowInterceptorsConfig.length; i++) {
- PageflowActionInterceptors.PerPageflow ppfi = perPageFlowInterceptorsConfig[i];
+ PerPageFlowActionInterceptorConfig ppfi = perPageFlowInterceptorsConfig[i];
- if (ppfi != null && pageFlowURI.equals(ppfi.getPageflowUri())) {
+ 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);
+ addInterceptors(perPageFlowInterceptorsConfig[i].getActionInterceptors(), interceptorsList,
+ ActionInterceptor.class);
+ addSimpleInterceptors(perPageFlowInterceptorsConfig[i].getSimpleActionInterceptors(), interceptorsList);
- PageflowActionInterceptors.PerPageflow.PerAction[] perActionConfigs =
- perPageFlowInterceptorsConfig[i].getPerActionArray();
+ PerActionInterceptorConfig[] perActionConfigs = perPageFlowInterceptorsConfig[i].getPerActionInterceptors();
if (perActionConfigs != null) {
for (int j = 0; j < perActionConfigs.length; j++) {
- PageflowActionInterceptors.PerPageflow.PerAction perActionConfig = perActionConfigs[j];
+ PerActionInterceptorConfig perActionConfig = perActionConfigs[j];
- if (perActionConfig != null && actionName.equals(perActionConfig.getActionName())) {
+ 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);
+ addInterceptors(perActionConfig.getActionInterceptors(), interceptorsList, ActionInterceptor.class);
+ addSimpleInterceptors(perActionConfig.getSimpleActionInterceptors(), interceptorsList);
}
}
}
@@ -208,13 +215,18 @@
cacheByPageFlow.put(actionName, interceptorsList);
cache.put(namespace, cacheByPageFlow);
+
return interceptorsList;
}
- private static void addSimpleInterceptors(org.apache.ti.schema.config.SimpleActionInterceptor[] configBeans,
- List/*< Interceptor >*/ interceptorsList) {
+ private static void addSimpleInterceptors(org.apache.ti.util.config.bean.SimpleActionInterceptorConfig[] configBeans,
+ List /*< Interceptor >*/ interceptorsList) {
+ if (configBeans == null) {
+ return;
+ }
+
for (int i = 0; i < configBeans.length; i++) {
- org.apache.ti.schema.config.SimpleActionInterceptor configBean = configBeans[i];
+ org.apache.ti.util.config.bean.SimpleActionInterceptorConfig configBean = configBeans[i];
String path = configBean.getInterceptPath();
boolean afterAction = configBean.getAfterAction();
SimpleActionInterceptorConfig config = new SimpleActionInterceptorConfig(path, afterAction);
@@ -223,7 +235,7 @@
}
public void setOriginalForward(Forward origFwd) {
- _originalForward = origFwd != null ? new InterceptorForward(origFwd) : null;
+ _originalForward = (origFwd != null) ? new InterceptorForward(origFwd) : null;
}
public static void init(Map appScope) {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org