Author: kabir.khan(a)jboss.com
Date: 2009-09-30 07:34:49 -0400 (Wed, 30 Sep 2009)
New Revision: 3817
Added:
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/context/api/ContextualInstance.java
ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockLifecycle.java
ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/TestContainer.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/Foo.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/NaiveClusterTest.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/SwitchableContainerTest.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/SwitchableSingletonProvider.java
Removed:
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/context/api/ContexutalInstance.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/Foo.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/NaiveClusterTest.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/SwitchableContainerTest.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/SwitchableSingletonProvider.java
Modified:
ri/branches/kabir-builder/
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/SimpleInjectionTarget.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/AbstractMapContext.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/BeanInstanceImpl.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/ContextLifecycle.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/DependentContext.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/DependentInstancesStore.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/beanstore/AbstractAttributeBackedBeanStore.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/beanstore/HashMapBeanStore.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/AbstractWebBeansELResolver.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/ELCreationalContextStack.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/WebBeansMethodExpression.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/WebBeansValueExpression.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/util/Reflections.java
ri/branches/kabir-builder/jboss-as/build.properties
ri/branches/kabir-builder/jboss-tck-runner/pom.xml
ri/branches/kabir-builder/osgi-bundle/pom.xml
ri/branches/kabir-builder/parent/pom.xml
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Lifecycle.java
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingLifecycle.java
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/context/api/BeanStore.java
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/context/api/helpers/AbstractMapBackedBeanStore.java
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/context/api/helpers/ConcurrentHashMapBeanStore.java
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/context/api/helpers/ForwardingBeanStore.java
ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockServletLifecycle.java
ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/test/harness/AbstractStandaloneContainersImpl.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/DiscoverFailsBootstrapTest.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/InjectionServicesTest.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/WBStartupTest.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/SorterTest.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleDecorator1.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleDecorator2.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletEnvironmentTest.java
ri/branches/kabir-builder/tests/unit-tests.xml
ri/branches/kabir-builder/version-matrix/pom.xml
Log:
Merged revisions
3757-3758,3763,3768-3769,3771-3772,3776,3784-3785,3791-3793,3796,3800-3801 via svnmerge
from
https://svn.jboss.org/repos/webbeans/ri/trunk
.......
r3757 | pete.muir(a)jboss.org | 2009-09-23 12:11:51 +0100 (Wed, 23 Sep 2009) | 1 line
add some versions for tomcat
.......
r3758 | pete.muir(a)jboss.org | 2009-09-23 12:12:01 +0100 (Wed, 23 Sep 2009) | 1 line
fix cleanup order
.......
r3763 | pete.muir(a)jboss.org | 2009-09-23 16:10:17 +0100 (Wed, 23 Sep 2009) | 1 line
move versions to version matrix
.......
r3768 | pete.muir(a)jboss.org | 2009-09-23 19:22:11 +0100 (Wed, 23 Sep 2009) | 1 line
support the situation where the ELContextListener isn't registered
.......
r3769 | pete.muir(a)jboss.org | 2009-09-23 20:53:54 +0100 (Wed, 23 Sep 2009) | 1 line
fix some security access problem
.......
r3771 | pete.muir(a)jboss.org | 2009-09-23 22:45:05 +0100 (Wed, 23 Sep 2009) | 1 line
add various jettys deps
.......
r3772 | pete.muir(a)jboss.org | 2009-09-23 22:45:19 +0100 (Wed, 23 Sep 2009) | 1 line
allow default package
.......
r3776 | pete.muir(a)jboss.org | 2009-09-23 23:08:02 +0100 (Wed, 23 Sep 2009) | 1 line
WBRI-390
.......
r3784 | pete.muir(a)jboss.org | 2009-09-25 17:25:33 +0100 (Fri, 25 Sep 2009) | 1 line
Add isXXXActive methods
.......
r3785 | pete.muir(a)jboss.org | 2009-09-25 17:27:20 +0100 (Fri, 25 Sep 2009) | 1 line
Extract test bootstrap code to TestContainer, use it, and start on a naive cluster test
.......
r3791 | cpopetz | 2009-09-28 15:19:21 +0100 (Mon, 28 Sep 2009) | 2 lines
allow creation of InjectionTarget<T> where T is non-Producible by deferring
exception until produce() is invoked
.......
r3792 | rogerk | 2009-09-28 15:37:27 +0100 (Mon, 28 Sep 2009) | 1 line
synch with 1.0.0.PREVIEW4.SP1
.......
r3793 | cpopetz | 2009-09-28 22:33:41 +0100 (Mon, 28 Sep 2009) | 2 lines
No longer need our own build of wicket; move to 1.4.1
.......
r3796 | shane.bryzak(a)jboss.com | 2009-09-29 05:29:31 +0100 (Tue, 29 Sep 2009) | 2 lines
how did this typo get past unnoticed
.......
r3800 | pete.muir(a)jboss.org | 2009-09-29 14:11:46 +0100 (Tue, 29 Sep 2009) | 1 line
Allow running standalone
.......
r3801 | pete.muir(a)jboss.org | 2009-09-29 14:57:56 +0100 (Tue, 29 Sep 2009) | 1 line
Allow running standalone TCK
.......
Property changes on: ri/branches/kabir-builder
___________________________________________________________________
Name: svnmerge-integrated
- /ri/trunk:1-3741
+ /ri/trunk:1-3804
Modified:
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/SimpleInjectionTarget.java
===================================================================
---
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/SimpleInjectionTarget.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/SimpleInjectionTarget.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -57,8 +57,18 @@
this.beanManager = beanManager;
this.type = type;
this.injectionPoints = new HashSet<InjectionPoint>();
- this.constructor = Beans.getBeanConstructor(null, type);
- this.injectionPoints.addAll(Beans.getParameterInjectionPoints(null, constructor));
+ ConstructorInjectionPoint<T> constructor = null;
+ try
+ {
+ constructor = Beans.getBeanConstructor(null, type);
+ this.injectionPoints.addAll(Beans.getParameterInjectionPoints(null,
constructor));
+ }
+ catch (Exception e)
+ {
+ // this means the bean of a type that cannot be produce()d, but that is
non-fatal
+ // unless someone calls produce()
+ }
+ this.constructor = constructor;
this.injectableFields = new HashSet<FieldInjectionPoint<?,?>>();
this.injectableFields.addAll(Beans.getFieldInjectionPoints(null, type));
this.injectionPoints.addAll(injectableFields);
@@ -75,6 +85,16 @@
public T produce(CreationalContext<T> ctx)
{
+ if (constructor == null)
+ {
+ // this means we couldn't find a constructor on instantiation, which
+ // means there isn't one that's spec-compliant
+ // try again so the correct DefinitionException is thrown
+ Beans.getBeanConstructor(null, type);
+ // should not be reached
+ throw new IllegalStateException(
+ "We were not previously able to find the bean constructor, but now
are?");
+ }
return constructor.newInstance(beanManager, ctx);
}
Modified:
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
===================================================================
---
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -80,7 +80,7 @@
return this;
}
- private <X> ProcessAnnotatedTypeImpl<X>
createProcessAnnotatedTypeEvent(Class<X> clazz, ClassTransformer classTransformer)
+ private static <X> ProcessAnnotatedTypeImpl<X>
createProcessAnnotatedTypeEvent(Class<X> clazz, ClassTransformer classTransformer)
{
WBClass<X> annotatedType = classTransformer.loadClass(clazz);
return new ProcessAnnotatedTypeImpl<X>(annotatedType) {};
Modified:
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/AbstractMapContext.java
===================================================================
---
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/AbstractMapContext.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/AbstractMapContext.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -24,7 +24,7 @@
import javax.enterprise.context.spi.CreationalContext;
import org.jboss.webbeans.context.api.BeanStore;
-import org.jboss.webbeans.context.api.ContexutalInstance;
+import org.jboss.webbeans.context.api.ContextualInstance;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -75,7 +75,7 @@
{
throw new IllegalStateException("No bean store available for " +
toString());
}
- ContexutalInstance<T> beanInstance = getBeanStore().get(contextual);
+ ContextualInstance<T> beanInstance = getBeanStore().get(contextual);
if (beanInstance != null)
{
return beanInstance.getInstance();
@@ -128,7 +128,7 @@
{
throw new IllegalStateException("No bean store available for " +
toString());
}
- ContexutalInstance<T> beanInstance = getBeanStore().get(contextual);
+ ContextualInstance<T> beanInstance = getBeanStore().get(contextual);
contextual.destroy(beanInstance.getInstance(),
beanInstance.getCreationalContext());
}
Modified:
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/BeanInstanceImpl.java
===================================================================
---
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/BeanInstanceImpl.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/BeanInstanceImpl.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -19,9 +19,9 @@
import javax.enterprise.context.spi.Contextual;
import javax.enterprise.context.spi.CreationalContext;
-import org.jboss.webbeans.context.api.ContexutalInstance;
+import org.jboss.webbeans.context.api.ContextualInstance;
-public class BeanInstanceImpl<T> implements ContexutalInstance<T>
+public class BeanInstanceImpl<T> implements ContextualInstance<T>
{
private final Contextual<T> contextual;
Modified:
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/ContextLifecycle.java
===================================================================
---
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/ContextLifecycle.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/ContextLifecycle.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -41,11 +41,11 @@
public static LogProvider log = Logging.getLogProvider(ContextLifecycle.class);
- public final ApplicationContext applicationContext;
- public final SessionContext sessionContext;
- public final ConversationContext conversationContext;
- public final RequestContext requestContext;
- public final DependentContext dependentContext;
+ private final ApplicationContext applicationContext;
+ private final SessionContext sessionContext;
+ private final ConversationContext conversationContext;
+ private final RequestContext requestContext;
+ private final DependentContext dependentContext;
public ContextLifecycle(ApplicationContext applicationContext, SessionContext
sessionContext, ConversationContext conversationContext, RequestContext requestContext,
DependentContext dependentContext)
{
@@ -92,9 +92,24 @@
public boolean isRequestActive()
{
- return requestContext.isActive() && dependentContext.isActive();
+ return applicationContext.isActive() && requestContext.isActive()
&& dependentContext.isActive();
}
+ public boolean isApplicationActive()
+ {
+ return applicationContext.isActive() && dependentContext.isActive();
+ }
+
+ public boolean isConversationActive()
+ {
+ return applicationContext.isActive() && sessionContext.isActive()
&& conversationContext.isActive() && dependentContext.isActive();
+ }
+
+ public boolean isSessionActive()
+ {
+ return applicationContext.isActive() && sessionContext.isActive()
&& dependentContext.isActive();
+ }
+
public void beginApplication(BeanStore applicationBeanStore)
{
@@ -116,11 +131,11 @@
public void cleanup()
{
+ dependentContext.cleanup();
+ requestContext.cleanup();
+ conversationContext.cleanup();
+ sessionContext.cleanup();
applicationContext.cleanup();
- sessionContext.cleanup();
- conversationContext.cleanup();
- requestContext.cleanup();
- dependentContext.cleanup();
}
public ApplicationContext getApplicationContext()
Modified:
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/DependentContext.java
===================================================================
---
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/DependentContext.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/DependentContext.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -27,7 +27,7 @@
import javax.enterprise.context.spi.Contextual;
import javax.enterprise.context.spi.CreationalContext;
-import org.jboss.webbeans.context.api.ContexutalInstance;
+import org.jboss.webbeans.context.api.ContextualInstance;
/**
* The dependent context
@@ -63,7 +63,7 @@
if (creationalContext instanceof WBCreationalContext<?>)
{
WBCreationalContext<T> creationalContextImpl =
(WBCreationalContext<T>) creationalContext;
- ContexutalInstance<T> beanInstance = new
BeanInstanceImpl<T>(contextual, instance, creationalContext);
+ ContextualInstance<T> beanInstance = new
BeanInstanceImpl<T>(contextual, instance, creationalContext);
creationalContextImpl.getParentDependentInstancesStore().addDependentInstance(beanInstance);
}
return instance;
Modified:
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/DependentInstancesStore.java
===================================================================
---
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/DependentInstancesStore.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/DependentInstancesStore.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -20,7 +20,7 @@
import java.util.Collections;
import java.util.List;
-import org.jboss.webbeans.context.api.ContexutalInstance;
+import org.jboss.webbeans.context.api.ContextualInstance;
import org.jboss.webbeans.log.Log;
import org.jboss.webbeans.log.Logging;
@@ -34,14 +34,14 @@
private static Log log = Logging.getLog(DependentInstancesStore.class);
// A object -> List of contextual instances mapping
- private List<ContexutalInstance<?>> dependentInstances;
+ private List<ContextualInstance<?>> dependentInstances;
/**
* Creates a new DependentInstancesStore
*/
public DependentInstancesStore()
{
- dependentInstances = Collections.synchronizedList(new
ArrayList<ContexutalInstance<?>>());
+ dependentInstances = Collections.synchronizedList(new
ArrayList<ContextualInstance<?>>());
}
/**
@@ -50,7 +50,7 @@
* @param key The key to store the instance under
* @param contextualInstance The instance to store
*/
- public <T> void addDependentInstance(ContexutalInstance<T>
contextualInstance)
+ public <T> void addDependentInstance(ContextualInstance<T>
contextualInstance)
{
log.trace("Registered dependent instance #0", contextualInstance);
dependentInstances.add(contextualInstance);
@@ -64,13 +64,13 @@
public void destroyDependentInstances()
{
log.trace("Destroying dependent instances");
- for (ContexutalInstance<?> injectedInstance : dependentInstances)
+ for (ContextualInstance<?> injectedInstance : dependentInstances)
{
destroy(injectedInstance);
}
}
- private static <T> void destroy(ContexutalInstance<T> beanInstance)
+ private static <T> void destroy(ContextualInstance<T> beanInstance)
{
beanInstance.getContextual().destroy(beanInstance.getInstance(),
beanInstance.getCreationalContext());
}
Modified:
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/beanstore/AbstractAttributeBackedBeanStore.java
===================================================================
---
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/beanstore/AbstractAttributeBackedBeanStore.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/beanstore/AbstractAttributeBackedBeanStore.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -26,7 +26,7 @@
import org.jboss.webbeans.Container;
import org.jboss.webbeans.ContextualIdStore;
import org.jboss.webbeans.context.api.BeanStore;
-import org.jboss.webbeans.context.api.ContexutalInstance;
+import org.jboss.webbeans.context.api.ContextualInstance;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.util.Names;
@@ -50,11 +50,11 @@
* @return The instance
*/
@SuppressWarnings("unchecked")
- public <T> ContexutalInstance<T> get(Contextual<? extends T>
contextual)
+ public <T> ContextualInstance<T> get(Contextual<? extends T>
contextual)
{
Integer contextualId =
Container.instance().deploymentServices().get(ContextualIdStore.class).getId(contextual);
String key = getNamingScheme().getKeyFromId(contextualId);
- ContexutalInstance<T> instance = (ContexutalInstance<T>)
getAttribute(key);
+ ContextualInstance<T> instance = (ContextualInstance<T>)
getAttribute(key);
log.trace("Looked for " + key + " and got " + instance);
return instance;
}
@@ -131,7 +131,7 @@
* @param instance The instance
* @return The instance added
*/
- public <T> void put(ContexutalInstance<T> beanInstance)
+ public <T> void put(ContextualInstance<T> beanInstance)
{
Integer contextualId =
Container.instance().deploymentServices().get(ContextualIdStore.class).getId(beanInstance.getContextual());
String key = getNamingScheme().getKeyFromId(contextualId);
Modified:
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/beanstore/HashMapBeanStore.java
===================================================================
---
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/beanstore/HashMapBeanStore.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/beanstore/HashMapBeanStore.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -23,7 +23,7 @@
import javax.enterprise.context.spi.Contextual;
-import org.jboss.webbeans.context.api.ContexutalInstance;
+import org.jboss.webbeans.context.api.ContextualInstance;
import org.jboss.webbeans.context.api.helpers.AbstractMapBackedBeanStore;
/**
@@ -37,14 +37,14 @@
private static final long serialVersionUID = 4770689245633688471L;
// The backing map
- protected Map<Contextual<? extends Object>, ContexutalInstance<? extends
Object>> delegate;
+ protected Map<Contextual<? extends Object>, ContextualInstance<? extends
Object>> delegate;
/**
* Constructor
*/
public HashMapBeanStore()
{
- delegate = new HashMap<Contextual<? extends Object>,
ContexutalInstance<? extends Object>>();
+ delegate = new HashMap<Contextual<? extends Object>,
ContextualInstance<? extends Object>>();
}
/**
@@ -53,7 +53,7 @@
* @return The delegate
*/
@Override
- public Map<Contextual<? extends Object>, ContexutalInstance<? extends
Object>> delegate()
+ public Map<Contextual<? extends Object>, ContextualInstance<? extends
Object>> delegate()
{
return delegate;
}
Modified:
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/AbstractWebBeansELResolver.java
===================================================================
---
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/AbstractWebBeansELResolver.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/AbstractWebBeansELResolver.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -16,18 +16,17 @@
*/
package org.jboss.webbeans.el;
+import static org.jboss.webbeans.el.ELCreationalContextStack.getCreationalContextStore;
+
import java.beans.FeatureDescriptor;
import java.util.Iterator;
import java.util.concurrent.Callable;
import javax.el.ELContext;
import javax.el.ELResolver;
-import javax.enterprise.context.spi.Contextual;
-import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Bean;
import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.Container;
/**
* An EL-resolver against the named beans
@@ -37,18 +36,6 @@
public abstract class AbstractWebBeansELResolver extends ELResolver
{
- private static final Contextual<?> CONTEXTUAL = new Contextual<Object>()
- {
-
- public Object create(CreationalContext<Object> creationalContext)
- {
- return null;
- }
-
- public void destroy(Object instance, CreationalContext<Object>
creationalContext) {}
-
- };
-
protected abstract BeanManagerImpl getManager(ELContext context);
@Override
@@ -151,25 +138,6 @@
public void setValue(ELContext context, Object base, Object property, Object value)
{
}
-
- private static ELCreationalContextStack getCreationalContextStore(ELContext context)
- {
- Object o = context.getContext(ELCreationalContextStack.class);
-
- if (!(o instanceof ELCreationalContextStack))
- {
- ELCreationalContextStack store =
ELCreationalContextStack.addToContext(context);
- o = store;
- }
- ELCreationalContextStack store = (ELCreationalContextStack) o;
- if (store.isEmpty())
- {
- // TODO need to use correct manager for module
- ELCreationalContext<?> creationalContext =
ELCreationalContext.of(Container.instance().deploymentManager().createCreationalContext(CONTEXTUAL));
- store.push(creationalContext);
- }
- return (ELCreationalContextStack) o;
- }
}
Modified:
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/ELCreationalContextStack.java
===================================================================
---
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/ELCreationalContextStack.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/ELCreationalContextStack.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -3,10 +3,27 @@
import java.util.Stack;
import javax.el.ELContext;
+import javax.enterprise.context.spi.Contextual;
+import javax.enterprise.context.spi.CreationalContext;
+import org.jboss.webbeans.Container;
+
class ELCreationalContextStack extends Stack<ELCreationalContext<?>>
{
+
+ private static final Contextual<?> CONTEXTUAL = new Contextual<Object>()
+ {
+
+ public Object create(CreationalContext<Object> creationalContext)
+ {
+ return null;
+ }
+
+ public void destroy(Object instance, CreationalContext<Object>
creationalContext) {}
+
+ };
+
private static final long serialVersionUID = -57142365866995726L;
public static ELCreationalContextStack addToContext(ELContext context)
@@ -16,4 +33,24 @@
return store;
}
+
+ public static ELCreationalContextStack getCreationalContextStore(ELContext context)
+ {
+ Object o = context.getContext(ELCreationalContextStack.class);
+
+ if (!(o instanceof ELCreationalContextStack))
+ {
+ ELCreationalContextStack store =
ELCreationalContextStack.addToContext(context);
+ o = store;
+ }
+ ELCreationalContextStack store = (ELCreationalContextStack) o;
+ if (store.isEmpty())
+ {
+ // TODO need to use correct manager for module
+ ELCreationalContext<?> creationalContext =
ELCreationalContext.of(Container.instance().deploymentManager().createCreationalContext(CONTEXTUAL));
+ store.push(creationalContext);
+ }
+ return (ELCreationalContextStack) o;
+ }
+
}
\ No newline at end of file
Modified:
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/WebBeansMethodExpression.java
===================================================================
---
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/WebBeansMethodExpression.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/WebBeansMethodExpression.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -16,6 +16,8 @@
*/
package org.jboss.webbeans.el;
+import static org.jboss.webbeans.el.ELCreationalContextStack.getCreationalContextStore;
+
import javax.el.ELContext;
import javax.el.MethodExpression;
import javax.el.MethodInfo;
@@ -92,15 +94,5 @@
creationalContext.release();
}
}
-
- private ELCreationalContextStack getCreationalContextStore(ELContext context)
- {
- Object o = context.getContext(ELCreationalContextStack.class);
- if (!(o instanceof ELCreationalContextStack))
- {
- throw new IllegalStateException("Something went wrong with the ELContext,
expecting a CreationalContextStore to be present, but instead got " + o);
- }
- return (ELCreationalContextStack) o;
- }
}
Modified:
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/WebBeansValueExpression.java
===================================================================
---
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/WebBeansValueExpression.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/WebBeansValueExpression.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -16,6 +16,8 @@
*/
package org.jboss.webbeans.el;
+import static org.jboss.webbeans.el.ELCreationalContextStack.getCreationalContextStore;
+
import javax.el.ELContext;
import javax.el.ValueExpression;
import javax.enterprise.context.spi.Contextual;
@@ -109,15 +111,5 @@
creationalContext.release();
}
}
-
- private ELCreationalContextStack getCreationalContextStore(ELContext context)
- {
- Object o = context.getContext(ELCreationalContextStack.class);
- if (!(o instanceof ELCreationalContextStack))
- {
- throw new IllegalStateException("Something went wrong with the ELContext,
expecting a CreationalContextStore to be present, but instead got " + o);
- }
- return (ELCreationalContextStack) o;
- }
}
Modified:
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/util/Reflections.java
===================================================================
---
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/util/Reflections.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/util/Reflections.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -31,12 +31,15 @@
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.lang.reflect.WildcardType;
+import java.security.AccessControlException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import javax.inject.Qualifier;
+import org.jboss.webbeans.log.Log;
+import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.util.reflection.ParameterizedTypeImpl;
/**
@@ -48,6 +51,8 @@
public class Reflections
{
+ private static final Log log = Logging.getLog(Reflections.class);
+
private static final Type[] EMPTY_TYPES = {};
public static class HierarchyDiscovery
@@ -129,11 +134,19 @@
@SuppressWarnings("unchecked")
private void discoverFromClass(Class<?> clazz)
{
- discoverTypes(resolveType(type, clazz.getGenericSuperclass()));
- for (Type c : clazz.getGenericInterfaces())
+ try
{
- discoverTypes(resolveType(type, c));
+ discoverTypes(resolveType(type, clazz.getGenericSuperclass()));
+ for (Type c : clazz.getGenericInterfaces())
+ {
+ discoverTypes(resolveType(type, c));
+ }
}
+ catch (AccessControlException e)
+ {
+ // TODO Hmm, is this a hack?
+ log.trace("Security exception scanning " + clazz.getName(), e);
+ }
}
/**
@@ -836,7 +849,7 @@
public static Field ensureAccessible(Field field)
{
- if (!field.isAccessible() &&
!field.getDeclaringClass().getPackage().getName().startsWith("java.util"))
+ if (!field.isAccessible() &&
!isIgnorePackage(field.getDeclaringClass().getPackage()))
{
field.setAccessible(true);
}
@@ -845,7 +858,7 @@
public static Method ensureAccessible(Method method)
{
- if (!method.isAccessible() &&
!method.getDeclaringClass().getPackage().getName().startsWith("java.util"))
+ if (!method.isAccessible() &&
!isIgnorePackage(method.getDeclaringClass().getPackage()))
{
method.setAccessible(true);
}
@@ -854,11 +867,25 @@
public static <T> Constructor<T> ensureAccessible(Constructor<T>
constructor)
{
- if (!constructor.isAccessible() &&
!constructor.getDeclaringClass().getPackage().getName().startsWith("java.util"))
+ Class<?> c = constructor.getDeclaringClass();
+ Package p = c.getPackage();
+ if (!constructor.isAccessible() && !isIgnorePackage(p))
{
constructor.setAccessible(true);
}
return constructor;
}
+
+ private static boolean isIgnorePackage(Package pkg)
+ {
+ if (pkg != null)
+ {
+ return pkg.getName().startsWith("java.lang");
+ }
+ else
+ {
+ return false;
+ }
+ }
}
Modified: ri/branches/kabir-builder/jboss-as/build.properties
===================================================================
--- ri/branches/kabir-builder/jboss-as/build.properties 2009-09-30 10:56:56 UTC (rev
3816)
+++ ri/branches/kabir-builder/jboss-as/build.properties 2009-09-30 11:34:49 UTC (rev
3817)
@@ -1,5 +1,5 @@
# Container a number of properties associated with installing Web Beans into JBoss AS and
running the TCK in JBoss AS
-#jboss.home=/Applications/jboss-5.2.0.Beta1
+jboss.home=/home/shane/apps/jboss
org.jboss.testharness.container.javaOpts=-Xms128m -Xmx384m -XX:MaxPermSize=128m
-Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000
-Dsun.rmi.dgc.server.gcInterval=3600000
# time to allow before attempting to restart JBoss AS
Modified: ri/branches/kabir-builder/jboss-tck-runner/pom.xml
===================================================================
--- ri/branches/kabir-builder/jboss-tck-runner/pom.xml 2009-09-30 10:56:56 UTC (rev 3816)
+++ ri/branches/kabir-builder/jboss-tck-runner/pom.xml 2009-09-30 11:34:49 UTC (rev 3817)
@@ -3,6 +3,7 @@
<artifactId>webbeans-parent</artifactId>
<groupId>org.jboss.webbeans</groupId>
<version>1.0.0-SNAPSHOT</version>
+ <relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.webbeans</groupId>
Modified: ri/branches/kabir-builder/osgi-bundle/pom.xml
===================================================================
--- ri/branches/kabir-builder/osgi-bundle/pom.xml 2009-09-30 10:56:56 UTC (rev 3816)
+++ ri/branches/kabir-builder/osgi-bundle/pom.xml 2009-09-30 11:34:49 UTC (rev 3817)
@@ -21,7 +21,7 @@
<parent>
<artifactId>webbeans-parent</artifactId>
<groupId>org.jboss.webbeans</groupId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.0.0.PREVIEW4.SP1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -60,8 +60,8 @@
<Embed-Dependency>*; scope=compile;
inline=true</Embed-Dependency>
<_exportcontents>javax.event; javax.context;
javax.webbeans; javax.decorator; javax.inject; javax.enterprise.*;
version=${osgi.version},
- org.jboss.webbeans.ejb;
org.jboss.webbeans.bean.proxy; org.jboss.webbeans.*.api.*; org.jboss.webbeans.*.spi.*;
org.jboss.webbeans.conversation; org.jboss.webbeans; org.jboss.webbeans.bootstrap;
org.jboss.webbeans.introspector; org.jboss.webbeans.servlet; version=${osgi.version},
- org.jboss.webbeans.el;
include:="WebBeansELResolver"; version=${osgi.version},
+ org.jboss.webbeans.context;
org.jboss.webbeans.ejb; org.jboss.webbeans.bean; org.jboss.webbeans.bean.proxy;
org.jboss.webbeans.*.api.*; org.jboss.webbeans.*.spi.*; org.jboss.webbeans.conversation;
org.jboss.webbeans; org.jboss.webbeans.bootstrap; org.jboss.webbeans.introspector;
org.jboss.webbeans.servlet; version=${osgi.version},
+ org.jboss.webbeans.el; version=${osgi.version},
org.jboss.webbeans.jsf;
include:="WebBeansPhaseListener"; version=${osgi.version},
javassist.util.proxy;version="3.8.1.GA"
</_exportcontents>
@@ -129,7 +129,13 @@
<groupId>com.google.collections</groupId>
<artifactId>google-collections</artifactId>
</dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>inject-api</artifactId>
+ <version>1.0.0-PRD</version>
+ </dependency>
+
</dependencies>
</project>
Modified: ri/branches/kabir-builder/parent/pom.xml
===================================================================
--- ri/branches/kabir-builder/parent/pom.xml 2009-09-30 10:56:56 UTC (rev 3816)
+++ ri/branches/kabir-builder/parent/pom.xml 2009-09-30 11:34:49 UTC (rev 3817)
@@ -9,6 +9,7 @@
<groupId>org.jboss.webbeans</groupId>
<artifactId>webbeans-version-matrix</artifactId>
<version>1.0.0-SNAPSHOT</version>
+ <relativePath>../version-matrix</relativePath>
</parent>
<name>Web Beans, the reference implementation of JSR-299</name>
Modified:
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Lifecycle.java
===================================================================
---
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Lifecycle.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Lifecycle.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -24,6 +24,12 @@
public void endRequest(String id, BeanStore requestBeanStore);
public boolean isRequestActive();
+
+ public boolean isSessionActive();
+
+ public boolean isApplicationActive();
+
+ public boolean isConversationActive();
public void beginApplication(BeanStore applicationBeanStore);
Modified:
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingLifecycle.java
===================================================================
---
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingLifecycle.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingLifecycle.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -84,6 +84,21 @@
{
return delegate().isRequestActive();
}
+
+ public boolean isApplicationActive()
+ {
+ return delegate().isApplicationActive();
+ }
+
+ public boolean isConversationActive()
+ {
+ return delegate().isConversationActive();
+ }
+
+ public boolean isSessionActive()
+ {
+ return delegate().isSessionActive();
+ }
public void restoreSession(String id, BeanStore sessionBeanStore)
{
Modified:
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/context/api/BeanStore.java
===================================================================
---
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/context/api/BeanStore.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/context/api/BeanStore.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -36,7 +36,7 @@
* @param contextual The contextual whose instance is to be return
* @return The instance. Null if not found
*/
- public abstract <T> ContexutalInstance<T> get(Contextual<? extends
T> contextual);
+ public abstract <T> ContextualInstance<T> get(Contextual<? extends
T> contextual);
/**
* Clears the store of contextual instances
@@ -56,5 +56,5 @@
* @param contextualInstance the contextual instance
* @return The instance added
*/
- public abstract <T> void put(ContexutalInstance<T> contextualInstance);
+ public abstract <T> void put(ContextualInstance<T> contextualInstance);
}
\ No newline at end of file
Copied:
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/context/api/ContextualInstance.java
(from rev 3801,
ri/trunk/spi/src/main/java/org/jboss/webbeans/context/api/ContextualInstance.java)
===================================================================
---
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/context/api/ContextualInstance.java
(rev 0)
+++
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/context/api/ContextualInstance.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -0,0 +1,14 @@
+package org.jboss.webbeans.context.api;
+
+import javax.enterprise.context.spi.Contextual;
+import javax.enterprise.context.spi.CreationalContext;
+
+public interface ContextualInstance<T>
+{
+
+ public T getInstance();
+
+ public CreationalContext<T> getCreationalContext();
+
+ public Contextual<T> getContextual();
+}
Deleted:
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/context/api/ContexutalInstance.java
===================================================================
---
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/context/api/ContexutalInstance.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/context/api/ContexutalInstance.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -1,15 +0,0 @@
-package org.jboss.webbeans.context.api;
-
-import javax.enterprise.context.spi.Contextual;
-import javax.enterprise.context.spi.CreationalContext;
-
-public interface ContexutalInstance<T>
-{
-
- public T getInstance();
-
- public CreationalContext<T> getCreationalContext();
-
- public Contextual<T> getContextual();
-
-}
Modified:
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/context/api/helpers/AbstractMapBackedBeanStore.java
===================================================================
---
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/context/api/helpers/AbstractMapBackedBeanStore.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/context/api/helpers/AbstractMapBackedBeanStore.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -5,7 +5,7 @@
import javax.enterprise.context.spi.Contextual;
-import org.jboss.webbeans.context.api.ContexutalInstance;
+import org.jboss.webbeans.context.api.ContextualInstance;
import org.jboss.webbeans.context.api.BeanStore;
public abstract class AbstractMapBackedBeanStore implements BeanStore
@@ -16,7 +16,7 @@
super();
}
- public abstract Map<Contextual<? extends Object>, ContexutalInstance<?
extends Object>> delegate();
+ public abstract Map<Contextual<? extends Object>, ContextualInstance<?
extends Object>> delegate();
/**
* Gets an instance from the store
@@ -26,10 +26,10 @@
*
* @see org.jboss.webbeans.context.api.BeanStore#get(BaseBean)
*/
- public <T extends Object> ContexutalInstance<T> get(Contextual<?
extends T> bean)
+ public <T extends Object> ContextualInstance<T> get(Contextual<?
extends T> bean)
{
@SuppressWarnings("unchecked")
- ContexutalInstance<T> instance = (ContexutalInstance<T>)
delegate().get(bean);
+ ContextualInstance<T> instance = (ContextualInstance<T>)
delegate().get(bean);
return instance;
}
@@ -63,7 +63,7 @@
*
* @see org.jboss.webbeans.context.api.BeanStore#put(Contextual, Object)
*/
- public <T> void put(ContexutalInstance<T> beanInstance)
+ public <T> void put(ContextualInstance<T> beanInstance)
{
delegate().put(beanInstance.getContextual(), beanInstance);
}
Modified:
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/context/api/helpers/ConcurrentHashMapBeanStore.java
===================================================================
---
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/context/api/helpers/ConcurrentHashMapBeanStore.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/context/api/helpers/ConcurrentHashMapBeanStore.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -23,7 +23,7 @@
import javax.enterprise.context.spi.Contextual;
-import org.jboss.webbeans.context.api.ContexutalInstance;
+import org.jboss.webbeans.context.api.ContextualInstance;
/**
* A BeanStore that uses a HashMap as backing storage
@@ -36,14 +36,14 @@
private static final long serialVersionUID = 4770689245633688471L;
// The backing map
- protected Map<Contextual<? extends Object>, ContexutalInstance<? extends
Object>> delegate;
+ protected Map<Contextual<? extends Object>, ContextualInstance<? extends
Object>> delegate;
/**
* Constructor
*/
public ConcurrentHashMapBeanStore()
{
- delegate = new ConcurrentHashMap<Contextual<? extends Object>,
ContexutalInstance<? extends Object>>();
+ delegate = new ConcurrentHashMap<Contextual<? extends Object>,
ContextualInstance<? extends Object>>();
}
/**
@@ -52,7 +52,7 @@
* @return The delegate
*/
@Override
- public Map<Contextual<? extends Object>, ContexutalInstance<? extends
Object>> delegate()
+ public Map<Contextual<? extends Object>, ContextualInstance<? extends
Object>> delegate()
{
return delegate;
}
Modified:
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/context/api/helpers/ForwardingBeanStore.java
===================================================================
---
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/context/api/helpers/ForwardingBeanStore.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/context/api/helpers/ForwardingBeanStore.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -5,7 +5,7 @@
import javax.enterprise.context.spi.Contextual;
import org.jboss.webbeans.context.api.BeanStore;
-import org.jboss.webbeans.context.api.ContexutalInstance;
+import org.jboss.webbeans.context.api.ContextualInstance;
public abstract class ForwardingBeanStore implements BeanStore
{
@@ -17,7 +17,7 @@
delegate().clear();
}
- public <T> ContexutalInstance<T> get(Contextual<? extends T> bean)
+ public <T> ContextualInstance<T> get(Contextual<? extends T> bean)
{
return delegate().get(bean);
}
@@ -27,7 +27,7 @@
return delegate().getContextuals();
}
- public <T> void put(ContexutalInstance<T> beanInstance)
+ public <T> void put(ContextualInstance<T> beanInstance)
{
delegate().put(beanInstance);
}
Copied:
ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockLifecycle.java
(from rev 3801, ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockLifecycle.java)
===================================================================
---
ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockLifecycle.java
(rev 0)
+++
ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockLifecycle.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -0,0 +1,24 @@
+package org.jboss.webbeans.mock;
+
+import org.jboss.webbeans.bootstrap.api.Lifecycle;
+
+public interface MockLifecycle extends Lifecycle
+{
+
+ public abstract void initialize();
+
+ public abstract void beginApplication();
+
+ public abstract void endApplication();
+
+ public abstract void resetContexts();
+
+ public abstract void beginRequest();
+
+ public abstract void endRequest();
+
+ public abstract void beginSession();
+
+ public abstract void endSession();
+
+}
\ No newline at end of file
Modified:
ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockServletLifecycle.java
===================================================================
---
ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockServletLifecycle.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockServletLifecycle.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -11,7 +11,7 @@
import org.jboss.webbeans.resources.spi.ResourceLoader;
import org.jboss.webbeans.servlet.api.ServletServices;
-public class MockServletLifecycle extends ForwardingLifecycle
+public class MockServletLifecycle extends ForwardingLifecycle implements MockLifecycle
{
private static final ResourceLoader MOCK_RESOURCE_LOADER = new MockResourceLoader();
@@ -35,6 +35,9 @@
deployment.getServices().add(ServletServices.class, new
MockServletServices(deployment.getArchive()));
}
+ /* (non-Javadoc)
+ * @see org.jboss.webbeans.mock.MockLifecycle#initialize()
+ */
public void initialize()
{
try
@@ -53,21 +56,28 @@
return lifecycle;
}
- public MockDeployment getDeployment()
+ protected MockDeployment getDeployment()
{
return deployment;
}
- public WebBeansBootstrap getBootstrap()
+ protected WebBeansBootstrap getBootstrap()
{
return bootstrap;
}
+ /* (non-Javadoc)
+ * @see org.jboss.webbeans.mock.MockLifecycle#beginApplication()
+ */
public void beginApplication()
{
bootstrap.startInitialization().deployBeans().validateBeans().endInitialization();
}
+ /* (non-Javadoc)
+ * @see org.jboss.webbeans.mock.MockLifecycle#endApplication()
+ */
+ @Override
public void endApplication()
{
bootstrap.shutdown();
@@ -78,33 +88,48 @@
return applicationBeanStore;
}
+ /* (non-Javadoc)
+ * @see org.jboss.webbeans.mock.MockLifecycle#resetContexts()
+ */
public void resetContexts()
{
}
+ /* (non-Javadoc)
+ * @see org.jboss.webbeans.mock.MockLifecycle#beginRequest()
+ */
public void beginRequest()
{
super.beginRequest("Mock", requestBeanStore);
}
+ /* (non-Javadoc)
+ * @see org.jboss.webbeans.mock.MockLifecycle#endRequest()
+ */
public void endRequest()
{
super.endRequest("Mock", requestBeanStore);
}
+ /* (non-Javadoc)
+ * @see org.jboss.webbeans.mock.MockLifecycle#beginSession()
+ */
public void beginSession()
{
super.restoreSession("Mock", sessionBeanStore);
}
+ /* (non-Javadoc)
+ * @see org.jboss.webbeans.mock.MockLifecycle#endSession()
+ */
public void endSession()
{
// TODO Conversation handling breaks this :-(
//super.endSession("Mock", sessionBeanStore);
}
- public Environment getEnvironment()
+ protected Environment getEnvironment()
{
return Environments.SERVLET;
}
Copied:
ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/TestContainer.java
(from rev 3801, ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/TestContainer.java)
===================================================================
---
ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/TestContainer.java
(rev 0)
+++
ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/TestContainer.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -0,0 +1,142 @@
+package org.jboss.webbeans.mock;
+
+import java.net.URL;
+
+import org.jboss.webbeans.BeanManagerImpl;
+
+/**
+ * Control of the container, used for tests. Wraps up common operations.
+ *
+ * @author pmuir
+ *
+ */
+public class TestContainer
+{
+
+ public static class Status
+ {
+
+ private final Exception deploymentException;
+
+ public Status(Exception deploymentException)
+ {
+ this.deploymentException = deploymentException;
+ }
+
+ public Exception getDeploymentException()
+ {
+ return deploymentException;
+ }
+
+ public boolean isSuccess()
+ {
+ return deploymentException == null;
+ }
+
+ }
+
+ private final MockServletLifecycle lifecycle;
+ private final Iterable<Class<?>> classes;
+ private final Iterable<URL> beansXml;
+
+ /**
+ * Create a container, specifying the classes and beans.xml to deploy
+ *
+ * @param lifecycle
+ * @param classes
+ * @param beansXml
+ */
+ public TestContainer(MockServletLifecycle lifecycle, Iterable<Class<?>>
classes, Iterable<URL> beansXml)
+ {
+ this.lifecycle = lifecycle;
+ this.classes = classes;
+ this.beansXml = beansXml;
+ }
+
+ /**
+ * Start the container, returning the container state
+ *
+ * @return
+ */
+ public Status startContainerAndReturnStatus()
+ {
+ try
+ {
+ startContainer();
+ }
+ catch (Exception e)
+ {
+ return new Status(e);
+ }
+ return new Status(null);
+ }
+
+ public void startContainer()
+ {
+ MockBeanDeploymentArchive archive = lifecycle.getDeployment().getArchive();
+ archive.setBeanClasses(classes);
+ if (beansXml != null)
+ {
+ archive.setWebBeansXmlFiles(beansXml);
+ }
+ lifecycle.initialize();
+ lifecycle.beginApplication();
+ }
+
+ /**
+ * Get the context lifecycle, allowing fine control over the contexts' state
+ *
+ * @return
+ */
+ public MockLifecycle getLifecycle()
+ {
+ return lifecycle;
+ }
+
+ public BeanManagerImpl getBeanManager()
+ {
+ return lifecycle.getBootstrap().getManager(getDeployment().getArchive());
+ }
+
+ public MockDeployment getDeployment()
+ {
+ return lifecycle.getDeployment();
+ }
+
+ /**
+ * Utility method which ensures a request is active and available for use
+ *
+ */
+ public void ensureRequestActive()
+ {
+ if (!lifecycle.isSessionActive())
+ {
+ lifecycle.beginSession();
+ }
+ if (!lifecycle.isRequestActive())
+ {
+ lifecycle.beginRequest();
+ }
+ }
+
+ /**
+ * Clean up the container, ending any active contexts
+ *
+ */
+ public void stopContainer()
+ {
+ if (lifecycle.isRequestActive())
+ {
+ lifecycle.endRequest();
+ }
+ if (lifecycle.isSessionActive())
+ {
+ lifecycle.endSession();
+ }
+ if (lifecycle.isApplicationActive())
+ {
+ lifecycle.endApplication();
+ }
+ }
+
+}
\ No newline at end of file
Modified:
ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/test/harness/AbstractStandaloneContainersImpl.java
===================================================================
---
ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/test/harness/AbstractStandaloneContainersImpl.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/test/harness/AbstractStandaloneContainersImpl.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -4,39 +4,33 @@
import org.jboss.testharness.api.DeploymentException;
import org.jboss.testharness.spi.StandaloneContainers;
-import org.jboss.webbeans.mock.MockBeanDeploymentArchive;
import org.jboss.webbeans.mock.MockServletLifecycle;
+import org.jboss.webbeans.mock.TestContainer;
+import org.jboss.webbeans.mock.TestContainer.Status;
public abstract class AbstractStandaloneContainersImpl implements StandaloneContainers
{
private DeploymentException deploymentException;
+
+ private TestContainer testContainer;
- private MockServletLifecycle lifecycle;
-
public boolean deploy(Iterable<Class<?>> classes, Iterable<URL>
beansXml)
{
- this.lifecycle = newLifecycle();
+ this.testContainer = new TestContainer(newLifecycle(), classes, beansXml);
- try
+ Status status = testContainer.startContainerAndReturnStatus();
+ if (!status.isSuccess())
{
- MockBeanDeploymentArchive archive = lifecycle.getDeployment().getArchive();
- archive.setBeanClasses(classes);
- if (beansXml != null)
- {
- archive.setWebBeansXmlFiles(beansXml);
- }
- lifecycle.initialize();
- lifecycle.beginApplication();
+ this.deploymentException = new DeploymentException("Error deploying
beans", status.getDeploymentException());
+ return false;
}
- catch (Exception e)
+ else
{
- this.deploymentException = new DeploymentException("Error deploying
beans", e);
- return false;
+ testContainer.getLifecycle().beginSession();
+ testContainer.getLifecycle().beginRequest();
+ return true;
}
- lifecycle.beginSession();
- lifecycle.beginRequest();
- return true;
}
protected abstract MockServletLifecycle newLifecycle();
@@ -64,10 +58,8 @@
public void undeploy()
{
- lifecycle.endRequest();
- lifecycle.endSession();
- lifecycle.endApplication();
- lifecycle = null;
+ testContainer.stopContainer();
+ testContainer = null;
deploymentException = null;
}
Modified:
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/DiscoverFailsBootstrapTest.java
===================================================================
---
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/DiscoverFailsBootstrapTest.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/DiscoverFailsBootstrapTest.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -1,6 +1,9 @@
package org.jboss.webbeans.test.unit.bootstrap;
-import org.jboss.webbeans.mock.MockEELifecycle;
+import org.jboss.webbeans.bootstrap.WebBeansBootstrap;
+import org.jboss.webbeans.bootstrap.api.Bootstrap;
+import org.jboss.webbeans.bootstrap.api.Environments;
+import org.jboss.webbeans.context.api.helpers.ConcurrentHashMapBeanStore;
import org.testng.annotations.Test;
public class DiscoverFailsBootstrapTest
@@ -9,10 +12,8 @@
@Test(groups="bootstrap",
expectedExceptions=IllegalArgumentException.class)
public void testDiscoverFails()
{
- MockEELifecycle lifecycle = new MockEELifecycle();
- lifecycle.getBootstrap().startContainer(lifecycle.getEnvironment(), null,
lifecycle.getApplicationBeanStore());
- lifecycle.initialize();
- lifecycle.beginApplication();
+ Bootstrap bootstrap = new WebBeansBootstrap();
+ bootstrap.startContainer(Environments.SE, null, new ConcurrentHashMapBeanStore());
}
}
Modified:
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/InjectionServicesTest.java
===================================================================
---
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/InjectionServicesTest.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/InjectionServicesTest.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -7,24 +7,22 @@
import org.jboss.webbeans.injection.spi.InjectionServices;
import org.jboss.webbeans.mock.MockEELifecycle;
+import org.jboss.webbeans.mock.TestContainer;
import org.testng.annotations.Test;
public class InjectionServicesTest
{
@Test
- public void testDiscoverFails()
+ public void testInjectionOfTarget()
{
- MockEELifecycle lifecycle = new MockEELifecycle();
- lifecycle.getDeployment().getArchive().setBeanClasses(Arrays.asList(Foo.class,
Bar.class));
+ TestContainer container = new TestContainer(new MockEELifecycle(),
Arrays.asList(Foo.class, Bar.class), null);
CheckableInjectionServices ijs = new CheckableInjectionServices();
- lifecycle.getDeployment().getArchive().getServices().add(InjectionServices.class,
ijs);
- lifecycle.initialize();
- lifecycle.beginApplication();
- lifecycle.beginSession();
- lifecycle.beginRequest();
+ container.getDeployment().getArchive().getServices().add(InjectionServices.class,
ijs);
+ container.startContainer();
+ container.ensureRequestActive();
- BeanManager manager =
lifecycle.getBootstrap().getManager(lifecycle.getDeployment().getArchive());
+ BeanManager manager = container.getBeanManager();
Bean<? extends Object> bean = manager.resolve(manager.getBeans(Foo.class));
ijs.reset();
@@ -39,9 +37,7 @@
assert foo.getMessage().equals("hi!");
- lifecycle.endRequest();
- lifecycle.endSession();
- lifecycle.endApplication();
+ container.stopContainer();
}
}
Modified:
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/WBStartupTest.java
===================================================================
---
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/WBStartupTest.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/WBStartupTest.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -22,6 +22,7 @@
import javax.enterprise.inject.spi.BeanManager;
import org.jboss.webbeans.mock.MockEELifecycle;
+import org.jboss.webbeans.mock.TestContainer;
import org.testng.annotations.Test;
/**
@@ -34,14 +35,11 @@
@Test
public void test()
{
- MockEELifecycle lifecycle = new MockEELifecycle();
- lifecycle.getDeployment().getArchive().setBeanClasses(Arrays.asList(Foo.class,
Bar.class));
- lifecycle.initialize();
- lifecycle.beginApplication();
- lifecycle.beginSession();
- lifecycle.beginRequest();
+ TestContainer container = new TestContainer(new MockEELifecycle(),
Arrays.asList(Foo.class, Bar.class), null);
+ container.startContainer();
+ container.ensureRequestActive();
- BeanManager manager =
lifecycle.getBootstrap().getManager(lifecycle.getDeployment().getArchive());
+ BeanManager manager = container.getBeanManager();
Bean<? extends Object> bean = manager.resolve(manager.getBeans(Foo.class));
Foo foo = (Foo) manager.getReference(bean, Foo.class,
manager.createCreationalContext(bean));
@@ -49,10 +47,7 @@
assert foo != null;
assert foo.getBar() != null;
-
- lifecycle.endRequest();
- lifecycle.endSession();
- lifecycle.endApplication();
+ container.stopContainer();
}
}
Modified:
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/SorterTest.java
===================================================================
---
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/SorterTest.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/SorterTest.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -27,6 +27,8 @@
import java.util.List;
import java.util.Set;
+import javax.enterprise.inject.spi.BeanManager;
+
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.DefinitionException;
import org.jboss.webbeans.builder.sorter.DeploymentItem;
@@ -35,7 +37,10 @@
import org.jboss.webbeans.introspector.jlr.WBClassImpl;
import org.jboss.webbeans.mock.MockEELifecycle;
import org.jboss.webbeans.mock.MockEjbDescriptor;
+import org.jboss.webbeans.mock.TestContainer;
import org.jboss.webbeans.resources.ClassTransformer;
+import org.jboss.webbeans.test.unit.bootstrap.Bar;
+import org.jboss.webbeans.test.unit.bootstrap.Foo;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
@@ -48,7 +53,7 @@
*/
public class SorterTest
{
- MockEELifecycle lifecycle;
+ TestContainer container;
BeanManagerImpl manager;
final int ITERATIONS = 100;
@@ -56,21 +61,16 @@
@BeforeClass
public void beforeMethod() throws Exception
{
- lifecycle = new MockEELifecycle();
- lifecycle.getDeployment().getArchive().setBeanClasses(new
ArrayList<Class<?>>());
- lifecycle.initialize();
- lifecycle.beginApplication();
- lifecycle.beginSession();
- lifecycle.beginRequest();
- manager =
lifecycle.getBootstrap().getManager(lifecycle.getDeployment().getArchive());
+ container = new TestContainer(new MockEELifecycle(), Arrays.asList(Foo.class,
Bar.class), null);
+ container.startContainer();
+ container.ensureRequestActive();
+ manager = container.getBeanManager();
}
@AfterClass
public void afterClass()
{
- lifecycle.endRequest();
- lifecycle.endSession();
- lifecycle.endApplication();
+ container.stopContainer();
}
@Test
Copied: ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster
(from rev 3801, ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster)
Deleted:
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/Foo.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/Foo.java 2009-09-29
13:57:56 UTC (rev 3801)
+++
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/Foo.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -1,23 +0,0 @@
-package org.jboss.webbeans.test.unit.cluster;
-
-import java.io.Serializable;
-
-import javax.enterprise.context.SessionScoped;
-
-@SessionScoped
-public class Foo implements Serializable
-{
-
- private String name;
-
- public void setName(String name)
- {
- this.name = name;
- }
-
- public String getName()
- {
- return name;
- }
-
-}
Copied:
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/Foo.java
(from rev 3801,
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/Foo.java)
===================================================================
---
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/Foo.java
(rev 0)
+++
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/Foo.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -0,0 +1,23 @@
+package org.jboss.webbeans.test.unit.cluster;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.SessionScoped;
+
+@SessionScoped
+public class Foo implements Serializable
+{
+
+ private String name;
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+}
Deleted:
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/NaiveClusterTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/NaiveClusterTest.java 2009-09-29
13:57:56 UTC (rev 3801)
+++
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/NaiveClusterTest.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -1,82 +0,0 @@
-package org.jboss.webbeans.test.unit.cluster;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.Arrays;
-
-import javax.enterprise.inject.spi.Bean;
-
-import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.bootstrap.api.SingletonProvider;
-import org.jboss.webbeans.context.ContextLifecycle;
-import org.jboss.webbeans.context.api.BeanStore;
-import org.jboss.webbeans.mock.MockEELifecycle;
-import org.jboss.webbeans.mock.TestContainer;
-import org.testng.annotations.Test;
-
-public class NaiveClusterTest
-{
-
- @Test
- public void testSessionReplication() throws Exception
- {
- SingletonProvider.initialize(new SwitchableSingletonProvider());
-
- // Bootstrap container 1
- SwitchableSingletonProvider.use(1);
-
- TestContainer container1 = new TestContainer(new MockEELifecycle(),
Arrays.<Class<?>>asList(Foo.class), null);
- container1.startContainer();
- container1.ensureRequestActive();
-
- BeanManagerImpl beanManager1 = container1.getBeanManager();
- Bean<?> fooBean1 = beanManager1.resolve(beanManager1.getBeans(Foo.class));
-
- // Bootstrap container 2
- SwitchableSingletonProvider.use(2);
-
- TestContainer container2 = new TestContainer(new MockEELifecycle(),
Arrays.<Class<?>>asList(Foo.class), null);
- container2.startContainer();
- container2.ensureRequestActive();
-
- BeanManagerImpl beanManager2 = container2.getBeanManager();
- Bean<?> fooBean2 = beanManager2.resolve(beanManager2.getBeans(Foo.class));
-
- SwitchableSingletonProvider.use(1);
- // Set a value into Foo1
- Foo foo1 = (Foo) beanManager1.getReference(fooBean1, Foo.class,
beanManager1.createCreationalContext(fooBean1));
- foo1.setName("container 1");
-
- replicateSession(beanManager1, beanManager2);
-
- SwitchableSingletonProvider.use(2);
- Foo foo2 = (Foo) beanManager2.getReference(fooBean2, Foo.class,
beanManager2.createCreationalContext(fooBean2));
- assert foo2.getName().equals("container 1");
- }
-
- private void replicateSession(BeanManagerImpl beanManager1, BeanManagerImpl
beanManager2) throws Exception
- {
- // Mimic replicating the session
- BeanStore sessionBeanStore =
beanManager1.getServices().get(ContextLifecycle.class).getSessionContext().getBeanStore();
- BeanStore replicatedSessionBeanStore = (BeanStore)
deserialize(serialize(sessionBeanStore));
-
beanManager2.getServices().get(ContextLifecycle.class).getSessionContext().setBeanStore(replicatedSessionBeanStore);
- }
-
- protected byte[] serialize(Object instance) throws IOException
- {
- ByteArrayOutputStream bytes = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(bytes);
- out.writeObject(instance);
- return bytes.toByteArray();
- }
-
- protected Object deserialize(byte[] bytes) throws IOException, ClassNotFoundException
- {
- ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes));
- return in.readObject();
- }
-
-}
Copied:
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/NaiveClusterTest.java
(from rev 3801,
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/NaiveClusterTest.java)
===================================================================
---
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/NaiveClusterTest.java
(rev 0)
+++
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/NaiveClusterTest.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -0,0 +1,82 @@
+package org.jboss.webbeans.test.unit.cluster;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Arrays;
+
+import javax.enterprise.inject.spi.Bean;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.bootstrap.api.SingletonProvider;
+import org.jboss.webbeans.context.ContextLifecycle;
+import org.jboss.webbeans.context.api.BeanStore;
+import org.jboss.webbeans.mock.MockEELifecycle;
+import org.jboss.webbeans.mock.TestContainer;
+import org.testng.annotations.Test;
+
+public class NaiveClusterTest
+{
+
+ @Test
+ public void testSessionReplication() throws Exception
+ {
+ SingletonProvider.initialize(new SwitchableSingletonProvider());
+
+ // Bootstrap container 1
+ SwitchableSingletonProvider.use(1);
+
+ TestContainer container1 = new TestContainer(new MockEELifecycle(),
Arrays.<Class<?>>asList(Foo.class), null);
+ container1.startContainer();
+ container1.ensureRequestActive();
+
+ BeanManagerImpl beanManager1 = container1.getBeanManager();
+ Bean<?> fooBean1 = beanManager1.resolve(beanManager1.getBeans(Foo.class));
+
+ // Bootstrap container 2
+ SwitchableSingletonProvider.use(2);
+
+ TestContainer container2 = new TestContainer(new MockEELifecycle(),
Arrays.<Class<?>>asList(Foo.class), null);
+ container2.startContainer();
+ container2.ensureRequestActive();
+
+ BeanManagerImpl beanManager2 = container2.getBeanManager();
+ Bean<?> fooBean2 = beanManager2.resolve(beanManager2.getBeans(Foo.class));
+
+ SwitchableSingletonProvider.use(1);
+ // Set a value into Foo1
+ Foo foo1 = (Foo) beanManager1.getReference(fooBean1, Foo.class,
beanManager1.createCreationalContext(fooBean1));
+ foo1.setName("container 1");
+
+ replicateSession(beanManager1, beanManager2);
+
+ SwitchableSingletonProvider.use(2);
+ Foo foo2 = (Foo) beanManager2.getReference(fooBean2, Foo.class,
beanManager2.createCreationalContext(fooBean2));
+ assert foo2.getName().equals("container 1");
+ }
+
+ private void replicateSession(BeanManagerImpl beanManager1, BeanManagerImpl
beanManager2) throws Exception
+ {
+ // Mimic replicating the session
+ BeanStore sessionBeanStore =
beanManager1.getServices().get(ContextLifecycle.class).getSessionContext().getBeanStore();
+ BeanStore replicatedSessionBeanStore = (BeanStore)
deserialize(serialize(sessionBeanStore));
+
beanManager2.getServices().get(ContextLifecycle.class).getSessionContext().setBeanStore(replicatedSessionBeanStore);
+ }
+
+ protected byte[] serialize(Object instance) throws IOException
+ {
+ ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream(bytes);
+ out.writeObject(instance);
+ return bytes.toByteArray();
+ }
+
+ protected Object deserialize(byte[] bytes) throws IOException, ClassNotFoundException
+ {
+ ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes));
+ return in.readObject();
+ }
+
+}
Deleted:
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/SwitchableContainerTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/SwitchableContainerTest.java 2009-09-29
13:57:56 UTC (rev 3801)
+++
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/SwitchableContainerTest.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -1,56 +0,0 @@
-package org.jboss.webbeans.test.unit.cluster;
-
-import java.util.Arrays;
-
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
-
-import org.jboss.webbeans.bootstrap.api.SingletonProvider;
-import org.jboss.webbeans.mock.MockEELifecycle;
-import org.jboss.webbeans.mock.TestContainer;
-import org.testng.annotations.Test;
-
-public class SwitchableContainerTest
-{
-
- @Test
- public void test()
- {
- SingletonProvider.initialize(new SwitchableSingletonProvider());
-
- // Bootstrap container 1
- SwitchableSingletonProvider.use(1);
-
- TestContainer container1 = new TestContainer(new MockEELifecycle(),
Arrays.<Class<?>>asList(Foo.class), null);
- container1.startContainer();
- container1.ensureRequestActive();
-
- BeanManager beanManager1 = container1.getBeanManager();
- Bean<?> fooBean1 = beanManager1.resolve(beanManager1.getBeans(Foo.class));
- Foo foo1 = (Foo) beanManager1.getReference(fooBean1, Foo.class,
beanManager1.createCreationalContext(fooBean1));
- foo1.setName("container 1");
-
- // Bootstrap container 2
- SwitchableSingletonProvider.use(2);
-
- TestContainer container2 = new TestContainer(new MockEELifecycle(),
Arrays.<Class<?>>asList(Foo.class), null);
- container2.startContainer();
- container2.ensureRequestActive();
-
- BeanManager beanManager2 = container2.getBeanManager();
- Bean<?> fooBean2 = beanManager2.resolve(beanManager2.getBeans(Foo.class));
- Foo foo2 = (Foo) beanManager2.getReference(fooBean2, Foo.class,
beanManager2.createCreationalContext(fooBean2));
- foo2.setName("container 2");
-
- // Switch to container 1 and check value
- SwitchableSingletonProvider.use(1);
- foo1 = (Foo) beanManager1.getReference(fooBean1, Foo.class,
beanManager1.createCreationalContext(fooBean1));
- assert foo1.getName().equals("container 1");
-
- // Switch to container 2 and check value
- SwitchableSingletonProvider.use(2);
- foo2 = (Foo) beanManager2.getReference(fooBean2, Foo.class,
beanManager2.createCreationalContext(fooBean2));
- assert foo2.getName().equals("container 2");
- }
-
-}
Copied:
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/SwitchableContainerTest.java
(from rev 3801,
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/SwitchableContainerTest.java)
===================================================================
---
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/SwitchableContainerTest.java
(rev 0)
+++
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/SwitchableContainerTest.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -0,0 +1,56 @@
+package org.jboss.webbeans.test.unit.cluster;
+
+import java.util.Arrays;
+
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.jboss.webbeans.bootstrap.api.SingletonProvider;
+import org.jboss.webbeans.mock.MockEELifecycle;
+import org.jboss.webbeans.mock.TestContainer;
+import org.testng.annotations.Test;
+
+public class SwitchableContainerTest
+{
+
+ @Test
+ public void test()
+ {
+ SingletonProvider.initialize(new SwitchableSingletonProvider());
+
+ // Bootstrap container 1
+ SwitchableSingletonProvider.use(1);
+
+ TestContainer container1 = new TestContainer(new MockEELifecycle(),
Arrays.<Class<?>>asList(Foo.class), null);
+ container1.startContainer();
+ container1.ensureRequestActive();
+
+ BeanManager beanManager1 = container1.getBeanManager();
+ Bean<?> fooBean1 = beanManager1.resolve(beanManager1.getBeans(Foo.class));
+ Foo foo1 = (Foo) beanManager1.getReference(fooBean1, Foo.class,
beanManager1.createCreationalContext(fooBean1));
+ foo1.setName("container 1");
+
+ // Bootstrap container 2
+ SwitchableSingletonProvider.use(2);
+
+ TestContainer container2 = new TestContainer(new MockEELifecycle(),
Arrays.<Class<?>>asList(Foo.class), null);
+ container2.startContainer();
+ container2.ensureRequestActive();
+
+ BeanManager beanManager2 = container2.getBeanManager();
+ Bean<?> fooBean2 = beanManager2.resolve(beanManager2.getBeans(Foo.class));
+ Foo foo2 = (Foo) beanManager2.getReference(fooBean2, Foo.class,
beanManager2.createCreationalContext(fooBean2));
+ foo2.setName("container 2");
+
+ // Switch to container 1 and check value
+ SwitchableSingletonProvider.use(1);
+ foo1 = (Foo) beanManager1.getReference(fooBean1, Foo.class,
beanManager1.createCreationalContext(fooBean1));
+ assert foo1.getName().equals("container 1");
+
+ // Switch to container 2 and check value
+ SwitchableSingletonProvider.use(2);
+ foo2 = (Foo) beanManager2.getReference(fooBean2, Foo.class,
beanManager2.createCreationalContext(fooBean2));
+ assert foo2.getName().equals("container 2");
+ }
+
+}
Deleted:
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/SwitchableSingletonProvider.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/SwitchableSingletonProvider.java 2009-09-29
13:57:56 UTC (rev 3801)
+++
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/SwitchableSingletonProvider.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -1,61 +0,0 @@
-package org.jboss.webbeans.test.unit.cluster;
-
-import java.util.Hashtable;
-import java.util.Map;
-
-import org.jboss.webbeans.bootstrap.api.Singleton;
-import org.jboss.webbeans.bootstrap.api.SingletonProvider;
-
-public class SwitchableSingletonProvider extends SingletonProvider
-{
-
- public static void use(Integer id)
- {
- if (id == null)
- {
- throw new IllegalArgumentException("id cannot be null");
- }
- SwitchableSingleton.id = id;
- }
-
- private static class SwitchableSingleton<T> implements Singleton<T>
- {
-
- private static Integer id = 0;
-
- private final Map<Integer, T> store;
-
- public SwitchableSingleton()
- {
- this.store = new Hashtable<Integer, T>();
- }
-
- public void clear()
- {
- store.remove(id);
- }
-
- public T get()
- {
- return store.get(id);
- }
-
- public boolean isSet()
- {
- return store.containsKey(id);
- }
-
- public void set(T object)
- {
- store.put(id, object);
- }
-
- }
-
- @Override
- public <T> Singleton<T> create(Class<? extends T> expectedType)
- {
- return new SwitchableSingleton<T>();
- }
-
-}
Copied:
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/SwitchableSingletonProvider.java
(from rev 3801,
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/SwitchableSingletonProvider.java)
===================================================================
---
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/SwitchableSingletonProvider.java
(rev 0)
+++
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/SwitchableSingletonProvider.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -0,0 +1,61 @@
+package org.jboss.webbeans.test.unit.cluster;
+
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.jboss.webbeans.bootstrap.api.Singleton;
+import org.jboss.webbeans.bootstrap.api.SingletonProvider;
+
+public class SwitchableSingletonProvider extends SingletonProvider
+{
+
+ public static void use(Integer id)
+ {
+ if (id == null)
+ {
+ throw new IllegalArgumentException("id cannot be null");
+ }
+ SwitchableSingleton.id = id;
+ }
+
+ private static class SwitchableSingleton<T> implements Singleton<T>
+ {
+
+ private static Integer id = 0;
+
+ private final Map<Integer, T> store;
+
+ public SwitchableSingleton()
+ {
+ this.store = new Hashtable<Integer, T>();
+ }
+
+ public void clear()
+ {
+ store.remove(id);
+ }
+
+ public T get()
+ {
+ return store.get(id);
+ }
+
+ public boolean isSet()
+ {
+ return store.containsKey(id);
+ }
+
+ public void set(T object)
+ {
+ store.put(id, object);
+ }
+
+ }
+
+ @Override
+ public <T> Singleton<T> create(Class<? extends T> expectedType)
+ {
+ return new SwitchableSingleton<T>();
+ }
+
+}
Modified:
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleDecorator1.java
===================================================================
---
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleDecorator1.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleDecorator1.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -53,6 +53,6 @@
public int echo3(int i)
{
echo3 = true;
- return delegate.echo1(i);
+ return delegate.echo3(i);
}
}
Modified:
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleDecorator2.java
===================================================================
---
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleDecorator2.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/decorator/simple/SimpleDecorator2.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -47,12 +47,12 @@
public int echo2(int i)
{
echo2 = true;
- return delegate.echo1(i);
+ return delegate.echo2(i);
}
public int echo3(int i)
{
echo3 = true;
- return delegate.echo1(i);
+ return delegate.echo3(i);
}
}
Modified:
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletEnvironmentTest.java
===================================================================
---
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletEnvironmentTest.java 2009-09-30
10:56:56 UTC (rev 3816)
+++
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletEnvironmentTest.java 2009-09-30
11:34:49 UTC (rev 3817)
@@ -9,42 +9,38 @@
import javax.enterprise.inject.spi.Bean;
import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.Container;
-import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.bean.ManagedBean;
-import org.jboss.webbeans.mock.MockBeanDeploymentArchive;
+import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.mock.MockServletLifecycle;
+import org.jboss.webbeans.mock.TestContainer;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
public class ServletEnvironmentTest
{
- private MockServletLifecycle lifecycle;
+ private TestContainer container;
private BeanManagerImpl manager;
@BeforeClass
public void beforeClass() throws Throwable
{
- lifecycle = new MockServletLifecycle();
- lifecycle.initialize();
- MockBeanDeploymentArchive archive = lifecycle.getDeployment().getArchive();
- archive.setBeanClasses(Arrays.asList(Animal.class, DeadlyAnimal.class,
DeadlySpider.class, DeadlyAnimal.class, Hound.class, HoundLocal.class, Salmon.class,
ScottishFish.class, SeaBass.class, Sole.class, Spider.class, Tarantula.class,
TarantulaProducer.class, Tuna.class));
- lifecycle.beginApplication();
- lifecycle.beginSession();
- lifecycle.beginRequest();
- manager = Container.instance().deploymentManager();
+ container = new TestContainer(new MockServletLifecycle(),
Arrays.asList(Animal.class, DeadlyAnimal.class, DeadlySpider.class, DeadlyAnimal.class,
Hound.class, HoundLocal.class, Salmon.class, ScottishFish.class, SeaBass.class,
Sole.class, Spider.class, Tarantula.class, TarantulaProducer.class, Tuna.class), null);
+ container.startContainer();
+ container.ensureRequestActive();
+ manager = container.getBeanManager();
}
@AfterClass(alwaysRun=true)
public void afterClass() throws Exception
{
- lifecycle.endRequest();
- lifecycle.endSession();
- lifecycle.endApplication();
- lifecycle = null;
+ container.stopContainer();
+ container = null;
+ manager = null;
}
+ @Test
public void testSimpleBeans()
{
Map<Class<?>, Bean<?>> beans = new HashMap<Class<?>,
Bean<?>>();
@@ -67,6 +63,7 @@
manager.getInstanceByType(Sole.class, new AnnotationLiteral<Whitefish>()
{}).ping();
}
+ @Test
public void testProducerMethodBean()
{
Map<Class<?>, Bean<?>> beans = new HashMap<Class<?>,
Bean<?>>();
Modified: ri/branches/kabir-builder/tests/unit-tests.xml
===================================================================
--- ri/branches/kabir-builder/tests/unit-tests.xml 2009-09-30 10:56:56 UTC (rev 3816)
+++ ri/branches/kabir-builder/tests/unit-tests.xml 2009-09-30 11:34:49 UTC (rev 3817)
@@ -56,6 +56,7 @@
<package name="org.jboss.webbeans.test.unit.manager" />
<package name="org.jboss.webbeans.test.unit.noncontextual" />
<package name="org.jboss.webbeans.test.unit.security" />
+ <package name="org.jboss.webbeans.test.unit.decorator.simple"
/>
</packages>
</test>
Modified: ri/branches/kabir-builder/version-matrix/pom.xml
===================================================================
--- ri/branches/kabir-builder/version-matrix/pom.xml 2009-09-30 10:56:56 UTC (rev 3816)
+++ ri/branches/kabir-builder/version-matrix/pom.xml 2009-09-30 11:34:49 UTC (rev 3817)
@@ -51,11 +51,38 @@
<webbeans.version>1.0.0-SNAPSHOT</webbeans.version>
<webbeans.servlet.version>1.0.0-SNAPSHOT</webbeans.servlet.version>
<webbeans.se.version>1.0.0-SNAPSHOT</webbeans.se.version>
+ <webbeans.wicket.version>1.0.0-SNAPSHOT</webbeans.wicket.version>
<jboss.test.harness.version>1.0.0-SNAPSHOT</jboss.test.harness.version>
+ <jetty.version>6.1.21</jetty.version>
+ <wicket.version>1.4.1</wicket.version>
</properties>
<dependencyManagement>
<dependencies>
+
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket</artifactId>
+ <version>${wicket.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ <version>${jetty.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-plus</artifactId>
+ <version>${jetty.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jsp-2.1-jetty</artifactId>
+ <version>${jetty.version}</version>
+ </dependency>
<dependency>
<groupId>org.testng</groupId>
@@ -129,6 +156,12 @@
<artifactId>jsp-api</artifactId>
<version>2.1</version>
</dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.2</version>
+ </dependency>
<dependency>
<groupId>javax.transaction</groupId>
@@ -141,6 +174,12 @@
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.4.2</version>
+ </dependency>
<dependency>
<groupId>jaxen</groupId>
@@ -169,13 +208,13 @@
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
- <version>1.2_12</version>
+ <version>1.2_13</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
- <version>1.2_12</version>
+ <version>1.2_13</version>
</dependency>
<dependency>
@@ -287,13 +326,6 @@
<artifactId>webbeans-se</artifactId>
<version>${webbeans.se.version}</version>
</dependency>
-
- <!-- Deprecated -->
- <dependency>
- <groupId>org.jboss.webbeans</groupId>
- <artifactId>se-module</artifactId>
- <version>${webbeans.se.version}</version>
- </dependency>
<dependency>
<groupId>org.jboss.webbeans.servlet</groupId>
@@ -306,6 +338,12 @@
<artifactId>webbeans-servlet</artifactId>
<version>${webbeans.servlet.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.webbeans</groupId>
+ <artifactId>webbeans-wicket</artifactId>
+ <version>${webbeans.wicket.version}</version>
+ </dependency>
<dependency>
<groupId>org.jboss.jsr299.tck</groupId>
@@ -356,6 +394,12 @@
</dependency>
<dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>jasper</artifactId>
+ <version>6.0.20</version>
+ </dependency>
+
+ <dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.1</version>
@@ -382,6 +426,11 @@
<pluginManagement>
<plugins>
<plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.4</version>
+ </plugin>
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
@@ -493,7 +542,7 @@
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
- <version>6.1.16</version>
+ <version>${jetty.version}</version>
</plugin>
<plugin>
<groupId>org.twdata.maven</groupId>
@@ -506,6 +555,11 @@
<version>1.0-beta-3</version>
</plugin>
<plugin>
+ <groupId>com.pyx4j</groupId>
+ <artifactId>maven-junction-plugin</artifactId>
+ <version>1.0.3</version>
+ </plugin>
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0-beta-1</version>