You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by ge...@apache.org on 2009/11/07 10:49:33 UTC
svn commit: r833661 - in
/incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax: decorator/
enterprise/event/ enterprise/inject/ enterprise/util/
Author: gerdogdu
Date: Sat Nov 7 09:49:32 2009
New Revision: 833661
URL: http://svn.apache.org/viewvc?rev=833661&view=rev
Log:
Update for latest specification. Change Decorates to Delegate and create util package.
Added:
incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/decorator/Delegate.java
- copied, changed from r833635, incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/decorator/Decorates.java
incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/util/
incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/util/AnnotationLiteral.java
- copied, changed from r833635, incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/AnnotationLiteral.java
incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/util/NonBinding.java
- copied, changed from r833635, incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/NonBinding.java
incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/util/TypeLiteral.java (contents, props changed)
- copied, changed from r833635, incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/TypeLiteral.java
Removed:
incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/decorator/Decorates.java
incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/AnnotationLiteral.java
incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/NonBinding.java
incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/TypeLiteral.java
Modified:
incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/event/Event.java
incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/Instance.java
Copied: incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/decorator/Delegate.java (from r833635, incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/decorator/Decorates.java)
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/decorator/Delegate.java?p2=incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/decorator/Delegate.java&p1=incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/decorator/Decorates.java&r1=833635&r2=833661&rev=833661&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/decorator/Decorates.java (original)
+++ incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/decorator/Delegate.java Sat Nov 7 09:49:32 2009
@@ -35,7 +35,7 @@
@Target({FIELD,PARAMETER})
@Retention(RUNTIME)
@Documented
-public @interface Decorates
+public @interface Delegate
{
}
Modified: incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/event/Event.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/event/Event.java?rev=833661&r1=833660&r2=833661&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/event/Event.java (original)
+++ incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/event/Event.java Sat Nov 7 09:49:32 2009
@@ -20,7 +20,7 @@
import java.lang.annotation.Annotation;
-import javax.enterprise.inject.TypeLiteral;
+import javax.enterprise.util.TypeLiteral;
/**
* The event interface is used for firing events with specific classifiers and types.
Modified: incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/Instance.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/Instance.java?rev=833661&r1=833660&r2=833661&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/Instance.java (original)
+++ incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/Instance.java Sat Nov 7 09:49:32 2009
@@ -20,6 +20,7 @@
import java.lang.annotation.Annotation;
+import javax.enterprise.util.TypeLiteral;
import javax.inject.Provider;
/**
Copied: incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/util/AnnotationLiteral.java (from r833635, incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/AnnotationLiteral.java)
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/util/AnnotationLiteral.java?p2=incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/util/AnnotationLiteral.java&p1=incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/AnnotationLiteral.java&r1=833635&r2=833661&rev=833661&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/AnnotationLiteral.java (original)
+++ incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/util/AnnotationLiteral.java Sat Nov 7 09:49:32 2009
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package javax.enterprise.inject;
+package javax.enterprise.util;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
@@ -24,7 +24,7 @@
import java.lang.reflect.Type;
/**
- *
+ * Annotation literal utility.
*
* @param <T> wrapped annotation class
* @version $Rev$Â $Date$
@@ -34,6 +34,8 @@
{
private Class<T> annotationType;
+
+ private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
protected AnnotationLiteral()
{
@@ -50,16 +52,24 @@
protected Class<T> getAnnotationType(Class<?> definedClazz)
{
Type superClazz = definedClazz.getGenericSuperclass();
+
Class<T> clazz = null;
-
- if (superClazz instanceof ParameterizedType)
+
+ if (superClazz.equals(Object.class))
+ {
+ throw new RuntimeException("Super class must be parametrized type!");
+ }
+
+ else if (superClazz instanceof ParameterizedType)
{
ParameterizedType paramType = (ParameterizedType) superClazz;
Type[] actualArgs = paramType.getActualTypeArguments();
if (actualArgs.length == 1)
{
+ //Actual annotation type
Type type = actualArgs[0];
+
if (type instanceof Class)
{
clazz = (Class<T>) type;
@@ -67,19 +77,16 @@
}
else
{
- throw new RuntimeException("Not class type");
+ throw new RuntimeException("Not class type!");
}
-
}
else
{
- throw new RuntimeException("More than one parametric type");
+ throw new RuntimeException("More than one parametric type!");
}
-
}
else
{
- // Look for super, maybe inner
return getAnnotationType((Class<?>) superClazz);
}
@@ -126,16 +133,12 @@
try
{
-
if (!method.isAccessible())
{
method.setAccessible(true);
}
- return method.invoke(instance, new Object[]
- {
- });
-
+ return method.invoke(instance, EMPTY_OBJECT_ARRAY);
}
catch (Exception e)
{
Copied: incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/util/NonBinding.java (from r833635, incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/NonBinding.java)
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/util/NonBinding.java?p2=incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/util/NonBinding.java&p1=incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/NonBinding.java&r1=833635&r2=833661&rev=833661&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/NonBinding.java (original)
+++ incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/util/NonBinding.java Sat Nov 7 09:49:32 2009
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package javax.enterprise.inject;
+package javax.enterprise.util;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
Copied: incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/util/TypeLiteral.java (from r833635, incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/TypeLiteral.java)
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/util/TypeLiteral.java?p2=incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/util/TypeLiteral.java&p1=incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/TypeLiteral.java&r1=833635&r2=833661&rev=833661&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/TypeLiteral.java (original)
+++ incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/util/TypeLiteral.java Sat Nov 7 09:49:32 2009
@@ -16,13 +16,18 @@
* specific language governing permissions and limitations
* under the License.
*/
-package javax.enterprise.inject;
+package javax.enterprise.util;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
-
+/**
+ * Type literal implementation.
+ * @version $Rev$ $Date$
+ *
+ * @param <T> wrapped type
+ */
@SuppressWarnings("unchecked")
public abstract class TypeLiteral<T>
{
@@ -70,30 +75,28 @@
if (clazz == null)
{
- throw new RuntimeException("Class parameter clazz can not be null");
+ throw new RuntimeException("Class parameter can not be null!");
}
Type superClazz = clazz.getGenericSuperclass();
if (superClazz.equals(Object.class))
{
- throw new RuntimeException("Super class must be parametrized type");
+ throw new RuntimeException("Super class must be parametrized type!");
}
else if (superClazz instanceof ParameterizedType)
{
- ParameterizedType pt = (ParameterizedType) superClazz;
+ ParameterizedType pt = (ParameterizedType) superClazz;
Type[] actualArgs = pt.getActualTypeArguments();
if (actualArgs.length == 1)
{
type = actualArgs[0];
-
}
else
{
- throw new RuntimeException("More than one parametric type");
+ throw new RuntimeException("More than one parametric type!");
}
-
}
else
{
@@ -103,40 +106,48 @@
return type;
}
- /*
- * (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
+
result = prime * result + ((definedType == null) ? 0 : definedType.hashCode());
+
return result;
}
- /*
- * (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(Object obj)
{
if (this == obj)
- return true;
+ {
+ return true;
+ }
+
if (obj == null)
- return false;
+ {
+ return false;
+ }
+
if (getClass() != obj.getClass())
- return false;
+ {
+ return false;
+ }
+
TypeLiteral other = (TypeLiteral) obj;
if (definedType == null)
{
if (other.definedType != null)
- return false;
+ {
+ return false;
+ }
}
else if (!definedType.equals(other.definedType))
- return false;
+ {
+ return false;
+ }
+
return true;
}
Propchange: incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/util/TypeLiteral.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/util/TypeLiteral.java
------------------------------------------------------------------------------
svn:keywords = Rev Date