You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by mu...@apache.org on 2008/06/10 16:07:37 UTC

svn commit: r666116 - in /struts/sandbox/trunk/struts2-convention-plugin/src: main/java/org/apache/struts2/convention/ main/java/org/apache/struts2/convention/annotation/ test/java/org/apache/struts2/convention/ test/java/org/apache/struts2/convention/...

Author: musachy
Date: Tue Jun 10 07:07:36 2008
New Revision: 666116

URL: http://svn.apache.org/viewvc?rev=666116&view=rev
Log:
Add @DefaultInterceptorRef to packages

Added:
    struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/DefaultInterceptorRef.java   (with props)
    struts/sandbox/trunk/struts2-convention-plugin/src/test/java/org/apache/struts2/convention/actions/defaultinterceptor/
    struts/sandbox/trunk/struts2-convention-plugin/src/test/java/org/apache/struts2/convention/actions/defaultinterceptor/SingleActionNameAction2.java
    struts/sandbox/trunk/struts2-convention-plugin/src/test/java/org/apache/struts2/convention/actions/defaultinterceptor/package-info.java   (with props)
Modified:
    struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java
    struts/sandbox/trunk/struts2-convention-plugin/src/test/java/org/apache/struts2/convention/PackageBasedActionConfigBuilderTest.java

Modified: struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java?rev=666116&r1=666115&r2=666116&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java (original)
+++ struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java Tue Jun 10 07:07:36 2008
@@ -35,6 +35,7 @@
 import org.apache.struts2.convention.annotation.Action;
 import org.apache.struts2.convention.annotation.Actions;
 import org.apache.struts2.convention.annotation.AnnotationTools;
+import org.apache.struts2.convention.annotation.DefaultInterceptorRef;
 import org.apache.struts2.convention.annotation.ExceptionMapping;
 import org.apache.struts2.convention.annotation.ExceptionMappings;
 import org.apache.struts2.convention.annotation.Namespace;
@@ -692,6 +693,15 @@
         if (pkgConfig == null) {
             pkgConfig = new PackageConfig.Builder(name).namespace(actionNamespace).addParent(parentPkg);
             packageConfigs.put(name, pkgConfig);
+
+            //check for @DefaultInterceptorRef in the package
+            DefaultInterceptorRef defaultInterceptorRef = AnnotationTools.findAnnotation(actionClass, DefaultInterceptorRef.class);
+            if (defaultInterceptorRef != null) {
+                pkgConfig.defaultInterceptorRef(defaultInterceptorRef.value());
+
+                if (LOG.isTraceEnabled())
+                    LOG.trace("Setting [#0] as the default interceptor ref for [#1]", defaultInterceptorRef.value(), pkgConfig.getName());
+            }
         }
 
         if (LOG.isTraceEnabled()) {

Added: struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/DefaultInterceptorRef.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/DefaultInterceptorRef.java?rev=666116&view=auto
==============================================================================
--- struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/DefaultInterceptorRef.java (added)
+++ struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/DefaultInterceptorRef.java Tue Jun 10 07:07:36 2008
@@ -0,0 +1,39 @@
+/*
+ * $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.convention.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Defines the default interceptor for all actions
+ * in this package
+ */
+@Target({ElementType.PACKAGE})
+@Retention(value = RetentionPolicy.RUNTIME)
+public @interface DefaultInterceptorRef {
+    /**
+     * @return  The interceptor name.
+     */
+    String value();
+}

Propchange: struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/DefaultInterceptorRef.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: struts/sandbox/trunk/struts2-convention-plugin/src/test/java/org/apache/struts2/convention/PackageBasedActionConfigBuilderTest.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-convention-plugin/src/test/java/org/apache/struts2/convention/PackageBasedActionConfigBuilderTest.java?rev=666116&r1=666115&r2=666116&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-convention-plugin/src/test/java/org/apache/struts2/convention/PackageBasedActionConfigBuilderTest.java (original)
+++ struts/sandbox/trunk/struts2-convention-plugin/src/test/java/org/apache/struts2/convention/PackageBasedActionConfigBuilderTest.java Tue Jun 10 07:07:36 2008
@@ -42,6 +42,7 @@
 import org.apache.struts2.convention.actions.action.SingleActionNameAction;
 import org.apache.struts2.convention.actions.action.TestAction;
 import org.apache.struts2.convention.actions.action.TestExtends;
+import org.apache.struts2.convention.actions.defaultinterceptor.SingleActionNameAction2;
 import org.apache.struts2.convention.actions.exception.ExceptionsActionLevelAction;
 import org.apache.struts2.convention.actions.exception.ExceptionsMethodLevelAction;
 import org.apache.struts2.convention.actions.interceptor.ActionLevelInterceptor2Action;
@@ -125,6 +126,8 @@
             "", strutsDefault, null);
         PackageConfig paramsPkg = makePackageConfig("org.apache.struts2.convention.actions.params#struts-default#/params",
                 "/params", strutsDefault, null);
+        PackageConfig defaultInterceptorPkg = makePackageConfig("org.apache.struts2.convention.actions.defaultinterceptor#struts-default#/defaultinterceptor",
+                "/defaultinterceptor", strutsDefault, null);
         PackageConfig exceptionPkg = makePackageConfig("org.apache.struts2.convention.actions.exception#struts-default#/exception",
                 "/exception", strutsDefault, null);
         PackageConfig actionPkg = makePackageConfig("org.apache.struts2.convention.actions.action#struts-default#/action",
@@ -183,6 +186,9 @@
         /* org.apache.struts2.convention.actions.params */
         expect(resultMapBuilder.build(ActionParamsMethodLevelAction.class, getAnnotation(ActionParamsMethodLevelAction.class, "run1", Action.class), "actionParam1", paramsPkg)).andReturn(results);
 
+        /* org.apache.struts2.convention.actions.defaultinterceptor */
+        expect(resultMapBuilder.build(SingleActionNameAction2.class, getAnnotation(SingleActionNameAction2.class, "execute", Action.class), "action345", defaultInterceptorPkg)).andReturn(results);
+
         /* org.apache.struts2.convention.actions.exception */
         expect(resultMapBuilder.build(ExceptionsMethodLevelAction.class, getAnnotation(ExceptionsMethodLevelAction.class, "run1", Action.class), "exception1", exceptionPkg)).andReturn(results);
         expect(resultMapBuilder.build(ExceptionsActionLevelAction.class, getAnnotation(ExceptionsActionLevelAction.class, "execute", Action.class), "exceptions-action-level", exceptionPkg)).andReturn(results);
@@ -370,6 +376,11 @@
         verifyActionConfig(pkgConfig, "idx2", org.apache.struts2.convention.actions.idx.idx2.Index.class, "execute",
             "org.apache.struts2.convention.actions.idx.idx2#struts-default#/idx/idx2");
 
+        /* org.apache.struts2.convention.actions.defaultinterceptor */
+        pkgConfig = configuration.getPackageConfig("org.apache.struts2.convention.actions.defaultinterceptor#struts-default#/defaultinterceptor");
+        assertNotNull(pkgConfig);
+        assertEquals("validationWorkflowStack", pkgConfig.getDefaultInterceptorRef());
+
         /* org.apache.struts2.convention.actions.idx.idx2 */
         pkgConfig = configuration.getPackageConfig("org.apache.struts2.convention.actions.idx.idx2#struts-default#/idx/idx2");
         assertNotNull(pkgConfig);

Added: struts/sandbox/trunk/struts2-convention-plugin/src/test/java/org/apache/struts2/convention/actions/defaultinterceptor/SingleActionNameAction2.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-convention-plugin/src/test/java/org/apache/struts2/convention/actions/defaultinterceptor/SingleActionNameAction2.java?rev=666116&view=auto
==============================================================================
--- struts/sandbox/trunk/struts2-convention-plugin/src/test/java/org/apache/struts2/convention/actions/defaultinterceptor/SingleActionNameAction2.java (added)
+++ struts/sandbox/trunk/struts2-convention-plugin/src/test/java/org/apache/struts2/convention/actions/defaultinterceptor/SingleActionNameAction2.java Tue Jun 10 07:07:36 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.convention.actions.defaultinterceptor;
+
+import org.apache.struts2.convention.annotation.Action;
+
+/**
+ * <p>
+ * This is a test action.
+ * </p>
+ */
+public class SingleActionNameAction2 implements com.opensymphony.xwork2.Action{
+    @Action("action345")
+    public String execute() {
+        return null;
+    }
+}
\ No newline at end of file

Added: struts/sandbox/trunk/struts2-convention-plugin/src/test/java/org/apache/struts2/convention/actions/defaultinterceptor/package-info.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-convention-plugin/src/test/java/org/apache/struts2/convention/actions/defaultinterceptor/package-info.java?rev=666116&view=auto
==============================================================================
--- struts/sandbox/trunk/struts2-convention-plugin/src/test/java/org/apache/struts2/convention/actions/defaultinterceptor/package-info.java (added)
+++ struts/sandbox/trunk/struts2-convention-plugin/src/test/java/org/apache/struts2/convention/actions/defaultinterceptor/package-info.java Tue Jun 10 07:07:36 2008
@@ -0,0 +1,22 @@
+/*
+ * $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.
+ */
+@org.apache.struts2.convention.annotation.DefaultInterceptorRef("validationWorkflowStack")
+package org.apache.struts2.convention.actions.defaultinterceptor;
\ No newline at end of file

Propchange: struts/sandbox/trunk/struts2-convention-plugin/src/test/java/org/apache/struts2/convention/actions/defaultinterceptor/package-info.java
------------------------------------------------------------------------------
    svn:keywords = Id