Author: pbenedict Date: Sun Nov 16 14:34:54 2008 New Revision: 718127 URL: http://svn.apache.org/viewvc?rev=718127&view=rev Log: STR-3168: Add new Dispatcher interface
Added: struts/struts1/trunk/core/src/main/java/org/apache/struts/action/Dispatcher.java (with props) Modified: struts/struts1/trunk/extras/src/main/java/org/apache/struts/actions/ActionDispatcher.java Added: struts/struts1/trunk/core/src/main/java/org/apache/struts/action/Dispatcher.java URL: http://svn.apache.org/viewvc/struts/struts1/trunk/core/src/main/java/org/apache/struts/action/Dispatcher.java?rev=718127&view=auto ============================================================================== --- struts/struts1/trunk/core/src/main/java/org/apache/struts/action/Dispatcher.java (added) +++ struts/struts1/trunk/core/src/main/java/org/apache/struts/action/Dispatcher.java Sun Nov 16 14:34:54 2008 @@ -0,0 +1,47 @@ +/* + * $Id$ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.struts.action; + +import org.apache.struts.chain.contexts.ActionContext; + +/** + * This interface defines an intermediate handler that determines what method to + * execute in an [EMAIL PROTECTED] Action}. Unlike the classical execute signature, it is + * up to the implementation to determine the particular arguments and return + * type. + * + * @version $Rev$ + * @since Struts 1.4 + */ +public interface Dispatcher { + + /** + * Dispatches to the action referenced by the specified context. + * + * @param context the current action context + * @return the result type, <code>null</code> if the response was handled + * directly, or [EMAIL PROTECTED] Void} if the executed method has no return + * signature + * @throws Exception if an exception occurs + */ + Object dispatchAction(ActionContext context) throws Exception; + +} Propchange: struts/struts1/trunk/core/src/main/java/org/apache/struts/action/Dispatcher.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: struts/struts1/trunk/core/src/main/java/org/apache/struts/action/Dispatcher.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Modified: struts/struts1/trunk/extras/src/main/java/org/apache/struts/actions/ActionDispatcher.java URL: http://svn.apache.org/viewvc/struts/struts1/trunk/extras/src/main/java/org/apache/struts/actions/ActionDispatcher.java?rev=718127&r1=718126&r2=718127&view=diff ============================================================================== --- struts/struts1/trunk/extras/src/main/java/org/apache/struts/actions/ActionDispatcher.java (original) +++ struts/struts1/trunk/extras/src/main/java/org/apache/struts/actions/ActionDispatcher.java Sun Nov 16 14:34:54 2008 @@ -27,6 +27,9 @@ import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.Dispatcher; +import org.apache.struts.chain.contexts.ActionContext; +import org.apache.struts.chain.contexts.ServletActionContext; import org.apache.struts.util.MessageResources; import javax.servlet.ServletException; @@ -87,7 +90,7 @@ * @version $Rev$ $Date$ * @since Struts 1.2.7 */ -public class ActionDispatcher { +public class ActionDispatcher implements Dispatcher { // ----------------------------------------------------- Instance Variables /** @@ -497,4 +500,14 @@ protected boolean isCancelled(HttpServletRequest request) { return (request.getAttribute(Globals.CANCEL_KEY) != null); } + + /** + * @since Struts 1.4 + */ + public Object dispatchAction(ActionContext context) throws Exception { + ServletActionContext servletContext = (ServletActionContext) context; + return execute((ActionMapping) context.getActionConfig(), context.getActionForm(), + servletContext.getRequest(), servletContext.getResponse()); + } + }