svn commit: r655931 - in /struts/sandbox/trunk/struts2-convention-plugin: ./ src/main/java/org/apache/struts2/convention/
Author: musachy Date: Tue May 13 09:03:04 2008 New Revision: 655931 URL: http://svn.apache.org/viewvc?rev=655931&view=rev Log: Use xwork logging instead of jdk logging Modified: struts/sandbox/trunk/struts2-convention-plugin/pom.xml struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/AbstractClassLoaderResolver.java struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/ClassClassLoaderResolver.java struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/ConventionUnknownHandler.java struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/DefaultResultMapBuilder.java struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/SEOActionNameBuilder.java Modified: struts/sandbox/trunk/struts2-convention-plugin/pom.xml URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-convention-plugin/pom.xml?rev=655931&r1=655930&r2=655931&view=diff == --- struts/sandbox/trunk/struts2-convention-plugin/pom.xml (original) +++ struts/sandbox/trunk/struts2-convention-plugin/pom.xml Tue May 13 09:03:04 2008 @@ -27,7 +27,7 @@ org.apache.struts struts2-plugins -2.1.1-SNAPSHOT +2.1.3-SNAPSHOT org.apache.struts struts2-convention-plugin Modified: struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/AbstractClassLoaderResolver.java URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/AbstractClassLoaderResolver.java?rev=655931&r1=655930&r2=655931&view=diff == --- struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/AbstractClassLoaderResolver.java (original) +++ struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/AbstractClassLoaderResolver.java Tue May 13 09:03:04 2008 @@ -36,8 +36,9 @@ import java.util.Set; import java.util.jar.JarEntry; import java.util.jar.JarInputStream; -import java.util.logging.Level; -import java.util.logging.Logger; + +import com.opensymphony.xwork2.util.logging.Logger; +import com.opensymphony.xwork2.util.logging.LoggerFactory; /** * This class is maintained in the Java.net Commons library and the test cases @@ -51,7 +52,7 @@ * */ public abstract class AbstractClassLoaderResolver { -private static final Logger logger = Logger.getLogger(AbstractClassLoaderResolver.class.getName()); +private static final Logger LOG = LoggerFactory.getLogger(AbstractClassLoaderResolver.class); /** * The set of matches being accumulated. @@ -234,7 +235,8 @@ } } } catch (IOException ioe) { -logger.log(Level.WARNING, "Could not read ClassPath entries", ioe); +if (LOG.isErrorEnabled()) +LOG.error("Could not read ClassPath entries", ioe); } } @@ -274,7 +276,8 @@ loadResourcesInJar(test, recursive, baseURLSpec, dirName, file); } } catch (IOException ioe) { -logger.log(Level.WARNING, "Could not read ClassPath entries", ioe); +if (LOG.isErrorEnabled()) +LOG.error("Could not read ClassPath entries", ioe); } } } @@ -283,8 +286,8 @@ ClassLoader loader = getClassLoader(); List urls = new ArrayList(); for (String dirName : dirNames) { -if (logger.isLoggable(Level.FINEST)) { -logger.finest("Looking up resources in directory [" + dirName + "]"); +if (LOG.isTraceEnabled()) { +LOG.trace("Looking up resources in directory [#0]", dirName); } try { @@ -294,7 +297,8 @@ urls.add(url); } } catch (IOException ioe) { -logger.log(Level.WARNING, "Could not read driectory [" + dirName + "]", ioe); +if (LOG.isErrorEnabled()) +LOG.error("Could not read driectory [#0]", ioe, dirName); } } @@ -316,9 +320,8 @@ urlPath = urlPath.substring(0, index); } -if (logger.isLoggable(Level.FINE)) { -logger.fine("Scanning for resources in [" + urlPath + "] matching criteria [" + -test + "]"); +if (LOG.isTraceEnabled()) { +LOG.trace("Scanning for resources in [#0] matching criteria [#1]", urlPath, test.toString());
svn commit: r655952 - in /struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation: Action.java Actions.java Namespace.java ParentPackage.java Result.java
Author: musachy Date: Tue May 13 10:44:53 2008 New Revision: 655952 URL: http://svn.apache.org/viewvc?rev=655952&view=rev Log: Add snippet tags Modified: struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/Action.java struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/Actions.java struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/Namespace.java struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/ParentPackage.java struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/Result.java struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/ResultPath.java struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/Results.java Modified: struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/Action.java URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/Action.java?rev=655952&r1=655951&r2=655952&view=diff == --- struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/Action.java (original) +++ struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/Action.java Tue May 13 10:44:53 2008 @@ -26,6 +26,7 @@ import java.lang.annotation.Target; /** + * * * This annotation can be used to control the URL that maps to * a specific method in an Action class. By default, the method @@ -35,12 +36,10 @@ * method. This also allows developers to specify multiple URLs * that will be handled by a single class or a single method. * - * * * This can also be used via the [EMAIL PROTECTED] Actions} annotation * to associate multiple URLs with a single method. * - * * * Here's an example: * @@ -51,6 +50,7 @@ * public String execute() {} * } * + * */ @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) Modified: struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/Actions.java URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/Actions.java?rev=655952&r1=655951&r2=655952&view=diff == --- struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/Actions.java (original) +++ struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/Actions.java Tue May 13 10:44:53 2008 @@ -26,10 +26,12 @@ import java.lang.annotation.Target; /** + * * * This annotation allows for multiple [EMAIL PROTECTED] Action} annotations * to be used on a single method. * + * */ @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) Modified: struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/Namespace.java URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/Namespace.java?rev=655952&r1=655951&r2=655952&view=diff == --- struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/Namespace.java (original) +++ struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/Namespace.java Tue May 13 10:44:53 2008 @@ -26,6 +26,7 @@ import java.lang.annotation.ElementType; /** + * * * This annotation defines how actions can modify the namespace * that they are added to. This overrides the behavior of the @@ -80,6 +81,7 @@ * The namespace as determined using the Java package name and the * standard convention based naming. * + * */ @Target({ElementType.PACKAGE, ElementType.TYPE}) @Retention(value = RetentionPolicy.RUNTIME) Modified: struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/ParentPackage.java URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/ParentPackage.java?rev=655952&r1=655951&r2=655952&view=diff == --- struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/ParentPackage.java (original) +++ struts/sandbox/trunk/struts2-conventi
svn commit: r656033 - 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/
Author: musachy Date: Tue May 13 15:18:17 2008 New Revision: 656033 URL: http://svn.apache.org/viewvc?rev=656033&view=rev Log: [WW-1796] @InterceptorRef and @InterceptorRefs annotations to configure actions with custom interceptor-refs (interceptor params still missing) thanks to Aadi Deshpande for the patch Added: struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/InterceptorRef.java struts/sandbox/trunk/struts2-convention-plugin/src/test/java/org/apache/struts2/convention/actions/interceptor/ struts/sandbox/trunk/struts2-convention-plugin/src/test/java/org/apache/struts2/convention/actions/interceptor/InterceptorsAction.java Modified: struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/Action.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=656033&r1=656032&r2=656033&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 May 13 15:18:17 2008 @@ -27,6 +27,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -34,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.InterceptorRef; import org.apache.struts2.convention.annotation.Namespace; import org.apache.struts2.convention.annotation.ParentPackage; @@ -41,8 +43,10 @@ import com.opensymphony.xwork2.config.Configuration; import com.opensymphony.xwork2.config.ConfigurationException; import com.opensymphony.xwork2.config.entities.ActionConfig; +import com.opensymphony.xwork2.config.entities.InterceptorMapping; import com.opensymphony.xwork2.config.entities.PackageConfig; import com.opensymphony.xwork2.config.entities.ResultConfig; +import com.opensymphony.xwork2.config.providers.InterceptorBuilder; import com.opensymphony.xwork2.inject.Inject; import com.opensymphony.xwork2.util.logging.Logger; import com.opensymphony.xwork2.util.logging.LoggerFactory; @@ -421,12 +425,40 @@ actionClass.toString(), actionName, pkgCfg.getName(), pkgCfg.getNamespace()); } +//build interceptors +List interceptors = buildInterceptors(pkgCfg, actionName, annotation); +actionConfig.addInterceptors(interceptors); + +//build results Map results = resultMapBuilder.build(actionClass, annotation, actionName, pkgCfg.build()); actionConfig.addResultConfigs(results); pkgCfg.addActionConfig(actionName, actionConfig.build()); } +private List buildInterceptors(PackageConfig.Builder builder, String actionName, Action annotation) { +List interceptorList = new ArrayList(10); + +if (annotation != null) { +InterceptorRef[] interceptors = annotation.interceptorRefs(); +if (interceptors != null) { +for (InterceptorRef interceptor : interceptors) { +if (LOG.isTraceEnabled()) +LOG.trace("Adding interceptor [#0] to [#1]", interceptor.value(), actionName); +interceptorList.addAll(buildInterceptorList(builder, interceptor)); +} +} +} + +return interceptorList; +} + +private List buildInterceptorList(PackageConfig.Builder builder, InterceptorRef ref) { +return InterceptorBuilder.constructInterceptorReference(builder, ref.value(), new LinkedHashMap(), +builder.build().getLocation(), (ObjectFactory) configuration.getContainer().getInstance( +ObjectFactory.class)); +} + private PackageConfig.Builder getPackageConfig(final Map packageConfigs, String actionNamespace, final String actionPackage, final Class actionClass, Action action) { Modified: struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/Action.j
svn commit: r656074 - in /struts/sandbox/trunk/struts2-convention-plugin/src: main/java/org/apache/struts2/convention/ main/java/org/apache/struts2/convention/annotation/ main/resources/ test/java/org
Author: musachy Date: Tue May 13 18:21:16 2008 New Revision: 656074 URL: http://svn.apache.org/viewvc?rev=656074&view=rev Log: Add params to Interceptors in @Action Added: struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/DefaultInterceptorMapBuilder.java struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/InterceptorMapBuilder.java struts/sandbox/trunk/struts2-convention-plugin/src/test/java/org/apache/struts2/convention/TestInterceptor.java Modified: struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/annotation/InterceptorRef.java struts/sandbox/trunk/struts2-convention-plugin/src/main/resources/struts-plugin.xml struts/sandbox/trunk/struts2-convention-plugin/src/test/java/org/apache/struts2/convention/PackageBasedActionConfigBuilderTest.java struts/sandbox/trunk/struts2-convention-plugin/src/test/java/org/apache/struts2/convention/actions/interceptor/InterceptorsAction.java Added: struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/DefaultInterceptorMapBuilder.java URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/DefaultInterceptorMapBuilder.java?rev=656074&view=auto == --- struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/DefaultInterceptorMapBuilder.java (added) +++ struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/DefaultInterceptorMapBuilder.java Tue May 13 18:21:16 2008 @@ -0,0 +1,110 @@ +/* + * $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; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.struts2.convention.annotation.Action; +import org.apache.struts2.convention.annotation.InterceptorRef; + +import com.opensymphony.xwork2.ObjectFactory; +import com.opensymphony.xwork2.config.Configuration; +import com.opensymphony.xwork2.config.ConfigurationException; +import com.opensymphony.xwork2.config.entities.InterceptorMapping; +import com.opensymphony.xwork2.config.entities.PackageConfig; +import com.opensymphony.xwork2.config.providers.InterceptorBuilder; +import com.opensymphony.xwork2.inject.Inject; +import com.opensymphony.xwork2.util.logging.Logger; +import com.opensymphony.xwork2.util.logging.LoggerFactory; + +/** + * + * Builds interceptor mappings from annotations. + * + */ +public class DefaultInterceptorMapBuilder implements InterceptorMapBuilder { + private static final Logger LOG = LoggerFactory + .getLogger(DefaultInterceptorMapBuilder.class); + + private Configuration configuration; + + public List build(PackageConfig.Builder builder, + String actionName, Action annotation) { + List interceptorList = new ArrayList( + 10); + + if (annotation != null) { + InterceptorRef[] interceptors = annotation.interceptorRefs(); + if (interceptors != null) { + for (InterceptorRef interceptor : interceptors) { + if (LOG.isTraceEnabled()) + LOG.trace("Adding interceptor [#0] to [#1]", + interceptor.value(), actionName); + Map params = createParameterMap(interceptor + .params()); + interceptorList.addAll(buildInterceptorList(builder, + interceptor, params)); + } + } + } + +