[weld-commits] Weld SVN: r5456 - in core/trunk: impl/src/main/java/org/jboss/weld/manager and 35 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Wed Jan 13 15:41:08 EST 2010


Author: pete.muir at jboss.org
Date: 2010-01-13 15:41:04 -0500 (Wed, 13 Jan 2010)
New Revision: 5456

Added:
   core/trunk/impl/src/main/java/org/jboss/weld/servlet/BeanProvider.java
   core/trunk/tests/src/main/java/org/jboss/weld/test/Utils.java
Modified:
   core/trunk/impl/src/main/java/org/jboss/weld/jsf/ConversationAwareViewHandler.java
   core/trunk/impl/src/main/java/org/jboss/weld/jsf/FacesUrlTransformer.java
   core/trunk/impl/src/main/java/org/jboss/weld/jsf/JsfHelper.java
   core/trunk/impl/src/main/java/org/jboss/weld/jsf/WeldPhaseListener.java
   core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java
   core/trunk/impl/src/main/java/org/jboss/weld/servlet/ConversationPropagationFilter.java
   core/trunk/impl/src/main/java/org/jboss/weld/servlet/ServletLifecycle.java
   core/trunk/tests/src/main/java/org/jboss/weld/test/AbstractWeldTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/activities/ActivitiesTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/activities/current/InjectedManagerCurrentActivityTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/activities/current/InstanceCurrentActivityTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/activities/current/JndiManagerCurrentActivityTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/beanManager/serializability/ManagerTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/builtinBeans/BuiltInBeanPassivationCapableTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/builtinBeans/ee/EEResourceProducerFieldPassivationCapableTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/ApplicationScopedTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/ParameterizedTypeScopedTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/SimpleDecoratorTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithAbstractMethodAndInitializerMethodTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithAbstractMethodTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithCallToItselfTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithConstructorTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithInitializerMethodTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/decoratedTypes/PartialDecoratorTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/generic/PartialDecoratorTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/stackoverflow/StackOverFlowTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/EnterpriseBeanDefinitionTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/EnterpriseBeanTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/proxyability/EnterpriseBeanLifecycleTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/event/EventQualifierTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/event/SimpleEventTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/examples/ExampleTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/examples/MockExampleTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/exceptions/ExceptionHandlingTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/ExtensionTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/generic/GenericBeanTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/injectionPoint/InjectionPointTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/ParameterizedProducerTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/ManagerProducerTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/NullProducerTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/proxy/enterprise/EnterpriseBeanProxyTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/LookupInstanceTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/Weld256Test.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/circular/CircularDependencyTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/circular/resource/ResourceCircularDependencyTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/wbri279/Weld279Test.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/wbri293/ContextualReferenceTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/scope/ScopeTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/serialization/SerializationTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/extensions/NonBdaExtensionTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/nonTransitiveResolution/TransitiveResolutionTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/environments/servlet/ServletEnvironmentTest.java
Log:
WELD-52

Modified: core/trunk/impl/src/main/java/org/jboss/weld/jsf/ConversationAwareViewHandler.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/jsf/ConversationAwareViewHandler.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/impl/src/main/java/org/jboss/weld/jsf/ConversationAwareViewHandler.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -16,7 +16,8 @@
  */
 package org.jboss.weld.jsf;
 
-import static org.jboss.weld.jsf.JsfHelper.getModuleBeanManager;
+import static org.jboss.weld.jsf.JsfHelper.getServletContext;
+import static org.jboss.weld.servlet.BeanProvider.conversation;
 
 import javax.faces.application.ViewHandler;
 import javax.faces.application.ViewHandlerWrapper;
@@ -67,7 +68,7 @@
    public String getActionURL(FacesContext context, String viewId)
    {
       String actionUrl = super.getActionURL(context, viewId);
-      ConversationImpl conversation = getModuleBeanManager(context).getInstanceByType(ConversationImpl.class);  
+      ConversationImpl conversation = conversation(getServletContext(context));  
       if (!conversation.isTransient())
       {
          return new FacesUrlTransformer(actionUrl, context).appendConversationIdIfNecessary(conversation.getUnderlyingId()).getUrl();

Modified: core/trunk/impl/src/main/java/org/jboss/weld/jsf/FacesUrlTransformer.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/jsf/FacesUrlTransformer.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/impl/src/main/java/org/jboss/weld/jsf/FacesUrlTransformer.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -15,14 +15,10 @@
  * limitations under the License.
  */
 package org.jboss.weld.jsf;
+import static org.jboss.weld.jsf.JsfHelper.getConversationId;
 
-import static org.jboss.weld.jsf.JsfHelper.getModuleBeanManager;
-
-import javax.enterprise.util.AnnotationLiteral;
 import javax.faces.context.FacesContext;
 
-import org.jboss.weld.conversation.ConversationIdName;
-
 /**
  * Helper class for preparing JSF URLs which include the conversation id.
  * 
@@ -50,7 +46,7 @@
 
    public FacesUrlTransformer appendConversationIdIfNecessary(String cid)
    {
-      String cidParamName = getModuleBeanManager(context).getInstanceByType(String.class, new AnnotationLiteral<ConversationIdName>(){});
+      String cidParamName = getConversationId(context);
       int queryStringIndex = url.indexOf(QUERY_STRING_DELIMITER);
       // if there is no query string or there is a query string but the cid param is absent, then append it
       if (queryStringIndex < 0 || url.indexOf(cidParamName + PARAMETER_ASSIGNMENT_OPERATOR, queryStringIndex) < 0)

Modified: core/trunk/impl/src/main/java/org/jboss/weld/jsf/JsfHelper.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/jsf/JsfHelper.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/impl/src/main/java/org/jboss/weld/jsf/JsfHelper.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -21,18 +21,13 @@
 import static org.jboss.weld.logging.messages.JsfMessage.FOUND_CONVERSATION_FROM_REQUEST;
 import static org.jboss.weld.logging.messages.JsfMessage.IMPROPER_ENVIRONMENT;
 import static org.jboss.weld.logging.messages.JsfMessage.RESUMING_CONVERSATION;
+import static org.jboss.weld.servlet.BeanProvider.conversationIdName;
 
-import javax.enterprise.util.AnnotationLiteral;
 import javax.faces.context.FacesContext;
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpSession;
 
-import org.jboss.weld.Container;
-import org.jboss.weld.conversation.ConversationIdName;
 import org.jboss.weld.exceptions.ForbiddenStateException;
-import org.jboss.weld.manager.BeanManagerImpl;
-import org.jboss.weld.servlet.ServletHelper;
-import org.jboss.weld.util.reflection.SecureReflections;
 import org.slf4j.cal10n.LocLogger;
 
 /**
@@ -43,36 +38,8 @@
  */
 public class JsfHelper
 {
-   private static final LocLogger log = loggerFactory().getLogger(JSF);
    
-   /**
-    * Checks if the current request is a JSF postback. The JsfApiAbstraction is
-    * consulted to determine if the JSF version is compatible with JSF 2.0. If
-    * so, the {@link FacesContext#isPostback()} convenience method is used
-    * (which is technically an optimized and safer implementation). Otherwise,
-    * the ResponseStateManager is consulted directly.
-    * 
-    * @return true if this request is a JSF postback, false otherwise
-    */
-   public static boolean isPostback(FacesContext facesContext)
-   {
-      if (Container.instance().services().get(JsfApiAbstraction.class).isApiVersionCompatibleWith(2.0))
-      {
-         try
-         {
-            return (Boolean) SecureReflections.invoke(facesContext, "isPostback");
-         }
-         catch (Exception e)
-         {
-            // Sorry, guys ;-) --NIK
-            return false;
-         }
-      }
-      else
-      {
-         return facesContext.getRenderKit().getResponseStateManager().isPostback(facesContext);
-      }
-   }
+   private static final LocLogger log = loggerFactory().getLogger(JSF);
 
    /**
     * Gets the propagated conversation id parameter from the request
@@ -81,8 +48,7 @@
     */
    public static String getConversationIdFromRequest(FacesContext facesContext)
    {
-      BeanManagerImpl moduleBeanManager = JsfHelper.getModuleBeanManager(facesContext);
-      String cidName = moduleBeanManager.getInstanceByType(String.class, new AnnotationLiteral<ConversationIdName>(){});
+      String cidName = conversationIdName(getServletContext(facesContext));
       String cid = facesContext.getExternalContext().getRequestParameterMap().get(cidName);
       log.trace(FOUND_CONVERSATION_FROM_REQUEST, cid);
       return cid;
@@ -118,11 +84,11 @@
       }
    }
    
-   public static BeanManagerImpl getModuleBeanManager(FacesContext facesContext)
+   public static ServletContext getServletContext(FacesContext facesContext)
    {
       if (facesContext.getExternalContext().getContext() instanceof ServletContext)
       {
-         return ServletHelper.getModuleBeanManager((ServletContext) facesContext.getExternalContext().getContext());
+         return (ServletContext) facesContext.getExternalContext().getContext();
       }
       else
       {

Modified: core/trunk/impl/src/main/java/org/jboss/weld/jsf/WeldPhaseListener.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/jsf/WeldPhaseListener.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/impl/src/main/java/org/jboss/weld/jsf/WeldPhaseListener.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -24,28 +24,28 @@
 
 import static org.jboss.weld.jsf.JsfHelper.getConversationId;
 import static org.jboss.weld.jsf.JsfHelper.getHttpSession;
-import static org.jboss.weld.jsf.JsfHelper.getModuleBeanManager;
+import static org.jboss.weld.jsf.JsfHelper.getServletContext;
 import static org.jboss.weld.logging.Category.JSF;
 import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
 import static org.jboss.weld.logging.messages.JsfMessage.CLEANING_UP_CONVERSATION;
 import static org.jboss.weld.logging.messages.JsfMessage.INITIATING_CONVERSATION;
 import static org.jboss.weld.logging.messages.JsfMessage.SKIPPING_CLEANING_UP_CONVERSATION;
+import static org.jboss.weld.servlet.BeanProvider.conversation;
+import static org.jboss.weld.servlet.BeanProvider.conversationManager;
+import static org.jboss.weld.servlet.BeanProvider.httpSessionManager;
 
 import javax.faces.context.FacesContext;
 import javax.faces.event.PhaseEvent;
 import javax.faces.event.PhaseId;
 import javax.faces.event.PhaseListener;
+import javax.servlet.ServletContext;
 import javax.servlet.http.HttpSession;
 
 import org.jboss.weld.Container;
 import org.jboss.weld.context.ContextLifecycle;
 import org.jboss.weld.context.ConversationContext;
 import org.jboss.weld.context.SessionContext;
-import org.jboss.weld.conversation.ConversationImpl;
-import org.jboss.weld.conversation.ConversationManager;
-import org.jboss.weld.manager.BeanManagerImpl;
 import org.jboss.weld.servlet.ConversationBeanStore;
-import org.jboss.weld.servlet.HttpSessionManager;
 import org.slf4j.cal10n.LocLogger;
 
 /**
@@ -123,13 +123,12 @@
     */
    private void afterRenderResponse(FacesContext facesContext)
    {
-      BeanManagerImpl moduleBeanManager = getModuleBeanManager(facesContext);
       SessionContext sessionContext = Container.instance().services().get(ContextLifecycle.class).getSessionContext();
       ConversationContext conversationContext = Container.instance().services().get(ContextLifecycle.class).getConversationContext();
       if (sessionContext.isActive())
       {
          log.trace(CLEANING_UP_CONVERSATION, "Render Response", "response complete");
-         moduleBeanManager.getInstanceByType(ConversationManager.class).cleanupConversation();
+         conversationManager(getServletContext(facesContext)).cleanupConversation();
          conversationContext.setActive(false);
       }
       else
@@ -143,12 +142,11 @@
     */
    private void afterResponseComplete(FacesContext facesContext, PhaseId phaseId)
    {
-      BeanManagerImpl moduleBeanManager = getModuleBeanManager(facesContext);
       SessionContext sessionContext = Container.instance().services().get(ContextLifecycle.class).getSessionContext();
       if (sessionContext.isActive())
       {
          log.trace(CLEANING_UP_CONVERSATION, phaseId, "the response has been marked complete");
-         moduleBeanManager.getInstanceByType(ConversationManager.class).cleanupConversation();
+         conversationManager(getServletContext(facesContext)).cleanupConversation();
       }
       else
       {
@@ -164,11 +162,11 @@
     */
    private void initiateSessionAndConversation(FacesContext facesContext)
    {
+      ServletContext servletContext = getServletContext(facesContext);
       HttpSession session = getHttpSession(facesContext);
-      BeanManagerImpl moduleBeanManager = getModuleBeanManager(facesContext);
-      moduleBeanManager.getInstanceByType(HttpSessionManager.class).setSession(session);
-      moduleBeanManager.getInstanceByType(ConversationManager.class).beginOrRestoreConversation(getConversationId(facesContext));
-      String cid = moduleBeanManager.getInstanceByType(ConversationImpl.class).getUnderlyingId();
+      httpSessionManager(servletContext).setSession(session);
+      conversationManager(servletContext).beginOrRestoreConversation(getConversationId(facesContext));
+      String cid = conversation(servletContext).getUnderlyingId();
       
       ConversationContext conversationContext = Container.instance().services().get(ContextLifecycle.class).getConversationContext();
       conversationContext.setBeanStore(new ConversationBeanStore(session, cid));

Modified: core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -33,7 +33,6 @@
 import static org.jboss.weld.logging.messages.BeanManagerMessage.TOO_MANY_ACTIVITIES;
 import static org.jboss.weld.logging.messages.BeanManagerMessage.UNPROXYABLE_RESOLUTION;
 import static org.jboss.weld.logging.messages.BeanManagerMessage.UNRESOLVABLE_ELEMENT;
-import static org.jboss.weld.logging.messages.BeanManagerMessage.UNRESOLVABLE_TYPE;
 
 import java.io.Serializable;
 import java.lang.annotation.Annotation;
@@ -872,31 +871,6 @@
          return getReference(injectionPoint, resolvedBean, creationalContext);
    }
 
-   /**
-    * Returns an instance by API type and binding types
-    * 
-    * @param beanType The API type to match
-    * @param bindings The binding types to match
-    * @return An instance of the bean
-    * 
-    */
-   @Deprecated
-   public <T> T getInstanceByType(Class<T> beanType, Annotation... bindings)
-   {
-      Set<Bean<?>> beans = getBeans(beanType, bindings);
-      Bean<?> bean = resolve(beans);
-      if (bean == null)
-      {
-         throw new UnsatisfiedResolutionException(UNRESOLVABLE_TYPE, beanType, Arrays.toString(bindings)); 
-      }
-      Object reference = getReference(bean, beanType, createCreationalContext(bean));
-      
-      @SuppressWarnings("unchecked")
-      T instance = (T) reference;
-      
-      return instance;
-   }
-
    public <T> Bean<T> getBean(WeldAnnotated<T, ?> element, Annotation... bindings)
    {
       Bean<T> bean = (Bean<T>) resolve(getBeans(element, bindings));

Added: core/trunk/impl/src/main/java/org/jboss/weld/servlet/BeanProvider.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/servlet/BeanProvider.java	                        (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/servlet/BeanProvider.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -0,0 +1,56 @@
+package org.jboss.weld.servlet;
+
+import static org.jboss.weld.servlet.ServletHelper.getModuleBeanManager;
+
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.util.AnnotationLiteral;
+import javax.servlet.ServletContext;
+
+import org.jboss.weld.conversation.ConversationIdName;
+import org.jboss.weld.conversation.ConversationImpl;
+import org.jboss.weld.conversation.ConversationManager;
+import org.jboss.weld.manager.BeanManagerImpl;
+
+public class BeanProvider
+{
+
+   private static class ConversationIdNameLiteral extends AnnotationLiteral<ConversationIdName> implements ConversationIdName
+   {
+      
+      public static final ConversationIdName INSTANCE = new ConversationIdNameLiteral();
+      
+      private ConversationIdNameLiteral() {}
+      
+   }
+   
+   public static ConversationManager conversationManager(ServletContext servletContext)
+   {
+      BeanManagerImpl beanManager = getModuleBeanManager(servletContext);
+      Bean<?> bean = beanManager.resolve(beanManager.getBeans(ConversationManager.class));
+      return (ConversationManager) beanManager.getReference(bean, ConversationManager.class, beanManager.createCreationalContext(bean));
+   }
+   
+   public static HttpSessionManager httpSessionManager(ServletContext servletContext)
+   {
+      BeanManagerImpl beanManager = getModuleBeanManager(servletContext);
+      Bean<?> bean = beanManager.resolve(beanManager.getBeans(HttpSessionManager.class));
+      return (HttpSessionManager) beanManager.getReference(bean, HttpSessionManager.class, beanManager.createCreationalContext(bean));
+   }
+   
+   public static ConversationImpl conversation(ServletContext servletContext)
+   {
+      BeanManagerImpl beanManager = getModuleBeanManager(servletContext);
+      Bean<?> bean = beanManager.resolve(beanManager.getBeans(ConversationImpl.class));
+      return (ConversationImpl) beanManager.getReference(bean, ConversationImpl.class, beanManager.createCreationalContext(bean));
+   }
+   
+   public static String conversationIdName(ServletContext servletContext)
+   {
+      BeanManagerImpl beanManager = getModuleBeanManager(servletContext);
+      Bean<?> bean = beanManager.resolve(beanManager.getBeans(String.class, ConversationIdNameLiteral.INSTANCE));
+      return (String) beanManager.getReference(bean, String.class, beanManager.createCreationalContext(bean));
+   }
+   
+   private BeanProvider() {}
+   
+}


Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/servlet/BeanProvider.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Modified: core/trunk/impl/src/main/java/org/jboss/weld/servlet/ConversationPropagationFilter.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/servlet/ConversationPropagationFilter.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/impl/src/main/java/org/jboss/weld/servlet/ConversationPropagationFilter.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -16,11 +16,11 @@
  */
 package org.jboss.weld.servlet;
 
-import static org.jboss.weld.servlet.ServletHelper.getModuleBeanManager;
+import static org.jboss.weld.servlet.BeanProvider.conversation;
+import static org.jboss.weld.servlet.BeanProvider.conversationManager;
 
 import java.io.IOException;
 
-import javax.enterprise.util.AnnotationLiteral;
 import javax.faces.context.FacesContext;
 import javax.servlet.Filter;
 import javax.servlet.FilterChain;
@@ -33,9 +33,7 @@
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponseWrapper;
 
-import org.jboss.weld.conversation.ConversationIdName;
 import org.jboss.weld.conversation.ConversationImpl;
-import org.jboss.weld.conversation.ConversationManager;
 import org.jboss.weld.jsf.FacesUrlTransformer;
 
 /**
@@ -79,12 +77,11 @@
          @Override
          public void sendRedirect(String path) throws IOException
          {
-            ConversationImpl conversation = getModuleBeanManager(ctx) .getInstanceByType(ConversationImpl.class);
+            ConversationImpl conversation = conversation(ctx);
             if (!conversation.isTransient())
             {
-               String cidParamName = getModuleBeanManager(ctx).getInstanceByType(String.class, new AnnotationLiteral<ConversationIdName>(){});
                path = new FacesUrlTransformer(path, FacesContext.getCurrentInstance()).toRedirectViewId().toActionUrl().appendConversationIdIfNecessary(conversation.getUnderlyingId()).encode();
-               getModuleBeanManager(ctx).getInstanceByType(ConversationManager.class).cleanupConversation();
+               conversationManager(ctx).cleanupConversation();
             }
             super.sendRedirect(path);
          }

Modified: core/trunk/impl/src/main/java/org/jboss/weld/servlet/ServletLifecycle.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/servlet/ServletLifecycle.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/impl/src/main/java/org/jboss/weld/servlet/ServletLifecycle.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -23,7 +23,8 @@
 package org.jboss.weld.servlet;
 
 import static org.jboss.weld.logging.messages.ServletMessage.REQUEST_SCOPE_BEAN_STORE_MISSING;
-import static org.jboss.weld.servlet.ServletHelper.getModuleBeanManager;
+import static org.jboss.weld.servlet.BeanProvider.conversationManager;
+import static org.jboss.weld.servlet.BeanProvider.httpSessionManager;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
@@ -73,7 +74,7 @@
     */
    public void endSession(HttpSession session)
    {
-      ConversationManager conversationManager = getModuleBeanManager(session.getServletContext()).getInstanceByType(ConversationManager.class);
+      ConversationManager conversationManager = conversationManager(session.getServletContext());
       if (lifecycle.getSessionContext().isActive())
       {
          conversationManager.destroyAllConversations();
@@ -111,7 +112,7 @@
       lifecycle.restoreSession(session == null ? "Inactive session" : session.getId(), sessionBeanStore);
       if (session != null)
       {
-         getModuleBeanManager(session.getServletContext()).getInstanceByType(HttpSessionManager.class).setSession(session);
+         httpSessionManager(session.getServletContext()).setSession(session);
       }
       return sessionBeanStore;
    }
@@ -120,7 +121,7 @@
    {
       BeanStore beanStore = new HttpSessionBeanStore(session);
       lifecycle.restoreSession(session.getId(), beanStore);
-      getModuleBeanManager(session.getServletContext()).getInstanceByType(HttpSessionManager.class).setSession(session);
+      httpSessionManager(session.getServletContext()).setSession(session);
       return beanStore;
    }
 

Modified: core/trunk/tests/src/main/java/org/jboss/weld/test/AbstractWeldTest.java
===================================================================
--- core/trunk/tests/src/main/java/org/jboss/weld/test/AbstractWeldTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/main/java/org/jboss/weld/test/AbstractWeldTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -1,28 +1,16 @@
 package org.jboss.weld.test;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
 import java.util.Set;
 
-import javax.el.ELContext;
 import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.util.TypeLiteral;
 import javax.servlet.ServletContext;
 
 import org.jboss.testharness.AbstractTest;
 import org.jboss.testharness.impl.runner.servlet.ServletTestRunner;
 import org.jboss.weld.manager.BeanManagerImpl;
 import org.jboss.weld.mock.el.EL;
-import org.jboss.weld.util.collections.EnumerationList;
 import org.testng.ITestContext;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
@@ -66,134 +54,34 @@
       super.afterClass();
    }
 
-   /**
-    * Checks if all annotations are in a given set of annotations
-    * 
-    * @param annotations The annotation set
-    * @param annotationTypes The annotations to match
-    * @return True if match, false otherwise
-    */
-   public boolean annotationSetMatches(Set<? extends Annotation> annotations, Class<? extends Annotation>... annotationTypes)
-   {
-      List<Class<? extends Annotation>> annotationTypeList = new ArrayList<Class<? extends Annotation>>();
-      annotationTypeList.addAll(Arrays.asList(annotationTypes));
-      for (Annotation annotation : annotations)
-      {
-         if (annotationTypeList.contains(annotation.annotationType()))
-         {
-            annotationTypeList.remove(annotation.annotationType());
-         }
-         else
-         {
-            return false;
-         }
-      }
-      return annotationTypeList.size() == 0;
-   }
-   
-   public boolean typeSetMatches(Set<Type> types, Type... requiredTypes)
-   {
-      List<Type> typeList = Arrays.asList(requiredTypes);
-      return requiredTypes.length == types.size() && types.containsAll(typeList);
-   }
-
-   protected Iterable<URL> getResources(String name)
-   {
-      if (name.startsWith("/"))
-      {
-         name = name.substring(1);
-      }
-      else
-      {
-         name = getClass().getPackage().getName().replace(".", "/") + "/" + name;
-      }
-      try
-      {
-         return new EnumerationList<URL>(getClass().getClassLoader().getResources(name));
-      }
-      catch (IOException e)
-      {
-         throw new RuntimeException("Error loading resource from classloader" + name, e);
-      }
-   }
-
-   protected byte[] serialize(Object instance) throws IOException
-   {
-      ByteArrayOutputStream bytes = new ByteArrayOutputStream();
-      ObjectOutputStream out = new ObjectOutputStream(bytes);
-      out.writeObject(instance);
-      return bytes.toByteArray();
-   }
-
-   protected <T> T deserialize(byte[] bytes) throws IOException, ClassNotFoundException
-   {
-      ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes));
-      return (T) in.readObject();
-   }
-
    protected BeanManagerImpl getCurrentManager()
    {
       return BeanManagerLocator.INSTANCE.locate();
    }
 
-   public boolean isExceptionInHierarchy(Throwable exception, Class<? extends Throwable> expectedException )
-   {
-      while (exception != null)
-      {
-         if (exception.getClass().equals(expectedException))
-         {
-            return true;
-         }
-         exception = exception.getCause();
-      }
-      return false;
-   }
-
    public <T> Bean<T> getBean(Type beanType, Annotation... bindings)
    {
-      Set<Bean<?>> beans = getCurrentManager().getBeans(beanType, bindings);
-      if (beans.size() > 1)
-      {
-         throw new RuntimeException("More than one bean resolved to " + beanType + " with bindings " + Arrays.asList(bindings));
-      }
-      if (beans.size() == 0)
-      {
-         throw new RuntimeException("No beans resolved to " + beanType + " with bindings " + Arrays.asList(bindings));
-      }
-      @SuppressWarnings("unchecked")
-      Bean<T> bean = (Bean<T>) beans.iterator().next();
-      return bean;
+      return Utils.getBean(getCurrentManager(), beanType, bindings);
    }
 
-   @SuppressWarnings("unchecked")
    public <T> Set<Bean<T>> getBeans(Class<T> type, Annotation... bindings)
    {
-      return (Set) getCurrentManager().getBeans(type, bindings);
+      return Utils.getBeans(getCurrentManager(), type, bindings);
    }
 
-   @SuppressWarnings("unchecked")
-   public <T> Set<Bean<T>> getBeans(TypeLiteral<T> type, Annotation... bindings)
+   public <T> T getReference(Class<T> beanType, Annotation... bindings)
    {
-      return (Set)getCurrentManager().getBeans(type.getType(), bindings);
+      return Utils.getReference(getCurrentManager(), beanType, bindings);
    }
-
-   @SuppressWarnings("unchecked")
-   public <T> T createContextualInstance(Class<T> beanType, Annotation... bindings)
-   {
-      Bean<?> bean = getBean(beanType, bindings);
-      return (T) getCurrentManager().getReference(bean, beanType, getCurrentManager().createCreationalContext(bean));
-   }
    
    public <T> T getReference(Bean<T> bean)
    {
-      return (T) getCurrentManager().getReference(bean, bean.getBeanClass(), getCurrentManager().createCreationalContext(bean));
+      return Utils.getReference(getCurrentManager(), bean);
    }
 
-   @SuppressWarnings("unchecked")
    public <T> T evaluateValueExpression(String expression, Class<T> expectedType)
    {
-      ELContext elContext = EL.createELContext(getCurrentManager().getCurrent());
-      return (T) EL.EXPRESSION_FACTORY.createValueExpression(elContext, expression, expectedType).getValue(elContext);
+      return Utils.evaluateValueExpression(getCurrentManager(), expression, expectedType);
    }
    
    protected String getPath(String viewId)

Added: core/trunk/tests/src/main/java/org/jboss/weld/test/Utils.java
===================================================================
--- core/trunk/tests/src/main/java/org/jboss/weld/test/Utils.java	                        (rev 0)
+++ core/trunk/tests/src/main/java/org/jboss/weld/test/Utils.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -0,0 +1,156 @@
+package org.jboss.weld.test;
+
+import static org.jboss.weld.logging.messages.BeanManagerMessage.UNRESOLVABLE_TYPE;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+import javax.el.ELContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.util.TypeLiteral;
+
+import org.jboss.weld.exceptions.UnsatisfiedResolutionException;
+import org.jboss.weld.manager.BeanManagerImpl;
+import org.jboss.weld.mock.el.EL;
+import org.jboss.weld.util.collections.EnumerationList;
+
+
+public class Utils
+{
+
+   /**
+    * Checks if all annotations are in a given set of annotations
+    * 
+    * @param annotations The annotation set
+    * @param annotationTypes The annotations to match
+    * @return True if match, false otherwise
+    */
+   public static boolean annotationSetMatches(Set<? extends Annotation> annotations, Class<? extends Annotation>... annotationTypes)
+   {
+      List<Class<? extends Annotation>> annotationTypeList = new ArrayList<Class<? extends Annotation>>();
+      annotationTypeList.addAll(Arrays.asList(annotationTypes));
+      for (Annotation annotation : annotations)
+      {
+         if (annotationTypeList.contains(annotation.annotationType()))
+         {
+            annotationTypeList.remove(annotation.annotationType());
+         }
+         else
+         {
+            return false;
+         }
+      }
+      return annotationTypeList.size() == 0;
+   }
+
+   public static boolean typeSetMatches(Set<Type> types, Type... requiredTypes)
+   {
+      List<Type> typeList = Arrays.asList(requiredTypes);
+      return requiredTypes.length == types.size() && types.containsAll(typeList);
+   }
+
+   public static Iterable<URL> getResources(Class<?> clazz, String name)
+   {
+      if (name.startsWith("/"))
+      {
+         name = name.substring(1);
+      }
+      else
+      {
+         name = clazz.getPackage().getName().replace(".", "/") + "/" + name;
+      }
+      try
+      {
+         return new EnumerationList<URL>(clazz.getClassLoader().getResources(name));
+      }
+      catch (IOException e)
+      {
+         throw new RuntimeException("Error loading resource from classloader" + name, e);
+      }
+   }
+
+   public static byte[] serialize(Object instance) throws IOException
+   {
+      ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+      ObjectOutputStream out = new ObjectOutputStream(bytes);
+      out.writeObject(instance);
+      return bytes.toByteArray();
+   }
+
+   public static <T> T deserialize(byte[] bytes) throws IOException, ClassNotFoundException
+   {
+      ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes));
+      return (T) in.readObject();
+   }
+
+   public static boolean isExceptionInHierarchy(Throwable exception, Class<? extends Throwable> expectedException )
+   {
+      while (exception != null)
+      {
+         if (exception.getClass().equals(expectedException))
+         {
+            return true;
+         }
+         exception = exception.getCause();
+      }
+      return false;
+   }
+   
+   public static <T> Bean<T> getBean(BeanManagerImpl beanManager, Type beanType, Annotation... bindings)
+   {
+      Set<Bean<?>> beans = beanManager.getBeans(beanType, bindings);
+      Bean<?> bean = beanManager.resolve(beans);
+      if (bean == null)
+      {
+         throw new UnsatisfiedResolutionException(UNRESOLVABLE_TYPE, beanType, Arrays.toString(bindings)); 
+      }
+      
+      @SuppressWarnings("unchecked")
+      Bean<T> typedBean = (Bean<T>) bean;
+      
+      return typedBean;
+   }
+
+   @SuppressWarnings("unchecked")
+   public static <T> Set<Bean<T>> getBeans(BeanManagerImpl beanManager, Class<T> type, Annotation... bindings)
+   {
+      return (Set) beanManager.getBeans(type, bindings);
+   }
+
+   @SuppressWarnings("unchecked")
+   public static <T> Set<Bean<T>> getBeans(BeanManagerImpl beanManager, TypeLiteral<T> type, Annotation... bindings)
+   {
+      return (Set) beanManager.getBeans(type.getType(), bindings);
+   }
+
+   @SuppressWarnings("unchecked")
+   public static <T> T getReference(BeanManagerImpl beanManager, Class<T> beanType, Annotation... bindings)
+   {
+      Bean<?> bean = getBean(beanManager, beanType, bindings);
+      return (T) beanManager.getReference(bean, beanType, beanManager.createCreationalContext(bean));
+   }
+   
+   @SuppressWarnings("unchecked")
+   public static <T> T getReference(BeanManagerImpl beanManager, Bean<T> bean)
+   {
+      return (T) beanManager.getReference(bean, bean.getBeanClass(), beanManager.createCreationalContext(bean));
+   }
+
+   @SuppressWarnings("unchecked")
+   public static <T> T evaluateValueExpression(BeanManagerImpl beanManager, String expression, Class<T> expectedType)
+   {
+      ELContext elContext = EL.createELContext(beanManager.getCurrent());
+      return (T) EL.EXPRESSION_FACTORY.createValueExpression(elContext, expression, expectedType).getValue(elContext);
+   }
+
+}


Property changes on: core/trunk/tests/src/main/java/org/jboss/weld/test/Utils.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/activities/ActivitiesTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/activities/ActivitiesTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/activities/ActivitiesTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -271,7 +271,7 @@
          }
 
             });
-      createContextualInstance(Field.class).get();
+      getReference(Field.class).get();
    }
 
    @Test

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/activities/current/InjectedManagerCurrentActivityTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/activities/current/InjectedManagerCurrentActivityTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/activities/current/InjectedManagerCurrentActivityTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -60,7 +60,7 @@
       assert getBeans(Cow.class).size() == 1;
       WeldManager childActivity = getCurrentManager().createActivity();
       childActivity.setCurrent(dummyContext.getScope());
-      assert createContextualInstance(Horse.class).getManager().equals(childActivity);
+      assert getReference(Horse.class).getManager().equals(childActivity);
    }
 
 }

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/activities/current/InstanceCurrentActivityTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/activities/current/InstanceCurrentActivityTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/activities/current/InstanceCurrentActivityTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -161,7 +161,7 @@
       BeanManagerImpl childActivity = getCurrentManager().createActivity();
       childActivity.addBean(new Daisy(childActivity));
       childActivity.setCurrent(dummyContext.getScope());
-      assert createContextualInstance(Field.class).get() != null;
+      assert getReference(Field.class).get() != null;
    }
 
 }

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/activities/current/JndiManagerCurrentActivityTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/activities/current/JndiManagerCurrentActivityTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/activities/current/JndiManagerCurrentActivityTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -62,7 +62,7 @@
       assert getBeans(Cow.class).size() == 1;
       WeldManager childActivity = getCurrentManager().createActivity();
       childActivity.setCurrent(dummyContext.getScope());
-      assert createContextualInstance(Donkey.class).getManager().equals(childActivity);
+      assert getReference(Donkey.class).getManager().equals(childActivity);
    }
 
 }

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/beanManager/serializability/ManagerTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/beanManager/serializability/ManagerTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/beanManager/serializability/ManagerTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -16,6 +16,7 @@
 import org.jboss.weld.literal.DefaultLiteral;
 import org.jboss.weld.manager.BeanManagerImpl;
 import org.jboss.weld.test.AbstractWeldTest;
+import org.jboss.weld.test.Utils;
 import org.testng.annotations.Test;
 
 @Artifact
@@ -99,7 +100,7 @@
    public void testRootManagerSerializability() throws Exception
    {
       String rootManagerId = getCurrentManager().getId();
-      BeanManagerImpl deserializedRootManager = (BeanManagerImpl) deserialize(serialize(getCurrentManager()));
+      BeanManagerImpl deserializedRootManager = (BeanManagerImpl) Utils.deserialize(Utils.serialize(getCurrentManager()));
       assert deserializedRootManager.getId().equals(rootManagerId);
       assert getCurrentManager().getBeans(Foo.class).size() == 1;
       assert deserializedRootManager.getBeans(Foo.class).size() == 1;
@@ -113,7 +114,7 @@
       Bean<?> dummyBean = new DummyBean();
       childManager.addBean(dummyBean);
       String childManagerId = childManager.getId();
-      BeanManagerImpl deserializedChildManager = (BeanManagerImpl) deserialize(serialize(childManager));
+      BeanManagerImpl deserializedChildManager = (BeanManagerImpl) Utils.deserialize(Utils.serialize(childManager));
       assert deserializedChildManager.getId().equals(childManagerId);
       assert childManager.getBeans(Dummy.class).size() == 1;
       assert deserializedChildManager.getBeans(Dummy.class).size() == 1;

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/builtinBeans/BuiltInBeanPassivationCapableTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/builtinBeans/BuiltInBeanPassivationCapableTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/builtinBeans/BuiltInBeanPassivationCapableTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -22,6 +22,7 @@
 
 import org.jboss.testharness.impl.packaging.Artifact;
 import org.jboss.weld.test.AbstractWeldTest;
+import org.jboss.weld.test.Utils;
 import org.testng.annotations.Test;
 
 @Artifact
@@ -31,40 +32,40 @@
    @Test
    public void testDefaultValidatorBean() throws Throwable
    {
-      Validator validator = getCurrentManager().getInstanceByType(Validator.class);
-      Validator validator1 = deserialize(serialize(validator));
+      Validator validator = getReference(Validator.class);
+      Validator validator1 = Utils.deserialize(Utils.serialize(validator));
       assert checkValidator(validator1);
    }
 
    @Test
    public void testDefaultValidatorFactoryBean() throws Throwable
    {
-      ValidatorFactory validatorFactory = getCurrentManager().getInstanceByType(ValidatorFactory.class);
-      ValidatorFactory validatorFactory1 = deserialize(serialize(validatorFactory));
+      ValidatorFactory validatorFactory = getReference(ValidatorFactory.class);
+      ValidatorFactory validatorFactory1 = Utils.deserialize(Utils.serialize(validatorFactory));
       assert checkValidatorFactory(validatorFactory1);
    }
 
    @Test(groups="incontainer-broken")
    public void testPrincipal() throws Throwable
    {
-      Principal principal = getCurrentManager().getInstanceByType(Principal.class);
-      Principal principal1 = deserialize(serialize(principal));
+      Principal principal = getReference(Principal.class);
+      Principal principal1 = Utils.deserialize(Utils.serialize(principal));
       assert checkPrincipal(principal1);
    }
 
    @Test
    public void testUserTransactionBean() throws Throwable
    {
-      UserTransaction userTransaction = getCurrentManager().getInstanceByType(UserTransaction.class);
-      UserTransaction userTransaction1 = deserialize(serialize(userTransaction));
+      UserTransaction userTransaction = getReference(UserTransaction.class);
+      UserTransaction userTransaction1 = Utils.deserialize(Utils.serialize(userTransaction));
       assert checkUserTransaction(userTransaction1);
    }
    
    @Test 
    public void testBeanManagerBean() throws Throwable
    {
-      BeanManager beanManager = getCurrentManager().getInstanceByType(BeanManager.class);
-      BeanManager beanManager1 = deserialize(serialize(beanManager));
+      BeanManager beanManager = getReference(BeanManager.class);
+      BeanManager beanManager1 = Utils.deserialize(Utils.serialize(beanManager));
       assert checkBeanManager(beanManager1);
       assert checkEquality(beanManager, beanManager1);
    }
@@ -72,8 +73,8 @@
    @Test
    public void testInstance() throws Throwable
    {
-      Instance<Cow> instance = getCurrentManager().getInstanceByType(Consumer.class).getCow();
-      Instance<Cow> instance1 = deserialize(serialize(instance));
+      Instance<Cow> instance = getReference(Consumer.class).getCow();
+      Instance<Cow> instance1 = Utils.deserialize(Utils.serialize(instance));
       assert checkInstance(instance1);
       assert checkEquality(instance, instance1);
    }
@@ -81,9 +82,9 @@
    @Test
    public void testEvent() throws Throwable
    {
-      Event<Cow> event = getCurrentManager().getInstanceByType(Consumer.class).getEvent();
-      CowEventObserver observer = getCurrentManager().getInstanceByType(CowEventObserver.class);
-      Event<Cow> event1 = deserialize(serialize(event));
+      Event<Cow> event = getReference(Consumer.class).getEvent();
+      CowEventObserver observer = getReference(CowEventObserver.class);
+      Event<Cow> event1 = Utils.deserialize(Utils.serialize(event));
       assert checkEvent(event1, observer);
       assert checkEquality(event, event1);
    }
@@ -92,9 +93,9 @@
    public void testFieldInjectionPoint() throws Throwable
    {
       Dog.reset();
-      getCurrentManager().getInstanceByType(FieldInjectionPointConsumer.class).ping();
+      getReference(FieldInjectionPointConsumer.class).ping();
       InjectionPoint injectionPoint = Dog.getInjectionPoint();
-      InjectionPoint injectionPoint1 = deserialize(serialize(injectionPoint));
+      InjectionPoint injectionPoint1 = Utils.deserialize(Utils.serialize(injectionPoint));
       assert checkInjectionPoint(injectionPoint1, FieldInjectionPointConsumer.class);
       assert checkEquality(injectionPoint, injectionPoint1);
    }
@@ -103,9 +104,9 @@
    public void testConstructorInjectionPoint() throws Throwable
    {
       Dog.reset();
-      getCurrentManager().getInstanceByType(ConstructorInjectionPointConsumer.class).ping();
+      getReference(ConstructorInjectionPointConsumer.class).ping();
       InjectionPoint injectionPoint = Dog.getInjectionPoint();
-      InjectionPoint injectionPoint1 = deserialize(serialize(injectionPoint));
+      InjectionPoint injectionPoint1 = Utils.deserialize(Utils.serialize(injectionPoint));
       assert checkInjectionPoint(injectionPoint1, ConstructorInjectionPointConsumer.class);
       assert checkEquality(injectionPoint, injectionPoint1);
    }
@@ -114,9 +115,9 @@
    public void testMethodInjectionPoint() throws Throwable
    {
       Dog.reset();
-      getCurrentManager().getInstanceByType(MethodInjectionPointConsumer.class).ping();
+      getReference(MethodInjectionPointConsumer.class).ping();
       InjectionPoint injectionPoint = Dog.getInjectionPoint();
-      InjectionPoint injectionPoint1 = deserialize(serialize(injectionPoint));
+      InjectionPoint injectionPoint1 = Utils.deserialize(Utils.serialize(injectionPoint));
       assert checkInjectionPoint(injectionPoint1, MethodInjectionPointConsumer.class);
       assert checkEquality(injectionPoint, injectionPoint1);
    }
@@ -124,9 +125,9 @@
    @Test
    public void testAllOnBean() throws Throwable
    {
-      Consumer consumer = getCurrentManager().getInstanceByType(Consumer.class);
+      Consumer consumer = getReference(Consumer.class);
       consumer.check();
-      Consumer consumer1 = deserialize(serialize(consumer));
+      Consumer consumer1 = Utils.deserialize(Utils.serialize(consumer));
       consumer1.check();
    }
 

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/builtinBeans/ee/EEResourceProducerFieldPassivationCapableTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/builtinBeans/ee/EEResourceProducerFieldPassivationCapableTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/builtinBeans/ee/EEResourceProducerFieldPassivationCapableTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -18,6 +18,7 @@
 import org.jboss.testharness.impl.packaging.PackagingType;
 import org.jboss.testharness.impl.packaging.Resource;
 import org.jboss.weld.test.AbstractWeldTest;
+import org.jboss.weld.test.Utils;
 import org.testng.annotations.Test;
 
 @Artifact
@@ -32,41 +33,41 @@
    @Test
    public void testResource() throws Throwable
    {
-      UserTransaction userTransaction = getCurrentManager().getInstanceByType(UserTransaction.class, PRODUCED);
-      UserTransaction userTransaction1 = deserialize(serialize(userTransaction));
+      UserTransaction userTransaction = getReference(UserTransaction.class, PRODUCED);
+      UserTransaction userTransaction1 = Utils.deserialize(Utils.serialize(userTransaction));
       assert checkUserTransaction(userTransaction1);
    }
    
    @Test
    public void testEntityManager() throws Throwable
    {
-      EntityManager entityManager = getCurrentManager().getInstanceByType(EntityManager.class, PRODUCED);
-      EntityManager entityManager1 = deserialize(serialize(entityManager));
+      EntityManager entityManager = getReference(EntityManager.class, PRODUCED);
+      EntityManager entityManager1 = Utils.deserialize(Utils.serialize(entityManager));
       assert checkEntityManager(entityManager1);
    }
    
    @Test
    public void testEntityManagerFactory() throws Throwable
    {
-      EntityManagerFactory entityManagerFactory = getCurrentManager().getInstanceByType(EntityManagerFactory.class, PRODUCED);
-      EntityManagerFactory entityManagerFactory1 = deserialize(serialize(entityManagerFactory));
+      EntityManagerFactory entityManagerFactory = getReference(EntityManagerFactory.class, PRODUCED);
+      EntityManagerFactory entityManagerFactory1 = Utils.deserialize(Utils.serialize(entityManagerFactory));
       assert checkEntityManagerFactory(entityManagerFactory1);
    }
    
    @Test
    public void testRemoteEjb() throws Throwable
    {
-      HorseRemote horse = getCurrentManager().getInstanceByType(HorseRemote.class, PRODUCED);
-      HorseRemote horse1 = deserialize(serialize(horse));
+      HorseRemote horse = getReference(HorseRemote.class, PRODUCED);
+      HorseRemote horse1 = Utils.deserialize(Utils.serialize(horse));
       assert checkRemoteEjb(horse1);
    }
    
    @Test
    public void testAllOnBean() throws Throwable
    {
-      EEResourceConsumer consumer = getCurrentManager().getInstanceByType(EEResourceConsumer.class);
+      EEResourceConsumer consumer = getReference(EEResourceConsumer.class);
       consumer.check();
-      EEResourceConsumer consumer1 = deserialize(serialize(consumer));
+      EEResourceConsumer consumer1 = Utils.deserialize(Utils.serialize(consumer));
       consumer1.check();
    }
 

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/ApplicationScopedTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/ApplicationScopedTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/ApplicationScopedTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -14,7 +14,7 @@
    public void testConcurrentInitilized() throws InterruptedException
    {
       final CountDownLatch latch = new CountDownLatch(10);
-      final ApplicationScopedObject applictionScopedObject = getCurrentManager().getInstanceByType(ApplicationScopedObject.class);
+      final ApplicationScopedObject applictionScopedObject = getReference(ApplicationScopedObject.class);
       for (int i = 0; i < 10; i++)
       {
          new Thread(new Runnable()

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/ParameterizedTypeScopedTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/ParameterizedTypeScopedTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/ParameterizedTypeScopedTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -13,7 +13,7 @@
    @Test
    public void testStringList()
    {
-      List<String> str = createContextualInstance(StringHolder.class).getStrings();
+      List<String> str = getReference(StringHolder.class).getStrings();
       assert str.size() == 2;
    }
 }

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/SimpleDecoratorTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/SimpleDecoratorTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/SimpleDecoratorTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -17,7 +17,7 @@
    @Test
    public void testSimpleDecorator()
    {
-      SimpleBean simpleBean = getCurrentManager().getInstanceByType(SimpleBean.class);
+      SimpleBean simpleBean = getReference(SimpleBean.class);
       
       resetDecorators();
       assert simpleBean.echo1(1) == 1;

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -37,7 +37,7 @@
 
       resetAll();
 
-      Window window = getCurrentManager().getInstanceByType(WindowImpl.class);
+      Window window = getReference(WindowImpl.class);
       window.draw();
       assert WindowImpl.drawn;
       assert FrameWithFieldInjectedDelegate.drawn;

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithAbstractMethodAndInitializerMethodTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithAbstractMethodAndInitializerMethodTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithAbstractMethodAndInitializerMethodTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -35,7 +35,7 @@
    public void testAbstractDecoratorApplied()
    {
 
-      Window window = getCurrentManager().getInstanceByType(WindowImpl.class);
+      Window window = getReference(WindowImpl.class);
 
       resetAll();
       window.draw();

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithAbstractMethodTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithAbstractMethodTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithAbstractMethodTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -35,7 +35,7 @@
    public void testAbstractDecoratorApplied()
    {
 
-      Window window = getCurrentManager().getInstanceByType(WindowImpl.class);
+      Window window = getReference(WindowImpl.class);
 
       resetAll();
       window.draw();

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithCallToItselfTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithCallToItselfTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithCallToItselfTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -35,7 +35,7 @@
    public void testAbstractDecoratorApplied()
    {
 
-      Window window = getCurrentManager().getInstanceByType(WindowImpl.class);
+      Window window = getReference(WindowImpl.class);
 
       resetAll();
       window.move();

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithConstructorTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithConstructorTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithConstructorTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -37,7 +37,7 @@
 
       resetAll();
 
-      Window window = getCurrentManager().getInstanceByType(WindowImpl.class);
+      Window window = getReference(WindowImpl.class);
       window.draw();
       assert WindowImpl.drawn;
       assert FrameWithConstructorInjectedDelegate.drawn;

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithInitializerMethodTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithInitializerMethodTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithInitializerMethodTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -37,7 +37,7 @@
 
       resetAll();
 
-      Window window = getCurrentManager().getInstanceByType(WindowImpl.class);
+      Window window = getReference(WindowImpl.class);
       window.draw();
       assert WindowImpl.drawn;
       assert FrameWithInitializerMethodInjectedDelegate.drawn;

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/decoratedTypes/PartialDecoratorTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/decoratedTypes/PartialDecoratorTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/decoratedTypes/PartialDecoratorTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -33,7 +33,7 @@
    @Test
    public void testDecoratorDoesNotDecorateOutsideDecoratedTypes()
    {
-      TestBean testBean = getCurrentManager().getInstanceByType(TestBean.class);
+      TestBean testBean = getReference(TestBean.class);
       testBean.decoratedMethod();
       testBean.notDecoratedMethod();
 

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/generic/PartialDecoratorTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/generic/PartialDecoratorTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/generic/PartialDecoratorTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -33,7 +33,7 @@
    @Test
    public void testDecoratorDoesNotDecorateOutsideDecoratedTypes()
    {
-      TestBean testBean = getCurrentManager().getInstanceByType(TestBean.class);
+      TestBean testBean = getReference(TestBean.class);
       testBean.invoke();
 
       assert PartialDecorator.decoratedInvoked;

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/stackoverflow/StackOverFlowTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/stackoverflow/StackOverFlowTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/stackoverflow/StackOverFlowTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -17,7 +17,7 @@
    @Test(description="WELD-296")
    public void test()
    {
-      getCurrentManager().getInstanceByType(PaymentService.class, new AnnotationLiteral<SimpleService>() {}).pay("Pete", new BigDecimal(100));
+      getReference(PaymentService.class, new AnnotationLiteral<SimpleService>() {}).pay("Pete", new BigDecimal(100));
    }
 
 }

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/EnterpriseBeanDefinitionTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/EnterpriseBeanDefinitionTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/EnterpriseBeanDefinitionTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -6,6 +6,7 @@
 import org.jboss.testharness.impl.packaging.Packaging;
 import org.jboss.testharness.impl.packaging.PackagingType;
 import org.jboss.weld.test.AbstractWeldTest;
+import org.jboss.weld.test.Utils;
 import org.testng.annotations.Test;
 
 @Artifact
@@ -17,7 +18,7 @@
    public void testSuperInterfacesAreBeanTypes()
    {
       Bean<?> bean = getBean(Dog.class);
-      assert typeSetMatches(bean.getTypes(), Object.class, Dog.class, Animal.class);
+      assert Utils.typeSetMatches(bean.getTypes(), Object.class, Dog.class, Animal.class);
    }
    
 }

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/EnterpriseBeanTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/EnterpriseBeanTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/EnterpriseBeanTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -7,6 +7,7 @@
 import org.jboss.testharness.impl.packaging.Packaging;
 import org.jboss.testharness.impl.packaging.PackagingType;
 import org.jboss.weld.test.AbstractWeldTest;
+import org.jboss.weld.test.Utils;
 import org.testng.annotations.Test;
 
 @Artifact
@@ -26,7 +27,7 @@
    {
       try
       {
-         getCurrentManager().getInstanceByType(Fedora.class).causeRuntimeException();
+         getReference(Fedora.class).causeRuntimeException();
       }
       catch (Throwable t)
       {
@@ -43,11 +44,11 @@
    {
       try
       {
-         getCurrentManager().getInstanceByType(Fedora.class).causeRuntimeException();
+         getReference(Fedora.class).causeRuntimeException();
       }
       catch (Throwable t) 
       {
-         if (isExceptionInHierarchy(t, BowlerHatException.class))
+         if (Utils.isExceptionInHierarchy(t, BowlerHatException.class))
          {
             return;
          }

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -47,7 +47,7 @@
    @Test(groups = { "enterpriseBeans", "clientProxy", "lifecycle", "integration" })
    public void testCreateSFSB()
    {
-      GrossStadt frankfurt = getCurrentManager().getInstanceByType(GrossStadt.class);
+      GrossStadt frankfurt = getReference(GrossStadt.class);
       Bean<KleinStadt> stadtBean = getBean(KleinStadt.class);
       assert stadtBean != null : "Expected a bean for stateful session bean Kassel";
       CreationalContext<KleinStadt> creationalContext = new MockCreationalContext<KleinStadt>();
@@ -74,7 +74,7 @@
    @Test(groups = { "enterpriseBeans", "clientProxy", "lifecycle", "integration" })
    public void testDestroyRemovesSFSB() throws Exception
    {
-      GrossStadt frankfurt = getCurrentManager().getInstanceByType(GrossStadt.class);
+      GrossStadt frankfurt = getReference(GrossStadt.class);
       Bean<KleinStadt> stadtBean = getBean(KleinStadt.class);
       assert stadtBean != null : "Expected a bean for stateful session bean Kassel";
       RequestContext requestContext = Container.instance().services().get(ContextLifecycle.class).getRequestContext();

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/proxyability/EnterpriseBeanLifecycleTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/proxyability/EnterpriseBeanLifecycleTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/proxyability/EnterpriseBeanLifecycleTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -16,7 +16,7 @@
    @Test(description="WELD-290")
    public void testSLSBInjectedIntoPassivatingManagedBean()
    {
-      SimpleBean bean = getCurrentManager().getInstanceByType(SimpleBean.class);
+      SimpleBean bean = getReference(SimpleBean.class);
       assert bean.getMessage().equals("This is my message from my stateless bean");
       
    }

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/event/EventQualifierTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/event/EventQualifierTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/event/EventQualifierTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -11,7 +11,7 @@
    @Test(description="WELD-226")
    public void testDefaultQualifierNotRequired()
    {
-      Bar bar = getCurrentManager().getInstanceByType(Bar.class);
+      Bar bar = getReference(Bar.class);
       bar.fireWithNoQualifiers();
       assert bar.isUnqualifiedObserved();
       assert !bar.isUpdatedObserved();

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/event/SimpleEventTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/event/SimpleEventTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/event/SimpleEventTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -49,7 +49,7 @@
    @Test
    public void testFireEventOnEvent()
    {
-      App app = createContextualInstance(App.class);
+      App app = getReference(App.class);
       
       initFlags();
       

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/examples/ExampleTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/examples/ExampleTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/examples/ExampleTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -10,12 +10,12 @@
    @Test
    public void testGameGenerator() throws Exception 
    {
-     Game game1 = getCurrentManager().getInstanceByType(Game.class);
-     Game game2 = getCurrentManager().getInstanceByType(Game.class);
+     Game game1 = getReference(Game.class);
+     Game game2 = getReference(Game.class);
      assert game1!=game2;
      assert game1.getNumber()!=game2.getNumber();
-     Generator gen1 = getCurrentManager().getInstanceByType(Generator.class);
-     Generator gen2 = getCurrentManager().getInstanceByType(Generator.class);
+     Generator gen1 = getReference(Generator.class);
+     Generator gen2 = getReference(Generator.class);
      assert gen1.getRandom()!=null;
      assert gen1.getRandom()==gen2.getRandom();
    }
@@ -24,7 +24,7 @@
    public void testSentenceTranslator() throws Exception 
    {
       
-      TextTranslator tt1 = getCurrentManager().getInstanceByType(TextTranslator.class);
+      TextTranslator tt1 = getReference(TextTranslator.class);
       try 
       {
          tt1.translate("hello world");

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/examples/MockExampleTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/examples/MockExampleTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/examples/MockExampleTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -13,7 +13,7 @@
    @Test
    public void testMockSentenceTranslator() throws Exception 
    {   
-      TextTranslator tt2 = getCurrentManager().getInstanceByType(TextTranslator.class);
+      TextTranslator tt2 = getReference(TextTranslator.class);
       assert "Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.".equals( tt2.translate("Hello world. How's tricks?") );
    }
    

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/exceptions/ExceptionHandlingTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/exceptions/ExceptionHandlingTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/exceptions/ExceptionHandlingTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -16,7 +16,7 @@
    {
       try
       {
-         getCurrentManager().getInstanceByType(Lorry_Broken.class);
+         getReference(Lorry_Broken.class);
       }
       catch (Exception e) 
       {
@@ -33,7 +33,7 @@
    {
       try
       {
-         getCurrentManager().getInstanceByType(Ship.class, new AnnotationLiteral<Large>() {});
+         getReference(Ship.class, new AnnotationLiteral<Large>() {});
       }
       catch (Exception e) 
       {

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/ExtensionTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/ExtensionTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/ExtensionTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -19,14 +19,14 @@
    public void testExtensionInjectableAsBean()
    {
       assert SimpleExtension.getInstance() != null;
-      assert getCurrentManager().getInstanceByType(SimpleExtension.class).equals(SimpleExtension.getInstance());
+      assert getReference(SimpleExtension.class).equals(SimpleExtension.getInstance());
    }
    
    @Test(description="WELD-243")
    public void testContainerEventsOnlySentToExtensionBeans()
    {
-      ExtensionObserver extensionObserver = getCurrentManager().getInstanceByType(ExtensionObserver.class);
-      OtherObserver otherObserver = getCurrentManager().getInstanceByType(OtherObserver.class);
+      ExtensionObserver extensionObserver = getReference(ExtensionObserver.class);
+      OtherObserver otherObserver = getReference(OtherObserver.class);
       
       assert extensionObserver.isBeforeBeanDiscovery();
       assert extensionObserver.isAllBeforeBeanDiscovery();
@@ -93,7 +93,7 @@
    @Test
    public void testInjectionTargetWrapped()
    {
-      getCurrentManager().getInstanceByType(Capercaillie.class);
+      getReference(Capercaillie.class);
       assert Woodland.isPostConstructCalled();
       assert WoodlandExtension.isInjectCalled();
       assert WoodlandExtension.isPostConstructCalled();

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/generic/GenericBeanTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/generic/GenericBeanTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/generic/GenericBeanTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -31,7 +31,7 @@
    @Test
    public void testGenericBean()
    {
-      TestBean testBean = getCurrentManager().getInstanceByType(TestBean.class);
+      TestBean testBean = getReference(TestBean.class);
       assert "Hello".equals(testBean.echo("Hello"));
       assert Integer.valueOf(1).equals(testBean.echo(1));
       Subclass subclassInstance = new Subclass();

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/injectionPoint/InjectionPointTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/injectionPoint/InjectionPointTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/injectionPoint/InjectionPointTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -5,6 +5,7 @@
 
 import org.jboss.testharness.impl.packaging.Artifact;
 import org.jboss.weld.test.AbstractWeldTest;
+import org.jboss.weld.test.Utils;
 import org.testng.annotations.Test;
 
 @Artifact
@@ -14,11 +15,11 @@
    @Test(description="WELD-239")
    public void testCorrectInjectionPointUsed()
    {
-      getCurrentManager().getInstanceByType(IntConsumer.class).ping();
+      getReference(IntConsumer.class).ping();
       
       try
       {
-         getCurrentManager().getInstanceByType(DoubleConsumer.class).ping();
+         getReference(DoubleConsumer.class).ping();
       }
       catch (IllegalProductException e)
       {
@@ -29,11 +30,11 @@
    @Test(description="WELD-316")
    public void testFieldInjectionPointSerializability() throws Throwable
    {
-      getCurrentManager().getInstanceByType(StringConsumer.class).ping();
+      getReference(StringConsumer.class).ping();
       InjectionPoint ip = StringGenerator.getInjectionPoint();
       assert ip != null;
       assert ip.getMember().getName().equals("str");
-      InjectionPoint ip1 = deserialize(serialize(ip));
+      InjectionPoint ip1 = Utils.deserialize(Utils.serialize(ip));
       assert ip1.getMember().getName().equals("str");
    }
 

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/ParameterizedProducerTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/ParameterizedProducerTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/ParameterizedProducerTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -14,10 +14,10 @@
    @Test
    public void testParameterizedListInjection()
    {
-      List<String> strings = createContextualInstance(Target.class).getStringList();
+      List<String> strings = getReference(Target.class).getStringList();
       assert strings.size() == 2;
 
-      ParameterizedListInjection item = getCurrentManager().getInstanceByType(ParameterizedListInjection.class);
+      ParameterizedListInjection item = getReference(ParameterizedListInjection.class);
       assert item.getFieldInjection().size() == 2;
       assert item.getValue().size() == 2;
       assert item.getSetterInjection().size() == 2;
@@ -27,10 +27,10 @@
    @Test
    public void testParameterizedCollectionInjection()
    {
-      Collection<String> strings = createContextualInstance(Target.class).getStrings();
+      Collection<String> strings = getReference(Target.class).getStrings();
       assert strings.size() == 2;
 
-      ParameterizedCollectionInjection item = getCurrentManager().getInstanceByType(ParameterizedCollectionInjection.class);
+      ParameterizedCollectionInjection item = getReference(ParameterizedCollectionInjection.class);
       assert item.getFieldInjection().size() == 2;
       assert item.getValue().size() == 2;
       assert item.getSetterInjection().size() == 2;
@@ -40,10 +40,10 @@
    @Test
    public void testIntegerCollectionInjection()
    {
-      Collection<Integer> integers = createContextualInstance(Target.class).getIntegers();
+      Collection<Integer> integers = getReference(Target.class).getIntegers();
       assert integers.size() == 4;
 
-      IntegerCollectionInjection item = getCurrentManager().getInstanceByType(IntegerCollectionInjection.class);
+      IntegerCollectionInjection item = getReference(IntegerCollectionInjection.class);
       assert item.getFieldInjection().size() == 4;
       assert item.getValue().size() == 4;
       assert item.getSetterInjection().size() == 4;
@@ -53,14 +53,14 @@
    @Test
    public void testInstanceList()
    {
-        ListInstance listInstance = getCurrentManager().getInstanceByType(ListInstance.class);
+        ListInstance listInstance = getReference(ListInstance.class);
         assert listInstance.get().isAmbiguous();
    }
    
    @Test
    public void testTypeParameterInstance()
    {
-        ListStringInstance listInstance = getCurrentManager().getInstanceByType(ListStringInstance.class);
+        ListStringInstance listInstance = getReference(ListStringInstance.class);
         assert listInstance.get().size() == 2;
    }
 }

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/ManagerProducerTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/ManagerProducerTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/ManagerProducerTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -11,7 +11,7 @@
    public void testInjectManagerProducer()
    {
       ManagerProducer.setInjectionPointInjected(false);
-      getCurrentManager().getInstanceByType(IntInjection.class);
+      getReference(IntInjection.class);
       assert ManagerProducer.isInjectionPointInjected();
    }
 

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/NullProducerTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/NullProducerTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/NullProducerTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -11,7 +11,7 @@
    @Test(description="WBRI-276")
    public void testProducerMethodReturnsNull()
    {
-      getCurrentManager().getInstanceByType(Government.class).destabilize();
+      getReference(Government.class).destabilize();
    }
 
 }

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/proxy/enterprise/EnterpriseBeanProxyTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/proxy/enterprise/EnterpriseBeanProxyTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/proxy/enterprise/EnterpriseBeanProxyTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -19,7 +19,7 @@
    @Test(description="WBRI-109")
    public void testNoInterfaceView() throws Exception
    {
-      Object mouse = getCurrentManager().getInstanceByType(MouseLocal.class);
+      Object mouse = getReference(MouseLocal.class);
       assert mouse instanceof ProxyObject;
       assert mouse instanceof MouseLocal;
    }

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/LookupInstanceTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/LookupInstanceTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/LookupInstanceTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -18,7 +18,7 @@
    @Test
    public void testLookupInstance() throws Exception
    {
-      assert createContextualInstance(new TypeLiteral<Instance<List<?>>>(){}.getRawType(), DefaultLiteral.INSTANCE) == null; 
+      assert getReference(new TypeLiteral<Instance<List<?>>>(){}.getRawType(), DefaultLiteral.INSTANCE) == null; 
    }
    
 }

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/Weld256Test.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/Weld256Test.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/Weld256Test.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -11,7 +11,7 @@
    @Test
    public void testParameterizedInjection()
    {
-      LookupFoo lookupFoo = getCurrentManager().getInstanceByType(LookupFoo.class);
+      LookupFoo lookupFoo = getReference(LookupFoo.class);
       assert lookupFoo.getFoo().getName().equals("foo");
       assert lookupFoo.getFoobaz().getName().equals("foobase");
    }

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/circular/CircularDependencyTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/circular/CircularDependencyTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/circular/CircularDependencyTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -11,7 +11,7 @@
    @Test
    public void testCircularInjectionOnTwoSimpleDependentBeans() throws Exception
    {
-      getCurrentManager().getInstanceByType(Foo.class).getName();
+      getReference(Foo.class).getName();
       assert Foo.success;
       assert Bar.success;
    }
@@ -19,13 +19,13 @@
    @Test
    public void testDependentProducerMethodDeclaredOnDependentBeanWhichInjectsProducedBean() throws Exception
    {
-      getCurrentManager().getInstanceByType(DependentSelfConsumingDependentProducer.class).ping();
+      getReference(DependentSelfConsumingDependentProducer.class).ping();
    }
    
    @Test
    public void testDependentSelfConsumingProducer() throws Exception
    {
-      getCurrentManager().getInstanceByType(Violation.class).ping();
+      getReference(Violation.class).ping();
    }
 
 }

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/circular/resource/ResourceCircularDependencyTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/circular/resource/ResourceCircularDependencyTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/circular/resource/ResourceCircularDependencyTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -18,7 +18,7 @@
    @Test
    public void testResourceProducerField() throws Exception
    {
-      assert getCurrentManager().getInstanceByType(Baz.class).getFooDb().isOpen();
+      assert getReference(Baz.class).getFooDb().isOpen();
       assert true;
    }
 

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/wbri279/Weld279Test.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/wbri279/Weld279Test.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/wbri279/Weld279Test.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -31,7 +31,7 @@
    @Test(description="WELD-279")
    public void testLookupOfGenericTypeSubclass()
    {
-      assert createContextualInstance(SomeBean.class).getObjectAsString().equals(IntegerFactory.VALUE.toString());
+      assert getReference(SomeBean.class).getObjectAsString().equals(IntegerFactory.VALUE.toString());
    }
 
 }

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/wbri293/ContextualReferenceTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/wbri293/ContextualReferenceTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/wbri293/ContextualReferenceTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -30,9 +30,9 @@
 {
    @Test(groups = "broken")
    public void testReferencesEqual() {
-      Sheep sheep = getCurrentManager().getInstanceByType(Sheep.class);
+      Sheep sheep = getReference(Sheep.class);
       sheep.setAge(10);
-      Sheep sheep2 = getCurrentManager().getInstanceByType(Sheep.class);
+      Sheep sheep2 = getReference(Sheep.class);
       assert sheep.getAge() == sheep2.getAge();
       assert sheep.equals(sheep2);
    }

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/scope/ScopeTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/scope/ScopeTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/scope/ScopeTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -36,7 +36,7 @@
       assert getReference(specialTempBean).getNumber() == 10;
       assert getReference(uselessTempBean).getNumber() == 11;
       
-      TempConsumer tempConsumer = createContextualInstance(TempConsumer.class);
+      TempConsumer tempConsumer = getReference(TempConsumer.class);
       tempConsumer.getSpecialTemp().setNumber(101);
       tempConsumer.getUselessTemp().setNumber(102);
       

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/serialization/SerializationTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/serialization/SerializationTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/serialization/SerializationTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -2,6 +2,7 @@
 
 import org.jboss.testharness.impl.packaging.Artifact;
 import org.jboss.weld.test.AbstractWeldTest;
+import org.jboss.weld.test.Utils;
 import org.testng.annotations.Test;
 
 @Artifact
@@ -12,12 +13,12 @@
    public void testConversationManagerSerializable()
       throws Exception
    {
-      TestConversationManager cMgr = getCurrentManager().getInstanceByType(TestConversationManager.class);
+      TestConversationManager cMgr = getReference(TestConversationManager.class);
       
       assert cMgr.getConversationInstance() != null;
       assert cMgr.getConversationInstance().get() != null;
       
-      Object deserialized = deserialize(serialize(cMgr));
+      Object deserialized = Utils.deserialize(Utils.serialize(cMgr));
       
       assert deserialized instanceof TestConversationManager;
       TestConversationManager deserializedCMgr = (TestConversationManager) deserialized;

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/extensions/NonBdaExtensionTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/extensions/NonBdaExtensionTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/extensions/NonBdaExtensionTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -9,6 +9,7 @@
 import org.jboss.weld.mock.MockBeanDeploymentArchive;
 import org.jboss.weld.mock.MockServletLifecycle;
 import org.jboss.weld.mock.TestContainer;
+import org.jboss.weld.test.Utils;
 import org.jboss.weld.util.serviceProvider.PackageServiceLoaderFactory;
 import org.jboss.weld.util.serviceProvider.ServiceLoaderFactory;
 import org.testng.annotations.Test;
@@ -61,7 +62,7 @@
       BeanManagerImpl beanManager1 = container.getBeanManager();
       BeanManagerImpl beanManager2 = container.getLifecycle().getBootstrap().getManager(bda2);
       
-      Observer1 observer1 = beanManager1.getInstanceByType(Observer1.class);
+      Observer1 observer1 = Utils.getReference(beanManager1, Observer1.class);
       assert observer1.isBeforeBeanDiscoveryCalled();
       assert observer1.getBeforeBeanDiscoveryBeanManager().equals(beanManager1);
       assert observer1.isAfterBeanDiscoveryCalled();
@@ -74,7 +75,7 @@
       // Also check that the accessibility graph has been updated
       assert beanManager1.getBeans(Observer2.class).size() == 1;
       
-      Observer2 observer2 = beanManager2.getInstanceByType(Observer2.class);
+      Observer2 observer2 = Utils.getReference(beanManager2, Observer2.class);
       assert observer2.isBeforeBeanDiscoveryCalled();
       assert observer2.getBeforeBeanDiscoveryBeanManager().equals(beanManager2);
       assert observer2.isAfterBeanDiscoveryCalled();
@@ -129,8 +130,8 @@
       // Get the bean manager for bda1 and bda2
       BeanManagerImpl beanManager1 = container.getBeanManager();
       
-      CountingObserver1 observer1 = beanManager1.getInstanceByType(CountingObserver1.class);
-      CountingObserver2 observer2 = beanManager1.getInstanceByType(CountingObserver2.class);
+      CountingObserver1 observer1 = Utils.getReference(beanManager1, CountingObserver1.class);
+      CountingObserver2 observer2 = Utils.getReference(beanManager1, CountingObserver2.class);
       assert observer1.getBeforeBeanDiscovery() == 1;
       assert observer1.getProcessFooManagedBean() == 1;
       assert observer1.getProcessBarManagedBean() == 0;

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/nonTransitiveResolution/TransitiveResolutionTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/nonTransitiveResolution/TransitiveResolutionTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/nonTransitiveResolution/TransitiveResolutionTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -8,6 +8,7 @@
 import org.jboss.weld.mock.MockDeployment;
 import org.jboss.weld.mock.MockServletLifecycle;
 import org.jboss.weld.mock.TestContainer;
+import org.jboss.weld.test.Utils;
 import org.testng.annotations.Test;
 
 public class TransitiveResolutionTest
@@ -116,7 +117,7 @@
       assert warBeanManager.getBeans(Foo.class).size() == 1;
       assert ejbJarBeanManager.getBeans(Foo.class).size() == 1;
       assert ejbJarBeanManager.getBeans(Bar.class).size() == 0;
-      Bar bar = warBeanManager.getInstanceByType(Bar.class);
+      Bar bar = Utils.getReference(warBeanManager, Bar.class);
       assert bar.getFoo() != null;
       assert bar.getBeanManager() != null;
       assert bar.getBeanManager().equals(warBeanManager);

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/environments/servlet/ServletEnvironmentTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/environments/servlet/ServletEnvironmentTest.java	2010-01-13 18:48:08 UTC (rev 5455)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/environments/servlet/ServletEnvironmentTest.java	2010-01-13 20:41:04 UTC (rev 5456)
@@ -13,6 +13,7 @@
 import org.jboss.weld.manager.BeanManagerImpl;
 import org.jboss.weld.mock.MockServletLifecycle;
 import org.jboss.weld.mock.TestContainer;
+import org.jboss.weld.test.Utils;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
@@ -46,7 +47,7 @@
       Map<Class<?>, Bean<?>> beans = new HashMap<Class<?>, Bean<?>>();
       for (Bean<?> bean : manager.getBeans())
       {
-         if (bean instanceof RIBean)
+         if (bean instanceof RIBean<?>)
          {
             beans.put(((RIBean<?>) bean).getType(), bean);
          }
@@ -56,11 +57,11 @@
       assert beans.containsKey(SeaBass.class);
       assert beans.containsKey(Sole.class);
       
-      assert beans.get(Tuna.class) instanceof ManagedBean;
-      assert beans.get(Salmon.class) instanceof ManagedBean;
-      assert beans.get(SeaBass.class) instanceof ManagedBean;
-      assert beans.get(Sole.class) instanceof ManagedBean;
-      manager.getInstanceByType(Sole.class, new AnnotationLiteral<Whitefish>() {}).ping();
+      assert beans.get(Tuna.class) instanceof ManagedBean<?>;
+      assert beans.get(Salmon.class) instanceof ManagedBean<?>;
+      assert beans.get(SeaBass.class) instanceof ManagedBean<?>;
+      assert beans.get(Sole.class) instanceof ManagedBean<?>;
+      Utils.getReference(manager, Sole.class, new AnnotationLiteral<Whitefish>() {}).ping();
    }
    
    @Test
@@ -69,7 +70,7 @@
       Map<Class<?>, Bean<?>> beans = new HashMap<Class<?>, Bean<?>>();
       for (Bean<?> bean : manager.getBeans())
       {
-         if (bean instanceof RIBean)
+         if (bean instanceof RIBean<?>)
          {
             beans.put(((RIBean<?>) bean).getType(), bean);
          }
@@ -77,10 +78,10 @@
       assert beans.containsKey(TarantulaProducer.class);
       assert beans.containsKey(Tarantula.class);
       
-      Bean<?> bean = beans.get(TarantulaProducer.class);
+      beans.get(TarantulaProducer.class);
       
-      assert beans.get(TarantulaProducer.class) instanceof ManagedBean;
-      manager.getInstanceByType(Tarantula.class, new AnnotationLiteral<Tame>() {}).ping();
+      assert beans.get(TarantulaProducer.class) instanceof ManagedBean<?>;
+      Utils.getReference(manager, Tarantula.class, new AnnotationLiteral<Tame>() {}).ping();
    }
    
    public void testSingleEnterpriseBean()
@@ -89,14 +90,14 @@
       Map<Class<?>, Bean<?>> classes = new HashMap<Class<?>, Bean<?>>();
       for (Bean<?> bean : beans)
       {
-         if (bean instanceof RIBean)
+         if (bean instanceof RIBean<?>)
          {
             classes.put(((RIBean<?>) bean).getType(), bean);
          }
       }
       assert classes.containsKey(Hound.class);
-      assert classes.get(Hound.class) instanceof ManagedBean;
-      manager.getInstanceByType(HoundLocal.class, new AnnotationLiteral<Tame>() {}).ping();
+      assert classes.get(Hound.class) instanceof ManagedBean<?>;
+      Utils.getReference(manager, HoundLocal.class, new AnnotationLiteral<Tame>() {}).ping();
    }
    
 }



More information about the weld-commits mailing list