You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by je...@apache.org on 2008/07/01 15:49:01 UTC
svn commit: r673081 - in /struts/struts2/trunk/plugins:
codebehind/src/main/java/org/apache/struts2/codebehind/CodebehindUnknownHandler.java
rest/src/main/java/org/apache/struts2/rest/RestActionSupport.java
rest/src/main/resources/struts-plugin.xml
Author: jeromy
Date: Tue Jul 1 06:49:01 2008
New Revision: 673081
URL: http://svn.apache.org/viewvc?rev=673081&view=rev
Log:
WW-2702 Codebehind unknown handler can now instantiate PackageConfig.defaultClassRef instead of only ActionSupport.
Rest plugin provides defaultClassImpl impl with index() method to support unknown actions.
Added:
struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionSupport.java
Modified:
struts/struts2/trunk/plugins/codebehind/src/main/java/org/apache/struts2/codebehind/CodebehindUnknownHandler.java
struts/struts2/trunk/plugins/rest/src/main/resources/struts-plugin.xml
Modified: struts/struts2/trunk/plugins/codebehind/src/main/java/org/apache/struts2/codebehind/CodebehindUnknownHandler.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/codebehind/src/main/java/org/apache/struts2/codebehind/CodebehindUnknownHandler.java?rev=673081&r1=673080&r2=673081&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/codebehind/src/main/java/org/apache/struts2/codebehind/CodebehindUnknownHandler.java (original)
+++ struts/struts2/trunk/plugins/codebehind/src/main/java/org/apache/struts2/codebehind/CodebehindUnknownHandler.java Tue Jul 1 06:49:01 2008
@@ -75,7 +75,7 @@
public void setPathPrefix(String prefix) {
this.templatePathPrefix=prefix;
}
-
+
@Inject
public void setServletContext(ServletContext servletContext) {
this.servletContext = servletContext;
@@ -110,7 +110,7 @@
/** Create a new ActionConfig in the default package, with the default interceptor stack and a single result */
protected ActionConfig buildActionConfig(String path, String namespace, String actionName, ResultTypeConfig resultTypeConfig) {
final PackageConfig pkg = configuration.getPackageConfig(defaultPackageName);
- return new ActionConfig.Builder(defaultPackageName, "execute", ActionSupport.class.getName())
+ return new ActionConfig.Builder(defaultPackageName, "execute", pkg.getDefaultClassRef())
.addInterceptors(InterceptorBuilder.constructInterceptorReference(new InterceptorLocator() {
public Object getInterceptorConfig(String name) {
return pkg.getAllInterceptorConfigs().get(name); // recurse package hiearchy
Added: struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionSupport.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionSupport.java?rev=673081&view=auto
==============================================================================
--- struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionSupport.java (added)
+++ struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionSupport.java Tue Jul 1 06:49:01 2008
@@ -0,0 +1,35 @@
+/*
+ * $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.struts2.rest;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+/**
+ * Extends {@link ActionSupport} to provides a default implementation of the index method that can be invoked for
+ * unknown actions by the {@link com.opensymphony.xwork2.UnknownHandler}.
+ */
+public class RestActionSupport extends ActionSupport {
+
+ public String index() throws Exception {
+ return execute();
+ }
+}
Modified: struts/struts2/trunk/plugins/rest/src/main/resources/struts-plugin.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/rest/src/main/resources/struts-plugin.xml?rev=673081&r1=673080&r2=673081&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/rest/src/main/resources/struts-plugin.xml (original)
+++ struts/struts2/trunk/plugins/rest/src/main/resources/struts-plugin.xml Tue Jul 1 06:49:01 2008
@@ -47,6 +47,7 @@
<constant name="struts.codebehind.classSuffix" value="Controller"/>
<constant name="struts.codebehind.action.checkImplementsAction" value="false"/>
<constant name="struts.codebehind.action.checkAnnotation" value="false"/>
+ <constant name="struts.codebehind.action.defaultMethodName" value="index"/>
<constant name="struts.configuration.classpath.defaultParentPackage" value="rest-default" />
@@ -112,6 +113,9 @@
</interceptors>
<default-interceptor-ref name="restDefaultStack"/>
+
+ <default-class-ref class="org.apache.struts2.rest.RestActionSupport"/>
+
</package>
</struts>