[webbeans-commits] Webbeans SVN: r3559 - ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap and 4 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Wed Aug 19 09:08:02 EDT 2009
Author: pete.muir at jboss.org
Date: 2009-08-19 09:08:01 -0400 (Wed, 19 Aug 2009)
New Revision: 3559
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/EventTypesTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/FireEventTest.java
tck/trunk/impl/src/main/resources/tck-audit-jsr299.xml
Log:
Move where PAT is fired, workaround Java generics oddity
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java 2009-08-19 08:52:29 UTC (rev 3558)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java 2009-08-19 13:08:01 UTC (rev 3559)
@@ -584,13 +584,13 @@
{
throw new IllegalArgumentException("Event type " + resolvedType + " is not allowed");
}
-// for (Type type : types)
-// {
-// if (type instanceof TypeVariable)
-// {
-// throw new IllegalArgumentException("Cannot provide an event type parameterized with a type parameter " + resolvedType);
-// }
-// }
+ for (Type type : types)
+ {
+ if (type instanceof TypeVariable)
+ {
+ throw new IllegalArgumentException("Cannot provide an event type parameterized with a type parameter " + resolvedType);
+ }
+ }
}
/**
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-08-19 08:52:29 UTC (rev 3558)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-08-19 13:08:01 UTC (rev 3559)
@@ -16,7 +16,6 @@
*/
package org.jboss.webbeans.bootstrap;
-import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
@@ -53,18 +52,34 @@
ClassTransformer classTransformer = getManager().getServices().get(ClassTransformer.class);
if (!clazz.isAnnotation() && !clazz.isEnum())
{
- classes.add(classTransformer.loadClass(clazz));
+ ProcessAnnotatedTypeImpl<?> event = createProcessAnnotatedTypeEvent(clazz, classTransformer);
+ getManager().fireEvent(event);
+ if (!event.isVeto())
+ {
+ if (event.getAnnotatedType() instanceof WBClass<?>)
+ {
+ classes.add((WBClass<?>) event.getAnnotatedType());
+ }
+ else
+ {
+ classes.add(classTransformer.loadClass(event.getAnnotatedType()));
+ }
+ }
}
return this;
}
+ private <X> ProcessAnnotatedTypeImpl<X> createProcessAnnotatedTypeEvent(Class<X> clazz, ClassTransformer classTransformer)
+ {
+ WBClass<X> annotatedType = classTransformer.loadClass(clazz);
+ return new ProcessAnnotatedTypeImpl<X>(annotatedType) {};
+ }
+
+ // TODO Do we need to fire PAT for annotated types added via BBD? Probably not PLM.
public AbstractBeanDeployer addClass(AnnotatedType<?> clazz)
{
ClassTransformer classTransformer = getManager().getServices().get(ClassTransformer.class);
- if (!clazz.getJavaClass().isAnnotation() && !clazz.getJavaClass().isEnum())
- {
- classes.add(classTransformer.loadClass(clazz));
- }
+ classes.add(classTransformer.loadClass(clazz));
return this;
}
@@ -77,12 +92,6 @@
return this;
}
- public AbstractBeanDeployer addClasses(Collection<WBClass<?>> classes)
- {
- this.classes.addAll(classes);
- return this;
- }
-
public AbstractBeanDeployer createBeans()
{
for (WBClass<?> clazz : classes)
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-08-19 08:52:29 UTC (rev 3558)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-08-19 13:08:01 UTC (rev 3559)
@@ -19,9 +19,7 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
-import javax.enterprise.inject.spi.AnnotatedType;
import javax.enterprise.inject.spi.BeforeShutdown;
import javax.enterprise.inject.spi.Extension;
@@ -271,7 +269,7 @@
{
synchronized (this)
{
- beanDeployer.addClasses(fireProcessAnnotatedTypeEvents(deploymentVisitor.getBeanClasses()));
+ beanDeployer.addClasses(deploymentVisitor.getBeanClasses());
beanDeployer.getEnvironment().addBean(new ManagerBean(manager));
beanDeployer.getEnvironment().addBean(new InjectionPointBean(manager));
beanDeployer.getEnvironment().addBean(new EventBean(manager));
@@ -413,33 +411,7 @@
throw new DeploymentException(event.getDeploymentProblems().get(0));
}
}
-
- private Collection<WBClass<?>> fireProcessAnnotatedTypeEvents(Iterable<Class<?>> classes)
- {
- ClassTransformer classTransformer = getManager().getServices().get(ClassTransformer.class);
- HashSet<WBClass<?>> finalClassSet = new HashSet<WBClass<?>>();
- for (Class<?> clazz : classes)
- {
- WBClass<?> annotatedType = classTransformer.loadClass(clazz);
- ProcessAnnotatedTypeImpl<?> event = createProcessAnnotatedTypeEvent(annotatedType);
- getManager().fireEvent(event);
- if (!event.isVeto())
- {
- if (event.isAnnotatedTypeReplaced())
- {
- //TODO Create another WBClass<?> that uses this annotated type
- }
- finalClassSet.add(annotatedType);
- }
- }
- return finalClassSet;
- }
- private <X> ProcessAnnotatedTypeImpl<X> createProcessAnnotatedTypeEvent(AnnotatedType<X> annotatedType)
- {
- return new ProcessAnnotatedTypeImpl<X>(annotatedType);
- }
-
/**
* Gets version information
*
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java 2009-08-19 08:52:29 UTC (rev 3558)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java 2009-08-19 13:08:01 UTC (rev 3559)
@@ -75,7 +75,7 @@
assert Shop.deliveryObservedBy.equals(FarmShop.class.getName());
}
- @Test(groups = { "events", "ri-broken" }, expectedExceptions = IllegalArgumentException.class)
+ @Test(groups = { "events" }, expectedExceptions = IllegalArgumentException.class)
@SpecAssertion(section = "11.3.11", id = "c")
public <T> void testEventObjectContainsTypeVariablesWhenResolvingFails()
{
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/EventTypesTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/EventTypesTest.java 2009-08-19 08:52:29 UTC (rev 3558)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/eventTypes/EventTypesTest.java 2009-08-19 13:08:01 UTC (rev 3559)
@@ -59,18 +59,4 @@
assert observer.getObjectEventQuantity() == 1;
assert observer.getTotalEventsObserved() == 4;
}
-
- @Test(groups = { "event", "ri-broken" }, expectedExceptions=IllegalArgumentException.class)
- @SpecAssertion(section = "10.1", id = "cb")
- public <T> void testEventTypeFiredByEventInterfaceMayNotContainTypeVariable()
- {
- getInstanceByType(new TypeLiteral<TuneSelect<T>>(){}).soloArtistPlaying(new Artist<T>());
- }
-
- @Test(groups = { "event", "ri-broken"}, expectedExceptions = IllegalArgumentException.class)
- @SpecAssertion(section = "10.1", id = "cb")
- public void testEventTypeFiredByBeanManagerMayNotContainTypeVariable()
- {
- getCurrentManager().fireEvent(new Artist<Solo>());
- }
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/FireEventTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/FireEventTest.java 2009-08-19 08:52:29 UTC (rev 3558)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/fires/FireEventTest.java 2009-08-19 13:08:01 UTC (rev 3559)
@@ -272,7 +272,7 @@
assert houseKeeping.getItemsMissing().iterator().next() == crackers;
}
- @Test(groups = {"events", "ri-broken"}, expectedExceptions = IllegalArgumentException.class)
+ @Test(groups = {"events"}, expectedExceptions = IllegalArgumentException.class)
@SpecAssertion(section = "10.3.1", id = "f")
public <T> void testEventFireThrowsExceptionIfEventObjectContainsTypeVariable()
{
Modified: tck/trunk/impl/src/main/resources/tck-audit-jsr299.xml
===================================================================
--- tck/trunk/impl/src/main/resources/tck-audit-jsr299.xml 2009-08-19 08:52:29 UTC (rev 3558)
+++ tck/trunk/impl/src/main/resources/tck-audit-jsr299.xml 2009-08-19 13:08:01 UTC (rev 3559)
@@ -4066,8 +4066,9 @@
<text>The event types of the event include all superclasses and interfaces of the runtime class of the event object.</text>
</assertion>
- <assertion id="cb">
+ <assertion id="cb" testable="false">
<text>An event type may not contain a type variable.</text>
+ <note>Doesn't specify an error condition</note>
</assertion>
<assertion id="d">
More information about the weld-commits
mailing list