[webbeans-commits] Webbeans SVN: r98 - in ri/trunk/webbeans-ri/src: main/java/org/jboss/webbeans/model and 1 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Mon Sep 8 14:57:12 EDT 2008
Author: pete.muir at jboss.org
Date: 2008-09-08 14:57:12 -0400 (Mon, 08 Sep 2008)
New Revision: 98
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AbstractAnnotatedItem.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/SimpleAnnotatedItem.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AbstractEnterpriseComponentModel.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AbstractProducerComponentModel.java
Removed:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/SimpleAnnotatedItem.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/JmsComponentModel.java
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedItem.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedType.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/SimpleAnnotatedMethod.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/SimpleAnnotatedType.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AbstractClassComponentModel.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AbstractComponentModel.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/EnterpriseComponentModel.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/MergedStereotypesModel.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/ProducerMethodComponentModel.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/RemoteComponentModel.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/SimpleComponentModel.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/StereotypeModel.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ConstructorMetaModelTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EnterpriseComponentModelTest.java
Log:
Use object orientation properly
Copied: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AbstractAnnotatedItem.java (from rev 95, ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/SimpleAnnotatedItem.java)
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AbstractAnnotatedItem.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AbstractAnnotatedItem.java 2008-09-08 18:57:12 UTC (rev 98)
@@ -0,0 +1,99 @@
+package org.jboss.webbeans.introspector;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+public abstract class AbstractAnnotatedItem<E> implements AnnotatedItem<E>
+{
+
+ private Map<Class<? extends Annotation>, Annotation> annotationMap;
+ private Map<Class<? extends Annotation>, Set<Annotation>> metaAnnotations;
+ private Set<Annotation> annotationSet;
+
+ public AbstractAnnotatedItem(Map<Class<? extends Annotation>, Annotation> annotationMap)
+ {
+ if (annotationMap == null)
+ {
+ throw new NullPointerException("annotationMap cannot be null");
+ }
+ this.annotationMap = annotationMap;
+ }
+
+ protected static Map<Class<? extends Annotation>, Annotation> buildAnnotationMap(AnnotatedElement element)
+ {
+ Map<Class<? extends Annotation>, Annotation> annotationMap = new HashMap<Class<? extends Annotation>, Annotation>();
+ for (Annotation annotation : element.getAnnotations())
+ {
+ annotationMap.put(annotation.annotationType(), annotation);
+ }
+ return annotationMap;
+ }
+
+ protected static Set<Annotation> populateAnnotationSet(Set<Annotation> annotationSet, Map<Class<? extends Annotation>, Annotation> annotationMap)
+ {
+ for (Entry<Class<? extends Annotation>, Annotation> entry : annotationMap.entrySet())
+ {
+ annotationSet.add(entry.getValue());
+ }
+ return annotationSet;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends Annotation> T getAnnotation(Class<? extends T> annotationType)
+ {
+ return (T) annotationMap.get(annotationType);
+ }
+
+ public Set<Annotation> getAnnotations(Class<? extends Annotation> metaAnnotationType)
+ {
+ if (metaAnnotations == null)
+ {
+ metaAnnotations = new HashMap<Class<? extends Annotation>, Set<Annotation>>();
+ }
+ populateMetaAnnotationMap(metaAnnotationType, metaAnnotations, annotationMap);
+ return metaAnnotations.get(metaAnnotationType);
+ }
+
+ public Set<Annotation> getAnnotations()
+ {
+ if (annotationSet == null)
+ {
+ annotationSet = populateAnnotationSet(new HashSet<Annotation>(), annotationMap);
+ }
+ return annotationSet;
+ }
+
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotatedType)
+ {
+ return annotationMap.containsKey(annotatedType);
+ }
+
+ protected static <T extends Annotation> Map<Class<? extends Annotation>, Set<Annotation>> populateMetaAnnotationMap(
+ Class<T> metaAnnotationType, Map<Class<? extends Annotation>, Set<Annotation>> metaAnnotations, Map<Class<? extends Annotation>, Annotation> annotationMap)
+ {
+ if (!metaAnnotations.containsKey(metaAnnotationType))
+ {
+ Set<Annotation> s = new HashSet<Annotation>();
+ for (Entry<Class<? extends Annotation>, Annotation> entry : annotationMap.entrySet())
+ {
+ if (entry.getValue().annotationType().isAnnotationPresent(metaAnnotationType))
+ {
+ s.add(entry.getValue());
+ }
+ }
+ metaAnnotations.put(metaAnnotationType, s);
+ }
+ return metaAnnotations;
+ }
+
+ protected Map<Class<? extends Annotation>, Annotation> getAnnotationMap()
+ {
+ return annotationMap;
+ }
+
+}
\ No newline at end of file
Property changes on: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AbstractAnnotatedItem.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedItem.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedItem.java 2008-09-08 18:56:33 UTC (rev 97)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedItem.java 2008-09-08 18:57:12 UTC (rev 98)
@@ -11,7 +11,7 @@
* @author Pete Muir
*
*/
-public interface AnnotatedItem
+public interface AnnotatedItem<E>
{
/**
@@ -19,7 +19,7 @@
*
* An empty set is returned if no annotations are present
*/
- public abstract <T extends Annotation> Set<T> getAnnotations();
+ public <A extends Annotation> Set<A> getAnnotations();
/**
* Get all annotations which are annotated with the given meta annotation
@@ -28,21 +28,23 @@
* If no annotations are present which are annotated with the given meta
* annotation an empty set is returned
*/
- public abstract <T extends Annotation> Set<Annotation> getAnnotations(
- Class<T> metaAnnotationType);
+ public Set<Annotation> getAnnotations(
+ Class<? extends Annotation> metaAnnotationType);
/**
* Get an annotation for the annotation type specified.
*
* If the annotation isn't present, null is returned
*/
- public abstract <T extends Annotation> T getAnnotation(
- Class<T> annotationType);
+ public <A extends Annotation> A getAnnotation(
+ Class<? extends A> annotationType);
/**
* Return true if the annotation type specified is present
*/
- public abstract boolean isAnnotationPresent(
+ public boolean isAnnotationPresent(
Class<? extends Annotation> annotationType);
+
+ public E getDelegate();
}
\ No newline at end of file
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java 2008-09-08 18:56:33 UTC (rev 97)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java 2008-09-08 18:57:12 UTC (rev 98)
@@ -9,7 +9,7 @@
* @author Pete Muir
*
*/
-public interface AnnotatedMethod extends AnnotatedItem
+public interface AnnotatedMethod extends AnnotatedItem<Method>
{
public Method getAnnotatedMethod();
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedType.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedType.java 2008-09-08 18:56:33 UTC (rev 97)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedType.java 2008-09-08 18:57:12 UTC (rev 98)
@@ -8,13 +8,13 @@
* @author Pete Muir
*
*/
-public interface AnnotatedType extends AnnotatedItem
+public interface AnnotatedType<T> extends AnnotatedItem<Class<? extends T>>
{
/**
* Return the class of the annotated item. If this annotatedItem isn't in use
* then this method should return null
*/
- public Class<?> getAnnotatedClass();
+ public Class<? extends T> getAnnotatedClass();
}
\ No newline at end of file
Deleted: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/SimpleAnnotatedItem.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/SimpleAnnotatedItem.java 2008-09-08 18:56:33 UTC (rev 97)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/SimpleAnnotatedItem.java 2008-09-08 18:57:12 UTC (rev 98)
@@ -1,99 +0,0 @@
-package org.jboss.webbeans.introspector;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-
-public class SimpleAnnotatedItem implements AnnotatedItem
-{
-
- private Map<Class<? extends Annotation>, Annotation> annotationMap;
- private Map<Class<? extends Annotation>, Set<Annotation>> metaAnnotations;
- private Set<Annotation> annotationSet;
-
- public SimpleAnnotatedItem(Map<Class<? extends Annotation>, Annotation> annotationMap)
- {
- if (annotationMap == null)
- {
- throw new NullPointerException("annotationMap cannot be null");
- }
- this.annotationMap = annotationMap;
- }
-
- protected static Map<Class<? extends Annotation>, Annotation> buildAnnotationMap(AnnotatedElement element)
- {
- Map<Class<? extends Annotation>, Annotation> annotationMap = new HashMap<Class<? extends Annotation>, Annotation>();
- for (Annotation annotation : element.getAnnotations())
- {
- annotationMap.put(annotation.annotationType(), annotation);
- }
- return annotationMap;
- }
-
- protected static Set<Annotation> populateAnnotationSet(Set<Annotation> annotationSet, Map<Class<? extends Annotation>, Annotation> annotationMap)
- {
- for (Entry<Class<? extends Annotation>, Annotation> entry : annotationMap.entrySet())
- {
- annotationSet.add(entry.getValue());
- }
- return annotationSet;
- }
-
- @SuppressWarnings("unchecked")
- public <T extends Annotation> T getAnnotation(Class<T> annotationType)
- {
- return (T) annotationMap.get(annotationType);
- }
-
- public <T extends Annotation> Set<Annotation> getAnnotations(Class<T> metaAnnotationType)
- {
- if (metaAnnotations == null)
- {
- metaAnnotations = new HashMap<Class<? extends Annotation>, Set<Annotation>>();
- }
- populateMetaAnnotationMap(metaAnnotationType, metaAnnotations, annotationMap);
- return metaAnnotations.get(metaAnnotationType);
- }
-
- public Set<Annotation> getAnnotations()
- {
- if (annotationSet == null)
- {
- annotationSet = populateAnnotationSet(new HashSet<Annotation>(), annotationMap);
- }
- return annotationSet;
- }
-
- public boolean isAnnotationPresent(Class<? extends Annotation> annotatedType)
- {
- return annotationMap.containsKey(annotatedType);
- }
-
- protected static <T extends Annotation> Map<Class<? extends Annotation>, Set<Annotation>> populateMetaAnnotationMap(
- Class<T> metaAnnotationType, Map<Class<? extends Annotation>, Set<Annotation>> metaAnnotations, Map<Class<? extends Annotation>, Annotation> annotationMap)
- {
- if (!metaAnnotations.containsKey(metaAnnotationType))
- {
- Set<Annotation> s = new HashSet<Annotation>();
- for (Entry<Class<? extends Annotation>, Annotation> entry : annotationMap.entrySet())
- {
- if (entry.getValue().annotationType().isAnnotationPresent(metaAnnotationType))
- {
- s.add(entry.getValue());
- }
- }
- metaAnnotations.put(metaAnnotationType, s);
- }
- return metaAnnotations;
- }
-
- protected Map<Class<? extends Annotation>, Annotation> getAnnotationMap()
- {
- return annotationMap;
- }
-
-}
\ No newline at end of file
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/SimpleAnnotatedItem.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/SimpleAnnotatedItem.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/SimpleAnnotatedItem.java 2008-09-08 18:57:12 UTC (rev 98)
@@ -0,0 +1,19 @@
+package org.jboss.webbeans.introspector;
+
+import java.lang.annotation.Annotation;
+import java.util.Map;
+
+public class SimpleAnnotatedItem<E> extends AbstractAnnotatedItem<E>
+{
+
+ public SimpleAnnotatedItem(Map<Class<? extends Annotation>, Annotation> annotationMap)
+ {
+ super(annotationMap);
+ }
+
+ public E getDelegate()
+ {
+ return null;
+ }
+
+}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/SimpleAnnotatedMethod.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/SimpleAnnotatedMethod.java 2008-09-08 18:56:33 UTC (rev 97)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/SimpleAnnotatedMethod.java 2008-09-08 18:57:12 UTC (rev 98)
@@ -2,7 +2,7 @@
import java.lang.reflect.Method;
-public class SimpleAnnotatedMethod extends SimpleAnnotatedItem implements AnnotatedMethod
+public class SimpleAnnotatedMethod extends AbstractAnnotatedItem<Method> implements AnnotatedMethod
{
private Method annotatedMethod;
@@ -24,4 +24,9 @@
return annotatedMethod + " " + getAnnotatedMethod().toString();
}
+ public Method getDelegate()
+ {
+ return annotatedMethod;
+ }
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/SimpleAnnotatedType.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/SimpleAnnotatedType.java 2008-09-08 18:56:33 UTC (rev 97)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/SimpleAnnotatedType.java 2008-09-08 18:57:12 UTC (rev 98)
@@ -10,23 +10,23 @@
* @author pmuir
*
*/
-public class SimpleAnnotatedType extends SimpleAnnotatedItem implements AnnotatedType
+public class SimpleAnnotatedType<T> extends AbstractAnnotatedItem<Class<? extends T>> implements AnnotatedType<T>
{
- private Class<?> annotatedClass;
+ private Class<? extends T> annotatedClass;
- public SimpleAnnotatedType(Class<?> annotatedClass, Map<Class<? extends Annotation>, Annotation> annotationMap)
+ public SimpleAnnotatedType(Class<? extends T> annotatedClass, Map<Class<? extends Annotation>, Annotation> annotationMap)
{
super(annotationMap);
this.annotatedClass = annotatedClass;
}
- public SimpleAnnotatedType(Class<?> annotatedClass)
+ public SimpleAnnotatedType(Class<? extends T> annotatedClass)
{
this(annotatedClass, buildAnnotationMap(annotatedClass));
}
- public Class<?> getAnnotatedClass()
+ public Class<? extends T> getAnnotatedClass()
{
return annotatedClass;
}
@@ -36,5 +36,10 @@
{
return annotatedClass + " " + super.getAnnotationMap().toString();
}
+
+ public Class<? extends T> getDelegate()
+ {
+ return annotatedClass;
+ }
}
\ No newline at end of file
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AbstractClassComponentModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AbstractClassComponentModel.java 2008-09-08 18:56:33 UTC (rev 97)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AbstractClassComponentModel.java 2008-09-08 18:57:12 UTC (rev 98)
@@ -1,26 +1,11 @@
package org.jboss.webbeans.model;
-
-import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
import java.util.logging.Logger;
import javax.webbeans.Dependent;
-import javax.webbeans.DeploymentType;
-import javax.webbeans.Destroys;
-import javax.webbeans.Named;
-import javax.webbeans.ScopeType;
import org.jboss.webbeans.ContainerImpl;
-import org.jboss.webbeans.bindings.DependentBinding;
-import org.jboss.webbeans.bindings.ProductionBinding;
-import org.jboss.webbeans.ejb.EjbMetaData;
-import org.jboss.webbeans.injectable.InjectableMethod;
-import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.AnnotatedType;
import org.jboss.webbeans.util.LoggerUtil;
import org.jboss.webbeans.util.Reflections;
@@ -34,17 +19,14 @@
* @author Pete Muir
*
*/
-public abstract class AbstractClassComponentModel<T> extends AbstractComponentModel<T>
+public abstract class AbstractClassComponentModel<T> extends AbstractComponentModel<T, Class<? extends T>>
{
private static Logger log = LoggerUtil.getLogger(LOGGER_NAME);
- private Annotation deploymentType;
- private MergedStereotypesModel mergedStereotypes;
- private String name;
- private Annotation scopeType;
private Class<? extends T> type;
- private Set<Annotation> bindingTypes;
+ private AnnotatedType<T> annotatedItem;
+ private AnnotatedType<T> xmlAnnotatedItem;
/**
*
@@ -53,7 +35,7 @@
* @param container
*/
@SuppressWarnings("unchecked")
- public AbstractClassComponentModel(AnnotatedType annotatedItem, AnnotatedType xmlAnnotatedItem, ContainerImpl container)
+ public AbstractClassComponentModel(AnnotatedType<T> annotatedItem, AnnotatedType xmlAnnotatedItem)
{
if (annotatedItem == null)
{
@@ -64,36 +46,51 @@
{
throw new NullPointerException("xmlAnnotatedItem must not be null. If the component is declared just in Java, pass in an empty xmlAnnotatedItem");
}
- this.type = (Class<? extends T>) initType(annotatedItem, xmlAnnotatedItem);
- log.fine("Building Web Bean component metadata for " + type);
- this.bindingTypes = initBindingTypes(annotatedItem, xmlAnnotatedItem);
- mergedStereotypes = new MergedStereotypesModel(annotatedItem, xmlAnnotatedItem, container);
- this.deploymentType = initDeploymentType(mergedStereotypes, annotatedItem, xmlAnnotatedItem, container);
- this.scopeType = initScopeType(mergedStereotypes, annotatedItem, xmlAnnotatedItem);
- this.name = initName(getMergedStereotypes(), annotatedItem, xmlAnnotatedItem, getType());
- checkRequiredTypesImplemented(getMergedStereotypes(), getType());
- checkScopeAllowed(getMergedStereotypes(), getScopeType(), getType());
+ this.annotatedItem = annotatedItem;
+ this.xmlAnnotatedItem = xmlAnnotatedItem;
+ }
+
+ @Override
+ protected void init(ContainerImpl container)
+ {
+ super.init(container);
+ checkRequiredTypesImplemented();
+ checkScopeAllowed();
// TODO This is too high
checkComponentImplementation(getType());
// TODO Interceptors
}
+ @Override
+ protected AnnotatedType<T> getAnnotatedItem()
+ {
+ return annotatedItem;
+ }
+
+ @Override
+ protected AnnotatedType<T> getXmlAnnotatedItem()
+ {
+ return xmlAnnotatedItem;
+ }
+
@SuppressWarnings("unchecked")
- protected static Class<?> initType(AnnotatedType annotatedItem, AnnotatedType xmlAnnotatedItem)
+ protected void initType()
{
- if (annotatedItem.getAnnotatedClass() != null && xmlAnnotatedItem.getAnnotatedClass() != null && !annotatedItem.getAnnotatedClass().equals(xmlAnnotatedItem.getAnnotatedClass()))
+ if (getAnnotatedItem().getDelegate() != null && getXmlAnnotatedItem().getDelegate() != null && !getAnnotatedItem().getDelegate().equals(getXmlAnnotatedItem().getDelegate()))
{
throw new IllegalArgumentException("Cannot build a component which specifies different classes in XML and Java");
}
- else if (xmlAnnotatedItem.getAnnotatedClass() != null)
+ else if (getXmlAnnotatedItem().getDelegate() != null)
{
log.finest("Component type specified in XML");
- return xmlAnnotatedItem.getAnnotatedClass();
+ this.type = getXmlAnnotatedItem().getDelegate();
+ return;
}
- else if (annotatedItem.getAnnotatedClass() != null)
+ else if (getAnnotatedItem().getDelegate() != null)
{
log.finest("Component type specified in Java");
- return annotatedItem.getAnnotatedClass();
+ this.type = getAnnotatedItem().getDelegate();
+ return;
}
else
{
@@ -101,156 +98,20 @@
}
}
- protected static Annotation initDeploymentType(MergedStereotypesModel stereotypes, AnnotatedType annotatedItem, AnnotatedType xmlAnnotatedItem, ContainerImpl container)
+ @Override
+ protected String getDefaultName()
{
- Set<Annotation> xmlDeploymentTypes = xmlAnnotatedItem.getAnnotations(DeploymentType.class);
-
- if (xmlDeploymentTypes.size() > 1)
- {
- throw new RuntimeException("At most one deployment type may be specified (" + xmlDeploymentTypes + " are specified)");
- }
-
- if (xmlDeploymentTypes.size() == 1)
- {
- Annotation deploymentType = xmlDeploymentTypes.iterator().next();
- log.finest("Deployment type " + deploymentType + " specified in XML");
- return deploymentType;
- }
-
- if (xmlAnnotatedItem.getAnnotatedClass() == null)
- {
-
- Set<Annotation> deploymentTypes = annotatedItem.getAnnotations(DeploymentType.class);
-
- if (deploymentTypes.size() > 1)
- {
- throw new RuntimeException("At most one deployment type may be specified (" + deploymentTypes + " are specified) on " + annotatedItem.getAnnotatedClass());
- }
- if (deploymentTypes.size() == 1)
- {
- Annotation deploymentType = deploymentTypes.iterator().next();
- log.finest("Deployment type " + deploymentType + " specified by annotation");
- return deploymentType;
- }
- }
-
- if (stereotypes.getPossibleDeploymentTypes().size() > 0)
- {
- Annotation deploymentType = getDeploymentType(container.getEnabledDeploymentTypes(), stereotypes.getPossibleDeploymentTypes());
- log.finest("Deployment type " + deploymentType + " specified by stereotype");
- return deploymentType;
- }
-
- if (xmlAnnotatedItem.getAnnotatedClass() != null)
- {
- log.finest("Using default @Production deployment type");
- return new ProductionBinding();
- }
- throw new RuntimeException("All Java annotated classes have a deployment type");
- }
-
- /**
- * Return the scope of the component
- */
- protected static Annotation initScopeType(MergedStereotypesModel stereotypes, AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem)
- {
- Set<Annotation> xmlScopes = xmlAnnotatedItem.getAnnotations(ScopeType.class);
- if (xmlScopes.size() > 1)
- {
- throw new RuntimeException("At most one scope may be specified in XML");
- }
-
- if (xmlScopes.size() == 1)
- {
- Annotation scope = xmlScopes.iterator().next();
- log.finest("Scope " + scope + " specified in XML");
- return scope;
- }
-
- Set<Annotation> scopes = annotatedItem.getAnnotations(ScopeType.class);
- if (scopes.size() > 1)
- {
- throw new RuntimeException("At most one scope may be specified");
- }
-
- if (scopes.size() == 1)
- {
- Annotation scope = scopes.iterator().next();
- log.finest("Scope " + scope + " specified b annotation");
- return scope;
- }
-
- if (stereotypes.getPossibleScopeTypes().size() == 1)
- {
- Annotation scope = stereotypes.getPossibleScopeTypes().iterator().next();
- log.finest("Scope " + scope + " specified by stereotype");
- return scope;
- }
- else if (stereotypes.getPossibleScopeTypes().size() > 1)
- {
- throw new RuntimeException("All stereotypes must specify the same scope OR a scope must be specified on the component");
- }
-
- log.finest("Using default @Dependent scope");
- return new DependentBinding();
- }
-
- public static Annotation getDeploymentType(List<Annotation> enabledDeploymentTypes, Map<Class<? extends Annotation>, Annotation> possibleDeploymentTypes)
- {
- for (int i = (enabledDeploymentTypes.size() - 1); i > 0; i--)
- {
- if (possibleDeploymentTypes.containsKey((enabledDeploymentTypes.get(i).annotationType())))
- {
- return enabledDeploymentTypes.get(i);
- }
- }
- return null;
- }
-
- protected static String initName(MergedStereotypesModel stereotypes, AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, Class<?> type)
- {
- boolean componentNameDefaulted = false;
- String name = null;
- if (xmlAnnotatedItem.isAnnotationPresent(Named.class))
- {
- name = xmlAnnotatedItem.getAnnotation(Named.class).value();
- if ("".equals(name))
- {
- log.finest("Using default name (specified in XML)");
- componentNameDefaulted = true;
- }
- else
- {
- log.finest("Using name " + name + " specified in XML");
- }
- }
- else if (annotatedItem.isAnnotationPresent(Named.class))
- {
- name = annotatedItem.getAnnotation(Named.class).value();
- if ("".equals(name))
- {
- log.finest("Using default name (specified by annotations)");
- componentNameDefaulted = true;
- }
- else
- {
- log.finest("Using name " + name + " specified in XML");
- }
- }
- if ("".equals(name) && (componentNameDefaulted || stereotypes.isComponentNameDefaulted()))
- {
- name = Strings.decapitalize(type.getSimpleName());
- log.finest("Default name of " + type + " is " + name );
- }
+ String name = Strings.decapitalize(getType().getSimpleName());
+ log.finest("Default name of " + type + " is " + name );
return name;
}
/**
* Check that the types required by the stereotypes on the component are implemented
*/
- protected static void checkRequiredTypesImplemented(MergedStereotypesModel stereotypes, Class<?> type)
+ protected void checkRequiredTypesImplemented()
{
- for (Class<?> requiredType : stereotypes.getRequiredTypes())
+ for (Class<?> requiredType : getMergedStereotypes().getRequiredTypes())
{
log.finest("Checking if required type " + requiredType + " is implemented");
if (!requiredType.isAssignableFrom(type))
@@ -264,19 +125,19 @@
* Check that the scope type is allowed by the stereotypes on the component and the component type
* @param type
*/
- protected static void checkScopeAllowed(MergedStereotypesModel stereotypes, Annotation scopeType, Class<?> type)
+ protected void checkScopeAllowed()
{
- log.finest("Checking if " + scopeType + " is allowed for " + type);
- if (stereotypes.getSupportedScopes().size() > 0)
+ log.finest("Checking if " + getScopeType() + " is allowed for " + type);
+ if (getMergedStereotypes().getSupportedScopes().size() > 0)
{
- if (!stereotypes.getSupportedScopes().contains(scopeType.annotationType()))
+ if (!getMergedStereotypes().getSupportedScopes().contains(getScopeType().annotationType()))
{
- throw new RuntimeException("Scope " + scopeType + " is not an allowed by the stereotype for " + type);
+ throw new RuntimeException("Scope " + getScopeType() + " is not an allowed by the stereotype for " + type);
}
}
- if (isDeclaredFinal(type) && !scopeType.annotationType().equals(Dependent.class))
+ if (isDeclaredFinal(type) && !getScopeType().annotationType().equals(Dependent.class))
{
- throw new RuntimeException("Scope " + scopeType + " is not allowed as the class is declared final or has methods declared final for " + type + ". Only @Dependent is allowed for final components");
+ throw new RuntimeException("Scope " + getScopeType() + " is not allowed as the class is declared final or has methods declared final for " + type + ". Only @Dependent is allowed for final components");
}
}
@@ -296,53 +157,8 @@
return false;
}
- protected static <T> InjectableMethod<?> initRemoveMethod(EjbMetaData<T> ejbMetaData, Class<? extends T> type)
- {
- if (ejbMetaData.isStateful())
- {
- if (ejbMetaData.getRemoveMethods().size() == 1)
- {
- return new InjectableMethod<Object>(ejbMetaData.getRemoveMethods().get(0));
- }
- else if (ejbMetaData.getRemoveMethods().size() > 1)
- {
- List<Method> possibleRemoveMethods = new ArrayList<Method>();
- for (Method removeMethod : ejbMetaData.getRemoveMethods())
- {
- if (removeMethod.isAnnotationPresent(Destroys.class))
- {
- possibleRemoveMethods.add(removeMethod);
- }
- }
- if (possibleRemoveMethods.size() == 1)
- {
- return new InjectableMethod<Object>(possibleRemoveMethods.get(0));
- }
- else if (possibleRemoveMethods.size() > 1)
- {
- throw new RuntimeException("Multiple remove methods are annotated @Destroys for " + type);
- }
- else if (possibleRemoveMethods.size() == 0)
- {
- throw new RuntimeException("Multiple remove methods are declared, and none are annotated @Destroys for " + type);
- }
- }
- else if (ejbMetaData.getRemoveMethods().size() == 0)
- {
- throw new RuntimeException("Stateful enterprise bean component has no remove methods declared for " + type);
- }
- }
- else
- {
- List<Method> destroysMethods = Reflections.getMethods(type, Destroys.class);
- if (destroysMethods.size() > 0)
- {
- throw new RuntimeException("Only stateful enterprise bean components can have methods annotated @Destroys; " + type + " is not a stateful enterprise bean component");
- }
- }
- return null;
- }
+
protected static void checkComponentImplementation(Class<?> type)
{
if (Reflections.isAbstract(type))
@@ -350,36 +166,10 @@
throw new RuntimeException("Web Bean implementation class " + type + " cannot be declared abstract");
}
}
-
- public Annotation getDeploymentType()
- {
- return deploymentType;
- }
-
- public String getName()
- {
- return name;
- }
- @Override
- public Annotation getScopeType()
- {
- return scopeType;
- }
-
- protected MergedStereotypesModel getMergedStereotypes()
- {
- return mergedStereotypes;
- }
-
protected Class<? extends T> getType()
{
return type;
}
-
- public Set<Annotation> getBindingTypes()
- {
- return bindingTypes;
- }
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AbstractComponentModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AbstractComponentModel.java 2008-09-08 18:56:33 UTC (rev 97)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AbstractComponentModel.java 2008-09-08 18:57:12 UTC (rev 98)
@@ -1,57 +1,258 @@
package org.jboss.webbeans.model;
import java.lang.annotation.Annotation;
+import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;
import javax.webbeans.BindingType;
+import javax.webbeans.DeploymentType;
+import javax.webbeans.Named;
+import javax.webbeans.ScopeType;
+import org.jboss.webbeans.ContainerImpl;
import org.jboss.webbeans.bindings.CurrentBinding;
+import org.jboss.webbeans.bindings.DependentBinding;
+import org.jboss.webbeans.bindings.ProductionBinding;
import org.jboss.webbeans.injectable.ComponentConstructor;
import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.util.LoggerUtil;
-public abstract class AbstractComponentModel<T>
+public abstract class AbstractComponentModel<T, E>
{
public static final String LOGGER_NAME = "componentModel";
private static Logger log = LoggerUtil.getLogger(LOGGER_NAME);
+
+ private Set<Annotation> bindingTypes;
+ private String name;
+ private Annotation scopeType;
+ private MergedStereotypesModel<T, E> mergedStereotypes;
+ private Annotation deploymentType;
+
+ protected void init(ContainerImpl container)
+ {
+ mergedStereotypes = new MergedStereotypesModel<T, E>(getAnnotatedItem(), getXmlAnnotatedItem(), container);
+ initType();
+ log.fine("Building Web Bean component metadata for " + getType());
+ initBindingTypes();
+ initName();
+ initDeploymentType(container);
+ initScopeType();
+ }
+
+ protected abstract void initType();
- protected static Set<Annotation> initBindingTypes(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem)
+ protected abstract AnnotatedItem<E> getAnnotatedItem();
+
+ protected abstract AnnotatedItem<E> getXmlAnnotatedItem();
+
+ protected void initBindingTypes()
{
- Set<Annotation> xmlBindingTypes = xmlAnnotatedItem.getAnnotations(BindingType.class);
+ Set<Annotation> xmlBindingTypes = getXmlAnnotatedItem().getAnnotations(BindingType.class);
if (xmlBindingTypes.size() > 0)
{
// TODO support producer expression default binding type
log.finest("Using binding types " + xmlBindingTypes + " specified in XML");
- return xmlBindingTypes;
+ this.bindingTypes= xmlBindingTypes;
+ return;
}
+ else
+ {
+ Set<Annotation> bindingTypes = getAnnotatedItem().getAnnotations(BindingType.class);
+
+ if (bindingTypes.size() == 0)
+ {
+ log.finest("Adding default @Current binding type");
+ bindingTypes.add(new CurrentBinding());
+ }
+ else
+ {
+ log.finest("Using binding types " + bindingTypes + " specified by annotations");
+ }
+ this.bindingTypes = bindingTypes;
+ return;
+ }
+ }
+
+ /**
+ * Return the scope of the component
+ */
+ protected void initScopeType()
+ {
+ Set<Annotation> xmlScopes = getXmlAnnotatedItem().getAnnotations(ScopeType.class);
+ if (xmlScopes.size() > 1)
+ {
+ throw new RuntimeException("At most one scope may be specified in XML");
+ }
- Set<Annotation> bindingTypes = annotatedItem.getAnnotations(BindingType.class);
+ if (xmlScopes.size() == 1)
+ {
+ this.scopeType = xmlScopes.iterator().next();
+ log.finest("Scope " + scopeType + " specified in XML");
+ return;
+ }
- if (bindingTypes.size() == 0)
+ Set<Annotation> scopes = getAnnotatedItem().getAnnotations(ScopeType.class);
+ if (scopes.size() > 1)
{
- log.finest("Adding default @Current binding type");
- bindingTypes.add(new CurrentBinding());
+ throw new RuntimeException("At most one scope may be specified");
}
- else
+
+ if (scopes.size() == 1)
{
- log.finest("Using binding types " + bindingTypes + " specified by annotations");
+ this.scopeType = scopes.iterator().next();
+ log.finest("Scope " + scopeType + " specified b annotation");
+ return;
}
+
+ if (getMergedStereotypes().getPossibleScopeTypes().size() == 1)
+ {
+ this.scopeType = getMergedStereotypes().getPossibleScopeTypes().iterator().next();
+ log.finest("Scope " + scopeType + " specified by stereotype");
+ return;
+ }
+ else if (getMergedStereotypes().getPossibleScopeTypes().size() > 1)
+ {
+ throw new RuntimeException("All stereotypes must specify the same scope OR a scope must be specified on the component");
+ }
+ this.scopeType = new DependentBinding();
+ log.finest("Using default @Dependent scope");
+ }
+
+ protected void initName()
+ {
+ boolean componentNameDefaulted = false;
+ if (getXmlAnnotatedItem().isAnnotationPresent(Named.class))
+ {
+ String xmlName = getXmlAnnotatedItem().getAnnotation(Named.class).value();
+ if ("".equals(xmlName))
+ {
+ log.finest("Using default name (specified in XML)");
+ componentNameDefaulted = true;
+ }
+ else
+ {
+ log.finest("Using name " + xmlName + " specified in XML");
+ this.name = xmlName;
+ return;
+ }
+ }
+ else if (getAnnotatedItem().isAnnotationPresent(Named.class))
+ {
+ String javaName = getAnnotatedItem().getAnnotation(Named.class).value();
+ if ("".equals(javaName))
+ {
+ log.finest("Using default name (specified by annotations)");
+ componentNameDefaulted = true;
+ }
+ else
+ {
+ log.finest("Using name " + javaName + " specified in XML");
+ this.name = javaName;
+ return;
+ }
+ }
+ if (componentNameDefaulted || getMergedStereotypes().isComponentNameDefaulted())
+ {
+ this.name = getDefaultName();
+ return;
+ }
+ }
+
+ protected void initDeploymentType(ContainerImpl container)
+ {
+ Set<Annotation> xmlDeploymentTypes = getXmlAnnotatedItem().getAnnotations(DeploymentType.class);
+
+ if (xmlDeploymentTypes.size() > 1)
+ {
+ throw new RuntimeException("At most one deployment type may be specified (" + xmlDeploymentTypes + " are specified)");
+ }
+
+ if (xmlDeploymentTypes.size() == 1)
+ {
+ this.deploymentType = xmlDeploymentTypes.iterator().next();
+ log.finest("Deployment type " + deploymentType + " specified in XML");
+ return;
+ }
+
+ if (getXmlAnnotatedItem().getDelegate() == null)
+ {
+
+ Set<Annotation> deploymentTypes = getAnnotatedItem().getAnnotations(DeploymentType.class);
+
+ if (deploymentTypes.size() > 1)
+ {
+ throw new RuntimeException("At most one deployment type may be specified (" + deploymentTypes + " are specified) on " + getAnnotatedItem().getDelegate());
+ }
+ if (deploymentTypes.size() == 1)
+ {
+ this.deploymentType = deploymentTypes.iterator().next();
+ log.finest("Deployment type " + deploymentType + " specified by annotation");
+ return;
+ }
+ }
+
+ if (getMergedStereotypes().getPossibleDeploymentTypes().size() > 0)
+ {
+ this.deploymentType = getDeploymentType(container.getEnabledDeploymentTypes(), getMergedStereotypes().getPossibleDeploymentTypes());
+ log.finest("Deployment type " + deploymentType + " specified by stereotype");
+ return;
+ }
+
+ if (getXmlAnnotatedItem().getDelegate() != null)
+ {
+ this.deploymentType = new ProductionBinding();
+ log.finest("Using default @Production deployment type");
+ return;
+ }
+ throw new RuntimeException("type: " + getType() + " must specify a deployment type");
+ }
+
+ public static Annotation getDeploymentType(List<Annotation> enabledDeploymentTypes, Map<Class<? extends Annotation>, Annotation> possibleDeploymentTypes)
+ {
+ for (int i = (enabledDeploymentTypes.size() - 1); i > 0; i--)
+ {
+ if (possibleDeploymentTypes.containsKey((enabledDeploymentTypes.get(i).annotationType())))
+ {
+ return enabledDeploymentTypes.get(i);
+ }
+ }
+ return null;
+ }
+
+ protected MergedStereotypesModel<T, E> getMergedStereotypes()
+ {
+ return mergedStereotypes;
+ }
+
+ protected abstract String getDefaultName();
+
+ public Set<Annotation> getBindingTypes()
+ {
return bindingTypes;
}
- public abstract Set<Annotation> getBindingTypes();
+ public Annotation getScopeType()
+ {
+ return scopeType;
+ }
+
- public abstract Annotation getScopeType();
+ protected abstract E getType();
- protected abstract Class<? extends T> getType();
-
public abstract ComponentConstructor<T> getConstructor();
- public abstract Annotation getDeploymentType();
+ public Annotation getDeploymentType()
+ {
+ return deploymentType;
+ }
- public abstract String getName();
+ public String getName()
+ {
+ return name;
+ }
}
\ No newline at end of file
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AbstractEnterpriseComponentModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AbstractEnterpriseComponentModel.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AbstractEnterpriseComponentModel.java 2008-09-08 18:57:12 UTC (rev 98)
@@ -0,0 +1,113 @@
+package org.jboss.webbeans.model;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.webbeans.ApplicationScoped;
+import javax.webbeans.Dependent;
+import javax.webbeans.Destroys;
+
+import org.jboss.webbeans.ContainerImpl;
+import org.jboss.webbeans.ejb.EjbMetaData;
+import org.jboss.webbeans.injectable.InjectableMethod;
+import org.jboss.webbeans.introspector.AnnotatedType;
+import org.jboss.webbeans.util.Reflections;
+
+public abstract class AbstractEnterpriseComponentModel<T> extends
+ AbstractClassComponentModel<T>
+{
+
+ private InjectableMethod<?> removeMethod;
+ private EjbMetaData<T> ejbMetaData;
+
+ public AbstractEnterpriseComponentModel(AnnotatedType<T> annotatedItem,
+ AnnotatedType<T> xmlAnnotatedItem)
+ {
+ super(annotatedItem, xmlAnnotatedItem);
+
+ }
+
+ @Override
+ protected void init(ContainerImpl container)
+ {
+ super.init(container);
+ ejbMetaData = container.getEjbManager().getEjbMetaData(getType());
+ initRemoveMethod();
+ checkEnterpriseScopeAllowed();
+ }
+
+ public InjectableMethod<?> getRemoveMethod()
+ {
+ return removeMethod;
+ }
+
+ protected EjbMetaData<T> getEjbMetaData()
+ {
+ return ejbMetaData;
+ }
+
+ /**
+ * Check that the scope type is allowed by the stereotypes on the component and the component type
+ * @param type
+ */
+ protected void checkEnterpriseScopeAllowed()
+ {
+ if (getEjbMetaData().isStateless() && !getScopeType().annotationType().equals(Dependent.class))
+ {
+ throw new RuntimeException("Scope " + getScopeType() + " is not allowed on stateless enterpise bean components for " + getType() + ". Only @Dependent is allowed on stateless enterprise bean components");
+ }
+ if (getEjbMetaData().isSingleton() && (!getScopeType().annotationType().equals(Dependent.class) || !getScopeType().annotationType().equals(ApplicationScoped.class)))
+ {
+ throw new RuntimeException("Scope " + getScopeType() + " is not allowed on singleton enterpise bean components for " + getType() + ". Only @Dependent or @ApplicationScoped is allowed on singleton enterprise bean components");
+ }
+ }
+
+ // TODO loggigng
+ protected void initRemoveMethod()
+ {
+ if (getEjbMetaData().isStateful())
+ {
+ if (getEjbMetaData().getRemoveMethods().size() == 1)
+ {
+ this.removeMethod = new InjectableMethod<Object>(getEjbMetaData().getRemoveMethods().get(0));
+ }
+ else if (getEjbMetaData().getRemoveMethods().size() > 1)
+ {
+ List<Method> possibleRemoveMethods = new ArrayList<Method>();
+ for (Method removeMethod : getEjbMetaData().getRemoveMethods())
+ {
+ if (removeMethod.isAnnotationPresent(Destroys.class))
+ {
+ possibleRemoveMethods.add(removeMethod);
+ }
+ }
+ if (possibleRemoveMethods.size() == 1)
+ {
+ this.removeMethod = new InjectableMethod<Object>(possibleRemoveMethods.get(0));
+ }
+ else if (possibleRemoveMethods.size() > 1)
+ {
+ throw new RuntimeException("Multiple remove methods are annotated @Destroys for " + getType());
+ }
+ else if (possibleRemoveMethods.size() == 0)
+ {
+ throw new RuntimeException("Multiple remove methods are declared, and none are annotated @Destroys for " + getType());
+ }
+ }
+ else if (getEjbMetaData().getRemoveMethods().size() == 0)
+ {
+ throw new RuntimeException("Stateful enterprise bean component has no remove methods declared for " + getType());
+ }
+ }
+ else
+ {
+ List<Method> destroysMethods = Reflections.getMethods(getType(), Destroys.class);
+ if (destroysMethods.size() > 0)
+ {
+ throw new RuntimeException("Only stateful enterprise bean components can have methods annotated @Destroys; " + getType() + " is not a stateful enterprise bean component");
+ }
+ }
+ }
+
+}
\ No newline at end of file
Property changes on: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AbstractEnterpriseComponentModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AbstractProducerComponentModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AbstractProducerComponentModel.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AbstractProducerComponentModel.java 2008-09-08 18:57:12 UTC (rev 98)
@@ -0,0 +1,10 @@
+package org.jboss.webbeans.model;
+
+import java.lang.reflect.Method;
+
+public abstract class AbstractProducerComponentModel<T> extends
+ AbstractComponentModel<T, Method>
+{
+
+
+}
\ No newline at end of file
Property changes on: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/AbstractProducerComponentModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/EnterpriseComponentModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/EnterpriseComponentModel.java 2008-09-08 18:56:33 UTC (rev 97)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/EnterpriseComponentModel.java 2008-09-08 18:57:12 UTC (rev 98)
@@ -1,62 +1,37 @@
package org.jboss.webbeans.model;
-import java.lang.annotation.Annotation;
-
-import javax.webbeans.ApplicationScoped;
-import javax.webbeans.Dependent;
-
import org.jboss.webbeans.ContainerImpl;
-import org.jboss.webbeans.ejb.EjbMetaData;
import org.jboss.webbeans.injectable.ComponentConstructor;
import org.jboss.webbeans.injectable.EnterpriseConstructor;
-import org.jboss.webbeans.injectable.InjectableMethod;
import org.jboss.webbeans.introspector.AnnotatedType;
-public class EnterpriseComponentModel<T> extends AbstractClassComponentModel<T>
+public class EnterpriseComponentModel<T> extends AbstractEnterpriseComponentModel<T>
{
private EnterpriseConstructor<T> constructor;
- private InjectableMethod<?> removeMethod;
-
- public EnterpriseComponentModel(AnnotatedType annotatedItem,
- AnnotatedType xmlAnnotatedItem, ContainerImpl container)
+ public EnterpriseComponentModel(AnnotatedType<T> annotatedItem,
+ AnnotatedType<T> xmlAnnotatedItem, ContainerImpl container)
{
- super(annotatedItem, xmlAnnotatedItem, container);
- EjbMetaData<T> ejbMetaData = container.getEjbManager().getEjbMetaData(getType());
- this.constructor = initConstructor(ejbMetaData, container);
- EnterpriseComponentModel.checkScopeAllowed(getMergedStereotypes(), getScopeType(), getType(), ejbMetaData);
- this.removeMethod = initRemoveMethod(ejbMetaData, getType());
+ super(annotatedItem, xmlAnnotatedItem);
+ init(container);
}
- protected static <T> EnterpriseConstructor<T> initConstructor(EjbMetaData<T> ejbMetaData, ContainerImpl container)
+ @Override
+ protected void init(ContainerImpl container)
{
- return new EnterpriseConstructor<T>(ejbMetaData);
+ super.init(container);
+ this.constructor = new EnterpriseConstructor<T>(getEjbMetaData());
}
-
- /**
- * Check that the scope type is allowed by the stereotypes on the component and the component type
- * @param type
- */
- protected static <T> void checkScopeAllowed(MergedStereotypesModel stereotypes, Annotation scopeType, Class<?> type, EjbMetaData<T> ejbMetaData)
- {
- if (ejbMetaData.isStateless() && !scopeType.annotationType().equals(Dependent.class))
- {
- throw new RuntimeException("Scope " + scopeType + " is not allowed on stateless enterpise bean components for " + type + ". Only @Dependent is allowed on stateless enterprise bean components");
- }
- if (ejbMetaData.isSingleton() && (!scopeType.annotationType().equals(Dependent.class) || !scopeType.annotationType().equals(ApplicationScoped.class)))
- {
- throw new RuntimeException("Scope " + scopeType + " is not allowed on singleton enterpise bean components for " + type + ". Only @Dependent or @ApplicationScoped is allowed on singleton enterprise bean components");
- }
- }
public ComponentConstructor<T> getConstructor()
{
return constructor;
}
- public InjectableMethod<?> getRemoveMethod()
+ @Override
+ public String toString()
{
- return removeMethod;
+ return "EnterpriseComponentModel[" + getType().getName() + "]";
}
}
Deleted: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/JmsComponentModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/JmsComponentModel.java 2008-09-08 18:56:33 UTC (rev 97)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/JmsComponentModel.java 2008-09-08 18:57:12 UTC (rev 98)
@@ -1,113 +0,0 @@
-package org.jboss.webbeans.model;
-
-import java.lang.annotation.Annotation;
-import java.util.HashMap;
-import java.util.Set;
-
-import javax.webbeans.Current;
-import javax.webbeans.Dependent;
-import javax.webbeans.ScopeType;
-
-import org.jboss.webbeans.ContainerImpl;
-import org.jboss.webbeans.injectable.ComponentConstructor;
-import org.jboss.webbeans.injectable.JMSConstructor;
-import org.jboss.webbeans.introspector.AnnotatedItem;
-import org.jboss.webbeans.introspector.SimpleAnnotatedItem;
-import org.jboss.webbeans.util.Reflections;
-
-// TODO Work out what to return on methods we don't support
-
-public class JmsComponentModel<T> extends AbstractComponentModel<T>
-{
-
- // TODO Work out how to handle xml elements which don't correspond to annotations
-
- private String jndiName;
- private ComponentConstructor<T> constructor;
- private Set<Annotation> bindingTypes;
- private Annotation scopeType;
-
- @SuppressWarnings("unchecked")
- public JmsComponentModel(AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
- {
- AnnotatedItem annotatedItem = new SimpleAnnotatedItem(new HashMap<Class<? extends Annotation>, Annotation>());
- bindingTypes = initBindingTypes(annotatedItem, xmlAnnotatedItem);
- //scopeType = new DependentBiding();
- checkBindingTypesAllowed(bindingTypes, null);
- checkScopeAllowed(xmlAnnotatedItem, null);
- // TODO Initialize queue. topic
- this.constructor = new JMSConstructor<T>(jndiName);
- }
-
- @SuppressWarnings("unchecked")
- protected static void checkBindingTypesAllowed(Set<Annotation> bindingTypes,
- String type)
- {
- if (bindingTypes.size() == 0)
- {
- throw new RuntimeException("Must declare at least one binding type for JMS Component " + type);
- }
- if (Reflections.annotationSetMatches(bindingTypes, Current.class))
- {
- throw new RuntimeException("Cannot declared the binding type @Current for JMS Component " + type);
- }
-
- }
-
- protected static <T> Class<? extends T> initType(AnnotatedItem xmlAnnotatedItem)
- {
- // TODO return TopicPublisher if its a topic or QueueSession if its a queue
- return null;
- }
-
- protected static void checkScopeAllowed(AnnotatedItem xmlAnnotatedItem, Class<?> type)
- {
- Set<Annotation> scopeTypeAnnotations = xmlAnnotatedItem.getAnnotations(ScopeType.class);
- if (scopeTypeAnnotations.size() > 0 && ! scopeTypeAnnotations.iterator().next().annotationType().equals(Dependent.class))
- {
- throw new RuntimeException("JMS component may only have scope @Dependent for " + type);
- }
- }
-
- @Override
- public ComponentConstructor<T> getConstructor()
- {
- return constructor;
- }
-
- @Override
- public Set<Annotation> getBindingTypes()
- {
- return bindingTypes;
- }
-
- @Override
- protected Class<? extends T> getType()
- {
- return null;
- }
-
- public String getJndiName()
- {
- return jndiName;
- }
-
- @Override
- public Annotation getScopeType()
- {
- return scopeType;
- }
-
- @Override
- public Annotation getDeploymentType()
- {
- return null;
- }
-
- @Override
- public String getName()
- {
- return null;
- }
-
-}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/MergedStereotypesModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/MergedStereotypesModel.java 2008-09-08 18:56:33 UTC (rev 97)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/MergedStereotypesModel.java 2008-09-08 18:57:12 UTC (rev 98)
@@ -16,7 +16,7 @@
* @author pmuir
*
*/
-public class MergedStereotypesModel
+public class MergedStereotypesModel<T, E>
{
private Map<Class<? extends Annotation>, Annotation> possibleDeploymentTypes;
@@ -25,7 +25,7 @@
private Set<Class<?>> requiredTypes;
private Set<Class<? extends Annotation>> supportedScopes;
- public MergedStereotypesModel(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
+ public MergedStereotypesModel(AnnotatedItem<E> annotatedItem, AnnotatedItem<E> xmlAnnotatedItem, ContainerImpl container)
{
possibleDeploymentTypes = new HashMap<Class<? extends Annotation>, Annotation>();
possibleScopeTypes = new HashSet<Annotation>();
@@ -40,7 +40,7 @@
for (Annotation stereotypeAnnotation : stereotypeAnnotations)
{
// Retrieve and merge all metadata from stereotypes
- StereotypeModel stereotype = container.getStereotypeManager().getStereotype(stereotypeAnnotation.annotationType());
+ StereotypeModel<?> stereotype = container.getStereotypeManager().getStereotype(stereotypeAnnotation.annotationType());
if (stereotype == null)
{
throw new NullPointerException("Stereotype " + stereotypeAnnotation + " not registered with container");
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/ProducerMethodComponentModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/ProducerMethodComponentModel.java 2008-09-08 18:56:33 UTC (rev 97)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/ProducerMethodComponentModel.java 2008-09-08 18:57:12 UTC (rev 98)
@@ -1,72 +1,97 @@
package org.jboss.webbeans.model;
import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.util.Set;
+import java.util.HashMap;
+import javax.webbeans.Dependent;
+
import org.jboss.webbeans.ContainerImpl;
import org.jboss.webbeans.injectable.ComponentConstructor;
+import org.jboss.webbeans.injectable.MethodConstructor;
+import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.AnnotatedMethod;
+import org.jboss.webbeans.introspector.SimpleAnnotatedItem;
-public class ProducerMethodComponentModel<T> extends AbstractComponentModel<T>
+public class ProducerMethodComponentModel<T> extends AbstractProducerComponentModel<T>
{
+ private Method type;
+ private ComponentConstructor<T> constructor;
+
+ private AnnotatedItem<Method> xmlAnnotatedItem = new SimpleAnnotatedItem<Method>(new HashMap<Class<? extends Annotation>, Annotation>());
+ private AnnotatedMethod annotatedMethod;
+
@SuppressWarnings("unchecked")
- public ProducerMethodComponentModel(AnnotatedMethod annotatedItem, ContainerImpl container)
+ public ProducerMethodComponentModel(AnnotatedMethod annotatedMethod, ContainerImpl container)
{
- checkProducerMethod(annotatedItem, container);
+ this.annotatedMethod = annotatedMethod;
+ init(container);
}
+
+ @Override
+ protected void init(ContainerImpl container)
+ {
+ super.init(container);
+ checkProducerMethod();
+ this.constructor = new MethodConstructor<T>(type);
+ }
@Override
- public ComponentConstructor getConstructor()
+ public ComponentConstructor<T> getConstructor()
{
- // TODO Auto-generated method stub
- return null;
+ return constructor;
}
- public static void checkProducerMethod(AnnotatedMethod annotatedItem, ContainerImpl container)
+ protected void checkProducerMethod()
{
- if (Modifier.isStatic(annotatedItem.getAnnotatedMethod().getModifiers()))
+ if (Modifier.isStatic(getAnnotatedItem().getDelegate().getModifiers()))
{
- throw new RuntimeException("Producer method cannot be static " + annotatedItem);
+ throw new RuntimeException("Producer method cannot be static " + annotatedMethod);
}
// TODO Check if declaring class is a WB component
-
+ if (Modifier.isFinal(getAnnotatedItem().getDelegate().getModifiers()) || getScopeType().annotationType().equals(Dependent.class))
+ {
+ throw new RuntimeException("Final producer method must have @Dependent scope " + annotatedMethod);
+ }
}
+
+ @Override
+ public String toString()
+ {
+ return "ProducerMethodComponentModel[" + getType().getName() + "]";
+ }
@Override
- public Set<Annotation> getBindingTypes()
+ protected AnnotatedItem<Method> getAnnotatedItem()
{
- // TODO Auto-generated method stub
- return null;
+ return annotatedMethod;
}
@Override
- public Annotation getDeploymentType()
+ protected String getDefaultName()
{
// TODO Auto-generated method stub
return null;
}
@Override
- public String getName()
+ protected Method getType()
{
- // TODO Auto-generated method stub
- return null;
+ return type;
}
@Override
- public Annotation getScopeType()
+ protected AnnotatedItem<Method> getXmlAnnotatedItem()
{
- // TODO Auto-generated method stub
- return null;
+ return xmlAnnotatedItem;
}
@Override
- protected Class<? extends T> getType()
+ protected void initType()
{
- // TODO Auto-generated method stub
- return null;
+ this.type = annotatedMethod.getAnnotatedMethod();
}
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/RemoteComponentModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/RemoteComponentModel.java 2008-09-08 18:56:33 UTC (rev 97)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/RemoteComponentModel.java 2008-09-08 18:57:12 UTC (rev 98)
@@ -1,69 +1,47 @@
package org.jboss.webbeans.model;
-import java.lang.annotation.Annotation;
-
-import javax.webbeans.ApplicationScoped;
import javax.webbeans.BoundTo;
-import javax.webbeans.Dependent;
import org.jboss.webbeans.ContainerImpl;
-import org.jboss.webbeans.ejb.EjbMetaData;
import org.jboss.webbeans.injectable.ComponentConstructor;
import org.jboss.webbeans.injectable.EnterpriseConstructor;
import org.jboss.webbeans.injectable.InjectableMethod;
-import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.AnnotatedType;
-public class RemoteComponentModel<T> extends AbstractClassComponentModel<T>
+public class RemoteComponentModel<T> extends AbstractEnterpriseComponentModel<T>
{
private EnterpriseConstructor<T> constructor;
private InjectableMethod<?> removeMethod;
private String boundTo;
- public RemoteComponentModel(AnnotatedType annotatedItem,
- AnnotatedType xmlAnnotatedItem, ContainerImpl container)
+ public RemoteComponentModel(AnnotatedType<T> annotatedItem,
+ AnnotatedType<T> xmlAnnotatedItem)
{
- super(annotatedItem, xmlAnnotatedItem, container);
- EjbMetaData<T> ejbMetaData = container.getEjbManager().getEjbMetaData(getType());
- this.constructor = initConstructor(ejbMetaData, container);
- EnterpriseComponentModel.checkScopeAllowed(getMergedStereotypes(), getScopeType(), getType(), ejbMetaData);
- this.removeMethod = initRemoveMethod(ejbMetaData, getType());
- this.boundTo = initBoundTo(annotatedItem, xmlAnnotatedItem, getType());
+ super(annotatedItem, xmlAnnotatedItem);
}
- protected static <T> EnterpriseConstructor<T> initConstructor(EjbMetaData<T> ejbMetaData, ContainerImpl container)
+ @Override
+ protected void init(ContainerImpl container)
{
- return new EnterpriseConstructor<T>(ejbMetaData);
+ super.init(container);
+ // TODO initialize constructor
+ initBoundTo();
}
-
- /**
- * Check that the scope type is allowed by the stereotypes on the component and the component type
- * @param type
- */
- protected static <T> void checkScopeAllowed(MergedStereotypesModel stereotypes, Annotation scopeType, Class<?> type, EjbMetaData<T> ejbMetaData)
- {
- if (ejbMetaData.isStateless() && !scopeType.annotationType().equals(Dependent.class))
- {
- throw new RuntimeException("Scope " + scopeType + " is not allowed on stateless enterpise bean components for " + type + ". Only @Dependent is allowed on stateless enterprise bean components");
- }
- if (ejbMetaData.isSingleton() && (!scopeType.annotationType().equals(Dependent.class) || !scopeType.annotationType().equals(ApplicationScoped.class)))
- {
- throw new RuntimeException("Scope " + scopeType + " is not allowed on singleton enterpise bean components for " + type + ". Only @Dependent or @ApplicationScoped is allowed on singleton enterprise bean components");
- }
- }
- protected static String initBoundTo(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, Class<?> type)
+ protected void initBoundTo()
{
- if (xmlAnnotatedItem.isAnnotationPresent(BoundTo.class))
+ if (getXmlAnnotatedItem().isAnnotationPresent(BoundTo.class))
{
- return xmlAnnotatedItem.getAnnotation(BoundTo.class).value();
+ this.boundTo = getXmlAnnotatedItem().getAnnotation(BoundTo.class).value();
+ return;
}
- if (annotatedItem.isAnnotationPresent(BoundTo.class))
+ if (getAnnotatedItem().isAnnotationPresent(BoundTo.class))
{
- return annotatedItem.getAnnotation(BoundTo.class).value();
+ this.boundTo = getAnnotatedItem().getAnnotation(BoundTo.class).value();
+ return;
}
- throw new RuntimeException("Remote component doesn't specify @BoundTo or <bound-to /> for " + type);
+ throw new RuntimeException("Remote component doesn't specify @BoundTo or <bound-to /> for " + getType());
}
public ComponentConstructor<T> getConstructor()
@@ -80,5 +58,11 @@
{
return boundTo;
}
+
+ @Override
+ public String toString()
+ {
+ return "RemoteComponentModel[" + getType().getName() + "]";
+ }
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/SimpleComponentModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/SimpleComponentModel.java 2008-09-08 18:56:33 UTC (rev 97)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/SimpleComponentModel.java 2008-09-08 18:57:12 UTC (rev 98)
@@ -17,8 +17,6 @@
public class SimpleComponentModel<T> extends AbstractClassComponentModel<T>
{
- public static final String LOGGER_NAME = "componentMetaModel";
-
private static Logger log = LoggerUtil.getLogger(LOGGER_NAME);
private SimpleConstructor<T> constructor;
@@ -33,8 +31,15 @@
@SuppressWarnings("unchecked")
public SimpleComponentModel(AnnotatedType annotatedItem, AnnotatedType xmlAnnotatedItem, ContainerImpl container)
{
- super(annotatedItem, xmlAnnotatedItem, container);
- this.constructor = initConstructor(getType());
+ super(annotatedItem, xmlAnnotatedItem);
+ init(container);
+ }
+
+ @Override
+ protected void init(ContainerImpl container)
+ {
+ super.init(container);
+ initConstructor();
checkType(getType());
// TODO Interceptors
}
@@ -48,59 +53,63 @@
}
@SuppressWarnings("unchecked")
- protected static <T> SimpleConstructor<T> initConstructor(Class<? extends T> type)
+ protected void initConstructor()
{
- if (type.getConstructors().length == 1)
+ if (getType().getConstructors().length == 1)
{
- Constructor<T> constructor = type.getConstructors()[0];
- log.finest("Exactly one constructor (" + constructor +") defined, using it as the component constructor for " + type);
- return new SimpleConstructor<T>(constructor);
+ Constructor<T> constructor = getType().getConstructors()[0];
+ log.finest("Exactly one constructor (" + constructor +") defined, using it as the component constructor for " + getType());
+ this.constructor = new SimpleConstructor<T>(constructor);
+ return;
}
- if (type.getConstructors().length > 1)
+ if (getType().getConstructors().length > 1)
{
- List<Constructor<T>> initializerAnnotatedConstructors = Reflections.getConstructors(type, Initializer.class);
- List<Constructor<T>> bindingTypeAnnotatedConstructors = Reflections.getConstructorsForMetaAnnotatedParameter(type, BindingType.class);
- log.finest("Found " + initializerAnnotatedConstructors + " constructors annotated with @Initializer for " + type);
- log.finest("Found " + bindingTypeAnnotatedConstructors + " with parameters annotated with binding types for " + type);
+ List<Constructor<T>> initializerAnnotatedConstructors = Reflections.getConstructors(getType(), Initializer.class);
+ List<Constructor<T>> bindingTypeAnnotatedConstructors = Reflections.getConstructorsForMetaAnnotatedParameter(getType(), BindingType.class);
+ log.finest("Found " + initializerAnnotatedConstructors + " constructors annotated with @Initializer for " + getType());
+ log.finest("Found " + bindingTypeAnnotatedConstructors + " with parameters annotated with binding types for " + getType());
if ((initializerAnnotatedConstructors.size() + bindingTypeAnnotatedConstructors.size()) > 1)
{
if (initializerAnnotatedConstructors.size() > 1)
{
- throw new RuntimeException("Cannot have more than one constructor annotated with @Initializer for " + type);
+ throw new RuntimeException("Cannot have more than one constructor annotated with @Initializer for " + getType());
}
else if (bindingTypeAnnotatedConstructors.size() > 1)
{
- throw new RuntimeException("Cannot have more than one constructor with binding types specified on constructor parameters for " + type);
+ throw new RuntimeException("Cannot have more than one constructor with binding types specified on constructor parameters for " + getType());
}
else
{
- throw new RuntimeException("Specify a constructor either annotated with @Initializer or with parameters annotated with binding types for " + type);
+ throw new RuntimeException("Specify a constructor either annotated with @Initializer or with parameters annotated with binding types for " + getType());
}
}
else if (initializerAnnotatedConstructors.size() == 1)
{
Constructor<T> constructor = initializerAnnotatedConstructors.get(0);
- log.finest("Exactly one constructor (" + constructor +") annotated with @Initializer defined, using it as the component constructor for " + type);
- return new SimpleConstructor<T>(constructor);
+ log.finest("Exactly one constructor (" + constructor +") annotated with @Initializer defined, using it as the component constructor for " + getType());
+ this.constructor = new SimpleConstructor<T>(constructor);
+ return;
}
else if (bindingTypeAnnotatedConstructors.size() == 1)
{
Constructor<T> constructor = bindingTypeAnnotatedConstructors.get(0);
- log.finest("Exactly one constructor (" + constructor +") with parameters annotated with binding types defined, using it as the component constructor for " + type);
- return new SimpleConstructor<T>(constructor);
+ log.finest("Exactly one constructor (" + constructor +") with parameters annotated with binding types defined, using it as the component constructor for " + getType());
+ this.constructor = new SimpleConstructor<T>(constructor);
+ return;
}
}
- if (type.getConstructors().length == 0)
+ if (getType().getConstructors().length == 0)
{
- Constructor<T> constructor = (Constructor<T>) Reflections.getConstructor(type);
- log.finest("No constructor defined, using implicit no arguement constructor for " + type);
- return new SimpleConstructor<T>(constructor);
+ Constructor<T> constructor = (Constructor<T>) Reflections.getConstructor(getType());
+ log.finest("No constructor defined, using implicit no arguement constructor for " + getType());
+ this.constructor = new SimpleConstructor<T>(constructor);
+ return;
}
- throw new RuntimeException("Cannot determine constructor to use for " + type);
+ throw new RuntimeException("Cannot determine constructor to use for " + getType());
}
public SimpleConstructor<T> getConstructor()
@@ -119,6 +128,5 @@
{
return "SimpleComponentModel[" + getType().getName() + "]";
}
-
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/StereotypeModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/StereotypeModel.java 2008-09-08 18:56:33 UTC (rev 97)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/StereotypeModel.java 2008-09-08 18:57:12 UTC (rev 98)
@@ -12,7 +12,6 @@
import javax.webbeans.ScopeType;
import javax.webbeans.Stereotype;
-import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.AnnotatedType;
/**
@@ -21,7 +20,7 @@
* @author pmuir
*
*/
-public class StereotypeModel
+public class StereotypeModel<T>
{
private Class<? extends Annotation> stereotypeClass;
@@ -33,7 +32,7 @@
private Set<Annotation> interceptorBindings;
@SuppressWarnings("unchecked")
- public StereotypeModel(AnnotatedType annotatedClass)
+ public StereotypeModel(AnnotatedType<T> annotatedClass)
{
initStereotypeClass(annotatedClass);
Stereotype stereotype = annotatedClass.getAnnotation(Stereotype.class);
@@ -46,7 +45,7 @@
checkBindingTypes(annotatedClass);
}
- private void checkBindingTypes(AnnotatedItem annotatedClass)
+ private void checkBindingTypes(AnnotatedType<T> annotatedClass)
{
Set<Annotation> bindingTypes = annotatedClass.getAnnotations(BindingType.class);
if (bindingTypes.size() > 0)
@@ -56,7 +55,7 @@
}
@SuppressWarnings("unchecked")
- private void initStereotypeClass(AnnotatedType annotatedClass)
+ private void initStereotypeClass(AnnotatedType<T> annotatedClass)
{
if (Annotation.class.isAssignableFrom(annotatedClass.getAnnotatedClass()))
{
@@ -68,12 +67,12 @@
}
}
- private void initInterceptorBindings(AnnotatedItem annotatedClass)
+ private void initInterceptorBindings(AnnotatedType<T> annotatedClass)
{
interceptorBindings = annotatedClass.getAnnotations(InterceptorBindingType.class);
}
- private void initSupportedScopes(AnnotatedItem annotatedElement, Stereotype stereotype)
+ private void initSupportedScopes(AnnotatedType<T> annotatedElement, Stereotype stereotype)
{
this.supportedScopes = new HashSet<Class<? extends Annotation>>();
Class<? extends Annotation>[] supportedScopes = stereotype.supportedScopes();
@@ -83,7 +82,7 @@
}
}
- private void initRequiredTypes(AnnotatedItem annotatedElement, Stereotype stereotype)
+ private void initRequiredTypes(AnnotatedType<T> annotatedElement, Stereotype stereotype)
{
this.requiredTypes = new HashSet<Class<?>>();
Class<?>[] requiredTypes = stereotype.requiredTypes();
@@ -93,7 +92,7 @@
}
}
- private void initComponentNameDefaulted(AnnotatedItem annotatedElement)
+ private void initComponentNameDefaulted(AnnotatedType<T> annotatedElement)
{
if (annotatedElement.isAnnotationPresent(Named.class))
{
@@ -105,7 +104,7 @@
}
}
- private void initDefaultScopeType(AnnotatedItem annotatedElement)
+ private void initDefaultScopeType(AnnotatedType<T> annotatedElement)
{
Set<Annotation> scopeTypes = annotatedElement.getAnnotations(ScopeType.class);
if (scopeTypes.size() > 1)
@@ -118,7 +117,7 @@
}
}
- private void initDefaultDeploymentType(AnnotatedItem annotatedElement)
+ private void initDefaultDeploymentType(AnnotatedType<T> annotatedElement)
{
Set<Annotation> deploymentTypes = annotatedElement.getAnnotations(DeploymentType.class);
if (deploymentTypes.size() > 1)
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ConstructorMetaModelTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ConstructorMetaModelTest.java 2008-09-08 18:56:33 UTC (rev 97)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ConstructorMetaModelTest.java 2008-09-08 18:57:12 UTC (rev 98)
@@ -41,7 +41,7 @@
@Test
public void testImplicitConstructor()
{
- SimpleConstructor<Order> constructor = new SimpleComponentModel<Order>(new SimpleAnnotatedType(Order.class), emptyAnnotatedItem, container).getConstructor();
+ SimpleConstructor<Order> constructor = new SimpleComponentModel<Order>(new SimpleAnnotatedType<Order>(Order.class), emptyAnnotatedItem, container).getConstructor();
assert constructor.getConstructor().getDeclaringClass().equals(Order.class);
assert constructor.getConstructor().getParameterTypes().length == 0;
assert constructor.getParameters().size() == 0;
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EnterpriseComponentModelTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EnterpriseComponentModelTest.java 2008-09-08 18:56:33 UTC (rev 97)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EnterpriseComponentModelTest.java 2008-09-08 18:57:12 UTC (rev 98)
@@ -10,6 +10,7 @@
import org.jboss.webbeans.ContainerImpl;
import org.jboss.webbeans.introspector.AnnotatedType;
import org.jboss.webbeans.introspector.SimpleAnnotatedType;
+import org.jboss.webbeans.model.AbstractEnterpriseComponentModel;
import org.jboss.webbeans.model.EnterpriseComponentModel;
import org.jboss.webbeans.test.annotations.Synchronous;
import org.jboss.webbeans.test.components.Bear;
@@ -69,7 +70,7 @@
boolean exception = false;
try
{
- new EnterpriseComponentModel<Bear>(new SimpleAnnotatedType(Bear.class), emptyAnnotatedItem, container);
+ new EnterpriseComponentModel<Bear>(new SimpleAnnotatedType<Bear>(Bear.class), emptyAnnotatedItem, container);
}
catch (Exception e)
{
@@ -99,7 +100,7 @@
public void testStateful()
{
- EnterpriseComponentModel<Tiger> tiger = new EnterpriseComponentModel<Tiger>(new SimpleAnnotatedType(Tiger.class), emptyAnnotatedItem, container);
+ AbstractEnterpriseComponentModel<Tiger> tiger = new EnterpriseComponentModel<Tiger>(new SimpleAnnotatedType(Tiger.class), emptyAnnotatedItem, container);
Reflections.annotationSetMatches(tiger.getBindingTypes(), Synchronous.class);
assert tiger.getRemoveMethod().getMethod().getName().equals("remove");
assert tiger.getName() == null;
@@ -110,7 +111,7 @@
public void testMultipleRemoveMethodsWithDestroys()
{
- EnterpriseComponentModel<Elephant> elephant = new EnterpriseComponentModel<Elephant>(new SimpleAnnotatedType(Elephant.class), emptyAnnotatedItem, container);
+ AbstractEnterpriseComponentModel<Elephant> elephant = new EnterpriseComponentModel<Elephant>(new SimpleAnnotatedType(Elephant.class), emptyAnnotatedItem, container);
assert elephant.getRemoveMethod().getMethod().getName().equals("remove2");
}
@@ -166,7 +167,7 @@
public void testRemoveMethodWithDefaultBinding()
{
- EnterpriseComponentModel<Panther> panther = new EnterpriseComponentModel<Panther>(new SimpleAnnotatedType(Panther.class), emptyAnnotatedItem, container);
+ AbstractEnterpriseComponentModel<Panther> panther = new EnterpriseComponentModel<Panther>(new SimpleAnnotatedType(Panther.class), emptyAnnotatedItem, container);
assert panther.getRemoveMethod().getMethod().getName().equals("remove");
assert panther.getRemoveMethod().getParameters().size() == 1;
@@ -179,7 +180,7 @@
@Test
public void testMessageDriven()
{
- EnterpriseComponentModel<Leopard> leopard = new EnterpriseComponentModel<Leopard>(new SimpleAnnotatedType(Leopard.class), emptyAnnotatedItem, container);
+ AbstractEnterpriseComponentModel<Leopard> leopard = new EnterpriseComponentModel<Leopard>(new SimpleAnnotatedType(Leopard.class), emptyAnnotatedItem, container);
Reflections.annotationSetMatches(leopard.getBindingTypes(), Current.class);
}
More information about the weld-commits
mailing list