[webbeans-commits] Webbeans SVN: r24 - ri/trunk/webbeans-impl.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-06-30 18:45:56 -0400 (Mon, 30 Jun 2008)
New Revision: 24
Modified:
ri/trunk/webbeans-impl/pom.xml
Log:
Enable emma for coverage
Modified: ri/trunk/webbeans-impl/pom.xml
===================================================================
--- ri/trunk/webbeans-impl/pom.xml 2008-06-30 22:45:49 UTC (rev 23)
+++ ri/trunk/webbeans-impl/pom.xml 2008-06-30 22:45:56 UTC (rev 24)
@@ -1,5 +1,7 @@
<?xml version="1.0"?>
-<project>
+<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">
<parent>
<artifactId>parent</artifactId>
<groupId>org.jboss.webbeans</groupId>
@@ -23,4 +25,40 @@
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>emma-maven-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <inherited>true</inherited>
+ <executions>
+ <execution>
+ <goals>
+ <goal>instrument</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkMode>always</forkMode>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>emma-maven-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <inherited>true</inherited>
+ </plugin>
+ </plugins>
+ </reporting>
</project>
\ No newline at end of file
16 years, 4 months
[webbeans-commits] Webbeans SVN: r23 - ri/trunk/webbeans-api/src/main/java/javax/webbeans.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-06-30 18:45:49 -0400 (Mon, 30 Jun 2008)
New Revision: 23
Modified:
ri/trunk/webbeans-api/src/main/java/javax/webbeans/DynamicBinding.java
Log:
Do this lazily (nicer for enhancer)
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/DynamicBinding.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/DynamicBinding.java 2008-06-30 22:45:18 UTC (rev 22)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/DynamicBinding.java 2008-06-30 22:45:49 UTC (rev 23)
@@ -9,18 +9,9 @@
private Class<T> annotationType;
- @SuppressWarnings("unchecked")
- public DynamicBinding()
- {
- annotationType = getAnnotationType(getClass());
- if (annotationType == null)
- {
- throw new RuntimeException("Unable to determine type of dynamic binding for " + getClass());
- }
- }
-
private static <T> Class<T> getAnnotationType(Class<?> clazz)
{
+
Type type = clazz.getGenericSuperclass();
Class<T> annotationType = null;
if (type instanceof ParameterizedType)
@@ -43,6 +34,11 @@
public Class<? extends Annotation> annotationType()
{
+ annotationType = getAnnotationType(getClass());
+ if (annotationType == null)
+ {
+ throw new RuntimeException("Unable to determine type of dynamic binding for " + getClass());
+ }
return annotationType;
}
@@ -50,7 +46,7 @@
public String toString()
{
// TODO Make this closer to the spec for Annotation
- String annotationName = "@" + annotationType.getName();
+ String annotationName = "@" + annotationType().getName();
return annotationName;
}
16 years, 4 months
[webbeans-commits] Webbeans SVN: r22 - ri/trunk.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-06-30 18:45:18 -0400 (Mon, 30 Jun 2008)
New Revision: 22
Modified:
ri/trunk/pom.xml
Log:
add emma coverage plugin
Modified: ri/trunk/pom.xml
===================================================================
--- ri/trunk/pom.xml 2008-06-30 17:02:15 UTC (rev 21)
+++ ri/trunk/pom.xml 2008-06-30 22:45:18 UTC (rev 22)
@@ -10,6 +10,13 @@
<name>Web Beans</name>
<url>http://www.seamframework.org/WebBeans</url>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>snapshots.repository.codehaus.org</id>
+ <url>http://snapshots.repository.codehaus.org</url>
+ </pluginRepository>
+ </pluginRepositories>
+
<modules>
<module>webbeans-api</module>
<module>webbeans-impl</module>
16 years, 4 months
[webbeans-commits] Webbeans SVN: r21 - in ri/trunk/webbeans-impl/src: main/java/org/jboss/webbeans/bindings and 6 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-06-30 13:02:15 -0400 (Mon, 30 Jun 2008)
New Revision: 21
Added:
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/ConversationScopedBinding.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/RequestScopedBinding.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ContainerTest.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnotherDeploymentType.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/FishStereotype.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/HornedAnimalDeploymentType.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/HornedMammalStereotype.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/MammalStereotype.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/RiverFishStereotype.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithBindingTypes.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithNonEmptyNamed.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithTooManyDeploymentTypes.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithTooManyScopeTypes.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AnimalStereotypeBinding.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AnotherDeploymentTypeBinding.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AsynchronousBinding.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/FishStereotypeBinding.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/HornedAnimalDeploymentTypeBinding.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/HornedMamalStereotypeBinding.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/RiverFishStereotypeBinding.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Antelope.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Carp.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Cat.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Chair.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ComponentWithTooManyDeploymentTypes.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ComponentWithTooManyScopeTypes.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Goldfish.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Haddock.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Moose.java
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/Tuna.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/mock/
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/mock/MockContainerImpl.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/util/
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/util/Util.java
Removed:
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ClassWithNoAnnotations.java
Modified:
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ContainerImpl.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/MergedComponentStereotypes.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ClassAnnotatedItemTest.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/StereotypeMetaModelTest.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnimalStereotype.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Gorilla.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Order.java
Log:
Complete implementation of chapter 2 (less producer methods) with tests
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-06-30 14:50:25 UTC (rev 20)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -1,10 +1,8 @@
package org.jboss.webbeans;
import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;
@@ -14,10 +12,10 @@
import javax.webbeans.DeploymentType;
import javax.webbeans.Named;
import javax.webbeans.ScopeType;
-import javax.webbeans.Stereotype;
import org.jboss.webbeans.bindings.CurrentBinding;
import org.jboss.webbeans.bindings.DependentBinding;
+import org.jboss.webbeans.bindings.ProductionBinding;
import org.jboss.webbeans.util.AnnotatedItem;
import org.jboss.webbeans.util.LoggerUtil;
@@ -78,8 +76,24 @@
protected static Class<?> getType(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem)
{
- // TODO Consider XML type
- return annotatedItem.getAnnotatedClass();
+ 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");
+ }
}
/**
@@ -89,7 +103,8 @@
{
if (stereotypes.getSupportedScopes().size() > 0)
{
- if (!stereotypes.getSupportedScopes().contains(scopeType))
+ log.finest("Checking if " + scopeType + " is allowed");
+ if (!stereotypes.getSupportedScopes().contains(scopeType.annotationType()))
{
throw new RuntimeException("Scope " + scopeType + " is not an allowed by the component's stereotype");
}
@@ -101,14 +116,12 @@
*/
protected static void checkRequiredTypesImplemented(MergedComponentStereotypes stereotypes, Class<?> type)
{
- if (stereotypes.getRequiredTypes().size() > 0)
+ for (Class<?> requiredType : stereotypes.getRequiredTypes())
{
- // TODO This needs to check a lot more. Or we do through checking assignability
- List<Class> classes = Arrays.asList(type.getInterfaces());
- if (!classes.containsAll(stereotypes.getRequiredTypes()))
+ log.finest("Checking if required type " + requiredType + " is implemented");
+ if (!requiredType.isAssignableFrom(type))
{
- // TODO Ugh, improve this exception
- throw new RuntimeException("Not all required types are implemented");
+ throw new RuntimeException("Required type " + requiredType + " isn't implement on " + type);
}
}
}
@@ -126,8 +139,9 @@
if (xmlScopes.size() == 1)
{
- log.info("Scope specified in XML");
- return xmlScopes.iterator().next();
+ Annotation scope = xmlScopes.iterator().next();
+ log.finest("Scope " + scope + " specified in XML");
+ return scope;
}
Set<Annotation> scopes = annotatedItem.getAnnotations(ScopeType.class);
@@ -138,75 +152,95 @@
if (scopes.size() == 1)
{
- log.info("Scope specified by annotation");
- return scopes.iterator().next();
+ Annotation scope = scopes.iterator().next();
+ log.finest("Scope " + scope + " specified b annotation");
+ return scope;
}
- if (stereotypes.getPossibleScopeTypes().size() > 0)
+ if (stereotypes.getPossibleScopeTypes().size() == 1)
{
- return stereotypes.getPossibleScopeTypes().iterator().next();
+ 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 initComponentType(MergedComponentStereotypes stereotypes, AnnotatedItem annotatedElement, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
+ protected static Annotation initComponentType(MergedComponentStereotypes stereotypes, AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
{
- /*
- * TODO deployment types actually identify components to deploy - and so
- * if declared in XML and java then there are two components to deploy -
- * this needs to be handled at a higher level
- *
- * TODO Ignore deployment type annotations on class if declared in XML
- */
- Set<Annotation> xmlDeploymentTypes = annotatedElement.getAnnotations(DeploymentType.class);
+ Set<Annotation> xmlDeploymentTypes = xmlAnnotatedItem.getAnnotations(DeploymentType.class);
if (xmlDeploymentTypes.size() > 1)
{
- throw new RuntimeException("At most one deployment type may be specified in XML");
+ throw new RuntimeException("At most one deployment type may be specified (" + xmlDeploymentTypes + " are specified)");
}
if (xmlDeploymentTypes.size() == 1)
{
- return xmlDeploymentTypes.iterator().next();
+ Annotation deploymentType = xmlDeploymentTypes.iterator().next();
+ log.finest("Deployment type " + deploymentType + " specified in XML");
+ return deploymentType;
}
- Set<Annotation> deploymentTypes = annotatedElement.getAnnotations(DeploymentType.class);
+ if (xmlAnnotatedItem.getAnnotatedClass() == null)
+ {
- if (deploymentTypes.size() > 1)
- {
- // TODO Improve the exception
- throw new RuntimeException("At most one deployment type may be specified");
+ 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 (deploymentTypes.size() == 1)
+
+ if (stereotypes.getPossibleDeploymentTypes().size() > 0)
{
- return deploymentTypes.iterator().next();
+ Annotation deploymentType = getDeploymentType(container.getEnabledDeploymentTypes(), stereotypes.getPossibleDeploymentTypes());
+ log.finest("Deployment type " + deploymentType + " specified by stereotype");
+ return deploymentType;
}
- if (stereotypes.getPossibleDeploymentTypes().size() > 0)
+ if (xmlAnnotatedItem.getAnnotatedClass() != null)
{
- return getDeploymentType(container.getEnabledDeploymentTypes(), stereotypes.getPossibleDeploymentTypes());
+ log.finest("Using default @Production deployment type");
+ return new ProductionBinding();
}
-
- // TODO If declared in XML then we can return Production here
- // TODO We shouldn't get here, but what to do if we have?
- return null;
+ throw new RuntimeException("All Java annotated classes have a deployment type");
}
- protected static Set<Annotation> initBindingTypes(AnnotatedItem annotatedElement, AnnotatedItem xmlAnnotatedItem)
+ 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 = annotatedElement.getAnnotations(BindingType.class);
+ 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;
}
@@ -219,36 +253,45 @@
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()))
{
// TODO Write default name alogorithm
+ log.finest("Default name is TODO" );
}
return name;
}
- public static Annotation getDeploymentType(List<Annotation> enabledDeploymentTypes, Set<Annotation> possibleDeploymentTypes)
+ public static Annotation getDeploymentType(List<Annotation> enabledDeploymentTypes, Map<Class<? extends Annotation>, Annotation> possibleDeploymentTypes)
{
- List<Annotation> l = new ArrayList<Annotation>(enabledDeploymentTypes);
- l.retainAll(possibleDeploymentTypes);
- if (l.size() > 0)
+ for (int i = (enabledDeploymentTypes.size() - 1); i > 0; i--)
{
- return l.get(0);
+ if (possibleDeploymentTypes.containsKey((enabledDeploymentTypes.get(i).annotationType())))
+ {
+ return enabledDeploymentTypes.get(i);
+ }
}
- else
- {
- return null;
- }
+ return null;
}
@Override
Modified: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ContainerImpl.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ContainerImpl.java 2008-06-30 14:50:25 UTC (rev 20)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ContainerImpl.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -9,6 +9,7 @@
import javax.webbeans.Container;
import javax.webbeans.Context;
import javax.webbeans.Observer;
+import javax.webbeans.Standard;
import javax.webbeans.TypeLiteral;
import org.jboss.webbeans.bindings.ProductionBinding;
@@ -20,21 +21,28 @@
private List<Annotation> enabledDeploymentTypes;
private StereotypeManager stereotypeManager;
- public ContainerImpl()
+ public ContainerImpl(List<Annotation> enabledDeploymentTypes)
{
- initEnabledDeploymentTypes();
+ initEnabledDeploymentTypes(enabledDeploymentTypes);
this.stereotypeManager = new StereotypeManager();
}
- private void initEnabledDeploymentTypes()
+ private void initEnabledDeploymentTypes(List<Annotation> enabledDeploymentTypes)
{
this.enabledDeploymentTypes = new ArrayList<Annotation>();
- // TODO Support enabling custom deployment types
- if (this.enabledDeploymentTypes.size() == 0)
+ if (enabledDeploymentTypes == null)
{
this.enabledDeploymentTypes.add(0, new StandardBinding());
this.enabledDeploymentTypes.add(1, new ProductionBinding());
}
+ else
+ {
+ this.enabledDeploymentTypes.addAll(enabledDeploymentTypes);
+ if (!this.enabledDeploymentTypes.get(0).annotationType().equals(Standard.class))
+ {
+ throw new RuntimeException("@Standard must be the lowest precedence deployment type");
+ }
+ }
}
public Container addComponent(ComponentInstance component)
Modified: 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-06-30 14:50:25 UTC (rev 20)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/MergedComponentStereotypes.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -1,7 +1,9 @@
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;
@@ -16,7 +18,7 @@
public class MergedComponentStereotypes
{
- private Set<Annotation> possibleDeploymentTypes;
+ private Map<Class<? extends Annotation>, Annotation> possibleDeploymentTypes;
private Set<Annotation> possibleScopeTypes;
private boolean componentNameDefaulted;
private Set<Class<?>> requiredTypes;
@@ -24,7 +26,7 @@
public MergedComponentStereotypes(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
{
- possibleDeploymentTypes = new HashSet<Annotation>();
+ possibleDeploymentTypes = new HashMap<Class<? extends Annotation>, Annotation>();
possibleScopeTypes = new HashSet<Annotation>();
requiredTypes = new HashSet<Class<?>>();
supportedScopes = new HashSet<Class<? extends Annotation>>();
@@ -38,9 +40,13 @@
{
// 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.add(stereotype.getDefaultDeploymentType());
+ possibleDeploymentTypes.put(stereotype.getDefaultDeploymentType().annotationType(), stereotype.getDefaultDeploymentType());
}
if (stereotype.getDefaultScopeType() != null)
{
@@ -53,14 +59,9 @@
componentNameDefaulted = true;
}
}
-
- if (this.possibleScopeTypes.size() > 1)
- {
- throw new RuntimeException("All stereotypes must specify the same scope OR a scope must be specified on the component");
- }
}
- public Set<Annotation> getPossibleDeploymentTypes()
+ public Map<Class<? extends Annotation>, Annotation> getPossibleDeploymentTypes()
{
return possibleDeploymentTypes;
}
Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/ConversationScopedBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/ConversationScopedBinding.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/ConversationScopedBinding.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans.bindings;
+
+import javax.webbeans.ConversationScoped;
+import javax.webbeans.DynamicBinding;
+
+public class ConversationScopedBinding extends DynamicBinding<ConversationScoped> implements ConversationScoped
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/ConversationScopedBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/RequestScopedBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/RequestScopedBinding.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/RequestScopedBinding.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans.bindings;
+
+import javax.webbeans.DynamicBinding;
+import javax.webbeans.RequestScoped;
+
+public class RequestScopedBinding extends DynamicBinding<RequestScoped> implements RequestScoped
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/RequestScopedBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ClassAnnotatedItemTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ClassAnnotatedItemTest.java 2008-06-30 14:50:25 UTC (rev 20)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ClassAnnotatedItemTest.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -5,11 +5,10 @@
import java.util.Set;
import javax.webbeans.DeploymentType;
-import javax.webbeans.Named;
import javax.webbeans.Production;
import javax.webbeans.Stereotype;
-import org.jboss.webbeans.test.components.ClassWithNoAnnotations;
+import org.jboss.webbeans.test.components.Antelope;
import org.jboss.webbeans.test.components.Order;
import org.jboss.webbeans.util.AnnotatedItem;
import org.jboss.webbeans.util.ClassAnnotatedItem;
@@ -22,10 +21,8 @@
public void testDeclaredAnnotations()
{
AnnotatedItem annotatedElement = new ClassAnnotatedItem(Order.class);
- assert annotatedElement.getAnnotations().size() == 2;
+ assert annotatedElement.getAnnotations().size() == 1;
assert annotatedElement.getAnnotation(Production.class) != null;
- assert annotatedElement.getAnnotation(Named.class) != null;
- System.out.println(annotatedElement.getAnnotatedClass());
assert annotatedElement.getAnnotatedClass().equals(Order.class);
}
@@ -46,7 +43,7 @@
AnnotatedItem annotatedElement = new ClassAnnotatedItem(Order.class);
assert annotatedElement.getAnnotation(Stereotype.class) == null;
assert annotatedElement.getAnnotations(Stereotype.class).size() == 0;
- AnnotatedItem classWithNoAnnotations = new ClassAnnotatedItem(ClassWithNoAnnotations.class);
+ AnnotatedItem classWithNoAnnotations = new ClassAnnotatedItem(Antelope.class);
assert classWithNoAnnotations.getAnnotations().size() == 0;
}
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-06-30 14:50:25 UTC (rev 20)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentInstanceTest.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -1,31 +1,66 @@
package org.jboss.webbeans.test;
+import static org.jboss.webbeans.test.util.Util.annotationSetMatches;
+
import java.lang.annotation.Annotation;
-import java.util.Arrays;
+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.bindings.ConversationScopedBinding;
import org.jboss.webbeans.bindings.CurrentBinding;
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.Goldfish;
import org.jboss.webbeans.test.components.Gorilla;
+import org.jboss.webbeans.test.components.Haddock;
+import org.jboss.webbeans.test.components.Moose;
import org.jboss.webbeans.test.components.Order;
+import org.jboss.webbeans.test.components.Trout;
+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.BeforeClass;
import org.junit.Test;
public class ComponentInstanceTest
@@ -33,75 +68,424 @@
private ContainerImpl container;
- private static AnnotatedItem emptyAnnotatedItem;
+ private AnnotatedItem emptyAnnotatedItem;
- private static AnnotatedItem currentSynchronousOrder;
+ @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);
+ }
- @BeforeClass
- public static void beforeClass()
+ private void initStereotypes(ContainerImpl container)
{
- 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()
+ 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
{
- public String value()
- {
- return "currentSynchronousOrder";
- }
- });
- currentSynchronousOrder = new MutableAnnotatedItem(Order.class, orderXmlAnnotations);
+ 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);
- emptyAnnotatedItem = new MutableAnnotatedItem(null, new HashMap<Class<? extends Annotation>, Annotation>());
+ ComponentInstance<ComponentWithTooManyDeploymentTypes> component = new ComponentInstanceImpl<ComponentWithTooManyDeploymentTypes>(new ClassAnnotatedItem(ComponentWithTooManyDeploymentTypes.class), xmlDefinedDeploymentTypeAnnotatedItem, container);
+ assert component.getComponentType().annotationType().equals(AnotherDeploymentType.class);
}
- @Before
- public void before()
+ @Test
+ public void testXmlDefaultDeploymentType()
{
- // TODO Probably need a mock container
- container = new ContainerImpl();
- StereotypeMetaModel animalStereotype = new StereotypeMetaModel(new ClassAnnotatedItem(AnimalStereotype.class));
- container.getStereotypeManager().addStereotype(animalStereotype);
+ AnnotatedItem antelopeAnnotatedItem = new MutableAnnotatedItem(Antelope.class, new HashMap<Class<? extends Annotation>, Annotation>());
+ ComponentInstance<Antelope> antelope = new ComponentInstanceImpl<Antelope>(emptyAnnotatedItem, antelopeAnnotatedItem, container);
+ assert antelope.getComponentType().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.getComponentType().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.getComponentType().annotationType().equals(HornedAnimalDeploymentType.class);
+
+ }
+
+ // **** TESTS FOR BINDING TYPE **** //
+
@SuppressWarnings("unchecked")
@Test
- public void testOrder()
+ 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 Production.class.equals(order.getComponentType().annotationType());
- assert "order".equals(order.getName());
assert order.getBindingTypes().size() == 1;
order.getBindingTypes().iterator().next().annotationType().equals(Current.class);
+ }
+
+ // **** TESTS FOR SCOPES **** //
+
+ @Test
+ public void testScopeDeclaredInJava()
+ {
+ ComponentInstance<Trout> trout = new ComponentInstanceImpl<Trout>(new ClassAnnotatedItem(Trout.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(Trout.class, annotations);
+ ComponentInstance<Trout> trout = new ComponentInstanceImpl<Trout>(new ClassAnnotatedItem(Trout.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(Trout.class, annotations);
+
+ ComponentInstance<Trout> trout = new ComponentInstanceImpl<Trout>(new ClassAnnotatedItem(Trout.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);
- //assert order.getTypes() == ??
}
+ @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(Trout.class, annotations);
+ ComponentInstance<Trout> trout = new ComponentInstanceImpl<Trout>(new ClassAnnotatedItem(Trout.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(Trout.class, annotations);
+
+ ComponentInstance<Trout> trout = new ComponentInstanceImpl<Trout>(new ClassAnnotatedItem(Trout.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()
+ {
+ ComponentInstance<Haddock> haddock = new ComponentInstanceImpl<Haddock>(new ClassAnnotatedItem(Haddock.class), emptyAnnotatedItem, container);
+ assert haddock.getName() != null;
+ // TODO Test naming algorithms
+ }
+
+ @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(Trout.class, annotations);
+ ComponentInstance<Trout> trout = new ComponentInstanceImpl<Trout>(new ClassAnnotatedItem(Trout.class), annotatedItem, container);
+
+ assert trout.getName() != null;
+ // TODO Test naming algorithms
+ }
+
+ @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(Trout.class, annotations);
+ ComponentInstance<Trout> trout = new ComponentInstanceImpl<Trout>(new ClassAnnotatedItem(Trout.class), annotatedItem, container);
+
+ assert trout.getName().equals("aTrout");
+ }
+
+ @Test
+ public void testNotNamed()
+ {
+ ComponentInstance<Trout> trout = new ComponentInstanceImpl<Trout>(new ClassAnnotatedItem(Trout.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 testCurrentSynchronousOrder()
+ public void testStereotypeDeclaredInXmlAndJava()
{
- ComponentInstance<Order> order = new ComponentInstanceImpl<Order>(new ClassAnnotatedItem(Order.class), currentSynchronousOrder, container);
+ 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.getComponentType().annotationType());
assert "currentSynchronousOrder".equals(order.getName());
assert order.getBindingTypes().size() == 2;
- for (Annotation annotation : order.getBindingTypes())
- {
- // TODO Write a utility class to do this type of test
- assert annotation.annotationType().equals(Current.class) || annotation.annotationType().equals(Synchronous.class);
- }
+ assert annotationSetMatches(order.getBindingTypes(), Current.class, Synchronous.class);
assert order.getScopeType().annotationType().equals(Dependent.class);
}
@Test
- public void testGorilla()
+ public void testSingleStereotype()
{
ComponentInstance<Gorilla> gorilla = new ComponentInstanceImpl<Gorilla>(new ClassAnnotatedItem(Gorilla.class), emptyAnnotatedItem, container);
assert gorilla.getName() == null;
- // TODO Ensure that the a java declared component declares a deployment type
- //assert gorilla.getComponentType() == null;
+ assert gorilla.getComponentType().annotationType().equals(Production.class);
assert gorilla.getBindingTypes().iterator().next().annotationType().equals(Current.class);
- assert gorilla.getScopeType().annotationType().equals(Dependent.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;
+
+ }
}
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ContainerTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ContainerTest.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ContainerTest.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,63 @@
+package org.jboss.webbeans.test;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.webbeans.Production;
+import javax.webbeans.Standard;
+
+import org.jboss.webbeans.ContainerImpl;
+import org.jboss.webbeans.bindings.StandardBinding;
+import org.jboss.webbeans.test.annotations.AnotherDeploymentType;
+import org.jboss.webbeans.test.annotations.HornedAnimalDeploymentType;
+import org.jboss.webbeans.test.bindings.AnotherDeploymentTypeBinding;
+import org.jboss.webbeans.test.bindings.HornedAnimalDeploymentTypeBinding;
+import org.jboss.webbeans.test.mock.MockContainerImpl;
+import org.junit.Test;
+
+public class ContainerTest
+{
+
+ @Test
+ public void testDefaultEnabledDeploymentTypes()
+ {
+ ContainerImpl container = new MockContainerImpl(null);
+ assert container.getEnabledDeploymentTypes().size() == 2;
+ assert container.getEnabledDeploymentTypes().get(0).annotationType().equals(Standard.class);
+ assert container.getEnabledDeploymentTypes().get(1).annotationType().equals(Production.class);
+ }
+
+ @Test
+ public void testCustomDeploymentTypes()
+ {
+ List<Annotation> enabledDeploymentTypes = new ArrayList<Annotation>();
+ enabledDeploymentTypes.add(new StandardBinding());
+ enabledDeploymentTypes.add(new AnotherDeploymentTypeBinding());
+ enabledDeploymentTypes.add(new HornedAnimalDeploymentTypeBinding());
+ ContainerImpl container = new MockContainerImpl(enabledDeploymentTypes);
+ assert container.getEnabledDeploymentTypes().size() == 3;
+ assert container.getEnabledDeploymentTypes().get(0).annotationType().equals(Standard.class);
+ assert container.getEnabledDeploymentTypes().get(1).annotationType().equals(AnotherDeploymentType.class);
+ assert container.getEnabledDeploymentTypes().get(2).annotationType().equals(HornedAnimalDeploymentType.class);
+ }
+
+ @Test
+ public void testStandardMustBeDeclared()
+ {
+ List<Annotation> enabledDeploymentTypes = new ArrayList<Annotation>();
+ enabledDeploymentTypes.add(new AnotherDeploymentTypeBinding());
+ enabledDeploymentTypes.add(new HornedAnimalDeploymentTypeBinding());
+ boolean exception = false;
+ try
+ {
+ new MockContainerImpl(enabledDeploymentTypes);
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ContainerTest.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-06-30 14:50:25 UTC (rev 20)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/StereotypeMetaModelTest.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -11,6 +11,10 @@
import org.jboss.webbeans.test.annotations.AnimalOrderStereotype;
import org.jboss.webbeans.test.annotations.AnimalStereotype;
import org.jboss.webbeans.test.annotations.RequestScopedAnimalStereotype;
+import org.jboss.webbeans.test.annotations.StereotypeWithBindingTypes;
+import org.jboss.webbeans.test.annotations.StereotypeWithNonEmptyNamed;
+import org.jboss.webbeans.test.annotations.StereotypeWithTooManyDeploymentTypes;
+import org.jboss.webbeans.test.annotations.StereotypeWithTooManyScopeTypes;
import org.jboss.webbeans.test.components.Animal;
import org.jboss.webbeans.test.components.Order;
import org.jboss.webbeans.util.ClassAnnotatedItem;
@@ -48,10 +52,10 @@
public void testAnimalStereotype()
{
StereotypeMetaModel animalStereotype = new StereotypeMetaModel(new ClassAnnotatedItem(AnimalStereotype.class));
- assert animalStereotype.getDefaultScopeType() == null;
+ assert animalStereotype.getDefaultScopeType().annotationType().equals(RequestScoped.class);
assert animalStereotype.getInterceptorBindings().size() == 0;
assert animalStereotype.getRequiredTypes().size() == 1;
- assert Animal.class.equals(animalStereotype.getRequiredTypes().iterator().next());
+ assert animalStereotype.getRequiredTypes().contains(Animal.class);
assert animalStereotype.getSupportedScopes().size() == 0;
assert !animalStereotype.isComponentNameDefaulted();
assert animalStereotype.getDefaultDeploymentType() == null;
@@ -80,9 +84,69 @@
assert animalStereotype.getRequiredTypes().size() == 1;
assert Animal.class.equals(animalStereotype.getRequiredTypes().iterator().next());
assert animalStereotype.getSupportedScopes().size() == 1;
- assert RequestScoped.class.equals(animalStereotype.getSupportedScopes().iterator().next());
+ assert animalStereotype.getSupportedScopes().contains(RequestScoped.class);
assert !animalStereotype.isComponentNameDefaulted();
assert animalStereotype.getDefaultDeploymentType() == null;
}
+ @Test
+ public void testStereotypeWithTooManyScopeTypes()
+ {
+ boolean exception = false;
+ try
+ {
+ new StereotypeMetaModel(new ClassAnnotatedItem(StereotypeWithTooManyScopeTypes.class));
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+ }
+
+ @Test
+ public void testStereotypeWithTooManyDeploymentTypes()
+ {
+ boolean exception = false;
+ try
+ {
+ new StereotypeMetaModel(new ClassAnnotatedItem(StereotypeWithTooManyDeploymentTypes.class));
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+ }
+
+ @Test
+ public void testStereotypeWithNonEmptyNamed()
+ {
+ boolean exception = false;
+ try
+ {
+ new StereotypeMetaModel(new ClassAnnotatedItem(StereotypeWithNonEmptyNamed.class));
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+ }
+
+ @Test
+ public void testStereotypeWithBindingTypes()
+ {
+ boolean exception = false;
+ try
+ {
+ new StereotypeMetaModel(new ClassAnnotatedItem(StereotypeWithBindingTypes.class));
+ }
+ catch (Exception e)
+ {
+ exception = true;
+ }
+ assert exception;
+ }
+
}
Modified: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnimalStereotype.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnimalStereotype.java 2008-06-30 14:50:25 UTC (rev 20)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnimalStereotype.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -6,6 +6,7 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+import javax.webbeans.RequestScoped;
import javax.webbeans.Stereotype;
import org.jboss.webbeans.test.components.Animal;
@@ -13,6 +14,7 @@
@Stereotype(requiredTypes=Animal.class)
@Target( { TYPE })
@Retention(RUNTIME)
+@RequestScoped
public @interface AnimalStereotype
{
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnotherDeploymentType.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnotherDeploymentType.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnotherDeploymentType.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,20 @@
+package org.jboss.webbeans.test.annotations;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.DeploymentType;
+
+@Target( { TYPE, METHOD })
+@Retention(RUNTIME)
+@Documented
+@DeploymentType
+public @interface AnotherDeploymentType
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnotherDeploymentType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: 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 (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/Asynchronous.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,20 @@
+package org.jboss.webbeans.test.annotations;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.BindingType;
+
+@Target( { TYPE, METHOD })
+@Retention(RUNTIME)
+@Documented
+@BindingType
+public @interface Asynchronous
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/Asynchronous.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/FishStereotype.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/FishStereotype.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/FishStereotype.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,21 @@
+package org.jboss.webbeans.test.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.ApplicationScoped;
+import javax.webbeans.Stereotype;
+
+import org.jboss.webbeans.test.components.Animal;
+
+(a)Stereotype(requiredTypes=Animal.class)
+@Target( { TYPE })
+@Retention(RUNTIME)
+@ApplicationScoped
+public @interface FishStereotype
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/FishStereotype.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/HornedAnimalDeploymentType.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/HornedAnimalDeploymentType.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/HornedAnimalDeploymentType.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,20 @@
+package org.jboss.webbeans.test.annotations;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.DeploymentType;
+
+@Target( { TYPE, METHOD })
+@Retention(RUNTIME)
+@Documented
+@DeploymentType
+public @interface HornedAnimalDeploymentType
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/HornedAnimalDeploymentType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/HornedMammalStereotype.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/HornedMammalStereotype.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/HornedMammalStereotype.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,19 @@
+package org.jboss.webbeans.test.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import javax.webbeans.Stereotype;
+
+import org.jboss.webbeans.test.components.Animal;
+
+(a)Stereotype(requiredTypes=Animal.class)
+@Target( { TYPE })
+@Retention(RUNTIME)
+@HornedAnimalDeploymentType
+public @interface HornedMammalStereotype
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/HornedMammalStereotype.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/MammalStereotype.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/MammalStereotype.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/MammalStereotype.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,20 @@
+package org.jboss.webbeans.test.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.Stereotype;
+
+import org.jboss.webbeans.test.components.Animal;
+
+(a)Stereotype(requiredTypes=Animal.class)
+@Target( { TYPE })
+@Retention(RUNTIME)
+@AnotherDeploymentType
+public @interface MammalStereotype
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/MammalStereotype.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/RiverFishStereotype.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/RiverFishStereotype.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/RiverFishStereotype.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,21 @@
+package org.jboss.webbeans.test.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.ApplicationScoped;
+import javax.webbeans.Stereotype;
+
+import org.jboss.webbeans.test.components.Animal;
+
+(a)Stereotype(requiredTypes=Animal.class)
+@Target( { TYPE })
+@Retention(RUNTIME)
+@ApplicationScoped
+public @interface RiverFishStereotype
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/RiverFishStereotype.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithBindingTypes.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithBindingTypes.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithBindingTypes.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,21 @@
+package org.jboss.webbeans.test.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.ApplicationScoped;
+import javax.webbeans.RequestScoped;
+import javax.webbeans.Stereotype;
+
+@Stereotype
+@Target( { TYPE })
+@Retention(RUNTIME)
+@ApplicationScoped
+@RequestScoped
+public @interface StereotypeWithBindingTypes
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithBindingTypes.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithNonEmptyNamed.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithNonEmptyNamed.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithNonEmptyNamed.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,19 @@
+package org.jboss.webbeans.test.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.Named;
+import javax.webbeans.Stereotype;
+
+@Stereotype
+@Target( { TYPE })
+@Retention(RUNTIME)
+@Named("foo")
+public @interface StereotypeWithNonEmptyNamed
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithNonEmptyNamed.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithTooManyDeploymentTypes.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithTooManyDeploymentTypes.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithTooManyDeploymentTypes.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,20 @@
+package org.jboss.webbeans.test.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.Production;
+import javax.webbeans.Stereotype;
+
+@Stereotype
+@Target( { TYPE })
+@Retention(RUNTIME)
+@Production
+@AnotherDeploymentType
+public @interface StereotypeWithTooManyDeploymentTypes
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithTooManyDeploymentTypes.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithTooManyScopeTypes.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithTooManyScopeTypes.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithTooManyScopeTypes.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,17 @@
+package org.jboss.webbeans.test.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import javax.webbeans.Stereotype;
+
+@Stereotype
+@Target( { TYPE })
+@Retention(RUNTIME)
+@Asynchronous
+public @interface StereotypeWithTooManyScopeTypes
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithTooManyScopeTypes.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AnimalStereotypeBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AnimalStereotypeBinding.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AnimalStereotypeBinding.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,10 @@
+package org.jboss.webbeans.test.bindings;
+
+import javax.webbeans.DynamicBinding;
+
+import org.jboss.webbeans.test.annotations.AnimalStereotype;
+
+public class AnimalStereotypeBinding extends DynamicBinding<AnimalStereotype> implements AnimalStereotype
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AnimalStereotypeBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AnotherDeploymentTypeBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AnotherDeploymentTypeBinding.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AnotherDeploymentTypeBinding.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,10 @@
+/**
+ *
+ */
+package org.jboss.webbeans.test.bindings;
+
+import javax.webbeans.DynamicBinding;
+
+import org.jboss.webbeans.test.annotations.AnotherDeploymentType;
+
+public class AnotherDeploymentTypeBinding extends DynamicBinding<AnotherDeploymentType> implements AnotherDeploymentType {}
\ No newline at end of file
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AnotherDeploymentTypeBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AsynchronousBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AsynchronousBinding.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AsynchronousBinding.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,11 @@
+/**
+ *
+ */
+package org.jboss.webbeans.test.bindings;
+
+import javax.webbeans.DynamicBinding;
+
+import org.jboss.webbeans.test.annotations.Asynchronous;
+
+
+public class AsynchronousBinding extends DynamicBinding<Asynchronous> implements Asynchronous {}
\ No newline at end of file
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AsynchronousBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/FishStereotypeBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/FishStereotypeBinding.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/FishStereotypeBinding.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,10 @@
+package org.jboss.webbeans.test.bindings;
+
+import javax.webbeans.DynamicBinding;
+
+import org.jboss.webbeans.test.annotations.RiverFishStereotype;
+
+public class FishStereotypeBinding extends DynamicBinding<RiverFishStereotype> implements RiverFishStereotype
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/FishStereotypeBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/HornedAnimalDeploymentTypeBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/HornedAnimalDeploymentTypeBinding.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/HornedAnimalDeploymentTypeBinding.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,10 @@
+/**
+ *
+ */
+package org.jboss.webbeans.test.bindings;
+
+import javax.webbeans.DynamicBinding;
+
+import org.jboss.webbeans.test.annotations.HornedAnimalDeploymentType;
+
+public class HornedAnimalDeploymentTypeBinding extends DynamicBinding<HornedAnimalDeploymentType> implements HornedAnimalDeploymentType {}
\ No newline at end of file
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/HornedAnimalDeploymentTypeBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/HornedMamalStereotypeBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/HornedMamalStereotypeBinding.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/HornedMamalStereotypeBinding.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,10 @@
+/**
+ *
+ */
+package org.jboss.webbeans.test.bindings;
+
+import javax.webbeans.DynamicBinding;
+
+import org.jboss.webbeans.test.annotations.HornedMammalStereotype;
+
+public class HornedMamalStereotypeBinding extends DynamicBinding<HornedMammalStereotype> implements HornedMammalStereotype {}
\ No newline at end of file
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/HornedMamalStereotypeBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/RiverFishStereotypeBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/RiverFishStereotypeBinding.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/RiverFishStereotypeBinding.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,10 @@
+package org.jboss.webbeans.test.bindings;
+
+import javax.webbeans.DynamicBinding;
+
+import org.jboss.webbeans.test.annotations.FishStereotype;
+
+public class RiverFishStereotypeBinding extends DynamicBinding<FishStereotype> implements FishStereotype
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/RiverFishStereotypeBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Antelope.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Antelope.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Antelope.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.test.components;
+
+public class Antelope implements Animal
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Antelope.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Carp.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Carp.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Carp.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans.test.components;
+
+import org.jboss.webbeans.test.annotations.RequestScopedAnimalStereotype;
+
+@RequestScopedAnimalStereotype
+public class Carp implements Animal
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Carp.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Cat.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Cat.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Cat.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,12 @@
+package org.jboss.webbeans.test.components;
+
+import javax.webbeans.Production;
+
+import org.jboss.webbeans.test.annotations.Synchronous;
+
+@Production
+@Synchronous
+public class Cat
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Cat.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Chair.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Chair.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Chair.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans.test.components;
+
+import org.jboss.webbeans.test.annotations.AnimalStereotype;
+
+@AnimalStereotype
+public class Chair
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Chair.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ClassWithNoAnnotations.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ClassWithNoAnnotations.java 2008-06-30 14:50:25 UTC (rev 20)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ClassWithNoAnnotations.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -1,6 +0,0 @@
-package org.jboss.webbeans.test.components;
-
-public class ClassWithNoAnnotations
-{
-
-}
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ComponentWithTooManyDeploymentTypes.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ComponentWithTooManyDeploymentTypes.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ComponentWithTooManyDeploymentTypes.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,12 @@
+package org.jboss.webbeans.test.components;
+
+import javax.webbeans.Production;
+
+import org.jboss.webbeans.test.annotations.AnotherDeploymentType;
+
+@Production
+@AnotherDeploymentType
+public class ComponentWithTooManyDeploymentTypes
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ComponentWithTooManyDeploymentTypes.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ComponentWithTooManyScopeTypes.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ComponentWithTooManyScopeTypes.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ComponentWithTooManyScopeTypes.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,11 @@
+package org.jboss.webbeans.test.components;
+
+import javax.webbeans.ConversationScoped;
+import javax.webbeans.RequestScoped;
+
+@RequestScoped
+@ConversationScoped
+public class ComponentWithTooManyScopeTypes
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ComponentWithTooManyScopeTypes.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Goldfish.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Goldfish.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Goldfish.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,14 @@
+package org.jboss.webbeans.test.components;
+
+import javax.webbeans.Production;
+import javax.webbeans.RequestScoped;
+
+import org.jboss.webbeans.test.annotations.RequestScopedAnimalStereotype;
+
+@RequestScopedAnimalStereotype
+@RequestScoped
+@Production
+public class Goldfish implements Animal
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Goldfish.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Gorilla.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Gorilla.java 2008-06-30 14:50:25 UTC (rev 20)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Gorilla.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -1,8 +1,11 @@
package org.jboss.webbeans.test.components;
+import javax.webbeans.Production;
+
import org.jboss.webbeans.test.annotations.AnimalStereotype;
@AnimalStereotype
+@Production
public class Gorilla implements Animal
{
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Haddock.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Haddock.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Haddock.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,11 @@
+package org.jboss.webbeans.test.components;
+
+import javax.webbeans.Named;
+import javax.webbeans.Production;
+
+@Production
+@Named
+public class Haddock implements Animal
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Haddock.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Moose.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Moose.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Moose.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,12 @@
+package org.jboss.webbeans.test.components;
+
+import javax.webbeans.Named;
+
+import org.jboss.webbeans.test.annotations.MammalStereotype;
+
+@MammalStereotype
+@Named("aMoose")
+public class Moose implements Animal
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Moose.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Order.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Order.java 2008-06-30 14:50:25 UTC (rev 20)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Order.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -1,10 +1,8 @@
package org.jboss.webbeans.test.components;
-import javax.webbeans.Named;
import javax.webbeans.Production;
@Production
-@Named("order")
public class Order
{
Added: 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 (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Trout.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,11 @@
+package org.jboss.webbeans.test.components;
+
+import javax.webbeans.Production;
+import javax.webbeans.RequestScoped;
+
+@Production
+@RequestScoped
+public class Trout implements Animal
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Trout.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Tuna.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Tuna.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Tuna.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans.test.components;
+
+import org.jboss.webbeans.test.annotations.AnotherDeploymentType;
+
+@AnotherDeploymentType
+public class Tuna
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Tuna.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/mock/MockContainerImpl.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/mock/MockContainerImpl.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/mock/MockContainerImpl.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,16 @@
+package org.jboss.webbeans.test.mock;
+
+import java.lang.annotation.Annotation;
+import java.util.List;
+
+import org.jboss.webbeans.ContainerImpl;
+
+public class MockContainerImpl extends ContainerImpl
+{
+
+ public MockContainerImpl(List<Annotation> enabledDeploymentTypes)
+ {
+ super(enabledDeploymentTypes);
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/mock/MockContainerImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/util/Util.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/util/Util.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/util/Util.java 2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,48 @@
+package org.jboss.webbeans.test.util;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+public class Util
+{
+
+ public static boolean annotationSetMatches(Set<Annotation> annotations, Class<? extends Annotation>... annotationTypes)
+ {
+ List<Class<? extends Annotation>> annotationTypeList = new ArrayList<Class<? extends Annotation>>();
+ annotationTypeList.addAll(Arrays.asList(annotationTypes));
+ for (Annotation annotation : annotations)
+ {
+ if (annotationTypeList.contains(annotation.annotationType()))
+ {
+ annotationTypeList.remove(annotation.annotationType());
+ }
+ else
+ {
+ return false;
+ }
+ }
+ return annotationTypeList.size() == 0;
+ }
+
+ public static boolean annotationTypeSetMatches(Set<Class<? extends Annotation>> annotations, Class<? extends Annotation>... annotationTypes)
+ {
+ List<Class<? extends Annotation>> annotationTypeList = new ArrayList<Class<? extends Annotation>>();
+ annotationTypeList.addAll(Arrays.asList(annotationTypes));
+ for (Class<? extends Annotation> annotation : annotations)
+ {
+ if (annotationTypeList.contains(annotation))
+ {
+ annotationTypeList.remove(annotation);
+ }
+ else
+ {
+ return false;
+ }
+ }
+ return annotationTypeList.size() == 0;
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/util/Util.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years, 4 months
[webbeans-commits] Webbeans SVN: r20 - ri/trunk/webbeans-api/src/main/java/javax/webbeans.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-06-30 10:50:25 -0400 (Mon, 30 Jun 2008)
New Revision: 20
Modified:
ri/trunk/webbeans-api/src/main/java/javax/webbeans/ApplicationScoped.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/ConversationScoped.java
Log:
Oops (too much copy and pasting!)
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/ApplicationScoped.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/ApplicationScoped.java 2008-06-27 14:14:53 UTC (rev 19)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/ApplicationScoped.java 2008-06-30 14:50:25 UTC (rev 20)
@@ -13,7 +13,7 @@
@Target( { METHOD, FIELD, PARAMETER, TYPE })
@Retention(RUNTIME)
@Documented
-@BindingType
+@ScopeType
public @interface ApplicationScoped
{
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/ConversationScoped.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/ConversationScoped.java 2008-06-27 14:14:53 UTC (rev 19)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/ConversationScoped.java 2008-06-30 14:50:25 UTC (rev 20)
@@ -13,7 +13,7 @@
@Target( { METHOD, FIELD, PARAMETER, TYPE })
@Retention(RUNTIME)
@Documented
-@BindingType
+@ScopeType
public @interface ConversationScoped
{
16 years, 4 months
[webbeans-commits] Webbeans SVN: r19 - in ri/trunk/webbeans-impl/src: main/java/org/jboss/webbeans/bindings and 5 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-06-27 10:14:53 -0400 (Fri, 27 Jun 2008)
New Revision: 19
Added:
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/MergedComponentStereotypes.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/CurrentBinding.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/DependentBinding.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/NamedBinding.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/ProductionBinding.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/StandardBinding.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/AbstractAnnotatedItem.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/AnnotatedItem.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/ClassAnnotatedItem.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/LoggerUtil.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableAnnotatedItem.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ClassAnnotatedItemTest.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableAnnotatedItemTest.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnimalOrderStereotype.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnimalStereotype.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/RequestScopedAnimalStereotype.java
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/bindings/
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/SynchronousBinding.java
Removed:
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/CurrentBinding.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/DependentBinding.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ProductionBinding.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StandardBinding.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/AnnotatedWebBean.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableAnnotatedWebBean.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableAnnotatedWebBeanTest.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalOrderStereotype.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalStereotype.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/RequestScopedAnimalStereotype.java
Modified:
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ContainerImpl.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeMetaModel.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/StereotypeMetaModelTest.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Gorilla.java
Log:
JUL based logging with filter support (WBRI-14), support for merging in XML based annotations, split out algorithms into static methods for reuse, better class hierachy for AnnotatedItem, more tests
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-06-27 14:12:41 UTC (rev 18)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -6,6 +6,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.logging.Logger;
import javax.webbeans.BindingType;
import javax.webbeans.ComponentInstance;
@@ -15,7 +16,10 @@
import javax.webbeans.ScopeType;
import javax.webbeans.Stereotype;
-import org.jboss.webbeans.util.AnnotatedWebBean;
+import org.jboss.webbeans.bindings.CurrentBinding;
+import org.jboss.webbeans.bindings.DependentBinding;
+import org.jboss.webbeans.util.AnnotatedItem;
+import org.jboss.webbeans.util.LoggerUtil;
/**
* Web Beans Component meta model
@@ -26,72 +30,82 @@
public class ComponentInstanceImpl<T> extends ComponentInstance<T>
{
+
+
+ public static final String LOGGER_NAME = "componentInstance";
+
+ private static Logger log = LoggerUtil.getLogger(LOGGER_NAME);
+
+ private Class<?> type;
private Set<Annotation> bindingTypes;
private Annotation componentType;
private String name;
private Annotation scopeType;
- private Set<Annotation> possibleDeploymentTypes;
- private Set<Annotation> possibleScopeTypes;
- private boolean componentNameDefaulted;
- private Set<Class<?>> requiredTypes;
- private Set<Class<? extends Annotation>> supportedScopes;
- public ComponentInstanceImpl(AnnotatedWebBean annotatedElement, ContainerImpl container)
+ /**
+ *
+ * @param annotatedItem Annotations read from java classes
+ * @param xmlAnnotatedItem Annotations read from XML
+ * @param container
+ */
+ public ComponentInstanceImpl(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
{
- initStereotypes(annotatedElement, container);
- initBindingTypes(annotatedElement);
- initComponentType(annotatedElement, container);
- initScopeType(annotatedElement);
- initName(annotatedElement);
- checkRequiredTypesImplemented(annotatedElement);
- checkScopeAllowed(annotatedElement);
+ 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 = getType(annotatedItem, xmlAnnotatedItem);
+ log.fine("Building Web Bean component metadata for " + type);
+ MergedComponentStereotypes stereotypes = new MergedComponentStereotypes(annotatedItem, xmlAnnotatedItem, container);
+ this.bindingTypes = initBindingTypes(annotatedItem, xmlAnnotatedItem);
+ this.componentType = initComponentType(stereotypes, annotatedItem, xmlAnnotatedItem, container);
+ this.scopeType = initScopeType(stereotypes, annotatedItem, xmlAnnotatedItem);
+ this.name = initName(stereotypes, annotatedItem, xmlAnnotatedItem);
+ checkRequiredTypesImplemented(stereotypes, type);
+ checkScopeAllowed(stereotypes, scopeType);
// TODO Interceptors
}
- private void initStereotypes(AnnotatedWebBean annotatedElement, ContainerImpl container)
+ /*
+ * A series of static methods which implement the algorithms defined in the Web Beans spec for component meta data
+ */
+
+ protected static Class<?> getType(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem)
{
- possibleDeploymentTypes = new HashSet<Annotation>();
- possibleScopeTypes = new HashSet<Annotation>();
- requiredTypes = new HashSet<Class<?>>();
- supportedScopes = new HashSet<Class<? extends Annotation>>();
- for (Annotation stereotypeAnnotation : annotatedElement.getAnnotations(Stereotype.class))
- {
- StereotypeMetaModel stereotype = container.getStereotypeManager().getStereotype(stereotypeAnnotation.annotationType());
- if (stereotype.getDefaultDeploymentType() != null)
- {
- possibleDeploymentTypes.add(stereotype.getDefaultDeploymentType());
- }
- if (stereotype.getDefaultScopeType() != null)
- {
- possibleScopeTypes.add(stereotype.getDefaultScopeType());
- }
- requiredTypes.addAll(stereotype.getRequiredTypes());
- supportedScopes.addAll(stereotype.getSupportedScopes());
- if (stereotype.isComponentNameDefaulted())
- {
- componentNameDefaulted = true;
- }
- }
+ // TODO Consider XML type
+ return annotatedItem.getAnnotatedClass();
}
- private void checkScopeAllowed(AnnotatedWebBean annotatedClass)
+ /**
+ * Check that the scope type is allowed by the stereotypes on the component
+ */
+ protected static void checkScopeAllowed(MergedComponentStereotypes stereotypes, Annotation scopeType)
{
- if (supportedScopes.size() > 0)
+ if (stereotypes.getSupportedScopes().size() > 0)
{
- if (!supportedScopes.contains(scopeType))
+ if (!stereotypes.getSupportedScopes().contains(scopeType))
{
throw new RuntimeException("Scope " + scopeType + " is not an allowed by the component's stereotype");
}
}
}
- private void checkRequiredTypesImplemented(AnnotatedWebBean annotatedClass)
+ /**
+ * Check that the types required by the stereotypes on the component are implemented
+ */
+ protected static void checkRequiredTypesImplemented(MergedComponentStereotypes stereotypes, Class<?> type)
{
- if (requiredTypes.size() > 0)
+ if (stereotypes.getRequiredTypes().size() > 0)
{
// TODO This needs to check a lot more. Or we do through checking assignability
- List<Class> classes = Arrays.asList(annotatedClass.getAnnotatedClass().getInterfaces());
- if (!classes.containsAll(requiredTypes))
+ List<Class> classes = Arrays.asList(type.getInterfaces());
+ if (!classes.containsAll(stereotypes.getRequiredTypes()))
{
// TODO Ugh, improve this exception
throw new RuntimeException("Not all required types are implemented");
@@ -99,78 +113,128 @@
}
}
- private void initScopeType(AnnotatedWebBean annotatedElement)
+ /**
+ * Return the scope of the component
+ */
+ protected static Annotation initScopeType(MergedComponentStereotypes stereotypes, AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem)
{
- Set<Annotation> scopes = annotatedElement.getAnnotations(ScopeType.class);
- if (scopes.size() > 1)
+ Set<Annotation> xmlScopes = xmlAnnotatedItem.getAnnotations(ScopeType.class);
+ if (xmlScopes.size() > 1)
{
- throw new RuntimeException("At most one scope may be specified");
+ throw new RuntimeException("At most one scope may be specified in XML");
}
- else if (scopes.size() == 1)
+
+ if (xmlScopes.size() == 1)
{
- this.scopeType = scopes.iterator().next();
+ log.info("Scope specified in XML");
+ return xmlScopes.iterator().next();
}
- else if (possibleScopeTypes.size() == 1)
+
+ Set<Annotation> scopes = annotatedItem.getAnnotations(ScopeType.class);
+ if (scopes.size() > 1)
{
- this.scopeType = possibleScopeTypes.iterator().next();
+ throw new RuntimeException("At most one scope may be specified");
}
- else if (possibleScopeTypes.size() > 0)
+
+ if (scopes.size() == 1)
{
- //TODO DO something
+ log.info("Scope specified by annotation");
+ return scopes.iterator().next();
}
- else
+
+ if (stereotypes.getPossibleScopeTypes().size() > 0)
{
- this.scopeType = new DependentBinding();
+ return stereotypes.getPossibleScopeTypes().iterator().next();
}
+
+ return new DependentBinding();
}
- private void initComponentType(AnnotatedWebBean annotatedElement, ContainerImpl container)
+ protected static Annotation initComponentType(MergedComponentStereotypes stereotypes, AnnotatedItem annotatedElement, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
{
+ /*
+ * TODO deployment types actually identify components to deploy - and so
+ * if declared in XML and java then there are two components to deploy -
+ * this needs to be handled at a higher level
+ *
+ * TODO Ignore deployment type annotations on class if declared in XML
+ */
+ Set<Annotation> xmlDeploymentTypes = annotatedElement.getAnnotations(DeploymentType.class);
+
+ if (xmlDeploymentTypes.size() > 1)
+ {
+ throw new RuntimeException("At most one deployment type may be specified in XML");
+ }
+
+ if (xmlDeploymentTypes.size() == 1)
+ {
+ return xmlDeploymentTypes.iterator().next();
+ }
+
Set<Annotation> deploymentTypes = annotatedElement.getAnnotations(DeploymentType.class);
+
if (deploymentTypes.size() > 1)
{
+ // TODO Improve the exception
throw new RuntimeException("At most one deployment type may be specified");
}
- else if (deploymentTypes.size() == 1)
+ if (deploymentTypes.size() == 1)
{
- this.componentType = deploymentTypes.iterator().next();
+ return deploymentTypes.iterator().next();
}
- else
+
+ if (stereotypes.getPossibleDeploymentTypes().size() > 0)
{
- this.componentType = getDeploymentType(container.getEnabledDeploymentTypes(), possibleDeploymentTypes);
+ return getDeploymentType(container.getEnabledDeploymentTypes(), stereotypes.getPossibleDeploymentTypes());
}
+
+ // TODO If declared in XML then we can return Production here
+ // TODO We shouldn't get here, but what to do if we have?
+ return null;
}
- private void initBindingTypes(AnnotatedWebBean annotatedElement)
+ protected static Set<Annotation> initBindingTypes(AnnotatedItem annotatedElement, AnnotatedItem xmlAnnotatedItem)
{
- bindingTypes = annotatedElement.getAnnotations(BindingType.class);
+ Set<Annotation> xmlBindingTypes = xmlAnnotatedItem.getAnnotations(BindingType.class);
+ if (xmlBindingTypes.size() > 0)
+ {
+ // TODO support producer expression default binding type
+ return xmlBindingTypes;
+ }
- // Add the default binding if needed
+ Set<Annotation> bindingTypes = annotatedElement.getAnnotations(BindingType.class);
if (bindingTypes.size() == 0)
{
bindingTypes.add(new CurrentBinding());
}
+ return bindingTypes;
}
- private void initName(AnnotatedWebBean annotatedElement)
+ protected static String initName(MergedComponentStereotypes stereotypes, AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem)
{
- if (annotatedElement.isAnnotationPresent(Named.class))
+ boolean componentNameDefaulted = false;
+ String name = null;
+ if (xmlAnnotatedItem.isAnnotationPresent(Named.class))
{
- String name = annotatedElement.getAnnotation(Named.class).value();
+ name = xmlAnnotatedItem.getAnnotation(Named.class).value();
if ("".equals(name))
{
componentNameDefaulted = true;
}
- else
+ }
+ else if (annotatedItem.isAnnotationPresent(Named.class))
+ {
+ name = annotatedItem.getAnnotation(Named.class).value();
+ if ("".equals(name))
{
- componentNameDefaulted = false;
- this.name = name;
+ componentNameDefaulted = true;
}
}
- if (componentNameDefaulted)
+ if ("".equals(name) && (componentNameDefaulted || stereotypes.isComponentNameDefaulted()))
{
// TODO Write default name alogorithm
}
+ return name;
}
public static Annotation getDeploymentType(List<Annotation> enabledDeploymentTypes, Set<Annotation> possibleDeploymentTypes)
@@ -183,7 +247,7 @@
}
else
{
- return new ProductionBinding();
+ return null;
}
}
Modified: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ContainerImpl.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ContainerImpl.java 2008-06-27 14:12:41 UTC (rev 18)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ContainerImpl.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -11,6 +11,9 @@
import javax.webbeans.Observer;
import javax.webbeans.TypeLiteral;
+import org.jboss.webbeans.bindings.ProductionBinding;
+import org.jboss.webbeans.bindings.StandardBinding;
+
public class ContainerImpl implements Container
{
Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/CurrentBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/CurrentBinding.java 2008-06-27 14:12:41 UTC (rev 18)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/CurrentBinding.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -1,6 +0,0 @@
-package org.jboss.webbeans;
-
-import javax.webbeans.Current;
-import javax.webbeans.DynamicBinding;
-
-public class CurrentBinding extends DynamicBinding<Current> implements Current {}
Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/DependentBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/DependentBinding.java 2008-06-27 14:12:41 UTC (rev 18)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/DependentBinding.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -1,9 +0,0 @@
-package org.jboss.webbeans;
-
-import javax.webbeans.Dependent;
-import javax.webbeans.DynamicBinding;
-
-public class DependentBinding extends DynamicBinding<Dependent> implements Dependent
-{
-
-}
Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/MergedComponentStereotypes.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/MergedComponentStereotypes.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/MergedComponentStereotypes.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -0,0 +1,88 @@
+package org.jboss.webbeans;
+
+import java.lang.annotation.Annotation;
+import java.util.HashSet;
+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 Set<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 HashSet<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.getDefaultDeploymentType() != null)
+ {
+ possibleDeploymentTypes.add(stereotype.getDefaultDeploymentType());
+ }
+ if (stereotype.getDefaultScopeType() != null)
+ {
+ possibleScopeTypes.add(stereotype.getDefaultScopeType());
+ }
+ requiredTypes.addAll(stereotype.getRequiredTypes());
+ supportedScopes.addAll(stereotype.getSupportedScopes());
+ if (stereotype.isComponentNameDefaulted())
+ {
+ componentNameDefaulted = true;
+ }
+ }
+
+ if (this.possibleScopeTypes.size() > 1)
+ {
+ throw new RuntimeException("All stereotypes must specify the same scope OR a scope must be specified on the component");
+ }
+ }
+
+ public Set<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/MergedComponentStereotypes.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ProductionBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ProductionBinding.java 2008-06-27 14:12:41 UTC (rev 18)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ProductionBinding.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -1,9 +0,0 @@
-package org.jboss.webbeans;
-
-import javax.webbeans.DynamicBinding;
-import javax.webbeans.Production;
-
-public class ProductionBinding extends DynamicBinding<Production> implements Production
-{
-
-}
Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StandardBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StandardBinding.java 2008-06-27 14:12:41 UTC (rev 18)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StandardBinding.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -1,9 +0,0 @@
-package org.jboss.webbeans;
-
-import javax.webbeans.DynamicBinding;
-import javax.webbeans.Standard;
-
-public class StandardBinding extends DynamicBinding<Standard> implements Standard
-{
-
-}
Modified: 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-06-27 14:12:41 UTC (rev 18)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeMetaModel.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -2,9 +2,7 @@
import java.lang.annotation.Annotation;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
import javax.webbeans.BindingType;
@@ -14,7 +12,7 @@
import javax.webbeans.ScopeType;
import javax.webbeans.Stereotype;
-import org.jboss.webbeans.util.AnnotatedWebBean;
+import org.jboss.webbeans.util.AnnotatedItem;
/**
* A meta model for a stereotype, allows us to cache a stereotype and to validate it
@@ -34,7 +32,7 @@
private Set<Annotation> interceptorBindings;
@SuppressWarnings("unchecked")
- public StereotypeMetaModel(AnnotatedWebBean annotatedClass)
+ public StereotypeMetaModel(AnnotatedItem annotatedClass)
{
initStereotypeClass(annotatedClass);
Stereotype stereotype = annotatedClass.getAnnotation(Stereotype.class);
@@ -47,7 +45,7 @@
checkBindingTypes(annotatedClass);
}
- private void checkBindingTypes(AnnotatedWebBean annotatedClass)
+ private void checkBindingTypes(AnnotatedItem annotatedClass)
{
Set<Annotation> bindingTypes = annotatedClass.getAnnotations(BindingType.class);
if (bindingTypes.size() > 0)
@@ -57,7 +55,7 @@
}
@SuppressWarnings("unchecked")
- private void initStereotypeClass(AnnotatedWebBean annotatedClass)
+ private void initStereotypeClass(AnnotatedItem annotatedClass)
{
if (Annotation.class.isAssignableFrom(annotatedClass.getAnnotatedClass()))
{
@@ -69,12 +67,12 @@
}
}
- private void initInterceptorBindings(AnnotatedWebBean annotatedClass)
+ private void initInterceptorBindings(AnnotatedItem annotatedClass)
{
interceptorBindings = annotatedClass.getAnnotations(InterceptorBindingType.class);
}
- private void initSupportedScopes(AnnotatedWebBean annotatedElement, Stereotype stereotype)
+ private void initSupportedScopes(AnnotatedItem annotatedElement, Stereotype stereotype)
{
this.supportedScopes = new HashSet<Class<? extends Annotation>>();
Class<? extends Annotation>[] supportedScopes = stereotype.supportedScopes();
@@ -84,7 +82,7 @@
}
}
- private void initRequiredTypes(AnnotatedWebBean annotatedElement, Stereotype stereotype)
+ private void initRequiredTypes(AnnotatedItem annotatedElement, Stereotype stereotype)
{
this.requiredTypes = new HashSet<Class<?>>();
Class<?>[] requiredTypes = stereotype.requiredTypes();
@@ -94,7 +92,7 @@
}
}
- private void initComponentNameDefaulted(AnnotatedWebBean annotatedElement)
+ private void initComponentNameDefaulted(AnnotatedItem annotatedElement)
{
if (annotatedElement.isAnnotationPresent(Named.class))
{
@@ -106,7 +104,7 @@
}
}
- private void initDefaultScopeType(AnnotatedWebBean annotatedElement)
+ private void initDefaultScopeType(AnnotatedItem annotatedElement)
{
Set<Annotation> scopeTypes = annotatedElement.getAnnotations(ScopeType.class);
if (scopeTypes.size() > 1)
@@ -119,7 +117,7 @@
}
}
- private void initDefaultDeploymentType(AnnotatedWebBean annotatedElement)
+ private void initDefaultDeploymentType(AnnotatedItem annotatedElement)
{
Set<Annotation> deploymentTypes = annotatedElement.getAnnotations(DeploymentType.class);
if (deploymentTypes.size() > 1)
Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/CurrentBinding.java (from rev 15, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/CurrentBinding.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/CurrentBinding.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/CurrentBinding.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.bindings;
+
+import javax.webbeans.Current;
+import javax.webbeans.DynamicBinding;
+
+public class CurrentBinding extends DynamicBinding<Current> implements Current {}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/CurrentBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/DependentBinding.java (from rev 17, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/DependentBinding.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/DependentBinding.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/DependentBinding.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans.bindings;
+
+import javax.webbeans.Dependent;
+import javax.webbeans.DynamicBinding;
+
+public class DependentBinding extends DynamicBinding<Dependent> implements Dependent
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/DependentBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/NamedBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/NamedBinding.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/NamedBinding.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans.bindings;
+
+import javax.webbeans.DynamicBinding;
+import javax.webbeans.Named;
+
+public abstract class NamedBinding extends DynamicBinding<Named> implements Named
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/NamedBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/ProductionBinding.java (from rev 17, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ProductionBinding.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/ProductionBinding.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/ProductionBinding.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans.bindings;
+
+import javax.webbeans.DynamicBinding;
+import javax.webbeans.Production;
+
+public class ProductionBinding extends DynamicBinding<Production> implements Production
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/ProductionBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/StandardBinding.java (from rev 17, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StandardBinding.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/StandardBinding.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/StandardBinding.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans.bindings;
+
+import javax.webbeans.DynamicBinding;
+import javax.webbeans.Standard;
+
+public class StandardBinding extends DynamicBinding<Standard> implements Standard
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/StandardBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/AbstractAnnotatedItem.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/AbstractAnnotatedItem.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/AbstractAnnotatedItem.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -0,0 +1,107 @@
+package org.jboss.webbeans.util;
+
+import java.lang.annotation.Annotation;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+/**
+ * Base class for implementing AnnotatedItem. This implementation assumes
+ * the annotationMap is immutable.
+ *
+ * @author pmuir
+ *
+ */
+public abstract class AbstractAnnotatedItem implements AnnotatedItem
+{
+
+ private Map<Class<? extends Annotation>, Annotation> annotationMap;
+ private Map<Class<? extends Annotation>, Set<Annotation>> metaAnnotations;
+ private Set<Annotation> annotationSet;
+ private Class<?> annotatedClass;
+
+ public AbstractAnnotatedItem(Class<?> annotatedClass, Map<Class<? extends Annotation>, Annotation> annotationMap)
+ {
+ this.annotatedClass = annotatedClass;
+ if (annotationMap == null)
+ {
+ throw new NullPointerException("annotationMap cannot be null");
+ }
+ this.annotationMap = annotationMap;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType)
+ {
+ return (T) annotationMap.get(annotationType);
+ }
+
+ public <T extends Annotation> Set<Annotation> getAnnotations(Class<T> metaAnnotationType)
+ {
+ if (metaAnnotations == null)
+ {
+ metaAnnotations = new HashMap<Class<? extends Annotation>, Set<Annotation>>();
+ }
+ populateMetaAnnotationMap(metaAnnotationType, metaAnnotations, annotationMap);
+ return metaAnnotations.get(metaAnnotationType);
+ }
+
+ public Set<Annotation> getAnnotations()
+ {
+ if (annotationSet == null)
+ {
+ annotationSet = populateAnnotationSet(new HashSet<Annotation>(), annotationMap);
+ }
+ return annotationSet;
+ }
+
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotatedType)
+ {
+ return annotationMap.containsKey(annotatedType);
+ }
+
+ public Class<?> getAnnotatedClass()
+ {
+ return annotatedClass;
+ }
+
+ protected static Set<Annotation> populateAnnotationSet(Set<Annotation> annotationSet, Map<Class<? extends Annotation>, Annotation> annotationMap)
+ {
+ for (Entry<Class<? extends Annotation>, Annotation> entry : annotationMap.entrySet())
+ {
+ annotationSet.add(entry.getValue());
+ }
+ return annotationSet;
+ }
+
+ protected static <T extends Annotation> Map<Class<? extends Annotation>, Set<Annotation>> populateMetaAnnotationMap(Class<T> metaAnnotationType, Map<Class<? extends Annotation>, Set<Annotation>> metaAnnotations, Map<Class<? extends Annotation>, Annotation> annotationMap)
+ {
+ if (!metaAnnotations.containsKey(metaAnnotationType))
+ {
+ Set<Annotation> s = new HashSet<Annotation>();
+ for (Entry<Class<? extends Annotation>, Annotation> entry : annotationMap.entrySet())
+ {
+ if (entry.getValue().annotationType().isAnnotationPresent(metaAnnotationType))
+ {
+ s.add(entry.getValue());
+ }
+ }
+ metaAnnotations.put(metaAnnotationType, s);
+ }
+ return metaAnnotations;
+ }
+
+ protected Map<Class<? extends Annotation>, Annotation> getAnnotationMap()
+ {
+ return annotationMap;
+ }
+
+ @Override
+ public String toString()
+ {
+ return annotatedClass + " " + annotationMap.toString();
+ }
+
+}
\ No newline at end of file
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/AbstractAnnotatedItem.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/AnnotatedItem.java (from rev 17, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/AnnotatedWebBean.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/AnnotatedItem.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/AnnotatedItem.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -0,0 +1,51 @@
+package org.jboss.webbeans.util;
+
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+/**
+ * AnnotatedItem provides a uniform access to the annotations on an annotated
+ * item defined either in Java or XML
+ *
+ * @author Pete Muir
+ *
+ */
+public interface AnnotatedItem
+{
+
+ /**
+ * Get all annotations on the item
+ *
+ * An empty set is returned if no annotations are present
+ */
+ public abstract <T extends Annotation> Set<T> getAnnotations();
+
+ /**
+ * Get all annotations which are annotated with the given meta annotation
+ * type
+ *
+ * If no annotations are present which are annotated with the given meta
+ * annotation an empty set is returned
+ */
+ public abstract <T extends Annotation> Set<Annotation> getAnnotations(
+ Class<T> metaAnnotationType);
+
+ /**
+ * Get an annotation for the annotation type specified.
+ *
+ * If the annotation isn't present, null is returned
+ */
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType);
+
+ /**
+ * Return true if the annotation type specified is present
+ */
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotationType);
+
+ /**
+ * Return the class of the annotated item. If this annotatedItem isn't in use
+ * then this method should return null
+ */
+ public Class<?> getAnnotatedClass();
+
+}
\ No newline at end of file
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/AnnotatedItem.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/AnnotatedWebBean.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/AnnotatedWebBean.java 2008-06-27 14:12:41 UTC (rev 18)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/AnnotatedWebBean.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -1,50 +0,0 @@
-package org.jboss.webbeans.util;
-
-import java.lang.annotation.Annotation;
-import java.util.Set;
-
-/**
- * AnnotatedWebBean provides a uniform access to the annotations on a Web Bean,
- * defined either in Java or XML
- *
- * @author Pete Muir
- *
- */
-public interface AnnotatedWebBean
-{
-
- /**
- * Get all annotations on the item
- *
- * An empty set is returned if no annotations are present
- */
- public abstract <T extends Annotation> Set<T> getAnnotations();
-
- /**
- * Get all annotations which are annotated with the given meta annotation
- * type
- *
- * If no annotations are present which are annotated with the given meta
- * annotation an empty set is returned
- */
- public abstract <T extends Annotation> Set<Annotation> getAnnotations(
- Class<T> metaAnnotationType);
-
- /**
- * Get an annotation for the annotation type specified.
- *
- * If the annotation isn't present, null is returned
- */
- public <T extends Annotation> T getAnnotation(Class<T> annotationType);
-
- /**
- * Return true if the annotation type specified is present
- */
- public boolean isAnnotationPresent(Class<? extends Annotation> annotationType);
-
- /**
- * Return the class of the annotated item
- */
- public Class<?> getAnnotatedClass();
-
-}
\ No newline at end of file
Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/ClassAnnotatedItem.java (from rev 17, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableAnnotatedWebBean.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/ClassAnnotatedItem.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/ClassAnnotatedItem.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -0,0 +1,32 @@
+package org.jboss.webbeans.util;
+
+import java.lang.annotation.Annotation;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Implementation of annotatedItem that wraps a simple Java class and reads
+ * annotations from there.
+ *
+ * @author pmuir
+ *
+ */
+public class ClassAnnotatedItem extends AbstractAnnotatedItem
+{
+
+ public ClassAnnotatedItem(Class<?> clazz)
+ {
+ super(clazz, buildAnnotationMap(clazz));
+
+ }
+
+ protected static Map<Class<? extends Annotation>, Annotation> buildAnnotationMap(Class<?> clazz)
+ {
+ Map<Class<? extends Annotation>, Annotation> annotationMap = new HashMap<Class<? extends Annotation>, Annotation>();
+ for (Annotation annotation : clazz.getAnnotations())
+ {
+ annotationMap.put(annotation.annotationType(), annotation);
+ }
+ return annotationMap;
+ }
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/ClassAnnotatedItem.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: 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 (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/LoggerUtil.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -0,0 +1,38 @@
+package org.jboss.webbeans.util;
+
+import java.util.logging.Filter;
+import java.util.logging.Logger;
+
+public class LoggerUtil
+{
+
+ public static final String FILTER_PROPERTY = "org.jboss.webbeans.logger.filter";
+
+ public static final String WEBBEANS_LOGGER = "javax.webbeans.";
+
+ private static Filter filter;
+
+ static
+ {
+ String filterClassName = System.getProperty(FILTER_PROPERTY);
+ if (filterClassName != null && !"".equals(filterClassName))
+ try
+ {
+ filter = (Filter) Class.forName(filterClassName).newInstance();
+ }
+ catch (Exception e)
+ {
+ throw new IllegalArgumentException("Unable to instantiate logging filter");
+ }
+
+ }
+
+ public static Logger getLogger(String name)
+ {
+ name = WEBBEANS_LOGGER + name;
+ Logger logger = Logger.getLogger(name);
+ logger.setFilter(filter);
+ return logger;
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/LoggerUtil.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableAnnotatedItem.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableAnnotatedItem.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableAnnotatedItem.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -0,0 +1,70 @@
+package org.jboss.webbeans.util;
+
+import java.lang.annotation.Annotation;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Support for a mutable annotated item
+ *
+ */
+public class MutableAnnotatedItem extends AbstractAnnotatedItem
+{
+
+ private Map<Class<? extends Annotation>, Set<Annotation>> metaAnnotations;
+ private Set<Annotation> annotationSet;
+
+ public MutableAnnotatedItem(Class<?> annotatedClass, Map<Class<? extends Annotation>, Annotation> annotationMap)
+ {
+ super(annotatedClass, annotationMap);
+ }
+
+ private void setDirty()
+ {
+ metaAnnotations = null;
+ this.annotationSet = null;
+ }
+
+ public <T extends Annotation> Set<Annotation> getAnnotations(Class<T> metaAnnotationType)
+ {
+ if (metaAnnotations == null)
+ {
+ metaAnnotations = new HashMap<Class<? extends Annotation>, Set<Annotation>>();
+ }
+ populateMetaAnnotationMap(metaAnnotationType, metaAnnotations, getAnnotationMap());
+ return metaAnnotations.get(metaAnnotationType);
+ }
+
+ public Set<Annotation> getAnnotations()
+ {
+ if (annotationSet == null)
+ {
+ annotationSet = new HashSet<Annotation>();
+ populateAnnotationSet(annotationSet, getAnnotationMap());
+ }
+ return annotationSet;
+ }
+
+ /**
+ * Add an annotation to the AnnotatedElement
+ * @param annotation
+ */
+ public void add(Annotation annotation)
+ {
+ setDirty();
+ getAnnotationMap().put(annotation.annotationType(), annotation);
+ }
+
+ public void addAll(Collection<Annotation> annotations)
+ {
+ for (Annotation annotation : annotations)
+ {
+ this.getAnnotationMap().put(annotation.annotationType(), annotation);
+ }
+ setDirty();
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableAnnotatedItem.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableAnnotatedWebBean.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableAnnotatedWebBean.java 2008-06-27 14:12:41 UTC (rev 18)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableAnnotatedWebBean.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -1,112 +0,0 @@
-package org.jboss.webbeans.util;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-
-public class MutableAnnotatedWebBean implements AnnotatedWebBean
-{
-
- private Map<Class<? extends Annotation>, Annotation> annotations;
-
- private Map<Class<? extends Annotation>, Set<Annotation>> metaAnnotations;
- private Set<Annotation> annotationSet;
- private Class<?> annotatedClass;
-
- private MutableAnnotatedWebBean()
- {
- this.annotations = new HashMap<Class<? extends Annotation>, Annotation>();
- }
-
- public MutableAnnotatedWebBean(Class<?> clazz)
- {
- this();
- this.annotatedClass = clazz;
- for (Annotation annotation : clazz.getAnnotations())
- {
- add(annotation);
- }
- }
-
- @SuppressWarnings("unchecked")
- public <T extends Annotation> T getAnnotation(Class<T> annotationType)
- {
- return (T) annotations.get(annotationType);
- }
-
- private void setDirty()
- {
- metaAnnotations = null;
- this.annotationSet = null;
- }
-
- public <T extends Annotation> Set<Annotation> getAnnotations(Class<T> metaAnnotationType)
- {
- if (metaAnnotations == null)
- {
- metaAnnotations = new HashMap<Class<? extends Annotation>, Set<Annotation>>();
- }
- if (!metaAnnotations.containsKey(metaAnnotationType))
- {
- Set<Annotation> s = new HashSet<Annotation>();
- for (Entry<Class<? extends Annotation>, Annotation> entry : annotations.entrySet())
- {
- if (entry.getValue().annotationType().isAnnotationPresent(metaAnnotationType))
- {
- s.add(entry.getValue());
- }
- }
- metaAnnotations.put(metaAnnotationType, s);
- }
- return metaAnnotations.get(metaAnnotationType);
- }
-
-
- public Set<Annotation> getAnnotations()
- {
- if (annotationSet == null)
- {
- annotationSet = new HashSet<Annotation>();
- for (Entry<Class<? extends Annotation>, Annotation> entry : annotations.entrySet())
- {
- annotationSet.add(entry.getValue());
- }
- }
- return annotationSet;
- }
-
- public boolean isAnnotationPresent(Class<? extends Annotation> annotatedType)
- {
- return annotations.containsKey(annotatedType);
- }
-
- /**
- * Add an annotation to the AnnotatedElement
- * @param annotation
- */
- public void add(Annotation annotation)
- {
- setDirty();
- annotations.put(annotation.annotationType(), annotation);
- }
-
- public void addAll(Collection<Annotation> annotations)
- {
- for (Annotation annotation : annotations)
- {
- this.annotations.put(annotation.annotationType(), annotation);
- }
- setDirty();
- }
-
- public Class<?> getAnnotatedClass()
- {
- return annotatedClass;
- }
-
-}
Copied: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ClassAnnotatedItemTest.java (from rev 17, ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableAnnotatedWebBeanTest.java)
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ClassAnnotatedItemTest.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ClassAnnotatedItemTest.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -0,0 +1,53 @@
+package org.jboss.webbeans.test;
+
+import java.lang.annotation.Annotation;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.webbeans.DeploymentType;
+import javax.webbeans.Named;
+import javax.webbeans.Production;
+import javax.webbeans.Stereotype;
+
+import org.jboss.webbeans.test.components.ClassWithNoAnnotations;
+import org.jboss.webbeans.test.components.Order;
+import org.jboss.webbeans.util.AnnotatedItem;
+import org.jboss.webbeans.util.ClassAnnotatedItem;
+import org.junit.Test;
+
+public class ClassAnnotatedItemTest
+{
+
+ @Test
+ public void testDeclaredAnnotations()
+ {
+ AnnotatedItem annotatedElement = new ClassAnnotatedItem(Order.class);
+ assert annotatedElement.getAnnotations().size() == 2;
+ assert annotatedElement.getAnnotation(Production.class) != null;
+ assert annotatedElement.getAnnotation(Named.class) != null;
+ System.out.println(annotatedElement.getAnnotatedClass());
+ assert annotatedElement.getAnnotatedClass().equals(Order.class);
+ }
+
+ @Test
+ public void testMetaAnnotations()
+ {
+ AnnotatedItem annotatedElement = new ClassAnnotatedItem(Order.class);
+ Set<Annotation> annotations = annotatedElement.getAnnotations(DeploymentType.class);
+ assert annotations.size() == 1;
+ Iterator<Annotation> it = annotations.iterator();
+ Annotation production = it.next();
+ assert Production.class.equals(production.annotationType());
+ }
+
+ @Test
+ public void testEmpty()
+ {
+ AnnotatedItem annotatedElement = new ClassAnnotatedItem(Order.class);
+ assert annotatedElement.getAnnotation(Stereotype.class) == null;
+ assert annotatedElement.getAnnotations(Stereotype.class).size() == 0;
+ AnnotatedItem classWithNoAnnotations = new ClassAnnotatedItem(ClassWithNoAnnotations.class);
+ assert classWithNoAnnotations.getAnnotations().size() == 0;
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ClassAnnotatedItemTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-06-27 14:12:41 UTC (rev 18)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentInstanceTest.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -1,18 +1,31 @@
package org.jboss.webbeans.test;
+import java.lang.annotation.Annotation;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
import javax.webbeans.ComponentInstance;
import javax.webbeans.Current;
import javax.webbeans.Dependent;
+import javax.webbeans.Named;
import javax.webbeans.Production;
import org.jboss.webbeans.ComponentInstanceImpl;
import org.jboss.webbeans.ContainerImpl;
import org.jboss.webbeans.StereotypeMetaModel;
-import org.jboss.webbeans.test.components.AnimalStereotype;
+import org.jboss.webbeans.bindings.CurrentBinding;
+import org.jboss.webbeans.bindings.NamedBinding;
+import org.jboss.webbeans.test.annotations.AnimalStereotype;
+import org.jboss.webbeans.test.annotations.Synchronous;
+import org.jboss.webbeans.test.bindings.SynchronousBinding;
import org.jboss.webbeans.test.components.Gorilla;
import org.jboss.webbeans.test.components.Order;
-import org.jboss.webbeans.util.MutableAnnotatedWebBean;
+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.BeforeClass;
import org.junit.Test;
public class ComponentInstanceTest
@@ -20,12 +33,34 @@
private ContainerImpl container;
+ private static AnnotatedItem emptyAnnotatedItem;
+
+ private static AnnotatedItem currentSynchronousOrder;
+
+ @BeforeClass
+ public static void beforeClass()
+ {
+ 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";
+ }
+ });
+ currentSynchronousOrder = new MutableAnnotatedItem(Order.class, orderXmlAnnotations);
+
+ emptyAnnotatedItem = new MutableAnnotatedItem(null, new HashMap<Class<? extends Annotation>, Annotation>());
+ }
+
@Before
public void before()
{
// TODO Probably need a mock container
container = new ContainerImpl();
- StereotypeMetaModel animalStereotype = new StereotypeMetaModel(new MutableAnnotatedWebBean(AnimalStereotype.class));
+ StereotypeMetaModel animalStereotype = new StereotypeMetaModel(new ClassAnnotatedItem(AnimalStereotype.class));
container.getStereotypeManager().addStereotype(animalStereotype);
}
@@ -34,7 +69,7 @@
public void testOrder()
{
- ComponentInstance<Order> order = new ComponentInstanceImpl<Order>(new MutableAnnotatedWebBean(Order.class), container);
+ ComponentInstance<Order> order = new ComponentInstanceImpl<Order>(new ClassAnnotatedItem(Order.class), emptyAnnotatedItem, container);
assert Production.class.equals(order.getComponentType().annotationType());
assert "order".equals(order.getName());
assert order.getBindingTypes().size() == 1;
@@ -43,10 +78,26 @@
//assert order.getTypes() == ??
}
+ @SuppressWarnings("unchecked")
@Test
+ public void testCurrentSynchronousOrder()
+ {
+ ComponentInstance<Order> order = new ComponentInstanceImpl<Order>(new ClassAnnotatedItem(Order.class), currentSynchronousOrder, container);
+ assert Production.class.equals(order.getComponentType().annotationType());
+ assert "currentSynchronousOrder".equals(order.getName());
+ assert order.getBindingTypes().size() == 2;
+ for (Annotation annotation : order.getBindingTypes())
+ {
+ // TODO Write a utility class to do this type of test
+ assert annotation.annotationType().equals(Current.class) || annotation.annotationType().equals(Synchronous.class);
+ }
+ assert order.getScopeType().annotationType().equals(Dependent.class);
+ }
+
+ @Test
public void testGorilla()
{
- ComponentInstance<Gorilla> gorilla = new ComponentInstanceImpl<Gorilla>(new MutableAnnotatedWebBean(Gorilla.class), container);
+ ComponentInstance<Gorilla> gorilla = new ComponentInstanceImpl<Gorilla>(new ClassAnnotatedItem(Gorilla.class), emptyAnnotatedItem, container);
assert gorilla.getName() == null;
// TODO Ensure that the a java declared component declares a deployment type
//assert gorilla.getComponentType() == null;
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableAnnotatedItemTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableAnnotatedItemTest.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableAnnotatedItemTest.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -0,0 +1,40 @@
+package org.jboss.webbeans.test;
+
+import java.lang.annotation.Annotation;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.webbeans.BindingType;
+import javax.webbeans.Current;
+
+import org.jboss.webbeans.bindings.CurrentBinding;
+import org.jboss.webbeans.util.MutableAnnotatedItem;
+import org.junit.Test;
+
+public class MutableAnnotatedItemTest
+{
+
+ @Test
+ public void testMutability()
+ {
+ MutableAnnotatedItem annotatedElement = new MutableAnnotatedItem(null, new HashMap<Class<? extends Annotation>, Annotation>());
+ assert annotatedElement.getAnnotations().size() == 0;
+ annotatedElement.add(new CurrentBinding());
+ assert annotatedElement.getAnnotations().size() == 1;
+ assert annotatedElement.getAnnotation(Current.class) != null;
+ }
+
+ @Test
+ public void testMutableMetaAnnotations()
+ {
+ MutableAnnotatedItem annotatedElement = new MutableAnnotatedItem(null, new HashMap<Class<? extends Annotation>, Annotation>());
+ annotatedElement.add(new CurrentBinding());
+ Set<Annotation> annotations = annotatedElement.getAnnotations(BindingType.class);
+ assert annotations.size() == 1;
+ Iterator<Annotation> it = annotations.iterator();
+ Annotation production = it.next();
+ assert Current.class.equals(production.annotationType());
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableAnnotatedItemTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableAnnotatedWebBeanTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableAnnotatedWebBeanTest.java 2008-06-27 14:12:41 UTC (rev 18)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableAnnotatedWebBeanTest.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -1,81 +0,0 @@
-package org.jboss.webbeans.test;
-
-import java.lang.annotation.Annotation;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.webbeans.BindingType;
-import javax.webbeans.Current;
-import javax.webbeans.DeploymentType;
-import javax.webbeans.Named;
-import javax.webbeans.Production;
-import javax.webbeans.ScopeType;
-import javax.webbeans.Stereotype;
-
-import org.jboss.webbeans.CurrentBinding;
-import org.jboss.webbeans.test.components.ClassWithNoAnnotations;
-import org.jboss.webbeans.test.components.Order;
-import org.jboss.webbeans.util.AnnotatedWebBean;
-import org.jboss.webbeans.util.MutableAnnotatedWebBean;
-import org.junit.Test;
-
-public class MutableAnnotatedWebBeanTest
-{
-
- @Test
- public void testDeclaredAnnotations()
- {
- AnnotatedWebBean annotatedElement = new MutableAnnotatedWebBean(Order.class);
- assert annotatedElement.getAnnotations().size() == 2;
- assert annotatedElement.getAnnotation(Production.class) != null;
- assert annotatedElement.getAnnotation(Named.class) != null;
- System.out.println(annotatedElement.getAnnotatedClass());
- assert annotatedElement.getAnnotatedClass().equals(Order.class);
- }
-
- @Test
- public void testMutability()
- {
- MutableAnnotatedWebBean annotatedElement = new MutableAnnotatedWebBean(Order.class);
- assert annotatedElement.getAnnotations().size() == 2;
- annotatedElement.add(new CurrentBinding());
- assert annotatedElement.getAnnotations().size() == 3;
- assert annotatedElement.getAnnotation(Production.class) != null;
- assert annotatedElement.getAnnotation(Named.class) != null;
- assert annotatedElement.getAnnotation(Current.class) != null;
- }
-
- @Test
- public void testMetaAnnotations()
- {
- AnnotatedWebBean annotatedElement = new MutableAnnotatedWebBean(Order.class);
- Set<Annotation> annotations = annotatedElement.getAnnotations(DeploymentType.class);
- assert annotations.size() == 1;
- Iterator<Annotation> it = annotations.iterator();
- Annotation production = it.next();
- assert Production.class.equals(production.annotationType());
- }
-
- @Test
- public void testMutableMetaAnnotations()
- {
- MutableAnnotatedWebBean annotatedElement = new MutableAnnotatedWebBean(Order.class);
- annotatedElement.add(new CurrentBinding());
- Set<Annotation> annotations = annotatedElement.getAnnotations(BindingType.class);
- assert annotations.size() == 1;
- Iterator<Annotation> it = annotations.iterator();
- Annotation production = it.next();
- assert Current.class.equals(production.annotationType());
- }
-
- @Test
- public void testEmpty()
- {
- AnnotatedWebBean annotatedElement = new MutableAnnotatedWebBean(Order.class);
- assert annotatedElement.getAnnotation(Stereotype.class) == null;
- assert annotatedElement.getAnnotations(Stereotype.class).size() == 0;
- AnnotatedWebBean classWithNoAnnotations = new MutableAnnotatedWebBean(ClassWithNoAnnotations.class);
- assert classWithNoAnnotations.getAnnotations().size() == 0;
- }
-
-}
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-06-27 14:12:41 UTC (rev 18)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/StereotypeMetaModelTest.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -8,12 +8,12 @@
import javax.webbeans.RequestScoped;
import org.jboss.webbeans.StereotypeMetaModel;
+import org.jboss.webbeans.test.annotations.AnimalOrderStereotype;
+import org.jboss.webbeans.test.annotations.AnimalStereotype;
+import org.jboss.webbeans.test.annotations.RequestScopedAnimalStereotype;
import org.jboss.webbeans.test.components.Animal;
-import org.jboss.webbeans.test.components.AnimalOrderStereotype;
-import org.jboss.webbeans.test.components.AnimalStereotype;
import org.jboss.webbeans.test.components.Order;
-import org.jboss.webbeans.test.components.RequestScopedAnimalStereotype;
-import org.jboss.webbeans.util.MutableAnnotatedWebBean;
+import org.jboss.webbeans.util.ClassAnnotatedItem;
import org.junit.Test;
public class StereotypeMetaModelTest
@@ -22,7 +22,7 @@
@Test
public void testComponentStereotype()
{
- StereotypeMetaModel componentStereotype = new StereotypeMetaModel(new MutableAnnotatedWebBean(Component.class));
+ StereotypeMetaModel componentStereotype = new StereotypeMetaModel(new ClassAnnotatedItem(Component.class));
assert Production.class.equals(componentStereotype.getDefaultDeploymentType().annotationType());
assert componentStereotype.getDefaultScopeType() == null;
@@ -35,7 +35,7 @@
@Test
public void testModelStereotype()
{
- StereotypeMetaModel modelStereotype = new StereotypeMetaModel(new MutableAnnotatedWebBean(Model.class));
+ StereotypeMetaModel modelStereotype = new StereotypeMetaModel(new ClassAnnotatedItem(Model.class));
assert Production.class.equals(modelStereotype.getDefaultDeploymentType().annotationType());
assert RequestScoped.class.equals(modelStereotype.getDefaultScopeType().annotationType());
assert modelStereotype.isComponentNameDefaulted();
@@ -47,7 +47,7 @@
@Test
public void testAnimalStereotype()
{
- StereotypeMetaModel animalStereotype = new StereotypeMetaModel(new MutableAnnotatedWebBean(AnimalStereotype.class));
+ StereotypeMetaModel animalStereotype = new StereotypeMetaModel(new ClassAnnotatedItem(AnimalStereotype.class));
assert animalStereotype.getDefaultScopeType() == null;
assert animalStereotype.getInterceptorBindings().size() == 0;
assert animalStereotype.getRequiredTypes().size() == 1;
@@ -60,7 +60,7 @@
@Test
public void testAnimalOrderStereotype()
{
- StereotypeMetaModel animalStereotype = new StereotypeMetaModel(new MutableAnnotatedWebBean(AnimalOrderStereotype.class));
+ StereotypeMetaModel animalStereotype = new StereotypeMetaModel(new ClassAnnotatedItem(AnimalOrderStereotype.class));
assert animalStereotype.getDefaultScopeType() == null;
assert animalStereotype.getInterceptorBindings().size() == 0;
assert animalStereotype.getRequiredTypes().size() == 2;
@@ -74,7 +74,7 @@
@Test
public void testRequestScopedAnimalStereotype()
{
- StereotypeMetaModel animalStereotype = new StereotypeMetaModel(new MutableAnnotatedWebBean(RequestScopedAnimalStereotype.class));
+ StereotypeMetaModel animalStereotype = new StereotypeMetaModel(new ClassAnnotatedItem(RequestScopedAnimalStereotype.class));
assert animalStereotype.getDefaultScopeType() == null;
assert animalStereotype.getInterceptorBindings().size() == 0;
assert animalStereotype.getRequiredTypes().size() == 1;
Copied: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnimalOrderStereotype.java (from rev 17, ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalOrderStereotype.java)
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnimalOrderStereotype.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnimalOrderStereotype.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -0,0 +1,20 @@
+package org.jboss.webbeans.test.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.Stereotype;
+
+import org.jboss.webbeans.test.components.Animal;
+import org.jboss.webbeans.test.components.Order;
+
+(a)Stereotype(requiredTypes={Animal.class, Order.class})
+@Target( { TYPE })
+@Retention(RUNTIME)
+public @interface AnimalOrderStereotype
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnimalOrderStereotype.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnimalStereotype.java (from rev 17, ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalStereotype.java)
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnimalStereotype.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnimalStereotype.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -0,0 +1,19 @@
+package org.jboss.webbeans.test.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.Stereotype;
+
+import org.jboss.webbeans.test.components.Animal;
+
+(a)Stereotype(requiredTypes=Animal.class)
+@Target( { TYPE })
+@Retention(RUNTIME)
+public @interface AnimalStereotype
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnimalStereotype.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/RequestScopedAnimalStereotype.java (from rev 17, ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/RequestScopedAnimalStereotype.java)
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/RequestScopedAnimalStereotype.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/RequestScopedAnimalStereotype.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -0,0 +1,20 @@
+package org.jboss.webbeans.test.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.RequestScoped;
+import javax.webbeans.Stereotype;
+
+import org.jboss.webbeans.test.components.Animal;
+
+(a)Stereotype(requiredTypes=Animal.class, supportedScopes=RequestScoped.class)
+@Target( { TYPE })
+@Retention(RUNTIME)
+public @interface RequestScopedAnimalStereotype
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/RequestScopedAnimalStereotype.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: 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 (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/Synchronous.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -0,0 +1,20 @@
+package org.jboss.webbeans.test.annotations;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.BindingType;
+
+@Target( { TYPE, METHOD })
+@Retention(RUNTIME)
+@Documented
+@BindingType
+public @interface Synchronous
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/Synchronous.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/SynchronousBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/SynchronousBinding.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/SynchronousBinding.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -0,0 +1,10 @@
+package org.jboss.webbeans.test.bindings;
+
+import javax.webbeans.DynamicBinding;
+
+import org.jboss.webbeans.test.annotations.Synchronous;
+
+public class SynchronousBinding extends DynamicBinding<Synchronous> implements Synchronous
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/SynchronousBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalOrderStereotype.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalOrderStereotype.java 2008-06-27 14:12:41 UTC (rev 18)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalOrderStereotype.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -1,17 +0,0 @@
-package org.jboss.webbeans.test.components;
-
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.webbeans.Stereotype;
-
-(a)Stereotype(requiredTypes={Animal.class, Order.class})
-@Target( { TYPE })
-@Retention(RUNTIME)
-public @interface AnimalOrderStereotype
-{
-
-}
Deleted: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalStereotype.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalStereotype.java 2008-06-27 14:12:41 UTC (rev 18)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalStereotype.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -1,17 +0,0 @@
-package org.jboss.webbeans.test.components;
-
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.webbeans.Stereotype;
-
-(a)Stereotype(requiredTypes=Animal.class)
-@Target( { TYPE })
-@Retention(RUNTIME)
-public @interface AnimalStereotype
-{
-
-}
Modified: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Gorilla.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Gorilla.java 2008-06-27 14:12:41 UTC (rev 18)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Gorilla.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -1,5 +1,7 @@
package org.jboss.webbeans.test.components;
+import org.jboss.webbeans.test.annotations.AnimalStereotype;
+
@AnimalStereotype
public class Gorilla implements Animal
{
Deleted: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/RequestScopedAnimalStereotype.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/RequestScopedAnimalStereotype.java 2008-06-27 14:12:41 UTC (rev 18)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/RequestScopedAnimalStereotype.java 2008-06-27 14:14:53 UTC (rev 19)
@@ -1,18 +0,0 @@
-package org.jboss.webbeans.test.components;
-
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.webbeans.RequestScoped;
-import javax.webbeans.Stereotype;
-
-(a)Stereotype(requiredTypes=Animal.class, supportedScopes=RequestScoped.class)
-@Target( { TYPE })
-@Retention(RUNTIME)
-public @interface RequestScopedAnimalStereotype
-{
-
-}
16 years, 5 months
[webbeans-commits] Webbeans SVN: r18 - in ri/trunk/webbeans-api/src/main: resources and 1 other directory.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-06-27 10:12:41 -0400 (Fri, 27 Jun 2008)
New Revision: 18
Modified:
ri/trunk/webbeans-api/src/main/java/javax/webbeans/DynamicBinding.java
ri/trunk/webbeans-api/src/main/resources/web-beans.xsd
Log:
Fix dynamicbinding to correctly interpret super class types
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/DynamicBinding.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/DynamicBinding.java 2008-06-26 18:53:21 UTC (rev 17)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/DynamicBinding.java 2008-06-27 14:12:41 UTC (rev 18)
@@ -12,7 +12,17 @@
@SuppressWarnings("unchecked")
public DynamicBinding()
{
- Type type = getClass().getGenericSuperclass();
+ annotationType = getAnnotationType(getClass());
+ if (annotationType == null)
+ {
+ throw new RuntimeException("Unable to determine type of dynamic binding for " + getClass());
+ }
+ }
+
+ private static <T> Class<T> getAnnotationType(Class<?> clazz)
+ {
+ Type type = clazz.getGenericSuperclass();
+ Class<T> annotationType = null;
if (type instanceof ParameterizedType)
{
ParameterizedType parameterizedType = (ParameterizedType) type;
@@ -21,10 +31,14 @@
annotationType = (Class<T>) parameterizedType.getActualTypeArguments()[0];
}
}
- if (annotationType == null)
+ if (annotationType == null && clazz != Object.class)
{
- throw new RuntimeException("Unable to determine type of dynamic binding");
+ return getAnnotationType(clazz.getSuperclass());
}
+ else
+ {
+ return annotationType;
+ }
}
public Class<? extends Annotation> annotationType()
Modified: ri/trunk/webbeans-api/src/main/resources/web-beans.xsd
===================================================================
--- ri/trunk/webbeans-api/src/main/resources/web-beans.xsd 2008-06-26 18:53:21 UTC (rev 17)
+++ ri/trunk/webbeans-api/src/main/resources/web-beans.xsd 2008-06-27 14:12:41 UTC (rev 18)
@@ -25,7 +25,7 @@
<xs:element ref="web-beans:binding" />
<xs:element ref="web-beans:scope" />
<xs:element ref="web-beans:named" />
- <xs:element ref="web-beans:stereotype" />
+ <xs:element ref="web-beans:stereotype" maxOccurs="unbounded"/>
<xs:element ref="web-beans:producer-method" />
<xs:element ref="web-beans:producer-type" />
<xs:element ref="web-beans:remote" />
16 years, 5 months
[webbeans-commits] Webbeans SVN: r17 - in ri/trunk/webbeans-impl/src: main/java/org/jboss/webbeans/util and 2 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-06-26 14:53:21 -0400 (Thu, 26 Jun 2008)
New Revision: 17
Added:
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ContainerImpl.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/DependentBinding.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ProductionBinding.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StandardBinding.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/util/AnnotatedWebBean.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableAnnotatedWebBean.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableAnnotatedWebBeanTest.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/StereotypeMetaModelTest.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Animal.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalOrderStereotype.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalStereotype.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ClassWithNoAnnotations.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Gorilla.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/RequestScopedAnimalStereotype.java
Removed:
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/EnhancedAnnotatedElement.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableEnhancedAnnotatedElement.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableEnhancedAnnotatedElementTest.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/ComponentInstanceTest.java
Log:
More work on meta model, and a meta model for stereotypes
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-06-26 18:52:46 UTC (rev 16)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java 2008-06-26 18:53:21 UTC (rev 17)
@@ -1,20 +1,21 @@
package org.jboss.webbeans;
import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import javax.webbeans.BindingType;
import javax.webbeans.ComponentInstance;
import javax.webbeans.Container;
-import javax.webbeans.Current;
import javax.webbeans.DeploymentType;
import javax.webbeans.Named;
import javax.webbeans.ScopeType;
import javax.webbeans.Stereotype;
-import org.jboss.webbeans.util.EnhancedAnnotatedElement;
+import org.jboss.webbeans.util.AnnotatedWebBean;
/**
* Web Beans Component meta model
@@ -29,23 +30,76 @@
private Annotation componentType;
private String name;
private Annotation scopeType;
- private Set<Annotation> stereotypes;
+ private Set<Annotation> possibleDeploymentTypes;
+ private Set<Annotation> possibleScopeTypes;
+ private boolean componentNameDefaulted;
+ private Set<Class<?>> requiredTypes;
+ private Set<Class<? extends Annotation>> supportedScopes;
- public ComponentInstanceImpl(EnhancedAnnotatedElement annotatedElement)
+ public ComponentInstanceImpl(AnnotatedWebBean annotatedElement, ContainerImpl container)
{
- initSterotypes(annotatedElement);
+ initStereotypes(annotatedElement, container);
initBindingTypes(annotatedElement);
- initComponentType(annotatedElement);
+ initComponentType(annotatedElement, container);
initScopeType(annotatedElement);
initName(annotatedElement);
+ checkRequiredTypesImplemented(annotatedElement);
+ checkScopeAllowed(annotatedElement);
+ // TODO Interceptors
}
- private void initSterotypes(EnhancedAnnotatedElement annotatedElement)
+ private void initStereotypes(AnnotatedWebBean annotatedElement, ContainerImpl container)
{
- this.stereotypes = annotatedElement.getAnnotations(Stereotype.class);
+ possibleDeploymentTypes = new HashSet<Annotation>();
+ possibleScopeTypes = new HashSet<Annotation>();
+ requiredTypes = new HashSet<Class<?>>();
+ supportedScopes = new HashSet<Class<? extends Annotation>>();
+ for (Annotation stereotypeAnnotation : annotatedElement.getAnnotations(Stereotype.class))
+ {
+ StereotypeMetaModel stereotype = container.getStereotypeManager().getStereotype(stereotypeAnnotation.annotationType());
+ if (stereotype.getDefaultDeploymentType() != null)
+ {
+ possibleDeploymentTypes.add(stereotype.getDefaultDeploymentType());
+ }
+ if (stereotype.getDefaultScopeType() != null)
+ {
+ possibleScopeTypes.add(stereotype.getDefaultScopeType());
+ }
+ requiredTypes.addAll(stereotype.getRequiredTypes());
+ supportedScopes.addAll(stereotype.getSupportedScopes());
+ if (stereotype.isComponentNameDefaulted())
+ {
+ componentNameDefaulted = true;
+ }
+ }
}
+
+ private void checkScopeAllowed(AnnotatedWebBean annotatedClass)
+ {
+ if (supportedScopes.size() > 0)
+ {
+ if (!supportedScopes.contains(scopeType))
+ {
+ throw new RuntimeException("Scope " + scopeType + " is not an allowed by the component's stereotype");
+ }
+ }
+ }
+
+ private void checkRequiredTypesImplemented(AnnotatedWebBean annotatedClass)
+ {
+ if (requiredTypes.size() > 0)
+ {
+ // TODO This needs to check a lot more. Or we do through checking assignability
+ List<Class> classes = Arrays.asList(annotatedClass.getAnnotatedClass().getInterfaces());
+ if (!classes.containsAll(requiredTypes))
+ {
+ // TODO Ugh, improve this exception
+ throw new RuntimeException("Not all required types are implemented");
+ }
+ }
+ }
- private void initScopeType(EnhancedAnnotatedElement annotatedElement)
+ private void initScopeType(AnnotatedWebBean annotatedElement)
{
Set<Annotation> scopes = annotatedElement.getAnnotations(ScopeType.class);
if (scopes.size() > 1)
@@ -56,13 +110,21 @@
{
this.scopeType = scopes.iterator().next();
}
+ else if (possibleScopeTypes.size() == 1)
+ {
+ this.scopeType = possibleScopeTypes.iterator().next();
+ }
+ else if (possibleScopeTypes.size() > 0)
+ {
+ //TODO DO something
+ }
else
{
- // TODO Look at sterotypes
+ this.scopeType = new DependentBinding();
}
}
- private void initComponentType(EnhancedAnnotatedElement annotatedElement)
+ private void initComponentType(AnnotatedWebBean annotatedElement, ContainerImpl container)
{
Set<Annotation> deploymentTypes = annotatedElement.getAnnotations(DeploymentType.class);
if (deploymentTypes.size() > 1)
@@ -75,11 +137,11 @@
}
else
{
- // TODO Look at sterotypes
+ this.componentType = getDeploymentType(container.getEnabledDeploymentTypes(), possibleDeploymentTypes);
}
}
- private void initBindingTypes(EnhancedAnnotatedElement annotatedElement)
+ private void initBindingTypes(AnnotatedWebBean annotatedElement)
{
bindingTypes = annotatedElement.getAnnotations(BindingType.class);
@@ -90,19 +152,40 @@
}
}
- private void initName(EnhancedAnnotatedElement annotatedElement)
+ private void initName(AnnotatedWebBean annotatedElement)
{
if (annotatedElement.isAnnotationPresent(Named.class))
{
String name = annotatedElement.getAnnotation(Named.class).value();
if ("".equals(name))
{
- // TODO write default name algorithm
-
+ componentNameDefaulted = true;
}
- this.name = name;
+ else
+ {
+ componentNameDefaulted = false;
+ this.name = name;
+ }
}
+ if (componentNameDefaulted)
+ {
+ // TODO Write default name alogorithm
+ }
}
+
+ public static Annotation getDeploymentType(List<Annotation> enabledDeploymentTypes, Set<Annotation> possibleDeploymentTypes)
+ {
+ List<Annotation> l = new ArrayList<Annotation>(enabledDeploymentTypes);
+ l.retainAll(possibleDeploymentTypes);
+ if (l.size() > 0)
+ {
+ return l.get(0);
+ }
+ else
+ {
+ return new ProductionBinding();
+ }
+ }
@Override
public T create(Container container)
@@ -148,5 +231,7 @@
{
return scopeType;
}
+
+
}
Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ContainerImpl.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ContainerImpl.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ContainerImpl.java 2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,127 @@
+package org.jboss.webbeans;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.webbeans.ComponentInstance;
+import javax.webbeans.Container;
+import javax.webbeans.Context;
+import javax.webbeans.Observer;
+import javax.webbeans.TypeLiteral;
+
+public class ContainerImpl implements Container
+{
+
+ private List<Annotation> enabledDeploymentTypes;
+ private StereotypeManager stereotypeManager;
+
+ public ContainerImpl()
+ {
+ initEnabledDeploymentTypes();
+ this.stereotypeManager = new StereotypeManager();
+ }
+
+ private void initEnabledDeploymentTypes()
+ {
+ this.enabledDeploymentTypes = new ArrayList<Annotation>();
+ // TODO Support enabling custom deployment types
+ if (this.enabledDeploymentTypes.size() == 0)
+ {
+ this.enabledDeploymentTypes.add(0, new StandardBinding());
+ this.enabledDeploymentTypes.add(1, new ProductionBinding());
+ }
+ }
+
+ public Container addComponent(ComponentInstance component)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void addContext(Context context)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void addObserver(Observer observer)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void fireEvent(Object event, Annotation... bindings)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Context getContext(Class<Annotation> scopeType)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object getInstanceByName(String name)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public <T> T getInstanceByType(Class<T> type, Annotation... bindingTypes)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public <T> T getInstanceByType(TypeLiteral<T> type,
+ Annotation... bindingTypes)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void removeObserver(Observer observer)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Set<ComponentInstance> resolveByName(String name)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public <T> T resolveByType(Class<T> apiType, Annotation... bindingTypes)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public <T> T resolveByType(TypeLiteral<T> apiType,
+ Annotation... bindingTypes)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public <T> Set<Observer<T>> resolveObservers(T event, Annotation... bindings)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<Annotation> getEnabledDeploymentTypes()
+ {
+ return enabledDeploymentTypes;
+ }
+
+ public StereotypeManager getStereotypeManager()
+ {
+ return this.stereotypeManager;
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ContainerImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/DependentBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/DependentBinding.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/DependentBinding.java 2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans;
+
+import javax.webbeans.Dependent;
+import javax.webbeans.DynamicBinding;
+
+public class DependentBinding extends DynamicBinding<Dependent> implements Dependent
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/DependentBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ProductionBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ProductionBinding.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ProductionBinding.java 2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans;
+
+import javax.webbeans.DynamicBinding;
+import javax.webbeans.Production;
+
+public class ProductionBinding extends DynamicBinding<Production> implements Production
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ProductionBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StandardBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StandardBinding.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StandardBinding.java 2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans;
+
+import javax.webbeans.DynamicBinding;
+import javax.webbeans.Standard;
+
+public class StandardBinding extends DynamicBinding<Standard> implements Standard
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StandardBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,23 @@
+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);
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeMetaModel.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeMetaModel.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/StereotypeMetaModel.java 2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,193 @@
+package org.jboss.webbeans;
+
+import java.lang.annotation.Annotation;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+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.AnnotatedWebBean;
+
+/**
+ * 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(AnnotatedWebBean 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(AnnotatedWebBean 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(AnnotatedWebBean 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(AnnotatedWebBean annotatedClass)
+ {
+ interceptorBindings = annotatedClass.getAnnotations(InterceptorBindingType.class);
+ }
+
+ private void initSupportedScopes(AnnotatedWebBean 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(AnnotatedWebBean 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(AnnotatedWebBean 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(AnnotatedWebBean 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(AnnotatedWebBean 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/StereotypeMetaModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/AnnotatedWebBean.java (from rev 15, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/EnhancedAnnotatedElement.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/AnnotatedWebBean.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/AnnotatedWebBean.java 2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,50 @@
+package org.jboss.webbeans.util;
+
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+/**
+ * AnnotatedWebBean provides a uniform access to the annotations on a Web Bean,
+ * defined either in Java or XML
+ *
+ * @author Pete Muir
+ *
+ */
+public interface AnnotatedWebBean
+{
+
+ /**
+ * Get all annotations on the item
+ *
+ * An empty set is returned if no annotations are present
+ */
+ public abstract <T extends Annotation> Set<T> getAnnotations();
+
+ /**
+ * Get all annotations which are annotated with the given meta annotation
+ * type
+ *
+ * If no annotations are present which are annotated with the given meta
+ * annotation an empty set is returned
+ */
+ public abstract <T extends Annotation> Set<Annotation> getAnnotations(
+ Class<T> metaAnnotationType);
+
+ /**
+ * Get an annotation for the annotation type specified.
+ *
+ * If the annotation isn't present, null is returned
+ */
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType);
+
+ /**
+ * Return true if the annotation type specified is present
+ */
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotationType);
+
+ /**
+ * Return the class of the annotated item
+ */
+ public Class<?> getAnnotatedClass();
+
+}
\ No newline at end of file
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/AnnotatedWebBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/EnhancedAnnotatedElement.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/EnhancedAnnotatedElement.java 2008-06-26 18:52:46 UTC (rev 16)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/EnhancedAnnotatedElement.java 2008-06-26 18:53:21 UTC (rev 17)
@@ -1,18 +0,0 @@
-package org.jboss.webbeans.util;
-
-import java.lang.annotation.Annotation;
-import java.util.Set;
-
-public interface EnhancedAnnotatedElement
-{
-
- public abstract <T extends Annotation> Set<T> getAnnotations();
-
- public abstract <T extends Annotation> Set<Annotation> getAnnotations(
- Class<T> metaAnnotationType);
-
- public <T extends Annotation> T getAnnotation(Class<T> arg0);
-
- public boolean isAnnotationPresent(Class<? extends Annotation> arg0);
-
-}
\ No newline at end of file
Copied: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableAnnotatedWebBean.java (from rev 15, ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableEnhancedAnnotatedElement.java)
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableAnnotatedWebBean.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableAnnotatedWebBean.java 2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,112 @@
+package org.jboss.webbeans.util;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+public class MutableAnnotatedWebBean implements AnnotatedWebBean
+{
+
+ private Map<Class<? extends Annotation>, Annotation> annotations;
+
+ private Map<Class<? extends Annotation>, Set<Annotation>> metaAnnotations;
+ private Set<Annotation> annotationSet;
+ private Class<?> annotatedClass;
+
+ private MutableAnnotatedWebBean()
+ {
+ this.annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+ }
+
+ public MutableAnnotatedWebBean(Class<?> clazz)
+ {
+ this();
+ this.annotatedClass = clazz;
+ for (Annotation annotation : clazz.getAnnotations())
+ {
+ add(annotation);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType)
+ {
+ return (T) annotations.get(annotationType);
+ }
+
+ private void setDirty()
+ {
+ metaAnnotations = null;
+ this.annotationSet = null;
+ }
+
+ public <T extends Annotation> Set<Annotation> getAnnotations(Class<T> metaAnnotationType)
+ {
+ if (metaAnnotations == null)
+ {
+ metaAnnotations = new HashMap<Class<? extends Annotation>, Set<Annotation>>();
+ }
+ if (!metaAnnotations.containsKey(metaAnnotationType))
+ {
+ Set<Annotation> s = new HashSet<Annotation>();
+ for (Entry<Class<? extends Annotation>, Annotation> entry : annotations.entrySet())
+ {
+ if (entry.getValue().annotationType().isAnnotationPresent(metaAnnotationType))
+ {
+ s.add(entry.getValue());
+ }
+ }
+ metaAnnotations.put(metaAnnotationType, s);
+ }
+ return metaAnnotations.get(metaAnnotationType);
+ }
+
+
+ public Set<Annotation> getAnnotations()
+ {
+ if (annotationSet == null)
+ {
+ annotationSet = new HashSet<Annotation>();
+ for (Entry<Class<? extends Annotation>, Annotation> entry : annotations.entrySet())
+ {
+ annotationSet.add(entry.getValue());
+ }
+ }
+ return annotationSet;
+ }
+
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotatedType)
+ {
+ return annotations.containsKey(annotatedType);
+ }
+
+ /**
+ * Add an annotation to the AnnotatedElement
+ * @param annotation
+ */
+ public void add(Annotation annotation)
+ {
+ setDirty();
+ annotations.put(annotation.annotationType(), annotation);
+ }
+
+ public void addAll(Collection<Annotation> annotations)
+ {
+ for (Annotation annotation : annotations)
+ {
+ this.annotations.put(annotation.annotationType(), annotation);
+ }
+ setDirty();
+ }
+
+ public Class<?> getAnnotatedClass()
+ {
+ return annotatedClass;
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableAnnotatedWebBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableEnhancedAnnotatedElement.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableEnhancedAnnotatedElement.java 2008-06-26 18:52:46 UTC (rev 16)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableEnhancedAnnotatedElement.java 2008-06-26 18:53:21 UTC (rev 17)
@@ -1,113 +0,0 @@
-package org.jboss.webbeans.util;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-
-/**
- * Helper class which allows us to store the annotations present on an object
- *
- * Also allows you to discover meta annotations
- *
- * @author pmuir
- *
- */
-public class MutableEnhancedAnnotatedElement implements EnhancedAnnotatedElement
-{
-
- private Map<Class<? extends Annotation>, Annotation> annotations;
-
- private Map<Class<? extends Annotation>, Set<Annotation>> metaAnnotations;
- private Set<Annotation> annotationSet;
-
- public MutableEnhancedAnnotatedElement()
- {
- this.annotations = new HashMap<Class<? extends Annotation>, Annotation>();
- }
-
- public MutableEnhancedAnnotatedElement(AnnotatedElement annotatedElement)
- {
- this();
- for (Annotation annotation : annotatedElement.getAnnotations())
- {
- add(annotation);
- }
- }
-
- @SuppressWarnings("unchecked")
- public <T extends Annotation> T getAnnotation(Class<T> annotationType)
- {
- return (T) annotations.get(annotationType);
- }
-
- private void setDirty()
- {
- metaAnnotations = null;
- this.annotationSet = null;
- }
-
- public <T extends Annotation> Set<Annotation> getAnnotations(Class<T> metaAnnotationType)
- {
- if (metaAnnotations == null)
- {
- metaAnnotations = new HashMap<Class<? extends Annotation>, Set<Annotation>>();
- }
- if (!metaAnnotations.containsKey(metaAnnotationType))
- {
- Set<Annotation> s = new HashSet<Annotation>();
- for (Entry<Class<? extends Annotation>, Annotation> entry : annotations.entrySet())
- {
- if (entry.getValue().annotationType().isAnnotationPresent(metaAnnotationType))
- {
- s.add(entry.getValue());
- }
- }
- metaAnnotations.put(metaAnnotationType, s);
- }
- return metaAnnotations.get(metaAnnotationType);
- }
-
-
- public Set<Annotation> getAnnotations()
- {
- if (annotationSet == null)
- {
- annotationSet = new HashSet<Annotation>();
- for (Entry<Class<? extends Annotation>, Annotation> entry : annotations.entrySet())
- {
- annotationSet.add(entry.getValue());
- }
- }
- return annotationSet;
- }
-
- public boolean isAnnotationPresent(Class<? extends Annotation> annotatedType)
- {
- return annotations.containsKey(annotatedType);
- }
-
- /**
- * Add an annotation to the AnnotatedElement
- * @param annotation
- */
- public void add(Annotation annotation)
- {
- setDirty();
- annotations.put(annotation.annotationType(), annotation);
- }
-
- public void addAll(Collection<Annotation> annotations)
- {
- for (Annotation annotation : annotations)
- {
- this.annotations.put(annotation.annotationType(), annotation);
- }
- setDirty();
- }
-
-}
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-06-26 18:52:46 UTC (rev 16)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentInstanceTest.java 2008-06-26 18:53:21 UTC (rev 17)
@@ -1,22 +1,56 @@
package org.jboss.webbeans.test;
import javax.webbeans.ComponentInstance;
+import javax.webbeans.Current;
+import javax.webbeans.Dependent;
import javax.webbeans.Production;
import org.jboss.webbeans.ComponentInstanceImpl;
+import org.jboss.webbeans.ContainerImpl;
+import org.jboss.webbeans.StereotypeMetaModel;
+import org.jboss.webbeans.test.components.AnimalStereotype;
+import org.jboss.webbeans.test.components.Gorilla;
import org.jboss.webbeans.test.components.Order;
-import org.jboss.webbeans.util.MutableEnhancedAnnotatedElement;
+import org.jboss.webbeans.util.MutableAnnotatedWebBean;
+import org.junit.Before;
import org.junit.Test;
public class ComponentInstanceTest
{
+
+ private ContainerImpl container;
+
+ @Before
+ public void before()
+ {
+ // TODO Probably need a mock container
+ container = new ContainerImpl();
+ StereotypeMetaModel animalStereotype = new StereotypeMetaModel(new MutableAnnotatedWebBean(AnimalStereotype.class));
+ container.getStereotypeManager().addStereotype(animalStereotype);
+ }
+ @SuppressWarnings("unchecked")
@Test
- public void testMetaModel()
+ public void testOrder()
{
- ComponentInstance<Order> order = new ComponentInstanceImpl<Order>(new MutableEnhancedAnnotatedElement(Order.class));
+
+ ComponentInstance<Order> order = new ComponentInstanceImpl<Order>(new MutableAnnotatedWebBean(Order.class), container);
assert Production.class.equals(order.getComponentType().annotationType());
assert "order".equals(order.getName());
+ assert order.getBindingTypes().size() == 1;
+ order.getBindingTypes().iterator().next().annotationType().equals(Current.class);
+ assert order.getScopeType().annotationType().equals(Dependent.class);
+ //assert order.getTypes() == ??
}
+ @Test
+ public void testGorilla()
+ {
+ ComponentInstance<Gorilla> gorilla = new ComponentInstanceImpl<Gorilla>(new MutableAnnotatedWebBean(Gorilla.class), container);
+ assert gorilla.getName() == null;
+ // TODO Ensure that the a java declared component declares a deployment type
+ //assert gorilla.getComponentType() == null;
+ assert gorilla.getBindingTypes().iterator().next().annotationType().equals(Current.class);
+ assert gorilla.getScopeType().annotationType().equals(Dependent.class);
+ }
}
Copied: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableAnnotatedWebBeanTest.java (from rev 15, ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableEnhancedAnnotatedElementTest.java)
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableAnnotatedWebBeanTest.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableAnnotatedWebBeanTest.java 2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,81 @@
+package org.jboss.webbeans.test;
+
+import java.lang.annotation.Annotation;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.webbeans.BindingType;
+import javax.webbeans.Current;
+import javax.webbeans.DeploymentType;
+import javax.webbeans.Named;
+import javax.webbeans.Production;
+import javax.webbeans.ScopeType;
+import javax.webbeans.Stereotype;
+
+import org.jboss.webbeans.CurrentBinding;
+import org.jboss.webbeans.test.components.ClassWithNoAnnotations;
+import org.jboss.webbeans.test.components.Order;
+import org.jboss.webbeans.util.AnnotatedWebBean;
+import org.jboss.webbeans.util.MutableAnnotatedWebBean;
+import org.junit.Test;
+
+public class MutableAnnotatedWebBeanTest
+{
+
+ @Test
+ public void testDeclaredAnnotations()
+ {
+ AnnotatedWebBean annotatedElement = new MutableAnnotatedWebBean(Order.class);
+ assert annotatedElement.getAnnotations().size() == 2;
+ assert annotatedElement.getAnnotation(Production.class) != null;
+ assert annotatedElement.getAnnotation(Named.class) != null;
+ System.out.println(annotatedElement.getAnnotatedClass());
+ assert annotatedElement.getAnnotatedClass().equals(Order.class);
+ }
+
+ @Test
+ public void testMutability()
+ {
+ MutableAnnotatedWebBean annotatedElement = new MutableAnnotatedWebBean(Order.class);
+ assert annotatedElement.getAnnotations().size() == 2;
+ annotatedElement.add(new CurrentBinding());
+ assert annotatedElement.getAnnotations().size() == 3;
+ assert annotatedElement.getAnnotation(Production.class) != null;
+ assert annotatedElement.getAnnotation(Named.class) != null;
+ assert annotatedElement.getAnnotation(Current.class) != null;
+ }
+
+ @Test
+ public void testMetaAnnotations()
+ {
+ AnnotatedWebBean annotatedElement = new MutableAnnotatedWebBean(Order.class);
+ Set<Annotation> annotations = annotatedElement.getAnnotations(DeploymentType.class);
+ assert annotations.size() == 1;
+ Iterator<Annotation> it = annotations.iterator();
+ Annotation production = it.next();
+ assert Production.class.equals(production.annotationType());
+ }
+
+ @Test
+ public void testMutableMetaAnnotations()
+ {
+ MutableAnnotatedWebBean annotatedElement = new MutableAnnotatedWebBean(Order.class);
+ annotatedElement.add(new CurrentBinding());
+ Set<Annotation> annotations = annotatedElement.getAnnotations(BindingType.class);
+ assert annotations.size() == 1;
+ Iterator<Annotation> it = annotations.iterator();
+ Annotation production = it.next();
+ assert Current.class.equals(production.annotationType());
+ }
+
+ @Test
+ public void testEmpty()
+ {
+ AnnotatedWebBean annotatedElement = new MutableAnnotatedWebBean(Order.class);
+ assert annotatedElement.getAnnotation(Stereotype.class) == null;
+ assert annotatedElement.getAnnotations(Stereotype.class).size() == 0;
+ AnnotatedWebBean classWithNoAnnotations = new MutableAnnotatedWebBean(ClassWithNoAnnotations.class);
+ assert classWithNoAnnotations.getAnnotations().size() == 0;
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableAnnotatedWebBeanTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableEnhancedAnnotatedElementTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableEnhancedAnnotatedElementTest.java 2008-06-26 18:52:46 UTC (rev 16)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableEnhancedAnnotatedElementTest.java 2008-06-26 18:53:21 UTC (rev 17)
@@ -1,66 +0,0 @@
-package org.jboss.webbeans.test;
-
-import java.lang.annotation.Annotation;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.webbeans.Current;
-import javax.webbeans.DeploymentType;
-import javax.webbeans.Named;
-import javax.webbeans.Production;
-import javax.webbeans.ScopeType;
-
-import org.jboss.webbeans.CurrentBinding;
-import org.jboss.webbeans.test.components.Order;
-import org.jboss.webbeans.util.EnhancedAnnotatedElement;
-import org.jboss.webbeans.util.MutableEnhancedAnnotatedElement;
-import org.junit.Test;
-
-public class MutableEnhancedAnnotatedElementTest
-{
-
- @Test
- public void testDeclaredAnnotations()
- {
- EnhancedAnnotatedElement annotatedElement = new MutableEnhancedAnnotatedElement(Order.class);
- assert annotatedElement.getAnnotations().size() == 2;
- assert annotatedElement.getAnnotation(Production.class) != null;
- assert annotatedElement.getAnnotation(Named.class) != null;
- }
-
- @Test
- public void testMutability()
- {
- MutableEnhancedAnnotatedElement annotatedElement = new MutableEnhancedAnnotatedElement(Order.class);
- assert annotatedElement.getAnnotations().size() == 2;
- annotatedElement.add(new CurrentBinding());
- assert annotatedElement.getAnnotations().size() == 3;
- assert annotatedElement.getAnnotation(Production.class) != null;
- assert annotatedElement.getAnnotation(Named.class) != null;
- assert annotatedElement.getAnnotation(Current.class) != null;
- }
-
- @Test
- public void testMetaAnnotations()
- {
- EnhancedAnnotatedElement annotatedElement = new MutableEnhancedAnnotatedElement(Order.class);
- Set<Annotation> annotations = annotatedElement.getAnnotations(DeploymentType.class);
- assert annotations.size() == 1;
- Iterator<Annotation> it = annotations.iterator();
- Annotation production = it.next();
- assert Production.class.equals(production.annotationType());
- }
-
- @Test
- public void testMutableMetaAnnotations()
- {
- MutableEnhancedAnnotatedElement annotatedElement = new MutableEnhancedAnnotatedElement(Order.class);
- annotatedElement.add(new CurrentBinding());
- Set<Annotation> annotations = annotatedElement.getAnnotations(ScopeType.class);
- assert annotations.size() == 1;
- Iterator<Annotation> it = annotations.iterator();
- Annotation production = it.next();
- assert Current.class.equals(production.annotationType());
- }
-
-}
Added: 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 (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/StereotypeMetaModelTest.java 2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,88 @@
+package org.jboss.webbeans.test;
+
+import java.util.Arrays;
+
+import javax.webbeans.Component;
+import javax.webbeans.Model;
+import javax.webbeans.Production;
+import javax.webbeans.RequestScoped;
+
+import org.jboss.webbeans.StereotypeMetaModel;
+import org.jboss.webbeans.test.components.Animal;
+import org.jboss.webbeans.test.components.AnimalOrderStereotype;
+import org.jboss.webbeans.test.components.AnimalStereotype;
+import org.jboss.webbeans.test.components.Order;
+import org.jboss.webbeans.test.components.RequestScopedAnimalStereotype;
+import org.jboss.webbeans.util.MutableAnnotatedWebBean;
+import org.junit.Test;
+
+public class StereotypeMetaModelTest
+{
+
+ @Test
+ public void testComponentStereotype()
+ {
+ StereotypeMetaModel componentStereotype = new StereotypeMetaModel(new MutableAnnotatedWebBean(Component.class));
+
+ assert Production.class.equals(componentStereotype.getDefaultDeploymentType().annotationType());
+ assert componentStereotype.getDefaultScopeType() == null;
+ assert componentStereotype.getInterceptorBindings().size() == 0;
+ assert componentStereotype.getRequiredTypes().size() == 0;
+ assert componentStereotype.getSupportedScopes().size() == 0;
+ assert !componentStereotype.isComponentNameDefaulted();
+ }
+
+ @Test
+ public void testModelStereotype()
+ {
+ StereotypeMetaModel modelStereotype = new StereotypeMetaModel(new MutableAnnotatedWebBean(Model.class));
+ assert Production.class.equals(modelStereotype.getDefaultDeploymentType().annotationType());
+ assert RequestScoped.class.equals(modelStereotype.getDefaultScopeType().annotationType());
+ assert modelStereotype.isComponentNameDefaulted();
+ assert modelStereotype.getInterceptorBindings().size() == 0;
+ assert modelStereotype.getRequiredTypes().size() == 0;
+ assert modelStereotype.getSupportedScopes().size() == 0;
+ }
+
+ @Test
+ public void testAnimalStereotype()
+ {
+ StereotypeMetaModel animalStereotype = new StereotypeMetaModel(new MutableAnnotatedWebBean(AnimalStereotype.class));
+ assert animalStereotype.getDefaultScopeType() == null;
+ assert animalStereotype.getInterceptorBindings().size() == 0;
+ assert animalStereotype.getRequiredTypes().size() == 1;
+ assert Animal.class.equals(animalStereotype.getRequiredTypes().iterator().next());
+ assert animalStereotype.getSupportedScopes().size() == 0;
+ assert !animalStereotype.isComponentNameDefaulted();
+ assert animalStereotype.getDefaultDeploymentType() == null;
+ }
+
+ @Test
+ public void testAnimalOrderStereotype()
+ {
+ StereotypeMetaModel animalStereotype = new StereotypeMetaModel(new MutableAnnotatedWebBean(AnimalOrderStereotype.class));
+ assert animalStereotype.getDefaultScopeType() == null;
+ assert animalStereotype.getInterceptorBindings().size() == 0;
+ assert animalStereotype.getRequiredTypes().size() == 2;
+ Class<?> [] requiredTypes = {Animal.class, Order.class};
+ assert animalStereotype.getRequiredTypes().containsAll(Arrays.asList(requiredTypes));
+ assert animalStereotype.getSupportedScopes().size() == 0;
+ assert !animalStereotype.isComponentNameDefaulted();
+ assert animalStereotype.getDefaultDeploymentType() == null;
+ }
+
+ @Test
+ public void testRequestScopedAnimalStereotype()
+ {
+ StereotypeMetaModel animalStereotype = new StereotypeMetaModel(new MutableAnnotatedWebBean(RequestScopedAnimalStereotype.class));
+ assert animalStereotype.getDefaultScopeType() == null;
+ assert animalStereotype.getInterceptorBindings().size() == 0;
+ assert animalStereotype.getRequiredTypes().size() == 1;
+ assert Animal.class.equals(animalStereotype.getRequiredTypes().iterator().next());
+ assert animalStereotype.getSupportedScopes().size() == 1;
+ assert RequestScoped.class.equals(animalStereotype.getSupportedScopes().iterator().next());
+ assert !animalStereotype.isComponentNameDefaulted();
+ assert animalStereotype.getDefaultDeploymentType() == null;
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/StereotypeMetaModelTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Animal.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Animal.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Animal.java 2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.test.components;
+
+public interface Animal
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Animal.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalOrderStereotype.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalOrderStereotype.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalOrderStereotype.java 2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,17 @@
+package org.jboss.webbeans.test.components;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.Stereotype;
+
+(a)Stereotype(requiredTypes={Animal.class, Order.class})
+@Target( { TYPE })
+@Retention(RUNTIME)
+public @interface AnimalOrderStereotype
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalOrderStereotype.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalStereotype.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalStereotype.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalStereotype.java 2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,17 @@
+package org.jboss.webbeans.test.components;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.Stereotype;
+
+(a)Stereotype(requiredTypes=Animal.class)
+@Target( { TYPE })
+@Retention(RUNTIME)
+public @interface AnimalStereotype
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/AnimalStereotype.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ClassWithNoAnnotations.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ClassWithNoAnnotations.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ClassWithNoAnnotations.java 2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.test.components;
+
+public class ClassWithNoAnnotations
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ClassWithNoAnnotations.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Gorilla.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Gorilla.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Gorilla.java 2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,7 @@
+package org.jboss.webbeans.test.components;
+
+@AnimalStereotype
+public class Gorilla implements Animal
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Gorilla.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/RequestScopedAnimalStereotype.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/RequestScopedAnimalStereotype.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/RequestScopedAnimalStereotype.java 2008-06-26 18:53:21 UTC (rev 17)
@@ -0,0 +1,18 @@
+package org.jboss.webbeans.test.components;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.RequestScoped;
+import javax.webbeans.Stereotype;
+
+(a)Stereotype(requiredTypes=Animal.class, supportedScopes=RequestScoped.class)
+@Target( { TYPE })
+@Retention(RUNTIME)
+public @interface RequestScopedAnimalStereotype
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/RequestScopedAnimalStereotype.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years, 5 months
[webbeans-commits] Webbeans SVN: r16 - in ri/trunk/webbeans-api: .settings and 1 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-06-26 14:52:46 -0400 (Thu, 26 Jun 2008)
New Revision: 16
Added:
ri/trunk/webbeans-api/.settings/
ri/trunk/webbeans-api/.settings/org.eclipse.jdt.core.prefs
ri/trunk/webbeans-api/.settings/org.eclipse.jdt.ui.prefs
Modified:
ri/trunk/webbeans-api/src/main/java/javax/webbeans/Current.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/RequestScoped.java
ri/trunk/webbeans-api/src/main/java/javax/webbeans/Stereotype.java
Log:
A couple of minor fixes
Added: ri/trunk/webbeans-api/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- ri/trunk/webbeans-api/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ ri/trunk/webbeans-api/.settings/org.eclipse.jdt.core.prefs 2008-06-26 18:52:46 UTC (rev 16)
@@ -0,0 +1,256 @@
+#Mon Jun 23 17:31:13 BST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_assignment=0
+org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
+org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
+org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_after_package=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=0
+org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
+org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
+org.eclipse.jdt.core.formatter.blank_lines_before_method=1
+org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
+org.eclipse.jdt.core.formatter.blank_lines_before_package=0
+org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
+org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
+org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
+org.eclipse.jdt.core.formatter.comment.format_block_comments=true
+org.eclipse.jdt.core.formatter.comment.format_header=false
+org.eclipse.jdt.core.formatter.comment.format_html=true
+org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
+org.eclipse.jdt.core.formatter.comment.format_line_comments=true
+org.eclipse.jdt.core.formatter.comment.format_source_code=true
+org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
+org.eclipse.jdt.core.formatter.comment.line_length=80
+org.eclipse.jdt.core.formatter.compact_else_if=true
+org.eclipse.jdt.core.formatter.continuation_indentation=2
+org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
+org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
+org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_empty_lines=false
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
+org.eclipse.jdt.core.formatter.indentation.size=3
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
+org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.lineSplit=80
+org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
+org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
+org.eclipse.jdt.core.formatter.tabulation.char=space
+org.eclipse.jdt.core.formatter.tabulation.size=3
+org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
+org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
Property changes on: ri/trunk/webbeans-api/.settings/org.eclipse.jdt.core.prefs
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-api/.settings/org.eclipse.jdt.ui.prefs
===================================================================
--- ri/trunk/webbeans-api/.settings/org.eclipse.jdt.ui.prefs (rev 0)
+++ ri/trunk/webbeans-api/.settings/org.eclipse.jdt.ui.prefs 2008-06-26 18:52:46 UTC (rev 16)
@@ -0,0 +1,5 @@
+#Mon Jun 23 17:31:14 BST 2008
+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/>
Property changes on: ri/trunk/webbeans-api/.settings/org.eclipse.jdt.ui.prefs
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/Current.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/Current.java 2008-06-25 10:50:10 UTC (rev 15)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/Current.java 2008-06-26 18:52:46 UTC (rev 16)
@@ -11,7 +11,7 @@
@Target( { TYPE, METHOD })
@Retention(RUNTIME)
@Documented
-@ScopeType
+@BindingType
public @interface Current
{
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/RequestScoped.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/RequestScoped.java 2008-06-25 10:50:10 UTC (rev 15)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/RequestScoped.java 2008-06-26 18:52:46 UTC (rev 16)
@@ -13,7 +13,7 @@
@Target( { METHOD, FIELD, PARAMETER, TYPE })
@Retention(RUNTIME)
@Documented
-@BindingType
+@ScopeType
public @interface RequestScoped
{
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/Stereotype.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/Stereotype.java 2008-06-25 10:50:10 UTC (rev 15)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/Stereotype.java 2008-06-26 18:52:46 UTC (rev 16)
@@ -3,6 +3,7 @@
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@@ -13,4 +14,8 @@
public @interface Stereotype
{
+ public Class<? extends Annotation>[] supportedScopes() default {};
+
+ public Class<?>[] requiredTypes() default {};
+
}
16 years, 5 months
[webbeans-commits] Webbeans SVN: r15 - in ri/trunk/webbeans-impl: src/main/java/org/jboss/webbeans and 4 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-06-25 06:50:10 -0400 (Wed, 25 Jun 2008)
New Revision: 15
Added:
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/CurrentBinding.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/EnhancedAnnotatedElement.java
ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableEnhancedAnnotatedElement.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentInstanceTest.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableEnhancedAnnotatedElementTest.java
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/
ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Order.java
Modified:
ri/trunk/webbeans-impl/pom.xml
Log:
Start WBRI-3 - component meta model and WBRI-13
Modified: ri/trunk/webbeans-impl/pom.xml
===================================================================
--- ri/trunk/webbeans-impl/pom.xml 2008-06-25 10:48:42 UTC (rev 14)
+++ ri/trunk/webbeans-impl/pom.xml 2008-06-25 10:50:10 UTC (rev 15)
@@ -1,21 +1,26 @@
-<?xml version="1.0"?><project>
- <parent>
- <artifactId>parent</artifactId>
- <groupId>org.jboss.webbeans</groupId>
- <version>1.0.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.jboss.webbeans</groupId>
- <artifactId>webbeans-impl</artifactId>
- <name>webbeans-impl</name>
- <version>1.0-SNAPSHOT</version>
- <url>http://maven.apache.org</url>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
+<?xml version="1.0"?>
+<project>
+ <parent>
+ <artifactId>parent</artifactId>
+ <groupId>org.jboss.webbeans</groupId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.webbeans</groupId>
+ <artifactId>webbeans-impl</artifactId>
+ <name>Web Beans RI</name>
+ <dependencies>
+
+ <dependency>
+ <groupId>org.jboss.webbeans</groupId>
+ <artifactId>webbeans-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
</project>
\ No newline at end of file
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-06-25 10:50:10 UTC (rev 15)
@@ -0,0 +1,152 @@
+package org.jboss.webbeans;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.util.Arrays;
+import java.util.Set;
+
+import javax.webbeans.BindingType;
+import javax.webbeans.ComponentInstance;
+import javax.webbeans.Container;
+import javax.webbeans.Current;
+import javax.webbeans.DeploymentType;
+import javax.webbeans.Named;
+import javax.webbeans.ScopeType;
+import javax.webbeans.Stereotype;
+
+import org.jboss.webbeans.util.EnhancedAnnotatedElement;
+
+/**
+ * Web Beans Component meta model
+ *
+ * @author Pete Muir
+ *
+ */
+public class ComponentInstanceImpl<T> extends ComponentInstance<T>
+{
+
+ private Set<Annotation> bindingTypes;
+ private Annotation componentType;
+ private String name;
+ private Annotation scopeType;
+ private Set<Annotation> stereotypes;
+
+ public ComponentInstanceImpl(EnhancedAnnotatedElement annotatedElement)
+ {
+ initSterotypes(annotatedElement);
+ initBindingTypes(annotatedElement);
+ initComponentType(annotatedElement);
+ initScopeType(annotatedElement);
+ initName(annotatedElement);
+ }
+
+ private void initSterotypes(EnhancedAnnotatedElement annotatedElement)
+ {
+ this.stereotypes = annotatedElement.getAnnotations(Stereotype.class);
+ }
+
+ private void initScopeType(EnhancedAnnotatedElement annotatedElement)
+ {
+ Set<Annotation> scopes = annotatedElement.getAnnotations(ScopeType.class);
+ if (scopes.size() > 1)
+ {
+ throw new RuntimeException("At most one scope may be specified");
+ }
+ else if (scopes.size() == 1)
+ {
+ this.scopeType = scopes.iterator().next();
+ }
+ else
+ {
+ // TODO Look at sterotypes
+ }
+ }
+
+ private void initComponentType(EnhancedAnnotatedElement 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.componentType = deploymentTypes.iterator().next();
+ }
+ else
+ {
+ // TODO Look at sterotypes
+ }
+ }
+
+ private void initBindingTypes(EnhancedAnnotatedElement annotatedElement)
+ {
+ bindingTypes = annotatedElement.getAnnotations(BindingType.class);
+
+ // Add the default binding if needed
+ if (bindingTypes.size() == 0)
+ {
+ bindingTypes.add(new CurrentBinding());
+ }
+ }
+
+ private void initName(EnhancedAnnotatedElement annotatedElement)
+ {
+ if (annotatedElement.isAnnotationPresent(Named.class))
+ {
+ String name = annotatedElement.getAnnotation(Named.class).value();
+ if ("".equals(name))
+ {
+ // TODO write default name algorithm
+
+ }
+ this.name = name;
+ }
+ }
+
+ @Override
+ public T create(Container container)
+ {
+ // TODO Auto-generated method stub
+ 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 getComponentType()
+ {
+ return componentType;
+ }
+
+ @Override
+ public String getName()
+ {
+ return name;
+ }
+
+ @Override
+ public Set<Class> getTypes()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Annotation getScopeType()
+ {
+ return scopeType;
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/CurrentBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/CurrentBinding.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/CurrentBinding.java 2008-06-25 10:50:10 UTC (rev 15)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans;
+
+import javax.webbeans.Current;
+import javax.webbeans.DynamicBinding;
+
+public class CurrentBinding extends DynamicBinding<Current> implements Current {}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/CurrentBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/EnhancedAnnotatedElement.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/EnhancedAnnotatedElement.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/EnhancedAnnotatedElement.java 2008-06-25 10:50:10 UTC (rev 15)
@@ -0,0 +1,18 @@
+package org.jboss.webbeans.util;
+
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+public interface EnhancedAnnotatedElement
+{
+
+ public abstract <T extends Annotation> Set<T> getAnnotations();
+
+ public abstract <T extends Annotation> Set<Annotation> getAnnotations(
+ Class<T> metaAnnotationType);
+
+ public <T extends Annotation> T getAnnotation(Class<T> arg0);
+
+ public boolean isAnnotationPresent(Class<? extends Annotation> arg0);
+
+}
\ No newline at end of file
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/EnhancedAnnotatedElement.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableEnhancedAnnotatedElement.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableEnhancedAnnotatedElement.java (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableEnhancedAnnotatedElement.java 2008-06-25 10:50:10 UTC (rev 15)
@@ -0,0 +1,113 @@
+package org.jboss.webbeans.util;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+/**
+ * Helper class which allows us to store the annotations present on an object
+ *
+ * Also allows you to discover meta annotations
+ *
+ * @author pmuir
+ *
+ */
+public class MutableEnhancedAnnotatedElement implements EnhancedAnnotatedElement
+{
+
+ private Map<Class<? extends Annotation>, Annotation> annotations;
+
+ private Map<Class<? extends Annotation>, Set<Annotation>> metaAnnotations;
+ private Set<Annotation> annotationSet;
+
+ public MutableEnhancedAnnotatedElement()
+ {
+ this.annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+ }
+
+ public MutableEnhancedAnnotatedElement(AnnotatedElement annotatedElement)
+ {
+ this();
+ for (Annotation annotation : annotatedElement.getAnnotations())
+ {
+ add(annotation);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType)
+ {
+ return (T) annotations.get(annotationType);
+ }
+
+ private void setDirty()
+ {
+ metaAnnotations = null;
+ this.annotationSet = null;
+ }
+
+ public <T extends Annotation> Set<Annotation> getAnnotations(Class<T> metaAnnotationType)
+ {
+ if (metaAnnotations == null)
+ {
+ metaAnnotations = new HashMap<Class<? extends Annotation>, Set<Annotation>>();
+ }
+ if (!metaAnnotations.containsKey(metaAnnotationType))
+ {
+ Set<Annotation> s = new HashSet<Annotation>();
+ for (Entry<Class<? extends Annotation>, Annotation> entry : annotations.entrySet())
+ {
+ if (entry.getValue().annotationType().isAnnotationPresent(metaAnnotationType))
+ {
+ s.add(entry.getValue());
+ }
+ }
+ metaAnnotations.put(metaAnnotationType, s);
+ }
+ return metaAnnotations.get(metaAnnotationType);
+ }
+
+
+ public Set<Annotation> getAnnotations()
+ {
+ if (annotationSet == null)
+ {
+ annotationSet = new HashSet<Annotation>();
+ for (Entry<Class<? extends Annotation>, Annotation> entry : annotations.entrySet())
+ {
+ annotationSet.add(entry.getValue());
+ }
+ }
+ return annotationSet;
+ }
+
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotatedType)
+ {
+ return annotations.containsKey(annotatedType);
+ }
+
+ /**
+ * Add an annotation to the AnnotatedElement
+ * @param annotation
+ */
+ public void add(Annotation annotation)
+ {
+ setDirty();
+ annotations.put(annotation.annotationType(), annotation);
+ }
+
+ public void addAll(Collection<Annotation> annotations)
+ {
+ for (Annotation annotation : annotations)
+ {
+ this.annotations.put(annotation.annotationType(), annotation);
+ }
+ setDirty();
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/util/MutableEnhancedAnnotatedElement.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: 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 (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentInstanceTest.java 2008-06-25 10:50:10 UTC (rev 15)
@@ -0,0 +1,22 @@
+package org.jboss.webbeans.test;
+
+import javax.webbeans.ComponentInstance;
+import javax.webbeans.Production;
+
+import org.jboss.webbeans.ComponentInstanceImpl;
+import org.jboss.webbeans.test.components.Order;
+import org.jboss.webbeans.util.MutableEnhancedAnnotatedElement;
+import org.junit.Test;
+
+public class ComponentInstanceTest
+{
+
+ @Test
+ public void testMetaModel()
+ {
+ ComponentInstance<Order> order = new ComponentInstanceImpl<Order>(new MutableEnhancedAnnotatedElement(Order.class));
+ assert Production.class.equals(order.getComponentType().annotationType());
+ assert "order".equals(order.getName());
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentInstanceTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableEnhancedAnnotatedElementTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableEnhancedAnnotatedElementTest.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableEnhancedAnnotatedElementTest.java 2008-06-25 10:50:10 UTC (rev 15)
@@ -0,0 +1,66 @@
+package org.jboss.webbeans.test;
+
+import java.lang.annotation.Annotation;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.webbeans.Current;
+import javax.webbeans.DeploymentType;
+import javax.webbeans.Named;
+import javax.webbeans.Production;
+import javax.webbeans.ScopeType;
+
+import org.jboss.webbeans.CurrentBinding;
+import org.jboss.webbeans.test.components.Order;
+import org.jboss.webbeans.util.EnhancedAnnotatedElement;
+import org.jboss.webbeans.util.MutableEnhancedAnnotatedElement;
+import org.junit.Test;
+
+public class MutableEnhancedAnnotatedElementTest
+{
+
+ @Test
+ public void testDeclaredAnnotations()
+ {
+ EnhancedAnnotatedElement annotatedElement = new MutableEnhancedAnnotatedElement(Order.class);
+ assert annotatedElement.getAnnotations().size() == 2;
+ assert annotatedElement.getAnnotation(Production.class) != null;
+ assert annotatedElement.getAnnotation(Named.class) != null;
+ }
+
+ @Test
+ public void testMutability()
+ {
+ MutableEnhancedAnnotatedElement annotatedElement = new MutableEnhancedAnnotatedElement(Order.class);
+ assert annotatedElement.getAnnotations().size() == 2;
+ annotatedElement.add(new CurrentBinding());
+ assert annotatedElement.getAnnotations().size() == 3;
+ assert annotatedElement.getAnnotation(Production.class) != null;
+ assert annotatedElement.getAnnotation(Named.class) != null;
+ assert annotatedElement.getAnnotation(Current.class) != null;
+ }
+
+ @Test
+ public void testMetaAnnotations()
+ {
+ EnhancedAnnotatedElement annotatedElement = new MutableEnhancedAnnotatedElement(Order.class);
+ Set<Annotation> annotations = annotatedElement.getAnnotations(DeploymentType.class);
+ assert annotations.size() == 1;
+ Iterator<Annotation> it = annotations.iterator();
+ Annotation production = it.next();
+ assert Production.class.equals(production.annotationType());
+ }
+
+ @Test
+ public void testMutableMetaAnnotations()
+ {
+ MutableEnhancedAnnotatedElement annotatedElement = new MutableEnhancedAnnotatedElement(Order.class);
+ annotatedElement.add(new CurrentBinding());
+ Set<Annotation> annotations = annotatedElement.getAnnotations(ScopeType.class);
+ assert annotations.size() == 1;
+ Iterator<Annotation> it = annotations.iterator();
+ Annotation production = it.next();
+ assert Current.class.equals(production.annotationType());
+ }
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/MutableEnhancedAnnotatedElementTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Order.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Order.java (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Order.java 2008-06-25 10:50:10 UTC (rev 15)
@@ -0,0 +1,11 @@
+package org.jboss.webbeans.test.components;
+
+import javax.webbeans.Named;
+import javax.webbeans.Production;
+
+@Production
+@Named("order")
+public class Order
+{
+
+}
Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Order.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years, 5 months