You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mb...@apache.org on 2014/03/26 21:20:03 UTC
svn commit: r1582033 [1/5] - in /commons/proper/proxy/trunk: ./ asm4/
asm4/src/main/java/org/apache/commons/proxy2/asm4/
asm4/src/test/java/org/apache/commons/proxy2/asm4/
build-tools/src/main/resources/org/apache/commons/proxy2/ cglib/
cglib/src/main/...
Author: mbenson
Date: Wed Mar 26 20:20:01 2014
New Revision: 1582033
URL: http://svn.apache.org/r1582033
Log:
checkstyle/findbugs/pmd
Added:
commons/proper/proxy/trunk/build-tools/src/main/resources/org/apache/commons/proxy2/findbugs-exclude-filter.xml
- copied, changed from r1578142, commons/proper/weaver/trunk/build-tools/src/main/resources/org/apache/commons/weaver/findbugs-exclude-filter.xml
Removed:
commons/proper/proxy/trunk/build-tools/src/main/resources/org/apache/commons/proxy2/license-header.txt
commons/proper/proxy/trunk/test/src/main/
Modified:
commons/proper/proxy/trunk/asm4/pom.xml
commons/proper/proxy/trunk/asm4/src/main/java/org/apache/commons/proxy2/asm4/ASM4ProxyFactory.java
commons/proper/proxy/trunk/asm4/src/test/java/org/apache/commons/proxy2/asm4/TestAsm4ProxyFactory.java
commons/proper/proxy/trunk/build-tools/src/main/resources/org/apache/commons/proxy2/checkstyle.xml
commons/proper/proxy/trunk/cglib/pom.xml
commons/proper/proxy/trunk/cglib/src/main/java/org/apache/commons/proxy2/cglib/CglibProxyFactory.java
commons/proper/proxy/trunk/cglib/src/test/java/org/apache/commons/proxy2/cglib/CglibProxyFactoryTest.java
commons/proper/proxy/trunk/core/pom.xml
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/DefaultProxyFactory.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/Interceptor.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/Invocation.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/Invoker.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/ObjectProvider.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/ProxyFactory.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/ProxyUtils.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/exception/InvokerException.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/exception/ObjectProviderException.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/exception/ProxyFactoryException.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/impl/AbstractProxyClassGenerator.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/impl/AbstractProxyFactory.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/impl/AbstractSubclassingProxyFactory.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/impl/MethodSignature.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/impl/ProxyClassCache.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/impl/ProxyClassGenerator.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/interceptor/InterceptorUtils.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/interceptor/ObjectProviderInterceptor.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/interceptor/SwitchInterceptor.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/interceptor/ThrowingInterceptor.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/interceptor/matcher/ArgumentMatcher.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/interceptor/matcher/InvocationMatcher.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/interceptor/matcher/argument/ArgumentMatcherUtils.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/interceptor/matcher/invocation/DeclaredByMatcher.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/interceptor/matcher/invocation/MethodNameMatcher.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/interceptor/matcher/invocation/ReturnTypeMatcher.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/invoker/DelegatingInvoker.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/invoker/DuckTypingInvoker.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/invoker/InvocationHandlerAdapter.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/invoker/NullInvoker.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/invoker/RecordedInvocation.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/invoker/recorder/InvocationRecorder.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/BeanProvider.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/CloningProvider.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/ConstantProvider.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/NullProvider.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/ObjectProviderUtils.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/ProviderDecorator.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/provider/SingletonProvider.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/serialization/ReadResolve.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/serialization/WriteReplace.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/serialization/package-info.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/AnnotationBuilder.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/AnnotationInvoker.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/AnnotationTrainer.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/BaseTrainer.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/StubBuilder.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/StubInterceptorBuilder.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/Trainer.java
commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/stub/TrainingContext.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/AbstractProxyFactoryTestCase.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/AbstractSubclassingProxyFactoryTestCase.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/ProxyUtilsTest.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/exception/AbstractExceptionClassTestCase.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/exception/DelegateProviderExceptionTest.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/exception/InvocationHandlerExceptionTest.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/exception/ProxyFactoryExceptionTest.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/impl/MethodSignatureTest.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/interceptor/InterceptorUtilsTest.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/interceptor/ObjectProviderInterceptorTest.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/interceptor/SwitchInterceptorTest.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/interceptor/matcher/DeclaredByMatcherTest.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/interceptor/matcher/MethodNameMatcherTest.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/interceptor/matcher/ReturnTypeMatcherTest.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/interceptor/matcher/argument/ArgumentMatcherUtilsTest.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/provider/BeanProviderTest.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/provider/CloningProviderTest.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/provider/ConstantProviderTest.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/provider/CountingProvider.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/provider/NullProviderTest.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/provider/ObjectProviderUtilsTest.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/util/AbstractEcho.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/util/AbstractTestCase.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/util/DuplicateEcho.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/util/Echo.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/util/EchoImpl.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/util/MockInvocation.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/util/QuoteService.java
commons/proper/proxy/trunk/core/src/test/java/org/apache/commons/proxy2/util/SuffixInterceptor.java
commons/proper/proxy/trunk/core/src/test/resources/log4j.properties
commons/proper/proxy/trunk/javassist/pom.xml
commons/proper/proxy/trunk/javassist/src/main/java/org/apache/commons/proxy2/javassist/JavassistInvocation.java
commons/proper/proxy/trunk/javassist/src/main/java/org/apache/commons/proxy2/javassist/JavassistProxyFactory.java
commons/proper/proxy/trunk/javassist/src/main/java/org/apache/commons/proxy2/javassist/JavassistUtils.java
commons/proper/proxy/trunk/javassist/src/test/java/org/apache/commons/proxy2/javassist/JavassistProxyFactoryTest.java
commons/proper/proxy/trunk/jdk/pom.xml
commons/proper/proxy/trunk/jdk/src/main/java/org/apache/commons/proxy2/jdk/JdkProxyFactory.java
commons/proper/proxy/trunk/pom.xml
commons/proper/proxy/trunk/src/site/site.xml
commons/proper/proxy/trunk/test/pom.xml
commons/proper/proxy/trunk/test/src/test/java/org/apache/commons/proxy2/DefaultProxyFactoryTest.java
commons/proper/proxy/trunk/test/src/test/java/org/apache/commons/proxy2/serialization/SerializationProxyTest.java
commons/proper/proxy/trunk/test/src/test/java/org/apache/commons/proxy2/stub/AbstractProxyFactoryAgnosticTest.java
commons/proper/proxy/trunk/test/src/test/java/org/apache/commons/proxy2/stub/AbstractStubTestCase.java
commons/proper/proxy/trunk/test/src/test/java/org/apache/commons/proxy2/stub/RetentionWrapper.java
commons/proper/proxy/trunk/test/src/test/java/org/apache/commons/proxy2/stub/StubBuilderTest.java
commons/proper/proxy/trunk/test/src/test/java/org/apache/commons/proxy2/stub/StubInterceptorBuilderTest.java
commons/proper/proxy/trunk/test/src/test/java/org/apache/commons/proxy2/stub/StubInterface.java
Modified: commons/proper/proxy/trunk/asm4/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/asm4/pom.xml?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/asm4/pom.xml (original)
+++ commons/proper/proxy/trunk/asm4/pom.xml Wed Mar 26 20:20:01 2014
@@ -57,4 +57,34 @@
<scope>test</scope>
</dependency>
</dependencies>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <configuration>
+ <!--rulesets>
+ <ruleset>/org/apache/commons/proxy2/pmd.xml</ruleset>
+ </rulesets-->
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>${checkstyle.version}</version>
+ <configuration>
+ <configLocation>org/apache/commons/proxy2/checkstyle.xml</configLocation>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <configuration>
+ <xmlOutput>true</xmlOutput>
+ <excludeFilterFile>/org/apache/commons/proxy2/findbugs-exclude-filter.xml</excludeFilterFile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
</project>
Modified: commons/proper/proxy/trunk/asm4/src/main/java/org/apache/commons/proxy2/asm4/ASM4ProxyFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/asm4/src/main/java/org/apache/commons/proxy2/asm4/ASM4ProxyFactory.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/asm4/src/main/java/org/apache/commons/proxy2/asm4/ASM4ProxyFactory.java (original)
+++ commons/proper/proxy/trunk/asm4/src/main/java/org/apache/commons/proxy2/asm4/ASM4ProxyFactory.java Wed Mar 26 20:20:01 2014
@@ -22,6 +22,8 @@ import java.lang.reflect.Method;
import java.lang.reflect.UndeclaredThrowableException;
import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.proxy2.Interceptor;
import org.apache.commons.proxy2.Invocation;
import org.apache.commons.proxy2.Invoker;
@@ -423,8 +425,7 @@ public class ASM4ProxyFactory extends Ab
&& method.getParameterTypes().length == 1 && Object.class.equals(method.getParameterTypes()[0]);
}
- @SuppressWarnings("serial")
- private static class ReflectionInvocation implements Invocation, Serializable
+ private static class ReflectionInvocation implements Invocation
{
private final Method method;
private final Object[] arguments;
@@ -435,7 +436,7 @@ public class ASM4ProxyFactory extends Ab
final Object[] arguments)
{
this.method = method;
- this.arguments = (arguments == null ? ProxyUtils.EMPTY_ARGUMENTS : arguments);
+ this.arguments = ObjectUtils.defaultIfNull(ArrayUtils.clone(arguments), ProxyUtils.EMPTY_ARGUMENTS);
this.proxy = proxy;
this.target = target;
}
Modified: commons/proper/proxy/trunk/asm4/src/test/java/org/apache/commons/proxy2/asm4/TestAsm4ProxyFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/asm4/src/test/java/org/apache/commons/proxy2/asm4/TestAsm4ProxyFactory.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/asm4/src/test/java/org/apache/commons/proxy2/asm4/TestAsm4ProxyFactory.java (original)
+++ commons/proper/proxy/trunk/asm4/src/test/java/org/apache/commons/proxy2/asm4/TestAsm4ProxyFactory.java Wed Mar 26 20:20:01 2014
@@ -20,7 +20,7 @@ import org.apache.commons.proxy2.Abstrac
public class TestAsm4ProxyFactory extends AbstractSubclassingProxyFactoryTestCase
{
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
+ //**********************************************************************************************************************
+ // Constructors
+ //**********************************************************************************************************************
}
Modified: commons/proper/proxy/trunk/build-tools/src/main/resources/org/apache/commons/proxy2/checkstyle.xml
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/build-tools/src/main/resources/org/apache/commons/proxy2/checkstyle.xml?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/build-tools/src/main/resources/org/apache/commons/proxy2/checkstyle.xml (original)
+++ commons/proper/proxy/trunk/build-tools/src/main/resources/org/apache/commons/proxy2/checkstyle.xml Wed Mar 26 20:20:01 2014
@@ -22,24 +22,19 @@
<!-- commons proxy2 customization of default Checkstyle behavior -->
<module name="Checker">
- <property name="localeLanguage" value="en"/>
-
- <module name="Header">
- <property name="headerFile" value="${checkstyle.header.file}"/>
- </module>
+ <property name="localeLanguage" value="en" />
<!-- no tabs allowed in files -->
- <module name="FileTabCharacter"/>
+ <module name="FileTabCharacter" />
<module name="TreeWalker">
- <!-- Verify that EVERY source file has the appropriate license -->
<!-- check sane import statements -->
- <module name="AvoidStarImport"/>
- <module name="RedundantImport"/>
- <module name="UnusedImports"/>
+ <module name="AvoidStarImport" />
+ <module name="RedundantImport" />
+ <module name="UnusedImports" />
<module name="LineLength">
- <property name="max" value="120"/>
+ <property name="max" value="120" />
</module>
</module>
</module>
Copied: commons/proper/proxy/trunk/build-tools/src/main/resources/org/apache/commons/proxy2/findbugs-exclude-filter.xml (from r1578142, commons/proper/weaver/trunk/build-tools/src/main/resources/org/apache/commons/weaver/findbugs-exclude-filter.xml)
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/build-tools/src/main/resources/org/apache/commons/proxy2/findbugs-exclude-filter.xml?p2=commons/proper/proxy/trunk/build-tools/src/main/resources/org/apache/commons/proxy2/findbugs-exclude-filter.xml&p1=commons/proper/weaver/trunk/build-tools/src/main/resources/org/apache/commons/weaver/findbugs-exclude-filter.xml&r1=1578142&r2=1582033&rev=1582033&view=diff
==============================================================================
--- commons/proper/weaver/trunk/build-tools/src/main/resources/org/apache/commons/weaver/findbugs-exclude-filter.xml (original)
+++ commons/proper/proxy/trunk/build-tools/src/main/resources/org/apache/commons/proxy2/findbugs-exclude-filter.xml Wed Mar 26 20:20:01 2014
@@ -23,26 +23,10 @@
-->
<FindBugsFilter>
- <!-- Reason: require that code execution hierarchy invoking CleanProcessor
- has privileges directly assigned
- -->
+ <!-- Reason: invocation arguments intentionally modifiable -->
<Match>
- <Class name="org.apache.commons.weaver.CleanProcessor" />
- <Method name="clean" />
- <Bug pattern="DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED" />
+ <Class name="org.apache.commons.proxy2.javassist.JavassistInvocation" />
+ <Bug pattern="EI_EXPOSE_REP" />
</Match>
- <!-- Reason: require that code execution hierarchy invoking WeaveProcessor
- has privileges directly assigned
- -->
- <Match>
- <Class name="org.apache.commons.weaver.WeaveProcessor" />
- <Method name="weave" />
- <Bug pattern="DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED" />
- </Match>
-
- <!-- Reason: generated code -->
- <Match>
- <Class name="org.apache.commons.weaver.maven.HelpMojo" />
- </Match>
</FindBugsFilter>
Modified: commons/proper/proxy/trunk/cglib/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/cglib/pom.xml?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/cglib/pom.xml (original)
+++ commons/proper/proxy/trunk/cglib/pom.xml Wed Mar 26 20:20:01 2014
@@ -55,4 +55,33 @@
</dependency>
</dependencies>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <configuration>
+ <!--rulesets>
+ <ruleset>/org/apache/commons/proxy2/pmd.xml</ruleset>
+ </rulesets-->
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>${checkstyle.version}</version>
+ <configuration>
+ <configLocation>org/apache/commons/proxy2/checkstyle.xml</configLocation>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <configuration>
+ <xmlOutput>true</xmlOutput>
+ <excludeFilterFile>/org/apache/commons/proxy2/findbugs-exclude-filter.xml</excludeFilterFile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
</project>
Modified: commons/proper/proxy/trunk/cglib/src/main/java/org/apache/commons/proxy2/cglib/CglibProxyFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/cglib/src/main/java/org/apache/commons/proxy2/cglib/CglibProxyFactory.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/cglib/src/main/java/org/apache/commons/proxy2/cglib/CglibProxyFactory.java (original)
+++ commons/proper/proxy/trunk/cglib/src/main/java/org/apache/commons/proxy2/cglib/CglibProxyFactory.java Wed Mar 26 20:20:01 2014
@@ -17,42 +17,54 @@
package org.apache.commons.proxy2.cglib;
-import net.sf.cglib.proxy.*;
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.proxy2.*;
-import org.apache.commons.proxy2.impl.AbstractSubclassingProxyFactory;
-
import java.io.Serializable;
import java.lang.reflect.Method;
+import net.sf.cglib.proxy.Callback;
+import net.sf.cglib.proxy.CallbackFilter;
+import net.sf.cglib.proxy.Dispatcher;
+import net.sf.cglib.proxy.Enhancer;
+import net.sf.cglib.proxy.MethodInterceptor;
+import net.sf.cglib.proxy.MethodProxy;
+
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.proxy2.Interceptor;
+import org.apache.commons.proxy2.Invocation;
+import org.apache.commons.proxy2.Invoker;
+import org.apache.commons.proxy2.ObjectProvider;
+import org.apache.commons.proxy2.ProxyUtils;
+import org.apache.commons.proxy2.impl.AbstractSubclassingProxyFactory;
+
/**
* Cglib-based {@link ProxyFactory} implementation.
*/
public class CglibProxyFactory extends AbstractSubclassingProxyFactory
{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
+ //******************************************************************************************************************
+ // Fields
+ //******************************************************************************************************************
private static CallbackFilter callbackFilter = new CglibProxyFactoryCallbackFilter();
- //**********************************************************************************************************************
- // ProxyFactory Implementation
- //**********************************************************************************************************************
+ //******************************************************************************************************************
+ // ProxyFactory Implementation
+ //******************************************************************************************************************
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
public <T> T createDelegatorProxy(ClassLoader classLoader, ObjectProvider<?> targetProvider,
- Class<?>... proxyClasses)
+ Class<?>... proxyClasses)
{
final Enhancer enhancer = new Enhancer();
enhancer.setClassLoader(classLoader);
enhancer.setInterfaces(toInterfaces(proxyClasses));
enhancer.setSuperclass(getSuperclass(proxyClasses));
enhancer.setCallbackFilter(callbackFilter);
- enhancer.setCallbacks(new Callback[]{new ObjectProviderDispatcher(targetProvider), new EqualsHandler(), new HashCodeHandler()});
+ enhancer.setCallbacks(new Callback[] { new ObjectProviderDispatcher(targetProvider), new EqualsHandler(),
+ new HashCodeHandler() });
return (T) enhancer.create();
}
@@ -61,14 +73,15 @@ public class CglibProxyFactory extends A
*/
@SuppressWarnings("unchecked")
public <T> T createInterceptorProxy(ClassLoader classLoader, Object target, Interceptor interceptor,
- Class<?>... proxyClasses)
+ Class<?>... proxyClasses)
{
final Enhancer enhancer = new Enhancer();
enhancer.setClassLoader(classLoader);
enhancer.setInterfaces(toInterfaces(proxyClasses));
enhancer.setSuperclass(getSuperclass(proxyClasses));
enhancer.setCallbackFilter(callbackFilter);
- enhancer.setCallbacks(new Callback[]{new InterceptorBridge(target, interceptor), new EqualsHandler(), new HashCodeHandler()});
+ enhancer.setCallbacks(new Callback[] { new InterceptorBridge(target, interceptor), new EqualsHandler(),
+ new HashCodeHandler() });
return (T) enhancer.create();
}
@@ -76,21 +89,21 @@ public class CglibProxyFactory extends A
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
- public <T> T createInvokerProxy(ClassLoader classLoader, Invoker invoker,
- Class<?>... proxyClasses)
+ public <T> T createInvokerProxy(ClassLoader classLoader, Invoker invoker, Class<?>... proxyClasses)
{
final Enhancer enhancer = new Enhancer();
enhancer.setClassLoader(classLoader);
enhancer.setInterfaces(toInterfaces(proxyClasses));
enhancer.setSuperclass(getSuperclass(proxyClasses));
enhancer.setCallbackFilter(callbackFilter);
- enhancer.setCallbacks(new Callback[]{new InvokerBridge(invoker), new EqualsHandler(), new HashCodeHandler()});
+ enhancer.setCallbacks(
+ new Callback[] { new InvokerBridge(invoker), new EqualsHandler(), new HashCodeHandler() });
return (T) enhancer.create();
}
-//**********************************************************************************************************************
-// Inner Classes
-//**********************************************************************************************************************
+ //******************************************************************************************************************
+ // Inner Classes
+ //******************************************************************************************************************
private static class CglibProxyFactoryCallbackFilter implements CallbackFilter
{
@@ -133,7 +146,7 @@ public class CglibProxyFactory extends A
}
}
- private static class InterceptorBridge implements net.sf.cglib.proxy.MethodInterceptor, Serializable
+ private static class InterceptorBridge implements MethodInterceptor, Serializable
{
/** Serialization version */
private static final long serialVersionUID = 1L;
@@ -171,11 +184,8 @@ public class CglibProxyFactory extends A
}
}
- private static class MethodProxyInvocation implements Invocation, Serializable
+ private static class MethodProxyInvocation implements Invocation
{
- /** Serialization version */
- private static final long serialVersionUID = 1L;
-
private final Object proxy;
private final Object target;
private final Method method;
@@ -188,7 +198,7 @@ public class CglibProxyFactory extends A
this.target = target;
this.method = method;
this.methodProxy = methodProxy;
- this.args = ArrayUtils.clone(args);
+ this.args = ObjectUtils.defaultIfNull(ArrayUtils.clone(args), ProxyUtils.EMPTY_ARGUMENTS);
}
public Method getMethod()
Modified: commons/proper/proxy/trunk/cglib/src/test/java/org/apache/commons/proxy2/cglib/CglibProxyFactoryTest.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/cglib/src/test/java/org/apache/commons/proxy2/cglib/CglibProxyFactoryTest.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/cglib/src/test/java/org/apache/commons/proxy2/cglib/CglibProxyFactoryTest.java (original)
+++ commons/proper/proxy/trunk/cglib/src/test/java/org/apache/commons/proxy2/cglib/CglibProxyFactoryTest.java Wed Mar 26 20:20:01 2014
@@ -21,9 +21,9 @@ import org.apache.commons.proxy2.Abstrac
public class CglibProxyFactoryTest extends AbstractSubclassingProxyFactoryTestCase
{
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
+ //**********************************************************************************************************************
+ // Constructors
+ //**********************************************************************************************************************
public CglibProxyFactoryTest()
{
Modified: commons/proper/proxy/trunk/core/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/pom.xml?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/pom.xml (original)
+++ commons/proper/proxy/trunk/core/pom.xml Wed Mar 26 20:20:01 2014
@@ -59,4 +59,33 @@
</plugins>
</build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>${checkstyle.version}</version>
+ <configuration>
+ <configLocation>org/apache/commons/proxy2/checkstyle.xml</configLocation>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <configuration>
+ <!--rulesets>
+ <ruleset>/org/apache/commons/proxy2/pmd.xml</ruleset>
+ </rulesets-->
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <configuration>
+ <xmlOutput>true</xmlOutput>
+ <excludeFilterFile>/org/apache/commons/proxy2/findbugs-exclude-filter.xml</excludeFilterFile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
</project>
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/DefaultProxyFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/DefaultProxyFactory.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/DefaultProxyFactory.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/DefaultProxyFactory.java Wed Mar 26 20:20:01 2014
@@ -20,25 +20,28 @@ import java.util.Arrays;
import java.util.ServiceLoader;
/**
- * {@link ProxyFactory} implementation that delegates to the first discovered
- * {@link ProxyFactory} service provider that {@link #canProxy(Class...)}.
- *
+ * {@link ProxyFactory} implementation that delegates to the first discovered {@link ProxyFactory} service provider that
+ * {@link #canProxy(Class...)}.
+ *
* @author Matt Benson
*/
-class DefaultProxyFactory implements ProxyFactory {
+class DefaultProxyFactory implements ProxyFactory
+{
/** Shared instance */
static final DefaultProxyFactory INSTANCE = new DefaultProxyFactory();
- private static final ServiceLoader<ProxyFactory> SERVICES = ServiceLoader
- .load(ProxyFactory.class);
+ private static final ServiceLoader<ProxyFactory> SERVICES = ServiceLoader.load(ProxyFactory.class);
/**
* {@inheritDoc}
*/
@Override
- public boolean canProxy(Class<?>... proxyClasses) {
- for (ProxyFactory proxyFactory : SERVICES) {
- if (proxyFactory.canProxy(proxyClasses)) {
+ public boolean canProxy(Class<?>... proxyClasses)
+ {
+ for (ProxyFactory proxyFactory : SERVICES)
+ {
+ if (proxyFactory.canProxy(proxyClasses))
+ {
return true;
}
}
@@ -49,11 +52,10 @@ class DefaultProxyFactory implements Pro
* {@inheritDoc}
*/
@Override
- public <T> T createDelegatorProxy(ObjectProvider<?> delegateProvider,
- Class<?>... proxyClasses) {
+ public <T> T createDelegatorProxy(ObjectProvider<?> delegateProvider, Class<?>... proxyClasses)
+ {
@SuppressWarnings("unchecked")
- final T result = (T) getCapableProxyFactory(proxyClasses).createDelegatorProxy(
- delegateProvider, proxyClasses);
+ final T result = (T) getCapableProxyFactory(proxyClasses).createDelegatorProxy(delegateProvider, proxyClasses);
return result;
}
@@ -61,11 +63,12 @@ class DefaultProxyFactory implements Pro
* {@inheritDoc}
*/
@Override
- public <T> T createDelegatorProxy(ClassLoader classLoader,
- ObjectProvider<?> delegateProvider, Class<?>... proxyClasses) {
+ public <T> T createDelegatorProxy(ClassLoader classLoader, ObjectProvider<?> delegateProvider,
+ Class<?>... proxyClasses)
+ {
@SuppressWarnings("unchecked")
- final T result = (T) getCapableProxyFactory(proxyClasses).createDelegatorProxy(
- classLoader, delegateProvider, proxyClasses);
+ final T result = (T) getCapableProxyFactory(proxyClasses).createDelegatorProxy(classLoader, delegateProvider,
+ proxyClasses);
return result;
}
@@ -73,11 +76,11 @@ class DefaultProxyFactory implements Pro
* {@inheritDoc}
*/
@Override
- public <T> T createInterceptorProxy(Object target, Interceptor interceptor,
- Class<?>... proxyClasses) {
+ public <T> T createInterceptorProxy(Object target, Interceptor interceptor, Class<?>... proxyClasses)
+ {
@SuppressWarnings("unchecked")
- final T result = (T) getCapableProxyFactory(proxyClasses).createInterceptorProxy(
- target, interceptor, proxyClasses);
+ final T result = (T) getCapableProxyFactory(proxyClasses).createInterceptorProxy(target, interceptor,
+ proxyClasses);
return result;
}
@@ -85,11 +88,12 @@ class DefaultProxyFactory implements Pro
* {@inheritDoc}
*/
@Override
- public <T> T createInterceptorProxy(ClassLoader classLoader, Object target,
- Interceptor interceptor, Class<?>... proxyClasses) {
+ public <T> T createInterceptorProxy(ClassLoader classLoader, Object target, Interceptor interceptor,
+ Class<?>... proxyClasses)
+ {
@SuppressWarnings("unchecked")
- final T result = (T) getCapableProxyFactory(proxyClasses).createInterceptorProxy(
- classLoader, target, interceptor, proxyClasses);
+ final T result = (T) getCapableProxyFactory(proxyClasses).createInterceptorProxy(classLoader, target,
+ interceptor, proxyClasses);
return result;
}
@@ -97,10 +101,10 @@ class DefaultProxyFactory implements Pro
* {@inheritDoc}
*/
@Override
- public <T> T createInvokerProxy(Invoker invoker, Class<?>... proxyClasses) {
+ public <T> T createInvokerProxy(Invoker invoker, Class<?>... proxyClasses)
+ {
@SuppressWarnings("unchecked")
- final T result = (T) getCapableProxyFactory(proxyClasses).createInvokerProxy(
- invoker, proxyClasses);
+ final T result = (T) getCapableProxyFactory(proxyClasses).createInvokerProxy(invoker, proxyClasses);
return result;
}
@@ -108,21 +112,23 @@ class DefaultProxyFactory implements Pro
* {@inheritDoc}
*/
@Override
- public <T> T createInvokerProxy(ClassLoader classLoader, Invoker invoker,
- Class<?>... proxyClasses) {
+ public <T> T createInvokerProxy(ClassLoader classLoader, Invoker invoker, Class<?>... proxyClasses)
+ {
@SuppressWarnings("unchecked")
- final T result = (T) getCapableProxyFactory(proxyClasses).createInvokerProxy(
- classLoader, invoker, proxyClasses);
+ final T result = (T) getCapableProxyFactory(proxyClasses)
+ .createInvokerProxy(classLoader, invoker, proxyClasses);
return result;
}
- private ProxyFactory getCapableProxyFactory(Class<?>... proxyClasses) {
- for (ProxyFactory proxyFactory : SERVICES) {
- if (proxyFactory.canProxy(proxyClasses)) {
+ private ProxyFactory getCapableProxyFactory(Class<?>... proxyClasses)
+ {
+ for (ProxyFactory proxyFactory : SERVICES)
+ {
+ if (proxyFactory.canProxy(proxyClasses))
+ {
return proxyFactory;
}
}
- throw new IllegalArgumentException("Could not proxy "
- + Arrays.toString(proxyClasses));
+ throw new IllegalArgumentException("Could not proxy " + Arrays.toString(proxyClasses));
}
}
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/Interceptor.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/Interceptor.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/Interceptor.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/Interceptor.java Wed Mar 26 20:20:01 2014
@@ -21,21 +21,22 @@ import java.io.Serializable;
/**
* "Intercepts" a method invocation.
- *
+ *
* @author James Carman
* @since 1.0
*/
public interface Interceptor extends Serializable
{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
+ //******************************************************************************************************************
+ // Other Methods
+ //******************************************************************************************************************
/**
* Intercept the specified {@link Invocation}.
+ *
* @param invocation
* @return return value of the method
* @throws Throwable
*/
- Object intercept( Invocation invocation ) throws Throwable;
+ Object intercept(Invocation invocation) throws Throwable;
}
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/Invocation.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/Invocation.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/Invocation.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/Invocation.java Wed Mar 26 20:20:01 2014
@@ -21,43 +21,44 @@ import java.lang.reflect.Method;
/**
* Method invocation for use by an {@link Interceptor}.
- *
+ *
* @author James Carman
* @since 1.0
*/
public interface Invocation
{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
+ //******************************************************************************************************************
+ // Other Methods
+ //******************************************************************************************************************
/**
- * Returns the arguments being passed to this method invocation. Changes in the elements of this array will be
+ * Returns the arguments being passed to this method invocation. Changes in the elements of this array will be
* propagated to the recipient of this invocation.
- *
+ *
* @return the arguments being passed to this method invocation
*/
Object[] getArguments();
/**
* Returns the method being called.
- *
+ *
* @return the method being called
*/
Method getMethod();
/**
* Returns the proxy object on which this invocation was invoked.
- *
+ *
* @return the proxy object on which this invocation was invoked
*/
Object getProxy();
/**
* Called in order to let the invocation proceed.
- *
+ *
* @return the return value of the invocation
- * @throws Throwable any exception or error that was thrown as a result of this invocation
+ * @throws Throwable
+ * any exception or error that was thrown as a result of this invocation
*/
Object proceed() throws Throwable;
}
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/Invoker.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/Invoker.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/Invoker.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/Invoker.java Wed Mar 26 20:20:01 2014
@@ -22,25 +22,29 @@ import java.lang.reflect.Method;
/**
* An invoker is responsible for handling a method invocation.
- *
+ *
* @author James Carman
* @since 1.0
*/
public interface Invoker extends Serializable
{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
+ //******************************************************************************************************************
+ // Other Methods
+ //******************************************************************************************************************
/**
- * "Invokes" the method. Implementation should throw a {@link org.apache.commons.proxy2.exception.InvokerException}
+ * "Invokes" the method. Implementation should throw a {@link org.apache.commons.proxy2.exception.InvokerException}
* if problems arise while trying to invoke the method.
- *
- * @param proxy the proxy2 object
- * @param method the method being invoked
- * @param arguments the arguments
+ *
+ * @param proxy
+ * the proxy2 object
+ * @param method
+ * the method being invoked
+ * @param arguments
+ * the arguments
* @return the return value
- * @throws Throwable thrown by the implementation
+ * @throws Throwable
+ * thrown by the implementation
*/
- Object invoke( Object proxy, Method method, Object[] arguments ) throws Throwable;
+ Object invoke(Object proxy, Method method, Object[] arguments) throws Throwable;
}
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/ObjectProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/ObjectProvider.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/ObjectProvider.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/ObjectProvider.java Wed Mar 26 20:20:01 2014
@@ -17,23 +17,25 @@
package org.apache.commons.proxy2;
+import java.io.Serializable;
+
/**
* Provides an object to a delegating proxy.
- *
+ *
* @author James Carman
* @since 1.0
*/
-public interface ObjectProvider<T>
+public interface ObjectProvider<T> extends Serializable
{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
+ //******************************************************************************************************************
+ // Other Methods
+ //******************************************************************************************************************
/**
- * Returns an object. Implementing classes should throw a
+ * Returns an object. Implementing classes should throw a
* {@link org.apache.commons.proxy2.exception.ObjectProviderException} if any problems arise while
* constructing/finding the object.
- *
+ *
* @return the object on which the method should be called
*/
T getObject();
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/ProxyFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/ProxyFactory.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/ProxyFactory.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/ProxyFactory.java Wed Mar 26 20:20:01 2014
@@ -19,88 +19,104 @@ package org.apache.commons.proxy2;
/**
* ProxyFactory interface.
+ *
* @since 2.0
*/
public interface ProxyFactory
{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
+ //******************************************************************************************************************
+ // Other Methods
+ //******************************************************************************************************************
/**
* Learn whether this {@link ProxyFactory} is capable of creating a proxy for the specified set of classes.
- *
- * @param proxyClasses the proxy2 classes
+ *
+ * @param proxyClasses
+ * the proxy2 classes
* @return boolean
*/
- boolean canProxy( Class<?>... proxyClasses );
+ boolean canProxy(Class<?>... proxyClasses);
/**
- * Creates a proxy which delegates to the object provided by <code>delegateProvider</code>. The proxy will be
+ * Creates a proxy which delegates to the object provided by <code>delegateProvider</code>. The proxy will be
* generated using the current thread's "context class loader."
- *
- * @param delegateProvider the delegate provider
- * @param proxyClasses the interfaces that the proxy should implement
+ *
+ * @param delegateProvider
+ * the delegate provider
+ * @param proxyClasses
+ * the interfaces that the proxy should implement
* @return a proxy which delegates to the object provided by the target object provider
*/
- <T> T createDelegatorProxy( ObjectProvider<?> delegateProvider, Class<?>... proxyClasses );
+ <T> T createDelegatorProxy(ObjectProvider<?> delegateProvider, Class<?>... proxyClasses);
/**
* Creates a proxy which delegates to the object provided by <code>delegateProvider</code>.
- *
- * @param classLoader the class loader to use when generating the proxy
- * @param delegateProvider the delegate provider
- * @param proxyClasses the interfaces that the proxy should implement
+ *
+ * @param classLoader
+ * the class loader to use when generating the proxy
+ * @param delegateProvider
+ * the delegate provider
+ * @param proxyClasses
+ * the interfaces that the proxy should implement
* @return a proxy which delegates to the object provided by the target <code>delegateProvider>
*/
- <T> T createDelegatorProxy( ClassLoader classLoader, ObjectProvider<?> delegateProvider,
- Class<?>... proxyClasses );
+ <T> T createDelegatorProxy(ClassLoader classLoader, ObjectProvider<?> delegateProvider, Class<?>... proxyClasses);
/**
* Creates a proxy which passes through a {@link Interceptor interceptor} before eventually reaching the
- * <code>target</code> object. The proxy will be generated using the current thread's "context class loader."
- *
- * @param target the target object
- * @param interceptor the method interceptor
- * @param proxyClasses the interfaces that the proxy should implement
+ * <code>target</code> object. The proxy will be generated using the current thread's "context class loader."
+ *
+ * @param target
+ * the target object
+ * @param interceptor
+ * the method interceptor
+ * @param proxyClasses
+ * the interfaces that the proxy should implement
* @return a proxy which passes through a {@link Interceptor interceptor} before eventually reaching the
* <code>target</code> object.
*/
- <T> T createInterceptorProxy( Object target, Interceptor interceptor,
- Class<?>... proxyClasses );
+ <T> T createInterceptorProxy(Object target, Interceptor interceptor, Class<?>... proxyClasses);
/**
* Creates a proxy which passes through a {@link Interceptor interceptor} before eventually reaching the
* <code>target</code> object.
- *
- * @param classLoader the class loader to use when generating the proxy
- * @param target the target object
- * @param interceptor the method interceptor
- * @param proxyClasses the interfaces that the proxy should implement.
+ *
+ * @param classLoader
+ * the class loader to use when generating the proxy
+ * @param target
+ * the target object
+ * @param interceptor
+ * the method interceptor
+ * @param proxyClasses
+ * the interfaces that the proxy should implement.
* @return a proxy which passes through a {@link Interceptor interceptor} before eventually reaching the
* <code>target</code> object.
*/
- <T> T createInterceptorProxy( ClassLoader classLoader, Object target, Interceptor interceptor,
- Class<?>... proxyClasses );
+ <T> T createInterceptorProxy(ClassLoader classLoader, Object target, Interceptor interceptor,
+ Class<?>... proxyClasses);
/**
- * Creates a proxy which uses the provided {@link Invoker} to handle all method invocations. The proxy will be
+ * Creates a proxy which uses the provided {@link Invoker} to handle all method invocations. The proxy will be
* generated using the current thread's "context class loader."
- *
- * @param invoker the invoker
- * @param proxyClasses the interfaces that the proxy should implement
+ *
+ * @param invoker
+ * the invoker
+ * @param proxyClasses
+ * the interfaces that the proxy should implement
* @return a proxy which uses the provided {@link Invoker} to handle all method invocations
*/
- <T> T createInvokerProxy( Invoker invoker, Class<?>... proxyClasses );
+ <T> T createInvokerProxy(Invoker invoker, Class<?>... proxyClasses);
/**
* Creates a proxy which uses the provided {@link Invoker} to handle all method invocations.
- *
- * @param classLoader the class loader to use when generating the proxy
- * @param invoker the invoker
- * @param proxyClasses the interfaces that the proxy should implement
+ *
+ * @param classLoader
+ * the class loader to use when generating the proxy
+ * @param invoker
+ * the invoker
+ * @param proxyClasses
+ * the interfaces that the proxy should implement
* @return a proxy which uses the provided {@link Invoker} to handle all method invocations
*/
- <T> T createInvokerProxy( ClassLoader classLoader, Invoker invoker,
- Class<?>... proxyClasses );
+ <T> T createInvokerProxy(ClassLoader classLoader, Invoker invoker, Class<?>... proxyClasses);
}
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/ProxyUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/ProxyUtils.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/ProxyUtils.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/ProxyUtils.java Wed Mar 26 20:20:01 2014
@@ -25,24 +25,24 @@ import java.util.Map;
/**
* Provides some helpful proxy utility methods.
- *
+ *
* @author James Carman
* @since 1.0
*/
public final class ProxyUtils
{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
+ //******************************************************************************************************************
+ // Fields
+ //******************************************************************************************************************
public static final Object[] EMPTY_ARGUMENTS = new Object[0];
public static final Class<?>[] EMPTY_ARGUMENT_TYPES = new Class[0];
private static final Map<Class<?>, Class<?>> WRAPPER_CLASS_MAP = new HashMap<Class<?>, Class<?>>();
private static final Map<Class<?>, Object> NULL_VALUE_MAP = new HashMap<Class<?>, Object>();
-//**********************************************************************************************************************
-// Static Methods
-//**********************************************************************************************************************
+ //******************************************************************************************************************
+ // Static Methods
+ //******************************************************************************************************************
static
{
@@ -69,17 +69,23 @@ public final class ProxyUtils
}
/**
- * <p>Gets an array of {@link Class} objects representing all interfaces implemented by the given class and its
- * superclasses.</p>
+ * <p>
+ * Gets an array of {@link Class} objects representing all interfaces implemented by the given class and its
+ * superclasses.
+ * </p>
* <p/>
- * <p>The order is determined by looking through each interface in turn as declared in the source file and following
+ * <p>
+ * The order is determined by looking through each interface in turn as declared in the source file and following
* its hierarchy up. Then each superclass is considered in the same way. Later duplicates are ignored, so the order
- * is maintained.</p>
+ * is maintained.
+ * </p>
* <p/>
- * <b>Note</b>: Implementation of this method was "borrowed" from
- * <a href="http://commons.apache.org/lang/">Apache Commons Lang</a> to avoid a dependency.</p>
- *
- * @param cls the class to look up, may be <code>null</code>
+ * <b>Note</b>: Implementation of this method was "borrowed" from <a href="http://commons.apache.org/lang/">Apache
+ * Commons Lang</a> to avoid a dependency.
+ * </p>
+ *
+ * @param cls
+ * the class to look up, may be <code>null</code>
* @return an array of {@link Class} objects representing all interfaces implemented by the given class and its
* superclasses or <code>null</code> if input class is null.
*/
@@ -115,10 +121,15 @@ public final class ProxyUtils
/**
* Returns the class name as you would expect to see it in Java code.
* <p/>
- * <b>Examples:</b> <ul> <li>getJavaClassName( Object[].class ) == "Object[]"</li> <li>getJavaClassName(
- * Object[][].class ) == "Object[][]"</li> <li>getJavaClassName( Integer.TYPE ) == "int"</li> </p>
- *
- * @param clazz the class
+ * <b>Examples:</b>
+ * <ul>
+ * <li>getJavaClassName( Object[].class ) == "Object[]"</li>
+ * <li>getJavaClassName( Object[][].class ) == "Object[][]"</li>
+ * <li>getJavaClassName( Integer.TYPE ) == "int"</li>
+ * </p>
+ *
+ * @param clazz
+ * the class
* @return the class' name as you would expect to see it in Java code
*/
public static String getJavaClassName(Class<?> clazz)
@@ -132,8 +143,9 @@ public final class ProxyUtils
/**
* Returns the wrapper class for the given primitive type.
- *
- * @param primitiveType the primitive type
+ *
+ * @param primitiveType
+ * the primitive type
* @return the wrapper class
*/
public static Class<?> getWrapperClass(Class<?> primitiveType)
@@ -143,8 +155,9 @@ public final class ProxyUtils
/**
* Returns the proper "null value" as specified by the Java language.
- *
- * @param type the type
+ *
+ * @param type
+ * the type
* @return the null value
*/
@SuppressWarnings("unchecked")
@@ -155,38 +168,42 @@ public final class ProxyUtils
/**
* Learn whether the specified method is/overrides {@link Object#equals(Object)}.
- * @param method to compare
+ *
+ * @param method
+ * to compare
* @return <code>true</code> for a method with signature <code>boolean equals(Object)</code>
*/
public static boolean isEqualsMethod(Method method)
{
- return "equals".equals(method.getName()) &&
- Boolean.TYPE.equals(method.getReturnType()) &&
- method.getParameterTypes().length == 1 &&
- Object.class.equals(method.getParameterTypes()[0]);
+ return "equals".equals(method.getName()) && Boolean.TYPE.equals(method.getReturnType())
+ && method.getParameterTypes().length == 1 && Object.class.equals(method.getParameterTypes()[0]);
}
/**
* Learn whether the specified method is/overrides {@link Object#hashCode()}.
- * @param method to compare
+ *
+ * @param method
+ * to compare
* @return true for a method with signature <code>int hashCode()</code>
*/
public static boolean isHashCode(Method method)
{
- return "hashCode".equals(method.getName()) &&
- Integer.TYPE.equals(method.getReturnType()) &&
- method.getParameterTypes().length == 0;
+ return "hashCode".equals(method.getName()) && Integer.TYPE.equals(method.getReturnType())
+ && method.getParameterTypes().length == 0;
}
/**
* Get a {@link ProxyFactory} that delegates to discoverable {@link ProxyFactory} service providers.
+ *
* @return {@link ProxyFactory}
*/
- public static ProxyFactory proxyFactory() {
+ public static ProxyFactory proxyFactory()
+ {
return DefaultProxyFactory.INSTANCE;
}
- private ProxyUtils() {
+ private ProxyUtils()
+ {
// Hiding constructor in utility class!
}
}
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/exception/InvokerException.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/exception/InvokerException.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/exception/InvokerException.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/exception/InvokerException.java Wed Mar 26 20:20:01 2014
@@ -19,7 +19,7 @@ package org.apache.commons.proxy2.except
/**
* To be used by an {@link org.apache.commons.proxy2.Invoker} when they encounter an error.
- *
+ *
* @author James Carman
* @since 1.0
*/
@@ -28,9 +28,9 @@ public class InvokerException extends Ru
/** Serialization version */
private static final long serialVersionUID = -1L;
- //**********************************************************************************************************************
- // Constructors
- //**********************************************************************************************************************
+ //******************************************************************************************************************
+ // Constructors
+ //******************************************************************************************************************
/**
* Create a new InvokerException instance.
@@ -41,28 +41,31 @@ public class InvokerException extends Ru
/**
* Create a new InvokerException instance.
+ *
* @param message
*/
- public InvokerException( String message )
+ public InvokerException(String message)
{
super(message);
}
/**
* Create a new InvokerException instance.
+ *
* @param cause
*/
- public InvokerException( Throwable cause )
+ public InvokerException(Throwable cause)
{
super(cause);
}
/**
* Create a new InvokerException instance.
+ *
* @param message
* @param cause
*/
- public InvokerException( String message, Throwable cause )
+ public InvokerException(String message, Throwable cause)
{
super(message, cause);
}
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/exception/ObjectProviderException.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/exception/ObjectProviderException.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/exception/ObjectProviderException.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/exception/ObjectProviderException.java Wed Mar 26 20:20:01 2014
@@ -20,7 +20,7 @@ package org.apache.commons.proxy2.except
/**
* {@link org.apache.commons.proxy2.ObjectProvider} implementations should throw this exception type to indicate that
* there was a problem creating/finding the object.
- *
+ *
* @author James Carman
* @since 1.0
*/
@@ -29,9 +29,9 @@ public class ObjectProviderException ext
/** Serialization version */
private static final long serialVersionUID = -1L;
- //**********************************************************************************************************************
- // Constructors
- //**********************************************************************************************************************
+ //******************************************************************************************************************
+ // Constructors
+ //******************************************************************************************************************
/**
* Create a new ObjectProviderException instance.
@@ -42,29 +42,55 @@ public class ObjectProviderException ext
/**
* Create a new ObjectProviderException instance.
+ *
* @param message
*/
- public ObjectProviderException( String message )
+ public ObjectProviderException(String message)
{
super(message);
}
/**
+ * Create a new ObjectProviderException instance using {@link String#format(String, Object...)} for the message.
+ *
+ * @param message
+ * @param arguments
+ */
+ public ObjectProviderException(String message, Object... arguments)
+ {
+ super(String.format(message, arguments));
+ }
+
+ /**
* Create a new ObjectProviderException instance.
+ *
* @param cause
*/
- public ObjectProviderException( Throwable cause )
+ public ObjectProviderException(Throwable cause)
{
super(cause);
}
/**
* Create a new ObjectProviderException instance.
+ *
* @param message
* @param cause
*/
- public ObjectProviderException( String message, Throwable cause )
+ public ObjectProviderException(String message, Throwable cause)
{
super(message, cause);
}
+
+ /**
+ * Create a new ObjectProviderException instance using {@link String#format(String, Object...)} for the message.
+ *
+ * @param cause
+ * @param message
+ * @param arguments
+ */
+ public ObjectProviderException(Throwable cause, String message, Object... arguments)
+ {
+ super(String.format(message, arguments), cause);
+ }
}
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/exception/ProxyFactoryException.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/exception/ProxyFactoryException.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/exception/ProxyFactoryException.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/exception/ProxyFactoryException.java Wed Mar 26 20:20:01 2014
@@ -20,7 +20,7 @@ package org.apache.commons.proxy2.except
/**
* A runtime exception type to be used by {@link org.apache.commons.proxy2.ProxyFactory proxy factories} when a problem
* occurs.
- *
+ *
* @author James Carman
* @since 1.0
*/
@@ -29,9 +29,9 @@ public class ProxyFactoryException exten
/** Serialization version */
private static final long serialVersionUID = -1L;
- //**********************************************************************************************************************
- // Constructors
- //**********************************************************************************************************************
+ //******************************************************************************************************************
+ // Constructors
+ //******************************************************************************************************************
/**
* Create a new ProxyFactoryException instance.
@@ -42,28 +42,31 @@ public class ProxyFactoryException exten
/**
* Create a new ProxyFactoryException instance.
+ *
* @param message
*/
- public ProxyFactoryException( String message )
+ public ProxyFactoryException(String message)
{
super(message);
}
/**
* Create a new ProxyFactoryException instance.
+ *
* @param cause
*/
- public ProxyFactoryException( Throwable cause )
+ public ProxyFactoryException(Throwable cause)
{
super(cause);
}
/**
* Create a new ProxyFactoryException instance.
+ *
* @param message
* @param cause
*/
- public ProxyFactoryException( String message, Throwable cause )
+ public ProxyFactoryException(String message, Throwable cause)
{
super(message, cause);
}
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/impl/AbstractProxyClassGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/impl/AbstractProxyClassGenerator.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/impl/AbstractProxyClassGenerator.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/impl/AbstractProxyClassGenerator.java Wed Mar 26 20:20:01 2014
@@ -19,51 +19,57 @@ package org.apache.commons.proxy2.impl;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.util.*;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
/**
* A useful superclass for {@link ProxyClassGenerator} implementations.
- *
+ *
* @author James Carman
* @since 1.0
*/
public abstract class AbstractProxyClassGenerator implements ProxyClassGenerator
{
-//**********************************************************************************************************************
-// Static Methods
-//**********************************************************************************************************************
+ //******************************************************************************************************************
+ // Static Methods
+ //******************************************************************************************************************
/**
- * Returns all methods that a proxy class must implement from the proxy interfaces. This method makes sure there
- * are no method signature clashes. For methods with the same signature (name and parameter types), the one
- * encountered first will be returned in the result. Final methods are also excluded from the result.
- *
- * @param proxyClasses the interfaces the proxy class must implement
+ * Returns all methods that a proxy class must implement from the proxy interfaces. This method makes sure there are
+ * no method signature clashes. For methods with the same signature (name and parameter types), the one encountered
+ * first will be returned in the result. Final methods are also excluded from the result.
+ *
+ * @param proxyClasses
+ * the interfaces the proxy class must implement
* @return all methods that the proxy class must implement
*/
- public static Method[] getImplementationMethods( Class<?>[] proxyClasses )
+ public static Method[] getImplementationMethods(Class<?>[] proxyClasses)
{
final Map<MethodSignature, Method> signatureMethodMap = new HashMap<MethodSignature, Method>();
final Set<MethodSignature> finalizedSignatures = new HashSet<MethodSignature>();
- for( int i = 0; i < proxyClasses.length; i++ )
+ for (int i = 0; i < proxyClasses.length; i++)
{
Class<?> proxyInterface = proxyClasses[i];
final Method[] methods = proxyInterface.getMethods();
- for( int j = 0; j < methods.length; j++ )
+ for (int j = 0; j < methods.length; j++)
{
final MethodSignature signature = new MethodSignature(methods[j]);
- if( Modifier.isFinal(methods[j].getModifiers()) )
+ if (Modifier.isFinal(methods[j].getModifiers()))
{
finalizedSignatures.add(signature);
}
- else if( !signatureMethodMap.containsKey(signature) )
+ else if (!signatureMethodMap.containsKey(signature))
{
signatureMethodMap.put(signature, methods[j]);
}
}
}
final Collection<Method> resultingMethods = signatureMethodMap.values();
- for (MethodSignature signature : finalizedSignatures) {
+ for (MethodSignature signature : finalizedSignatures)
+ {
resultingMethods.remove(signatureMethodMap.get(signature));
}
return resultingMethods.toArray(new Method[resultingMethods.size()]);
Modified: commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/impl/AbstractProxyFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/impl/AbstractProxyFactory.java?rev=1582033&r1=1582032&r2=1582033&view=diff
==============================================================================
--- commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/impl/AbstractProxyFactory.java (original)
+++ commons/proper/proxy/trunk/core/src/main/java/org/apache/commons/proxy2/impl/AbstractProxyFactory.java Wed Mar 26 20:20:01 2014
@@ -23,23 +23,23 @@ import org.apache.commons.proxy2.ObjectP
import org.apache.commons.proxy2.ProxyFactory;
/**
- * Base abstract {@link ProxyFactory} implementation, primarily providing
- * implementations of the interface methods that are typically convenience
- * constructs over the other methods.
+ * Base abstract {@link ProxyFactory} implementation, primarily providing implementations of the interface methods that
+ * are typically convenience constructs over the other methods.
*/
public abstract class AbstractProxyFactory implements ProxyFactory
{
/**
* Returns true if all <code>proxyClasses</code> are interfaces.
- *
- * @param proxyClasses the proxy classes
+ *
+ * @param proxyClasses
+ * the proxy classes
* @return true if all <code>proxyClasses</code> are interfaces
*/
- public boolean canProxy( Class<?>... proxyClasses )
+ public boolean canProxy(Class<?>... proxyClasses)
{
- for( Class<?> proxyClass : proxyClasses )
+ for (Class<?> proxyClass : proxyClasses)
{
- if( !proxyClass.isInterface() )
+ if (!proxyClass.isInterface())
{
return false;
}
@@ -48,47 +48,52 @@ public abstract class AbstractProxyFacto
}
/**
- * Creates a proxy which delegates to the object provided by <code>delegateProvider</code>. The proxy will be
+ * Creates a proxy which delegates to the object provided by <code>delegateProvider</code>. The proxy will be
* generated using the current thread's "context class loader."
- *
- * @param delegateProvider the delegate provider
- * @param proxyClasses the interfaces that the proxy should implement
+ *
+ * @param delegateProvider
+ * the delegate provider
+ * @param proxyClasses
+ * the interfaces that the proxy should implement
* @return a proxy which delegates to the object provided by the target object provider
*/
- public <T> T createDelegatorProxy( ObjectProvider<?> delegateProvider, Class<?>... proxyClasses )
+ public <T> T createDelegatorProxy(ObjectProvider<?> delegateProvider, Class<?>... proxyClasses)
{
return createDelegatorProxy(Thread.currentThread().getContextClassLoader(), delegateProvider, proxyClasses);
}
/**
* Creates a proxy which passes through a {@link Interceptor interceptor} before eventually reaching the
- * <code>target</code> object. The proxy will be generated using the current thread's "context class loader."
- *
- * @param target the target object
- * @param interceptor the method interceptor
- * @param proxyClasses the interfaces that the proxy should implement
+ * <code>target</code> object. The proxy will be generated using the current thread's "context class loader."
+ *
+ * @param target
+ * the target object
+ * @param interceptor
+ * the method interceptor
+ * @param proxyClasses
+ * the interfaces that the proxy should implement
* @return a proxy which passes through a {@link Interceptor interceptor} before eventually reaching the
* <code>target</code> object.
*/
- public <T> T createInterceptorProxy( Object target, Interceptor interceptor,
- Class<?>... proxyClasses )
+ public <T> T createInterceptorProxy(Object target, Interceptor interceptor, Class<?>... proxyClasses)
{
return createInterceptorProxy(Thread.currentThread().getContextClassLoader(), target, interceptor,
- proxyClasses);
+ proxyClasses);
}
/**
- * Creates a proxy which uses the provided {@link Invoker} to handle all method invocations. The proxy will be
+ * Creates a proxy which uses the provided {@link Invoker} to handle all method invocations. The proxy will be
* generated using the current thread's "context class loader."
- *
- * @param invoker the invoker
- * @param proxyClasses the interfaces that the proxy should implement
+ *
+ * @param invoker
+ * the invoker
+ * @param proxyClasses
+ * the interfaces that the proxy should implement
* @return a proxy which uses the provided {@link Invoker} to handle all method invocations
*/
- public <T> T createInvokerProxy( Invoker invoker, Class<?>... proxyClasses )
+ public <T> T createInvokerProxy(Invoker invoker, Class<?>... proxyClasses)
{
- return createInvokerProxy(Thread.currentThread().getContextClassLoader(), invoker,
- proxyClasses);
+ return createInvokerProxy(Thread.currentThread().getContextClassLoader(), invoker, proxyClasses);
}
}