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

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

Author: struberg
Date: Sat Jan  5 18:04:06 2013
New Revision: 1429345

URL: http://svn.apache.org/viewvc?rev=1429345&view=rev
Log:
OWB-751 rename empty annotation base class and make it abstract

Added:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/EmptyAnnotationLiteral.java
      - copied, changed from r1429337, openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AbstractAnnotationLiteral.java
Removed:
    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

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=1429345&r1=1429344&r2=1429345&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 18:04:06 2013
@@ -20,7 +20,7 @@ package org.apache.webbeans.annotation;
 
 import javax.enterprise.inject.Any;
 
-public class AnyLiteral extends AbstractAnnotationLiteral<Any> implements Any
+public class AnyLiteral extends EmptyAnnotationLiteral<Any> implements Any
 {
     private static final String TOSTRING = "@javax.enterprise.inject.Any()";
     private static final long serialVersionUID = -8922048102786275371L;

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=1429345&r1=1429344&r2=1429345&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 18:04:06 2013
@@ -25,7 +25,7 @@ import javax.enterprise.inject.Default;
  * 
  * @since 1.0
  */
-public class DefaultLiteral extends AbstractAnnotationLiteral<Default> implements Default
+public class DefaultLiteral extends EmptyAnnotationLiteral<Default> implements Default
 {
     private static final String TOSTRING = "@javax.enterprise.inject.Default()";
     private static final long serialVersionUID = 6788272256977634238L;

Copied: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/EmptyAnnotationLiteral.java (from r1429337, 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/EmptyAnnotationLiteral.java?p2=openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/EmptyAnnotationLiteral.java&p1=openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AbstractAnnotationLiteral.java&r1=1429337&r2=1429345&rev=1429345&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AbstractAnnotationLiteral.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/EmptyAnnotationLiteral.java Sat Jan  5 18:04:06 2013
@@ -21,16 +21,32 @@ package org.apache.webbeans.annotation;
 import javax.enterprise.util.AnnotationLiteral;
 import java.lang.annotation.Annotation;
 
-public class AbstractAnnotationLiteral<T extends Annotation> extends AnnotationLiteral<T>
+/**
+ * Base class for AnnotationLiterals which have no members.
+ * @param <T>
+ */
+public abstract class EmptyAnnotationLiteral<T extends Annotation> extends AnnotationLiteral<T>
 {
+    /**
+     * Implemented for performance reasons.
+     * This is needed because an Annotation always returns 0 as hashCode
+     * if there is no method in it.
+     * Contrary to this the generic {@link javax.enterprise.util.AnnotationLiteral#hashCode()}
+     * always does search for methods via reflection and only then returns 0.
+     * Not very well performing ...
+     * @return always 0
+     */
     @Override
     public int hashCode()
     {
-        // implemented for performance reasons
-        // currently this is needed because AnnotationLiteral always returns 0 as hashCode
         return 0;
     }
 
+    /**
+     * Just checks whether the 2 classes have the same annotationType.
+     * We do not need to dynamically evaluate the member values via reflection
+     * as there are no members in this annotation at all.
+     */
     @Override
     public boolean equals(final Object other)
     {

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=1429345&r1=1429344&r2=1429345&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 18:04:06 2013
@@ -26,7 +26,7 @@ import javax.enterprise.context.RequestS
  * @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
  * @since 1.0
  */
-public class RequestedScopeLiteral extends AbstractAnnotationLiteral<RequestScoped> implements RequestScoped
+public class RequestedScopeLiteral extends EmptyAnnotationLiteral<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=1429345&r1=1429344&r2=1429345&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 18:04:06 2013
@@ -26,7 +26,7 @@ import javax.enterprise.context.SessionS
  * @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
  * @since 1.0
  */
-public class SessionScopeLiteral extends AbstractAnnotationLiteral<SessionScoped> implements SessionScoped
+public class SessionScopeLiteral extends EmptyAnnotationLiteral<SessionScoped> implements SessionScoped
 {
 
     private static final long serialVersionUID = -7469945140661485990L;