[webbeans-commits] Webbeans SVN: r40 - in ri/trunk/webbeans-impl/src: main/java/org/jboss/webbeans/injectable and 2 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-07-03 13:42:40 -0400 (Thu, 03 Jul 2008)
New Revision: 40
Added:
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeManager.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ComponentConstructor.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Element.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/InjectableMethod.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Parameter.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/SimpleConstructor.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Unit.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/AbstractComponentModel.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/EnterpriseComponentModel.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/MergedStereotypesModel.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/RemoteComponentModel.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/SimpleComponentModel.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/StereotypeModel.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/stereotypes/
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/EnterpriseComponentModelTest.java
Removed:
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentMetaModel.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/MergedComponentStereotypes.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeManager.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeMetaModel.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ConstructorMetaModel.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ElementMetaModel.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/MethodMetaModel.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ParameterMetaModel.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/UnitMetaModel.java
Modified:
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentMetaModelTest.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ConstructorMetaModelTest.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/StereotypeMetaModelTest.java
Log:
Refactor component model to have different classes for different component types
Modified: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java 2008-07-03 15:16:06 UTC (rev 39)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -7,6 +7,7 @@
import javax.webbeans.ComponentInstance;
import javax.webbeans.Container;
+import org.jboss.webbeans.model.AbstractComponentModel;
import org.jboss.webbeans.util.LoggerUtil;
public class ComponentInstanceImpl<T> extends ComponentInstance<T>
@@ -16,9 +17,9 @@
private static Logger log = LoggerUtil.getLogger(LOGGER_NAME);
- private ComponentMetaModel<T> componentMetaModel;
+ private AbstractComponentModel<T> componentMetaModel;
- public ComponentInstanceImpl(ComponentMetaModel<T> componentMetaModel)
+ public ComponentInstanceImpl(AbstractComponentModel<T> componentMetaModel)
{
this.componentMetaModel = componentMetaModel;
}
Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentMetaModel.java 2008-07-03 15:16:06 UTC (rev 39)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentMetaModel.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -1,526 +0,0 @@
-package org.jboss.webbeans;
-
-import static org.jboss.webbeans.ComponentMetaModel.ComponentType.*;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Constructor;
-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.ApplicationScoped;
-import javax.webbeans.BindingType;
-import javax.webbeans.Dependent;
-import javax.webbeans.DeploymentType;
-import javax.webbeans.Destroys;
-import javax.webbeans.Initializer;
-import javax.webbeans.Named;
-import javax.webbeans.ScopeType;
-
-import org.jboss.webbeans.bindings.CurrentBinding;
-import org.jboss.webbeans.bindings.DependentBinding;
-import org.jboss.webbeans.bindings.ProductionBinding;
-import org.jboss.webbeans.ejb.EJB;
-import org.jboss.webbeans.ejb.EjbMetaData;
-import org.jboss.webbeans.injectable.ConstructorMetaModel;
-import org.jboss.webbeans.injectable.MethodMetaModel;
-import org.jboss.webbeans.util.AnnotatedItem;
-import org.jboss.webbeans.util.LoggerUtil;
-import org.jboss.webbeans.util.Reflections;
-import org.jboss.webbeans.util.Strings;
-
-/**
- * Web Beans Component meta model
- *
- * @author Pete Muir
- *
- */
-public class ComponentMetaModel<T>
-{
-
- public enum ComponentType
- {
- SIMPLE,
- ENTERPRISE;
- }
-
- public static final String LOGGER_NAME = "componentMetaModel";
-
- private static Logger log = LoggerUtil.getLogger(LOGGER_NAME);
-
- private Class<? extends T> type;
- private Set<Annotation> bindingTypes;
- private Annotation deploymentType;
- private String name;
- private Annotation scopeType;
- private ComponentType componentType;
- private ConstructorMetaModel<T> constructor;
- private EjbMetaData<T> ejbMetaData;
- private MethodMetaModel<?> removeMethod;
- /**
- *
- * @param annotatedItem Annotations read from java classes
- * @param xmlAnnotatedItem Annotations read from XML
- * @param container
- */
- @SuppressWarnings("unchecked")
- public ComponentMetaModel(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
- {
- if (annotatedItem == null)
- {
- throw new NullPointerException("annotatedItem must not be null. If the component is declared just in XML, pass in an empty annotatedItem");
- }
-
- if (xmlAnnotatedItem == null)
- {
- 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.ejbMetaData = EJB.getEjbMetaData(type);
- this.componentType = initComponentType(type, ejbMetaData);
- checkComponentImplementation(componentType, type);
- this.constructor = initConstructor(type);
- MergedComponentStereotypes stereotypes = new MergedComponentStereotypes(annotatedItem, xmlAnnotatedItem, container);
- this.bindingTypes = initBindingTypes(annotatedItem, xmlAnnotatedItem);
- this.deploymentType = initDeploymentType(stereotypes, annotatedItem, xmlAnnotatedItem, container);
- this.scopeType = initScopeType(stereotypes, annotatedItem, xmlAnnotatedItem);
- this.name = initName(stereotypes, annotatedItem, xmlAnnotatedItem, componentType, type);
- this.removeMethod = initRemoveMethod(componentType, ejbMetaData, type);
- checkRequiredTypesImplemented(stereotypes, type);
- checkScopeAllowed(stereotypes, scopeType, type, componentType, ejbMetaData);
- // TODO Interceptors
- }
-
- /*
- * A series of static methods which implement the algorithms defined in the Web Beans spec for component meta data
- */
-
- @SuppressWarnings("unchecked")
- protected static <T> ConstructorMetaModel<T> initConstructor(Class<? extends T> type)
- {
- if (type.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 ConstructorMetaModel<T>(constructor);
- }
-
- if (type.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);
- if ((initializerAnnotatedConstructors.size() + bindingTypeAnnotatedConstructors.size()) > 1)
- {
- if (initializerAnnotatedConstructors.size() > 1)
- {
- throw new RuntimeException("Cannot have more than one constructor annotated with @Initializer for " + type);
- }
-
- else if (bindingTypeAnnotatedConstructors.size() > 1)
- {
- throw new RuntimeException("Cannot have more than one constructor with binding types specified on constructor parameters for " + type);
- }
- else
- {
- throw new RuntimeException("Specify a constructor either annotated with @Initializer or with parameters annotated with binding types for " + type);
- }
- }
- 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 ConstructorMetaModel<T>(constructor);
- }
- 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 ConstructorMetaModel<T>(constructor);
- }
- }
-
- if (type.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 ConstructorMetaModel<T>(constructor);
- }
-
- throw new RuntimeException("Cannot determine constructor to use for " + type);
- }
-
- protected static <T> MethodMetaModel<?> initRemoveMethod(ComponentType componentType, EjbMetaData<T> ejbMetaData, Class<? extends T> type)
- {
- if (componentType.equals(ENTERPRISE) && ejbMetaData.isStateful())
- {
- if (ejbMetaData.getRemoveMethods().size() == 1)
- {
- return new MethodMetaModel<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 MethodMetaModel<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 <T> ComponentType initComponentType(Class<? extends T> type, EjbMetaData<T> ejbMetaData)
- {
- if (ejbMetaData != null && (ejbMetaData.isMessageDriven() || ejbMetaData.isSingleton() || ejbMetaData.isStateful() || ejbMetaData.isStateless()))
- {
- log.finest(type + " is an enterprise bean component");
- return ENTERPRISE;
- }
- else
- {
- log.finest(type + " is an simple component");
- return SIMPLE;
- }
- }
-
- protected static void checkComponentImplementation(ComponentType componentType, Class<?> type)
- {
- switch (componentType)
- {
- case SIMPLE:
- checkSimpleComponentImplementation(type);
- break;
- }
- }
-
- protected static void checkSimpleComponentImplementation(Class<?> type)
- {
- if (Reflections.isAbstract(type))
- {
- throw new RuntimeException("Web Bean implementation class " + type + " cannot be declared abstract");
- }
- }
-
- protected static boolean isDeclaredFinal(Class<?> type)
- {
- if (Reflections.isFinal(type))
- {
- return true;
- }
- for (Method method : type.getDeclaredMethods())
- {
- if (Reflections.isFinal(method))
- {
- return true;
- }
- }
- return false;
- }
-
- @SuppressWarnings("unchecked")
- protected static Class<?> initType(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem)
- {
- if (annotatedItem.getAnnotatedClass() != null && xmlAnnotatedItem.getAnnotatedClass() != null && !annotatedItem.getAnnotatedClass().equals(xmlAnnotatedItem.getAnnotatedClass()))
- {
- throw new IllegalArgumentException("Cannot build a component which specifies different classes in XML and Java");
- }
- else if (xmlAnnotatedItem.getAnnotatedClass() != null)
- {
- log.finest("Component type specified in XML");
- return xmlAnnotatedItem.getAnnotatedClass();
- }
- else if (annotatedItem.getAnnotatedClass() != null)
- {
- log.finest("Component type specified in Java");
- return annotatedItem.getAnnotatedClass();
- }
- else
- {
- throw new IllegalArgumentException("Cannot build a component which doesn't specify a type");
- }
- }
-
- /**
- * Check that the scope type is allowed by the stereotypes on the component and the component type
- * @param type
- */
- protected static void checkScopeAllowed(MergedComponentStereotypes stereotypes, Annotation scopeType, Class<?> type, ComponentType componentType, EjbMetaData ejbMetaData)
- {
- log.finest("Checking if " + scopeType + " is allowed for " + type);
- if (stereotypes.getSupportedScopes().size() > 0)
- {
- if (!stereotypes.getSupportedScopes().contains(scopeType.annotationType()))
- {
- throw new RuntimeException("Scope " + scopeType + " is not an allowed by the stereotype for " + type);
- }
- }
- if (isDeclaredFinal(type) && !scopeType.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");
- }
- if (componentType.equals(ComponentType.ENTERPRISE) && 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 (componentType.equals(ComponentType.ENTERPRISE) && 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");
- }
- }
-
- /**
- * Check that the types required by the stereotypes on the component are implemented
- */
- protected static void checkRequiredTypesImplemented(MergedComponentStereotypes stereotypes, Class<?> type)
- {
- for (Class<?> requiredType : stereotypes.getRequiredTypes())
- {
- log.finest("Checking if required type " + requiredType + " is implemented");
- if (!requiredType.isAssignableFrom(type))
- {
- throw new RuntimeException("Required type " + requiredType + " isn't implement on " + type);
- }
- }
- }
-
- /**
- * Return the scope of the component
- */
- protected static Annotation initScopeType(MergedComponentStereotypes 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();
- }
-
- protected static Annotation initDeploymentType(MergedComponentStereotypes stereotypes, AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
- {
- 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)");
- }
- 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");
- }
-
- protected static Set<Annotation> initBindingTypes(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem)
- {
- Set<Annotation> xmlBindingTypes = xmlAnnotatedItem.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;
- }
-
- Set<Annotation> bindingTypes = annotatedItem.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");
- }
- return bindingTypes;
- }
-
- protected static String initName(MergedComponentStereotypes stereotypes, AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ComponentType componentType, 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()))
- {
- if (ComponentType.SIMPLE.equals(componentType) || ComponentType.ENTERPRISE.equals(componentType))
- {
- name = Strings.decapitalize(type.getSimpleName());
- }
- log.finest("Default name of " + type + " is " + name );
- }
- return name;
- }
-
- 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;
- }
-
- public Set<Annotation> getBindingTypes()
- {
- return bindingTypes;
- }
-
- public Annotation getDeploymentType()
- {
- return deploymentType;
- }
-
- public String getName()
- {
- return name;
- }
-
- public Annotation getScopeType()
- {
- return scopeType;
- }
-
- public ConstructorMetaModel<T> getConstructor()
- {
- return constructor;
- }
-
- public ComponentType getComponentType()
- {
- return componentType;
- }
-
- public MethodMetaModel<?> getRemoveMethod()
- {
- return removeMethod;
- }
-
-}
Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/MergedComponentStereotypes.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/MergedComponentStereotypes.java 2008-07-03 15:16:06 UTC (rev 39)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/MergedComponentStereotypes.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -1,89 +0,0 @@
-package org.jboss.webbeans;
-
-import java.lang.annotation.Annotation;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.webbeans.Stereotype;
-
-import org.jboss.webbeans.util.AnnotatedItem;
-
-/**
- * Meta model for the merged stereotype for a component
- * @author pmuir
- *
- */
-public class MergedComponentStereotypes
-{
-
- private Map<Class<? extends Annotation>, Annotation> possibleDeploymentTypes;
- private Set<Annotation> possibleScopeTypes;
- private boolean componentNameDefaulted;
- private Set<Class<?>> requiredTypes;
- private Set<Class<? extends Annotation>> supportedScopes;
-
- public MergedComponentStereotypes(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
- {
- possibleDeploymentTypes = new HashMap<Class<? extends Annotation>, Annotation>();
- possibleScopeTypes = new HashSet<Annotation>();
- requiredTypes = new HashSet<Class<?>>();
- supportedScopes = new HashSet<Class<? extends Annotation>>();
-
- // All stereotypes declared in java and xml are merged
- Set<Annotation> stereotypeAnnotations = new HashSet<Annotation>();
- stereotypeAnnotations.addAll(annotatedItem.getAnnotations(Stereotype.class));
- stereotypeAnnotations.addAll(xmlAnnotatedItem.getAnnotations(Stereotype.class));
-
- for (Annotation stereotypeAnnotation : stereotypeAnnotations)
- {
- // Retrieve and merge all metadata from stereotypes
- StereotypeMetaModel stereotype = container.getStereotypeManager().getStereotype(stereotypeAnnotation.annotationType());
- if (stereotype == null)
- {
- throw new NullPointerException("Stereotype " + stereotypeAnnotation + " not registered with container");
- }
- if (stereotype.getDefaultDeploymentType() != null)
- {
- possibleDeploymentTypes.put(stereotype.getDefaultDeploymentType().annotationType(), stereotype.getDefaultDeploymentType());
- }
- if (stereotype.getDefaultScopeType() != null)
- {
- possibleScopeTypes.add(stereotype.getDefaultScopeType());
- }
- requiredTypes.addAll(stereotype.getRequiredTypes());
- supportedScopes.addAll(stereotype.getSupportedScopes());
- if (stereotype.isComponentNameDefaulted())
- {
- componentNameDefaulted = true;
- }
- }
- }
-
- public Map<Class<? extends Annotation>, Annotation> getPossibleDeploymentTypes()
- {
- return possibleDeploymentTypes;
- }
-
- public Set<Annotation> getPossibleScopeTypes()
- {
- return possibleScopeTypes;
- }
-
- public boolean isComponentNameDefaulted()
- {
- return componentNameDefaulted;
- }
-
- public Set<Class<?>> getRequiredTypes()
- {
- return requiredTypes;
- }
-
- public Set<Class<? extends Annotation>> getSupportedScopes()
- {
- return supportedScopes;
- }
-
-}
Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeManager.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeManager.java 2008-07-03 15:16:06 UTC (rev 39)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeManager.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -1,23 +0,0 @@
-package org.jboss.webbeans;
-
-import java.lang.annotation.Annotation;
-import java.util.HashMap;
-import java.util.Map;
-
-public class StereotypeManager
-{
-
- // TODO Store these in the application context (when it exists)
- public static Map<Class<? extends Annotation>, StereotypeMetaModel> stereotypes = new HashMap<Class<? extends Annotation>, StereotypeMetaModel>();
-
- public void addStereotype(StereotypeMetaModel stereotype)
- {
- stereotypes.put(stereotype.getStereotypeClass(), stereotype);
- }
-
- public StereotypeMetaModel getStereotype(Class<? extends Annotation> annotationType)
- {
- return stereotypes.get(annotationType);
- }
-
-}
Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeManager.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeManager.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeManager.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,25 @@
+package org.jboss.webbeans;
+
+import java.lang.annotation.Annotation;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.webbeans.model.StereotypeModel;
+
+public class StereotypeManager
+{
+
+ // TODO Store these in the application context (when it exists)
+ public static Map<Class<? extends Annotation>, StereotypeModel> stereotypes = new HashMap<Class<? extends Annotation>, StereotypeModel>();
+
+ public void addStereotype(StereotypeModel stereotype)
+ {
+ stereotypes.put(stereotype.getStereotypeClass(), stereotype);
+ }
+
+ public StereotypeModel getStereotype(Class<? extends Annotation> annotationType)
+ {
+ return stereotypes.get(annotationType);
+ }
+
+}
Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeMetaModel.java 2008-07-03 15:16:06 UTC (rev 39)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeMetaModel.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -1,191 +0,0 @@
-package org.jboss.webbeans;
-
-import java.lang.annotation.Annotation;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.webbeans.BindingType;
-import javax.webbeans.DeploymentType;
-import javax.webbeans.InterceptorBindingType;
-import javax.webbeans.Named;
-import javax.webbeans.ScopeType;
-import javax.webbeans.Stereotype;
-
-import org.jboss.webbeans.util.AnnotatedItem;
-
-/**
- * A meta model for a stereotype, allows us to cache a stereotype and to validate it
- *
- * @author pmuir
- *
- */
-public class StereotypeMetaModel
-{
-
- private Class<? extends Annotation> stereotypeClass;
- private Annotation defaultDeploymentType;
- private Annotation defaultScopeType;
- private boolean componentNameDefaulted;
- private Set<Class<? extends Annotation>> supportedScopes;
- private Set<Class<?>> requiredTypes;
- private Set<Annotation> interceptorBindings;
-
- @SuppressWarnings("unchecked")
- public StereotypeMetaModel(AnnotatedItem annotatedClass)
- {
- initStereotypeClass(annotatedClass);
- Stereotype stereotype = annotatedClass.getAnnotation(Stereotype.class);
- initDefaultDeploymentType(annotatedClass);
- initDefaultScopeType(annotatedClass);
- initComponentNameDefaulted(annotatedClass);
- initSupportedScopes(annotatedClass, stereotype);
- initRequiredTypes(annotatedClass, stereotype);
- initInterceptorBindings(annotatedClass);
- checkBindingTypes(annotatedClass);
- }
-
- private void checkBindingTypes(AnnotatedItem annotatedClass)
- {
- Set<Annotation> bindingTypes = annotatedClass.getAnnotations(BindingType.class);
- if (bindingTypes.size() > 0)
- {
- throw new RuntimeException("Cannot declare binding types on a stereotpe");
- }
- }
-
- @SuppressWarnings("unchecked")
- private void initStereotypeClass(AnnotatedItem annotatedClass)
- {
- if (Annotation.class.isAssignableFrom(annotatedClass.getAnnotatedClass()))
- {
- this.stereotypeClass = (Class<? extends Annotation>) annotatedClass.getAnnotatedClass();
- }
- else
- {
- throw new RuntimeException("@Stereotype can only be applied to an annotation");
- }
- }
-
- private void initInterceptorBindings(AnnotatedItem annotatedClass)
- {
- interceptorBindings = annotatedClass.getAnnotations(InterceptorBindingType.class);
- }
-
- private void initSupportedScopes(AnnotatedItem annotatedElement, Stereotype stereotype)
- {
- this.supportedScopes = new HashSet<Class<? extends Annotation>>();
- Class<? extends Annotation>[] supportedScopes = stereotype.supportedScopes();
- if (supportedScopes.length > 0)
- {
- this.supportedScopes.addAll(Arrays.asList(supportedScopes));
- }
- }
-
- private void initRequiredTypes(AnnotatedItem annotatedElement, Stereotype stereotype)
- {
- this.requiredTypes = new HashSet<Class<?>>();
- Class<?>[] requiredTypes = stereotype.requiredTypes();
- if (requiredTypes.length > 0)
- {
- this.requiredTypes.addAll(Arrays.asList(requiredTypes));
- }
- }
-
- private void initComponentNameDefaulted(AnnotatedItem annotatedElement)
- {
- if (annotatedElement.isAnnotationPresent(Named.class))
- {
- if (!"".equals(annotatedElement.getAnnotation(Named.class).value()))
- {
- throw new RuntimeException("Cannot specify a value for a @Named stereotype");
- }
- componentNameDefaulted = true;
- }
- }
-
- private void initDefaultScopeType(AnnotatedItem annotatedElement)
- {
- Set<Annotation> scopeTypes = annotatedElement.getAnnotations(ScopeType.class);
- if (scopeTypes.size() > 1)
- {
- throw new RuntimeException("At most one scope type may be specified");
- }
- else if (scopeTypes.size() == 1)
- {
- this.defaultScopeType = scopeTypes.iterator().next();
- }
- }
-
- private void initDefaultDeploymentType(AnnotatedItem annotatedElement)
- {
- Set<Annotation> deploymentTypes = annotatedElement.getAnnotations(DeploymentType.class);
- if (deploymentTypes.size() > 1)
- {
- throw new RuntimeException("At most one deployment type may be specified");
- }
- else if (deploymentTypes.size() == 1)
- {
- this.defaultDeploymentType = deploymentTypes.iterator().next();
- }
- }
-
- /**
- * Get the default deployment type the stereotype specifies, or null if none
- * is specified
- */
- public Annotation getDefaultDeploymentType()
- {
- return defaultDeploymentType;
- }
-
- /**
- * Get the default scope type the stereotype specifies, or null if none is
- * specified
- */
- public Annotation getDefaultScopeType()
- {
- return defaultScopeType;
- }
-
- /**
- * Get any interceptor bindings the the stereotype specifies, or an empty set
- * if none are specified
- */
- public Set<Annotation> getInterceptorBindings()
- {
- return interceptorBindings;
- }
-
- /**
- * Returns true if the stereotype specifies the component name should be
- * defaulted
- */
- public boolean isComponentNameDefaulted()
- {
- return componentNameDefaulted;
- }
-
- /**
- * Returns the scopes this stereotype allows, or an empty set if none are
- * specified
- */
- public Set<Class<? extends Annotation>> getSupportedScopes()
- {
- return supportedScopes;
- }
-
- /**
- * Returns the types this stereotype requires, or an empty set if none are
- * specified
- */
- public Set<Class<?>> getRequiredTypes()
- {
- return requiredTypes;
- }
-
- public Class<? extends Annotation> getStereotypeClass()
- {
- return stereotypeClass;
- }
-}
Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ComponentConstructor.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ComponentConstructor.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ComponentConstructor.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,10 @@
+package org.jboss.webbeans.injectable;
+
+import javax.webbeans.Container;
+
+public interface ComponentConstructor<T>
+{
+
+ public T invoke(Container container);
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ComponentConstructor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ConstructorMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ConstructorMetaModel.java 2008-07-03 15:16:06 UTC (rev 39)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ConstructorMetaModel.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -1,45 +0,0 @@
-package org.jboss.webbeans.injectable;
-
-import java.lang.reflect.Constructor;
-import java.util.logging.Logger;
-
-import javax.webbeans.Container;
-
-import org.jboss.webbeans.util.LoggerUtil;
-
-public class ConstructorMetaModel<T> extends UnitMetaModel<T>
-{
-
- public static final String LOGGER_NAME = "componentConstructor";
-
- private static Logger log = LoggerUtil.getLogger(LOGGER_NAME);
-
- private Constructor<T> constructor;
-
- @SuppressWarnings("unchecked")
- public ConstructorMetaModel(Constructor<T> constructor)
- {
- super(constructor.getParameterTypes(), constructor.getParameterAnnotations());
- this.constructor = constructor;
- log.finest("Initialized metadata for " + constructor + " with injectable parameters " + getParameters());
- }
-
- public Constructor<T> getConstructor()
- {
- return constructor;
- }
-
- public T invoke(Container container)
- {
- try
- {
- log.finest("Creating new instance of " + constructor.getDeclaringClass() + " with injected parameters " + getParameters());
- return constructor.newInstance(getParameterValues(container));
- }
- catch (Exception e)
- {
- throw new RuntimeException("Error instantiating " + constructor.getDeclaringClass(), e);
- }
- }
-
-}
Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Element.java (from rev 38, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ElementMetaModel.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Element.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Element.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,40 @@
+package org.jboss.webbeans.injectable;
+
+import java.lang.annotation.Annotation;
+
+import javax.webbeans.Container;
+
+public abstract class Element<T>
+{
+
+ private Annotation[] bindingTypes;
+
+ public Element(Annotation[] bindingTypes)
+ {
+ this.bindingTypes = bindingTypes;
+ }
+
+ public Element()
+ {
+ this.bindingTypes = new Annotation[0];
+ }
+
+ public Annotation[] getBindingTypes()
+ {
+ return bindingTypes;
+ }
+
+ @Override
+ public String toString()
+ {
+ return getType() + " with binding types " + getBindingTypes();
+ }
+
+ public T getValue(Container container)
+ {
+ return container.getInstanceByType(getType(), getBindingTypes());
+ }
+
+ public abstract Class<? extends T> getType();
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Element.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ElementMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ElementMetaModel.java 2008-07-03 15:16:06 UTC (rev 39)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ElementMetaModel.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -1,40 +0,0 @@
-package org.jboss.webbeans.injectable;
-
-import java.lang.annotation.Annotation;
-
-import javax.webbeans.Container;
-
-public abstract class ElementMetaModel<T>
-{
-
- private Annotation[] bindingTypes;
-
- public ElementMetaModel(Annotation[] bindingTypes)
- {
- this.bindingTypes = bindingTypes;
- }
-
- public ElementMetaModel()
- {
- this.bindingTypes = new Annotation[0];
- }
-
- public Annotation[] getBindingTypes()
- {
- return bindingTypes;
- }
-
- @Override
- public String toString()
- {
- return getType() + " with binding types " + getBindingTypes();
- }
-
- public T getValue(Container container)
- {
- return container.getInstanceByType(getType(), getBindingTypes());
- }
-
- public abstract Class<? extends T> getType();
-
-}
Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/InjectableMethod.java (from rev 39, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/MethodMetaModel.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/InjectableMethod.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/InjectableMethod.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,36 @@
+package org.jboss.webbeans.injectable;
+
+import javax.webbeans.Container;
+
+// TODO Name this class better
+public class InjectableMethod<T> extends Unit<T>
+{
+
+ private java.lang.reflect.Method method;
+
+ public InjectableMethod(java.lang.reflect.Method method)
+ {
+ super(method.getParameterTypes(), method.getParameterAnnotations());
+ this.method = method;
+ }
+
+ @SuppressWarnings("unchecked")
+ public T invoke(Container container, Object instance)
+ {
+ try
+ {
+ return (T) method.invoke(instance, getParameterValues(container));
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Unable to invoke " + method + " on " + instance, e);
+ }
+ }
+
+ public java.lang.reflect.Method getMethod()
+ {
+ return method;
+ }
+
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/InjectableMethod.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/MethodMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/MethodMetaModel.java 2008-07-03 15:16:06 UTC (rev 39)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/MethodMetaModel.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -1,37 +0,0 @@
-package org.jboss.webbeans.injectable;
-
-import java.lang.reflect.Method;
-
-import javax.webbeans.Container;
-
-public class MethodMetaModel<T> extends UnitMetaModel<T>
-{
-
- private Method method;
-
- public MethodMetaModel(Method method)
- {
- super(method.getParameterTypes(), method.getParameterAnnotations());
- this.method = method;
- }
-
- @SuppressWarnings("unchecked")
- public T invoke(Container container, Object instance)
- {
- try
- {
- return (T) method.invoke(instance, getParameterValues(container));
- }
- catch (Exception e)
- {
- throw new RuntimeException("Unable to invoke " + method + " on " + instance, e);
- }
- }
-
- public Method getMethod()
- {
- return method;
- }
-
-
-}
Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Parameter.java (from rev 38, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ParameterMetaModel.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Parameter.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Parameter.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,33 @@
+package org.jboss.webbeans.injectable;
+
+import java.lang.annotation.Annotation;
+
+import org.jboss.webbeans.bindings.CurrentBinding;
+
+public class Parameter<T> extends Element<T>
+{
+
+ private static Annotation[] currentBinding = {new CurrentBinding()};
+
+ private Class<? extends T> type;
+
+ public Parameter(Annotation[] bindingTypes, Class<? extends T> type)
+ {
+ super(bindingTypes);
+ this.type = type;
+ }
+
+ public Parameter(Class<? extends T> type)
+ {
+ super(currentBinding);
+ this.type = type;
+ }
+
+ public Class<? extends T> getType()
+ {
+ return type;
+ }
+
+
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Parameter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ParameterMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ParameterMetaModel.java 2008-07-03 15:16:06 UTC (rev 39)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ParameterMetaModel.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -1,33 +0,0 @@
-package org.jboss.webbeans.injectable;
-
-import java.lang.annotation.Annotation;
-
-import org.jboss.webbeans.bindings.CurrentBinding;
-
-public class ParameterMetaModel<T> extends ElementMetaModel<T>
-{
-
- private static Annotation[] currentBinding = {new CurrentBinding()};
-
- private Class<? extends T> type;
-
- public ParameterMetaModel(Annotation[] bindingTypes, Class<? extends T> type)
- {
- super(bindingTypes);
- this.type = type;
- }
-
- public ParameterMetaModel(Class<? extends T> type)
- {
- super(currentBinding);
- this.type = type;
- }
-
- public Class<? extends T> getType()
- {
- return type;
- }
-
-
-
-}
Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/SimpleConstructor.java (from rev 38, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ConstructorMetaModel.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/SimpleConstructor.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/SimpleConstructor.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,45 @@
+package org.jboss.webbeans.injectable;
+
+import java.lang.reflect.Constructor;
+import java.util.logging.Logger;
+
+import javax.webbeans.Container;
+
+import org.jboss.webbeans.util.LoggerUtil;
+
+public class SimpleConstructor<T> extends Unit<T> implements ComponentConstructor<T>
+{
+
+ public static final String LOGGER_NAME = "componentConstructor";
+
+ private static Logger log = LoggerUtil.getLogger(LOGGER_NAME);
+
+ private Constructor<T> constructor;
+
+ @SuppressWarnings("unchecked")
+ public SimpleConstructor(Constructor<T> constructor)
+ {
+ super(constructor.getParameterTypes(), constructor.getParameterAnnotations());
+ this.constructor = constructor;
+ log.finest("Initialized metadata for " + constructor + " with injectable parameters " + getParameters());
+ }
+
+ public Constructor<T> getConstructor()
+ {
+ return constructor;
+ }
+
+ public T invoke(Container container)
+ {
+ try
+ {
+ log.finest("Creating new instance of " + constructor.getDeclaringClass() + " with injected parameters " + getParameters());
+ return constructor.newInstance(getParameterValues(container));
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Error instantiating " + constructor.getDeclaringClass(), e);
+ }
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/SimpleConstructor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Unit.java (from rev 38, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/UnitMetaModel.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Unit.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/Unit.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,54 @@
+package org.jboss.webbeans.injectable;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.webbeans.Container;
+
+public abstract class Unit<T>
+{
+
+ private List<Element<Object>> parameters;
+
+ public Unit(Class<?>[] parameterTypes, Annotation[][] parameterAnnotations)
+ {
+ parameters = initParameters(parameterTypes, parameterAnnotations);
+ }
+
+ public List<Element<Object>> getParameters()
+ {
+ return parameters;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected static List<Element<Object>> initParameters(Class<?>[] parameterTypes, Annotation[][] parameterAnnotations)
+ {
+ List<Element<Object>> injectedParameters = new ArrayList<Element<Object>>();
+ for (int i = 0; i < parameterTypes.length; i++)
+ {
+ if (parameterAnnotations[i].length > 0)
+ {
+ Parameter<Object> parameter = new Parameter(parameterAnnotations[i], parameterTypes[i]);
+ injectedParameters.add(i, parameter);
+ }
+ else
+ {
+ Parameter<Object> parameter = new Parameter(parameterTypes[i]);
+ injectedParameters.add(i, parameter);
+ }
+ }
+ return injectedParameters;
+ }
+
+ public Object[] getParameterValues(Container container)
+ {
+ Object[] parameterValues = new Object[parameters.size()];
+ for (int i = 0; i < parameterValues.length; i++)
+ {
+ parameterValues[i] = parameters.get(i).getValue(container);
+ }
+ return parameterValues;
+ }
+
+}
Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/UnitMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/UnitMetaModel.java 2008-07-03 15:16:06 UTC (rev 39)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/UnitMetaModel.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -1,54 +0,0 @@
-package org.jboss.webbeans.injectable;
-
-import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.webbeans.Container;
-
-public abstract class UnitMetaModel<T>
-{
-
- private List<ElementMetaModel<Object>> parameters;
-
- public UnitMetaModel(Class<?>[] parameterTypes, Annotation[][] parameterAnnotations)
- {
- parameters = initParameters(parameterTypes, parameterAnnotations);
- }
-
- public List<ElementMetaModel<Object>> getParameters()
- {
- return parameters;
- }
-
- @SuppressWarnings("unchecked")
- protected static List<ElementMetaModel<Object>> initParameters(Class<?>[] parameterTypes, Annotation[][] parameterAnnotations)
- {
- List<ElementMetaModel<Object>> injectedParameters = new ArrayList<ElementMetaModel<Object>>();
- for (int i = 0; i < parameterTypes.length; i++)
- {
- if (parameterAnnotations[i].length > 0)
- {
- ParameterMetaModel<Object> parameter = new ParameterMetaModel(parameterAnnotations[i], parameterTypes[i]);
- injectedParameters.add(i, parameter);
- }
- else
- {
- ParameterMetaModel<Object> parameter = new ParameterMetaModel(parameterTypes[i]);
- injectedParameters.add(i, parameter);
- }
- }
- return injectedParameters;
- }
-
- public Object[] getParameterValues(Container container)
- {
- Object[] parameterValues = new Object[parameters.size()];
- for (int i = 0; i < parameterValues.length; i++)
- {
- parameterValues[i] = parameters.get(i).getValue(container);
- }
- return parameterValues;
- }
-
-}
Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/AbstractComponentModel.java (from rev 39, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentMetaModel.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/AbstractComponentModel.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/AbstractComponentModel.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,473 @@
+package org.jboss.webbeans.model;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+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.BindingType;
+import javax.webbeans.Dependent;
+import javax.webbeans.DeploymentType;
+import javax.webbeans.Destroys;
+import javax.webbeans.Initializer;
+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.ejb.EjbMetaData;
+import org.jboss.webbeans.injectable.ComponentConstructor;
+import org.jboss.webbeans.injectable.SimpleConstructor;
+import org.jboss.webbeans.injectable.InjectableMethod;
+import org.jboss.webbeans.util.AnnotatedItem;
+import org.jboss.webbeans.util.LoggerUtil;
+import org.jboss.webbeans.util.Reflections;
+import org.jboss.webbeans.util.Strings;
+
+
+
+/**
+ * Web Beans Component meta model
+ *
+ * @author Pete Muir
+ *
+ */
+public abstract class AbstractComponentModel<T>
+{
+
+ public static final String LOGGER_NAME = "componentMetaModel";
+
+ private static Logger log = LoggerUtil.getLogger(LOGGER_NAME);
+
+ private Class<? extends T> type;
+ private Set<Annotation> bindingTypes;
+ private Annotation deploymentType;
+ private Annotation scopeType;
+ private MergedStereotypesModel mergedStereotypes;
+
+ private String name;
+
+ /**
+ *
+ * @param annotatedItem Annotations read from java classes
+ * @param xmlAnnotatedItem Annotations read from XML
+ * @param container
+ */
+ @SuppressWarnings("unchecked")
+ public AbstractComponentModel(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
+ {
+ if (annotatedItem == null)
+ {
+ throw new NullPointerException("annotatedItem must not be null. If the component is declared just in XML, pass in an empty annotatedItem");
+ }
+
+ if (xmlAnnotatedItem == null)
+ {
+ 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);
+ mergedStereotypes = new MergedStereotypesModel(annotatedItem, xmlAnnotatedItem, container);
+ this.bindingTypes = initBindingTypes(annotatedItem, xmlAnnotatedItem);
+ this.deploymentType = initDeploymentType(mergedStereotypes, annotatedItem, xmlAnnotatedItem, container);
+ this.scopeType = initScopeType(mergedStereotypes, annotatedItem, xmlAnnotatedItem);
+ this.name = initName(getMergedStereotypes(), annotatedItem, xmlAnnotatedItem, type);
+ checkRequiredTypesImplemented(getMergedStereotypes(), type);
+ checkScopeAllowed(getMergedStereotypes(), getScopeType(), type);
+ checkComponentImplementation(type);
+ // TODO Interceptors
+ }
+
+ @SuppressWarnings("unchecked")
+ protected static Class<?> initType(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem)
+ {
+ if (annotatedItem.getAnnotatedClass() != null && xmlAnnotatedItem.getAnnotatedClass() != null && !annotatedItem.getAnnotatedClass().equals(xmlAnnotatedItem.getAnnotatedClass()))
+ {
+ throw new IllegalArgumentException("Cannot build a component which specifies different classes in XML and Java");
+ }
+ else if (xmlAnnotatedItem.getAnnotatedClass() != null)
+ {
+ log.finest("Component type specified in XML");
+ return xmlAnnotatedItem.getAnnotatedClass();
+ }
+ else if (annotatedItem.getAnnotatedClass() != null)
+ {
+ log.finest("Component type specified in Java");
+ return annotatedItem.getAnnotatedClass();
+ }
+ else
+ {
+ throw new IllegalArgumentException("Cannot build a component which doesn't specify a type");
+ }
+ }
+
+ protected static Set<Annotation> initBindingTypes(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem)
+ {
+ Set<Annotation> xmlBindingTypes = xmlAnnotatedItem.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;
+ }
+
+ Set<Annotation> bindingTypes = annotatedItem.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");
+ }
+ return bindingTypes;
+ }
+
+ protected static Annotation initDeploymentType(MergedStereotypesModel stereotypes, AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
+ {
+ 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)");
+ }
+ 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;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected static <T> SimpleConstructor<T> initConstructor(Class<? extends T> type)
+ {
+ if (type.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);
+ }
+
+ if (type.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);
+ if ((initializerAnnotatedConstructors.size() + bindingTypeAnnotatedConstructors.size()) > 1)
+ {
+ if (initializerAnnotatedConstructors.size() > 1)
+ {
+ throw new RuntimeException("Cannot have more than one constructor annotated with @Initializer for " + type);
+ }
+
+ else if (bindingTypeAnnotatedConstructors.size() > 1)
+ {
+ throw new RuntimeException("Cannot have more than one constructor with binding types specified on constructor parameters for " + type);
+ }
+ else
+ {
+ throw new RuntimeException("Specify a constructor either annotated with @Initializer or with parameters annotated with binding types for " + type);
+ }
+ }
+ 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);
+ }
+ 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);
+ }
+ }
+
+ if (type.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);
+ }
+
+ throw new RuntimeException("Cannot determine constructor to use for " + type);
+ }
+
+ 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 );
+ }
+ return name;
+ }
+
+ /**
+ * Check that the types required by the stereotypes on the component are implemented
+ */
+ protected static void checkRequiredTypesImplemented(MergedStereotypesModel stereotypes, Class<?> type)
+ {
+ for (Class<?> requiredType : stereotypes.getRequiredTypes())
+ {
+ log.finest("Checking if required type " + requiredType + " is implemented");
+ if (!requiredType.isAssignableFrom(type))
+ {
+ throw new RuntimeException("Required type " + requiredType + " isn't implement on " + type);
+ }
+ }
+ }
+
+ /**
+ * 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)
+ {
+ log.finest("Checking if " + scopeType + " is allowed for " + type);
+ if (stereotypes.getSupportedScopes().size() > 0)
+ {
+ if (!stereotypes.getSupportedScopes().contains(scopeType.annotationType()))
+ {
+ throw new RuntimeException("Scope " + scopeType + " is not an allowed by the stereotype for " + type);
+ }
+ }
+ if (isDeclaredFinal(type) && !scopeType.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");
+ }
+ }
+
+ protected static boolean isDeclaredFinal(Class<?> type)
+ {
+ if (Reflections.isFinal(type))
+ {
+ return true;
+ }
+ for (Method method : type.getDeclaredMethods())
+ {
+ if (Reflections.isFinal(method))
+ {
+ return true;
+ }
+ }
+ 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))
+ {
+ throw new RuntimeException("Web Bean implementation class " + type + " cannot be declared abstract");
+ }
+ }
+
+ public Set<Annotation> getBindingTypes()
+ {
+ return bindingTypes;
+ }
+
+ public Annotation getDeploymentType()
+ {
+ return deploymentType;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public Annotation getScopeType()
+ {
+ return scopeType;
+ }
+
+ protected Class<? extends T> getType()
+ {
+ return type;
+ }
+
+ protected MergedStereotypesModel getMergedStereotypes()
+ {
+ return mergedStereotypes;
+ }
+
+ public abstract ComponentConstructor<T> getConstructor();
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/AbstractComponentModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/EnterpriseComponentModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/EnterpriseComponentModel.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/EnterpriseComponentModel.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,57 @@
+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.EJB;
+import org.jboss.webbeans.ejb.EjbMetaData;
+import org.jboss.webbeans.injectable.SimpleConstructor;
+import org.jboss.webbeans.injectable.InjectableMethod;
+import org.jboss.webbeans.util.AnnotatedItem;
+
+public class EnterpriseComponentModel<T> extends AbstractComponentModel<T>
+{
+
+ private SimpleConstructor<T> constructor;
+ private InjectableMethod<?> removeMethod;
+
+ public EnterpriseComponentModel(AnnotatedItem annotatedItem,
+ AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
+ {
+ super(annotatedItem, xmlAnnotatedItem, container);
+ this.constructor = initConstructor(getType());
+ EjbMetaData<T> ejbMetaData = EJB.getEjbMetaData(getType());
+ EnterpriseComponentModel.checkScopeAllowed(getMergedStereotypes(), getScopeType(), getType(), ejbMetaData);
+ this.removeMethod = initRemoveMethod(ejbMetaData, getType());
+ }
+
+ /**
+ * 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 SimpleConstructor<T> getConstructor()
+ {
+ return constructor;
+ }
+
+ public InjectableMethod<?> getRemoveMethod()
+ {
+ return removeMethod;
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/EnterpriseComponentModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/MergedStereotypesModel.java (from rev 21, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/MergedComponentStereotypes.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/MergedStereotypesModel.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/MergedStereotypesModel.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,90 @@
+package org.jboss.webbeans.model;
+
+import java.lang.annotation.Annotation;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.webbeans.Stereotype;
+
+import org.jboss.webbeans.ContainerImpl;
+import org.jboss.webbeans.util.AnnotatedItem;
+
+/**
+ * Meta model for the merged stereotype for a component
+ * @author pmuir
+ *
+ */
+public class MergedStereotypesModel
+{
+
+ private Map<Class<? extends Annotation>, Annotation> possibleDeploymentTypes;
+ private Set<Annotation> possibleScopeTypes;
+ private boolean componentNameDefaulted;
+ private Set<Class<?>> requiredTypes;
+ private Set<Class<? extends Annotation>> supportedScopes;
+
+ public MergedStereotypesModel(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
+ {
+ possibleDeploymentTypes = new HashMap<Class<? extends Annotation>, Annotation>();
+ possibleScopeTypes = new HashSet<Annotation>();
+ requiredTypes = new HashSet<Class<?>>();
+ supportedScopes = new HashSet<Class<? extends Annotation>>();
+
+ // All stereotypes declared in java and xml are merged
+ Set<Annotation> stereotypeAnnotations = new HashSet<Annotation>();
+ stereotypeAnnotations.addAll(annotatedItem.getAnnotations(Stereotype.class));
+ stereotypeAnnotations.addAll(xmlAnnotatedItem.getAnnotations(Stereotype.class));
+
+ for (Annotation stereotypeAnnotation : stereotypeAnnotations)
+ {
+ // Retrieve and merge all metadata from stereotypes
+ StereotypeModel stereotype = container.getStereotypeManager().getStereotype(stereotypeAnnotation.annotationType());
+ if (stereotype == null)
+ {
+ throw new NullPointerException("Stereotype " + stereotypeAnnotation + " not registered with container");
+ }
+ if (stereotype.getDefaultDeploymentType() != null)
+ {
+ possibleDeploymentTypes.put(stereotype.getDefaultDeploymentType().annotationType(), stereotype.getDefaultDeploymentType());
+ }
+ if (stereotype.getDefaultScopeType() != null)
+ {
+ possibleScopeTypes.add(stereotype.getDefaultScopeType());
+ }
+ requiredTypes.addAll(stereotype.getRequiredTypes());
+ supportedScopes.addAll(stereotype.getSupportedScopes());
+ if (stereotype.isComponentNameDefaulted())
+ {
+ componentNameDefaulted = true;
+ }
+ }
+ }
+
+ public Map<Class<? extends Annotation>, Annotation> getPossibleDeploymentTypes()
+ {
+ return possibleDeploymentTypes;
+ }
+
+ public Set<Annotation> getPossibleScopeTypes()
+ {
+ return possibleScopeTypes;
+ }
+
+ public boolean isComponentNameDefaulted()
+ {
+ return componentNameDefaulted;
+ }
+
+ public Set<Class<?>> getRequiredTypes()
+ {
+ return requiredTypes;
+ }
+
+ public Set<Class<? extends Annotation>> getSupportedScopes()
+ {
+ return supportedScopes;
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/MergedStereotypesModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/RemoteComponentModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/RemoteComponentModel.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/RemoteComponentModel.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,26 @@
+package org.jboss.webbeans.model;
+
+import org.jboss.webbeans.ContainerImpl;
+import org.jboss.webbeans.injectable.ComponentConstructor;
+import org.jboss.webbeans.util.AnnotatedItem;
+
+public class RemoteComponentModel<T> extends AbstractComponentModel<T>
+{
+
+ public RemoteComponentModel(AnnotatedItem annotatedItem,
+ AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
+ {
+ super(annotatedItem, xmlAnnotatedItem, container);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public ComponentConstructor<T> getConstructor()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/RemoteComponentModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/SimpleComponentModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/SimpleComponentModel.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/SimpleComponentModel.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,39 @@
+package org.jboss.webbeans.model;
+
+import org.jboss.webbeans.ContainerImpl;
+import org.jboss.webbeans.injectable.SimpleConstructor;
+import org.jboss.webbeans.injectable.InjectableMethod;
+import org.jboss.webbeans.util.AnnotatedItem;
+
+public class SimpleComponentModel<T> extends AbstractComponentModel<T>
+{
+
+ private SimpleConstructor<T> constructor;
+ private InjectableMethod<?> removeMethod;
+
+ /**
+ *
+ * @param annotatedItem Annotations read from java classes
+ * @param xmlAnnotatedItem Annotations read from XML
+ * @param container
+ */
+ @SuppressWarnings("unchecked")
+ public SimpleComponentModel(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
+ {
+ super(annotatedItem, xmlAnnotatedItem, container);
+ this.constructor = initConstructor(getType());
+ // TODO Interceptors
+ }
+
+ public SimpleConstructor<T> getConstructor()
+ {
+ return constructor;
+ }
+
+ public InjectableMethod<?> getRemoveMethod()
+ {
+ return removeMethod;
+ }
+
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/SimpleComponentModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/StereotypeModel.java (from rev 19, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeMetaModel.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/StereotypeModel.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/StereotypeModel.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,191 @@
+package org.jboss.webbeans.model;
+
+import java.lang.annotation.Annotation;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.webbeans.BindingType;
+import javax.webbeans.DeploymentType;
+import javax.webbeans.InterceptorBindingType;
+import javax.webbeans.Named;
+import javax.webbeans.ScopeType;
+import javax.webbeans.Stereotype;
+
+import org.jboss.webbeans.util.AnnotatedItem;
+
+/**
+ * A meta model for a stereotype, allows us to cache a stereotype and to validate it
+ *
+ * @author pmuir
+ *
+ */
+public class StereotypeModel
+{
+
+ private Class<? extends Annotation> stereotypeClass;
+ private Annotation defaultDeploymentType;
+ private Annotation defaultScopeType;
+ private boolean componentNameDefaulted;
+ private Set<Class<? extends Annotation>> supportedScopes;
+ private Set<Class<?>> requiredTypes;
+ private Set<Annotation> interceptorBindings;
+
+ @SuppressWarnings("unchecked")
+ public StereotypeModel(AnnotatedItem annotatedClass)
+ {
+ initStereotypeClass(annotatedClass);
+ Stereotype stereotype = annotatedClass.getAnnotation(Stereotype.class);
+ initDefaultDeploymentType(annotatedClass);
+ initDefaultScopeType(annotatedClass);
+ initComponentNameDefaulted(annotatedClass);
+ initSupportedScopes(annotatedClass, stereotype);
+ initRequiredTypes(annotatedClass, stereotype);
+ initInterceptorBindings(annotatedClass);
+ checkBindingTypes(annotatedClass);
+ }
+
+ private void checkBindingTypes(AnnotatedItem annotatedClass)
+ {
+ Set<Annotation> bindingTypes = annotatedClass.getAnnotations(BindingType.class);
+ if (bindingTypes.size() > 0)
+ {
+ throw new RuntimeException("Cannot declare binding types on a stereotpe");
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void initStereotypeClass(AnnotatedItem annotatedClass)
+ {
+ if (Annotation.class.isAssignableFrom(annotatedClass.getAnnotatedClass()))
+ {
+ this.stereotypeClass = (Class<? extends Annotation>) annotatedClass.getAnnotatedClass();
+ }
+ else
+ {
+ throw new RuntimeException("@Stereotype can only be applied to an annotation");
+ }
+ }
+
+ private void initInterceptorBindings(AnnotatedItem annotatedClass)
+ {
+ interceptorBindings = annotatedClass.getAnnotations(InterceptorBindingType.class);
+ }
+
+ private void initSupportedScopes(AnnotatedItem annotatedElement, Stereotype stereotype)
+ {
+ this.supportedScopes = new HashSet<Class<? extends Annotation>>();
+ Class<? extends Annotation>[] supportedScopes = stereotype.supportedScopes();
+ if (supportedScopes.length > 0)
+ {
+ this.supportedScopes.addAll(Arrays.asList(supportedScopes));
+ }
+ }
+
+ private void initRequiredTypes(AnnotatedItem annotatedElement, Stereotype stereotype)
+ {
+ this.requiredTypes = new HashSet<Class<?>>();
+ Class<?>[] requiredTypes = stereotype.requiredTypes();
+ if (requiredTypes.length > 0)
+ {
+ this.requiredTypes.addAll(Arrays.asList(requiredTypes));
+ }
+ }
+
+ private void initComponentNameDefaulted(AnnotatedItem annotatedElement)
+ {
+ if (annotatedElement.isAnnotationPresent(Named.class))
+ {
+ if (!"".equals(annotatedElement.getAnnotation(Named.class).value()))
+ {
+ throw new RuntimeException("Cannot specify a value for a @Named stereotype");
+ }
+ componentNameDefaulted = true;
+ }
+ }
+
+ private void initDefaultScopeType(AnnotatedItem annotatedElement)
+ {
+ Set<Annotation> scopeTypes = annotatedElement.getAnnotations(ScopeType.class);
+ if (scopeTypes.size() > 1)
+ {
+ throw new RuntimeException("At most one scope type may be specified");
+ }
+ else if (scopeTypes.size() == 1)
+ {
+ this.defaultScopeType = scopeTypes.iterator().next();
+ }
+ }
+
+ private void initDefaultDeploymentType(AnnotatedItem annotatedElement)
+ {
+ Set<Annotation> deploymentTypes = annotatedElement.getAnnotations(DeploymentType.class);
+ if (deploymentTypes.size() > 1)
+ {
+ throw new RuntimeException("At most one deployment type may be specified");
+ }
+ else if (deploymentTypes.size() == 1)
+ {
+ this.defaultDeploymentType = deploymentTypes.iterator().next();
+ }
+ }
+
+ /**
+ * Get the default deployment type the stereotype specifies, or null if none
+ * is specified
+ */
+ public Annotation getDefaultDeploymentType()
+ {
+ return defaultDeploymentType;
+ }
+
+ /**
+ * Get the default scope type the stereotype specifies, or null if none is
+ * specified
+ */
+ public Annotation getDefaultScopeType()
+ {
+ return defaultScopeType;
+ }
+
+ /**
+ * Get any interceptor bindings the the stereotype specifies, or an empty set
+ * if none are specified
+ */
+ public Set<Annotation> getInterceptorBindings()
+ {
+ return interceptorBindings;
+ }
+
+ /**
+ * Returns true if the stereotype specifies the component name should be
+ * defaulted
+ */
+ public boolean isComponentNameDefaulted()
+ {
+ return componentNameDefaulted;
+ }
+
+ /**
+ * Returns the scopes this stereotype allows, or an empty set if none are
+ * specified
+ */
+ public Set<Class<? extends Annotation>> getSupportedScopes()
+ {
+ return supportedScopes;
+ }
+
+ /**
+ * Returns the types this stereotype requires, or an empty set if none are
+ * specified
+ */
+ public Set<Class<?>> getRequiredTypes()
+ {
+ return requiredTypes;
+ }
+
+ public Class<? extends Annotation> getStereotypeClass()
+ {
+ return stereotypeClass;
+ }
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/model/StereotypeModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentMetaModelTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentMetaModelTest.java 2008-07-03 15:16:06 UTC (rev 39)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentMetaModelTest.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -16,16 +16,15 @@
import javax.webbeans.Production;
import javax.webbeans.RequestScoped;
-import org.jboss.webbeans.ComponentMetaModel;
import org.jboss.webbeans.ContainerImpl;
-import org.jboss.webbeans.StereotypeMetaModel;
-import org.jboss.webbeans.ComponentMetaModel.ComponentType;
import org.jboss.webbeans.bindings.ConversationScopedBinding;
import org.jboss.webbeans.bindings.CurrentBinding;
import org.jboss.webbeans.bindings.DependentBinding;
import org.jboss.webbeans.bindings.NamedBinding;
import org.jboss.webbeans.bindings.RequestScopedBinding;
import org.jboss.webbeans.bindings.StandardBinding;
+import org.jboss.webbeans.model.SimpleComponentModel;
+import org.jboss.webbeans.model.StereotypeModel;
import org.jboss.webbeans.test.annotations.AnimalStereotype;
import org.jboss.webbeans.test.annotations.AnotherDeploymentType;
import org.jboss.webbeans.test.annotations.Asynchronous;
@@ -45,30 +44,20 @@
import org.jboss.webbeans.test.bindings.RiverFishStereotypeBinding;
import org.jboss.webbeans.test.bindings.SynchronousBinding;
import org.jboss.webbeans.test.components.Antelope;
-import org.jboss.webbeans.test.components.Bear;
import org.jboss.webbeans.test.components.Carp;
import org.jboss.webbeans.test.components.Cat;
import org.jboss.webbeans.test.components.Chair;
-import org.jboss.webbeans.test.components.Cheetah;
import org.jboss.webbeans.test.components.ComponentWithTooManyDeploymentTypes;
import org.jboss.webbeans.test.components.ComponentWithTooManyScopeTypes;
-import org.jboss.webbeans.test.components.Cougar;
import org.jboss.webbeans.test.components.Cow;
-import org.jboss.webbeans.test.components.Elephant;
-import org.jboss.webbeans.test.components.Giraffe;
import org.jboss.webbeans.test.components.Goldfish;
import org.jboss.webbeans.test.components.Gorilla;
import org.jboss.webbeans.test.components.Haddock;
import org.jboss.webbeans.test.components.Horse;
-import org.jboss.webbeans.test.components.Leopard;
-import org.jboss.webbeans.test.components.Lion;
import org.jboss.webbeans.test.components.Moose;
import org.jboss.webbeans.test.components.Order;
-import org.jboss.webbeans.test.components.Panther;
import org.jboss.webbeans.test.components.Pig;
-import org.jboss.webbeans.test.components.Puma;
import org.jboss.webbeans.test.components.SeaBass;
-import org.jboss.webbeans.test.components.Tiger;
import org.jboss.webbeans.test.components.Tuna;
import org.jboss.webbeans.test.mock.MockContainerImpl;
import org.jboss.webbeans.util.AnnotatedItem;
@@ -100,12 +89,12 @@
private void initStereotypes(ContainerImpl container)
{
- container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(AnimalStereotype.class)));
- container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(HornedMammalStereotype.class)));
- container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(MammalStereotype.class)));
- container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(FishStereotype.class)));
- container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(RiverFishStereotype.class)));
- container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(RequestScopedAnimalStereotype.class)));
+ container.getStereotypeManager().addStereotype(new StereotypeModel(new ClassAnnotatedItem(AnimalStereotype.class)));
+ container.getStereotypeManager().addStereotype(new StereotypeModel(new ClassAnnotatedItem(HornedMammalStereotype.class)));
+ container.getStereotypeManager().addStereotype(new StereotypeModel(new ClassAnnotatedItem(MammalStereotype.class)));
+ container.getStereotypeManager().addStereotype(new StereotypeModel(new ClassAnnotatedItem(FishStereotype.class)));
+ container.getStereotypeManager().addStereotype(new StereotypeModel(new ClassAnnotatedItem(RiverFishStereotype.class)));
+ container.getStereotypeManager().addStereotype(new StereotypeModel(new ClassAnnotatedItem(RequestScopedAnimalStereotype.class)));
}
@Test
@@ -114,7 +103,7 @@
boolean exception = false;
try
{
- new ComponentMetaModel<ComponentWithTooManyDeploymentTypes>(new ClassAnnotatedItem(ComponentWithTooManyDeploymentTypes.class), emptyAnnotatedItem, container);
+ new SimpleComponentModel<ComponentWithTooManyDeploymentTypes>(new ClassAnnotatedItem(ComponentWithTooManyDeploymentTypes.class), emptyAnnotatedItem, container);
}
catch (Exception e)
{
@@ -132,7 +121,7 @@
xmlDefinedDeploymentTypeAnnotations.put(AnotherDeploymentType.class, new AnotherDeploymentTypeBinding());
AnnotatedItem xmlDefinedDeploymentTypeAnnotatedItem = new MutableAnnotatedItem(ComponentWithTooManyDeploymentTypes.class, xmlDefinedDeploymentTypeAnnotations);
- ComponentMetaModel<ComponentWithTooManyDeploymentTypes> component = new ComponentMetaModel<ComponentWithTooManyDeploymentTypes>(new ClassAnnotatedItem(ComponentWithTooManyDeploymentTypes.class), xmlDefinedDeploymentTypeAnnotatedItem, container);
+ SimpleComponentModel<ComponentWithTooManyDeploymentTypes> component = new SimpleComponentModel<ComponentWithTooManyDeploymentTypes>(new ClassAnnotatedItem(ComponentWithTooManyDeploymentTypes.class), xmlDefinedDeploymentTypeAnnotatedItem, container);
assert component.getDeploymentType().annotationType().equals(AnotherDeploymentType.class);
}
@@ -140,7 +129,7 @@
public void testXmlDefaultDeploymentType()
{
AnnotatedItem antelopeAnnotatedItem = new MutableAnnotatedItem(Antelope.class, new HashMap<Class<? extends Annotation>, Annotation>());
- ComponentMetaModel<Antelope> antelope = new ComponentMetaModel<Antelope>(emptyAnnotatedItem, antelopeAnnotatedItem, container);
+ SimpleComponentModel<Antelope> antelope = new SimpleComponentModel<Antelope>(emptyAnnotatedItem, antelopeAnnotatedItem, container);
assert antelope.getDeploymentType().annotationType().equals(Production.class);
}
@@ -148,7 +137,7 @@
public void testXmlIgnoresJavaDeploymentType()
{
AnnotatedItem annotatedItem = new MutableAnnotatedItem(Tuna.class, new HashMap<Class<? extends Annotation>, Annotation>());
- ComponentMetaModel<Tuna> tuna = new ComponentMetaModel<Tuna>(new ClassAnnotatedItem(Tuna.class), annotatedItem, container);
+ SimpleComponentModel<Tuna> tuna = new SimpleComponentModel<Tuna>(new ClassAnnotatedItem(Tuna.class), annotatedItem, container);
assert tuna.getDeploymentType().annotationType().equals(Production.class);
}
@@ -159,7 +148,7 @@
annotations.put(HornedMammalStereotype.class, new HornedMamalStereotypeBinding());
AnnotatedItem annotatedItem = new MutableAnnotatedItem(Moose.class, annotations);
- ComponentMetaModel<Moose> moose = new ComponentMetaModel<Moose>(new ClassAnnotatedItem(Moose.class), annotatedItem, container);
+ SimpleComponentModel<Moose> moose = new SimpleComponentModel<Moose>(new ClassAnnotatedItem(Moose.class), annotatedItem, container);
assert moose.getDeploymentType().annotationType().equals(HornedAnimalDeploymentType.class);
}
@@ -174,7 +163,7 @@
annotations.put(Asynchronous.class, new AsynchronousBinding());
AnnotatedItem annotatedItem = new MutableAnnotatedItem(Cat.class, annotations);
- ComponentMetaModel<Cat> cat = new ComponentMetaModel<Cat>(new ClassAnnotatedItem(Cat.class), annotatedItem, container);
+ SimpleComponentModel<Cat> cat = new SimpleComponentModel<Cat>(new ClassAnnotatedItem(Cat.class), annotatedItem, container);
assert cat.getBindingTypes().size() == 1;
assert annotationSetMatches(cat.getBindingTypes(), Asynchronous.class);
}
@@ -183,7 +172,7 @@
@Test
public void testBindingTypesDeclaredInJava()
{
- ComponentMetaModel<Cat> cat = new ComponentMetaModel<Cat>(new ClassAnnotatedItem(Cat.class), emptyAnnotatedItem, container);
+ SimpleComponentModel<Cat> cat = new SimpleComponentModel<Cat>(new ClassAnnotatedItem(Cat.class), emptyAnnotatedItem, container);
assert cat.getBindingTypes().size() == 1;
assert annotationSetMatches(cat.getBindingTypes(), Synchronous.class);
}
@@ -196,7 +185,7 @@
annotations.put(Asynchronous.class, new AsynchronousBinding());
AnnotatedItem annotatedItem = new MutableAnnotatedItem(Antelope.class, annotations);
- ComponentMetaModel<Antelope> antelope = new ComponentMetaModel<Antelope>(emptyAnnotatedItem, annotatedItem, container);
+ SimpleComponentModel<Antelope> antelope = new SimpleComponentModel<Antelope>(emptyAnnotatedItem, annotatedItem, container);
assert annotationSetMatches(antelope.getBindingTypes(), Asynchronous.class);
}
@@ -204,7 +193,7 @@
@Test
public void testDefaultBindingType()
{
- ComponentMetaModel<Order> order = new ComponentMetaModel<Order>(new ClassAnnotatedItem(Order.class), emptyAnnotatedItem, container);
+ SimpleComponentModel<Order> order = new SimpleComponentModel<Order>(new ClassAnnotatedItem(Order.class), emptyAnnotatedItem, container);
assert order.getBindingTypes().size() == 1;
order.getBindingTypes().iterator().next().annotationType().equals(Current.class);
}
@@ -214,7 +203,7 @@
@Test
public void testScopeDeclaredInJava()
{
- ComponentMetaModel<SeaBass> trout = new ComponentMetaModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), emptyAnnotatedItem, container);
+ SimpleComponentModel<SeaBass> trout = new SimpleComponentModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), emptyAnnotatedItem, container);
assert trout.getScopeType().annotationType().equals(RequestScoped.class);
}
@@ -225,7 +214,7 @@
annotations.put(RequestScoped.class, new RequestScopedBinding());
AnnotatedItem annotatedItem = new MutableAnnotatedItem(Order.class, annotations);
- ComponentMetaModel<Order> order = new ComponentMetaModel<Order>(new ClassAnnotatedItem(Order.class), annotatedItem, container);
+ SimpleComponentModel<Order> order = new SimpleComponentModel<Order>(new ClassAnnotatedItem(Order.class), annotatedItem, container);
assert order.getScopeType().annotationType().equals(RequestScoped.class);
}
@@ -235,7 +224,7 @@
Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
annotations.put(ConversationScoped.class, new ConversationScopedBinding());
AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
- ComponentMetaModel<SeaBass> trout = new ComponentMetaModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
+ SimpleComponentModel<SeaBass> trout = new SimpleComponentModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
assert trout.getScopeType().annotationType().equals(ConversationScoped.class);
}
@@ -245,14 +234,14 @@
Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
- ComponentMetaModel<SeaBass> trout = new ComponentMetaModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
+ SimpleComponentModel<SeaBass> trout = new SimpleComponentModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
assert trout.getScopeType().annotationType().equals(RequestScoped.class);
}
@Test
public void testNoScopeSpecified()
{
- ComponentMetaModel<Order> order = new ComponentMetaModel<Order>(new ClassAnnotatedItem(Order.class), emptyAnnotatedItem, container);
+ SimpleComponentModel<Order> order = new SimpleComponentModel<Order>(new ClassAnnotatedItem(Order.class), emptyAnnotatedItem, container);
assert order.getScopeType().annotationType().equals(Dependent.class);
}
@@ -262,7 +251,7 @@
boolean exception = false;
try
{
- new ComponentMetaModel<ComponentWithTooManyScopeTypes>(new ClassAnnotatedItem(ComponentWithTooManyScopeTypes.class), emptyAnnotatedItem, container);
+ new SimpleComponentModel<ComponentWithTooManyScopeTypes>(new ClassAnnotatedItem(ComponentWithTooManyScopeTypes.class), emptyAnnotatedItem, container);
}
catch (Exception e)
{
@@ -281,7 +270,7 @@
annotations.put(RequestScoped.class, new RequestScopedBinding());
annotations.put(ConversationScoped.class, new ConversationScopedBinding());
AnnotatedItem antelopeAnnotatedItem = new MutableAnnotatedItem(Antelope.class, annotations);
- new ComponentMetaModel<Antelope>(emptyAnnotatedItem, antelopeAnnotatedItem, container);
+ new SimpleComponentModel<Antelope>(emptyAnnotatedItem, antelopeAnnotatedItem, container);
}
catch (Exception e)
{
@@ -296,7 +285,7 @@
Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
annotations.put(FishStereotype.class, new FishStereotypeBinding());
AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
- ComponentMetaModel<SeaBass> trout = new ComponentMetaModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
+ SimpleComponentModel<SeaBass> trout = new SimpleComponentModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
assert trout.getScopeType().annotationType().equals(RequestScoped.class);
}
@@ -311,7 +300,7 @@
boolean exception = false;
try
{
- new ComponentMetaModel<Haddock>(new ClassAnnotatedItem(Haddock.class), annotatedItem, container);
+ new SimpleComponentModel<Haddock>(new ClassAnnotatedItem(Haddock.class), annotatedItem, container);
}
catch (Exception e)
{
@@ -328,7 +317,7 @@
annotations.put(AnimalStereotype.class, new AnimalStereotypeBinding());
AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
- ComponentMetaModel<SeaBass> trout = new ComponentMetaModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
+ SimpleComponentModel<SeaBass> trout = new SimpleComponentModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
assert trout.getScopeType().annotationType().equals(RequestScoped.class);
}
@@ -340,7 +329,7 @@
annotations.put(RiverFishStereotype.class, new RiverFishStereotypeBinding());
AnnotatedItem annotatedItem = new MutableAnnotatedItem(Haddock.class, annotations);
- ComponentMetaModel<Haddock> haddock = new ComponentMetaModel<Haddock>(new ClassAnnotatedItem(Haddock.class), annotatedItem, container);
+ SimpleComponentModel<Haddock> haddock = new SimpleComponentModel<Haddock>(new ClassAnnotatedItem(Haddock.class), annotatedItem, container);
assert haddock.getScopeType().annotationType().equals(ApplicationScoped.class);
}
@@ -349,9 +338,8 @@
@Test
public void testNamed()
{
- ComponentMetaModel<Haddock> haddock = new ComponentMetaModel<Haddock>(new ClassAnnotatedItem(Haddock.class), emptyAnnotatedItem, container);
+ SimpleComponentModel<Haddock> haddock = new SimpleComponentModel<Haddock>(new ClassAnnotatedItem(Haddock.class), emptyAnnotatedItem, container);
assert haddock.getName() != null;
- haddock.getComponentType().equals(ComponentType.SIMPLE);
assert haddock.getName().equals("haddock");
}
@@ -368,10 +356,9 @@
}
});
AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
- ComponentMetaModel<SeaBass> trout = new ComponentMetaModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
+ SimpleComponentModel<SeaBass> trout = new SimpleComponentModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
assert trout.getName() != null;
- trout.getComponentType().equals(ComponentType.SIMPLE);
assert trout.getName().equals("seaBass");
}
@@ -388,7 +375,7 @@
}
});
AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
- ComponentMetaModel<SeaBass> trout = new ComponentMetaModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
+ SimpleComponentModel<SeaBass> trout = new SimpleComponentModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
assert trout.getName().equals("aTrout");
}
@@ -396,14 +383,14 @@
@Test
public void testNotNamed()
{
- ComponentMetaModel<SeaBass> trout = new ComponentMetaModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), emptyAnnotatedItem, container);
+ SimpleComponentModel<SeaBass> trout = new SimpleComponentModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), emptyAnnotatedItem, container);
assert trout.getName() == null;
}
@Test
public void testNonDefaultNamed()
{
- ComponentMetaModel<Moose> moose = new ComponentMetaModel<Moose>(new ClassAnnotatedItem(Moose.class), emptyAnnotatedItem, container);
+ SimpleComponentModel<Moose> moose = new SimpleComponentModel<Moose>(new ClassAnnotatedItem(Moose.class), emptyAnnotatedItem, container);
assert moose.getName().equals("aMoose");
}
@@ -426,7 +413,7 @@
});
AnnotatedItem currentSynchronousOrderAnnotatedItem = new MutableAnnotatedItem(Order.class, orderXmlAnnotations);
- ComponentMetaModel<Order> order = new ComponentMetaModel<Order>(new ClassAnnotatedItem(Order.class), currentSynchronousOrderAnnotatedItem, container);
+ SimpleComponentModel<Order> order = new SimpleComponentModel<Order>(new ClassAnnotatedItem(Order.class), currentSynchronousOrderAnnotatedItem, container);
assert Production.class.equals(order.getDeploymentType().annotationType());
assert "currentSynchronousOrder".equals(order.getName());
assert order.getBindingTypes().size() == 2;
@@ -437,7 +424,7 @@
@Test
public void testSingleStereotype()
{
- ComponentMetaModel<Gorilla> gorilla = new ComponentMetaModel<Gorilla>(new ClassAnnotatedItem(Gorilla.class), emptyAnnotatedItem, container);
+ SimpleComponentModel<Gorilla> gorilla = new SimpleComponentModel<Gorilla>(new ClassAnnotatedItem(Gorilla.class), emptyAnnotatedItem, container);
assert gorilla.getName() == null;
assert gorilla.getDeploymentType().annotationType().equals(Production.class);
assert gorilla.getBindingTypes().iterator().next().annotationType().equals(Current.class);
@@ -449,7 +436,7 @@
{
try
{
- new ComponentMetaModel<Gorilla>(new ClassAnnotatedItem(Gorilla.class), emptyAnnotatedItem, container);
+ new SimpleComponentModel<Gorilla>(new ClassAnnotatedItem(Gorilla.class), emptyAnnotatedItem, container);
}
catch (Exception e)
{
@@ -464,7 +451,7 @@
boolean exception = false;
try
{
- new ComponentMetaModel<Chair>(new ClassAnnotatedItem(Chair.class), emptyAnnotatedItem, container);
+ new SimpleComponentModel<Chair>(new ClassAnnotatedItem(Chair.class), emptyAnnotatedItem, container);
}
catch (Exception e)
{
@@ -479,7 +466,7 @@
{
try
{
- new ComponentMetaModel<Goldfish>(new ClassAnnotatedItem(Goldfish.class), emptyAnnotatedItem, container);
+ new SimpleComponentModel<Goldfish>(new ClassAnnotatedItem(Goldfish.class), emptyAnnotatedItem, container);
}
catch (Exception e)
{
@@ -495,7 +482,7 @@
boolean exception = false;
try
{
- new ComponentMetaModel<Carp>(new ClassAnnotatedItem(Carp.class), emptyAnnotatedItem, container);
+ new SimpleComponentModel<Carp>(new ClassAnnotatedItem(Carp.class), emptyAnnotatedItem, container);
}
catch (Exception e)
{
@@ -513,7 +500,7 @@
boolean exception = false;
try
{
- new ComponentMetaModel<Cow>(new ClassAnnotatedItem(Cow.class), emptyAnnotatedItem, container);
+ new SimpleComponentModel<Cow>(new ClassAnnotatedItem(Cow.class), emptyAnnotatedItem, container);
}
catch (Exception e)
{
@@ -528,7 +515,7 @@
boolean exception = false;
try
{
- new ComponentMetaModel<Horse>(new ClassAnnotatedItem(Horse.class), emptyAnnotatedItem, container);
+ new SimpleComponentModel<Horse>(new ClassAnnotatedItem(Horse.class), emptyAnnotatedItem, container);
}
catch (Exception e)
{
@@ -541,7 +528,7 @@
AnnotatedItem annotatedItem = new MutableAnnotatedItem(Horse.class, annotations);
try
{
- new ComponentMetaModel<Horse>(new ClassAnnotatedItem(Horse.class), annotatedItem, container);
+ new SimpleComponentModel<Horse>(new ClassAnnotatedItem(Horse.class), annotatedItem, container);
}
catch (Exception e)
{
@@ -555,7 +542,7 @@
boolean exception = false;
try
{
- new ComponentMetaModel<Pig>(new ClassAnnotatedItem(Pig.class), emptyAnnotatedItem, container);
+ new SimpleComponentModel<Pig>(new ClassAnnotatedItem(Pig.class), emptyAnnotatedItem, container);
}
catch (Exception e)
{
@@ -568,7 +555,7 @@
AnnotatedItem annotatedItem = new MutableAnnotatedItem(Pig.class, annotations);
try
{
- new ComponentMetaModel<Pig>(new ClassAnnotatedItem(Pig.class), annotatedItem, container);
+ new SimpleComponentModel<Pig>(new ClassAnnotatedItem(Pig.class), annotatedItem, container);
}
catch (Exception e)
{
@@ -576,152 +563,4 @@
}
}
- @SuppressWarnings("unchecked")
- @Test
- public void testStateless()
- {
- ComponentMetaModel<Lion> lion = new ComponentMetaModel<Lion>(new ClassAnnotatedItem(Lion.class), emptyAnnotatedItem, container);
- assert lion.getComponentType().equals(ComponentType.ENTERPRISE);
- assert lion.getScopeType().annotationType().equals(Dependent.class);
- annotationSetMatches(lion.getBindingTypes(), Current.class);
- assert lion.getName().equals("lion");
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testStatelessDefinedInXml()
- {
- Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
- AnnotatedItem annotatedItem = new MutableAnnotatedItem(Giraffe.class, annotations);
-
- ComponentMetaModel<Giraffe> giraffe = new ComponentMetaModel<Giraffe>(new ClassAnnotatedItem(Giraffe.class), annotatedItem, container);
- assert giraffe.getComponentType().equals(ComponentType.ENTERPRISE);
- assert giraffe.getScopeType().annotationType().equals(Dependent.class);
- annotationSetMatches(giraffe.getBindingTypes(), Current.class);
- }
-
- @Test
- public void testStatelessWithRequestScope()
- {
- boolean exception = false;
- try
- {
- new ComponentMetaModel<Bear>(new ClassAnnotatedItem(Bear.class), emptyAnnotatedItem, container);
- }
- catch (Exception e)
- {
- exception = true;
- }
- assert exception;
- }
-
- // TODO Need EJB3.1 @Test
- public void testSingleton()
- {
- //ComponentMetaModel<Lion> lion = new ComponentMetaModel<Lion>(new ClassAnnotatedItem(Lion.class), emptyAnnotatedItem, container);
- //assert lion.getComponentType().equals(ComponentType.ENTERPRISE);
- //assert lion.getScopeType().annotationType().equals(ApplicationScoped.class);
- }
-
- // TODO Need EJB3.1 @Test
- public void testSingletonWithRequestScope()
- {
- //ComponentMetaModel<Lion> lion = new ComponentMetaModel<Lion>(new ClassAnnotatedItem(Lion.class), emptyAnnotatedItem, container);
- //assert lion.getComponentType().equals(ComponentType.ENTERPRISE);
- //assert lion.getScopeType().annotationType().equals(ApplicationScoped.class);
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testStateful()
- {
-
- ComponentMetaModel<Tiger> tiger = new ComponentMetaModel<Tiger>(new ClassAnnotatedItem(Tiger.class), emptyAnnotatedItem, container);
- assert tiger.getComponentType().equals(ComponentType.ENTERPRISE);
- annotationSetMatches(tiger.getBindingTypes(), Synchronous.class);
- assert tiger.getRemoveMethod().getMethod().getName().equals("remove");
- assert tiger.getName() == null;
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testMultipleRemoveMethodsWithDestroys()
- {
-
- ComponentMetaModel<Elephant> elephant = new ComponentMetaModel<Elephant>(new ClassAnnotatedItem(Elephant.class), emptyAnnotatedItem, container);
- assert elephant.getComponentType().equals(ComponentType.ENTERPRISE);
- assert elephant.getRemoveMethod().getMethod().getName().equals("remove2");
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testMultipleRemoveMethodsWithoutDestroys()
- {
- boolean exception = false;
- try
- {
- new ComponentMetaModel<Puma>(new ClassAnnotatedItem(Puma.class), emptyAnnotatedItem, container);
- }
- catch (Exception e)
- {
- exception = true;
- }
- assert exception;
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testMultipleRemoveMethodsWithMultipleDestroys()
- {
- boolean exception = false;
- try
- {
- new ComponentMetaModel<Cougar>(new ClassAnnotatedItem(Cougar.class), emptyAnnotatedItem, container);
- }
- catch (Exception e)
- {
- exception = true;
- }
- assert exception;
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testNonStatefulEnterpriseComponentWithDestroys()
- {
- boolean exception = false;
- try
- {
- new ComponentMetaModel<Cheetah>(new ClassAnnotatedItem(Cheetah.class), emptyAnnotatedItem, container);
- }
- catch (Exception e)
- {
- exception = true;
- }
- assert exception;
- }
-
- @Test
- public void testRemoveMethodWithDefaultBinding()
- {
-
- ComponentMetaModel<Panther> panther = new ComponentMetaModel<Panther>(new ClassAnnotatedItem(Panther.class), emptyAnnotatedItem, container);
- assert panther.getComponentType().equals(ComponentType.ENTERPRISE);
- assert panther.getRemoveMethod().getMethod().getName().equals("remove");
- assert panther.getRemoveMethod().getParameters().size() == 1;
- assert panther.getRemoveMethod().getParameters().get(0).getType().equals(String.class);
- assert panther.getRemoveMethod().getParameters().get(0).getBindingTypes().length == 1;
- assert panther.getRemoveMethod().getParameters().get(0).getBindingTypes()[0].annotationType().equals(Current.class);
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testMessageDriven()
- {
- ComponentMetaModel<Leopard> leopard = new ComponentMetaModel<Leopard>(new ClassAnnotatedItem(Leopard.class), emptyAnnotatedItem, container);
- assert leopard.getComponentType().equals(ComponentType.ENTERPRISE);
- annotationSetMatches(leopard.getBindingTypes(), Current.class);
- }
-
-
}
Modified: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ConstructorMetaModelTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ConstructorMetaModelTest.java 2008-07-03 15:16:06 UTC (rev 39)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ConstructorMetaModelTest.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -5,9 +5,9 @@
import javax.webbeans.Current;
-import org.jboss.webbeans.ComponentMetaModel;
import org.jboss.webbeans.ContainerImpl;
-import org.jboss.webbeans.injectable.ConstructorMetaModel;
+import org.jboss.webbeans.injectable.SimpleConstructor;
+import org.jboss.webbeans.model.SimpleComponentModel;
import org.jboss.webbeans.test.annotations.Synchronous;
import org.jboss.webbeans.test.components.Chicken;
import org.jboss.webbeans.test.components.Donkey;
@@ -42,7 +42,7 @@
@Test
public void testImplicitConstructor()
{
- ConstructorMetaModel<Order> constructor = new ComponentMetaModel<Order>(new ClassAnnotatedItem(Order.class), emptyAnnotatedItem, container).getConstructor();
+ SimpleConstructor<Order> constructor = new SimpleComponentModel<Order>(new ClassAnnotatedItem(Order.class), emptyAnnotatedItem, container).getConstructor();
assert constructor.getConstructor().getDeclaringClass().equals(Order.class);
assert constructor.getConstructor().getParameterTypes().length == 0;
assert constructor.getParameters().size() == 0;
@@ -51,7 +51,7 @@
@Test
public void testSingleConstructor()
{
- ConstructorMetaModel<Donkey> constructor = new ComponentMetaModel<Donkey>(new ClassAnnotatedItem(Donkey.class), emptyAnnotatedItem, container).getConstructor();
+ SimpleConstructor<Donkey> constructor = new SimpleComponentModel<Donkey>(new ClassAnnotatedItem(Donkey.class), emptyAnnotatedItem, container).getConstructor();
assert constructor.getConstructor().getDeclaringClass().equals(Donkey.class);
assert constructor.getConstructor().getParameterTypes().length == 1;
assert constructor.getConstructor().getParameterTypes()[0].equals(String.class);
@@ -64,7 +64,7 @@
@Test
public void testInitializerAnnotatedConstructor()
{
- ConstructorMetaModel<Sheep> constructor = new ComponentMetaModel<Sheep>(new ClassAnnotatedItem(Sheep.class), emptyAnnotatedItem, container).getConstructor();
+ SimpleConstructor<Sheep> constructor = new SimpleComponentModel<Sheep>(new ClassAnnotatedItem(Sheep.class), emptyAnnotatedItem, container).getConstructor();
assert constructor.getConstructor().getDeclaringClass().equals(Sheep.class);
assert constructor.getConstructor().getParameterTypes().length == 2;
assert constructor.getConstructor().getParameterTypes()[0].equals(String.class);
@@ -81,7 +81,7 @@
@Test
public void testBindingTypeAnnotatedConstructor()
{
- ConstructorMetaModel<Duck> constructor = new ComponentMetaModel<Duck>(new ClassAnnotatedItem(Duck.class), emptyAnnotatedItem, container).getConstructor();
+ SimpleConstructor<Duck> constructor = new SimpleComponentModel<Duck>(new ClassAnnotatedItem(Duck.class), emptyAnnotatedItem, container).getConstructor();
assert constructor.getConstructor().getDeclaringClass().equals(Duck.class);
assert constructor.getConstructor().getParameterTypes().length == 2;
assert constructor.getConstructor().getParameterTypes()[0].equals(String.class);
@@ -101,7 +101,7 @@
boolean exception = false;
try
{
- new ComponentMetaModel<Chicken>(new ClassAnnotatedItem(Chicken.class), emptyAnnotatedItem, container);
+ new SimpleComponentModel<Chicken>(new ClassAnnotatedItem(Chicken.class), emptyAnnotatedItem, container);
}
catch (Exception e)
{
@@ -117,7 +117,7 @@
boolean exception = false;
try
{
- new ComponentMetaModel<Turkey>(new ClassAnnotatedItem(Turkey.class), emptyAnnotatedItem, container);
+ new SimpleComponentModel<Turkey>(new ClassAnnotatedItem(Turkey.class), emptyAnnotatedItem, container);
}
catch (Exception e)
{
@@ -133,7 +133,7 @@
boolean exception = false;
try
{
- new ComponentMetaModel<Goat>(new ClassAnnotatedItem(Goat.class), emptyAnnotatedItem, container);
+ new SimpleComponentModel<Goat>(new ClassAnnotatedItem(Goat.class), emptyAnnotatedItem, container);
}
catch (Exception e)
{
@@ -149,7 +149,7 @@
boolean exception = false;
try
{
- new ComponentMetaModel<Goose>(new ClassAnnotatedItem(Goose.class), emptyAnnotatedItem, container);
+ new SimpleComponentModel<Goose>(new ClassAnnotatedItem(Goose.class), emptyAnnotatedItem, container);
}
catch (Exception e)
{
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/EnterpriseComponentModelTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/EnterpriseComponentModelTest.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/EnterpriseComponentModelTest.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -0,0 +1,188 @@
+package org.jboss.webbeans.test;
+
+import static org.jboss.webbeans.test.util.Util.annotationSetMatches;
+
+import java.lang.annotation.Annotation;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.webbeans.Current;
+import javax.webbeans.Dependent;
+
+import org.jboss.webbeans.ContainerImpl;
+import org.jboss.webbeans.model.EnterpriseComponentModel;
+import org.jboss.webbeans.test.annotations.Synchronous;
+import org.jboss.webbeans.test.components.Bear;
+import org.jboss.webbeans.test.components.Cheetah;
+import org.jboss.webbeans.test.components.Cougar;
+import org.jboss.webbeans.test.components.Elephant;
+import org.jboss.webbeans.test.components.Giraffe;
+import org.jboss.webbeans.test.components.Leopard;
+import org.jboss.webbeans.test.components.Lion;
+import org.jboss.webbeans.test.components.Panther;
+import org.jboss.webbeans.test.components.Puma;
+import org.jboss.webbeans.test.components.Tiger;
+import org.jboss.webbeans.test.mock.MockContainerImpl;
+import org.jboss.webbeans.util.AnnotatedItem;
+import org.jboss.webbeans.util.ClassAnnotatedItem;
+import org.jboss.webbeans.util.MutableAnnotatedItem;
+import org.junit.Before;
+import org.junit.Test;
+
+public class EnterpriseComponentModelTest
+{
+
+private ContainerImpl container;
+
+ private AnnotatedItem emptyAnnotatedItem;
+
+ @Before
+ public void before()
+ {
+ emptyAnnotatedItem = new MutableAnnotatedItem(null, new HashMap<Class<? extends Annotation>, Annotation>());
+ container = new MockContainerImpl(null);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testStateless()
+ {
+ EnterpriseComponentModel<Lion> lion = new EnterpriseComponentModel<Lion>(new ClassAnnotatedItem(Lion.class), emptyAnnotatedItem, container);
+ assert lion.getScopeType().annotationType().equals(Dependent.class);
+ annotationSetMatches(lion.getBindingTypes(), Current.class);
+ assert lion.getName().equals("lion");
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testStatelessDefinedInXml()
+ {
+ Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+ AnnotatedItem annotatedItem = new MutableAnnotatedItem(Giraffe.class, annotations);
+
+ EnterpriseComponentModel<Giraffe> giraffe = new EnterpriseComponentModel<Giraffe>(new ClassAnnotatedItem(Giraffe.class), annotatedItem, container);
+ assert giraffe.getScopeType().annotationType().equals(Dependent.class);
+ annotationSetMatches(giraffe.getBindingTypes(), Current.class);
+ }
+
+ @Test
+ public void testStatelessWithRequestScope()
+ {
+ boolean exception = false;
+ try
+ {
+ new EnterpriseComponentModel<Bear>(new ClassAnnotatedItem(Bear.class), emptyAnnotatedItem, container);
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+ }
+
+ // TODO Need EJB3.1 @Test
+ public void testSingleton()
+ {
+ //ComponentMetaModel<Lion> lion = new ComponentMetaModel<Lion>(new ClassAnnotatedItem(Lion.class), emptyAnnotatedItem, container);
+ //assert lion.getComponentType().equals(ComponentType.ENTERPRISE);
+ //assert lion.getScopeType().annotationType().equals(ApplicationScoped.class);
+ }
+
+ // TODO Need EJB3.1 @Test
+ public void testSingletonWithRequestScope()
+ {
+ //ComponentMetaModel<Lion> lion = new ComponentMetaModel<Lion>(new ClassAnnotatedItem(Lion.class), emptyAnnotatedItem, container);
+ //assert lion.getComponentType().equals(ComponentType.ENTERPRISE);
+ //assert lion.getScopeType().annotationType().equals(ApplicationScoped.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testStateful()
+ {
+
+ EnterpriseComponentModel<Tiger> tiger = new EnterpriseComponentModel<Tiger>(new ClassAnnotatedItem(Tiger.class), emptyAnnotatedItem, container);
+ annotationSetMatches(tiger.getBindingTypes(), Synchronous.class);
+ assert tiger.getRemoveMethod().getMethod().getName().equals("remove");
+ assert tiger.getName() == null;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testMultipleRemoveMethodsWithDestroys()
+ {
+
+ EnterpriseComponentModel<Elephant> elephant = new EnterpriseComponentModel<Elephant>(new ClassAnnotatedItem(Elephant.class), emptyAnnotatedItem, container);
+ assert elephant.getRemoveMethod().getMethod().getName().equals("remove2");
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testMultipleRemoveMethodsWithoutDestroys()
+ {
+ boolean exception = false;
+ try
+ {
+ new EnterpriseComponentModel<Puma>(new ClassAnnotatedItem(Puma.class), emptyAnnotatedItem, container);
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testMultipleRemoveMethodsWithMultipleDestroys()
+ {
+ boolean exception = false;
+ try
+ {
+ new EnterpriseComponentModel<Cougar>(new ClassAnnotatedItem(Cougar.class), emptyAnnotatedItem, container);
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testNonStatefulEnterpriseComponentWithDestroys()
+ {
+ boolean exception = false;
+ try
+ {
+ new EnterpriseComponentModel<Cheetah>(new ClassAnnotatedItem(Cheetah.class), emptyAnnotatedItem, container);
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+ }
+
+ @Test
+ public void testRemoveMethodWithDefaultBinding()
+ {
+
+ EnterpriseComponentModel<Panther> panther = new EnterpriseComponentModel<Panther>(new ClassAnnotatedItem(Panther.class), emptyAnnotatedItem, container);
+
+ assert panther.getRemoveMethod().getMethod().getName().equals("remove");
+ assert panther.getRemoveMethod().getParameters().size() == 1;
+ assert panther.getRemoveMethod().getParameters().get(0).getType().equals(String.class);
+ assert panther.getRemoveMethod().getParameters().get(0).getBindingTypes().length == 1;
+ assert panther.getRemoveMethod().getParameters().get(0).getBindingTypes()[0].annotationType().equals(Current.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testMessageDriven()
+ {
+ EnterpriseComponentModel<Leopard> leopard = new EnterpriseComponentModel<Leopard>(new ClassAnnotatedItem(Leopard.class), emptyAnnotatedItem, container);
+ annotationSetMatches(leopard.getBindingTypes(), Current.class);
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/EnterpriseComponentModelTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/StereotypeMetaModelTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/StereotypeMetaModelTest.java 2008-07-03 15:16:06 UTC (rev 39)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/StereotypeMetaModelTest.java 2008-07-03 17:42:40 UTC (rev 40)
@@ -7,7 +7,7 @@
import javax.webbeans.Production;
import javax.webbeans.RequestScoped;
-import org.jboss.webbeans.StereotypeMetaModel;
+import org.jboss.webbeans.model.StereotypeModel;
import org.jboss.webbeans.test.annotations.AnimalOrderStereotype;
import org.jboss.webbeans.test.annotations.AnimalStereotype;
import org.jboss.webbeans.test.annotations.RequestScopedAnimalStereotype;
@@ -26,7 +26,7 @@
@Test
public void testComponentStereotype()
{
- StereotypeMetaModel componentStereotype = new StereotypeMetaModel(new ClassAnnotatedItem(Component.class));
+ StereotypeModel componentStereotype = new StereotypeModel(new ClassAnnotatedItem(Component.class));
assert Production.class.equals(componentStereotype.getDefaultDeploymentType().annotationType());
assert componentStereotype.getDefaultScopeType() == null;
@@ -39,7 +39,7 @@
@Test
public void testModelStereotype()
{
- StereotypeMetaModel modelStereotype = new StereotypeMetaModel(new ClassAnnotatedItem(Model.class));
+ StereotypeModel modelStereotype = new StereotypeModel(new ClassAnnotatedItem(Model.class));
assert Production.class.equals(modelStereotype.getDefaultDeploymentType().annotationType());
assert RequestScoped.class.equals(modelStereotype.getDefaultScopeType().annotationType());
assert modelStereotype.isComponentNameDefaulted();
@@ -51,7 +51,7 @@
@Test
public void testAnimalStereotype()
{
- StereotypeMetaModel animalStereotype = new StereotypeMetaModel(new ClassAnnotatedItem(AnimalStereotype.class));
+ StereotypeModel animalStereotype = new StereotypeModel(new ClassAnnotatedItem(AnimalStereotype.class));
assert animalStereotype.getDefaultScopeType().annotationType().equals(RequestScoped.class);
assert animalStereotype.getInterceptorBindings().size() == 0;
assert animalStereotype.getRequiredTypes().size() == 1;
@@ -64,7 +64,7 @@
@Test
public void testAnimalOrderStereotype()
{
- StereotypeMetaModel animalStereotype = new StereotypeMetaModel(new ClassAnnotatedItem(AnimalOrderStereotype.class));
+ StereotypeModel animalStereotype = new StereotypeModel(new ClassAnnotatedItem(AnimalOrderStereotype.class));
assert animalStereotype.getDefaultScopeType() == null;
assert animalStereotype.getInterceptorBindings().size() == 0;
assert animalStereotype.getRequiredTypes().size() == 2;
@@ -78,7 +78,7 @@
@Test
public void testRequestScopedAnimalStereotype()
{
- StereotypeMetaModel animalStereotype = new StereotypeMetaModel(new ClassAnnotatedItem(RequestScopedAnimalStereotype.class));
+ StereotypeModel animalStereotype = new StereotypeModel(new ClassAnnotatedItem(RequestScopedAnimalStereotype.class));
assert animalStereotype.getDefaultScopeType() == null;
assert animalStereotype.getInterceptorBindings().size() == 0;
assert animalStereotype.getRequiredTypes().size() == 1;
@@ -95,7 +95,7 @@
boolean exception = false;
try
{
- new StereotypeMetaModel(new ClassAnnotatedItem(StereotypeWithTooManyScopeTypes.class));
+ new StereotypeModel(new ClassAnnotatedItem(StereotypeWithTooManyScopeTypes.class));
}
catch (Exception e)
{
@@ -110,7 +110,7 @@
boolean exception = false;
try
{
- new StereotypeMetaModel(new ClassAnnotatedItem(StereotypeWithTooManyDeploymentTypes.class));
+ new StereotypeModel(new ClassAnnotatedItem(StereotypeWithTooManyDeploymentTypes.class));
}
catch (Exception e)
{
@@ -125,7 +125,7 @@
boolean exception = false;
try
{
- new StereotypeMetaModel(new ClassAnnotatedItem(StereotypeWithNonEmptyNamed.class));
+ new StereotypeModel(new ClassAnnotatedItem(StereotypeWithNonEmptyNamed.class));
}
catch (Exception e)
{
@@ -140,7 +140,7 @@
boolean exception = false;
try
{
- new StereotypeMetaModel(new ClassAnnotatedItem(StereotypeWithBindingTypes.class));
+ new StereotypeModel(new ClassAnnotatedItem(StereotypeWithBindingTypes.class));
}
catch (Exception e)
{
15 years, 10 months
[webbeans-commits] Webbeans SVN: r39 - in ri/trunk/webbeans-impl: src/main/java/org/jboss/webbeans and 3 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-07-03 11:16:06 -0400 (Thu, 03 Jul 2008)
New Revision: 39
Added:
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/EjbMetaDataTest.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Bear.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Cheetah.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Cougar.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Elephant.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Giraffe.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Leopard.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Lion.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Panther.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Puma.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Tiger.java
Modified:
ri/trunk/webbeans-impl/pom.xml
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentMetaModel.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/MethodMetaModel.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentMetaModelTest.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ConstructorMetaModelTest.java
Log:
Tests for enterprise bean support
Modified: ri/trunk/webbeans-impl/pom.xml
===================================================================
--- ri/trunk/webbeans-impl/pom.xml 2008-07-03 13:02:30 UTC (rev 38)
+++ ri/trunk/webbeans-impl/pom.xml 2008-07-03 15:16:06 UTC (rev 39)
@@ -23,6 +23,12 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>javax.ejb</groupId>
+ <artifactId>ejb-api</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
Modified: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentMetaModel.java 2008-07-03 13:02:30 UTC (rev 38)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentMetaModel.java 2008-07-03 15:16:06 UTC (rev 39)
@@ -467,7 +467,7 @@
}
if ("".equals(name) && (componentNameDefaulted || stereotypes.isComponentNameDefaulted()))
{
- if (ComponentType.SIMPLE.equals(componentType))
+ if (ComponentType.SIMPLE.equals(componentType) || ComponentType.ENTERPRISE.equals(componentType))
{
name = Strings.decapitalize(type.getSimpleName());
}
Modified: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/MethodMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/MethodMetaModel.java 2008-07-03 13:02:30 UTC (rev 38)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/MethodMetaModel.java 2008-07-03 15:16:06 UTC (rev 39)
@@ -28,4 +28,10 @@
}
}
+ public Method getMethod()
+ {
+ return method;
+ }
+
+
}
Modified: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentMetaModelTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentMetaModelTest.java 2008-07-03 13:02:30 UTC (rev 38)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentMetaModelTest.java 2008-07-03 15:16:06 UTC (rev 39)
@@ -45,20 +45,30 @@
import org.jboss.webbeans.test.bindings.RiverFishStereotypeBinding;
import org.jboss.webbeans.test.bindings.SynchronousBinding;
import org.jboss.webbeans.test.components.Antelope;
+import org.jboss.webbeans.test.components.Bear;
import org.jboss.webbeans.test.components.Carp;
import org.jboss.webbeans.test.components.Cat;
import org.jboss.webbeans.test.components.Chair;
+import org.jboss.webbeans.test.components.Cheetah;
import org.jboss.webbeans.test.components.ComponentWithTooManyDeploymentTypes;
import org.jboss.webbeans.test.components.ComponentWithTooManyScopeTypes;
+import org.jboss.webbeans.test.components.Cougar;
import org.jboss.webbeans.test.components.Cow;
+import org.jboss.webbeans.test.components.Elephant;
+import org.jboss.webbeans.test.components.Giraffe;
import org.jboss.webbeans.test.components.Goldfish;
import org.jboss.webbeans.test.components.Gorilla;
import org.jboss.webbeans.test.components.Haddock;
import org.jboss.webbeans.test.components.Horse;
+import org.jboss.webbeans.test.components.Leopard;
+import org.jboss.webbeans.test.components.Lion;
import org.jboss.webbeans.test.components.Moose;
import org.jboss.webbeans.test.components.Order;
+import org.jboss.webbeans.test.components.Panther;
import org.jboss.webbeans.test.components.Pig;
+import org.jboss.webbeans.test.components.Puma;
import org.jboss.webbeans.test.components.SeaBass;
+import org.jboss.webbeans.test.components.Tiger;
import org.jboss.webbeans.test.components.Tuna;
import org.jboss.webbeans.test.mock.MockContainerImpl;
import org.jboss.webbeans.util.AnnotatedItem;
@@ -566,4 +576,152 @@
}
}
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testStateless()
+ {
+ ComponentMetaModel<Lion> lion = new ComponentMetaModel<Lion>(new ClassAnnotatedItem(Lion.class), emptyAnnotatedItem, container);
+ assert lion.getComponentType().equals(ComponentType.ENTERPRISE);
+ assert lion.getScopeType().annotationType().equals(Dependent.class);
+ annotationSetMatches(lion.getBindingTypes(), Current.class);
+ assert lion.getName().equals("lion");
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testStatelessDefinedInXml()
+ {
+ Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+ AnnotatedItem annotatedItem = new MutableAnnotatedItem(Giraffe.class, annotations);
+
+ ComponentMetaModel<Giraffe> giraffe = new ComponentMetaModel<Giraffe>(new ClassAnnotatedItem(Giraffe.class), annotatedItem, container);
+ assert giraffe.getComponentType().equals(ComponentType.ENTERPRISE);
+ assert giraffe.getScopeType().annotationType().equals(Dependent.class);
+ annotationSetMatches(giraffe.getBindingTypes(), Current.class);
+ }
+
+ @Test
+ public void testStatelessWithRequestScope()
+ {
+ boolean exception = false;
+ try
+ {
+ new ComponentMetaModel<Bear>(new ClassAnnotatedItem(Bear.class), emptyAnnotatedItem, container);
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+ }
+
+ // TODO Need EJB3.1 @Test
+ public void testSingleton()
+ {
+ //ComponentMetaModel<Lion> lion = new ComponentMetaModel<Lion>(new ClassAnnotatedItem(Lion.class), emptyAnnotatedItem, container);
+ //assert lion.getComponentType().equals(ComponentType.ENTERPRISE);
+ //assert lion.getScopeType().annotationType().equals(ApplicationScoped.class);
+ }
+
+ // TODO Need EJB3.1 @Test
+ public void testSingletonWithRequestScope()
+ {
+ //ComponentMetaModel<Lion> lion = new ComponentMetaModel<Lion>(new ClassAnnotatedItem(Lion.class), emptyAnnotatedItem, container);
+ //assert lion.getComponentType().equals(ComponentType.ENTERPRISE);
+ //assert lion.getScopeType().annotationType().equals(ApplicationScoped.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testStateful()
+ {
+
+ ComponentMetaModel<Tiger> tiger = new ComponentMetaModel<Tiger>(new ClassAnnotatedItem(Tiger.class), emptyAnnotatedItem, container);
+ assert tiger.getComponentType().equals(ComponentType.ENTERPRISE);
+ annotationSetMatches(tiger.getBindingTypes(), Synchronous.class);
+ assert tiger.getRemoveMethod().getMethod().getName().equals("remove");
+ assert tiger.getName() == null;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testMultipleRemoveMethodsWithDestroys()
+ {
+
+ ComponentMetaModel<Elephant> elephant = new ComponentMetaModel<Elephant>(new ClassAnnotatedItem(Elephant.class), emptyAnnotatedItem, container);
+ assert elephant.getComponentType().equals(ComponentType.ENTERPRISE);
+ assert elephant.getRemoveMethod().getMethod().getName().equals("remove2");
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testMultipleRemoveMethodsWithoutDestroys()
+ {
+ boolean exception = false;
+ try
+ {
+ new ComponentMetaModel<Puma>(new ClassAnnotatedItem(Puma.class), emptyAnnotatedItem, container);
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testMultipleRemoveMethodsWithMultipleDestroys()
+ {
+ boolean exception = false;
+ try
+ {
+ new ComponentMetaModel<Cougar>(new ClassAnnotatedItem(Cougar.class), emptyAnnotatedItem, container);
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testNonStatefulEnterpriseComponentWithDestroys()
+ {
+ boolean exception = false;
+ try
+ {
+ new ComponentMetaModel<Cheetah>(new ClassAnnotatedItem(Cheetah.class), emptyAnnotatedItem, container);
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+ }
+
+ @Test
+ public void testRemoveMethodWithDefaultBinding()
+ {
+
+ ComponentMetaModel<Panther> panther = new ComponentMetaModel<Panther>(new ClassAnnotatedItem(Panther.class), emptyAnnotatedItem, container);
+ assert panther.getComponentType().equals(ComponentType.ENTERPRISE);
+ assert panther.getRemoveMethod().getMethod().getName().equals("remove");
+ assert panther.getRemoveMethod().getParameters().size() == 1;
+ assert panther.getRemoveMethod().getParameters().get(0).getType().equals(String.class);
+ assert panther.getRemoveMethod().getParameters().get(0).getBindingTypes().length == 1;
+ assert panther.getRemoveMethod().getParameters().get(0).getBindingTypes()[0].annotationType().equals(Current.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testMessageDriven()
+ {
+ ComponentMetaModel<Leopard> leopard = new ComponentMetaModel<Leopard>(new ClassAnnotatedItem(Leopard.class), emptyAnnotatedItem, container);
+ assert leopard.getComponentType().equals(ComponentType.ENTERPRISE);
+ annotationSetMatches(leopard.getBindingTypes(), Current.class);
+ }
+
+
}
Modified: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ConstructorMetaModelTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ConstructorMetaModelTest.java 2008-07-03 13:02:30 UTC (rev 38)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ConstructorMetaModelTest.java 2008-07-03 15:16:06 UTC (rev 39)
@@ -1,19 +1,14 @@
package org.jboss.webbeans.test;
import java.lang.annotation.Annotation;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
import javax.webbeans.Current;
import org.jboss.webbeans.ComponentMetaModel;
import org.jboss.webbeans.ContainerImpl;
-import org.jboss.webbeans.bindings.StandardBinding;
import org.jboss.webbeans.injectable.ConstructorMetaModel;
import org.jboss.webbeans.test.annotations.Synchronous;
-import org.jboss.webbeans.test.bindings.AnotherDeploymentTypeBinding;
-import org.jboss.webbeans.test.bindings.HornedAnimalDeploymentTypeBinding;
import org.jboss.webbeans.test.components.Chicken;
import org.jboss.webbeans.test.components.Donkey;
import org.jboss.webbeans.test.components.Duck;
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/EjbMetaDataTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/EjbMetaDataTest.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/EjbMetaDataTest.java 2008-07-03 15:16:06 UTC (rev 39)
@@ -0,0 +1,36 @@
+package org.jboss.webbeans.test;
+
+import org.jboss.webbeans.ejb.EjbMetaData;
+import org.jboss.webbeans.test.components.Leopard;
+import org.jboss.webbeans.test.components.Lion;
+import org.jboss.webbeans.test.components.Tiger;
+import org.junit.Test;
+
+public class EjbMetaDataTest
+{
+
+ @Test
+ public void testStateless()
+ {
+ EjbMetaData<Lion> lion = new EjbMetaData<Lion>(Lion.class);
+ assert lion.isStateless();
+ assert lion.getRemoveMethods() == null;
+ }
+
+ @Test
+ public void testStateful()
+ {
+ EjbMetaData<Tiger> tiger = new EjbMetaData<Tiger>(Tiger.class);
+ assert tiger.isStateful();
+ assert tiger.getRemoveMethods().size() == 1;
+ }
+
+ @Test
+ public void testMessageDriven()
+ {
+ EjbMetaData<Leopard> leopard = new EjbMetaData<Leopard>(Leopard.class);
+ assert leopard.isMessageDriven();
+ assert leopard.getRemoveMethods() == null;
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/EjbMetaDataTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Bear.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Bear.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Bear.java 2008-07-03 15:16:06 UTC (rev 39)
@@ -0,0 +1,13 @@
+package org.jboss.webbeans.test.components;
+
+import javax.ejb.Stateless;
+import javax.webbeans.Production;
+import javax.webbeans.RequestScoped;
+
+@Production
+@RequestScoped
+@Stateless
+public class Bear
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Bear.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Cheetah.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Cheetah.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Cheetah.java 2008-07-03 15:16:06 UTC (rev 39)
@@ -0,0 +1,18 @@
+package org.jboss.webbeans.test.components;
+
+import javax.ejb.Remove;
+import javax.webbeans.Destroys;
+import javax.webbeans.Production;
+
+@Production
+public class Cheetah
+{
+
+ @Remove @Destroys
+ public void remove()
+ {
+
+ }
+
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Cheetah.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Cougar.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Cougar.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Cougar.java 2008-07-03 15:16:06 UTC (rev 39)
@@ -0,0 +1,31 @@
+package org.jboss.webbeans.test.components;
+
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.webbeans.Destroys;
+import javax.webbeans.Production;
+
+@Production
+@Stateful
+public class Cougar
+{
+
+ @Remove
+ public void remove()
+ {
+
+ }
+
+ @Remove @Destroys
+ public void remove1()
+ {
+
+ }
+
+ @Remove @Destroys
+ public void remove2()
+ {
+
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Cougar.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Elephant.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Elephant.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Elephant.java 2008-07-03 15:16:06 UTC (rev 39)
@@ -0,0 +1,25 @@
+package org.jboss.webbeans.test.components;
+
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.webbeans.Destroys;
+import javax.webbeans.Production;
+
+@Production
+@Stateful
+public class Elephant
+{
+
+ @Remove
+ public void remove1()
+ {
+
+ }
+
+ @Remove @Destroys
+ public void remove2()
+ {
+
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Elephant.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Giraffe.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Giraffe.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Giraffe.java 2008-07-03 15:16:06 UTC (rev 39)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans.test.components;
+
+import javax.ejb.Stateless;
+
+@Stateless
+public class Giraffe
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Giraffe.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Leopard.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Leopard.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Leopard.java 2008-07-03 15:16:06 UTC (rev 39)
@@ -0,0 +1,11 @@
+package org.jboss.webbeans.test.components;
+
+import javax.ejb.MessageDriven;
+import javax.webbeans.Production;
+
+@Production
+@MessageDriven
+public class Leopard
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Leopard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Lion.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Lion.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Lion.java 2008-07-03 15:16:06 UTC (rev 39)
@@ -0,0 +1,13 @@
+package org.jboss.webbeans.test.components;
+
+import javax.ejb.Stateless;
+import javax.webbeans.Named;
+import javax.webbeans.Production;
+
+@Production
+@Stateless
+@Named
+public class Lion
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Lion.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Panther.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Panther.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Panther.java 2008-07-03 15:16:06 UTC (rev 39)
@@ -0,0 +1,18 @@
+package org.jboss.webbeans.test.components;
+
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.webbeans.Production;
+
+@Production
+@Stateful
+public class Panther
+{
+
+ @Remove
+ public void remove(String foo)
+ {
+
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Panther.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Puma.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Puma.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Puma.java 2008-07-03 15:16:06 UTC (rev 39)
@@ -0,0 +1,21 @@
+package org.jboss.webbeans.test.components;
+
+import javax.ejb.Stateful;
+import javax.webbeans.Production;
+
+@Stateful
+@Production
+public class Puma
+{
+
+ public void remove1()
+ {
+
+ }
+
+ public void remove2()
+ {
+
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Puma.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Tiger.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Tiger.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Tiger.java 2008-07-03 15:16:06 UTC (rev 39)
@@ -0,0 +1,21 @@
+package org.jboss.webbeans.test.components;
+
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.webbeans.Production;
+
+import org.jboss.webbeans.test.annotations.Synchronous;
+
+@Production
+@Stateful
+@Synchronous
+public class Tiger
+{
+
+ @Remove
+ public void remove()
+ {
+
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Tiger.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 10 months
[webbeans-commits] Webbeans SVN: r38 - in ri/trunk/webbeans-impl/src: main/java/org/jboss/webbeans/ejb and 3 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-07-03 09:02:30 -0400 (Thu, 03 Jul 2008)
New Revision: 38
Added:
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentMetaModel.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ConstructorMetaModel.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ElementMetaModel.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/MethodMetaModel.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ParameterMetaModel.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/UnitMetaModel.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentMetaModelTest.java
Removed:
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/AbstractInjectedThingMetaModel.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ConstructorMetaModel.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/InjectedParameterMetaModel.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentInstanceTest.java
Modified:
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ejb/EJB.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ejb/EjbMetaData.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ConstructorMetaModelTest.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Goose.java
Log:
Refactor component meta model
Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/AbstractInjectedThingMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/AbstractInjectedThingMetaModel.java 2008-07-03 01:55:49 UTC (rev 37)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/AbstractInjectedThingMetaModel.java 2008-07-03 13:02:30 UTC (rev 38)
@@ -1,33 +0,0 @@
-package org.jboss.webbeans;
-
-import java.lang.annotation.Annotation;
-
-public abstract class AbstractInjectedThingMetaModel
-{
-
- private Annotation[] bindingTypes;
-
- public AbstractInjectedThingMetaModel(Annotation[] bindingTypes)
- {
- this.bindingTypes = bindingTypes;
- }
-
- public AbstractInjectedThingMetaModel()
- {
- this.bindingTypes = new Annotation[0];
- }
-
- public Annotation[] getBindingTypes()
- {
- return bindingTypes;
- }
-
- public abstract Class<?> getType();
-
- @Override
- public String toString()
- {
- return getType() + " with binding types " + getBindingTypes();
- }
-
-}
Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java 2008-07-03 01:55:49 UTC (rev 37)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java 2008-07-03 13:02:30 UTC (rev 38)
@@ -1,422 +0,0 @@
-package org.jboss.webbeans;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Logger;
-
-import javax.webbeans.BindingType;
-import javax.webbeans.ComponentInstance;
-import javax.webbeans.Container;
-import javax.webbeans.Dependent;
-import javax.webbeans.DeploymentType;
-import javax.webbeans.Named;
-import javax.webbeans.ScopeType;
-
-import org.jboss.webbeans.bindings.CurrentBinding;
-import org.jboss.webbeans.bindings.DependentBinding;
-import org.jboss.webbeans.bindings.ProductionBinding;
-import org.jboss.webbeans.ejb.EJB;
-import org.jboss.webbeans.util.AnnotatedItem;
-import org.jboss.webbeans.util.LoggerUtil;
-import org.jboss.webbeans.util.Reflections;
-import org.jboss.webbeans.util.Strings;
-
-/**
- * Web Beans Component meta model
- *
- * @author Pete Muir
- *
- */
-public class ComponentInstanceImpl<T> extends ComponentInstance<T>
-{
-
- public enum ComponentType
- {
- SIMPLE,
- EJB_SESSION
- ;
- }
-
- public static final String LOGGER_NAME = "componentInstance";
-
- private static Logger log = LoggerUtil.getLogger(LOGGER_NAME);
-
- private Class<? extends T> type;
- private Set<Annotation> bindingTypes;
- private Annotation deploymentType;
- private String name;
- private Annotation scopeType;
- private ComponentType componentType;
- private ConstructorMetaModel<T> constructor;
- /**
- *
- * @param annotatedItem Annotations read from java classes
- * @param xmlAnnotatedItem Annotations read from XML
- * @param container
- */
- @SuppressWarnings("unchecked")
- public ComponentInstanceImpl(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
- {
- if (annotatedItem == null)
- {
- throw new NullPointerException("annotatedItem must not be null. If the component is declared just in XML, pass in an empty annotatedItem");
- }
-
- if (xmlAnnotatedItem == null)
- {
- 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.componentType = initComponentType(type);
- checkComponentImplementation(componentType, type);
- this.constructor = new ConstructorMetaModel<T>(type);
- MergedComponentStereotypes stereotypes = new MergedComponentStereotypes(annotatedItem, xmlAnnotatedItem, container);
- this.bindingTypes = initBindingTypes(annotatedItem, xmlAnnotatedItem);
- this.deploymentType = initDeploymentType(stereotypes, annotatedItem, xmlAnnotatedItem, container);
- this.scopeType = initScopeType(stereotypes, annotatedItem, xmlAnnotatedItem);
- this.name = initName(stereotypes, annotatedItem, xmlAnnotatedItem, componentType, type);
- checkRequiredTypesImplemented(stereotypes, type);
- checkScopeAllowed(stereotypes, scopeType, type);
- // TODO Interceptors
- }
-
- /*
- * A series of static methods which implement the algorithms defined in the Web Beans spec for component meta data
- */
-
- protected static ComponentType initComponentType(Class<?> type)
- {
- if (EJB.isStatefulEjbComponent(type) || EJB.isStatelessEjbComponent(type))
- {
- return ComponentType.EJB_SESSION;
- }
- else
- {
- return ComponentType.SIMPLE;
- }
- }
-
- protected static void checkComponentImplementation(ComponentType componentType, Class<?> type)
- {
- switch (componentType)
- {
- case SIMPLE:
- checkSimpleComponentImplementation(type);
- break;
- }
- }
-
- protected static void checkSimpleComponentImplementation(Class<?> type)
- {
- if (Reflections.isAbstract(type))
- {
- throw new RuntimeException("Web Bean implementation class " + type + " cannot be declared abstract");
- }
- }
-
- protected static boolean isDeclaredFinal(Class<?> type)
- {
- if (Reflections.isFinal(type))
- {
- return true;
- }
- for (Method method : type.getDeclaredMethods())
- {
- if (Reflections.isFinal(method))
- {
- return true;
- }
- }
- return false;
- }
-
- @SuppressWarnings("unchecked")
- protected static Class<?> initType(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem)
- {
- if (annotatedItem.getAnnotatedClass() != null && xmlAnnotatedItem.getAnnotatedClass() != null && !annotatedItem.getAnnotatedClass().equals(xmlAnnotatedItem.getAnnotatedClass()))
- {
- throw new IllegalArgumentException("Cannot build a component which specifies different classes in XML and Java");
- }
- else if (xmlAnnotatedItem.getAnnotatedClass() != null)
- {
- log.finest("Component type specified in XML");
- return xmlAnnotatedItem.getAnnotatedClass();
- }
- else if (annotatedItem.getAnnotatedClass() != null)
- {
- log.finest("Component type specified in Java");
- return annotatedItem.getAnnotatedClass();
- }
- else
- {
- throw new IllegalArgumentException("Cannot build a component which doesn't specify a type");
- }
- }
-
- /**
- * Check that the scope type is allowed by the stereotypes on the component and the component type
- * @param type
- */
- protected static void checkScopeAllowed(MergedComponentStereotypes stereotypes, Annotation scopeType, Class<?> type)
- {
- log.finest("Checking if " + scopeType + " is allowed");
- if (stereotypes.getSupportedScopes().size() > 0)
- {
- if (!stereotypes.getSupportedScopes().contains(scopeType.annotationType()))
- {
- throw new RuntimeException("Scope " + scopeType + " is not an allowed by the component's stereotype");
- }
- }
- if (isDeclaredFinal(type) && !scopeType.annotationType().equals(Dependent.class))
- {
- throw new RuntimeException("Scope " + scopeType + " is not allowed as the component is declared final or has methods declared final");
- }
- }
-
- /**
- * Check that the types required by the stereotypes on the component are implemented
- */
- protected static void checkRequiredTypesImplemented(MergedComponentStereotypes stereotypes, Class<?> type)
- {
- for (Class<?> requiredType : stereotypes.getRequiredTypes())
- {
- log.finest("Checking if required type " + requiredType + " is implemented");
- if (!requiredType.isAssignableFrom(type))
- {
- throw new RuntimeException("Required type " + requiredType + " isn't implement on " + type);
- }
- }
- }
-
- /**
- * Return the scope of the component
- */
- protected static Annotation initScopeType(MergedComponentStereotypes 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();
- }
-
- protected static Annotation initDeploymentType(MergedComponentStereotypes stereotypes, AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
- {
- 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)");
- }
- 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");
- }
-
- protected static Set<Annotation> initBindingTypes(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem)
- {
- Set<Annotation> xmlBindingTypes = xmlAnnotatedItem.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;
- }
-
- Set<Annotation> bindingTypes = annotatedItem.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");
- }
- return bindingTypes;
- }
-
- protected static String initName(MergedComponentStereotypes stereotypes, AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ComponentType componentType, 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()))
- {
- if (ComponentType.SIMPLE.equals(componentType))
- {
- name = Strings.decapitalize(type.getSimpleName());
- }
- log.finest("Default name of " + type + " is " + name );
- }
- return name;
- }
-
- 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;
- }
-
- @Override
- public T create(Container container)
- {
- return null;
- }
-
- @Override
- public void destroy(Container container, Object instance)
- {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public Set<Annotation> getBindingTypes()
- {
- return bindingTypes;
- }
-
- @Override
- public Annotation getDeploymentType()
- {
- return deploymentType;
- }
-
- @Override
- public String getName()
- {
- return name;
- }
-
- @Override
- public Set<Class> getTypes()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Annotation getScopeType()
- {
- return scopeType;
- }
-
- public ConstructorMetaModel<T> getConstructor()
- {
- return constructor;
- }
-
- public ComponentType getComponentType()
- {
- return componentType;
- }
-
-}
Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java 2008-07-03 13:02:30 UTC (rev 38)
@@ -0,0 +1,70 @@
+package org.jboss.webbeans;
+
+import java.lang.annotation.Annotation;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import javax.webbeans.ComponentInstance;
+import javax.webbeans.Container;
+
+import org.jboss.webbeans.util.LoggerUtil;
+
+public class ComponentInstanceImpl<T> extends ComponentInstance<T>
+{
+
+public static final String LOGGER_NAME = "componentMetaModel";
+
+ private static Logger log = LoggerUtil.getLogger(LOGGER_NAME);
+
+ private ComponentMetaModel<T> componentMetaModel;
+
+ public ComponentInstanceImpl(ComponentMetaModel<T> componentMetaModel)
+ {
+ this.componentMetaModel = componentMetaModel;
+ }
+
+ @Override
+ public T create(Container container)
+ {
+ return componentMetaModel.getConstructor().invoke(container);
+ }
+
+ @Override
+ public void destroy(Container container, T instance)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Set<Annotation> getBindingTypes()
+ {
+ return componentMetaModel.getBindingTypes();
+ }
+
+ @Override
+ public Annotation getDeploymentType()
+ {
+ return componentMetaModel.getDeploymentType();
+ }
+
+ @Override
+ public String getName()
+ {
+ return componentMetaModel.getName();
+ }
+
+ @Override
+ public Annotation getScopeType()
+ {
+ return componentMetaModel.getScopeType();
+ }
+
+ @Override
+ public Set<Class> getTypes()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentMetaModel.java (from rev 34, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentMetaModel.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentMetaModel.java 2008-07-03 13:02:30 UTC (rev 38)
@@ -0,0 +1,526 @@
+package org.jboss.webbeans;
+
+import static org.jboss.webbeans.ComponentMetaModel.ComponentType.*;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+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.ApplicationScoped;
+import javax.webbeans.BindingType;
+import javax.webbeans.Dependent;
+import javax.webbeans.DeploymentType;
+import javax.webbeans.Destroys;
+import javax.webbeans.Initializer;
+import javax.webbeans.Named;
+import javax.webbeans.ScopeType;
+
+import org.jboss.webbeans.bindings.CurrentBinding;
+import org.jboss.webbeans.bindings.DependentBinding;
+import org.jboss.webbeans.bindings.ProductionBinding;
+import org.jboss.webbeans.ejb.EJB;
+import org.jboss.webbeans.ejb.EjbMetaData;
+import org.jboss.webbeans.injectable.ConstructorMetaModel;
+import org.jboss.webbeans.injectable.MethodMetaModel;
+import org.jboss.webbeans.util.AnnotatedItem;
+import org.jboss.webbeans.util.LoggerUtil;
+import org.jboss.webbeans.util.Reflections;
+import org.jboss.webbeans.util.Strings;
+
+/**
+ * Web Beans Component meta model
+ *
+ * @author Pete Muir
+ *
+ */
+public class ComponentMetaModel<T>
+{
+
+ public enum ComponentType
+ {
+ SIMPLE,
+ ENTERPRISE;
+ }
+
+ public static final String LOGGER_NAME = "componentMetaModel";
+
+ private static Logger log = LoggerUtil.getLogger(LOGGER_NAME);
+
+ private Class<? extends T> type;
+ private Set<Annotation> bindingTypes;
+ private Annotation deploymentType;
+ private String name;
+ private Annotation scopeType;
+ private ComponentType componentType;
+ private ConstructorMetaModel<T> constructor;
+ private EjbMetaData<T> ejbMetaData;
+ private MethodMetaModel<?> removeMethod;
+ /**
+ *
+ * @param annotatedItem Annotations read from java classes
+ * @param xmlAnnotatedItem Annotations read from XML
+ * @param container
+ */
+ @SuppressWarnings("unchecked")
+ public ComponentMetaModel(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
+ {
+ if (annotatedItem == null)
+ {
+ throw new NullPointerException("annotatedItem must not be null. If the component is declared just in XML, pass in an empty annotatedItem");
+ }
+
+ if (xmlAnnotatedItem == null)
+ {
+ 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.ejbMetaData = EJB.getEjbMetaData(type);
+ this.componentType = initComponentType(type, ejbMetaData);
+ checkComponentImplementation(componentType, type);
+ this.constructor = initConstructor(type);
+ MergedComponentStereotypes stereotypes = new MergedComponentStereotypes(annotatedItem, xmlAnnotatedItem, container);
+ this.bindingTypes = initBindingTypes(annotatedItem, xmlAnnotatedItem);
+ this.deploymentType = initDeploymentType(stereotypes, annotatedItem, xmlAnnotatedItem, container);
+ this.scopeType = initScopeType(stereotypes, annotatedItem, xmlAnnotatedItem);
+ this.name = initName(stereotypes, annotatedItem, xmlAnnotatedItem, componentType, type);
+ this.removeMethod = initRemoveMethod(componentType, ejbMetaData, type);
+ checkRequiredTypesImplemented(stereotypes, type);
+ checkScopeAllowed(stereotypes, scopeType, type, componentType, ejbMetaData);
+ // TODO Interceptors
+ }
+
+ /*
+ * A series of static methods which implement the algorithms defined in the Web Beans spec for component meta data
+ */
+
+ @SuppressWarnings("unchecked")
+ protected static <T> ConstructorMetaModel<T> initConstructor(Class<? extends T> type)
+ {
+ if (type.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 ConstructorMetaModel<T>(constructor);
+ }
+
+ if (type.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);
+ if ((initializerAnnotatedConstructors.size() + bindingTypeAnnotatedConstructors.size()) > 1)
+ {
+ if (initializerAnnotatedConstructors.size() > 1)
+ {
+ throw new RuntimeException("Cannot have more than one constructor annotated with @Initializer for " + type);
+ }
+
+ else if (bindingTypeAnnotatedConstructors.size() > 1)
+ {
+ throw new RuntimeException("Cannot have more than one constructor with binding types specified on constructor parameters for " + type);
+ }
+ else
+ {
+ throw new RuntimeException("Specify a constructor either annotated with @Initializer or with parameters annotated with binding types for " + type);
+ }
+ }
+ 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 ConstructorMetaModel<T>(constructor);
+ }
+ 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 ConstructorMetaModel<T>(constructor);
+ }
+ }
+
+ if (type.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 ConstructorMetaModel<T>(constructor);
+ }
+
+ throw new RuntimeException("Cannot determine constructor to use for " + type);
+ }
+
+ protected static <T> MethodMetaModel<?> initRemoveMethod(ComponentType componentType, EjbMetaData<T> ejbMetaData, Class<? extends T> type)
+ {
+ if (componentType.equals(ENTERPRISE) && ejbMetaData.isStateful())
+ {
+ if (ejbMetaData.getRemoveMethods().size() == 1)
+ {
+ return new MethodMetaModel<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 MethodMetaModel<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 <T> ComponentType initComponentType(Class<? extends T> type, EjbMetaData<T> ejbMetaData)
+ {
+ if (ejbMetaData != null && (ejbMetaData.isMessageDriven() || ejbMetaData.isSingleton() || ejbMetaData.isStateful() || ejbMetaData.isStateless()))
+ {
+ log.finest(type + " is an enterprise bean component");
+ return ENTERPRISE;
+ }
+ else
+ {
+ log.finest(type + " is an simple component");
+ return SIMPLE;
+ }
+ }
+
+ protected static void checkComponentImplementation(ComponentType componentType, Class<?> type)
+ {
+ switch (componentType)
+ {
+ case SIMPLE:
+ checkSimpleComponentImplementation(type);
+ break;
+ }
+ }
+
+ protected static void checkSimpleComponentImplementation(Class<?> type)
+ {
+ if (Reflections.isAbstract(type))
+ {
+ throw new RuntimeException("Web Bean implementation class " + type + " cannot be declared abstract");
+ }
+ }
+
+ protected static boolean isDeclaredFinal(Class<?> type)
+ {
+ if (Reflections.isFinal(type))
+ {
+ return true;
+ }
+ for (Method method : type.getDeclaredMethods())
+ {
+ if (Reflections.isFinal(method))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected static Class<?> initType(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem)
+ {
+ if (annotatedItem.getAnnotatedClass() != null && xmlAnnotatedItem.getAnnotatedClass() != null && !annotatedItem.getAnnotatedClass().equals(xmlAnnotatedItem.getAnnotatedClass()))
+ {
+ throw new IllegalArgumentException("Cannot build a component which specifies different classes in XML and Java");
+ }
+ else if (xmlAnnotatedItem.getAnnotatedClass() != null)
+ {
+ log.finest("Component type specified in XML");
+ return xmlAnnotatedItem.getAnnotatedClass();
+ }
+ else if (annotatedItem.getAnnotatedClass() != null)
+ {
+ log.finest("Component type specified in Java");
+ return annotatedItem.getAnnotatedClass();
+ }
+ else
+ {
+ throw new IllegalArgumentException("Cannot build a component which doesn't specify a type");
+ }
+ }
+
+ /**
+ * Check that the scope type is allowed by the stereotypes on the component and the component type
+ * @param type
+ */
+ protected static void checkScopeAllowed(MergedComponentStereotypes stereotypes, Annotation scopeType, Class<?> type, ComponentType componentType, EjbMetaData ejbMetaData)
+ {
+ log.finest("Checking if " + scopeType + " is allowed for " + type);
+ if (stereotypes.getSupportedScopes().size() > 0)
+ {
+ if (!stereotypes.getSupportedScopes().contains(scopeType.annotationType()))
+ {
+ throw new RuntimeException("Scope " + scopeType + " is not an allowed by the stereotype for " + type);
+ }
+ }
+ if (isDeclaredFinal(type) && !scopeType.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");
+ }
+ if (componentType.equals(ComponentType.ENTERPRISE) && 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 (componentType.equals(ComponentType.ENTERPRISE) && 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");
+ }
+ }
+
+ /**
+ * Check that the types required by the stereotypes on the component are implemented
+ */
+ protected static void checkRequiredTypesImplemented(MergedComponentStereotypes stereotypes, Class<?> type)
+ {
+ for (Class<?> requiredType : stereotypes.getRequiredTypes())
+ {
+ log.finest("Checking if required type " + requiredType + " is implemented");
+ if (!requiredType.isAssignableFrom(type))
+ {
+ throw new RuntimeException("Required type " + requiredType + " isn't implement on " + type);
+ }
+ }
+ }
+
+ /**
+ * Return the scope of the component
+ */
+ protected static Annotation initScopeType(MergedComponentStereotypes 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();
+ }
+
+ protected static Annotation initDeploymentType(MergedComponentStereotypes stereotypes, AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
+ {
+ 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)");
+ }
+ 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");
+ }
+
+ protected static Set<Annotation> initBindingTypes(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem)
+ {
+ Set<Annotation> xmlBindingTypes = xmlAnnotatedItem.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;
+ }
+
+ Set<Annotation> bindingTypes = annotatedItem.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");
+ }
+ return bindingTypes;
+ }
+
+ protected static String initName(MergedComponentStereotypes stereotypes, AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ComponentType componentType, 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()))
+ {
+ if (ComponentType.SIMPLE.equals(componentType))
+ {
+ name = Strings.decapitalize(type.getSimpleName());
+ }
+ log.finest("Default name of " + type + " is " + name );
+ }
+ return name;
+ }
+
+ 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;
+ }
+
+ public Set<Annotation> getBindingTypes()
+ {
+ return bindingTypes;
+ }
+
+ public Annotation getDeploymentType()
+ {
+ return deploymentType;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public Annotation getScopeType()
+ {
+ return scopeType;
+ }
+
+ public ConstructorMetaModel<T> getConstructor()
+ {
+ return constructor;
+ }
+
+ public ComponentType getComponentType()
+ {
+ return componentType;
+ }
+
+ public MethodMetaModel<?> getRemoveMethod()
+ {
+ return removeMethod;
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentMetaModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ConstructorMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ConstructorMetaModel.java 2008-07-03 01:55:49 UTC (rev 37)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ConstructorMetaModel.java 2008-07-03 13:02:30 UTC (rev 38)
@@ -1,128 +0,0 @@
-package org.jboss.webbeans;
-
-import java.lang.reflect.Constructor;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.webbeans.BindingType;
-import javax.webbeans.Container;
-import javax.webbeans.Initializer;
-
-import org.jboss.webbeans.util.LoggerUtil;
-import org.jboss.webbeans.util.Reflections;
-
-public class ConstructorMetaModel<T>
-{
-
-public static final String LOGGER_NAME = "componentConstructor";
-
-
-
- private static Logger log = LoggerUtil.getLogger(LOGGER_NAME);
-
- private Constructor<T> constructor;
-
- private List<AbstractInjectedThingMetaModel> injectedParameters;
-
- @SuppressWarnings("unchecked")
- public ConstructorMetaModel(Class<? extends T> type)
- {
- this.injectedParameters = new ArrayList<AbstractInjectedThingMetaModel>();
- if (type.getConstructors().length == 1)
- {
- this.constructor = type.getConstructors()[0];
- log.finest("Exactly one constructor (" + constructor +") defined, using it as the component constructor for " + type);
- }
- else if (type.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);
- if ((initializerAnnotatedConstructors.size() + bindingTypeAnnotatedConstructors.size()) > 1)
- {
- if (initializerAnnotatedConstructors.size() > 1)
- {
- throw new RuntimeException("Cannot have more than one constructor annotated with @Initializer for " + type);
- }
-
- else if (bindingTypeAnnotatedConstructors.size() > 1)
- {
- throw new RuntimeException("Cannot have more than one constructor with binding types specified on constructor parameters for " + type);
- }
-
- else
- {
- throw new RuntimeException("Specify a constructor either annotated with @Initializer or with parameters annotated with binding types for " + type);
- }
- }
- else if (initializerAnnotatedConstructors.size() == 1)
- {
- this.constructor = initializerAnnotatedConstructors.get(0);
- log.finest("Exactly one constructor (" + constructor +") annotated with @Initializer defined, using it as the component constructor for " + type);
- }
- else if (bindingTypeAnnotatedConstructors.size() == 1)
- {
- this.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);
- }
- }
- else if (type.getConstructors().length == 0)
- {
- this.constructor = (Constructor<T>) Reflections.getConstructor(type);
- log.finest("No constructor defined, using implicit no arguement constructor for " + type);
- }
-
- if (this.constructor == null)
- {
- throw new RuntimeException("Cannot determine constructor to use for " + type);
- }
-
- for (int i = 0; i < constructor.getParameterTypes().length; i++)
- {
- if (constructor.getParameterAnnotations()[i].length > 0)
- {
- InjectedParameterMetaModel parameter = new InjectedParameterMetaModel(constructor.getParameterAnnotations()[i], constructor.getParameterTypes()[i]);
- injectedParameters.add(i, parameter);
- }
- else
- {
- InjectedParameterMetaModel parameter = new InjectedParameterMetaModel(constructor.getParameterTypes()[i]);
- injectedParameters.add(i, parameter);
- }
- }
- log.finest("Initialized metadata for " + constructor + " with injectable parameters " + injectedParameters);
-
- }
-
- public Constructor<T> getConstructor()
- {
- return constructor;
- }
-
- public List<AbstractInjectedThingMetaModel> getInjectedAttributes()
- {
- return injectedParameters;
- }
-
- public T newInstance(Container container)
- {
- Object[] parameters = new Object[injectedParameters.size()];
- log.finest("Creating new instance of " + constructor.getDeclaringClass() + " with injected parameters " + injectedParameters);
- for (int i = 0; i < injectedParameters.size(); i++)
- {
- parameters[i] = container.getInstanceByType(injectedParameters.get(i).getType(), injectedParameters.get(0).getBindingTypes());
- }
- try
- {
- return constructor.newInstance(parameters);
- }
- catch (Exception e)
- {
- throw new RuntimeException("Error instantiating " + constructor.getDeclaringClass(), e);
- }
- }
-
-}
Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/InjectedParameterMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/InjectedParameterMetaModel.java 2008-07-03 01:55:49 UTC (rev 37)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/InjectedParameterMetaModel.java 2008-07-03 13:02:30 UTC (rev 38)
@@ -1,31 +0,0 @@
-package org.jboss.webbeans;
-
-import java.lang.annotation.Annotation;
-
-import org.jboss.webbeans.bindings.CurrentBinding;
-
-public class InjectedParameterMetaModel extends AbstractInjectedThingMetaModel
-{
-
- private static Annotation[] currentBinding = {new CurrentBinding()};
-
- private Class<?> type;
-
- public InjectedParameterMetaModel(Annotation[] bindingTypes, Class<?> type)
- {
- super(bindingTypes);
- this.type = type;
- }
-
- public InjectedParameterMetaModel(Class<?> type)
- {
- super(currentBinding);
- this.type = type;
- }
-
- public Class<?> getType()
- {
- return type;
- }
-
-}
Modified: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ejb/EJB.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ejb/EJB.java 2008-07-03 01:55:49 UTC (rev 37)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ejb/EJB.java 2008-07-03 13:02:30 UTC (rev 38)
@@ -1,6 +1,8 @@
package org.jboss.webbeans.ejb;
import java.lang.annotation.Annotation;
+import java.util.HashMap;
+import java.util.Map;
import org.jboss.webbeans.util.Reflections;
@@ -9,17 +11,23 @@
public class EJB
{
+ private static Map<Class<?>, EjbMetaData> ejbMetaDataMap = new HashMap<Class<?>, EjbMetaData>();
+
public @interface Dummy {}
- public static final Class<Annotation> STATELESS;
- public static final Class<Annotation> STATEFUL;
- public static final Class<Annotation> MESSAGE_DRIVEN;
+ public static final Class<Annotation> STATELESS_ANNOTATION;
+ public static final Class<Annotation> STATEFUL_ANNOTATION;
+ public static final Class<Annotation> MESSAGE_DRIVEN_ANNOTATION;
+ public static final Class<Annotation> SINGLETON_ANNOTATION;
+ public static final Class<Annotation> REMOVE_ANNOTATION;
static
{
- STATELESS = classForName("javax.ejb.Stateless");
- STATEFUL = classForName("javax.ejb.Stateful");
- MESSAGE_DRIVEN = classForName("javax.ejb.MessageDriven");
+ STATELESS_ANNOTATION = classForName("javax.ejb.Stateless");
+ STATEFUL_ANNOTATION = classForName("javax.ejb.Stateful");
+ MESSAGE_DRIVEN_ANNOTATION = classForName("javax.ejb.MessageDriven");
+ SINGLETON_ANNOTATION = classForName("javax.ejb.Singleton");
+ REMOVE_ANNOTATION = classForName("javax.ejb.Remove");
}
private static Class classForName(String name)
@@ -34,39 +42,20 @@
}
}
- public static boolean isStatelessEjbComponent(Class<?> clazz)
+ public static <T> EjbMetaData<T> getEjbMetaData(Class<? extends T> clazz)
{
- EjbMetaData ejbMetaData = getEjbMetaData(clazz);
- if (ejbMetaData != null)
+ // TODO replace with an application lookup
+ if (!ejbMetaDataMap.containsKey(clazz))
{
- return ejbMetaData.isStateless();
+ EjbMetaData<T> ejbMetaData = new EjbMetaData(clazz);
+ ejbMetaDataMap.put(clazz, ejbMetaData);
+ return ejbMetaData;
}
- return false;
- }
-
- public static boolean isStatefulEjbComponent(Class<?> clazz)
- {
- EjbMetaData ejbMetaData = getEjbMetaData(clazz);
- if (ejbMetaData != null)
+ else
{
- return ejbMetaData.isStateful();
+ return ejbMetaDataMap.get(clazz);
}
- return false;
+
}
- public static boolean isMessageDrivenEjbComponent(Class<?> clazz)
- {
- EjbMetaData ejbMetaData = getEjbMetaData(clazz);
- if (ejbMetaData != null)
- {
- return ejbMetaData.isMessageDriven();
- }
- return false;
- }
-
- public static EjbMetaData getEjbMetaData(Class<?> clazz)
- {
- return null;
- }
-
}
Modified: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ejb/EjbMetaData.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ejb/EjbMetaData.java 2008-07-03 01:55:49 UTC (rev 37)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ejb/EjbMetaData.java 2008-07-03 13:02:30 UTC (rev 38)
@@ -1,24 +1,84 @@
package org.jboss.webbeans.ejb;
-public class EjbMetaData
+import static org.jboss.webbeans.ejb.EJB.MESSAGE_DRIVEN_ANNOTATION;
+import static org.jboss.webbeans.ejb.EJB.SINGLETON_ANNOTATION;
+import static org.jboss.webbeans.ejb.EJB.STATEFUL_ANNOTATION;
+import static org.jboss.webbeans.ejb.EJB.REMOVE_ANNOTATION;
+import static org.jboss.webbeans.ejb.EJB.STATELESS_ANNOTATION;
+import static org.jboss.webbeans.ejb.EjbMetaData.EjbType.MESSAGE_DRIVEN;
+import static org.jboss.webbeans.ejb.EjbMetaData.EjbType.SINGLETON;
+import static org.jboss.webbeans.ejb.EjbMetaData.EjbType.STATEFUL;
+import static org.jboss.webbeans.ejb.EjbMetaData.EjbType.STATELESS;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.webbeans.util.Reflections;
+
+public class EjbMetaData<T>
{
+ public enum EjbType
+ {
+ STATELESS,
+ STATEFUL,
+ SINGLETON,
+ MESSAGE_DRIVEN;
+ }
+
+ private EjbType ejbType;
+ private List<Method> removeMethods;
+
+ public EjbMetaData(Class<T> type)
+ {
+ // TODO Merge in ejb-jar.xml
+ if (type.isAnnotationPresent(STATELESS_ANNOTATION))
+ {
+ this.ejbType = STATELESS;
+ }
+ else if (type.isAnnotationPresent(STATEFUL_ANNOTATION))
+ {
+ this.ejbType = STATEFUL;
+ this.removeMethods = new ArrayList<Method>();
+ for (Method removeMethod : Reflections.getMethods(type, REMOVE_ANNOTATION))
+ {
+ removeMethods.add(removeMethod);
+ }
+ }
+ else if (type.isAnnotationPresent(MESSAGE_DRIVEN_ANNOTATION))
+ {
+ this.ejbType = MESSAGE_DRIVEN;
+ }
+ else if (type.isAnnotationPresent(SINGLETON_ANNOTATION))
+ {
+ this.ejbType = SINGLETON;
+ }
+ }
+
public boolean isStateless()
{
- // TODO Auto-generated method stub
- return false;
+ return STATELESS.equals(ejbType);
}
public boolean isStateful()
{
- // TODO Auto-generated method stub
- return false;
+ return STATEFUL.equals(ejbType);
}
public boolean isMessageDriven()
{
- // TODO Auto-generated method stub
- return false;
+ return MESSAGE_DRIVEN.equals(ejbType);
}
+ public boolean isSingleton()
+ {
+ return SINGLETON.equals(ejbType);
+ }
+
+ public List<Method> getRemoveMethods()
+ {
+ return removeMethods;
+ }
+
}
Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ConstructorMetaModel.java (from rev 34, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ConstructorMetaModel.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ConstructorMetaModel.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ConstructorMetaModel.java 2008-07-03 13:02:30 UTC (rev 38)
@@ -0,0 +1,45 @@
+package org.jboss.webbeans.injectable;
+
+import java.lang.reflect.Constructor;
+import java.util.logging.Logger;
+
+import javax.webbeans.Container;
+
+import org.jboss.webbeans.util.LoggerUtil;
+
+public class ConstructorMetaModel<T> extends UnitMetaModel<T>
+{
+
+ public static final String LOGGER_NAME = "componentConstructor";
+
+ private static Logger log = LoggerUtil.getLogger(LOGGER_NAME);
+
+ private Constructor<T> constructor;
+
+ @SuppressWarnings("unchecked")
+ public ConstructorMetaModel(Constructor<T> constructor)
+ {
+ super(constructor.getParameterTypes(), constructor.getParameterAnnotations());
+ this.constructor = constructor;
+ log.finest("Initialized metadata for " + constructor + " with injectable parameters " + getParameters());
+ }
+
+ public Constructor<T> getConstructor()
+ {
+ return constructor;
+ }
+
+ public T invoke(Container container)
+ {
+ try
+ {
+ log.finest("Creating new instance of " + constructor.getDeclaringClass() + " with injected parameters " + getParameters());
+ return constructor.newInstance(getParameterValues(container));
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Error instantiating " + constructor.getDeclaringClass(), e);
+ }
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ConstructorMetaModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ElementMetaModel.java (from rev 28, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/AbstractInjectedThingMetaModel.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ElementMetaModel.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ElementMetaModel.java 2008-07-03 13:02:30 UTC (rev 38)
@@ -0,0 +1,40 @@
+package org.jboss.webbeans.injectable;
+
+import java.lang.annotation.Annotation;
+
+import javax.webbeans.Container;
+
+public abstract class ElementMetaModel<T>
+{
+
+ private Annotation[] bindingTypes;
+
+ public ElementMetaModel(Annotation[] bindingTypes)
+ {
+ this.bindingTypes = bindingTypes;
+ }
+
+ public ElementMetaModel()
+ {
+ this.bindingTypes = new Annotation[0];
+ }
+
+ public Annotation[] getBindingTypes()
+ {
+ return bindingTypes;
+ }
+
+ @Override
+ public String toString()
+ {
+ return getType() + " with binding types " + getBindingTypes();
+ }
+
+ public T getValue(Container container)
+ {
+ return container.getInstanceByType(getType(), getBindingTypes());
+ }
+
+ public abstract Class<? extends T> getType();
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ElementMetaModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/MethodMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/MethodMetaModel.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/MethodMetaModel.java 2008-07-03 13:02:30 UTC (rev 38)
@@ -0,0 +1,31 @@
+package org.jboss.webbeans.injectable;
+
+import java.lang.reflect.Method;
+
+import javax.webbeans.Container;
+
+public class MethodMetaModel<T> extends UnitMetaModel<T>
+{
+
+ private Method method;
+
+ public MethodMetaModel(Method method)
+ {
+ super(method.getParameterTypes(), method.getParameterAnnotations());
+ this.method = method;
+ }
+
+ @SuppressWarnings("unchecked")
+ public T invoke(Container container, Object instance)
+ {
+ try
+ {
+ return (T) method.invoke(instance, getParameterValues(container));
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Unable to invoke " + method + " on " + instance, e);
+ }
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/MethodMetaModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ParameterMetaModel.java (from rev 34, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/InjectedParameterMetaModel.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ParameterMetaModel.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ParameterMetaModel.java 2008-07-03 13:02:30 UTC (rev 38)
@@ -0,0 +1,33 @@
+package org.jboss.webbeans.injectable;
+
+import java.lang.annotation.Annotation;
+
+import org.jboss.webbeans.bindings.CurrentBinding;
+
+public class ParameterMetaModel<T> extends ElementMetaModel<T>
+{
+
+ private static Annotation[] currentBinding = {new CurrentBinding()};
+
+ private Class<? extends T> type;
+
+ public ParameterMetaModel(Annotation[] bindingTypes, Class<? extends T> type)
+ {
+ super(bindingTypes);
+ this.type = type;
+ }
+
+ public ParameterMetaModel(Class<? extends T> type)
+ {
+ super(currentBinding);
+ this.type = type;
+ }
+
+ public Class<? extends T> getType()
+ {
+ return type;
+ }
+
+
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/ParameterMetaModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/UnitMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/UnitMetaModel.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/UnitMetaModel.java 2008-07-03 13:02:30 UTC (rev 38)
@@ -0,0 +1,54 @@
+package org.jboss.webbeans.injectable;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.webbeans.Container;
+
+public abstract class UnitMetaModel<T>
+{
+
+ private List<ElementMetaModel<Object>> parameters;
+
+ public UnitMetaModel(Class<?>[] parameterTypes, Annotation[][] parameterAnnotations)
+ {
+ parameters = initParameters(parameterTypes, parameterAnnotations);
+ }
+
+ public List<ElementMetaModel<Object>> getParameters()
+ {
+ return parameters;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected static List<ElementMetaModel<Object>> initParameters(Class<?>[] parameterTypes, Annotation[][] parameterAnnotations)
+ {
+ List<ElementMetaModel<Object>> injectedParameters = new ArrayList<ElementMetaModel<Object>>();
+ for (int i = 0; i < parameterTypes.length; i++)
+ {
+ if (parameterAnnotations[i].length > 0)
+ {
+ ParameterMetaModel<Object> parameter = new ParameterMetaModel(parameterAnnotations[i], parameterTypes[i]);
+ injectedParameters.add(i, parameter);
+ }
+ else
+ {
+ ParameterMetaModel<Object> parameter = new ParameterMetaModel(parameterTypes[i]);
+ injectedParameters.add(i, parameter);
+ }
+ }
+ return injectedParameters;
+ }
+
+ public Object[] getParameterValues(Container container)
+ {
+ Object[] parameterValues = new Object[parameters.size()];
+ for (int i = 0; i < parameterValues.length; i++)
+ {
+ parameterValues[i] = parameters.get(i).getValue(container);
+ }
+ return parameterValues;
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/injectable/UnitMetaModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentInstanceTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentInstanceTest.java 2008-07-03 01:55:49 UTC (rev 37)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentInstanceTest.java 2008-07-03 13:02:30 UTC (rev 38)
@@ -1,570 +0,0 @@
-package org.jboss.webbeans.test;
-
-import static org.jboss.webbeans.test.util.Util.annotationSetMatches;
-
-import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.webbeans.ApplicationScoped;
-import javax.webbeans.ComponentInstance;
-import javax.webbeans.ConversationScoped;
-import javax.webbeans.Current;
-import javax.webbeans.Dependent;
-import javax.webbeans.Named;
-import javax.webbeans.Production;
-import javax.webbeans.RequestScoped;
-
-import org.jboss.webbeans.ComponentInstanceImpl;
-import org.jboss.webbeans.ContainerImpl;
-import org.jboss.webbeans.StereotypeMetaModel;
-import org.jboss.webbeans.ComponentInstanceImpl.ComponentType;
-import org.jboss.webbeans.bindings.ConversationScopedBinding;
-import org.jboss.webbeans.bindings.CurrentBinding;
-import org.jboss.webbeans.bindings.DependentBinding;
-import org.jboss.webbeans.bindings.NamedBinding;
-import org.jboss.webbeans.bindings.RequestScopedBinding;
-import org.jboss.webbeans.bindings.StandardBinding;
-import org.jboss.webbeans.test.annotations.AnimalStereotype;
-import org.jboss.webbeans.test.annotations.AnotherDeploymentType;
-import org.jboss.webbeans.test.annotations.Asynchronous;
-import org.jboss.webbeans.test.annotations.FishStereotype;
-import org.jboss.webbeans.test.annotations.HornedAnimalDeploymentType;
-import org.jboss.webbeans.test.annotations.HornedMammalStereotype;
-import org.jboss.webbeans.test.annotations.MammalStereotype;
-import org.jboss.webbeans.test.annotations.RequestScopedAnimalStereotype;
-import org.jboss.webbeans.test.annotations.RiverFishStereotype;
-import org.jboss.webbeans.test.annotations.Synchronous;
-import org.jboss.webbeans.test.bindings.AnimalStereotypeBinding;
-import org.jboss.webbeans.test.bindings.AnotherDeploymentTypeBinding;
-import org.jboss.webbeans.test.bindings.AsynchronousBinding;
-import org.jboss.webbeans.test.bindings.FishStereotypeBinding;
-import org.jboss.webbeans.test.bindings.HornedAnimalDeploymentTypeBinding;
-import org.jboss.webbeans.test.bindings.HornedMamalStereotypeBinding;
-import org.jboss.webbeans.test.bindings.RiverFishStereotypeBinding;
-import org.jboss.webbeans.test.bindings.SynchronousBinding;
-import org.jboss.webbeans.test.components.Antelope;
-import org.jboss.webbeans.test.components.Carp;
-import org.jboss.webbeans.test.components.Cat;
-import org.jboss.webbeans.test.components.Chair;
-import org.jboss.webbeans.test.components.ComponentWithTooManyDeploymentTypes;
-import org.jboss.webbeans.test.components.ComponentWithTooManyScopeTypes;
-import org.jboss.webbeans.test.components.Cow;
-import org.jboss.webbeans.test.components.Goldfish;
-import org.jboss.webbeans.test.components.Gorilla;
-import org.jboss.webbeans.test.components.Haddock;
-import org.jboss.webbeans.test.components.Horse;
-import org.jboss.webbeans.test.components.Moose;
-import org.jboss.webbeans.test.components.Order;
-import org.jboss.webbeans.test.components.Pig;
-import org.jboss.webbeans.test.components.SeaBass;
-import org.jboss.webbeans.test.components.Tuna;
-import org.jboss.webbeans.test.mock.MockContainerImpl;
-import org.jboss.webbeans.util.AnnotatedItem;
-import org.jboss.webbeans.util.ClassAnnotatedItem;
-import org.jboss.webbeans.util.MutableAnnotatedItem;
-import org.junit.Before;
-import org.junit.Test;
-
-public class ComponentInstanceTest
-{
-
- private ContainerImpl container;
-
- private AnnotatedItem emptyAnnotatedItem;
-
- @Before
- public void before()
- {
- emptyAnnotatedItem = new MutableAnnotatedItem(null, new HashMap<Class<? extends Annotation>, Annotation>());
-
- List<Annotation> enabledDeploymentTypes = new ArrayList<Annotation>();
- enabledDeploymentTypes.add(new StandardBinding());
- enabledDeploymentTypes.add(new AnotherDeploymentTypeBinding());
- enabledDeploymentTypes.add(new HornedAnimalDeploymentTypeBinding());
- container = new MockContainerImpl(enabledDeploymentTypes);
-
- initStereotypes(container);
- }
-
- private void initStereotypes(ContainerImpl container)
- {
- container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(AnimalStereotype.class)));
- container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(HornedMammalStereotype.class)));
- container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(MammalStereotype.class)));
- container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(FishStereotype.class)));
- container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(RiverFishStereotype.class)));
- container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(RequestScopedAnimalStereotype.class)));
- }
-
- @Test
- public void testTooManyDeploymentTypes()
- {
- boolean exception = false;
- try
- {
- new ComponentInstanceImpl<ComponentWithTooManyDeploymentTypes>(new ClassAnnotatedItem(ComponentWithTooManyDeploymentTypes.class), emptyAnnotatedItem, container);
- }
- catch (Exception e)
- {
- exception = true;
- }
- assert exception;
- }
-
- // **** TESTS FOR DEPLOYMENT TYPE **** //
-
- @Test
- public void testXmlDeploymentTypeOverridesJava()
- {
- Map<Class<? extends Annotation>, Annotation> xmlDefinedDeploymentTypeAnnotations = new HashMap<Class<? extends Annotation>, Annotation>();
- xmlDefinedDeploymentTypeAnnotations.put(AnotherDeploymentType.class, new AnotherDeploymentTypeBinding());
- AnnotatedItem xmlDefinedDeploymentTypeAnnotatedItem = new MutableAnnotatedItem(ComponentWithTooManyDeploymentTypes.class, xmlDefinedDeploymentTypeAnnotations);
-
- ComponentInstance<ComponentWithTooManyDeploymentTypes> component = new ComponentInstanceImpl<ComponentWithTooManyDeploymentTypes>(new ClassAnnotatedItem(ComponentWithTooManyDeploymentTypes.class), xmlDefinedDeploymentTypeAnnotatedItem, container);
- assert component.getDeploymentType().annotationType().equals(AnotherDeploymentType.class);
- }
-
- @Test
- public void testXmlDefaultDeploymentType()
- {
- AnnotatedItem antelopeAnnotatedItem = new MutableAnnotatedItem(Antelope.class, new HashMap<Class<? extends Annotation>, Annotation>());
- ComponentInstance<Antelope> antelope = new ComponentInstanceImpl<Antelope>(emptyAnnotatedItem, antelopeAnnotatedItem, container);
- assert antelope.getDeploymentType().annotationType().equals(Production.class);
- }
-
- @Test
- public void testXmlIgnoresJavaDeploymentType()
- {
- AnnotatedItem annotatedItem = new MutableAnnotatedItem(Tuna.class, new HashMap<Class<? extends Annotation>, Annotation>());
- ComponentInstance<Tuna> tuna = new ComponentInstanceImpl<Tuna>(new ClassAnnotatedItem(Tuna.class), annotatedItem, container);
- assert tuna.getDeploymentType().annotationType().equals(Production.class);
- }
-
- @Test
- public void testDeploymentTypePrecedenceSelection()
- {
- Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
- annotations.put(HornedMammalStereotype.class, new HornedMamalStereotypeBinding());
- AnnotatedItem annotatedItem = new MutableAnnotatedItem(Moose.class, annotations);
-
- ComponentInstance<Moose> moose = new ComponentInstanceImpl<Moose>(new ClassAnnotatedItem(Moose.class), annotatedItem, container);
- assert moose.getDeploymentType().annotationType().equals(HornedAnimalDeploymentType.class);
-
- }
-
- // **** TESTS FOR BINDING TYPE **** //
-
- @SuppressWarnings("unchecked")
- @Test
- public void testXmlBindingTypeOverridesJava()
- {
- Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
- annotations.put(Asynchronous.class, new AsynchronousBinding());
- AnnotatedItem annotatedItem = new MutableAnnotatedItem(Cat.class, annotations);
-
- ComponentInstance<Cat> cat = new ComponentInstanceImpl<Cat>(new ClassAnnotatedItem(Cat.class), annotatedItem, container);
- assert cat.getBindingTypes().size() == 1;
- assert annotationSetMatches(cat.getBindingTypes(), Asynchronous.class);
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testBindingTypesDeclaredInJava()
- {
- ComponentInstance<Cat> cat = new ComponentInstanceImpl<Cat>(new ClassAnnotatedItem(Cat.class), emptyAnnotatedItem, container);
- assert cat.getBindingTypes().size() == 1;
- assert annotationSetMatches(cat.getBindingTypes(), Synchronous.class);
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testBindingTypesDeclaredInXml()
- {
- Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
- annotations.put(Asynchronous.class, new AsynchronousBinding());
- AnnotatedItem annotatedItem = new MutableAnnotatedItem(Antelope.class, annotations);
-
- ComponentInstance<Antelope> antelope = new ComponentInstanceImpl<Antelope>(emptyAnnotatedItem, annotatedItem, container);
- assert annotationSetMatches(antelope.getBindingTypes(), Asynchronous.class);
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testDefaultBindingType()
- {
- ComponentInstance<Order> order = new ComponentInstanceImpl<Order>(new ClassAnnotatedItem(Order.class), emptyAnnotatedItem, container);
- assert order.getBindingTypes().size() == 1;
- order.getBindingTypes().iterator().next().annotationType().equals(Current.class);
- }
-
- // **** TESTS FOR SCOPES **** //
-
- @Test
- public void testScopeDeclaredInJava()
- {
- ComponentInstance<SeaBass> trout = new ComponentInstanceImpl<SeaBass>(new ClassAnnotatedItem(SeaBass.class), emptyAnnotatedItem, container);
- assert trout.getScopeType().annotationType().equals(RequestScoped.class);
- }
-
- @Test
- public void testScopeDeclaredInXml()
- {
- Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
- annotations.put(RequestScoped.class, new RequestScopedBinding());
- AnnotatedItem annotatedItem = new MutableAnnotatedItem(Order.class, annotations);
-
- ComponentInstance<Order> order = new ComponentInstanceImpl<Order>(new ClassAnnotatedItem(Order.class), annotatedItem, container);
- assert order.getScopeType().annotationType().equals(RequestScoped.class);
- }
-
- @Test
- public void testScopeDeclaredInXmlOverridesJava()
- {
- Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
- annotations.put(ConversationScoped.class, new ConversationScopedBinding());
- AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
- ComponentInstance<SeaBass> trout = new ComponentInstanceImpl<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
- assert trout.getScopeType().annotationType().equals(ConversationScoped.class);
- }
-
- @Test
- public void testScopeMissingInXml()
- {
- Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
- AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
-
- ComponentInstance<SeaBass> trout = new ComponentInstanceImpl<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
- assert trout.getScopeType().annotationType().equals(RequestScoped.class);
- }
-
- @Test
- public void testNoScopeSpecified()
- {
- ComponentInstance<Order> order = new ComponentInstanceImpl<Order>(new ClassAnnotatedItem(Order.class), emptyAnnotatedItem, container);
- assert order.getScopeType().annotationType().equals(Dependent.class);
- }
-
- @Test
- public void testTooManyScopesSpecified()
- {
- boolean exception = false;
- try
- {
- new ComponentInstanceImpl<ComponentWithTooManyScopeTypes>(new ClassAnnotatedItem(ComponentWithTooManyScopeTypes.class), emptyAnnotatedItem, container);
- }
- catch (Exception e)
- {
- exception = true;
- }
- assert exception;
- }
-
- @Test
- public void testTooManyScopesSpecifiedInXml()
- {
- boolean exception = false;
- try
- {
- Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
- annotations.put(RequestScoped.class, new RequestScopedBinding());
- annotations.put(ConversationScoped.class, new ConversationScopedBinding());
- AnnotatedItem antelopeAnnotatedItem = new MutableAnnotatedItem(Antelope.class, annotations);
- new ComponentInstanceImpl<Antelope>(emptyAnnotatedItem, antelopeAnnotatedItem, container);
- }
- catch (Exception e)
- {
- exception = true;
- }
- assert exception;
- }
-
- @Test
- public void testScopeSpecifiedAndStereotyped()
- {
- Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
- annotations.put(FishStereotype.class, new FishStereotypeBinding());
- AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
- ComponentInstance<SeaBass> trout = new ComponentInstanceImpl<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
- assert trout.getScopeType().annotationType().equals(RequestScoped.class);
- }
-
- @Test
- public void testMutipleIncompatibleScopeStereotypes()
- {
- Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
- annotations.put(FishStereotype.class, new FishStereotypeBinding());
- annotations.put(AnimalStereotype.class, new AnimalStereotypeBinding());
- AnnotatedItem annotatedItem = new MutableAnnotatedItem(Haddock.class, annotations);
-
- boolean exception = false;
- try
- {
- new ComponentInstanceImpl<Haddock>(new ClassAnnotatedItem(Haddock.class), annotatedItem, container);
- }
- catch (Exception e)
- {
- exception = true;
- }
- assert exception;
- }
-
- @Test
- public void testMutipleIncompatibleScopeStereotypesWithScopeSpecified()
- {
- Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
- annotations.put(FishStereotype.class, new FishStereotypeBinding());
- annotations.put(AnimalStereotype.class, new AnimalStereotypeBinding());
- AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
-
- ComponentInstance<SeaBass> trout = new ComponentInstanceImpl<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
- assert trout.getScopeType().annotationType().equals(RequestScoped.class);
- }
-
- @Test
- public void testMutipleCompatibleScopeStereotypes()
- {
- Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
- annotations.put(FishStereotype.class, new FishStereotypeBinding());
- annotations.put(RiverFishStereotype.class, new RiverFishStereotypeBinding());
- AnnotatedItem annotatedItem = new MutableAnnotatedItem(Haddock.class, annotations);
-
- ComponentInstance<Haddock> haddock = new ComponentInstanceImpl<Haddock>(new ClassAnnotatedItem(Haddock.class), annotatedItem, container);
- assert haddock.getScopeType().annotationType().equals(ApplicationScoped.class);
- }
-
- // **** TESTS FOR COMPONENT NAME **** /
-
- @Test
- public void testNamed()
- {
- ComponentInstanceImpl<Haddock> haddock = new ComponentInstanceImpl<Haddock>(new ClassAnnotatedItem(Haddock.class), emptyAnnotatedItem, container);
- assert haddock.getName() != null;
- haddock.getComponentType().equals(ComponentType.SIMPLE);
- assert haddock.getName().equals("haddock");
- }
-
- @Test
- public void testXmlNamed()
- {
- Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
- annotations.put(Named.class, new NamedBinding()
- {
-
- public String value()
- {
- return "";
- }
- });
- AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
- ComponentInstanceImpl<SeaBass> trout = new ComponentInstanceImpl<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
-
- assert trout.getName() != null;
- trout.getComponentType().equals(ComponentType.SIMPLE);
- assert trout.getName().equals("seaBass");
- }
-
- @Test
- public void testNonDefaultXmlNamed()
- {
- Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
- annotations.put(Named.class, new NamedBinding()
- {
-
- public String value()
- {
- return "aTrout";
- }
- });
- AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
- ComponentInstance<SeaBass> trout = new ComponentInstanceImpl<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
-
- assert trout.getName().equals("aTrout");
- }
-
- @Test
- public void testNotNamed()
- {
- ComponentInstance<SeaBass> trout = new ComponentInstanceImpl<SeaBass>(new ClassAnnotatedItem(SeaBass.class), emptyAnnotatedItem, container);
- assert trout.getName() == null;
- }
-
- @Test
- public void testNonDefaultNamed()
- {
- ComponentInstance<Moose> moose = new ComponentInstanceImpl<Moose>(new ClassAnnotatedItem(Moose.class), emptyAnnotatedItem, container);
- assert moose.getName().equals("aMoose");
- }
-
-
- // **** TESTS FOR STEREOTYPES **** //
-
- @SuppressWarnings("unchecked")
- @Test
- public void testStereotypeDeclaredInXmlAndJava()
- {
- Map<Class<? extends Annotation>, Annotation> orderXmlAnnotations = new HashMap<Class<? extends Annotation>, Annotation>();
- orderXmlAnnotations.put(Current.class, new CurrentBinding());
- orderXmlAnnotations.put(Synchronous.class, new SynchronousBinding());
- orderXmlAnnotations.put(Named.class, new NamedBinding()
- {
- public String value()
- {
- return "currentSynchronousOrder";
- }
- });
- AnnotatedItem currentSynchronousOrderAnnotatedItem = new MutableAnnotatedItem(Order.class, orderXmlAnnotations);
-
- ComponentInstance<Order> order = new ComponentInstanceImpl<Order>(new ClassAnnotatedItem(Order.class), currentSynchronousOrderAnnotatedItem, container);
- assert Production.class.equals(order.getDeploymentType().annotationType());
- assert "currentSynchronousOrder".equals(order.getName());
- assert order.getBindingTypes().size() == 2;
- assert annotationSetMatches(order.getBindingTypes(), Current.class, Synchronous.class);
- assert order.getScopeType().annotationType().equals(Dependent.class);
- }
-
- @Test
- public void testSingleStereotype()
- {
- ComponentInstance<Gorilla> gorilla = new ComponentInstanceImpl<Gorilla>(new ClassAnnotatedItem(Gorilla.class), emptyAnnotatedItem, container);
- assert gorilla.getName() == null;
- assert gorilla.getDeploymentType().annotationType().equals(Production.class);
- assert gorilla.getBindingTypes().iterator().next().annotationType().equals(Current.class);
- assert gorilla.getScopeType().annotationType().equals(RequestScoped.class);
- }
-
- @Test
- public void testRequiredTypeIsImplemented()
- {
- try
- {
- new ComponentInstanceImpl<Gorilla>(new ClassAnnotatedItem(Gorilla.class), emptyAnnotatedItem, container);
- }
- catch (Exception e)
- {
- assert false;
- }
-
- }
-
- @Test
- public void testRequiredTypeIsNotImplemented()
- {
- boolean exception = false;
- try
- {
- new ComponentInstanceImpl<Chair>(new ClassAnnotatedItem(Chair.class), emptyAnnotatedItem, container);
- }
- catch (Exception e)
- {
- exception = true;
- }
- assert exception;
-
- }
-
- @Test
- public void testScopeIsSupported()
- {
- try
- {
- new ComponentInstanceImpl<Goldfish>(new ClassAnnotatedItem(Goldfish.class), emptyAnnotatedItem, container);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- assert false;
- }
-
- }
-
- @Test
- public void testScopeIsNotSupported()
- {
- boolean exception = false;
- try
- {
- new ComponentInstanceImpl<Carp>(new ClassAnnotatedItem(Carp.class), emptyAnnotatedItem, container);
- }
- catch (Exception e)
- {
- exception = true;
- }
- assert exception;
-
- }
-
- //*** COMPONENT CLASS CHECKS ****//
-
- @Test
- public void testAbstractClassIsNotAllowed()
- {
- boolean exception = false;
- try
- {
- new ComponentInstanceImpl<Cow>(new ClassAnnotatedItem(Cow.class), emptyAnnotatedItem, container);
- }
- catch (Exception e)
- {
- exception = true;
- }
- assert exception;
- }
-
- @Test
- public void testFinalClassMustBeDependentScoped()
- {
- boolean exception = false;
- try
- {
- new ComponentInstanceImpl<Horse>(new ClassAnnotatedItem(Horse.class), emptyAnnotatedItem, container);
- }
- catch (Exception e)
- {
- exception = true;
- }
- assert exception;
-
- Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
- annotations.put(Dependent.class, new DependentBinding());
- AnnotatedItem annotatedItem = new MutableAnnotatedItem(Horse.class, annotations);
- try
- {
- new ComponentInstanceImpl<Horse>(new ClassAnnotatedItem(Horse.class), annotatedItem, container);
- }
- catch (Exception e)
- {
- assert false;
- }
- }
-
- @Test
- public void testClassWithFinalMethodMustBeDependentScoped()
- {
- boolean exception = false;
- try
- {
- new ComponentInstanceImpl<Pig>(new ClassAnnotatedItem(Pig.class), emptyAnnotatedItem, container);
- }
- catch (Exception e)
- {
- exception = true;
- }
- assert exception;
-
- Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
- annotations.put(Dependent.class, new DependentBinding());
- AnnotatedItem annotatedItem = new MutableAnnotatedItem(Pig.class, annotations);
- try
- {
- new ComponentInstanceImpl<Pig>(new ClassAnnotatedItem(Pig.class), annotatedItem, container);
- }
- catch (Exception e)
- {
- assert false;
- }
- }
-
-}
Copied: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentMetaModelTest.java (from rev 35, ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentInstanceTest.java)
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentMetaModelTest.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentMetaModelTest.java 2008-07-03 13:02:30 UTC (rev 38)
@@ -0,0 +1,569 @@
+package org.jboss.webbeans.test;
+
+import static org.jboss.webbeans.test.util.Util.annotationSetMatches;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.webbeans.ApplicationScoped;
+import javax.webbeans.ConversationScoped;
+import javax.webbeans.Current;
+import javax.webbeans.Dependent;
+import javax.webbeans.Named;
+import javax.webbeans.Production;
+import javax.webbeans.RequestScoped;
+
+import org.jboss.webbeans.ComponentMetaModel;
+import org.jboss.webbeans.ContainerImpl;
+import org.jboss.webbeans.StereotypeMetaModel;
+import org.jboss.webbeans.ComponentMetaModel.ComponentType;
+import org.jboss.webbeans.bindings.ConversationScopedBinding;
+import org.jboss.webbeans.bindings.CurrentBinding;
+import org.jboss.webbeans.bindings.DependentBinding;
+import org.jboss.webbeans.bindings.NamedBinding;
+import org.jboss.webbeans.bindings.RequestScopedBinding;
+import org.jboss.webbeans.bindings.StandardBinding;
+import org.jboss.webbeans.test.annotations.AnimalStereotype;
+import org.jboss.webbeans.test.annotations.AnotherDeploymentType;
+import org.jboss.webbeans.test.annotations.Asynchronous;
+import org.jboss.webbeans.test.annotations.FishStereotype;
+import org.jboss.webbeans.test.annotations.HornedAnimalDeploymentType;
+import org.jboss.webbeans.test.annotations.HornedMammalStereotype;
+import org.jboss.webbeans.test.annotations.MammalStereotype;
+import org.jboss.webbeans.test.annotations.RequestScopedAnimalStereotype;
+import org.jboss.webbeans.test.annotations.RiverFishStereotype;
+import org.jboss.webbeans.test.annotations.Synchronous;
+import org.jboss.webbeans.test.bindings.AnimalStereotypeBinding;
+import org.jboss.webbeans.test.bindings.AnotherDeploymentTypeBinding;
+import org.jboss.webbeans.test.bindings.AsynchronousBinding;
+import org.jboss.webbeans.test.bindings.FishStereotypeBinding;
+import org.jboss.webbeans.test.bindings.HornedAnimalDeploymentTypeBinding;
+import org.jboss.webbeans.test.bindings.HornedMamalStereotypeBinding;
+import org.jboss.webbeans.test.bindings.RiverFishStereotypeBinding;
+import org.jboss.webbeans.test.bindings.SynchronousBinding;
+import org.jboss.webbeans.test.components.Antelope;
+import org.jboss.webbeans.test.components.Carp;
+import org.jboss.webbeans.test.components.Cat;
+import org.jboss.webbeans.test.components.Chair;
+import org.jboss.webbeans.test.components.ComponentWithTooManyDeploymentTypes;
+import org.jboss.webbeans.test.components.ComponentWithTooManyScopeTypes;
+import org.jboss.webbeans.test.components.Cow;
+import org.jboss.webbeans.test.components.Goldfish;
+import org.jboss.webbeans.test.components.Gorilla;
+import org.jboss.webbeans.test.components.Haddock;
+import org.jboss.webbeans.test.components.Horse;
+import org.jboss.webbeans.test.components.Moose;
+import org.jboss.webbeans.test.components.Order;
+import org.jboss.webbeans.test.components.Pig;
+import org.jboss.webbeans.test.components.SeaBass;
+import org.jboss.webbeans.test.components.Tuna;
+import org.jboss.webbeans.test.mock.MockContainerImpl;
+import org.jboss.webbeans.util.AnnotatedItem;
+import org.jboss.webbeans.util.ClassAnnotatedItem;
+import org.jboss.webbeans.util.MutableAnnotatedItem;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ComponentMetaModelTest
+{
+
+ private ContainerImpl container;
+
+ private AnnotatedItem emptyAnnotatedItem;
+
+ @Before
+ public void before()
+ {
+ emptyAnnotatedItem = new MutableAnnotatedItem(null, new HashMap<Class<? extends Annotation>, Annotation>());
+
+ List<Annotation> enabledDeploymentTypes = new ArrayList<Annotation>();
+ enabledDeploymentTypes.add(new StandardBinding());
+ enabledDeploymentTypes.add(new AnotherDeploymentTypeBinding());
+ enabledDeploymentTypes.add(new HornedAnimalDeploymentTypeBinding());
+ container = new MockContainerImpl(enabledDeploymentTypes);
+
+ initStereotypes(container);
+ }
+
+ private void initStereotypes(ContainerImpl container)
+ {
+ container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(AnimalStereotype.class)));
+ container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(HornedMammalStereotype.class)));
+ container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(MammalStereotype.class)));
+ container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(FishStereotype.class)));
+ container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(RiverFishStereotype.class)));
+ container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(RequestScopedAnimalStereotype.class)));
+ }
+
+ @Test
+ public void testTooManyDeploymentTypes()
+ {
+ boolean exception = false;
+ try
+ {
+ new ComponentMetaModel<ComponentWithTooManyDeploymentTypes>(new ClassAnnotatedItem(ComponentWithTooManyDeploymentTypes.class), emptyAnnotatedItem, container);
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+ }
+
+ // **** TESTS FOR DEPLOYMENT TYPE **** //
+
+ @Test
+ public void testXmlDeploymentTypeOverridesJava()
+ {
+ Map<Class<? extends Annotation>, Annotation> xmlDefinedDeploymentTypeAnnotations = new HashMap<Class<? extends Annotation>, Annotation>();
+ xmlDefinedDeploymentTypeAnnotations.put(AnotherDeploymentType.class, new AnotherDeploymentTypeBinding());
+ AnnotatedItem xmlDefinedDeploymentTypeAnnotatedItem = new MutableAnnotatedItem(ComponentWithTooManyDeploymentTypes.class, xmlDefinedDeploymentTypeAnnotations);
+
+ ComponentMetaModel<ComponentWithTooManyDeploymentTypes> component = new ComponentMetaModel<ComponentWithTooManyDeploymentTypes>(new ClassAnnotatedItem(ComponentWithTooManyDeploymentTypes.class), xmlDefinedDeploymentTypeAnnotatedItem, container);
+ assert component.getDeploymentType().annotationType().equals(AnotherDeploymentType.class);
+ }
+
+ @Test
+ public void testXmlDefaultDeploymentType()
+ {
+ AnnotatedItem antelopeAnnotatedItem = new MutableAnnotatedItem(Antelope.class, new HashMap<Class<? extends Annotation>, Annotation>());
+ ComponentMetaModel<Antelope> antelope = new ComponentMetaModel<Antelope>(emptyAnnotatedItem, antelopeAnnotatedItem, container);
+ assert antelope.getDeploymentType().annotationType().equals(Production.class);
+ }
+
+ @Test
+ public void testXmlIgnoresJavaDeploymentType()
+ {
+ AnnotatedItem annotatedItem = new MutableAnnotatedItem(Tuna.class, new HashMap<Class<? extends Annotation>, Annotation>());
+ ComponentMetaModel<Tuna> tuna = new ComponentMetaModel<Tuna>(new ClassAnnotatedItem(Tuna.class), annotatedItem, container);
+ assert tuna.getDeploymentType().annotationType().equals(Production.class);
+ }
+
+ @Test
+ public void testDeploymentTypePrecedenceSelection()
+ {
+ Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+ annotations.put(HornedMammalStereotype.class, new HornedMamalStereotypeBinding());
+ AnnotatedItem annotatedItem = new MutableAnnotatedItem(Moose.class, annotations);
+
+ ComponentMetaModel<Moose> moose = new ComponentMetaModel<Moose>(new ClassAnnotatedItem(Moose.class), annotatedItem, container);
+ assert moose.getDeploymentType().annotationType().equals(HornedAnimalDeploymentType.class);
+
+ }
+
+ // **** TESTS FOR BINDING TYPE **** //
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testXmlBindingTypeOverridesJava()
+ {
+ Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+ annotations.put(Asynchronous.class, new AsynchronousBinding());
+ AnnotatedItem annotatedItem = new MutableAnnotatedItem(Cat.class, annotations);
+
+ ComponentMetaModel<Cat> cat = new ComponentMetaModel<Cat>(new ClassAnnotatedItem(Cat.class), annotatedItem, container);
+ assert cat.getBindingTypes().size() == 1;
+ assert annotationSetMatches(cat.getBindingTypes(), Asynchronous.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testBindingTypesDeclaredInJava()
+ {
+ ComponentMetaModel<Cat> cat = new ComponentMetaModel<Cat>(new ClassAnnotatedItem(Cat.class), emptyAnnotatedItem, container);
+ assert cat.getBindingTypes().size() == 1;
+ assert annotationSetMatches(cat.getBindingTypes(), Synchronous.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testBindingTypesDeclaredInXml()
+ {
+ Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+ annotations.put(Asynchronous.class, new AsynchronousBinding());
+ AnnotatedItem annotatedItem = new MutableAnnotatedItem(Antelope.class, annotations);
+
+ ComponentMetaModel<Antelope> antelope = new ComponentMetaModel<Antelope>(emptyAnnotatedItem, annotatedItem, container);
+ assert annotationSetMatches(antelope.getBindingTypes(), Asynchronous.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testDefaultBindingType()
+ {
+ ComponentMetaModel<Order> order = new ComponentMetaModel<Order>(new ClassAnnotatedItem(Order.class), emptyAnnotatedItem, container);
+ assert order.getBindingTypes().size() == 1;
+ order.getBindingTypes().iterator().next().annotationType().equals(Current.class);
+ }
+
+ // **** TESTS FOR SCOPES **** //
+
+ @Test
+ public void testScopeDeclaredInJava()
+ {
+ ComponentMetaModel<SeaBass> trout = new ComponentMetaModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), emptyAnnotatedItem, container);
+ assert trout.getScopeType().annotationType().equals(RequestScoped.class);
+ }
+
+ @Test
+ public void testScopeDeclaredInXml()
+ {
+ Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+ annotations.put(RequestScoped.class, new RequestScopedBinding());
+ AnnotatedItem annotatedItem = new MutableAnnotatedItem(Order.class, annotations);
+
+ ComponentMetaModel<Order> order = new ComponentMetaModel<Order>(new ClassAnnotatedItem(Order.class), annotatedItem, container);
+ assert order.getScopeType().annotationType().equals(RequestScoped.class);
+ }
+
+ @Test
+ public void testScopeDeclaredInXmlOverridesJava()
+ {
+ Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+ annotations.put(ConversationScoped.class, new ConversationScopedBinding());
+ AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
+ ComponentMetaModel<SeaBass> trout = new ComponentMetaModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
+ assert trout.getScopeType().annotationType().equals(ConversationScoped.class);
+ }
+
+ @Test
+ public void testScopeMissingInXml()
+ {
+ Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+ AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
+
+ ComponentMetaModel<SeaBass> trout = new ComponentMetaModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
+ assert trout.getScopeType().annotationType().equals(RequestScoped.class);
+ }
+
+ @Test
+ public void testNoScopeSpecified()
+ {
+ ComponentMetaModel<Order> order = new ComponentMetaModel<Order>(new ClassAnnotatedItem(Order.class), emptyAnnotatedItem, container);
+ assert order.getScopeType().annotationType().equals(Dependent.class);
+ }
+
+ @Test
+ public void testTooManyScopesSpecified()
+ {
+ boolean exception = false;
+ try
+ {
+ new ComponentMetaModel<ComponentWithTooManyScopeTypes>(new ClassAnnotatedItem(ComponentWithTooManyScopeTypes.class), emptyAnnotatedItem, container);
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+ }
+
+ @Test
+ public void testTooManyScopesSpecifiedInXml()
+ {
+ boolean exception = false;
+ try
+ {
+ Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+ annotations.put(RequestScoped.class, new RequestScopedBinding());
+ annotations.put(ConversationScoped.class, new ConversationScopedBinding());
+ AnnotatedItem antelopeAnnotatedItem = new MutableAnnotatedItem(Antelope.class, annotations);
+ new ComponentMetaModel<Antelope>(emptyAnnotatedItem, antelopeAnnotatedItem, container);
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+ }
+
+ @Test
+ public void testScopeSpecifiedAndStereotyped()
+ {
+ Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+ annotations.put(FishStereotype.class, new FishStereotypeBinding());
+ AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
+ ComponentMetaModel<SeaBass> trout = new ComponentMetaModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
+ assert trout.getScopeType().annotationType().equals(RequestScoped.class);
+ }
+
+ @Test
+ public void testMutipleIncompatibleScopeStereotypes()
+ {
+ Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+ annotations.put(FishStereotype.class, new FishStereotypeBinding());
+ annotations.put(AnimalStereotype.class, new AnimalStereotypeBinding());
+ AnnotatedItem annotatedItem = new MutableAnnotatedItem(Haddock.class, annotations);
+
+ boolean exception = false;
+ try
+ {
+ new ComponentMetaModel<Haddock>(new ClassAnnotatedItem(Haddock.class), annotatedItem, container);
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+ }
+
+ @Test
+ public void testMutipleIncompatibleScopeStereotypesWithScopeSpecified()
+ {
+ Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+ annotations.put(FishStereotype.class, new FishStereotypeBinding());
+ annotations.put(AnimalStereotype.class, new AnimalStereotypeBinding());
+ AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
+
+ ComponentMetaModel<SeaBass> trout = new ComponentMetaModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
+ assert trout.getScopeType().annotationType().equals(RequestScoped.class);
+ }
+
+ @Test
+ public void testMutipleCompatibleScopeStereotypes()
+ {
+ Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+ annotations.put(FishStereotype.class, new FishStereotypeBinding());
+ annotations.put(RiverFishStereotype.class, new RiverFishStereotypeBinding());
+ AnnotatedItem annotatedItem = new MutableAnnotatedItem(Haddock.class, annotations);
+
+ ComponentMetaModel<Haddock> haddock = new ComponentMetaModel<Haddock>(new ClassAnnotatedItem(Haddock.class), annotatedItem, container);
+ assert haddock.getScopeType().annotationType().equals(ApplicationScoped.class);
+ }
+
+ // **** TESTS FOR COMPONENT NAME **** /
+
+ @Test
+ public void testNamed()
+ {
+ ComponentMetaModel<Haddock> haddock = new ComponentMetaModel<Haddock>(new ClassAnnotatedItem(Haddock.class), emptyAnnotatedItem, container);
+ assert haddock.getName() != null;
+ haddock.getComponentType().equals(ComponentType.SIMPLE);
+ assert haddock.getName().equals("haddock");
+ }
+
+ @Test
+ public void testXmlNamed()
+ {
+ Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+ annotations.put(Named.class, new NamedBinding()
+ {
+
+ public String value()
+ {
+ return "";
+ }
+ });
+ AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
+ ComponentMetaModel<SeaBass> trout = new ComponentMetaModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
+
+ assert trout.getName() != null;
+ trout.getComponentType().equals(ComponentType.SIMPLE);
+ assert trout.getName().equals("seaBass");
+ }
+
+ @Test
+ public void testNonDefaultXmlNamed()
+ {
+ Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+ annotations.put(Named.class, new NamedBinding()
+ {
+
+ public String value()
+ {
+ return "aTrout";
+ }
+ });
+ AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
+ ComponentMetaModel<SeaBass> trout = new ComponentMetaModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
+
+ assert trout.getName().equals("aTrout");
+ }
+
+ @Test
+ public void testNotNamed()
+ {
+ ComponentMetaModel<SeaBass> trout = new ComponentMetaModel<SeaBass>(new ClassAnnotatedItem(SeaBass.class), emptyAnnotatedItem, container);
+ assert trout.getName() == null;
+ }
+
+ @Test
+ public void testNonDefaultNamed()
+ {
+ ComponentMetaModel<Moose> moose = new ComponentMetaModel<Moose>(new ClassAnnotatedItem(Moose.class), emptyAnnotatedItem, container);
+ assert moose.getName().equals("aMoose");
+ }
+
+
+ // **** TESTS FOR STEREOTYPES **** //
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testStereotypeDeclaredInXmlAndJava()
+ {
+ Map<Class<? extends Annotation>, Annotation> orderXmlAnnotations = new HashMap<Class<? extends Annotation>, Annotation>();
+ orderXmlAnnotations.put(Current.class, new CurrentBinding());
+ orderXmlAnnotations.put(Synchronous.class, new SynchronousBinding());
+ orderXmlAnnotations.put(Named.class, new NamedBinding()
+ {
+ public String value()
+ {
+ return "currentSynchronousOrder";
+ }
+ });
+ AnnotatedItem currentSynchronousOrderAnnotatedItem = new MutableAnnotatedItem(Order.class, orderXmlAnnotations);
+
+ ComponentMetaModel<Order> order = new ComponentMetaModel<Order>(new ClassAnnotatedItem(Order.class), currentSynchronousOrderAnnotatedItem, container);
+ assert Production.class.equals(order.getDeploymentType().annotationType());
+ assert "currentSynchronousOrder".equals(order.getName());
+ assert order.getBindingTypes().size() == 2;
+ assert annotationSetMatches(order.getBindingTypes(), Current.class, Synchronous.class);
+ assert order.getScopeType().annotationType().equals(Dependent.class);
+ }
+
+ @Test
+ public void testSingleStereotype()
+ {
+ ComponentMetaModel<Gorilla> gorilla = new ComponentMetaModel<Gorilla>(new ClassAnnotatedItem(Gorilla.class), emptyAnnotatedItem, container);
+ assert gorilla.getName() == null;
+ assert gorilla.getDeploymentType().annotationType().equals(Production.class);
+ assert gorilla.getBindingTypes().iterator().next().annotationType().equals(Current.class);
+ assert gorilla.getScopeType().annotationType().equals(RequestScoped.class);
+ }
+
+ @Test
+ public void testRequiredTypeIsImplemented()
+ {
+ try
+ {
+ new ComponentMetaModel<Gorilla>(new ClassAnnotatedItem(Gorilla.class), emptyAnnotatedItem, container);
+ }
+ catch (Exception e)
+ {
+ assert false;
+ }
+
+ }
+
+ @Test
+ public void testRequiredTypeIsNotImplemented()
+ {
+ boolean exception = false;
+ try
+ {
+ new ComponentMetaModel<Chair>(new ClassAnnotatedItem(Chair.class), emptyAnnotatedItem, container);
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+
+ }
+
+ @Test
+ public void testScopeIsSupported()
+ {
+ try
+ {
+ new ComponentMetaModel<Goldfish>(new ClassAnnotatedItem(Goldfish.class), emptyAnnotatedItem, container);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ assert false;
+ }
+
+ }
+
+ @Test
+ public void testScopeIsNotSupported()
+ {
+ boolean exception = false;
+ try
+ {
+ new ComponentMetaModel<Carp>(new ClassAnnotatedItem(Carp.class), emptyAnnotatedItem, container);
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+
+ }
+
+ //*** COMPONENT CLASS CHECKS ****//
+
+ @Test
+ public void testAbstractClassIsNotAllowed()
+ {
+ boolean exception = false;
+ try
+ {
+ new ComponentMetaModel<Cow>(new ClassAnnotatedItem(Cow.class), emptyAnnotatedItem, container);
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+ }
+
+ @Test
+ public void testFinalClassMustBeDependentScoped()
+ {
+ boolean exception = false;
+ try
+ {
+ new ComponentMetaModel<Horse>(new ClassAnnotatedItem(Horse.class), emptyAnnotatedItem, container);
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+
+ Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+ annotations.put(Dependent.class, new DependentBinding());
+ AnnotatedItem annotatedItem = new MutableAnnotatedItem(Horse.class, annotations);
+ try
+ {
+ new ComponentMetaModel<Horse>(new ClassAnnotatedItem(Horse.class), annotatedItem, container);
+ }
+ catch (Exception e)
+ {
+ assert false;
+ }
+ }
+
+ @Test
+ public void testClassWithFinalMethodMustBeDependentScoped()
+ {
+ boolean exception = false;
+ try
+ {
+ new ComponentMetaModel<Pig>(new ClassAnnotatedItem(Pig.class), emptyAnnotatedItem, container);
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+
+ Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+ annotations.put(Dependent.class, new DependentBinding());
+ AnnotatedItem annotatedItem = new MutableAnnotatedItem(Pig.class, annotations);
+ try
+ {
+ new ComponentMetaModel<Pig>(new ClassAnnotatedItem(Pig.class), annotatedItem, container);
+ }
+ catch (Exception e)
+ {
+ assert false;
+ }
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentMetaModelTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ConstructorMetaModelTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ConstructorMetaModelTest.java 2008-07-03 01:55:49 UTC (rev 37)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ConstructorMetaModelTest.java 2008-07-03 13:02:30 UTC (rev 38)
@@ -1,9 +1,19 @@
package org.jboss.webbeans.test;
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
import javax.webbeans.Current;
-import org.jboss.webbeans.ConstructorMetaModel;
+import org.jboss.webbeans.ComponentMetaModel;
+import org.jboss.webbeans.ContainerImpl;
+import org.jboss.webbeans.bindings.StandardBinding;
+import org.jboss.webbeans.injectable.ConstructorMetaModel;
import org.jboss.webbeans.test.annotations.Synchronous;
+import org.jboss.webbeans.test.bindings.AnotherDeploymentTypeBinding;
+import org.jboss.webbeans.test.bindings.HornedAnimalDeploymentTypeBinding;
import org.jboss.webbeans.test.components.Chicken;
import org.jboss.webbeans.test.components.Donkey;
import org.jboss.webbeans.test.components.Duck;
@@ -12,65 +22,82 @@
import org.jboss.webbeans.test.components.Order;
import org.jboss.webbeans.test.components.Sheep;
import org.jboss.webbeans.test.components.Turkey;
+import org.jboss.webbeans.test.mock.MockContainerImpl;
+import org.jboss.webbeans.util.AnnotatedItem;
+import org.jboss.webbeans.util.ClassAnnotatedItem;
+import org.jboss.webbeans.util.MutableAnnotatedItem;
+import org.junit.Before;
import org.junit.Test;
public class ConstructorMetaModelTest
{
+ private ContainerImpl container;
+
+ private AnnotatedItem emptyAnnotatedItem;
+
+ @Before
+ public void before()
+ {
+ emptyAnnotatedItem = new MutableAnnotatedItem(null, new HashMap<Class<? extends Annotation>, Annotation>());
+ container = new MockContainerImpl(null);
+
+ }
+
@Test
public void testImplicitConstructor()
{
- ConstructorMetaModel<Order> constructor = new ConstructorMetaModel<Order>(Order.class);
+ ConstructorMetaModel<Order> constructor = new ComponentMetaModel<Order>(new ClassAnnotatedItem(Order.class), emptyAnnotatedItem, container).getConstructor();
assert constructor.getConstructor().getDeclaringClass().equals(Order.class);
assert constructor.getConstructor().getParameterTypes().length == 0;
- assert constructor.getInjectedAttributes().size() == 0;
+ assert constructor.getParameters().size() == 0;
}
@Test
public void testSingleConstructor()
{
- ConstructorMetaModel<Donkey> constructor = new ConstructorMetaModel<Donkey>(Donkey.class);
+ ConstructorMetaModel<Donkey> constructor = new ComponentMetaModel<Donkey>(new ClassAnnotatedItem(Donkey.class), emptyAnnotatedItem, container).getConstructor();
assert constructor.getConstructor().getDeclaringClass().equals(Donkey.class);
assert constructor.getConstructor().getParameterTypes().length == 1;
assert constructor.getConstructor().getParameterTypes()[0].equals(String.class);
- assert constructor.getInjectedAttributes().size() == 1;
- assert constructor.getInjectedAttributes().get(0).getType().equals(String.class);
- assert constructor.getInjectedAttributes().get(0).getBindingTypes().length == 1;
- assert constructor.getInjectedAttributes().get(0).getBindingTypes()[0].annotationType().equals(Current.class);
+ assert constructor.getParameters().size() == 1;
+ assert constructor.getParameters().get(0).getType().equals(String.class);
+ assert constructor.getParameters().get(0).getBindingTypes().length == 1;
+ assert constructor.getParameters().get(0).getBindingTypes()[0].annotationType().equals(Current.class);
}
@Test
public void testInitializerAnnotatedConstructor()
{
- ConstructorMetaModel<Sheep> constructor = new ConstructorMetaModel<Sheep>(Sheep.class);
+ ConstructorMetaModel<Sheep> constructor = new ComponentMetaModel<Sheep>(new ClassAnnotatedItem(Sheep.class), emptyAnnotatedItem, container).getConstructor();
assert constructor.getConstructor().getDeclaringClass().equals(Sheep.class);
assert constructor.getConstructor().getParameterTypes().length == 2;
assert constructor.getConstructor().getParameterTypes()[0].equals(String.class);
assert constructor.getConstructor().getParameterTypes()[1].equals(Double.class);
- assert constructor.getInjectedAttributes().size() == 2;
- assert constructor.getInjectedAttributes().get(0).getType().equals(String.class);
- assert constructor.getInjectedAttributes().get(1).getType().equals(Double.class);
- assert constructor.getInjectedAttributes().get(0).getBindingTypes().length == 1;
- assert constructor.getInjectedAttributes().get(0).getBindingTypes()[0].annotationType().equals(Current.class);
- assert constructor.getInjectedAttributes().get(1).getBindingTypes().length == 1;
- assert constructor.getInjectedAttributes().get(1).getBindingTypes()[0].annotationType().equals(Current.class);
+ assert constructor.getParameters().size() == 2;
+ assert constructor.getParameters().get(0).getType().equals(String.class);
+ assert constructor.getParameters().get(1).getType().equals(Double.class);
+ assert constructor.getParameters().get(0).getBindingTypes().length == 1;
+ assert constructor.getParameters().get(0).getBindingTypes()[0].annotationType().equals(Current.class);
+ assert constructor.getParameters().get(1).getBindingTypes().length == 1;
+ assert constructor.getParameters().get(1).getBindingTypes()[0].annotationType().equals(Current.class);
}
@Test
public void testBindingTypeAnnotatedConstructor()
{
- ConstructorMetaModel<Duck> constructor = new ConstructorMetaModel<Duck>(Duck.class);
+ ConstructorMetaModel<Duck> constructor = new ComponentMetaModel<Duck>(new ClassAnnotatedItem(Duck.class), emptyAnnotatedItem, container).getConstructor();
assert constructor.getConstructor().getDeclaringClass().equals(Duck.class);
assert constructor.getConstructor().getParameterTypes().length == 2;
assert constructor.getConstructor().getParameterTypes()[0].equals(String.class);
assert constructor.getConstructor().getParameterTypes()[1].equals(Integer.class);
- assert constructor.getInjectedAttributes().size() == 2;
- assert constructor.getInjectedAttributes().get(0).getType().equals(String.class);
- assert constructor.getInjectedAttributes().get(1).getType().equals(Integer.class);
- assert constructor.getInjectedAttributes().get(0).getBindingTypes().length == 1;
- assert constructor.getInjectedAttributes().get(0).getBindingTypes()[0].annotationType().equals(Current.class);
- assert constructor.getInjectedAttributes().get(1).getBindingTypes().length == 1;
- assert constructor.getInjectedAttributes().get(1).getBindingTypes()[0].annotationType().equals(Synchronous.class);
+ assert constructor.getParameters().size() == 2;
+ assert constructor.getParameters().get(0).getType().equals(String.class);
+ assert constructor.getParameters().get(1).getType().equals(Integer.class);
+ assert constructor.getParameters().get(0).getBindingTypes().length == 1;
+ assert constructor.getParameters().get(0).getBindingTypes()[0].annotationType().equals(Current.class);
+ assert constructor.getParameters().get(1).getBindingTypes().length == 1;
+ assert constructor.getParameters().get(1).getBindingTypes()[0].annotationType().equals(Synchronous.class);
}
@Test
@@ -79,7 +106,7 @@
boolean exception = false;
try
{
- new ConstructorMetaModel<Chicken>(Chicken.class);
+ new ComponentMetaModel<Chicken>(new ClassAnnotatedItem(Chicken.class), emptyAnnotatedItem, container);
}
catch (Exception e)
{
@@ -95,7 +122,7 @@
boolean exception = false;
try
{
- new ConstructorMetaModel<Turkey>(Turkey.class);
+ new ComponentMetaModel<Turkey>(new ClassAnnotatedItem(Turkey.class), emptyAnnotatedItem, container);
}
catch (Exception e)
{
@@ -111,7 +138,7 @@
boolean exception = false;
try
{
- new ConstructorMetaModel<Goat>(Goat.class);
+ new ComponentMetaModel<Goat>(new ClassAnnotatedItem(Goat.class), emptyAnnotatedItem, container);
}
catch (Exception e)
{
@@ -127,7 +154,7 @@
boolean exception = false;
try
{
- new ConstructorMetaModel<Goose>(Goose.class);
+ new ComponentMetaModel<Goose>(new ClassAnnotatedItem(Goose.class), emptyAnnotatedItem, container);
}
catch (Exception e)
{
Modified: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Goose.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Goose.java 2008-07-03 01:55:49 UTC (rev 37)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Goose.java 2008-07-03 13:02:30 UTC (rev 38)
@@ -3,7 +3,6 @@
import javax.webbeans.Initializer;
import javax.webbeans.Production;
-import org.jboss.webbeans.test.annotations.Asynchronous;
import org.jboss.webbeans.test.annotations.Synchronous;
@Production
15 years, 10 months
[webbeans-commits] Webbeans SVN: r37 - ri/trunk/webbeans-api/src/main/java/javax/webbeans.
by webbeans-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-07-02 21:55:49 -0400 (Wed, 02 Jul 2008)
New Revision: 37
Added:
ri/trunk/webbeans-api/src/main/java/javax/webbeans/ContextNotActive.java
Removed:
ri/trunk/webbeans-api/src/main/java/javax/webbeans/ContextNotActiveException.java
Log:
renamed to correct name as per spec
Added: ri/trunk/webbeans-api/src/main/java/javax/webbeans/ContextNotActive.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/ContextNotActive.java (rev 0)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/ContextNotActive.java 2008-07-03 01:55:49 UTC (rev 37)
@@ -0,0 +1,49 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package javax.webbeans;
+
+/**
+ * This exception is thrown if an invocation is performed on an inactive scope.
+ *
+ * @author Pete Muir
+ * @author Shane Bryzak
+ */
+
+public class ContextNotActive extends RuntimeException
+{
+
+ public ContextNotActive()
+ {
+ }
+
+ public ContextNotActive(String message)
+ {
+ super(message);
+ }
+
+ public ContextNotActive(Throwable cause)
+ {
+ super(cause);
+ }
+
+ public ContextNotActive(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+}
Deleted: ri/trunk/webbeans-api/src/main/java/javax/webbeans/ContextNotActiveException.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/ContextNotActiveException.java 2008-07-01 17:50:29 UTC (rev 36)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/ContextNotActiveException.java 2008-07-03 01:55:49 UTC (rev 37)
@@ -1,47 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-package javax.webbeans;
-
-/**
- *
- * @author Pete Muir
- */
-
-public class ContextNotActiveException extends RuntimeException
-{
-
- public ContextNotActiveException()
- {
- }
-
- public ContextNotActiveException(String message)
- {
- super(message);
- }
-
- public ContextNotActiveException(Throwable cause)
- {
- super(cause);
- }
-
- public ContextNotActiveException(String message, Throwable cause)
- {
- super(message, cause);
- }
-
-}
15 years, 10 months
[webbeans-commits] Webbeans SVN: r36 - in ri/trunk/webbeans-api: .settings and 2 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-07-01 13:50:29 -0400 (Tue, 01 Jul 2008)
New Revision: 36
Modified:
ri/trunk/webbeans-api/.settings/org.eclipse.jdt.ui.prefs
ri/trunk/webbeans-api/pom.xml
ri/trunk/webbeans-api/src/main/java/javax/webbeans/ApplicationScoped.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/BindingType.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/BoundTo.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/Component.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/ComponentInstance.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/Container.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/Context.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/ContextNotActiveException.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/Conversation.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/ConversationScoped.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/Current.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/Decorates.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/Decorator.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/Dependent.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/DeploymentType.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/Destroys.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/Disposes.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/DynamicBinding.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/Event.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/EventBindingType.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/IfExists.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/Initializer.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/InterceptorBindingType.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/Model.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/Named.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/New.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/Observer.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/ObserverException.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/Observes.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/Produces.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/Production.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/RequestScoped.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/ScopeType.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/SessionScoped.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/Specializes.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/Standard.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/Stereotype.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/TypeLiteral.java
ri/trunk/webbeans-api/src/main/resources/web-beans.xsd
Log:
Add licensing
Modified: ri/trunk/webbeans-api/.settings/org.eclipse.jdt.ui.prefs
===================================================================
--- ri/trunk/webbeans-api/.settings/org.eclipse.jdt.ui.prefs 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/.settings/org.eclipse.jdt.ui.prefs 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,5 +1,53 @@
-#Mon Jun 23 17:31:14 BST 2008
+#Tue Jul 01 18:49:14 BST 2008
+cleanup.add_default_serial_version_id=true
+cleanup.add_generated_serial_version_id=false
+cleanup.add_missing_annotations=false
+cleanup.add_missing_deprecated_annotations=true
+cleanup.add_missing_nls_tags=false
+cleanup.add_missing_override_annotations=true
+cleanup.add_serial_version_id=false
+cleanup.always_use_blocks=true
+cleanup.always_use_parentheses_in_expressions=false
+cleanup.always_use_this_for_non_static_field_access=false
+cleanup.always_use_this_for_non_static_method_access=false
+cleanup.convert_to_enhanced_for_loop=false
+cleanup.format_source_code=false
+cleanup.make_local_variable_final=true
+cleanup.make_parameters_final=false
+cleanup.make_private_fields_final=true
+cleanup.make_variable_declarations_final=false
+cleanup.never_use_blocks=false
+cleanup.never_use_parentheses_in_expressions=true
+cleanup.organize_imports=false
+cleanup.qualify_static_field_accesses_with_declaring_class=false
+cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+cleanup.qualify_static_member_accesses_with_declaring_class=false
+cleanup.qualify_static_method_accesses_with_declaring_class=false
+cleanup.remove_private_constructors=true
+cleanup.remove_trailing_whitespaces=false
+cleanup.remove_trailing_whitespaces_all=true
+cleanup.remove_trailing_whitespaces_ignore_empty=false
+cleanup.remove_unnecessary_casts=true
+cleanup.remove_unnecessary_nls_tags=true
+cleanup.remove_unused_imports=true
+cleanup.remove_unused_local_variables=false
+cleanup.remove_unused_private_fields=true
+cleanup.remove_unused_private_members=false
+cleanup.remove_unused_private_methods=true
+cleanup.remove_unused_private_types=true
+cleanup.sort_members=false
+cleanup.sort_members_all=false
+cleanup.use_blocks=false
+cleanup.use_blocks_only_for_return_and_throw=false
+cleanup.use_parentheses_in_expressions=false
+cleanup.use_this_for_non_static_field_access=false
+cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+cleanup.use_this_for_non_static_method_access=false
+cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+cleanup_profile=_WebBeans
+cleanup_settings_version=2
eclipse.preferences.version=1
formatter_profile=_Web Beans
formatter_settings_version=11
-org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates/>
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" delete!
d\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\n* JBoss, Home of Professional Open Source\n* Copyright 2008, Red Hat Middleware LLC, and individual contributors\n* by the @authors tag. See the copyright.txt in the distribution for a\n* full listing of individual contributors.\n*\n* Licensed under the Apache License, Version 2.0 (the "License");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n* http\://www.apache.org/licenses/LICENSE-2.0\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an "AS IS" BASIS, \n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/</template><template autoinsert\="false" context\="t!
ypecomment_context" deleted\="false" description\="Comment for created
types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @author ${user}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false"!
description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_conte!
xt" deleted\="false" description\="Code in new enum type bodies" enabl
ed\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" descr!
iption\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
Modified: ri/trunk/webbeans-api/pom.xml
===================================================================
--- ri/trunk/webbeans-api/pom.xml 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/pom.xml 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+JBoss, Home of Professional Open Source
+Copyright 2008, Red Hat Middleware LLC, and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/ApplicationScoped.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/ApplicationScoped.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/ApplicationScoped.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.METHOD;
@@ -10,6 +27,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Target( { METHOD, FIELD, PARAMETER, TYPE })
@Retention(RUNTIME)
@Documented
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/BindingType.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/BindingType.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/BindingType.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.TYPE;
@@ -7,6 +24,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Target(TYPE)
@Retention(RUNTIME)
@Documented
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/BoundTo.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/BoundTo.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/BoundTo.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.TYPE;
@@ -7,6 +24,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Target(TYPE)
@Retention(RUNTIME)
@Documented
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/Component.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/Component.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/Component.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.METHOD;
@@ -8,6 +25,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Production
@Stereotype
@Target( { TYPE, METHOD })
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/ComponentInstance.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/ComponentInstance.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/ComponentInstance.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import java.lang.annotation.Annotation;
@@ -4,9 +21,10 @@
import java.util.Set;
/**
- * Argh, this is not the name in the spec but then we have two classes called
- * Component
+ *
+ * @author Pete Muir
*/
+
public abstract class ComponentInstance<T>
{
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/Container.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/Container.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/Container.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import java.lang.annotation.Annotation;
@@ -3,4 +20,9 @@
import java.util.Set;
+/**
+ *
+ * @author Pete Muir
+ */
+
public interface Container
{
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/Context.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/Context.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/Context.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import java.lang.annotation.Annotation;
@@ -2,2 +19,7 @@
+/**
+ *
+ * @author Pete Muir
+ */
+
public interface Context
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/ContextNotActiveException.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/ContextNotActiveException.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/ContextNotActiveException.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,5 +1,27 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
+/**
+ *
+ * @author Pete Muir
+ */
+
public class ContextNotActiveException extends RuntimeException
{
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/Conversation.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/Conversation.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/Conversation.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,5 +1,27 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
+/**
+ *
+ * @author Pete Muir
+ */
+
public interface Conversation
{
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/ConversationScoped.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/ConversationScoped.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/ConversationScoped.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.METHOD;
@@ -10,6 +27,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Target( { METHOD, FIELD, PARAMETER, TYPE })
@Retention(RUNTIME)
@Documented
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/Current.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/Current.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/Current.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,6 +1,24 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@@ -8,7 +26,12 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
-@Target( { TYPE, METHOD })
+/**
+ *
+ * @author Pete Muir
+ */
+
+@Target( { TYPE, METHOD, PARAMETER })
@Retention(RUNTIME)
@Documented
@BindingType
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/Decorates.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/Decorates.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/Decorates.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.FIELD;
@@ -7,6 +24,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Target(FIELD)
@Retention(RUNTIME)
@Documented
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/Decorator.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/Decorator.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/Decorator.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.TYPE;
@@ -7,6 +24,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Target(TYPE)
@Retention(RUNTIME)
@Documented
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/Dependent.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/Dependent.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/Dependent.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.METHOD;
@@ -10,6 +27,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Target( { METHOD, FIELD, PARAMETER, TYPE })
@Retention(RUNTIME)
@Documented
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/DeploymentType.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/DeploymentType.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/DeploymentType.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.TYPE;
@@ -7,6 +24,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Target(TYPE)
@Retention(RUNTIME)
@Documented
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/Destroys.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/Destroys.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/Destroys.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.METHOD;
@@ -7,6 +24,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Target(METHOD)
@Retention(RUNTIME)
@Documented
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/Disposes.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/Disposes.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/Disposes.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.PARAMETER;
@@ -7,6 +24,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Target(PARAMETER)
@Retention(RUNTIME)
@Documented
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/DynamicBinding.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/DynamicBinding.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/DynamicBinding.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import java.lang.annotation.Annotation;
@@ -4,6 +21,11 @@
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
+/**
+ *
+ * @author Pete Muir
+ */
+
public abstract class DynamicBinding<T extends Annotation> implements Annotation
{
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/Event.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/Event.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/Event.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import java.lang.annotation.Annotation;
@@ -2,2 +19,7 @@
+/**
+ *
+ * @author Pete Muir
+ */
+
public interface Event<T>
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/EventBindingType.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/EventBindingType.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/EventBindingType.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.TYPE;
@@ -7,6 +24,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Target(TYPE)
@Retention(RUNTIME)
@Documented
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/IfExists.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/IfExists.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/IfExists.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.PARAMETER;
@@ -7,6 +24,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Target(PARAMETER)
@Retention(RUNTIME)
@Documented
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/Initializer.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/Initializer.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/Initializer.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.METHOD;
@@ -8,6 +25,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Target({METHOD,CONSTRUCTOR})
@Retention(RUNTIME)
@Documented
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/InterceptorBindingType.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/InterceptorBindingType.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/InterceptorBindingType.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.TYPE;
@@ -7,6 +24,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Target(TYPE)
@Retention(RUNTIME)
@Documented
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/Model.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/Model.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/Model.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.METHOD;
@@ -8,6 +25,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Named
@RequestScoped
@Production
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/Named.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/Named.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/Named.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.METHOD;
@@ -8,6 +25,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Target( { TYPE, METHOD })
@Retention(RUNTIME)
@Documented
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/New.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/New.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/New.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.FIELD;
@@ -10,6 +27,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Target( { METHOD, FIELD, PARAMETER, TYPE })
@Retention(RUNTIME)
@Documented
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/Observer.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/Observer.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/Observer.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import java.lang.annotation.Annotation;
@@ -3,4 +20,9 @@
import java.util.Set;
+/**
+ *
+ * @author Pete Muir
+ */
+
public interface Observer<T>
{
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/ObserverException.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/ObserverException.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/ObserverException.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,5 +1,27 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
+/**
+ *
+ * @author Pete Muir
+ */
+
public class ObserverException extends RuntimeException
{
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/Observes.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/Observes.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/Observes.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.PARAMETER;
@@ -7,6 +24,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Target(PARAMETER)
@Retention(RUNTIME)
@Documented
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/Produces.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/Produces.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/Produces.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.METHOD;
@@ -7,6 +24,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Target(METHOD)
@Retention(RUNTIME)
@Documented
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/Production.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/Production.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/Production.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.METHOD;
@@ -8,6 +25,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Target( { TYPE, METHOD })
@Retention(RUNTIME)
@Documented
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/RequestScoped.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/RequestScoped.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/RequestScoped.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.METHOD;
@@ -10,6 +27,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Target( { METHOD, FIELD, PARAMETER, TYPE })
@Retention(RUNTIME)
@Documented
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/ScopeType.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/ScopeType.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/ScopeType.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.TYPE;
@@ -7,6 +24,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Target(TYPE)
@Retention(RUNTIME)
@Documented
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/SessionScoped.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/SessionScoped.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/SessionScoped.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.METHOD;
@@ -10,6 +27,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Target( { METHOD, FIELD, PARAMETER, TYPE })
@Retention(RUNTIME)
@Documented
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/Specializes.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/Specializes.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/Specializes.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.METHOD;
@@ -8,6 +25,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Target( { TYPE, METHOD })
@Retention(RUNTIME)
@Documented
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/Standard.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/Standard.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/Standard.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.METHOD;
@@ -8,6 +25,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Target( { TYPE, METHOD })
@Retention(RUNTIME)
@Documented
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/Stereotype.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/Stereotype.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/Stereotype.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,3 +1,20 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
import static java.lang.annotation.ElementType.TYPE;
@@ -8,6 +25,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ * @author Pete Muir
+ */
+
@Target(TYPE)
@Retention(RUNTIME)
@Documented
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/TypeLiteral.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/TypeLiteral.java 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/TypeLiteral.java 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,5 +1,27 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package javax.webbeans;
+/**
+ *
+ * @author Pete Muir
+ */
+
public class TypeLiteral<T>
{
Modified: ri/trunk/webbeans-api/src/main/resources/web-beans.xsd
===================================================================
--- ri/trunk/webbeans-api/src/main/resources/web-beans.xsd 2008-07-01 17:29:49 UTC (rev 35)
+++ ri/trunk/webbeans-api/src/main/resources/web-beans.xsd 2008-07-01 17:50:29 UTC (rev 36)
@@ -1,4 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+JBoss, Home of Professional Open Source
+Copyright 2008, Red Hat Middleware LLC, and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
targetNamespace="http://seamframework.org/WebBeans"
15 years, 10 months
[webbeans-commits] Webbeans SVN: r35 - in ri/trunk/webbeans-impl/src: test/java/org/jboss/webbeans/test and 2 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-07-01 13:29:49 -0400 (Tue, 01 Jul 2008)
New Revision: 35
Added:
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ConstructorMetaModelTest.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Chicken.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Donkey.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Duck.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Goat.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Goose.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/SeaBass.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Sheep.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Turkey.java
Removed:
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Trout.java
Modified:
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/LoggerUtil.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/Reflections.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentInstanceTest.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/Asynchronous.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/Synchronous.java
Log:
Tests and fixes for chapter 3.1, no support for @Specializes yet
Modified: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/LoggerUtil.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/LoggerUtil.java 2008-07-01 17:28:51 UTC (rev 34)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/LoggerUtil.java 2008-07-01 17:29:49 UTC (rev 35)
@@ -1,16 +1,21 @@
package org.jboss.webbeans.util;
import java.util.logging.Filter;
+import java.util.logging.Handler;
+import java.util.logging.Level;
import java.util.logging.Logger;
public class LoggerUtil
{
public static final String FILTER_PROPERTY = "org.jboss.webbeans.logger.filter";
+ public static final String LEVEL_PROPERTY = "org.jboss.webbeans.logger.level";
public static final String WEBBEANS_LOGGER = "javax.webbeans.";
private static Filter filter;
+
+ private static Level level;
static
{
@@ -24,14 +29,34 @@
{
throw new IllegalArgumentException("Unable to instantiate logging filter");
}
+ String levelProperty = System.getProperty(LEVEL_PROPERTY);
+ if (levelProperty != null && !"".equals(levelProperty))
+ {
+ level = Level.parse(levelProperty);
+ }
+ if (level != null)
+ {
+ for (Handler handler : Logger.getLogger("").getHandlers())
+ {
+ handler.setLevel(level);
+ }
+ }
+
}
public static Logger getLogger(String name)
{
name = WEBBEANS_LOGGER + name;
Logger logger = Logger.getLogger(name);
- logger.setFilter(filter);
+ if (filter != null)
+ {
+ logger.setFilter(filter);
+ }
+ if (level != null)
+ {
+ logger.setLevel(level);
+ }
return logger;
}
Modified: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/Reflections.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/Reflections.java 2008-07-01 17:28:51 UTC (rev 34)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/Reflections.java 2008-07-01 17:29:49 UTC (rev 35)
@@ -66,7 +66,7 @@
public static <T> List<Constructor<T>> getConstructors(Class<? extends T> clazz, Class<? extends Annotation> annotationType)
{
List<Constructor<T>> constructors = new ArrayList<Constructor<T>>();
- for (Constructor<T> constructor : constructors)
+ for (Constructor<T> constructor : clazz.getConstructors())
{
if (constructor.isAnnotationPresent(annotationType))
{
@@ -79,7 +79,7 @@
public static <T> List<Constructor<T>> getConstructorsForAnnotatedParameter(Class<? extends T> clazz, Class<? extends Annotation> parameterAnnotationType)
{
List<Constructor<T>> constructors = new ArrayList<Constructor<T>>();
- for (Constructor<T> constructor : constructors)
+ for (Constructor<T> constructor : clazz.getConstructors())
{
for (Annotation[] annotations : constructor.getParameterAnnotations())
{
@@ -98,7 +98,7 @@
public static <T> List<Constructor<T>> getConstructorsForMetaAnnotatedParameter(Class<? extends T> clazz, Class<? extends Annotation> metaAnnotationType)
{
List<Constructor<T>> constructors = new ArrayList<Constructor<T>>();
- for (Constructor<T> constructor : constructors)
+ for (Constructor<T> constructor : clazz.getConstructors())
{
for (Annotation[] annotations : constructor.getParameterAnnotations())
{
Modified: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentInstanceTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentInstanceTest.java 2008-07-01 17:28:51 UTC (rev 34)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentInstanceTest.java 2008-07-01 17:29:49 UTC (rev 35)
@@ -20,6 +20,7 @@
import org.jboss.webbeans.ComponentInstanceImpl;
import org.jboss.webbeans.ContainerImpl;
import org.jboss.webbeans.StereotypeMetaModel;
+import org.jboss.webbeans.ComponentInstanceImpl.ComponentType;
import org.jboss.webbeans.bindings.ConversationScopedBinding;
import org.jboss.webbeans.bindings.CurrentBinding;
import org.jboss.webbeans.bindings.DependentBinding;
@@ -58,7 +59,7 @@
import org.jboss.webbeans.test.components.Moose;
import org.jboss.webbeans.test.components.Order;
import org.jboss.webbeans.test.components.Pig;
-import org.jboss.webbeans.test.components.Trout;
+import org.jboss.webbeans.test.components.SeaBass;
import org.jboss.webbeans.test.components.Tuna;
import org.jboss.webbeans.test.mock.MockContainerImpl;
import org.jboss.webbeans.util.AnnotatedItem;
@@ -204,7 +205,7 @@
@Test
public void testScopeDeclaredInJava()
{
- ComponentInstance<Trout> trout = new ComponentInstanceImpl<Trout>(new ClassAnnotatedItem(Trout.class), emptyAnnotatedItem, container);
+ ComponentInstance<SeaBass> trout = new ComponentInstanceImpl<SeaBass>(new ClassAnnotatedItem(SeaBass.class), emptyAnnotatedItem, container);
assert trout.getScopeType().annotationType().equals(RequestScoped.class);
}
@@ -224,8 +225,8 @@
{
Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
annotations.put(ConversationScoped.class, new ConversationScopedBinding());
- AnnotatedItem annotatedItem = new MutableAnnotatedItem(Trout.class, annotations);
- ComponentInstance<Trout> trout = new ComponentInstanceImpl<Trout>(new ClassAnnotatedItem(Trout.class), annotatedItem, container);
+ AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
+ ComponentInstance<SeaBass> trout = new ComponentInstanceImpl<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
assert trout.getScopeType().annotationType().equals(ConversationScoped.class);
}
@@ -233,9 +234,9 @@
public void testScopeMissingInXml()
{
Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
- AnnotatedItem annotatedItem = new MutableAnnotatedItem(Trout.class, annotations);
+ AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
- ComponentInstance<Trout> trout = new ComponentInstanceImpl<Trout>(new ClassAnnotatedItem(Trout.class), annotatedItem, container);
+ ComponentInstance<SeaBass> trout = new ComponentInstanceImpl<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
assert trout.getScopeType().annotationType().equals(RequestScoped.class);
}
@@ -285,8 +286,8 @@
{
Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
annotations.put(FishStereotype.class, new FishStereotypeBinding());
- AnnotatedItem annotatedItem = new MutableAnnotatedItem(Trout.class, annotations);
- ComponentInstance<Trout> trout = new ComponentInstanceImpl<Trout>(new ClassAnnotatedItem(Trout.class), annotatedItem, container);
+ AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
+ ComponentInstance<SeaBass> trout = new ComponentInstanceImpl<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
assert trout.getScopeType().annotationType().equals(RequestScoped.class);
}
@@ -316,9 +317,9 @@
Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
annotations.put(FishStereotype.class, new FishStereotypeBinding());
annotations.put(AnimalStereotype.class, new AnimalStereotypeBinding());
- AnnotatedItem annotatedItem = new MutableAnnotatedItem(Trout.class, annotations);
+ AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
- ComponentInstance<Trout> trout = new ComponentInstanceImpl<Trout>(new ClassAnnotatedItem(Trout.class), annotatedItem, container);
+ ComponentInstance<SeaBass> trout = new ComponentInstanceImpl<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
assert trout.getScopeType().annotationType().equals(RequestScoped.class);
}
@@ -339,9 +340,10 @@
@Test
public void testNamed()
{
- ComponentInstance<Haddock> haddock = new ComponentInstanceImpl<Haddock>(new ClassAnnotatedItem(Haddock.class), emptyAnnotatedItem, container);
+ ComponentInstanceImpl<Haddock> haddock = new ComponentInstanceImpl<Haddock>(new ClassAnnotatedItem(Haddock.class), emptyAnnotatedItem, container);
assert haddock.getName() != null;
- // TODO Test naming algorithms
+ haddock.getComponentType().equals(ComponentType.SIMPLE);
+ assert haddock.getName().equals("haddock");
}
@Test
@@ -356,11 +358,12 @@
return "";
}
});
- AnnotatedItem annotatedItem = new MutableAnnotatedItem(Trout.class, annotations);
- ComponentInstance<Trout> trout = new ComponentInstanceImpl<Trout>(new ClassAnnotatedItem(Trout.class), annotatedItem, container);
+ AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
+ ComponentInstanceImpl<SeaBass> trout = new ComponentInstanceImpl<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
assert trout.getName() != null;
- // TODO Test naming algorithms
+ trout.getComponentType().equals(ComponentType.SIMPLE);
+ assert trout.getName().equals("seaBass");
}
@Test
@@ -375,8 +378,8 @@
return "aTrout";
}
});
- AnnotatedItem annotatedItem = new MutableAnnotatedItem(Trout.class, annotations);
- ComponentInstance<Trout> trout = new ComponentInstanceImpl<Trout>(new ClassAnnotatedItem(Trout.class), annotatedItem, container);
+ AnnotatedItem annotatedItem = new MutableAnnotatedItem(SeaBass.class, annotations);
+ ComponentInstance<SeaBass> trout = new ComponentInstanceImpl<SeaBass>(new ClassAnnotatedItem(SeaBass.class), annotatedItem, container);
assert trout.getName().equals("aTrout");
}
@@ -384,7 +387,7 @@
@Test
public void testNotNamed()
{
- ComponentInstance<Trout> trout = new ComponentInstanceImpl<Trout>(new ClassAnnotatedItem(Trout.class), emptyAnnotatedItem, container);
+ ComponentInstance<SeaBass> trout = new ComponentInstanceImpl<SeaBass>(new ClassAnnotatedItem(SeaBass.class), emptyAnnotatedItem, container);
assert trout.getName() == null;
}
@@ -493,6 +496,8 @@
}
+ //*** COMPONENT CLASS CHECKS ****//
+
@Test
public void testAbstractClassIsNotAllowed()
{
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ConstructorMetaModelTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ConstructorMetaModelTest.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ConstructorMetaModelTest.java 2008-07-01 17:29:49 UTC (rev 35)
@@ -0,0 +1,140 @@
+package org.jboss.webbeans.test;
+
+import javax.webbeans.Current;
+
+import org.jboss.webbeans.ConstructorMetaModel;
+import org.jboss.webbeans.test.annotations.Synchronous;
+import org.jboss.webbeans.test.components.Chicken;
+import org.jboss.webbeans.test.components.Donkey;
+import org.jboss.webbeans.test.components.Duck;
+import org.jboss.webbeans.test.components.Goat;
+import org.jboss.webbeans.test.components.Goose;
+import org.jboss.webbeans.test.components.Order;
+import org.jboss.webbeans.test.components.Sheep;
+import org.jboss.webbeans.test.components.Turkey;
+import org.junit.Test;
+
+public class ConstructorMetaModelTest
+{
+
+ @Test
+ public void testImplicitConstructor()
+ {
+ ConstructorMetaModel<Order> constructor = new ConstructorMetaModel<Order>(Order.class);
+ assert constructor.getConstructor().getDeclaringClass().equals(Order.class);
+ assert constructor.getConstructor().getParameterTypes().length == 0;
+ assert constructor.getInjectedAttributes().size() == 0;
+ }
+
+ @Test
+ public void testSingleConstructor()
+ {
+ ConstructorMetaModel<Donkey> constructor = new ConstructorMetaModel<Donkey>(Donkey.class);
+ assert constructor.getConstructor().getDeclaringClass().equals(Donkey.class);
+ assert constructor.getConstructor().getParameterTypes().length == 1;
+ assert constructor.getConstructor().getParameterTypes()[0].equals(String.class);
+ assert constructor.getInjectedAttributes().size() == 1;
+ assert constructor.getInjectedAttributes().get(0).getType().equals(String.class);
+ assert constructor.getInjectedAttributes().get(0).getBindingTypes().length == 1;
+ assert constructor.getInjectedAttributes().get(0).getBindingTypes()[0].annotationType().equals(Current.class);
+ }
+
+ @Test
+ public void testInitializerAnnotatedConstructor()
+ {
+ ConstructorMetaModel<Sheep> constructor = new ConstructorMetaModel<Sheep>(Sheep.class);
+ assert constructor.getConstructor().getDeclaringClass().equals(Sheep.class);
+ assert constructor.getConstructor().getParameterTypes().length == 2;
+ assert constructor.getConstructor().getParameterTypes()[0].equals(String.class);
+ assert constructor.getConstructor().getParameterTypes()[1].equals(Double.class);
+ assert constructor.getInjectedAttributes().size() == 2;
+ assert constructor.getInjectedAttributes().get(0).getType().equals(String.class);
+ assert constructor.getInjectedAttributes().get(1).getType().equals(Double.class);
+ assert constructor.getInjectedAttributes().get(0).getBindingTypes().length == 1;
+ assert constructor.getInjectedAttributes().get(0).getBindingTypes()[0].annotationType().equals(Current.class);
+ assert constructor.getInjectedAttributes().get(1).getBindingTypes().length == 1;
+ assert constructor.getInjectedAttributes().get(1).getBindingTypes()[0].annotationType().equals(Current.class);
+ }
+
+ @Test
+ public void testBindingTypeAnnotatedConstructor()
+ {
+ ConstructorMetaModel<Duck> constructor = new ConstructorMetaModel<Duck>(Duck.class);
+ assert constructor.getConstructor().getDeclaringClass().equals(Duck.class);
+ assert constructor.getConstructor().getParameterTypes().length == 2;
+ assert constructor.getConstructor().getParameterTypes()[0].equals(String.class);
+ assert constructor.getConstructor().getParameterTypes()[1].equals(Integer.class);
+ assert constructor.getInjectedAttributes().size() == 2;
+ assert constructor.getInjectedAttributes().get(0).getType().equals(String.class);
+ assert constructor.getInjectedAttributes().get(1).getType().equals(Integer.class);
+ assert constructor.getInjectedAttributes().get(0).getBindingTypes().length == 1;
+ assert constructor.getInjectedAttributes().get(0).getBindingTypes()[0].annotationType().equals(Current.class);
+ assert constructor.getInjectedAttributes().get(1).getBindingTypes().length == 1;
+ assert constructor.getInjectedAttributes().get(1).getBindingTypes()[0].annotationType().equals(Synchronous.class);
+ }
+
+ @Test
+ public void testTooManyInitializerAnnotatedConstructor()
+ {
+ boolean exception = false;
+ try
+ {
+ new ConstructorMetaModel<Chicken>(Chicken.class);
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+
+ }
+
+ @Test
+ public void testTooManyConstructors()
+ {
+ boolean exception = false;
+ try
+ {
+ new ConstructorMetaModel<Turkey>(Turkey.class);
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+
+ }
+
+ @Test
+ public void testTooManyBindingTypeAnnotatedConstructor()
+ {
+ boolean exception = false;
+ try
+ {
+ new ConstructorMetaModel<Goat>(Goat.class);
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+
+ }
+
+ @Test
+ public void testBindingTypeAndInitializerAnnotatedConstructor()
+ {
+ boolean exception = false;
+ try
+ {
+ new ConstructorMetaModel<Goose>(Goose.class);
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ConstructorMetaModelTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/Asynchronous.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/Asynchronous.java 2008-07-01 17:28:51 UTC (rev 34)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/Asynchronous.java 2008-07-01 17:29:49 UTC (rev 35)
@@ -1,6 +1,7 @@
package org.jboss.webbeans.test.annotations;
import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@@ -10,7 +11,7 @@
import javax.webbeans.BindingType;
-@Target( { TYPE, METHOD })
+@Target( { TYPE, METHOD, PARAMETER })
@Retention(RUNTIME)
@Documented
@BindingType
Modified: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/Synchronous.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/Synchronous.java 2008-07-01 17:28:51 UTC (rev 34)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/Synchronous.java 2008-07-01 17:29:49 UTC (rev 35)
@@ -1,6 +1,7 @@
package org.jboss.webbeans.test.annotations;
import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@@ -10,7 +11,7 @@
import javax.webbeans.BindingType;
-@Target( { TYPE, METHOD })
+@Target( { TYPE, METHOD, PARAMETER })
@Retention(RUNTIME)
@Documented
@BindingType
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Chicken.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Chicken.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Chicken.java 2008-07-01 17:29:49 UTC (rev 35)
@@ -0,0 +1,21 @@
+package org.jboss.webbeans.test.components;
+
+import javax.webbeans.Initializer;
+import javax.webbeans.Production;
+
+@Production
+public class Chicken
+{
+
+ @Initializer
+ public Chicken(String foo)
+ {
+ }
+
+ @Initializer
+ public Chicken(String foo, Double bar)
+ {
+
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Chicken.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Donkey.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Donkey.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Donkey.java 2008-07-01 17:29:49 UTC (rev 35)
@@ -0,0 +1,14 @@
+package org.jboss.webbeans.test.components;
+
+import javax.webbeans.Production;
+
+@Production
+public class Donkey
+{
+
+ public Donkey(String foo)
+ {
+
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Donkey.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Duck.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Duck.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Duck.java 2008-07-01 17:29:49 UTC (rev 35)
@@ -0,0 +1,21 @@
+package org.jboss.webbeans.test.components;
+
+import javax.webbeans.Production;
+
+import org.jboss.webbeans.test.annotations.Synchronous;
+
+@Production
+public class Duck
+{
+
+ public Duck(String foo)
+ {
+ // TODO Auto-generated constructor stub
+ }
+
+ public Duck(String foo, @Synchronous Integer bar)
+ {
+
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Duck.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Goat.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Goat.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Goat.java 2008-07-01 17:29:49 UTC (rev 35)
@@ -0,0 +1,23 @@
+package org.jboss.webbeans.test.components;
+
+import javax.webbeans.Production;
+
+import org.jboss.webbeans.test.annotations.Asynchronous;
+import org.jboss.webbeans.test.annotations.Synchronous;
+
+@Production
+public class Goat
+{
+
+ public Goat(@Synchronous String foo)
+ {
+ // TODO Auto-generated constructor stub
+ }
+
+ public Goat(@Asynchronous String foo, String bar)
+ {
+ // TODO Auto-generated constructor stub
+ }
+
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Goat.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Goose.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Goose.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Goose.java 2008-07-01 17:29:49 UTC (rev 35)
@@ -0,0 +1,25 @@
+package org.jboss.webbeans.test.components;
+
+import javax.webbeans.Initializer;
+import javax.webbeans.Production;
+
+import org.jboss.webbeans.test.annotations.Asynchronous;
+import org.jboss.webbeans.test.annotations.Synchronous;
+
+@Production
+public class Goose
+{
+
+ public Goose(@Synchronous String foo)
+ {
+ // TODO Auto-generated constructor stub
+ }
+
+ @Initializer
+ public Goose(String foo, String bar)
+ {
+ // TODO Auto-generated constructor stub
+ }
+
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Goose.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/SeaBass.java (from rev 21, ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Trout.java)
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/SeaBass.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/SeaBass.java 2008-07-01 17:29:49 UTC (rev 35)
@@ -0,0 +1,11 @@
+package org.jboss.webbeans.test.components;
+
+import javax.webbeans.Production;
+import javax.webbeans.RequestScoped;
+
+@Production
+@RequestScoped
+public class SeaBass implements Animal
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/SeaBass.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Sheep.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Sheep.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Sheep.java 2008-07-01 17:29:49 UTC (rev 35)
@@ -0,0 +1,22 @@
+package org.jboss.webbeans.test.components;
+
+import javax.webbeans.Initializer;
+import javax.webbeans.Production;
+
+@Production
+public class Sheep
+{
+
+
+ public Sheep(String foo)
+ {
+
+ }
+
+ @Initializer
+ public Sheep(String foo, Double bar)
+ {
+
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Sheep.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Trout.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Trout.java 2008-07-01 17:28:51 UTC (rev 34)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Trout.java 2008-07-01 17:29:49 UTC (rev 35)
@@ -1,11 +0,0 @@
-package org.jboss.webbeans.test.components;
-
-import javax.webbeans.Production;
-import javax.webbeans.RequestScoped;
-
-@Production
-@RequestScoped
-public class Trout implements Animal
-{
-
-}
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Turkey.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Turkey.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Turkey.java 2008-07-01 17:29:49 UTC (rev 35)
@@ -0,0 +1,19 @@
+package org.jboss.webbeans.test.components;
+
+import javax.webbeans.Production;
+
+@Production
+public class Turkey
+{
+
+ public Turkey(String foo)
+ {
+
+ }
+
+ public Turkey(String foo, Integer bar)
+ {
+
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Turkey.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 10 months
[webbeans-commits] Webbeans SVN: r34 - ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-07-01 13:28:51 -0400 (Tue, 01 Jul 2008)
New Revision: 34
Modified:
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ConstructorMetaModel.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/InjectedParameterMetaModel.java
Log:
Tests and fixes for chapter 3.1, no support for @Specializes yet
Modified: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java 2008-07-01 17:25:14 UTC (rev 33)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java 2008-07-01 17:28:51 UTC (rev 34)
@@ -1,6 +1,7 @@
package org.jboss.webbeans;
import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
@@ -345,9 +346,9 @@
{
if (ComponentType.SIMPLE.equals(componentType))
{
- name = Strings.decapitalize(type.getName());
+ name = Strings.decapitalize(type.getSimpleName());
}
- log.finest("Default name is TODO" );
+ log.finest("Default name of " + type + " is " + name );
}
return name;
}
@@ -408,6 +409,14 @@
return scopeType;
}
+ public ConstructorMetaModel<T> getConstructor()
+ {
+ return constructor;
+ }
+ public ComponentType getComponentType()
+ {
+ return componentType;
+ }
}
Modified: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ConstructorMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ConstructorMetaModel.java 2008-07-01 17:25:14 UTC (rev 33)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ConstructorMetaModel.java 2008-07-01 17:28:51 UTC (rev 34)
@@ -3,6 +3,7 @@
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.List;
+import java.util.logging.Level;
import java.util.logging.Logger;
import javax.webbeans.BindingType;
@@ -17,6 +18,8 @@
public static final String LOGGER_NAME = "componentConstructor";
+
+
private static Logger log = LoggerUtil.getLogger(LOGGER_NAME);
private Constructor<T> constructor;
@@ -34,9 +37,10 @@
}
else if (type.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);
if ((initializerAnnotatedConstructors.size() + bindingTypeAnnotatedConstructors.size()) > 1)
{
if (initializerAnnotatedConstructors.size() > 1)
@@ -68,9 +72,14 @@
else if (type.getConstructors().length == 0)
{
this.constructor = (Constructor<T>) Reflections.getConstructor(type);
- log.finest("No constructor defined, using implicit no arguement constructor");
+ log.finest("No constructor defined, using implicit no arguement constructor for " + type);
}
+ if (this.constructor == null)
+ {
+ throw new RuntimeException("Cannot determine constructor to use for " + type);
+ }
+
for (int i = 0; i < constructor.getParameterTypes().length; i++)
{
if (constructor.getParameterAnnotations()[i].length > 0)
@@ -85,10 +94,7 @@
}
}
log.finest("Initialized metadata for " + constructor + " with injectable parameters " + injectedParameters);
- if (this.constructor == null)
- {
- throw new RuntimeException("Cannot determine constructor to use");
- }
+
}
public Constructor<T> getConstructor()
Modified: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/InjectedParameterMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/InjectedParameterMetaModel.java 2008-07-01 17:25:14 UTC (rev 33)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/InjectedParameterMetaModel.java 2008-07-01 17:28:51 UTC (rev 34)
@@ -2,9 +2,13 @@
import java.lang.annotation.Annotation;
+import org.jboss.webbeans.bindings.CurrentBinding;
+
public class InjectedParameterMetaModel extends AbstractInjectedThingMetaModel
{
+ private static Annotation[] currentBinding = {new CurrentBinding()};
+
private Class<?> type;
public InjectedParameterMetaModel(Annotation[] bindingTypes, Class<?> type)
@@ -15,7 +19,7 @@
public InjectedParameterMetaModel(Class<?> type)
{
- super();
+ super(currentBinding);
this.type = type;
}
15 years, 10 months
[webbeans-commits] Webbeans SVN: r33 - ri/trunk/webbeans-api/src/main/java/javax/webbeans.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-07-01 13:25:14 -0400 (Tue, 01 Jul 2008)
New Revision: 33
Modified:
ri/trunk/webbeans-api/src/main/java/javax/webbeans/Initializer.java
Log:
Allow Initializer on constructor
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/Initializer.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/Initializer.java 2008-07-01 14:05:30 UTC (rev 32)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/Initializer.java 2008-07-01 17:25:14 UTC (rev 33)
@@ -1,13 +1,14 @@
package javax.webbeans;
import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
-@Target(METHOD)
+@Target({METHOD,CONSTRUCTOR})
@Retention(RUNTIME)
@Documented
public @interface Initializer
15 years, 10 months
[webbeans-commits] Webbeans SVN: r32 - ri/trunk/webbeans-impl.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-07-01 10:05:30 -0400 (Tue, 01 Jul 2008)
New Revision: 32
Modified:
ri/trunk/webbeans-impl/pom.xml
Log:
switch to cobertura
Modified: ri/trunk/webbeans-impl/pom.xml
===================================================================
--- ri/trunk/webbeans-impl/pom.xml 2008-07-01 14:04:56 UTC (rev 31)
+++ ri/trunk/webbeans-impl/pom.xml 2008-07-01 14:05:30 UTC (rev 32)
@@ -25,24 +25,5 @@
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>emma-maven-plugin</artifactId>
- <inherited>true</inherited>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <forkMode>always</forkMode>
- <reportFormat>xml</reportFormat>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
</project>
\ No newline at end of file
15 years, 10 months
[webbeans-commits] Webbeans SVN: r31 - ri/trunk.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-07-01 10:04:56 -0400 (Tue, 01 Jul 2008)
New Revision: 31
Modified:
ri/trunk/pom.xml
Log:
switch to cobertura for coverage
Modified: ri/trunk/pom.xml
===================================================================
--- ri/trunk/pom.xml 2008-07-01 12:54:48 UTC (rev 30)
+++ ri/trunk/pom.xml 2008-07-01 14:04:56 UTC (rev 31)
@@ -9,9 +9,11 @@
<version>1.0.0-SNAPSHOT</version>
<name>Web Beans</name>
<url>http://www.seamframework.org/WebBeans</url>
-
- <description>The reference implementation of JSR 299: Web Beans</description>
-
+
+ <description>
+ The reference implementation of JSR 299: Web Beans
+ </description>
+
<developers>
<developer>
<name>Pete Muir</name>
@@ -22,15 +24,15 @@
<organization>JBoss, a division of Red Hat</organization>
<url>http://in.relation.to/Bloggers/Pete</url>
</developer>
-
+
<developer>
<name>Shane Bryzak</name>
<organization>JBoss, a division of Red Hat</organization>
</developer>
</developers>
-
-
+
+
<pluginRepositories>
<pluginRepository>
<id>snapshots.repository.codehaus.org</id>
@@ -80,38 +82,47 @@
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
- <artifactId>emma-maven-plugin</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ <version>2.0</version>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkMode>always</forkMode>
+ </configuration>
+ </plugin>
</plugins>
</pluginManagement>
</build>
-
+
<ciManagement>
<system>Hudson</system>
<url></url>
</ciManagement>
-
+
<issueManagement>
<system>JIRA</system>
<url>http://jira.jboss.org/browse/WBRI</url>
</issueManagement>
-
+
<inceptionYear>2008</inceptionYear>
-
+
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
-
+
<scm>
<connection>http://anonsvn.jboss.org/repos/webbeans</connection>
- <developerConnection>https://svn.jboss.org/repos/webbeans</developerConnection>
+ <developerConnection>
+ https://svn.jboss.org/repos/webbeans
+ </developerConnection>
<url>http://fisheye.jboss.org/browse/WebBeans</url>
</scm>
-
+
<distributionManagement>
<repository>
<!-- Copy the dist to the local checkout of the JBoss maven2 repo ${maven.repository.root} -->
@@ -127,4 +138,19 @@
</snapshotRepository>
</distributionManagement>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ <configuration>
+ <formats>
+ <format>html</format>
+ <format>xml</format>
+ </formats>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+
</project>
15 years, 10 months