Author: pete.muir(a)jboss.org
Date: 2009-04-05 20:39:03 -0400 (Sun, 05 Apr 2009)
New Revision: 2309
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/ELCurrentActivityTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/EventCurrentActivityTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/InactiveScopeTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/InjectedManagerCurrentActivityTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/InstanceCurrentActivityTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/JndiManagerCurrentActivityTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/NonNormalScopeTest.java
Removed:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/CurrentActivityTest.java
Modified:
ri/trunk/api/src/main/java/javax/inject/AnnotationLiteral.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/FacadeImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/ManagerBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/resources/ManagerObjectFactory.java
tck/trunk/impl/src/main/resources/tck-audit.xml
Log:
Current activities
Modified: ri/trunk/api/src/main/java/javax/inject/AnnotationLiteral.java
===================================================================
--- ri/trunk/api/src/main/java/javax/inject/AnnotationLiteral.java 2009-04-05 23:32:31 UTC
(rev 2308)
+++ ri/trunk/api/src/main/java/javax/inject/AnnotationLiteral.java 2009-04-06 00:39:03 UTC
(rev 2309)
@@ -91,21 +91,11 @@
return null;
}
- /**
- * {@inheritDoc}
- *
- * @return {@inheritDoc}
- */
public Class<? extends Annotation> annotationType()
{
return annotationType;
}
- /**
- * {@inheritDoc}
- *
- * @return {@inheritDoc}
- */
@Override
public String toString()
{
@@ -122,12 +112,6 @@
return string + ")";
}
- /**
- * {@inheritDoc}
- *
- * @param other {@inheritDoc}
- * @return {@inheritDoc}
- */
@Override
public boolean equals(Object other)
{
@@ -152,11 +136,6 @@
}
@Override
- /**
- * {@inheritDoc}
- *
- * @return {@inheritDoc}
- */
public int hashCode()
{
int hashCode = 0;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/FacadeImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/FacadeImpl.java 2009-04-05 23:32:31 UTC
(rev 2308)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/FacadeImpl.java 2009-04-06 00:39:03 UTC
(rev 2309)
@@ -22,7 +22,6 @@
import java.util.Set;
import javax.inject.DuplicateBindingTypeException;
-import javax.inject.manager.Manager;
import org.jboss.webbeans.metadata.MetaDataCache;
@@ -41,7 +40,7 @@
// The binding types the helper operates on
protected final Set<? extends Annotation> bindings;
// The Web Beans manager
- protected final ManagerImpl manager;
+ private final ManagerImpl manager;
// The type of the operation
protected final Class<T> type;
@@ -76,7 +75,7 @@
result.addAll(bindings);
for (Annotation newAnnotation : newBindings)
{
- if
(!manager.getServices().get(MetaDataCache.class).getBindingTypeModel(newAnnotation.annotationType()).isValid())
+ if
(!getManager().getServices().get(MetaDataCache.class).getBindingTypeModel(newAnnotation.annotationType()).isValid())
{
throw new IllegalArgumentException(newAnnotation + " is not a binding
for " + this);
}
@@ -88,4 +87,9 @@
return result.toArray(EMPTY_BINDINGS);
}
+ protected ManagerImpl getManager()
+ {
+ return manager.getCurrent();
+ }
+
}
\ No newline at end of file
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java 2009-04-05 23:32:31
UTC (rev 2308)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java 2009-04-06 00:39:03
UTC (rev 2309)
@@ -63,7 +63,7 @@
*/
public T get(Annotation... bindings)
{
- return manager.getInstanceByType(type, mergeInBindings(bindings));
+ return getManager().getInstanceByType(type, mergeInBindings(bindings));
}
/**
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-04-05 23:32:31
UTC (rev 2308)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-04-06 00:39:03
UTC (rev 2309)
@@ -101,6 +101,54 @@
public class ManagerImpl implements WebBeansManager, Serializable
{
+ private static class CurrentActivity
+ {
+
+ private final Context context;
+ private final ManagerImpl manager;
+
+ public CurrentActivity(Context context, ManagerImpl manager)
+ {
+ this.context = context;
+ this.manager = manager;
+ }
+
+ public Context getContext()
+ {
+ return context;
+ }
+
+ public ManagerImpl getManager()
+ {
+ return manager;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof CurrentActivity)
+ {
+ return this.getContext().equals(((CurrentActivity) obj).getContext());
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return getContext().hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ return getContext() + " -> " + getManager();
+ }
+ }
+
private static final Log log = Logging.getLog(ManagerImpl.class);
private static final long serialVersionUID = 3021562879133838561L;
@@ -121,22 +169,21 @@
*/
private transient List<Class<? extends Annotation>>
enabledDeploymentTypes;
private transient final ConcurrentListMultiMap<Class<? extends Annotation>,
Context> contexts;
+ private final transient Set<CurrentActivity> currentActivities;
private transient final ClientProxyProvider clientProxyProvider;
private transient final Map<Class<?>, EnterpriseBean<?>>
newEnterpriseBeans;
private transient final Map<String, RIBean<?>> riBeans;
private final transient Map<Bean<?>, Bean<?>> specializedBeans;
private final transient AtomicInteger ids;
-
/*
* Activity scoped services
* *************************
*/
private transient final EventManager eventManager;
private transient final Resolver resolver;
- private final transient NonContextualInjector nonContextualInjector;
+ private final transient NonContextualInjector nonContextualInjector;
-
/*
* Activity scoped data structures
* ********************************
@@ -170,6 +217,7 @@
new ConcurrentHashMap<String, RIBean<?>>(),
new ClientProxyProvider(),
new ConcurrentListHashMultiMap<Class<? extends Annotation>,
Context>(),
+ new CopyOnWriteArraySet<CurrentActivity>(),
new HashMap<Bean<?>, Bean<?>>(),
defaultEnabledDeploymentTypes,
new AtomicInteger()
@@ -200,6 +248,7 @@
parentManager.getRiBeans(),
parentManager.getClientProxyProvider(),
parentManager.getContexts(),
+ parentManager.getCurrentActivities(),
parentManager.getSpecializedBeans(),
parentManager.getEnabledDeploymentTypes(),
parentManager.getIds()
@@ -220,6 +269,7 @@
Map<String, RIBean<?>> riBeans,
ClientProxyProvider clientProxyProvider,
ConcurrentListMultiMap<Class<? extends Annotation>, Context>
contexts,
+ Set<CurrentActivity> currentActivities,
Map<Bean<?>, Bean<?>> specializedBeans,
List<Class<? extends Annotation>> enabledDeploymentTypes,
AtomicInteger ids
@@ -231,6 +281,7 @@
this.riBeans = riBeans;
this.clientProxyProvider = clientProxyProvider;
this.contexts = contexts;
+ this.currentActivities = currentActivities;
this.specializedBeans = specializedBeans;
this.registeredObservers = registeredObservers;
setEnabledDeploymentTypes(enabledDeploymentTypes);
@@ -993,10 +1044,36 @@
return childActivity;
}
- public Manager setCurrent(Class<? extends Annotation> scopeType)
+ public ManagerImpl setCurrent(Class<? extends Annotation> scopeType)
{
- throw new UnsupportedOperationException();
+ if (!getServices().get(MetaDataCache.class).getScopeModel(scopeType).isNormal())
+ {
+ throw new IllegalArgumentException("Scope must be a normal scope type
" + scopeType);
+ }
+ currentActivities.add(new CurrentActivity(getContext(scopeType), this));
+ return this;
}
+
+ public ManagerImpl getCurrent()
+ {
+ List<CurrentActivity> activeCurrentActivities = new
ArrayList<CurrentActivity>();
+ for (CurrentActivity currentActivity : currentActivities)
+ {
+ if (currentActivity.getContext().isActive())
+ {
+ activeCurrentActivities.add(currentActivity);
+ }
+ }
+ if (activeCurrentActivities.size() == 0)
+ {
+ return CurrentManager.rootManager();
+ }
+ else if (activeCurrentActivities.size() == 1)
+ {
+ return activeCurrentActivities.get(0).getManager();
+ }
+ throw new IllegalStateException("More than one current activity for an active
context " + currentActivities);
+ }
public ServiceRegistry getServices()
{
@@ -1101,6 +1178,11 @@
return ids;
}
+ protected Set<CurrentActivity> getCurrentActivities()
+ {
+ return currentActivities;
+ }
+
public Integer getId()
{
return id;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/ManagerBean.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/ManagerBean.java 2009-04-05
23:32:31 UTC (rev 2308)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/ManagerBean.java 2009-04-06
00:39:03 UTC (rev 2309)
@@ -30,7 +30,7 @@
public ManagerImpl create(CreationalContext<ManagerImpl> creationalContext)
{
- return getManager();
+ return getManager().getCurrent();
}
@Override
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java 2009-04-05
23:32:31 UTC (rev 2308)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java 2009-04-06
00:39:03 UTC (rev 2309)
@@ -25,6 +25,7 @@
import javax.inject.ExecutionException;
import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.ManagerImpl;
/**
* An EL-resolver against the named beans
@@ -86,14 +87,15 @@
{
if (property != null)
{
+ final ManagerImpl manager = CurrentManager.rootManager().getCurrent();
String propertyString = property.toString();
Namespace namespace = null;
if (base == null)
{
- if
(CurrentManager.rootManager().getRootNamespace().contains(propertyString))
+ if (manager.getRootNamespace().contains(propertyString))
{
context.setPropertyResolved(true);
- return
CurrentManager.rootManager().getRootNamespace().get(propertyString);
+ return manager.getRootNamespace().get(propertyString);
}
}
else if (base instanceof Namespace)
@@ -126,7 +128,7 @@
@Override
protected void execute() throws Exception
{
- holder.setValue(CurrentManager.rootManager().getInstanceByName(name));
+ holder.setValue(manager.getInstanceByName(name));
}
}.run();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventImpl.java 2009-04-05
23:32:31 UTC (rev 2308)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventImpl.java 2009-04-06
00:39:03 UTC (rev 2309)
@@ -67,7 +67,7 @@
*/
public void fire(T event, Annotation... bindings)
{
- manager.fireEvent(event, mergeInBindings(bindings));
+ getManager().fireEvent(event, mergeInBindings(bindings));
}
/**
@@ -78,7 +78,7 @@
*/
public void observe(Observer<T> observer, Annotation... bindings)
{
- manager.addObserver(observer, type, mergeInBindings(bindings));
+ getManager().addObserver(observer, type, mergeInBindings(bindings));
}
@Override
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/resources/ManagerObjectFactory.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/resources/ManagerObjectFactory.java 2009-04-05
23:32:31 UTC (rev 2308)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/resources/ManagerObjectFactory.java 2009-04-06
00:39:03 UTC (rev 2309)
@@ -13,7 +13,7 @@
public Object getObjectInstance(Object obj, Name name, Context nameCtx,
Hashtable<?, ?> environment) throws Exception
{
- return CurrentManager.rootManager();
+ return CurrentManager.rootManager().getCurrent();
}
}
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/CurrentActivityTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/CurrentActivityTest.java 2009-04-05
23:32:31 UTC (rev 2308)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/CurrentActivityTest.java 2009-04-06
00:39:03 UTC (rev 2309)
@@ -1,216 +0,0 @@
-package org.jboss.jsr299.tck.tests.activities.current;
-
-import java.lang.annotation.Annotation;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.context.Context;
-import javax.context.ContextNotActiveException;
-import javax.context.Contextual;
-import javax.context.CreationalContext;
-import javax.event.Observer;
-import javax.inject.AnnotationLiteral;
-import javax.inject.manager.Bean;
-import javax.inject.manager.Manager;
-
-import org.hibernate.tck.annotations.SpecAssertion;
-import org.hibernate.tck.annotations.SpecAssertions;
-import org.jboss.jsr299.tck.AbstractJSR299Test;
-import org.jboss.jsr299.tck.ForwardingBean;
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.testng.annotations.Test;
-
-@Artifact
-public class CurrentActivityTest extends AbstractJSR299Test
-{
-
- static interface TestableObserver<T> extends Observer<T>
- {
-
- boolean isObserved();
-
- }
-
-
- private static class DummyContext implements Context
- {
-
- private boolean active = true;
-
- public <T> T get(Contextual<T> contextual)
- {
- return null;
- }
-
- public <T> T get(Contextual<T> contextual, CreationalContext<T>
creationalContext)
- {
- return null;
- }
-
- public Class<? extends Annotation> getScopeType()
- {
- return Dummy.class;
- }
-
- public boolean isActive()
- {
- return active;
- }
-
- public void setActive(boolean active)
- {
- this.active = active;
- }
-
- }
-
- private static class NonNormalContext extends DummyContext
- {
-
- @Override
- public Class<? extends Annotation> getScopeType()
- {
- return NonNormalScope.class;
- }
-
- }
-
- @Test(groups="ri-broken",
expectedExceptions=ContextNotActiveException.class)
- @SpecAssertion(section="11.6.1", id="b")
- public void testInactiveScope()
- {
- DummyContext dummyContext = new DummyContext();
- dummyContext.setActive(false);
- getCurrentManager().addContext(dummyContext);
- Manager childActivity = getCurrentManager().createActivity();
- childActivity.setCurrent(dummyContext.getScopeType());
- }
-
- @Test(groups="ri-broken",
expectedExceptions=IllegalArgumentException.class)
- @SpecAssertion(section="11.6.1", id="c")
- public void testNonNormalScope()
- {
- Context dummyContext = new NonNormalContext();
- getCurrentManager().addContext(dummyContext);
- Manager childActivity = getCurrentManager().createActivity();
- childActivity.setCurrent(dummyContext.getScopeType());
- }
-
- @Test(groups="ri-broken")
- @SpecAssertion(section="11.6.1", id="d")
- public void testELEvaluationProcessedByCurrentActivty()
- {
- Context dummyContext = new DummyContext();
- getCurrentManager().addContext(dummyContext);
- assert getCurrentManager().resolveByType(Cow.class).size() == 1;
- final Bean<Cow> bean =
getCurrentManager().resolveByType(Cow.class).iterator().next();
- Manager childActivity = getCurrentManager().createActivity();
- childActivity.addBean(new ForwardingBean<Cow>(childActivity)
- {
-
- @Override
- protected Bean<Cow> delegate()
- {
- return bean;
- }
-
- @Override
- public String getName()
- {
- return "daisy";
- }
-
- });
- childActivity.setCurrent(dummyContext.getScopeType());
- assert
getCurrentConfiguration().getEl().evaluateValueExpression("#{daisy}", Cow.class)
!= null;
- }
-
- @Test(groups="ri-broken")
- @SpecAssertion(section="11.6.1", id="e")
- public void testInjectedManagerIsCurrentActivity()
- {
- Context dummyContext = new DummyContext();
- getCurrentManager().addContext(dummyContext);
- assert getCurrentManager().resolveByType(Cow.class).size() == 1;
- Manager childActivity = getCurrentManager().createActivity();
- childActivity.setCurrent(dummyContext.getScopeType());
- assert
getCurrentManager().getInstanceByType(Horse.class).getManager().equals(childActivity);
- }
-
-
- @Test(groups="ri-broken")
- @SpecAssertion(section="11.6.1", id="f")
- public void testJndiManagerIsCurrentActivity()
- {
- Context dummyContext = new DummyContext();
- getCurrentManager().addContext(dummyContext);
- assert getCurrentManager().resolveByType(Cow.class).size() == 1;
- Manager childActivity = getCurrentManager().createActivity();
- childActivity.setCurrent(dummyContext.getScopeType());
- assert
getCurrentManager().getInstanceByType(Donkey.class).getManager().equals(childActivity);
- }
-
- @Test(groups="ri-broken")
- @SpecAssertions({
- @SpecAssertion(section="11.6.1", id="g"),
- @SpecAssertion(section="11.6.1", id="m")
- })
- public void testEventProcessedByCurrentActivity()
- {
- Context dummyContext = new DummyContext();
- getCurrentManager().addContext(dummyContext);
- Manager childActivity = getCurrentManager().createActivity();
- TestableObserver<NightTime> observer = new
TestableObserver<NightTime>()
- {
-
- boolean observed = false;
-
- public void notify(NightTime event)
- {
- observed = true;
- }
-
- public boolean isObserved()
- {
- return observed;
- }
-
- };
- childActivity.addObserver(observer, NightTime.class);
- childActivity.setCurrent(dummyContext.getScopeType());
- getCurrentManager().getInstanceByType(Dusk.class).ping();
- assert observer.isObserved();
- }
-
- @Test(groups="ri-broken")
- @SpecAssertion(section="11.6.1", id="h")
- public void testInstanceProcessedByCurrentActivity()
- {
- Context dummyContext = new DummyContext();
- getCurrentManager().addContext(dummyContext);
- assert getCurrentManager().resolveByType(Cow.class).size() == 1;
- final Bean<Cow> bean =
getCurrentManager().resolveByType(Cow.class).iterator().next();
- Manager childActivity = getCurrentManager().createActivity();
- final Set<Annotation> bindingTypes = new HashSet<Annotation>();
- bindingTypes.add(new AnnotationLiteral<Tame>() {});
- childActivity.addBean(new ForwardingBean<Cow>(childActivity)
- {
-
- @Override
- protected Bean<Cow> delegate()
- {
- return bean;
- }
-
- @Override
- public Set<Annotation> getBindings()
- {
- return bindingTypes;
- }
-
- });
- childActivity.setCurrent(dummyContext.getScopeType());
- assert getCurrentManager().getInstanceByType(Field.class).get() != null;
- }
-
-}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/ELCurrentActivityTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/ELCurrentActivityTest.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/ELCurrentActivityTest.java 2009-04-06
00:39:03 UTC (rev 2309)
@@ -0,0 +1,173 @@
+package org.jboss.jsr299.tck.tests.activities.current;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.context.Context;
+import javax.context.Contextual;
+import javax.context.CreationalContext;
+import javax.context.Dependent;
+import javax.event.Observer;
+import javax.inject.AnnotationLiteral;
+import javax.inject.Production;
+import javax.inject.manager.Bean;
+import javax.inject.manager.InjectionPoint;
+import javax.inject.manager.Manager;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.testng.annotations.Test;
+
+@Artifact
+public class ELCurrentActivityTest extends AbstractJSR299Test
+{
+
+ static interface TestableObserver<T> extends Observer<T>
+ {
+
+ boolean isObserved();
+
+ }
+
+
+ private static class DummyContext implements Context
+ {
+
+ private boolean active = true;
+
+ public <T> T get(Contextual<T> contextual)
+ {
+ return null;
+ }
+
+ public <T> T get(Contextual<T> contextual, CreationalContext<T>
creationalContext)
+ {
+ return null;
+ }
+
+ public Class<? extends Annotation> getScopeType()
+ {
+ return Dummy.class;
+ }
+
+ public boolean isActive()
+ {
+ return active;
+ }
+
+ public void setActive(boolean active)
+ {
+ this.active = active;
+ }
+
+ }
+
+ private static class Daisy extends Bean<Cow>
+ {
+
+ private static final Set<Type> TYPES = new HashSet<Type>();
+
+ private final static Set<Annotation> BINDING_TYPES = new
HashSet<Annotation>();
+
+
+ static
+ {
+ TYPES.add(Cow.class);
+ TYPES.add(Object.class);
+ BINDING_TYPES.add(new AnnotationLiteral<Tame>() {});
+ }
+
+ public Daisy(Manager manager)
+ {
+ super(manager);
+ }
+
+ @Override
+ public Set<Annotation> getBindings()
+ {
+ return BINDING_TYPES;
+ }
+
+ @Override
+ public Class<? extends Annotation> getDeploymentType()
+ {
+ return Production.class;
+ }
+
+ @Override
+ public Set<? extends InjectionPoint> getInjectionPoints()
+ {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public String getName()
+ {
+ return "daisy";
+ }
+
+ @Override
+ public Class<? extends Annotation> getScopeType()
+ {
+ return Dependent.class;
+ }
+
+ @Override
+ public Set<Type> getTypes()
+ {
+ return TYPES;
+ }
+
+ @Override
+ public boolean isNullable()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isSerializable()
+ {
+ return false;
+ }
+
+ public Dummy create(CreationalContext<Dummy> creationalContext)
+ {
+ return null;
+ }
+
+ public void destroy(Dummy instance)
+ {
+
+ }
+
+ public Cow create(CreationalContext<Cow> creationalContext)
+ {
+ return new Cow();
+ }
+
+ public void destroy(Cow instance)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ @Test
+ @SpecAssertion(section="11.6.1", id="d")
+ public void testELEvaluationProcessedByCurrentActivty()
+ {
+ Context dummyContext = new DummyContext();
+ getCurrentManager().addContext(dummyContext);
+ assert getCurrentManager().resolveByType(Cow.class).size() == 1;
+ Manager childActivity = getCurrentManager().createActivity();
+ childActivity.addBean(new Daisy(childActivity));
+ childActivity.setCurrent(dummyContext.getScopeType());
+ assert
getCurrentConfiguration().getEl().evaluateValueExpression("#{daisy}", Cow.class)
!= null;
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/ELCurrentActivityTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/EventCurrentActivityTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/EventCurrentActivityTest.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/EventCurrentActivityTest.java 2009-04-06
00:39:03 UTC (rev 2309)
@@ -0,0 +1,92 @@
+package org.jboss.jsr299.tck.tests.activities.current;
+
+import java.lang.annotation.Annotation;
+
+import javax.context.Context;
+import javax.context.Contextual;
+import javax.context.CreationalContext;
+import javax.event.Observer;
+import javax.inject.manager.Manager;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.hibernate.tck.annotations.SpecAssertions;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.testng.annotations.Test;
+
+@Artifact
+public class EventCurrentActivityTest extends AbstractJSR299Test
+{
+
+ static interface TestableObserver<T> extends Observer<T>
+ {
+
+ boolean isObserved();
+
+ }
+
+
+ private static class DummyContext implements Context
+ {
+
+ private boolean active = true;
+
+ public <T> T get(Contextual<T> contextual)
+ {
+ return null;
+ }
+
+ public <T> T get(Contextual<T> contextual, CreationalContext<T>
creationalContext)
+ {
+ return null;
+ }
+
+ public Class<? extends Annotation> getScopeType()
+ {
+ return Dummy.class;
+ }
+
+ public boolean isActive()
+ {
+ return active;
+ }
+
+ public void setActive(boolean active)
+ {
+ this.active = active;
+ }
+
+ }
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section="11.6.1", id="g")
+ })
+ public void testEventProcessedByCurrentActivity()
+ {
+ Context dummyContext = new DummyContext();
+ getCurrentManager().addContext(dummyContext);
+ Manager childActivity = getCurrentManager().createActivity();
+ TestableObserver<NightTime> observer = new
TestableObserver<NightTime>()
+ {
+
+ boolean observed = false;
+
+ public void notify(NightTime event)
+ {
+ observed = true;
+ }
+
+ public boolean isObserved()
+ {
+ return observed;
+ }
+
+ };
+ childActivity.addObserver(observer, NightTime.class);
+ childActivity.setCurrent(dummyContext.getScopeType());
+ getCurrentManager().getInstanceByType(Dusk.class).ping();
+ assert observer.isObserved();
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/EventCurrentActivityTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/InactiveScopeTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/InactiveScopeTest.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/InactiveScopeTest.java 2009-04-06
00:39:03 UTC (rev 2309)
@@ -0,0 +1,72 @@
+package org.jboss.jsr299.tck.tests.activities.current;
+
+import java.lang.annotation.Annotation;
+
+import javax.context.Context;
+import javax.context.ContextNotActiveException;
+import javax.context.Contextual;
+import javax.context.CreationalContext;
+import javax.event.Observer;
+import javax.inject.manager.Manager;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.testng.annotations.Test;
+
+@Artifact
+public class InactiveScopeTest extends AbstractJSR299Test
+{
+
+ static interface TestableObserver<T> extends Observer<T>
+ {
+
+ boolean isObserved();
+
+ }
+
+
+ private static class DummyContext implements Context
+ {
+
+ private boolean active = true;
+
+ public <T> T get(Contextual<T> contextual)
+ {
+ return null;
+ }
+
+ public <T> T get(Contextual<T> contextual, CreationalContext<T>
creationalContext)
+ {
+ return null;
+ }
+
+ public Class<? extends Annotation> getScopeType()
+ {
+ return Dummy.class;
+ }
+
+ public boolean isActive()
+ {
+ return active;
+ }
+
+ public void setActive(boolean active)
+ {
+ this.active = active;
+ }
+
+ }
+
+ @Test(expectedExceptions=ContextNotActiveException.class)
+ @SpecAssertion(section="11.6.1", id="b")
+ public void testInactiveScope()
+ {
+ DummyContext dummyContext = new DummyContext();
+ dummyContext.setActive(false);
+ getCurrentManager().addContext(dummyContext);
+ Manager childActivity = getCurrentManager().createActivity();
+ childActivity.setCurrent(dummyContext.getScopeType());
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/InactiveScopeTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/InjectedManagerCurrentActivityTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/InjectedManagerCurrentActivityTest.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/InjectedManagerCurrentActivityTest.java 2009-04-06
00:39:03 UTC (rev 2309)
@@ -0,0 +1,71 @@
+package org.jboss.jsr299.tck.tests.activities.current;
+
+import java.lang.annotation.Annotation;
+
+import javax.context.Context;
+import javax.context.Contextual;
+import javax.context.CreationalContext;
+import javax.event.Observer;
+import javax.inject.manager.Manager;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.testng.annotations.Test;
+
+@Artifact
+public class InjectedManagerCurrentActivityTest extends AbstractJSR299Test
+{
+
+ static interface TestableObserver<T> extends Observer<T>
+ {
+
+ boolean isObserved();
+
+ }
+
+ private static class DummyContext implements Context
+ {
+
+ private boolean active = true;
+
+ public <T> T get(Contextual<T> contextual)
+ {
+ return null;
+ }
+
+ public <T> T get(Contextual<T> contextual, CreationalContext<T>
creationalContext)
+ {
+ return null;
+ }
+
+ public Class<? extends Annotation> getScopeType()
+ {
+ return Dummy.class;
+ }
+
+ public boolean isActive()
+ {
+ return active;
+ }
+
+ public void setActive(boolean active)
+ {
+ this.active = active;
+ }
+
+ }
+
+ @Test
+ @SpecAssertion(section="11.6.1", id="e")
+ public void testInjectedManagerIsCurrentActivity()
+ {
+ Context dummyContext = new DummyContext();
+ getCurrentManager().addContext(dummyContext);
+ assert getCurrentManager().resolveByType(Cow.class).size() == 1;
+ Manager childActivity = getCurrentManager().createActivity();
+ childActivity.setCurrent(dummyContext.getScopeType());
+ assert
getCurrentManager().getInstanceByType(Horse.class).getManager().equals(childActivity);
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/InjectedManagerCurrentActivityTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/InstanceCurrentActivityTest.java
(from rev 2307,
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/CurrentActivityTest.java)
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/InstanceCurrentActivityTest.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/InstanceCurrentActivityTest.java 2009-04-06
00:39:03 UTC (rev 2309)
@@ -0,0 +1,186 @@
+package org.jboss.jsr299.tck.tests.activities.current;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.context.Context;
+import javax.context.Contextual;
+import javax.context.CreationalContext;
+import javax.context.Dependent;
+import javax.event.Observer;
+import javax.inject.AnnotationLiteral;
+import javax.inject.Production;
+import javax.inject.manager.Bean;
+import javax.inject.manager.InjectionPoint;
+import javax.inject.manager.Manager;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.testng.annotations.Test;
+
+@Artifact
+public class InstanceCurrentActivityTest extends AbstractJSR299Test
+{
+
+ static interface TestableObserver<T> extends Observer<T>
+ {
+
+ boolean isObserved();
+
+ }
+
+ public static class TameLiteral extends AnnotationLiteral<Tame> implements Tame
{}
+
+
+ private static class DummyContext implements Context
+ {
+
+ private boolean active = true;
+
+ public <T> T get(Contextual<T> contextual)
+ {
+ return null;
+ }
+
+ public <T> T get(Contextual<T> contextual, CreationalContext<T>
creationalContext)
+ {
+ return null;
+ }
+
+ public Class<? extends Annotation> getScopeType()
+ {
+ return Dummy.class;
+ }
+
+ public boolean isActive()
+ {
+ return active;
+ }
+
+ public void setActive(boolean active)
+ {
+ this.active = active;
+ }
+
+ }
+
+ private static class NonNormalContext extends DummyContext
+ {
+
+ @Override
+ public Class<? extends Annotation> getScopeType()
+ {
+ return NonNormalScope.class;
+ }
+
+ }
+
+ private static class Daisy extends Bean<Cow>
+ {
+
+ private static final Set<Type> TYPES = new HashSet<Type>();
+
+ private final static Set<Annotation> BINDING_TYPES = new
HashSet<Annotation>();
+
+
+ static
+ {
+ TYPES.add(Cow.class);
+ TYPES.add(Object.class);
+ BINDING_TYPES.add(new TameLiteral());
+ }
+
+ public Daisy(Manager manager)
+ {
+ super(manager);
+ }
+
+ @Override
+ public Set<Annotation> getBindings()
+ {
+ return BINDING_TYPES;
+ }
+
+ @Override
+ public Class<? extends Annotation> getDeploymentType()
+ {
+ return Production.class;
+ }
+
+ @Override
+ public Set<? extends InjectionPoint> getInjectionPoints()
+ {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public String getName()
+ {
+ return "daisy";
+ }
+
+ @Override
+ public Class<? extends Annotation> getScopeType()
+ {
+ return Dependent.class;
+ }
+
+ @Override
+ public Set<Type> getTypes()
+ {
+ return TYPES;
+ }
+
+ @Override
+ public boolean isNullable()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isSerializable()
+ {
+ return false;
+ }
+
+ public Dummy create(CreationalContext<Dummy> creationalContext)
+ {
+ return null;
+ }
+
+ public void destroy(Dummy instance)
+ {
+
+ }
+
+ public Cow create(CreationalContext<Cow> creationalContext)
+ {
+ return new Cow();
+ }
+
+ public void destroy(Cow instance)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ @Test
+ @SpecAssertion(section="11.6.1", id="h")
+ public void testInstanceProcessedByCurrentActivity()
+ {
+ Context dummyContext = new DummyContext();
+ getCurrentManager().addContext(dummyContext);
+ assert getCurrentManager().resolveByType(Cow.class).size() == 1;
+ Manager childActivity = getCurrentManager().createActivity();
+ childActivity.addBean(new Daisy(childActivity));
+ childActivity.setCurrent(dummyContext.getScopeType());
+ assert getCurrentManager().getInstanceByType(Field.class).get() != null;
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/InstanceCurrentActivityTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/JndiManagerCurrentActivityTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/JndiManagerCurrentActivityTest.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/JndiManagerCurrentActivityTest.java 2009-04-06
00:39:03 UTC (rev 2309)
@@ -0,0 +1,72 @@
+package org.jboss.jsr299.tck.tests.activities.current;
+
+import java.lang.annotation.Annotation;
+
+import javax.context.Context;
+import javax.context.Contextual;
+import javax.context.CreationalContext;
+import javax.event.Observer;
+import javax.inject.manager.Manager;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.testng.annotations.Test;
+
+@Artifact
+public class JndiManagerCurrentActivityTest extends AbstractJSR299Test
+{
+
+ static interface TestableObserver<T> extends Observer<T>
+ {
+
+ boolean isObserved();
+
+ }
+
+
+ private static class DummyContext implements Context
+ {
+
+ private boolean active = true;
+
+ public <T> T get(Contextual<T> contextual)
+ {
+ return null;
+ }
+
+ public <T> T get(Contextual<T> contextual, CreationalContext<T>
creationalContext)
+ {
+ return null;
+ }
+
+ public Class<? extends Annotation> getScopeType()
+ {
+ return Dummy.class;
+ }
+
+ public boolean isActive()
+ {
+ return active;
+ }
+
+ public void setActive(boolean active)
+ {
+ this.active = active;
+ }
+
+ }
+
+ @Test(groups="ri-broken")
+ @SpecAssertion(section="11.6.1", id="f")
+ public void testJndiManagerIsCurrentActivity()
+ {
+ Context dummyContext = new DummyContext();
+ getCurrentManager().addContext(dummyContext);
+ assert getCurrentManager().resolveByType(Cow.class).size() == 1;
+ Manager childActivity = getCurrentManager().createActivity();
+ childActivity.setCurrent(dummyContext.getScopeType());
+ assert
getCurrentManager().getInstanceByType(Donkey.class).getManager().equals(childActivity);
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/JndiManagerCurrentActivityTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/NonNormalScopeTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/NonNormalScopeTest.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/NonNormalScopeTest.java 2009-04-06
00:39:03 UTC (rev 2309)
@@ -0,0 +1,80 @@
+package org.jboss.jsr299.tck.tests.activities.current;
+
+import java.lang.annotation.Annotation;
+
+import javax.context.Context;
+import javax.context.Contextual;
+import javax.context.CreationalContext;
+import javax.event.Observer;
+import javax.inject.manager.Manager;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.testng.annotations.Test;
+
+@Artifact
+public class NonNormalScopeTest extends AbstractJSR299Test
+{
+
+ static interface TestableObserver<T> extends Observer<T>
+ {
+
+ boolean isObserved();
+
+ }
+
+
+ private static class DummyContext implements Context
+ {
+
+ private boolean active = true;
+
+ public <T> T get(Contextual<T> contextual)
+ {
+ return null;
+ }
+
+ public <T> T get(Contextual<T> contextual, CreationalContext<T>
creationalContext)
+ {
+ return null;
+ }
+
+ public Class<? extends Annotation> getScopeType()
+ {
+ return Dummy.class;
+ }
+
+ public boolean isActive()
+ {
+ return active;
+ }
+
+ public void setActive(boolean active)
+ {
+ this.active = active;
+ }
+
+ }
+
+ private static class NonNormalContext extends DummyContext
+ {
+
+ @Override
+ public Class<? extends Annotation> getScopeType()
+ {
+ return NonNormalScope.class;
+ }
+
+ }
+
+ @Test(expectedExceptions=IllegalArgumentException.class)
+ @SpecAssertion(section="11.6.1", id="c")
+ public void testNonNormalScope()
+ {
+ Context dummyContext = new NonNormalContext();
+ getCurrentManager().addContext(dummyContext);
+ Manager childActivity = getCurrentManager().createActivity();
+ childActivity.setCurrent(dummyContext.getScopeType());
+ }
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/NonNormalScopeTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/main/resources/tck-audit.xml
===================================================================
--- tck/trunk/impl/src/main/resources/tck-audit.xml 2009-04-05 23:32:31 UTC (rev 2308)
+++ tck/trunk/impl/src/main/resources/tck-audit.xml 2009-04-06 00:39:03 UTC (rev 2309)
@@ -6404,7 +6404,8 @@
</assertion>
<assertion id="m">
- <text>A bean registered with an activity is only available to Unified EL
expressions that are evaluated when that activity or one of its children is the current
activity.</text>
+ <text>A bean registered with an activity is only available to Unified EL
expressions that are evaluated when that activity or one of its children is the current
activity.</text>
+ <note>This is a statement of intent</note>
</assertion>
</section>