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/06/27 10:52:10 UTC
svn commit: r788940 [2/2] - in
/incubator/openwebbeans/trunk/webbeans-impl/src:
main/java/org/apache/webbeans/component/
main/java/org/apache/webbeans/config/
main/java/org/apache/webbeans/container/
main/java/org/apache/webbeans/decorator/ main/java/o...
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableField.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableField.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableField.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableField.java Sat Jun 27 08:52:08 2009
@@ -49,7 +49,7 @@
field.setAccessible(true);
}
- field.set(instance, inject(this.injectionPointModel.getInjectionClassType(), this.injectionPointModel.getActualTypeArguments(), anns));
+ field.set(instance, inject(this.injectionPointModel.getInjectionGenericType(), anns));
}
catch (Exception e)
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableMethods.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableMethods.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableMethods.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableMethods.java Sat Jun 27 08:52:08 2009
@@ -51,7 +51,7 @@
Annotation[] anns = new Annotation[model.getBindingTypes().size()];
anns = model.getBindingTypes().toArray(anns);
- list.add(inject(model.getInjectionClassType(), model.getActualTypeArguments(), anns));
+ list.add(inject(model.getInjectionGenericType(), anns));
}
try
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorComparator.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorComparator.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorComparator.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorComparator.java Sat Jun 27 08:52:08 2009
@@ -19,13 +19,13 @@
import org.apache.webbeans.intercept.webbeans.WebBeansInterceptor;
-public class InterceptorComparator implements Comparator<Interceptor>
+public class InterceptorComparator<T> implements Comparator<Interceptor<T>>
{
- public int compare(Interceptor o1, Interceptor o2)
+ public int compare(Interceptor<T> o1, Interceptor<T> o2)
{
- WebBeansInterceptor src = (WebBeansInterceptor) o1;
- WebBeansInterceptor target = (WebBeansInterceptor) o2;
+ WebBeansInterceptor<T> src = (WebBeansInterceptor<T>) o1;
+ WebBeansInterceptor<T> target = (WebBeansInterceptor<T>) o2;
if (o1.equals(o2))
{
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataComparator.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataComparator.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataComparator.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataComparator.java Sat Jun 27 08:52:08 2009
@@ -45,8 +45,8 @@
}
else
{
- WebBeansInterceptor interceptorFirst = (WebBeansInterceptor) o1.getWebBeansInterceptor();
- WebBeansInterceptor interceptorSecond = (WebBeansInterceptor) o2.getWebBeansInterceptor();
+ WebBeansInterceptor<?> interceptorFirst = (WebBeansInterceptor<?>) o1.getWebBeansInterceptor();
+ WebBeansInterceptor<?> interceptorSecond = (WebBeansInterceptor<?>) o2.getWebBeansInterceptor();
if (interceptorFirst == null && interceptorSecond == null)
{
Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java?rev=788940&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java Sat Jun 27 08:52:08 2009
@@ -0,0 +1,151 @@
+/*
+ * 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.portable;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.Annotated;
+
+import org.apache.webbeans.util.ClassUtil;
+
+/**
+ * Abstract implementation of the {@link Annotated} contract.
+ *
+ * @version $Rev$ $Date$
+ */
+abstract class AbstractAnnotated implements Annotated
+{
+ /**Base type of an annotated element*/
+ private Type baseType = null;
+
+ /**Type closures*/
+ private Set<Type> typeClosures = new HashSet<Type>();
+
+ /**Set of annotations*/
+ private Set<Annotation> annotations = new HashSet<Annotation>();
+
+ /**
+ * Createa a new annotated element.
+ *
+ * @param baseType annotated element type
+ */
+ protected AbstractAnnotated(Type baseType)
+ {
+ this.baseType = baseType;
+ ClassUtil.setTypeHierarchy(this.typeClosures, this.baseType);
+ }
+
+ /**
+ * Adds new annotation to set.
+ *
+ * @param annotation new annotation
+ */
+ protected void addAnnotation(Annotation annotation)
+ {
+ this.annotations.add(annotation);
+ }
+
+
+ /**
+ * Adds new annotation to set.
+ *
+ * @param annotation new annotation
+ */
+ protected void setAnnotations(Annotation[] annotations)
+ {
+ this.annotations.clear();
+ for(Annotation annotation : annotations)
+ {
+ this.annotations.add(annotation);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType)
+ {
+ for(Annotation ann : this.annotations)
+ {
+ if(ann.annotationType().equals(annotationType))
+ {
+ return (T)ann;
+ }
+ }
+
+ return null;
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Set<Annotation> getAnnotations()
+ {
+ return this.annotations;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Type getBaseType()
+ {
+ return this.baseType;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Set<Type> getTypeClosure()
+ {
+ return this.typeClosures;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
+ {
+ for(Annotation ann : this.annotations)
+ {
+ if(ann.annotationType().equals(annotationType))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder();
+
+ builder.append("Base Type : " + baseType.toString() + ",");
+ builder.append("Type Closures : " + typeClosures.toString() + ",");
+ builder.append("Annotations : " + annotations.toString());
+
+ return builder.toString();
+ }
+
+}
\ No newline at end of file
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedCallable.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedCallable.java?rev=788940&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedCallable.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedCallable.java Sat Jun 27 08:52:08 2009
@@ -0,0 +1,95 @@
+/*
+ * 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.portable;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.enterprise.inject.spi.AnnotatedCallable;
+import javax.enterprise.inject.spi.AnnotatedParameter;
+
+/**
+ * Implementation of {@link AnnotatedCallable} interface.
+ *
+ * @version $Rev$ $Date$
+ *
+ * @param <X> declaring class
+ */
+abstract class AbstractAnnotatedCallable<X> extends AbstractAnnotatedMember<X> implements AnnotatedCallable<X>
+{
+ /**Annotated parameters*/
+ private List<AnnotatedParameter<X>> annotatedParameters = new ArrayList<AnnotatedParameter<X>>();
+
+ /**
+ * Creates a new instance.
+ *
+ * @param baseType base type
+ * @param javaMember member
+ */
+ AbstractAnnotatedCallable(Type baseType, Member javaMember)
+ {
+ super(baseType,javaMember);
+ }
+
+ protected void setAnnotatedParameters(Type[] genericParameterTypes,Annotation[][] parameterAnnotations)
+ {
+ int i = 0;
+
+ for(Type genericParameter : genericParameterTypes)
+ {
+ AnnotatedParameterImpl<X> parameterImpl = new AnnotatedParameterImpl<X>(genericParameter,this,i);
+ parameterImpl.setAnnotations(parameterAnnotations[i]);
+
+ addAnnotatedParameter(parameterImpl);
+
+ i++;
+ }
+ }
+
+ /**
+ * Adds new annotated parameter.
+ *
+ * @param parameter new annotated parameter
+ */
+ void addAnnotatedParameter(AnnotatedParameter<X> parameter)
+ {
+ this.annotatedParameters.add(parameter);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List<AnnotatedParameter<X>> getParameters()
+ {
+ return this.annotatedParameters;
+ }
+
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder(super.toString());
+ builder.append(",");
+ builder.append("Annotated Parameters : [");
+ for(AnnotatedParameter<X> parameter : annotatedParameters)
+ {
+ builder.append(parameter.toString());
+ }
+ builder.append("]");
+
+ return builder.toString();
+ }
+ }
\ No newline at end of file
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedCallable.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedCallable.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedMember.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedMember.java?rev=788940&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedMember.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedMember.java Sat Jun 27 08:52:08 2009
@@ -0,0 +1,112 @@
+/*
+ * 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.portable;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedMember;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+import org.apache.webbeans.util.ClassUtil;
+
+/**
+ * Implementation of {@link AnnotatedMember} interface.
+ *
+ * @version $Rev$ $Date$
+ *
+ * @param <X> declaring class
+ */
+abstract class AbstractAnnotatedMember<X> extends AbstractAnnotated implements AnnotatedMember<X>
+{
+ /**Annotated type that owns this member*/
+ private AnnotatedType<X> declaringType;
+
+ /**Member type*/
+ protected Member javaMember;
+
+ /**
+ * Creates a new instance.
+ *
+ * @param baseType base type
+ * @param javaMember member
+ */
+ @SuppressWarnings("unchecked")
+ AbstractAnnotatedMember(Type baseType, Member javaMember)
+ {
+ super(baseType);
+ this.javaMember = javaMember;
+ this.declaringType = (AnnotatedType<X>)AnnotatedElementFactory.newAnnotatedType(this.javaMember.getDeclaringClass());
+
+ AnnotatedTypeImpl<X> impl = (AnnotatedTypeImpl<X>)declaringType;
+
+ if(this.javaMember instanceof Constructor)
+ {
+ impl.addAnnotatedConstructor((AnnotatedConstructor<X>)this);
+ }
+
+ else if(this.javaMember instanceof Method)
+ {
+ impl.addAnnotatedMethod((AnnotatedMethod<X>)this);
+ }
+
+ else if(this.javaMember instanceof Field)
+ {
+ impl.addAnnotatedField((AnnotatedField<X>)this);
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public AnnotatedType<X> getDeclaringType()
+ {
+ return this.declaringType;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Member getJavaMember()
+ {
+ return this.javaMember;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isStatic()
+ {
+ return ClassUtil.isStatic(this.javaMember.getModifiers());
+ }
+
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder(super.toString());
+ builder.append(",");
+ builder.append("Java Member Name : " + this.javaMember.getName());
+
+ return builder.toString();
+ }
+}
\ No newline at end of file
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedMember.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedMember.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedConstructorImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedConstructorImpl.java?rev=788940&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedConstructorImpl.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedConstructorImpl.java Sat Jun 27 08:52:08 2009
@@ -0,0 +1,60 @@
+/*
+ * 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.portable;
+
+import java.lang.reflect.Constructor;
+
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+
+/**
+ * Implementation of {@link AnnotatedConstructor} interface.
+ *
+ * @version $Rev$ $Date$
+ *
+ * @param <X> class info
+ */
+class AnnotatedConstructorImpl<X> extends AbstractAnnotatedCallable<X> implements AnnotatedConstructor<X>
+{
+ /**
+ * Create a ew instance.
+ *
+ * @param baseType base type info
+ * @param javaMember constructor
+ */
+ AnnotatedConstructorImpl(Constructor<X> javaMember)
+ {
+ super(javaMember.getDeclaringClass(), javaMember);
+ setAnnotations(javaMember.getDeclaredAnnotations());
+ setAnnotatedParameters(javaMember.getGenericParameterTypes(), javaMember.getParameterAnnotations());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public Constructor<X> getJavaMember()
+ {
+ return Constructor.class.cast(this.javaMember);
+ }
+
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("Annotated Constructor,");
+ builder.append(super.toString());
+
+ return builder.toString();
+ }
+
+}
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedConstructorImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedConstructorImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java?rev=788940&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java Sat Jun 27 08:52:08 2009
@@ -0,0 +1,90 @@
+/*
+ * 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.portable;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+/**
+ * Factory for {@link Annotated} elements.
+ *
+ * @version $Rev$ $Date$
+ */
+public final class AnnotatedElementFactory
+{
+ private AnnotatedElementFactory()
+ {
+ // Emtpty
+ }
+
+ /**
+ * Creates and configures new annotated type.
+ *
+ * @param <X> class info
+ * @param annotatedClass annotated class
+ * @return new annotated type
+ */
+ public static <X> AnnotatedType<X> newAnnotatedType(Class<X> annotatedClass)
+ {
+ AnnotatedTypeImpl<X> annotatedType = new AnnotatedTypeImpl<X>(annotatedClass);
+
+ return annotatedType;
+ }
+
+ /**
+ * Creates and configures new annotated constructor.
+ *
+ * @param <X> declaring class
+ * @param constructor constructor
+ * @return new annotated constructor
+ */
+ public static <X> AnnotatedConstructor<X> newAnnotatedConstructor(Constructor<X> constructor)
+ {
+ return new AnnotatedConstructorImpl<X>(constructor);
+ }
+
+ /**
+ * Creates and configures new annotated field.
+ *
+ * @param <X> declaring class
+ * @param field field instance
+ * @param declaringClass declaring class
+ * @return new annotated field
+ */
+ public static <X> AnnotatedField<X> newAnnotatedField(Field field, Class<X> declaringClass)
+ {
+ return new AnnotatedFieldImpl<X>(field);
+ }
+
+ /**
+ * Creates and configures new annotated method.
+ *
+ * @param <X> declaring class
+ * @param method annotated method
+ * @param declaringClass declaring class info
+ * @return new annotated method
+ */
+ public static <X> AnnotatedMethod<X> newAnnotatedMethod(Method method, Class<X> declaringClass)
+ {
+ return new AnnotatedMethodImpl<X>(method);
+ }
+
+}
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedFieldImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedFieldImpl.java?rev=788940&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedFieldImpl.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedFieldImpl.java Sat Jun 27 08:52:08 2009
@@ -0,0 +1,59 @@
+/*
+ * 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.portable;
+
+import java.lang.reflect.Field;
+
+import javax.enterprise.inject.spi.AnnotatedField;
+
+/**
+ * Implementation of {@link AnnotatedField} interface.
+ *
+ * @version $Rev$ $Date$
+ *
+ * @param <X>
+ */
+public class AnnotatedFieldImpl<X> extends AbstractAnnotatedMember<X> implements AnnotatedField<X>
+{
+
+ /**
+ * Creates a new instance
+ *
+ * @param baseType base type
+ * @param javaMember field
+ */
+ AnnotatedFieldImpl(Field javaMember)
+ {
+ super(javaMember.getGenericType(), javaMember);
+ setAnnotations(javaMember.getDeclaredAnnotations());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Field getJavaMember()
+ {
+ return Field.class.cast(this.javaMember);
+ }
+
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("Annotated Field,");
+ builder.append(super.toString());
+
+ return builder.toString();
+ }
+
+}
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedFieldImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedFieldImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedMethodImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedMethodImpl.java?rev=788940&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedMethodImpl.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedMethodImpl.java Sat Jun 27 08:52:08 2009
@@ -0,0 +1,60 @@
+/*
+ * 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.portable;
+
+import java.lang.reflect.Method;
+
+import javax.enterprise.inject.spi.AnnotatedMethod;
+
+/**
+ * Implementation of {@link AnnotatedMethod} interface.
+ *
+ * @version $Rev$ $Date$
+ *
+ * @param <X> class info
+ */
+class AnnotatedMethodImpl<X> extends AbstractAnnotatedCallable<X> implements AnnotatedMethod<X>
+{
+
+ /**
+ * Create a ew instance.
+ *
+ * @param baseType base type info
+ * @param javaMember method
+ */
+ AnnotatedMethodImpl(Method javaMember)
+ {
+ super(javaMember.getGenericReturnType(), javaMember);
+ setAnnotations(javaMember.getDeclaredAnnotations());
+ setAnnotatedParameters(javaMember.getGenericParameterTypes(), javaMember.getParameterAnnotations());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Method getJavaMember()
+ {
+ return Method.class.cast(this.javaMember);
+ }
+
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("Annotated Method,");
+ builder.append(super.toString());
+
+ return builder.toString();
+ }
+
+}
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedMethodImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedMethodImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedParameterImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedParameterImpl.java?rev=788940&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedParameterImpl.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedParameterImpl.java Sat Jun 27 08:52:08 2009
@@ -0,0 +1,72 @@
+/*
+ * 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.portable;
+
+import java.lang.reflect.Type;
+
+import javax.enterprise.inject.spi.AnnotatedCallable;
+import javax.enterprise.inject.spi.AnnotatedParameter;
+
+/**
+ * Implementation of {@link AnnotatedParameter} interface.
+ *
+ * @version $Rev$ $Date$
+ *
+ * @param <X> declaring class info
+ */
+class AnnotatedParameterImpl<X> extends AbstractAnnotated implements AnnotatedParameter<X>
+{
+ /**Declaring callable*/
+ private AnnotatedCallable<X> declaringCallable;
+
+ /**Parameter position*/
+ private int position;
+
+ AnnotatedParameterImpl(Type baseType, AnnotatedCallable<X> declaringCallable, int position)
+ {
+ super(baseType);
+ this.declaringCallable = declaringCallable;
+ this.position = position;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public AnnotatedCallable<X> getDeclaringCallable()
+ {
+ return this.declaringCallable;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getPosition()
+ {
+ return this.position;
+ }
+
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("Annotated Parameter");
+ builder.append(",");
+ builder.append(super.toString()+ ",");
+ builder.append("Annotated Callable : [" + this.declaringCallable.toString() + "],");
+ builder.append("Position : " + position);
+
+ return builder.toString();
+ }
+}
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedParameterImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedParameterImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedTypeImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedTypeImpl.java?rev=788940&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedTypeImpl.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedTypeImpl.java Sat Jun 27 08:52:08 2009
@@ -0,0 +1,123 @@
+/*
+ * 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.portable;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+/**
+ * Implementation of the {@link AnnotatedType} interface.
+ *
+ * @version $Rev$ $Date$
+ *
+ * @param <X> class type
+ */
+class AnnotatedTypeImpl<X> extends AbstractAnnotated implements AnnotatedType<X>
+{
+ /**Annotated class*/
+ private Class<X> annotatedClass;
+
+ /**Constructors*/
+ private Set<AnnotatedConstructor<X>> constructors = new HashSet<AnnotatedConstructor<X>>();
+
+ /**Fields*/
+ private Set<AnnotatedField<? super X>> fields = new HashSet<AnnotatedField<? super X>>();
+
+ /**Methods*/
+ private Set<AnnotatedMethod<? super X>> methods = new HashSet<AnnotatedMethod<? super X>>();
+
+ /**
+ * Creates a new instance.
+ *
+ * @param annotatedClass class
+ */
+ AnnotatedTypeImpl(Class<X> annotatedClass)
+ {
+ super(annotatedClass);
+ this.annotatedClass = annotatedClass;
+ }
+
+ /**
+ * Adds new annotated constructor.
+ *
+ * @param constructor new constructor
+ */
+ void addAnnotatedConstructor(AnnotatedConstructor<X> constructor)
+ {
+ this.constructors.add(constructor);
+ }
+
+ /**
+ * Adds new annotated field.
+ *
+ * @param constructor new field
+ */
+ void addAnnotatedField(AnnotatedField<? super X> field)
+ {
+ this.fields.add(field);
+ }
+
+ /**
+ * Adds new annotated method.
+ *
+ * @param constructor new method
+ */
+ void addAnnotatedMethod(AnnotatedMethod<? super X> method)
+ {
+ this.methods.add(method);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Set<AnnotatedConstructor<X>> getConstructors()
+ {
+ return Collections.unmodifiableSet(this.constructors);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Set<AnnotatedField<? super X>> getFields()
+ {
+ return Collections.unmodifiableSet(this.fields);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Class<X> getJavaClass()
+ {
+ return this.annotatedClass;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Set<AnnotatedMethod<? super X>> getMethods()
+ {
+ return Collections.unmodifiableSet(this.methods);
+ }
+
+}
\ No newline at end of file
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedTypeImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedTypeImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java Sat Jun 27 08:52:08 2009
@@ -28,6 +28,7 @@
import org.apache.webbeans.exception.WebBeansException;
import org.apache.webbeans.intercept.InterceptorHandler;
import org.apache.webbeans.intercept.webbeans.WebBeansInterceptor;
+import org.apache.webbeans.util.ClassUtil;
import javassist.util.proxy.ProxyFactory;
@@ -46,9 +47,9 @@
Set<Type> types = bean.getTypes();
List<Class<?>> interfaceList = new ArrayList<Class<?>>();
Class<?> superClass = null;
- for (Type t : types)
+ for (Type generic : types)
{
- Class<?> type = (Class<?>)t;
+ Class<?> type = (Class<?>)ClassUtil.getClazz(generic);
if (type.isInterface())
{
interfaceList.add(type);
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java Sat Jun 27 08:52:08 2009
@@ -93,6 +93,7 @@
PRIMITIVE_TO_WRAPPERS_MAP.put(Byte.TYPE,Byte.class);
PRIMITIVE_TO_WRAPPERS_MAP.put(Short.TYPE,Short.class);
PRIMITIVE_TO_WRAPPERS_MAP.put(Boolean.TYPE,Boolean.class);
+ PRIMITIVE_TO_WRAPPERS_MAP.put(Void.TYPE,Void.class);
}
/*
@@ -642,6 +643,45 @@
return false;
}
+ public static boolean isUnboundedTypeVariable(Type type)
+ {
+ Asserts.assertNotNull(type, "type parameter can not be null");
+
+ if (type instanceof TypeVariable)
+ {
+ TypeVariable wc = (TypeVariable)type;
+ Type[] upper = wc.getBounds();
+
+
+ if(upper.length > 1)
+ {
+ return false;
+ }
+ else
+ {
+ Type arg = upper[0];
+ if(!(arg instanceof Class))
+ {
+ return false;
+ }
+ else
+ {
+ Class<?> clazz = (Class<?>)arg;
+ if(!clazz.equals(Object.class))
+ {
+ return false;
+ }
+ }
+ }
+ }
+ else
+ {
+ return false;
+ }
+
+ return true;
+ }
+
/**
* Returns true if type is an instance of <code>TypeVariable</code>
@@ -728,8 +768,8 @@
public static boolean isAssignable(Type beanType, Type requiredType)
{
- Asserts.assertNotNull(beanType, "lhs parameter can not be null");
- Asserts.assertNotNull(requiredType, "rhs parameter can not be null");
+ Asserts.assertNotNull(beanType, "beanType parameter can not be null");
+ Asserts.assertNotNull(requiredType, "requiredType parameter can not be null");
if (beanType instanceof ParameterizedType && requiredType instanceof ParameterizedType)
{
@@ -737,7 +777,7 @@
}
else if (beanType instanceof Class && requiredType instanceof Class)
{
- return isAssignable((Class) beanType, (Class) requiredType);
+ return isAssignable((Class) requiredType, (Class) beanType);
}
else if(beanType instanceof ParameterizedType && requiredType instanceof Class)
{
@@ -745,7 +785,7 @@
Type[] beanTypeArgs = ((ParameterizedType)beanType).getActualTypeArguments();
for(Type actual : beanTypeArgs)
{
- if(!ClassUtil.isWildCardType(actual))
+ if(!ClassUtil.isUnboundedTypeVariable(actual))
{
if(actual instanceof Class)
{
@@ -770,12 +810,28 @@
return ok;
}
+ else if(beanType instanceof Class && requiredType instanceof ParameterizedType)
+ {
+ Class<?> clazzBeanType = (Class<?>)beanType;
+ ParameterizedType ptReq = (ParameterizedType)requiredType;
+ Class<?> clazzReqType = (Class<?>)ptReq.getRawType();
+
+ if(isAssignable(clazzReqType, clazzBeanType))
+ {
+ return true;
+ }
+
+ return false;
+ }
else
{
return false;
}
}
+
+
+
/**
* Returns true if rhs is assignable type
* to the lhs, false otherwise.
@@ -789,6 +845,16 @@
Asserts.assertNotNull(lhs, "lhs parameter can not be null");
Asserts.assertNotNull(rhs, "rhs parameter can not be null");
+ if(lhs.isPrimitive())
+ {
+ lhs = getPrimitiveWrapper(lhs);
+ }
+
+ if(rhs.isPrimitive())
+ {
+ rhs = getPrimitiveWrapper(rhs);
+ }
+
if (lhs.isAssignableFrom(rhs))
{
return true;
@@ -859,7 +925,14 @@
else if(ClassUtil.isTypeVariable(requiredTypeArg) && ClassUtil.isTypeVariable(beanTypeArg))
{
return check4(beanTypeArg, requiredTypeArg);
- }
+ }
+ else if((beanTypeArg instanceof Class) && (requiredTypeArg instanceof Class))
+ {
+ if(isAssignable(beanTypeArg, requiredTypeArg))
+ {
+ return true;
+ }
+ }
}
return false;
@@ -1372,6 +1445,14 @@
return (clazz.getTypeParameters().length > 0) ? true : false;
}
+
+
+ public static TypeVariable<?>[] getTypeVariables(Class<?> clazz)
+ {
+ Asserts.assertNotNull("clazz argument can not be null");
+
+ return clazz.getTypeParameters();
+ }
public static Type[] getActualTypeArguements(Class<?> clazz)
{
@@ -1416,28 +1497,46 @@
return (Class<?>) type;
}
- public static Set<Type> setTypeHierarchy(Set<Type> set, Class<?> clazz)
+ public static Set<Type> setTypeHierarchy(Set<Type> set, Type clazz)
{
- Asserts.nullCheckForClass(clazz);
-
+ Class<?> raw = getClazz(clazz);
+
set.add(clazz);
- Class<?> sc = clazz.getSuperclass();
+ Type sc = raw.getGenericSuperclass();
if (sc != null)
{
setTypeHierarchy(set, sc);
}
- Class<?>[] interfaces = clazz.getInterfaces();
- for (Class<?> cl : interfaces)
- {
+ Type[] interfaces = raw.getGenericInterfaces();
+ for (Type cl : interfaces)
+ {
setTypeHierarchy(set, cl);
}
return set;
}
+
+ public static Class<?> getClazz(Type sc)
+ {
+ Class<?> raw = null;
+
+ if(sc instanceof ParameterizedType)
+ {
+ ParameterizedType pt = (ParameterizedType)sc;
+ raw = (Class<?>)pt.getRawType();
+ }
+ else
+ {
+ raw = (Class<?>)sc;
+ }
+
+ return raw;
+ }
+
//For Ejb API Type
public static Set<Type> setClassTypeHierarchy(Set<Type> set, Class<?> clazz)
{
@@ -1483,10 +1582,10 @@
{
ParameterizedType pt = (ParameterizedType) type;
- if (checkParametrizedType(pt))
- {
+ //if (checkParametrizedType(pt))
+ //{
return pt.getActualTypeArguments();
- }
+ //}
}
}
@@ -1555,10 +1654,10 @@
{
ParameterizedType pt = (ParameterizedType) type;
- if (checkParametrizedType(pt))
- {
+ //if (checkParametrizedType(pt))
+ //{
list.add(pt.getActualTypeArguments());
- }
+ //}
}
}
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java Sat Jun 27 08:52:08 2009
@@ -56,6 +56,7 @@
import javax.enterprise.inject.UnproxyableResolutionException;
import javax.enterprise.inject.deployment.DeploymentType;
import javax.enterprise.inject.deployment.Specializes;
+import javax.enterprise.inject.spi.Annotated;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.Interceptor;
@@ -1358,6 +1359,7 @@
}
comp.setName(superBean.getName());
+ comp.setSpecializedBean(true);
}
specialized.getBindings().addAll(superBean.getBindings());
@@ -1471,7 +1473,7 @@
Class<?> superClass = null;
for (Type t : types)
{
- Class<?> type = (Class<?>)t;
+ Class<?> type = ClassUtil.getClazz(t);
if (!type.isInterface())
{
@@ -1545,6 +1547,8 @@
configuredProducerSpecializedName(component, method, superMethod);
+ component.setSpecializedBean(true);
+
}
/**
@@ -1845,9 +1849,9 @@
public static void addInjectedImplicitEventComponent(InjectionPoint injectionPoint)
{
- Annotation[] anns = injectionPoint.getAnnotations();
+ Annotated annotated = injectionPoint.getAnnotated();
- if(AnnotationUtil.isAnnotationExist(anns, Fires.class))
+ if(annotated.isAnnotationPresent(Fires.class))
{
Type type = injectionPoint.getType();
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLDefinitionUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLDefinitionUtil.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLDefinitionUtil.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLDefinitionUtil.java Sat Jun 27 08:52:08 2009
@@ -666,7 +666,7 @@
Annotation[] bindingAnns = new Annotation[bindingTypes.size()];
bindingAnns = bindingTypes.toArray(bindingAnns);
- Set<Bean<T>> set = InjectionResolver.getInstance().implResolveByType(model.getInjectionClassType(), model.getActualTypeArguments(), bindingAnns);
+ Set<Bean<T>> set = InjectionResolver.getInstance().implResolveByType(model.getInjectionGenericType(), bindingAnns);
producerComponent = (XMLProducerComponentImpl<?>) set.iterator().next();
if (producerComponent == null)
Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/generic/GenericComponent.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/generic/GenericComponent.java?rev=788940&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/generic/GenericComponent.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/generic/GenericComponent.java Sat Jun 27 08:52:08 2009
@@ -0,0 +1,21 @@
+/*
+ * 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.test.component.inject.generic;
+
+import org.apache.webbeans.test.component.inject.parametrized.Persistent;
+
+public class GenericComponent<T extends Persistent> extends SuperGenericComponent<T>
+{
+
+}
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/generic/GenericComponent.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/generic/GenericComponentInjector.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/generic/GenericComponentInjector.java?rev=788940&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/generic/GenericComponentInjector.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/generic/GenericComponentInjector.java Sat Jun 27 08:52:08 2009
@@ -0,0 +1,73 @@
+/*
+ * 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.test.component.inject.generic;
+
+import javax.enterprise.inject.Current;
+
+import org.apache.webbeans.test.component.inject.parametrized.Persistent;
+import org.apache.webbeans.test.component.inject.parametrized.PersistentSuper;
+
+public class GenericComponentInjector<Y extends Persistent>
+{
+ private @Current GenericComponent<?> injection1;
+
+ private @Current GenericComponent<? extends PersistentSuper> injection2;
+
+ private @Current GenericComponent<Persistent> injection3;
+
+ private @Current GenericComponent<Y> injection4;
+
+ public GenericComponent<?> getInjection1()
+ {
+ return injection1;
+ }
+
+ public void setInjection1(GenericComponent<?> injection1)
+ {
+ this.injection1 = injection1;
+ }
+
+ public GenericComponent<? extends PersistentSuper> getInjection2()
+ {
+ return injection2;
+ }
+
+ public void setInjection2(GenericComponent<? extends PersistentSuper> injection2)
+ {
+ this.injection2 = injection2;
+ }
+
+ public GenericComponent<Persistent> getInjection3()
+ {
+ return injection3;
+ }
+
+ public void setInjection3(GenericComponent<Persistent> injection3)
+ {
+ this.injection3 = injection3;
+ }
+
+ public GenericComponent<Y> getInjection4()
+ {
+ return injection4;
+ }
+
+ public void setInjection4(GenericComponent<Y> injection4)
+ {
+ this.injection4 = injection4;
+ }
+
+
+
+}
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/generic/GenericComponentInjector.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/generic/SuperGenericComponent.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/generic/SuperGenericComponent.java?rev=788940&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/generic/SuperGenericComponent.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/generic/SuperGenericComponent.java Sat Jun 27 08:52:08 2009
@@ -0,0 +1,21 @@
+/*
+ * 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.test.component.inject.generic;
+
+import org.apache.webbeans.test.component.inject.parametrized.Persistent;
+
+public class SuperGenericComponent<T extends Persistent>
+{
+
+}
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/generic/SuperGenericComponent.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/parametrized/BoundedTypeVariableComponent.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/parametrized/BoundedTypeVariableComponent.java?rev=788940&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/parametrized/BoundedTypeVariableComponent.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/parametrized/BoundedTypeVariableComponent.java Sat Jun 27 08:52:08 2009
@@ -0,0 +1,36 @@
+/*
+ * 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.test.component.inject.parametrized;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+public class BoundedTypeVariableComponent<T extends Number,Y>
+{
+ public Collection<T> field1;
+
+ public Collection<? extends Number> field2;
+
+ public Collection<Y> field3;
+
+ public Collection<List<?>> field4;
+
+ public Collection field5;
+
+ public Map<Y, Y> field6;
+
+ public Collection<Object> field7;
+
+}
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/parametrized/BoundedTypeVariableComponent.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/parametrized/Persistent.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/parametrized/Persistent.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/parametrized/Persistent.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/parametrized/Persistent.java Sat Jun 27 08:52:08 2009
@@ -13,7 +13,7 @@
*/
package org.apache.webbeans.test.component.inject.parametrized;
-public class Persistent
+public class Persistent extends PersistentSuper
{
}
Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/parametrized/PersistentSuper.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/parametrized/PersistentSuper.java?rev=788940&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/parametrized/PersistentSuper.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/parametrized/PersistentSuper.java Sat Jun 27 08:52:08 2009
@@ -0,0 +1,19 @@
+/*
+ * 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.test.component.inject.parametrized;
+
+public class PersistentSuper
+{
+
+}
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/parametrized/PersistentSuper.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/servlet/TestContext.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/servlet/TestContext.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/servlet/TestContext.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/servlet/TestContext.java Sat Jun 27 08:52:08 2009
@@ -197,7 +197,7 @@
for(InjectionPoint injectionPoint : injectionPoints)
{
//If contains the @Obtains, defines implicit component
- if(injectionPoint.getAnnotation(Obtains.class) != null)
+ if(injectionPoint.getAnnotated().isAnnotationPresent(Obtains.class))
{
WebBeansUtil.addInjectedImplicitInstanceComponent(injectionPoint);
}
Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/generic/GenericBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/generic/GenericBeanTest.java?rev=788940&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/generic/GenericBeanTest.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/generic/GenericBeanTest.java Sat Jun 27 08:52:08 2009
@@ -0,0 +1,53 @@
+/*
+ * 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.test.unittests.inject.generic;
+
+import org.apache.webbeans.component.AbstractComponent;
+import org.apache.webbeans.test.component.inject.generic.GenericComponent;
+import org.apache.webbeans.test.component.inject.generic.GenericComponentInjector;
+import org.apache.webbeans.test.servlet.TestContext;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class GenericBeanTest extends TestContext
+{
+ public GenericBeanTest()
+ {
+ super(GenericBeanTest.class.getName());
+ }
+
+ @Before
+ public void init()
+ {
+ super.init();
+ }
+
+ @Test
+ @SuppressWarnings("unchecked")
+ public void testGenericBeanInjection()
+ {
+ defineSimpleWebBean(GenericComponent.class);
+ AbstractComponent<GenericComponentInjector> bean2 = defineSimpleWebBean(GenericComponentInjector.class);
+
+ GenericComponentInjector<?> instance = getManager().getInstance(bean2);
+ Assert.assertNotNull(instance.getInjection1());
+ Assert.assertNotNull(instance.getInjection2());
+ Assert.assertNotNull(instance.getInjection3());
+ Assert.assertNotNull(instance.getInjection4());
+
+
+
+ }
+}
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/generic/GenericBeanTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/parametrized/BoundedTypeVariableTest.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/parametrized/BoundedTypeVariableTest.java?rev=788940&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/parametrized/BoundedTypeVariableTest.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/parametrized/BoundedTypeVariableTest.java Sat Jun 27 08:52:08 2009
@@ -0,0 +1,89 @@
+/*
+ * 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.test.unittests.inject.parametrized;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+
+import org.apache.webbeans.test.component.inject.parametrized.BoundedTypeVariableComponent;
+import org.apache.webbeans.test.servlet.TestContext;
+import org.apache.webbeans.util.ClassUtil;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class BoundedTypeVariableTest extends TestContext
+{
+ public BoundedTypeVariableTest()
+ {
+ super(BoundedTypeVariableTest.class.getName());
+ }
+
+ @Test
+ public void testBoundedTypeVariableTest()
+ {
+ try
+ {
+ Field field1 = BoundedTypeVariableComponent.class.getField("field1");
+ Field field2 = BoundedTypeVariableComponent.class.getField("field2");
+ Field field3 = BoundedTypeVariableComponent.class.getField("field3");
+ Field field4 = BoundedTypeVariableComponent.class.getField("field4");
+ Field field5 = BoundedTypeVariableComponent.class.getField("field5");
+ Field field6 = BoundedTypeVariableComponent.class.getField("field6");
+ Field field7 = BoundedTypeVariableComponent.class.getField("field7");
+
+ ParameterizedType pt = (ParameterizedType)field1.getGenericType();
+ Type argument = pt.getActualTypeArguments()[0];
+
+ Assert.assertFalse(ClassUtil.isUnboundedTypeVariable(argument));
+
+ pt = (ParameterizedType)field2.getGenericType();
+ argument = pt.getActualTypeArguments()[0];
+
+ Assert.assertFalse(ClassUtil.isUnboundedTypeVariable(argument));
+
+ pt = (ParameterizedType)field3.getGenericType();
+ argument = pt.getActualTypeArguments()[0];
+
+ Assert.assertTrue(ClassUtil.isUnboundedTypeVariable(argument));
+
+ pt = (ParameterizedType)field4.getGenericType();
+ argument = pt.getActualTypeArguments()[0];
+
+ Assert.assertFalse(ClassUtil.isUnboundedTypeVariable(argument));
+
+ argument = field5.getGenericType();
+
+ Assert.assertFalse(ClassUtil.isUnboundedTypeVariable(argument));
+
+ Type[] arguments = ((ParameterizedType)field6.getGenericType()).getActualTypeArguments();
+
+ for(Type arg : arguments)
+ {
+ Assert.assertTrue(ClassUtil.isUnboundedTypeVariable(arg));
+ }
+
+ pt = (ParameterizedType)field7.getGenericType();
+ argument = pt.getActualTypeArguments()[0];
+
+ Assert.assertFalse(ClassUtil.isUnboundedTypeVariable(argument));
+
+
+ }catch(Exception e)
+ {
+ fail("BoundedWildCardTest");
+ }
+
+ }
+}
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/parametrized/BoundedTypeVariableTest.java
------------------------------------------------------------------------------
svn:eol-style = native