You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by rm...@apache.org on 2013/01/05 18:52:59 UTC

svn commit: r1429336 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation: AbstractAnnotationLiteral.java AnyLiteral.java DefaultLiteral.java RequestedScopeLiteral.java SessionScopeLiteral.java

Author: rmannibucau
Date: Sat Jan  5 17:52:58 2013
New Revision: 1429336

URL: http://svn.apache.org/viewvc?rev=1429336&view=rev
Log:
OWB-750 correct implementation of equals for our annotationlitterals

Added:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AbstractAnnotationLiteral.java
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnyLiteral.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/DefaultLiteral.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/RequestedScopeLiteral.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/SessionScopeLiteral.java

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AbstractAnnotationLiteral.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AbstractAnnotationLiteral.java?rev=1429336&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AbstractAnnotationLiteral.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AbstractAnnotationLiteral.java Sat Jan  5 17:52:58 2013
@@ -0,0 +1,41 @@
+/*
+ * 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.webbeans.annotation;
+
+import javax.enterprise.util.AnnotationLiteral;
+import java.lang.annotation.Annotation;
+
+public class AbstractAnnotationLiteral<T extends Annotation> extends AnnotationLiteral<T>
+{
+    @Override
+    public int hashCode()
+    {
+        // implemented for performance reasons
+        // currently this is needed because AnnotationLiteral always returns 0 as hashCode
+        return 0;
+    }
+
+    @Override
+    public boolean equals(final Object other)
+    {
+        // implemented for performance reasons
+        return Annotation.class.isInstance(other) &&
+                Annotation.class.cast(other).annotationType().equals(annotationType());
+    }
+}

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnyLiteral.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnyLiteral.java?rev=1429336&r1=1429335&r2=1429336&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnyLiteral.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnyLiteral.java Sat Jan  5 17:52:58 2013
@@ -19,33 +19,13 @@
 package org.apache.webbeans.annotation;
 
 import javax.enterprise.inject.Any;
-import javax.enterprise.util.AnnotationLiteral;
 
-public class AnyLiteral extends AnnotationLiteral<Any> implements Any
+public class AnyLiteral extends AbstractAnnotationLiteral<Any> implements Any
 {
     private static final String TOSTRING = "@javax.enterprise.inject.Any()";
     private static final long serialVersionUID = -8922048102786275371L;
 
     @Override
-    public int hashCode()
-    {
-        // implemented for performance reasons
-        // currently this is needed because AnnotationLiteral always returns 0 as hashCode
-        return 0;
-    }
-
-    @Override
-    public boolean equals(Object other)
-    {
-        // implemented for performance reasons
-        if (other instanceof Any)
-        {
-            return true;
-        }
-        return false;
-    }
-
-    @Override
     public String toString()
     {
         // implemented for performance reasons

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/DefaultLiteral.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/DefaultLiteral.java?rev=1429336&r1=1429335&r2=1429336&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/DefaultLiteral.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/DefaultLiteral.java Sat Jan  5 17:52:58 2013
@@ -19,38 +19,18 @@
 package org.apache.webbeans.annotation;
 
 import javax.enterprise.inject.Default;
-import javax.enterprise.util.AnnotationLiteral;
 
 /**
  * {@link Default} literal annotation.
  * 
  * @since 1.0
  */
-public class DefaultLiteral extends AnnotationLiteral<Default> implements Default
+public class DefaultLiteral extends AbstractAnnotationLiteral<Default> implements Default
 {
     private static final String TOSTRING = "@javax.enterprise.inject.Default()";
     private static final long serialVersionUID = 6788272256977634238L;
 
     @Override
-    public int hashCode()
-    {
-        // implemented for performance reasons
-        // currently this is needed because AnnotationLiteral always returns 0 as hashCode
-        return 0;
-    }
-
-    @Override
-    public boolean equals(Object other)
-    {
-        // implemented for performance reasons
-        if (other instanceof Default)
-        {
-            return true;
-        }
-        return false;
-    }
-
-    @Override
     public String toString()
     {
         // implemented for performance reasons

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/RequestedScopeLiteral.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/RequestedScopeLiteral.java?rev=1429336&r1=1429335&r2=1429336&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/RequestedScopeLiteral.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/RequestedScopeLiteral.java Sat Jan  5 17:52:58 2013
@@ -19,7 +19,6 @@
 package org.apache.webbeans.annotation;
 
 import javax.enterprise.context.RequestScoped;
-import javax.enterprise.util.AnnotationLiteral;
 
 /**
  * {@link RequestScoped} literal annotation.
@@ -27,7 +26,7 @@ import javax.enterprise.util.AnnotationL
  * @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
  * @since 1.0
  */
-public class RequestedScopeLiteral extends AnnotationLiteral<RequestScoped> implements RequestScoped
+public class RequestedScopeLiteral extends AbstractAnnotationLiteral<RequestScoped> implements RequestScoped
 {
 
     private static final long serialVersionUID = -7333612898060695008L;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/SessionScopeLiteral.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/SessionScopeLiteral.java?rev=1429336&r1=1429335&r2=1429336&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/SessionScopeLiteral.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/SessionScopeLiteral.java Sat Jan  5 17:52:58 2013
@@ -19,7 +19,6 @@
 package org.apache.webbeans.annotation;
 
 import javax.enterprise.context.SessionScoped;
-import javax.enterprise.util.AnnotationLiteral;
 
 /**
  * {@link javax.enterprise.context.RequestScoped} literal annotation.
@@ -27,7 +26,7 @@ import javax.enterprise.util.AnnotationL
  * @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
  * @since 1.0
  */
-public class SessionScopeLiteral extends AnnotationLiteral<SessionScoped> implements SessionScoped
+public class SessionScopeLiteral extends AbstractAnnotationLiteral<SessionScoped> implements SessionScoped
 {
 
     private static final long serialVersionUID = -7469945140661485990L;