You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by li...@apache.org on 2012/05/01 02:08:02 UTC
[2/3] git commit: Fixing equals for another instance of
AnnotationInstanceProvider
Fixing equals for another instance of AnnotationInstanceProvider
Project: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/commit/2a5d1809
Tree: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/tree/2a5d1809
Diff: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/diff/2a5d1809
Branch: refs/heads/master
Commit: 2a5d18093a51417eae73969b0a2ef14c47a9414f
Parents: a6927dc
Author: Jason Porter <li...@apache.org>
Authored: Mon Apr 30 12:50:11 2012 -0600
Committer: Jason Porter <li...@apache.org>
Committed: Mon Apr 30 18:07:35 2012 -0600
----------------------------------------------------------------------
.../util/metadata/AnnotationInstanceProvider.java | 20 ++++++++++----
1 files changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/2a5d1809/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/metadata/AnnotationInstanceProvider.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/metadata/AnnotationInstanceProvider.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/metadata/AnnotationInstanceProvider.java
index e4445ca..7d4cfdc 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/metadata/AnnotationInstanceProvider.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/metadata/AnnotationInstanceProvider.java
@@ -16,9 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
+
package org.apache.deltaspike.core.util.metadata;
+import org.apache.deltaspike.core.util.ClassUtils;
+
import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationHandler;
@@ -28,8 +31,6 @@ import java.util.Map;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
-import org.apache.deltaspike.core.util.ClassUtils;
-
/**
* <p>A small helper class to create an Annotation instance of the given annotation class
* via {@link java.lang.reflect.Proxy}. The annotation literal gets filled with the default values.</p>
@@ -44,7 +45,6 @@ import org.apache.deltaspike.core.util.ClassUtils;
* (Class<? extends Annotation>) ClassUtils.getClassLoader(null).loadClass(annotationClassName);
* Annotation a = DefaultAnnotation.of(annotationClass)
* </pre>
- *
*/
public class AnnotationInstanceProvider implements Annotation, InvocationHandler, Serializable
{
@@ -54,7 +54,7 @@ public class AnnotationInstanceProvider implements Annotation, InvocationHandler
// NOTE that this cache needs to be a WeakHashMap in order to prevent a memory leak
// (the garbage collector should be able to remove the ClassLoader).
private static volatile Map<ClassLoader, Map<String, Annotation>> annotationCache
- = new WeakHashMap<ClassLoader, Map<String, Annotation>>();
+ = new WeakHashMap<ClassLoader, Map<String, Annotation>>();
private Class<? extends Annotation> annotationClass;
@@ -73,8 +73,9 @@ public class AnnotationInstanceProvider implements Annotation, InvocationHandler
/**
* Creates an annotation instance for the given annotation class
+ *
* @param annotationClass type of the target annotation
- * @param <T> current type
+ * @param <T> current type
* @return annotation instance for the given type
*/
public static <T extends Annotation> T of(Class<T> annotationClass)
@@ -149,6 +150,13 @@ public class AnnotationInstanceProvider implements Annotation, InvocationHandler
}
else if ("equals".equals(method.getName()))
{
+ if (Proxy.isProxyClass(args[0].getClass()))
+ {
+ if (Proxy.getInvocationHandler(args[0]) instanceof AnnotationInstanceProvider)
+ {
+ return equals(Proxy.getInvocationHandler(args[0]));
+ }
+ }
return equals(args[0]);
}
else if ("annotationType".equals(method.getName()))
@@ -174,7 +182,7 @@ public class AnnotationInstanceProvider implements Annotation, InvocationHandler
/**
* Copied from Apache OWB (javax.enterprise.util.AnnotationLiteral#toString())
- * with minor changes.
+ * with minor changes.
*
* @return the current state of the annotation as string
*/