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 [1/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...
Author: gerdogdu
Date: Sat Jun 27 08:52:08 2009
New Revision: 788940
URL: http://svn.apache.org/viewvc?rev=788940&view=rev
Log:
Adding portable implementation classes. Updating injection point impl. Updating full resouliton to
consider generic types.
Added:
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java (with props)
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedCallable.java (with props)
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedMember.java (with props)
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedConstructorImpl.java (with props)
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java (with props)
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedFieldImpl.java (with props)
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedMethodImpl.java (with props)
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedParameterImpl.java (with props)
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedTypeImpl.java (with props)
incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/generic/
incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/generic/GenericComponent.java (with props)
incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/generic/GenericComponentInjector.java (with props)
incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/generic/SuperGenericComponent.java (with props)
incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/parametrized/BoundedTypeVariableComponent.java (with props)
incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/parametrized/PersistentSuper.java (with props)
incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/generic/
incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/generic/GenericBeanTest.java (with props)
incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/parametrized/BoundedTypeVariableTest.java (with props)
Modified:
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractComponent.java (contents, props changed)
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractObservesComponent.java (contents, props changed)
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/Component.java (contents, props changed)
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ComponentImpl.java (contents, props changed)
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InstanceComponentImpl.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ObservableComponentImpl.java (contents, props changed)
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansFinder.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ChildActivityManager.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java (contents, props changed)
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorComparator.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/xml/WebBeansXMLDecorator.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/BeanObserverImpl.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/xml/BeanObserverXMLImpl.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableConstructor.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableField.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethods.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceFactory.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableConstructor.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableField.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableMethods.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorComparator.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataComparator.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLDefinitionUtil.java
incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/parametrized/Persistent.java
incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/servlet/TestContext.java
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractComponent.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractComponent.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractComponent.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractComponent.java Sat Jun 27 08:52:08 2009
@@ -38,19 +38,12 @@
import org.apache.webbeans.util.ClassUtil;
/**
- * Abstract implementation of the {@link Component} contract. There are several
- * different implementation of this abtract class, including
- * <ul>
- * <li>Bean Implementation Class Component,</li>
- * <li>Producer Method Component</li>
- * </ul>
- * <p>
- * Each subclass is responsible for overriding
- * {@link AbstractComponent#createInstance()} and
- * {@link AbstractComponent#destroyInstance(Object)} methods.
- * </p>
+ * Abstract implementation of the {@link Component} contract.
*
- * @since 1.0
+ * @version $Rev$ $Date$
+ *
+ * @see Component
+ * @see Bean
*/
public abstract class AbstractComponent<T> extends Component<T>
{
@@ -80,6 +73,9 @@
/** Stereotypes of the component */
protected Set<Annotation> stereoTypes = new HashSet<Annotation>();
+
+ /**This bean is specialized or not*/
+ protected boolean specializedBean;
/**
* Holds the all of the interceptor related data, contains around-invoke,
@@ -119,6 +115,11 @@
this.returnType = returnType;
}
+ /**
+ * Creates a new instance.
+ *
+ * @param webBeanType beans type
+ */
protected AbstractComponent(WebBeansType webBeanType)
{
super(ManagerImpl.getManager());
@@ -126,7 +127,9 @@
}
-
+ /**
+ * {@inheritDoc}
+ */
public IBeanInheritedMetaData getInheritedMetaData()
{
return this.inheritedMetaData;
@@ -562,10 +565,22 @@
}
+ public void setSpecializedBean(boolean specialized)
+ {
+ this.specializedBean = specialized;
+ }
+
+ public boolean isSpecializedBean()
+ {
+ return this.specializedBean;
+ }
+
+
public String toString()
{
StringBuilder builder = new StringBuilder();
- builder.append("{\n");
+ builder.append("{\n");
+ builder.append("\tName : "+ getName() +", WebBeans Type: "+ getWebBeansType() + "\n");
builder.append("\tAPI Types:\n");
builder.append("\t[\n");
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractComponent.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractObservesComponent.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractObservesComponent.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractObservesComponent.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractObservesComponent.java Sat Jun 27 08:52:08 2009
@@ -20,6 +20,7 @@
import javax.decorator.Decorates;
import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.Initializer;
import org.apache.webbeans.config.DefinitionUtil;
import org.apache.webbeans.exception.WebBeansException;
@@ -27,10 +28,22 @@
import org.apache.webbeans.inject.InjectableMethods;
import org.apache.webbeans.intercept.InterceptorType;
import org.apache.webbeans.intercept.InvocationContextImpl;
+import org.apache.webbeans.logger.WebBeansLogger;
import org.apache.webbeans.util.WebBeansUtil;
+/**
+ * Abstract class for owning observer methods.
+ *
+ * @version $Rev$ $Date$
+ *
+ * @param <T> bean class
+ */
public abstract class AbstractObservesComponent<T> extends AbstractComponent<T> implements ObservesMethodsOwner<T>
{
+ /**Logger instance*/
+ private final WebBeansLogger logger = WebBeansLogger.getLogger(getClass());
+
+ /**Bean observable method*/
private Set<Method> observableMethods = new HashSet<Method>();
/** Injected fields of the component */
@@ -39,13 +52,23 @@
/** Injected methods of the component */
private Set<Method> injectedMethods = new HashSet<Method>();
+ /**From realization*/
protected boolean fromRealizes;
+ /**
+ * Creates a new observer owner component.
+ *
+ * @param webBeansType webbean type
+ * @param returnType bean class type
+ */
protected AbstractObservesComponent(WebBeansType webBeansType, Class<T> returnType)
{
super(webBeansType, returnType);
}
+ /**
+ * {@inheritDoc}
+ */
protected T createInstance(CreationalContext<T> creationalContext)
{
beforeConstructor();
@@ -57,20 +80,43 @@
return instance;
}
+ /**
+ * {@inheritDoc}
+ */
protected void destroyInstance(T instance)
{
destroyComponentInstance(instance);
}
+ /**
+ * Sub-classes must override this method to create bean instance.
+ *
+ * @param creationalContext creational context
+ * @return bean instance
+ */
abstract protected T createComponentInstance(CreationalContext<T> creationalContext);
+ /**
+ * Sub-classes must override this method to destroy bean instance.
+ *
+ * @param instance object instance.
+ */
abstract protected void destroyComponentInstance(T instance);
+ /**
+ * Called before constructor
+ */
protected void beforeConstructor()
{
}
+ /**
+ * Called after bean instance is created.
+ *
+ * @param instance bean instance
+ * @param creationalContext cretional context object
+ */
protected void afterConstructor(T instance,CreationalContext<T> creationalContext)
{
//Inject fields
@@ -89,23 +135,25 @@
//Call Post Construct
if (WebBeansUtil.isContainsInterceptorMethod(getInterceptorStack(), InterceptorType.POST_CONSTRUCT))
{
- InvocationContextImpl impl = new InvocationContextImpl(null,instance, null, null, WebBeansUtil.getInterceptorMethods(getInterceptorStack(), InterceptorType.POST_CONSTRUCT), InterceptorType.POST_CONSTRUCT);
-
+ InvocationContextImpl impl = new InvocationContextImpl(null,instance, null, null, WebBeansUtil.getInterceptorMethods(getInterceptorStack(), InterceptorType.POST_CONSTRUCT), InterceptorType.POST_CONSTRUCT);
try
{
impl.proceed();
-
}
catch (Exception e)
{
+ logger.error("Error is occured while executing @PostConstruct",e);
throw new WebBeansException(e);
}
}
}
- /*
- * Injectable fields
+ /**
+ * Injects fields of the bean after constructing.
+ *
+ * @param instance bean instance
+ * @param creationalContext creational context
*/
protected void injectFields(T instance, CreationalContext<T> creationalContext)
{
@@ -119,9 +167,13 @@
}
}
}
-
- /*
- * Injectable methods
+
+ /**
+ * Injects all {@link Initializer} methods of the bean
+ * instance.
+ *
+ * @param instance bean instance
+ * @param creationalContext creational context instance
*/
@SuppressWarnings("unchecked")
protected void injectMethods(T instance, CreationalContext<T> creationalContext)
@@ -217,5 +269,14 @@
this.injectedMethods.add(method);
}
-
-}
+ /**
+ * Returns bean logger instance.
+ *
+ * @return logger
+ */
+ protected WebBeansLogger getLogger()
+ {
+ return this.logger;
+ }
+
+}
\ No newline at end of file
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractObservesComponent.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/Component.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/Component.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/Component.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/Component.java Sat Jun 27 08:52:08 2009
@@ -25,19 +25,15 @@
import org.apache.webbeans.intercept.InterceptorData;
/**
- * Extends the unpublished {@link Bean} interface for backward capability with
- * EDR-1 of the specification.
- * <p>
- * <b>This class is not used by the client. It is used entirely as internal. It
- * exists only for compatibility problems.</b>
- * </p>
+ * OWB specific extension of the {@link Bean} interface.
+ * It is used internally. Do not use it.
*
- * @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
- * @since 1.0
+ * @version $Rev$Â $Date$
+ * <T> bean class
*/
public abstract class Component<T> implements Bean<T>
{
- /**Manager for beans*/
+ /**Bean Manager*/
private final BeanManager manager;
/**
@@ -60,30 +56,94 @@
return manager;
}
+ /**
+ * Returns bean's inherited meta data.
+ *
+ * @return inherited meta data.
+ */
public abstract IBeanInheritedMetaData getInheritedMetaData();
+ /**
+ * Returna deployment type as annotation.
+ *
+ * @return deployment type as annotation
+ */
public abstract Annotation getType();
+ /**
+ * Sets bean deployment type annotation.
+ *
+ * @param type bean deployment type annotation
+ */
public abstract void setType(Annotation type);
+ /**
+ * Returns scope type annotation.
+ *
+ * @return scope type annotation
+ */
public abstract Annotation getImplScopeType();
+ /**
+ * Sets bean scope type annotation.
+ *
+ * @param scopeType bean scope type annotation
+ */
public abstract void setImplScopeType(Annotation scopeType);
+ /**
+ * Returns bean type.
+ *
+ * @return webbeans type
+ * @see WebBeansType
+ */
public abstract WebBeansType getWebBeansType();
+ /**
+ * Adds binding type.
+ *
+ * @param bindingType bean binding type
+ */
public abstract void addBindingType(Annotation bindingType);
+ /**
+ * Adds new stereotype annotation.
+ *
+ * @param stereoType stereotype annotation
+ */
public abstract void addStereoType(Annotation stereoType);
+ /**
+ * Adds new api type.
+ *
+ * @param apiType api type
+ */
public abstract void addApiType(Class<?> apiType);
+ /**
+ * Adds new injection point.
+ *
+ * @param injectionPoint injection point
+ */
public abstract void addInjectionPoint(InjectionPoint injectionPoint);
+ /**
+ * Returns set of binding type annotations.
+ *
+ * @return set of binding type annotations
+ */
public abstract Set<Annotation> getImplBindingTypes();
+ /**
+ * Gets stereotypes annotations.
+ */
public abstract Set<Annotation> getStereotypes();
+ /**
+ * Sets name of the bean.
+ *
+ * @param name bean name
+ */
public abstract void setName(String name);
public abstract int getPrecedence();
@@ -99,4 +159,8 @@
public abstract void setSerializable(boolean serializable);
public abstract void setNullable(boolean nullable);
+
+ public abstract void setSpecializedBean(boolean specialized);
+
+ public abstract boolean isSpecializedBean();
}
\ No newline at end of file
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/Component.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ComponentImpl.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ComponentImpl.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ComponentImpl.java Sat Jun 27 08:52:08 2009
@@ -16,6 +16,7 @@
import java.lang.reflect.Constructor;
import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
import org.apache.webbeans.context.creational.CreationalContextFactory;
import org.apache.webbeans.exception.WebBeansException;
@@ -25,13 +26,9 @@
import org.apache.webbeans.util.WebBeansUtil;
/**
- * Concrete implementation of the {@link AbstractComponent}.
- * <p>
- * It is defined as bean implementation class component.
- * </p>
+ * Managed bean implementation of the {@link Bean}.
*
- * @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
- * @since 1.0
+ * @version $Rev$Â $Date$
*/
public class ComponentImpl<T> extends AbstractObservesComponent<T>
{
@@ -43,6 +40,12 @@
this(returnType, WebBeansType.SIMPLE);
}
+ /**
+ * Creates a new instance.
+ *
+ * @param returnType bean class
+ * @param type webbeans type
+ */
public ComponentImpl(Class<T> returnType, WebBeansType type)
{
super(type, returnType);
@@ -50,10 +53,9 @@
//Setting inherited meta data instance
setInheritedMetaData();
}
-
- /*
- * (non-Javadoc)
- * @see org.apache.webbeans.component.AbstractComponent#createInstance()
+
+ /**
+ * {@inheritDoc}
*/
@Override
protected T createComponentInstance(CreationalContext<T> creationalContext)
@@ -63,15 +65,13 @@
T instance = ic.doInjection();
-// if(WebBeansUtil.isScopeTypeNormal(getScopeType()))
-// {
-// creationalContext.push(instance);
-// }
-
return instance;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
@SuppressWarnings("unchecked")
protected void destroyComponentInstance(T instance)
@@ -82,15 +82,16 @@
try
{
impl.proceed();
-
}
catch (Exception e)
{
+ getLogger().error("Error is occıred while executing @PreDestroy method",e);
throw new WebBeansException(e);
}
}
+ //Remove it from creational context, if any
CreationalContextFactory.getInstance().removeCreationalContext(this);
}
@@ -112,12 +113,5 @@
public void setConstructor(Constructor<T> constructor)
{
this.constructor = constructor;
- }
-
-
- public String toString()
- {
- return super.toString();
- }
-
-}
+ }
+}
\ No newline at end of file
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ComponentImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InstanceComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InstanceComponentImpl.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InstanceComponentImpl.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InstanceComponentImpl.java Sat Jun 27 08:52:08 2009
@@ -17,7 +17,6 @@
package org.apache.webbeans.component;
import java.lang.annotation.Annotation;
-import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import javax.enterprise.context.spi.CreationalContext;
@@ -27,7 +26,7 @@
public class InstanceComponentImpl<T> extends AbstractComponent<Instance<T>>
{
- private Class<T> injectedType;
+ private Type injectedType;
private Type[] actualTypeArguments = new Type[0];
@@ -36,26 +35,10 @@
public InstanceComponentImpl(Class<Instance<T>> returnType, Type injectedType, Type[] injectedTypeArguments)
{
super(WebBeansType.INSTANCE, returnType);
- configureInjectionClazz(injectedType);
+ this.injectedType = injectedType;
this.injectedTypeArguments = injectedTypeArguments;
}
- @SuppressWarnings("unchecked")
- private void configureInjectionClazz(Type type)
- {
- if(type instanceof ParameterizedType)
- {
- ParameterizedType pt = (ParameterizedType)type;
- this.injectedType = (Class<T>)pt.getRawType();
-
- this.actualTypeArguments = pt.getActualTypeArguments();
- }
- else
- {
- this.injectedType = (Class<T>)type;
- }
- }
-
@Override
protected Instance<T> createInstance(CreationalContext<Instance<T>> creationalContext)
{
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ObservableComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ObservableComponentImpl.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ObservableComponentImpl.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ObservableComponentImpl.java Sat Jun 27 08:52:08 2009
@@ -17,18 +17,13 @@
import java.util.Set;
import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.New;
import org.apache.webbeans.exception.WebBeansException;
/**
- * Component definition with {@link New} binding annotation.
- * <p>
- * It is defined as concrete java class component.
- * </p>
+ * Implicit observable bean definition.
*
- * @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
- * @since 1.0
+ * @version $Rev$Â $Date$
*/
public class ObservableComponentImpl<T, K> extends ComponentImpl<T>
{
@@ -88,7 +83,4 @@
{
return eventType;
}
-
-
-
-}
+}
\ No newline at end of file
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ObservableComponentImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java Sat Jun 27 08:52:08 2009
@@ -39,6 +39,7 @@
import javax.enterprise.inject.deployment.DeploymentType;
import javax.enterprise.inject.deployment.Specializes;
import javax.enterprise.inject.deployment.Standard;
+import javax.enterprise.inject.spi.Annotated;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.event.Fires;
@@ -177,11 +178,13 @@
* @param component configuring web beans component
* @param clazz bean implementation class
*/
- public static <T> void defineProducerMethodApiTypes(AbstractComponent<T> component, Class<T> clazz)
+ public static <T> void defineProducerMethodApiTypes(AbstractComponent<T> component, Type type)
{
Set<Type> types = component.getTypes();
types.add(Object.class);
+ Class<?> clazz = ClassUtil.getClazz(type);
+
if (clazz.isPrimitive() || clazz.isArray())
{
types.add(clazz);
@@ -189,7 +192,7 @@
}
else
{
- ClassUtil.setTypeHierarchy(component.getTypes(), clazz);
+ ClassUtil.setTypeHierarchy(component.getTypes(), type);
}
}
@@ -687,7 +690,7 @@
Annotation[] methodAnns = method.getDeclaredAnnotations();
- DefinitionUtil.defineProducerMethodApiTypes(component, returnType);
+ DefinitionUtil.defineProducerMethodApiTypes(component, method.getGenericReturnType());
DefinitionUtil.defineScopeType(component, methodAnns, "WebBeans producer method : " + method.getName() + " in class " + parent.getReturnType().getName() + " must declare default @ScopeType annotation");
WebBeansUtil.checkProducerGenericType(component,method);
DefinitionUtil.defineBindingTypes(component, methodAnns);
@@ -780,7 +783,7 @@
annot = AnnotationUtil.getRealizesGenericAnnotations(component.getReturnType(), annot);
}
- Set<Bean<T>> set = InjectionResolver.getInstance().implResolveByType(ClassUtil.getFirstRawType(type), ClassUtil.getActualTypeArguements(type), annot);
+ Set<Bean<T>> set = InjectionResolver.getInstance().implResolveByType(type, annot);
Bean<T> bean = set.iterator().next();
ProducerComponentImpl<?> pr = null;
@@ -1175,17 +1178,16 @@
public static void addImplicitComponentForInjectionPoint(InjectionPoint injectionPoint)
{
- Annotation obtains = injectionPoint.getAnnotation(Obtains.class);
- Annotation fires = injectionPoint.getAnnotation(Fires.class);
-
+ Annotated annotated = injectionPoint.getAnnotated();
+
//If contains the @Obtains, defines implicit component
- if(obtains != null)
+ if(annotated.isAnnotationPresent(Obtains.class))
{
WebBeansUtil.checkObtainsInjectionPointConditions(injectionPoint);
WebBeansUtil.addInjectedImplicitInstanceComponent(injectionPoint);
}
//If contains the @Fires, defines implicit component
- else if(fires != null)
+ else if(annotated.isAnnotationPresent(Fires.class))
{
EventUtil.checkObservableInjectionPointConditions(injectionPoint);
WebBeansUtil.addInjectedImplicitEventComponent(injectionPoint);
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java Sat Jun 27 08:52:08 2009
@@ -29,6 +29,7 @@
import javax.enterprise.event.Event;
import javax.enterprise.inject.Current;
import javax.enterprise.inject.deployment.Specializes;
+import javax.enterprise.inject.spi.Annotated;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.Decorator;
import javax.enterprise.inject.spi.InjectionPoint;
@@ -235,7 +236,8 @@
// check for InjectionPoint injection
if (rawType.equals(InjectionPoint.class))
{
- if (injectionPoint.getAnnotations().length == 1 && injectionPoint.getAnnotations()[0].annotationType().equals(Current.class))
+ Annotated annotated = injectionPoint.getAnnotated();
+ if (annotated.getAnnotations().size() == 1 && annotated.isAnnotationPresent(Current.class))
{
if (!bean.getScopeType().equals(Dependent.class))
{
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansFinder.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansFinder.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansFinder.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansFinder.java Sat Jun 27 08:52:08 2009
@@ -16,7 +16,6 @@
import java.util.HashMap;
import java.util.Map;
-import org.apache.webbeans.container.InjectionResolver;
import org.apache.webbeans.container.ManagerImpl;
import org.apache.webbeans.context.SessionContextManager;
import org.apache.webbeans.context.creational.CreationalContextFactory;
@@ -24,7 +23,6 @@
import org.apache.webbeans.decorator.DecoratorsManager;
import org.apache.webbeans.deployment.DeploymentTypeManager;
import org.apache.webbeans.deployment.StereoTypeManager;
-import org.apache.webbeans.event.NotificationManager;
import org.apache.webbeans.exception.WebBeansException;
import org.apache.webbeans.intercept.InterceptorsManager;
import org.apache.webbeans.util.ClassUtil;
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ChildActivityManager.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ChildActivityManager.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ChildActivityManager.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ChildActivityManager.java Sat Jun 27 08:52:08 2009
@@ -40,6 +40,7 @@
* and delegates all other requests to it's parent Manager.
*
*/
+@SuppressWarnings("unchecked")
public class ChildActivityManager extends ManagerImpl
{
@@ -323,14 +324,12 @@
}
/** {@inheritDoc} */
- @SuppressWarnings("unchecked")
public List<Decorator<?>> resolveDecorators(Set<Type> types, Annotation... bindingTypes)
{
return Collections.EMPTY_LIST;
}
/** {@inheritDoc} */
- @SuppressWarnings("unchecked")
public List<Interceptor<?>> resolveInterceptors(InterceptionType type, Annotation... interceptorBindings)
{
return Collections.EMPTY_LIST;
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java Sat Jun 27 08:52:08 2009
@@ -16,20 +16,17 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
-import java.util.Arrays;
+import java.lang.reflect.TypeVariable;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.List;
import java.util.Set;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;
import org.apache.webbeans.annotation.CurrentLiteral;
-import org.apache.webbeans.component.InstanceComponentImpl;
-import org.apache.webbeans.component.ObservableComponentImpl;
-import org.apache.webbeans.component.ProducerComponentImpl;
-import org.apache.webbeans.component.ProducerFieldComponent;
+import org.apache.webbeans.component.AbstractComponent;
+import org.apache.webbeans.config.WebBeansFinder;
import org.apache.webbeans.container.activity.ActivityManager;
import org.apache.webbeans.deployment.DeploymentTypeManager;
import org.apache.webbeans.exception.WebBeansConfigurationException;
@@ -38,17 +35,41 @@
import org.apache.webbeans.util.Asserts;
import org.apache.webbeans.util.ClassUtil;
+/**
+ * Injection point resolver class.
+ *
+ * <p>
+ * It is a singleton class per ClassLoader per JVM. It is
+ * responsible for resolbing the bean instances at the injection points for
+ * its bean manager.
+ * </p>
+ *
+ * @version $Rev$ $Date$
+ * @see WebBeansFinder
+ */
@SuppressWarnings("unchecked")
public class InjectionResolver
{
+ /**Bean Manager*/
private ManagerImpl manager;
+ /**
+ * Creates a new injection resolve for given bean manager.
+ *
+ * @param manager bean manager
+ */
public InjectionResolver(ManagerImpl manager)
{
this.manager = manager;
}
+ /**
+ * Returns bean manager injection resolver.
+ *
+ * @return bean manager injection resolver
+ * @see WebBeansFinder
+ */
public static InjectionResolver getInstance()
{
InjectionResolver instance = ActivityManager.getInstance().getCurrentActivity().getInjectionResolver();
@@ -59,7 +80,7 @@
/**
* Check the type of the injection point.
* <p>
- * Injection point type can not be wildcard or type variable type.
+ * Injection point type can not be {@link TypeVariable}.
* </p>
*
* @param injectionPoint injection point
@@ -69,22 +90,10 @@
{
Type type = injectionPoint.getType();
- if(type instanceof Class)
- {
- return;
- }
- else if(type instanceof ParameterizedType)
- {
- ParameterizedType pt = (ParameterizedType)type;
-
- if(!ClassUtil.checkParametrizedType(pt))
- {
- throw new WebBeansConfigurationException("Injection point type : " + injectionPoint + " can not contain generic definitions!");
- }
- }
- else
+ //Check for injection point type variable
+ if(ClassUtil.isTypeVariable(type))
{
- throw new WebBeansConfigurationException("Injection point type : " + injectionPoint + " can not contain generic definitions!");
+ throw new WebBeansConfigurationException("Injection point type : " + injectionPoint + " can not define Type Variable generic type");
}
}
@@ -102,8 +111,6 @@
Class<?> clazz = null;
- Type[] args = new Type[0];
-
if (type instanceof ParameterizedType)
{
ParameterizedType pt = (ParameterizedType) type;
@@ -113,8 +120,6 @@
throw new WebBeansConfigurationException("Injection point type : " + injectionPoint + " type can not be defined as Typevariable or Wildcard type!");
}
- args = pt.getActualTypeArguments();
-
clazz = (Class<?>) pt.getRawType();
}
else
@@ -125,7 +130,7 @@
Annotation[] bindingTypes = new Annotation[injectionPoint.getBindings().size()];
bindingTypes = injectionPoint.getBindings().toArray(bindingTypes);
- Set<Bean<Object>> beanSet = implResolveByType(clazz, args ,bindingTypes);
+ Set<Bean<Object>> beanSet = implResolveByType(type ,bindingTypes);
ResolutionUtil.checkResolvedBeans(beanSet, clazz, bindingTypes);
@@ -142,25 +147,21 @@
}
+ /**
+ * Returns bean for injection point.
+ *
+ * @param injectionPoint injection point declaration
+ * @return bean for injection point
+ */
public Bean<Object> getInjectionPointBean(InjectionPoint injectionPoint)
{
Type type = injectionPoint.getType();
Class<?> clazz = null;
- Type[] args = new Type[0];
-
if (type instanceof ParameterizedType)
{
- ParameterizedType pt = (ParameterizedType) type;
-
- if (!ClassUtil.checkParametrizedType(pt))
- {
- throw new WebBeansConfigurationException("Injection point : " + injectionPoint + " can not defined type variable or wildcard");
- }
-
- args = pt.getActualTypeArguments();
-
+ ParameterizedType pt = (ParameterizedType) type;
clazz = (Class<?>) pt.getRawType();
}
else
@@ -171,7 +172,7 @@
Annotation[] bindingTypes = new Annotation[injectionPoint.getBindings().size()];
bindingTypes = injectionPoint.getBindings().toArray(bindingTypes);
- Set<Bean<Object>> beanSet = implResolveByType(clazz, args ,bindingTypes);
+ Set<Bean<Object>> beanSet = implResolveByType(type ,bindingTypes);
ResolutionUtil.checkResolvedBeans(beanSet, clazz);
@@ -179,6 +180,12 @@
}
+ /**
+ * Returns set of beans for given bean name.
+ *
+ * @param name bean name
+ * @return set of beans for given bean name
+ */
public Set<Bean<?>> implResolveByName(String name)
{
Asserts.assertNotNull(name, "name parameter can not be null");
@@ -219,28 +226,63 @@
}
}
}
-
+
+ //Still Ambigious, check for specialization
+ if(resolvedComponents.size() > 1)
+ {
+ //Check for specialization
+ Set<Bean<?>> specializedComponents = findSpecializedForNameResolution(resolvedComponents);
+ if(specializedComponents.size() > 0)
+ {
+ return specializedComponents;
+ }
+ }
+
return resolvedComponents;
}
+
+
+ /**
+ * Returns filtered set by specialization.
+ *
+ * @param resolvedComponents result beans
+ * @return filtered set by specialization
+ */
+ private Set<Bean<?>> findSpecializedForNameResolution(Set<Bean<?>> resolvedComponents)
+ {
+ Set<Bean<?>> specializedComponents = new HashSet<Bean<?>>();
+ if(resolvedComponents.size() > 0)
+ {
+ for(Bean<?> bean : resolvedComponents)
+ {
+ AbstractComponent<?> component = (AbstractComponent<?>)bean;
+
+ if(component.isSpecializedBean())
+ {
+ specializedComponents.add(component);
+ }
+ }
+ }
+
+ return specializedComponents;
+ }
/**
* Resolution by type.
*
* @param <T> bean type info
- * @param apiType injection point api type
- * @param actualTypeArguments actual type arguments if parameterized type
+ * @param injectionPointType injection point api type
+ * @param injectionPointTypeArguments actual type arguments if parameterized type
* @param binding binding type of the injection point
* @return set of resolved beans
*/
- public <T> Set<Bean<T>> implResolveByType(Class<?> apiType, Type[] actualTypeArguments, Annotation... binding)
+ public <T> Set<Bean<T>> implResolveByType(Type injectionPointType, Annotation... binding)
{
- Asserts.assertNotNull(apiType, "apiType parameter can not be null");
+ Asserts.assertNotNull(injectionPointType, "injectionPointType parameter can not be null");
Asserts.assertNotNull(binding, "binding parameter can not be null");
- if(apiType.isPrimitive())
- {
- apiType = ClassUtil.getPrimitiveWrapper(apiType);
- }
+ Set<Bean<T>> results = new HashSet<Bean<T>>();
+ Set<Bean<?>> deployedComponents = this.manager.getBeans();
boolean currentBinding = false;
boolean returnAll = false;
@@ -251,11 +293,8 @@
binding[0] = new CurrentLiteral();
currentBinding = true;
}
-
- Set<Bean<T>> results = new HashSet<Bean<T>>();
- Set<Bean<?>> deployedComponents = this.manager.getBeans();
-
- if (apiType.equals(Object.class) && currentBinding)
+
+ if (injectionPointType.equals(Object.class) && currentBinding)
{
returnAll = true;
}
@@ -278,117 +317,69 @@
Iterator<Type> itComponentApiTypes = componentApiTypes.iterator();
while (itComponentApiTypes.hasNext())
{
- Class<?> componentApiType = (Class<?>)itComponentApiTypes.next();
+ Type componentApiType = itComponentApiTypes.next();
- if(componentApiType.isPrimitive())
+ if(ClassUtil.isAssignable(componentApiType, injectionPointType))
{
- componentApiType = ClassUtil.getPrimitiveWrapper(componentApiType);
- }
-
- if (actualTypeArguments.length > 0)
- {
- Type[] actualArgs = null;
-
- if (ClassUtil.isAssignable(apiType, componentApiType))
- {
- if (ProducerComponentImpl.class.isAssignableFrom(component.getClass()))
- {
- actualArgs = ((ProducerComponentImpl<?>) component).getActualTypeArguments();
- if (Arrays.equals(actualArgs, actualTypeArguments))
- {
- results.add((Bean<T>) component);
- break;
- }
-
- }
-
- else if(component instanceof ObservableComponentImpl)
- {
- ObservableComponentImpl<?, ?> observableComponent = (ObservableComponentImpl<?, ?>)component;
- Class<?> eventType = (Class<?>)actualTypeArguments[0];
- if(eventType.equals(observableComponent.getEventType()))
- {
- results.add((Bean<T>) component);
- break;
- }
- }
- else if(component instanceof InstanceComponentImpl)
- {
- InstanceComponentImpl<?> instanceComponent = (InstanceComponentImpl<?>)component;
- actualArgs = instanceComponent.getActualTypeArguments();
-
- if (Arrays.equals(actualArgs, actualTypeArguments))
- {
- results.add((Bean<T>) component);
- break;
- }
- }
- else if(component instanceof ProducerFieldComponent)
- {
- ProducerFieldComponent<?> pf = (ProducerFieldComponent<?>)component;
- actualArgs = pf.getActualTypeArguments();
-
- if (Arrays.equals(actualArgs, actualTypeArguments))
- {
- results.add((Bean<T>) component);
- break;
- }
-
- }
-
- else
- {
- actualArgs = ClassUtil.getGenericSuperClassTypeArguments(componentApiType);
- if (Arrays.equals(actualArgs, actualTypeArguments))
- {
- results.add((Bean<T>) component);
- break;
- }
- else
- {
- List<Type[]> listActualArgs = ClassUtil.getGenericSuperInterfacesTypeArguments(componentApiType);
- Iterator<Type[]> itListActualArgs = listActualArgs.iterator();
- while (itListActualArgs.hasNext())
- {
- actualArgs = itListActualArgs.next();
-
- if (Arrays.equals(actualArgs, actualTypeArguments))
- {
- results.add((Bean<T>) component);
- break;
- }
-
- }
- }
-
- }
-
- }
- }
- else
- {
- if (ClassUtil.isAssignable(apiType, componentApiType))
- {
- results.add((Bean<T>) component);
- break;
- }
- }
+ results.add((Bean<T>) component);
+ break;
+ }
}
- }
+ }
}
-
+
+ //Look for binding types
results = findByBindingType(results, binding);
-
- if (results != null && !results.isEmpty())
+ //Look for precedence
+ results = findByPrecedence(results);
+
+ //Ambigious resulotion, check for specialization
+ if(results.size() > 1)
{
- results = findByPrecedence(results);
+ //Look for specialization
+ results = findBySpecialization(results);
}
-
return results;
}
-
+
+ /**
+ * Returns specialized beans if exists, otherwise return input result
+ *
+ * @param <T> bean class type
+ * @param result result beans
+ * @return specialized beans if exists, otherwise return input result
+ */
+ private <T> Set<Bean<T>> findBySpecialization(Set<Bean<T>> result)
+ {
+ Iterator<Bean<T>> it = result.iterator();
+ Set<Bean<T>> res = new HashSet<Bean<T>>();
+
+ while(it.hasNext())
+ {
+ AbstractComponent<T> component = (AbstractComponent<T>)it.next();
+ if(component.isSpecializedBean())
+ {
+ res.add(component);
+ }
+ }
+
+ if(res.size() > 0)
+ {
+ return res;
+ }
+
+ return result;
+ }
+
+ /**
+ * Return filtered beans according to the deployment type precedence.
+ *
+ * @param <T> bean class
+ * @param result resulted beans
+ * @return filtered beans according to the deployment type precedence
+ */
private <T> Set<Bean<T>> findByPrecedence(Set<Bean<T>> result)
{
Bean<T> resolvedComponent = null;
@@ -429,6 +420,14 @@
return res;
}
+ /**
+ * Returns filtered bean set according to the binding types.
+ *
+ * @param <T> bean class
+ * @param remainingSet bean set for filtering by binding type
+ * @param annotations binding types on injection point
+ * @return filtered bean set according to the binding types
+ */
private <T> Set<Bean<T>> findByBindingType(Set<Bean<T>> remainingSet, Annotation... annotations)
{
Iterator<Bean<T>> it = remainingSet.iterator();
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java Sat Jun 27 08:52:08 2009
@@ -357,7 +357,7 @@
{
ResolutionUtil.getInstanceByTypeConditions(bindingTypes);
- return this.injectionResolver.implResolveByType(apiType, new Type[0], bindingTypes);
+ return this.injectionResolver.implResolveByType(apiType, bindingTypes);
}
public <T> Set<Bean<T>> resolveByType(TypeLiteral<T> apiType, Annotation... bindingTypes)
@@ -366,9 +366,8 @@
ResolutionUtil.resolveByTypeConditions(ptype);
ResolutionUtil.getInstanceByTypeConditions(bindingTypes);
-
- Type[] args = ptype.getActualTypeArguments();
- return this.injectionResolver.implResolveByType(apiType.getRawType(), args, bindingTypes);
+
+ return this.injectionResolver.implResolveByType(apiType.getType(), bindingTypes);
}
public <T> Set<Observer<T>> resolveObservers(T event, Annotation... bindings)
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorComparator.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorComparator.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorComparator.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorComparator.java Sat Jun 27 08:52:08 2009
@@ -18,16 +18,16 @@
import javax.enterprise.inject.spi.Decorator;
-public class DecoratorComparator implements Comparator<Decorator>, Serializable
+public class DecoratorComparator<T> implements Comparator<Decorator<T>>, Serializable
{
/** default serial version UID */
private static final long serialVersionUID = 1L;
- public int compare(Decorator o1, Decorator o2)
+ public int compare(Decorator<T> o1, Decorator<T> o2)
{
- WebBeansDecorator src = (WebBeansDecorator) o1;
- WebBeansDecorator target = (WebBeansDecorator) o2;
+ WebBeansDecorator<T> src = (WebBeansDecorator<T>) o1;
+ WebBeansDecorator<T> target = (WebBeansDecorator<T>) o2;
if (o1.equals(o2))
{
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java Sat Jun 27 08:52:08 2009
@@ -51,11 +51,11 @@
ManagerImpl.getManager().addDecorator(decorator);
}
- public static void configureXMLDecoratorClass(AbstractComponent<Object> delegate, XMLInjectionPointModel model)
+ public static <T> void configureXMLDecoratorClass(AbstractComponent<T> delegate, XMLInjectionPointModel model)
{
logger.info("Configuring the Web Beans XML based Decorator Class : " + delegate.getReturnType().getName() + " started");
- WebBeansXMLDecorator decorator = new WebBeansXMLDecorator(delegate, model);
+ WebBeansXMLDecorator<T> decorator = new WebBeansXMLDecorator<T>(delegate, model);
logger.info("Configuring the Web Beans XML based Decorator Class : " + delegate.getReturnType() + " ended");
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/xml/WebBeansXMLDecorator.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/xml/WebBeansXMLDecorator.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/xml/WebBeansXMLDecorator.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/xml/WebBeansXMLDecorator.java Sat Jun 27 08:52:08 2009
@@ -17,11 +17,11 @@
import org.apache.webbeans.decorator.WebBeansDecorator;
import org.apache.webbeans.inject.xml.XMLInjectionPointModel;
-public class WebBeansXMLDecorator extends WebBeansDecorator
+public class WebBeansXMLDecorator<T> extends WebBeansDecorator<T>
{
private XMLInjectionPointModel decoratesModel = null;
- public WebBeansXMLDecorator(AbstractComponent<Object> delegateComponent, XMLInjectionPointModel model)
+ public WebBeansXMLDecorator(AbstractComponent<T> delegateComponent, XMLInjectionPointModel model)
{
super(delegateComponent);
this.decoratesModel = model;
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/BeanObserverImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/BeanObserverImpl.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/BeanObserverImpl.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/BeanObserverImpl.java Sat Jun 27 08:52:08 2009
@@ -16,7 +16,6 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
@@ -188,25 +187,12 @@
if (!observesAnnotation)
{
- Type[] args = new Type[0];
- Class<?> clazz = null;
- if (type instanceof ParameterizedType)
- {
- ParameterizedType pt = (ParameterizedType) type;
- args = pt.getActualTypeArguments();
-
- clazz = (Class<?>) pt.getRawType();
- }
- else
- {
- clazz = (Class<?>) type;
- }
-
+ //Get parameter annotations
Annotation[] bindingTypes = AnnotationUtil.getBindingAnnotations(annot);
if (bindingTypes.length > 0)
{
- list.add(manager.getInstance(InjectionResolver.getInstance().implResolveByType(clazz, args, bindingTypes).iterator().next()));
+ list.add(manager.getInstance(InjectionResolver.getInstance().implResolveByType(type, bindingTypes).iterator().next()));
}
else
{
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/xml/BeanObserverXMLImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/xml/BeanObserverXMLImpl.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/xml/BeanObserverXMLImpl.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/xml/BeanObserverXMLImpl.java Sat Jun 27 08:52:08 2009
@@ -53,7 +53,7 @@
Set<Annotation> setBindingTypes = model.getBindingTypes();
Annotation[] anns = new Annotation[setBindingTypes.size()];
anns = setBindingTypes.toArray(anns);
- params.add(manager.getInstance(InjectionResolver.getInstance().implResolveByType(model.getInjectionClassType(), model.getActualTypeArguments(), anns).iterator().next()));
+ params.add(manager.getInstance(InjectionResolver.getInstance().implResolveByType(model.getInjectionGenericType(), anns).iterator().next()));
}
return params;
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java Sat Jun 27 08:52:08 2009
@@ -21,7 +21,6 @@
import javax.enterprise.context.Dependent;
import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.event.Event;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.event.Fires;
@@ -30,12 +29,10 @@
import org.apache.webbeans.container.InjectionResolver;
import org.apache.webbeans.container.ManagerImpl;
import org.apache.webbeans.context.ContextFactory;
-import org.apache.webbeans.exception.WebBeansConfigurationException;
import org.apache.webbeans.inject.impl.InjectionPointFactory;
import org.apache.webbeans.plugins.OpenWebBeansPlugin;
import org.apache.webbeans.plugins.PluginLoader;
import org.apache.webbeans.util.AnnotationUtil;
-import org.apache.webbeans.util.ClassUtil;
import org.apache.webbeans.util.WebBeansUtil;
/**
@@ -68,7 +65,7 @@
* @param annotations binding annotations at the injection point
* @return current component instance in the resolved component scope
*/
- public <T> Object inject(Class<T> type, Type[] args, Annotation... annotations)
+ public <T> Object inject(Type type, Annotation... annotations)
{
boolean dependentContext = false;
@@ -95,16 +92,15 @@
if (isObservableBinding(annotations))
{
- return injectForObservable(args, annotations);
+ return injectForObservable(type, annotations);
}
- //Find injection point for injecting instance
- InjectionPoint injectionPoint = InjectionPointFactory.getPartialInjectionPoint(this.injectionOwnerComponent, type, this.injectionMember, this.injectionAnnotations, annotations);
+ //Find injection point for injecting instance (null is passed, we used this internally!!!)
+ InjectionPoint injectionPoint = InjectionPointFactory.getPartialInjectionPoint(this.injectionOwnerComponent, type, this.injectionMember, null, annotations);
//Get injection point Bean component
Bean<?> component = InjectionResolver.getInstance().getInjectionPointBean(injectionPoint);
-
if (component.getScopeType().equals(Dependent.class))
{
if(WebBeansUtil.isSimpleWebBeans(this.injectionOwnerComponent))
@@ -197,9 +193,9 @@
return null;
}
- private Object injectForObservable(Type[] args, Annotation... annotations)
+ private Object injectForObservable(Type type, Annotation... annotations)
{
- Bean<?> bean = InjectionResolver.getInstance().implResolveByType(Event.class, args, annotations).iterator().next();
+ Bean<?> bean = InjectionResolver.getInstance().implResolveByType(type, annotations).iterator().next();
return injectForDependent(bean,null);
}
@@ -221,10 +217,13 @@
protected void checkParametrizedTypeForInjectionPoint(ParameterizedType pType)
{
+ /*
+ * Parametrized type is OK For last draft!
if (!ClassUtil.checkParametrizedType(pType))
{
throw new WebBeansConfigurationException("Injection point with parametrized type : " + pType + " can not define Type variable or Wildcard type");
}
+ */
}
/**
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableConstructor.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableConstructor.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableConstructor.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableConstructor.java Sat Jun 27 08:52:08 2009
@@ -15,7 +15,6 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
-import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
@@ -77,24 +76,7 @@
annot[0] = new CurrentLiteral();
}
- Type[] args = new Type[0];
- Class<?> clazz = null;
- if (type instanceof ParameterizedType)
- {
- ParameterizedType pt = (ParameterizedType) type;
-
- checkParametrizedTypeForInjectionPoint(pt);
-
- args = pt.getActualTypeArguments();
-
- clazz = (Class<?>) pt.getRawType();
- }
- else
- {
- clazz = (Class<?>) type;
- }
-
- list.add(inject(clazz, args, AnnotationUtil.getBindingAnnotations(annot)));
+ list.add(inject(type, AnnotationUtil.getBindingAnnotations(annot)));
i++;
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableField.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableField.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableField.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableField.java Sat Jun 27 08:52:08 2009
@@ -15,7 +15,6 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
-import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import javax.enterprise.context.spi.CreationalContext;
@@ -24,7 +23,6 @@
import org.apache.webbeans.component.AbstractComponent;
import org.apache.webbeans.exception.WebBeansException;
import org.apache.webbeans.util.AnnotationUtil;
-import org.apache.webbeans.util.ClassUtil;
/**
* Field type injection.
@@ -53,7 +51,7 @@
{
Type type = field.getGenericType();
- Annotation[] annots = field.getAnnotations();
+ Annotation[] annots = field.getDeclaredAnnotations();
this.injectionAnnotations = annots;
@@ -70,33 +68,12 @@
bindingAnnos[0] = new CurrentLiteral();
}
- if (!ClassUtil.isPublic(field.getModifiers()))
- {
- field.setAccessible(true);
- }
-
- Type[] args = new Type[0];
- Class<?> clazz = null;
- if (type instanceof ParameterizedType)
- {
- ParameterizedType pt = (ParameterizedType) type;
-
- checkParametrizedTypeForInjectionPoint(pt);
- args = pt.getActualTypeArguments();
-
- clazz = (Class<?>) pt.getRawType();
- }
- else
- {
- clazz = (Class<?>) type;
- }
-
if (!field.isAccessible())
{
field.setAccessible(true);
}
- Object object = inject(clazz, args, bindingAnnos);
+ Object object = inject(type, bindingAnnos);
field.set(instance, object);
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethods.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethods.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethods.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethods.java Sat Jun 27 08:52:08 2009
@@ -15,7 +15,6 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
@@ -64,16 +63,14 @@
Type[] types = m.getGenericParameterTypes();
List<Object> list = new ArrayList<Object>();
- Annotation[] methodAnnots = m.getAnnotations();
+ Annotation[] methodAnnots = m.getDeclaredAnnotations();
this.injectionAnnotations = methodAnnots;
if (isResource(methodAnnots))
{
// if the method itself is resource annotated, e.g. @PersistenceUnit
- Type[] args = new Type[0];
- Class<?> clazz = (Class<?>) types[0];
- list.add(inject(clazz, args, methodAnnots));
+ list.add(inject(types[0], methodAnnots));
}
else
{
@@ -91,22 +88,6 @@
annot[0] = new CurrentLiteral();
}
- Type[] args = new Type[0];
- Class<?> clazz = null;
- if (type instanceof ParameterizedType)
- {
- ParameterizedType pt = (ParameterizedType) type;
-
- checkParametrizedTypeForInjectionPoint(pt);
- args = pt.getActualTypeArguments();
-
- clazz = (Class<?>) pt.getRawType();
- }
- else
- {
- clazz = (Class<?>) type;
- }
-
Annotation anns[] = AnnotationUtil.getBindingAnnotations(annot);
//check producer component for @Disposes,@Observes via @Realizes
@@ -117,7 +98,7 @@
anns = fromRealizes;
}
- list.add(inject(clazz, args, anns));
+ list.add(inject(type, anns));
i++;
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java Sat Jun 27 08:52:08 2009
@@ -24,17 +24,28 @@
import java.util.Set;
import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedParameter;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;
-import org.apache.webbeans.annotation.CurrentLiteral;
import org.apache.webbeans.inject.xml.XMLInjectionModelType;
import org.apache.webbeans.inject.xml.XMLInjectionPointModel;
+import org.apache.webbeans.portable.AnnotatedElementFactory;
import org.apache.webbeans.util.AnnotationUtil;
import org.apache.webbeans.util.Asserts;
public class InjectionPointFactory
{
+ /**
+ *
+ * @param owner
+ * @param xmlInjectionModel
+ * @return
+ * @deprecated
+ */
public static InjectionPoint getXMLInjectionPointData(Bean<?> owner, XMLInjectionPointModel xmlInjectionModel)
{
Asserts.assertNotNull(owner, "owner parameter can not be null");
@@ -65,7 +76,7 @@
if(available)
{
- injectionPoint = getGenericInjectionPoint(owner, anns, xmlInjectionModel.getInjectionGenericType(), xmlInjectionModel.getInjectionMember());
+ injectionPoint = getGenericInjectionPoint(owner, anns, xmlInjectionModel.getInjectionGenericType(), xmlInjectionModel.getInjectionMember(),null);
}
return injectionPoint;
@@ -81,7 +92,7 @@
if(!checkFieldApplicable(annots))
{
- return getGenericInjectionPoint(owner, annots, member.getGenericType(), member);
+ return getGenericInjectionPoint(owner, annots, member.getGenericType(), member, AnnotatedElementFactory.newAnnotatedField(member, member.getDeclaringClass()));
}
else
{
@@ -100,20 +111,20 @@
return false;
}
- private static InjectionPoint getGenericInjectionPoint(Bean<?> owner, Annotation[] annots, Type type, Member member)
+ private static InjectionPoint getGenericInjectionPoint(Bean<?> owner, Annotation[] annots, Type type, Member member,Annotated annotated)
{
InjectionPointImpl injectionPoint = null;
Annotation[] bindingAnnots = AnnotationUtil.getBindingAnnotations(annots);
- injectionPoint = new InjectionPointImpl(owner, type, member);
+ injectionPoint = new InjectionPointImpl(owner, type, member, annotated);
- addAnnotation(injectionPoint, annots, false);
addAnnotation(injectionPoint, bindingAnnots, true);
return injectionPoint;
}
+ @SuppressWarnings("unchecked")
public static List<InjectionPoint> getMethodInjectionPointData(Bean<?> owner, Method member)
{
Asserts.assertNotNull(owner, "owner parameter can not be null");
@@ -121,32 +132,17 @@
List<InjectionPoint> lists = new ArrayList<InjectionPoint>();
- Type[] types = member.getGenericParameterTypes();
- Annotation[][] annots = member.getParameterAnnotations();
-
- if (types.length > 0)
+ AnnotatedMethod method = AnnotatedElementFactory.newAnnotatedMethod(member, member.getDeclaringClass());
+ List<AnnotatedParameter<?>> parameters = method.getParameters();
+
+ InjectionPoint point = null;
+
+ for(AnnotatedParameter<?> parameter : parameters)
{
- int i = 0;
-
- for (Type type : types)
- {
- Annotation[] annot = annots[i];
-
- if (annot.length == 0)
- {
- annot = new Annotation[1];
- annot[0] = new CurrentLiteral();
- }
-
- if (!checkMethodApplicable(annot))
- {
- lists.add(getGenericInjectionPoint(owner, annot, type, member));
- }
-
- i++;
- }
+ point = getGenericInjectionPoint(owner, parameter.getAnnotations().toArray(new Annotation[0]), parameter.getBaseType(), member , parameter);
+ lists.add(point);
}
-
+
return lists;
}
@@ -165,9 +161,9 @@
}
- public static InjectionPoint getPartialInjectionPoint(Bean<?> owner,Type type, Member member, Annotation[] anns, Annotation...bindings)
+ public static InjectionPoint getPartialInjectionPoint(Bean<?> owner,Type type, Member member, Annotated annotated, Annotation...bindings)
{
- InjectionPointImpl impl = new InjectionPointImpl(owner,type,member);
+ InjectionPointImpl impl = new InjectionPointImpl(owner,type,member,annotated);
for(Annotation annot : bindings)
@@ -175,15 +171,11 @@
impl.addBindingAnnotation(annot);
}
- for(Annotation annot : anns)
- {
- impl.addAnnotation(annot);
- }
-
return impl;
}
+ @SuppressWarnings("unchecked")
public static List<InjectionPoint> getConstructorInjectionPointData(Bean<?> owner, Constructor<?> member)
{
Asserts.assertNotNull(owner, "owner parameter can not be null");
@@ -191,29 +183,17 @@
List<InjectionPoint> lists = new ArrayList<InjectionPoint>();
- Type[] types = member.getGenericParameterTypes();
- Annotation[][] annots = member.getParameterAnnotations();
-
- if (types.length > 0)
+ AnnotatedConstructor constructor = AnnotatedElementFactory.newAnnotatedConstructor(member);
+ List<AnnotatedParameter<?>> parameters = constructor.getParameters();
+
+ InjectionPoint point = null;
+
+ for(AnnotatedParameter<?> parameter : parameters)
{
- int i = 0;
-
- for (Type type : types)
- {
- Annotation[] annot = annots[i];
-
- if (annot.length == 0)
- {
- annot = new Annotation[1];
- annot[0] = new CurrentLiteral();
- }
-
- lists.add(getGenericInjectionPoint(owner, annot, type, member));
-
- i++;
- }
+ point = getGenericInjectionPoint(owner, parameter.getAnnotations().toArray(new Annotation[0]), parameter.getBaseType(), member , parameter);
+ lists.add(point);
}
-
+
return lists;
}
@@ -225,12 +205,7 @@
{
impl.addBindingAnnotation(ann);
}
- else
- {
- impl.addAnnotation(ann);
- }
}
- }
-
+ }
}
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java Sat Jun 27 08:52:08 2009
@@ -25,35 +25,28 @@
import java.util.HashSet;
import java.util.Set;
+import javax.enterprise.inject.spi.Annotated;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;
-import org.apache.webbeans.exception.WebBeansConfigurationException;
-import org.apache.webbeans.util.ClassUtil;
-
class InjectionPointImpl implements InjectionPoint
{
private Set<Annotation> bindingAnnotations = new HashSet<Annotation>();
- private Set<Annotation> annotations = new HashSet<Annotation>();
-
private Bean<?> ownerBean;
private Member injectionMember;
private Type injectionType;
- InjectionPointImpl(Bean<?> ownerBean, Type type, Member member)
+ private Annotated annotated;
+
+ InjectionPointImpl(Bean<?> ownerBean, Type type, Member member, Annotated annotated)
{
- //Check for injection point type variable
- if(ClassUtil.isTypeVariable(type))
- {
- throw new WebBeansConfigurationException("Injection point in bean : " + ownerBean + " can not define Type Variable generic type");
- }
-
this.ownerBean = ownerBean;
this.injectionMember = member;
this.injectionType = type;
+ this.annotated = annotated;
}
void addBindingAnnotation(Annotation bindingannotation)
@@ -61,35 +54,6 @@
this.bindingAnnotations.add(bindingannotation);
}
- void addAnnotation(Annotation annotation)
- {
- this.annotations.add(annotation);
- }
-
-
- @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;
- }
-
- public Annotation[] getAnnotations()
- {
- Annotation[] ann = new Annotation[this.annotations.size()];
- ann = this.annotations.toArray(ann);
-
- return ann;
- }
-
public Bean<?> getBean()
{
@@ -104,7 +68,6 @@
public Member getMember()
{
-
return this.injectionMember;
}
@@ -114,18 +77,25 @@
return this.injectionType;
}
- public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
+
+ @Override
+ public Annotated getAnnotated()
+ {
+ return annotated;
+ }
+
+ @Override
+ public boolean isDelegate()
+ {
+ return false;
+ }
+
+ @Override
+ public boolean isTransient()
{
- for(Annotation ann : this.annotations)
- {
- if(ann.annotationType().equals(annotationType))
- {
- return true;
- }
- }
-
return false;
}
+
public String toString()
{
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceFactory.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceFactory.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceFactory.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceFactory.java Sat Jun 27 08:52:08 2009
@@ -28,7 +28,7 @@
}
- public static <T> Instance<T> getInstance(Class<T> injectedType, Type[] actualTypeArguments, Annotation...annotations)
+ public static <T> Instance<T> getInstance(Type injectedType, Type[] actualTypeArguments, Annotation...annotations)
{
InstanceImpl<T> instance = new InstanceImpl<T>(injectedType,actualTypeArguments,annotations);
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java Sat Jun 27 08:52:08 2009
@@ -30,6 +30,7 @@
import org.apache.webbeans.container.ManagerImpl;
import org.apache.webbeans.container.ResolutionUtil;
import org.apache.webbeans.util.AnnotationUtil;
+import org.apache.webbeans.util.ClassUtil;
/**
* Implements the {@link Instance} interface.
@@ -38,7 +39,7 @@
class InstanceImpl<T> implements Instance<T>
{
/**Injected class type*/
- private Class<T> injectionClazz;
+ private Type injectionClazz;
/**Injected point actual type arguments*/
private Type[] actualTypeArguments = new Type[0];
@@ -52,7 +53,7 @@
* @param actualTypeArguments actual type arguments
* @param annotations binding annotations
*/
- InstanceImpl(Class<T> injectionClazz, Type[] actualTypeArguments, Annotation...annotations)
+ InstanceImpl(Type injectionClazz, Type[] actualTypeArguments, Annotation...annotations)
{
this.injectionClazz = injectionClazz;
this.actualTypeArguments = actualTypeArguments;
@@ -92,9 +93,9 @@
anns = this.bindingAnnotations.toArray(anns);
InjectionResolver resolver = InjectionResolver.getInstance();
- Set<Bean<T>> beans = resolver.implResolveByType(this.injectionClazz, this.actualTypeArguments, anns);
+ Set<Bean<T>> beans = resolver.implResolveByType(this.injectionClazz, anns);
- ResolutionUtil.checkResolvedBeans(beans, this.injectionClazz);
+ ResolutionUtil.checkResolvedBeans(beans, ClassUtil.getClazz(this.injectionClazz));
Bean<T> bean = beans.iterator().next();
@@ -105,7 +106,7 @@
{
StringBuilder builder = new StringBuilder();
builder.append("Instance<");
- builder.append(this.injectionClazz.getName());
+ builder.append(ClassUtil.getClazz(this.injectionClazz).getName());
builder.append(">");
builder.append(" with actual type arguments {");
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableConstructor.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableConstructor.java?rev=788940&r1=788939&r2=788940&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableConstructor.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableConstructor.java Sat Jun 27 08:52:08 2009
@@ -63,7 +63,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