openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1056145 [1/2] - in /openwebbeans/trunk: samples/standalone-sample/src/main/java/org/apache/webbeans/se/sample/ webbeans-ee-common/src/main/java/org/apache/webbeans/ee/common/beans/ webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/ we...
Date Fri, 07 Jan 2011 00:54:07 GMT
Author: djencks
Date: Fri Jan  7 00:54:06 2011
New Revision: 1056145

URL: http://svn.apache.org/viewvc?rev=1056145&view=rev
Log:
OWB-503 remove ServiceLoader and LifecycleFactory and use WebBeansContext methods instead. Add WebBeansContext fields in several classes where they can reduce map lookups

Removed:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/ServiceLoader.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/LifecycleFactory.java
Modified:
    openwebbeans/trunk/samples/standalone-sample/src/main/java/org/apache/webbeans/se/sample/Boot.java
    openwebbeans/trunk/webbeans-ee-common/src/main/java/org/apache/webbeans/ee/common/beans/PrinicipalBean.java
    openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/UserTransactionBean.java
    openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/ValidatorBean.java
    openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/ValidatorFactoryBean.java
    openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/event/TransactionalEventNotifier.java
    openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/boot/Bootstrap.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ConversationBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/test/OpenWebBeansTestLifeCycle.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/AbstractUnitTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/SerializationTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/tests/SessionContextTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/threadsafety/ThreadSafeBeanInitialisationTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/ExtensionTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/config/WebBeansScannerTest.java
    openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/java/org/apache/webbeans/resource/spi/ee/ExtendedStandaloneResourceInjectionService.java
    openwebbeans/trunk/webbeans-jms/src/main/java/org/apache/webbeans/jms/util/JmsUtil.java
    openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/OwbApplication.java
    openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/resource/OpenEjbResourceInjectionService.java
    openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/StandaloneContainersImpl.java
    openwebbeans/trunk/webbeans-resource/src/main/java/org/apache/webbeans/resource/spi/se/StandaloneResourceInjectionService.java
    openwebbeans/trunk/webbeans-test/cditest-owb/src/main/java/org/apache/webbeans/cditest/owb/CdiTestOpenWebBeansContainer.java
    openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java
    openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/WebContextsService.java
    openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/failover/FailOverBagWrapper.java
    openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/lifecycle/WebContainerLifecycle.java

Modified: openwebbeans/trunk/samples/standalone-sample/src/main/java/org/apache/webbeans/se/sample/Boot.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/standalone-sample/src/main/java/org/apache/webbeans/se/sample/Boot.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/samples/standalone-sample/src/main/java/org/apache/webbeans/se/sample/Boot.java (original)
+++ openwebbeans/trunk/samples/standalone-sample/src/main/java/org/apache/webbeans/se/sample/Boot.java Fri Jan  7 00:54:06 2011
@@ -26,7 +26,7 @@ import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.swing.JFrame;
 
-import org.apache.webbeans.lifecycle.LifecycleFactory;
+import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.se.sample.gui.LoginWindow;
 import org.apache.webbeans.spi.ContainerLifecycle;
 
@@ -40,7 +40,7 @@ public class Boot
     {
         try
         {
-            lifecycle = LifecycleFactory.getInstance().getLifecycle();
+            lifecycle = WebBeansContext.getInstance().getService(ContainerLifecycle.class);
             lifecycle.startApplication(startupObject);
             
         }

Modified: openwebbeans/trunk/webbeans-ee-common/src/main/java/org/apache/webbeans/ee/common/beans/PrinicipalBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ee-common/src/main/java/org/apache/webbeans/ee/common/beans/PrinicipalBean.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ee-common/src/main/java/org/apache/webbeans/ee/common/beans/PrinicipalBean.java (original)
+++ openwebbeans/trunk/webbeans-ee-common/src/main/java/org/apache/webbeans/ee/common/beans/PrinicipalBean.java Fri Jan  7 00:54:06 2011
@@ -26,7 +26,6 @@ import org.apache.webbeans.annotation.De
 import org.apache.webbeans.annotation.DependentScopeLiteral;
 import org.apache.webbeans.component.AbstractOwbBean;
 import org.apache.webbeans.component.WebBeansType;
-import org.apache.webbeans.corespi.ServiceLoader;
 import org.apache.webbeans.spi.SecurityService;
 
 public class PrinicipalBean extends AbstractOwbBean<Principal>
@@ -44,7 +43,7 @@ public class PrinicipalBean extends Abst
     @Override
     protected Principal createInstance(CreationalContext<Principal> creationalContext)
     {
-        SecurityService securityService = ServiceLoader.getService(SecurityService.class);
+        SecurityService securityService = getWebBeansContext().getService(SecurityService.class);
         if(securityService != null)
         {
             return securityService.getCurrentPrincipal();

Modified: openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/UserTransactionBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/UserTransactionBean.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/UserTransactionBean.java (original)
+++ openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/UserTransactionBean.java Fri Jan  7 00:54:06 2011
@@ -25,7 +25,6 @@ import org.apache.webbeans.annotation.De
 import org.apache.webbeans.annotation.DependentScopeLiteral;
 import org.apache.webbeans.component.AbstractOwbBean;
 import org.apache.webbeans.component.WebBeansType;
-import org.apache.webbeans.corespi.ServiceLoader;
 import org.apache.webbeans.spi.TransactionService;
 
 public class UserTransactionBean extends AbstractOwbBean<UserTransaction>
@@ -43,7 +42,7 @@ public class UserTransactionBean extends
     @Override
     protected UserTransaction createInstance(CreationalContext<UserTransaction> creationalContext)
     {
-        TransactionService transactionService = ServiceLoader.getService(TransactionService.class);
+        TransactionService transactionService = getWebBeansContext().getService(TransactionService.class);
         if(transactionService != null)
         {
             return transactionService.getUserTransaction();

Modified: openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/ValidatorBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/ValidatorBean.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/ValidatorBean.java (original)
+++ openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/ValidatorBean.java Fri Jan  7 00:54:06 2011
@@ -25,7 +25,6 @@ import org.apache.webbeans.annotation.De
 import org.apache.webbeans.annotation.DependentScopeLiteral;
 import org.apache.webbeans.component.AbstractOwbBean;
 import org.apache.webbeans.component.WebBeansType;
-import org.apache.webbeans.corespi.ServiceLoader;
 import org.apache.webbeans.spi.ValidatorService;
 
 public class ValidatorBean extends AbstractOwbBean<Validator>
@@ -43,7 +42,7 @@ public class ValidatorBean extends Abstr
     @Override
     protected Validator createInstance(CreationalContext<Validator> creationalContext)
     {
-        ValidatorService validatorService = ServiceLoader.getService(ValidatorService.class);
+        ValidatorService validatorService = getWebBeansContext().getService(ValidatorService.class);
         if(validatorService != null)
         {
             return validatorService.getDefaultValidator();

Modified: openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/ValidatorFactoryBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/ValidatorFactoryBean.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/ValidatorFactoryBean.java (original)
+++ openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/ValidatorFactoryBean.java Fri Jan  7 00:54:06 2011
@@ -25,7 +25,6 @@ import org.apache.webbeans.annotation.De
 import org.apache.webbeans.annotation.DependentScopeLiteral;
 import org.apache.webbeans.component.AbstractOwbBean;
 import org.apache.webbeans.component.WebBeansType;
-import org.apache.webbeans.corespi.ServiceLoader;
 import org.apache.webbeans.spi.ValidatorService;
 
 public class ValidatorFactoryBean extends AbstractOwbBean<ValidatorFactory>
@@ -43,7 +42,7 @@ public class ValidatorFactoryBean extend
     @Override
     protected ValidatorFactory createInstance(CreationalContext<ValidatorFactory> creationalContext)
     {
-        ValidatorService validatorService = ServiceLoader.getService(ValidatorService.class);
+        ValidatorService validatorService = getWebBeansContext().getService(ValidatorService.class);
         if(validatorService != null)
         {
             return validatorService.getDefaultValidatorFactory();

Modified: openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/event/TransactionalEventNotifier.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/event/TransactionalEventNotifier.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/event/TransactionalEventNotifier.java (original)
+++ openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/event/TransactionalEventNotifier.java Fri Jan  7 00:54:06 2011
@@ -25,7 +25,7 @@ import javax.transaction.Synchronization
 import javax.transaction.Transaction;
 
 import org.apache.webbeans.config.OWBLogConst;
-import org.apache.webbeans.corespi.ServiceLoader;
+import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.logger.WebBeansLogger;
 import org.apache.webbeans.spi.TransactionService;
 
@@ -41,7 +41,7 @@ public class TransactionalEventNotifier
     
     public static void registerTransactionSynchronization(TransactionPhase phase, ObserverMethod<? super Object> observer, Object event) throws Exception
     {
-        TransactionService transactionService = ServiceLoader.getService(TransactionService.class);
+        TransactionService transactionService = WebBeansContext.getInstance().getService(TransactionService.class);
         
         Transaction transaction = null;
         if(transactionService != null)

Modified: openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java (original)
+++ openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java Fri Jan  7 00:54:06 2011
@@ -50,10 +50,8 @@ import javax.interceptor.InvocationConte
 
 import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.context.ContextFactory;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
-import org.apache.webbeans.corespi.ServiceLoader;
 import org.apache.webbeans.decorator.DelegateHandler;
 import org.apache.webbeans.decorator.WebBeansDecoratorConfig;
 import org.apache.webbeans.decorator.WebBeansDecoratorInterceptor;
@@ -109,8 +107,8 @@ public class OpenWebBeansEjbInterceptor 
     /** Cached reference to the managed bean representing the EJB impl class this interceptor is associated with */
     private transient BaseEjbBean<?> contextual; 
     
-    /** cache of associated BeanManagerImpl */
-    private transient BeanManagerImpl manager;
+    /** cache of associated WebBeansContext */
+    private transient WebBeansContext webBeansContext;
     
     /* EJB InvocationContext.getTarget() provides underlying bean instance, which we do not want to hold a reference to */
     private CreationalKey ccKey;
@@ -257,9 +255,9 @@ public class OpenWebBeansEjbInterceptor 
             logger.debug("entry");
         }
 
-        if (this.manager == null) 
+        if (this.webBeansContext == null)
         {
-            this.manager = WebBeansContext.getInstance().getBeanManagerImpl();
+            this.webBeansContext = WebBeansContext.getInstance();
         }
 
         BaseEjbBean<?> injectionTarget = threadLocal.get();
@@ -291,12 +289,12 @@ public class OpenWebBeansEjbInterceptor 
         }
 
         // Even for contextuals, we want to manage it along with THIS intereptor instance (e.g. SLSB)
-        this.cc = manager.createCreationalContext(this.contextual);
+        this.cc = webBeansContext.getBeanManagerImpl().createCreationalContext(this.contextual);
         
         if (logger.wblWillLogDebug())
         {
             logger.debug("manager = {0} interceptor_instance = {1} contextual = {2} ", 
-                    new Object[] { this.manager, this, this.contextual});
+                    new Object[] { this.webBeansContext.getBeanManagerImpl(), this, this.contextual});
         }
         
         lifecycleCommon(context, InterceptorType.POST_CONSTRUCT);
@@ -352,7 +350,7 @@ public class OpenWebBeansEjbInterceptor 
      */
     private int activateContexts(Class<? extends Annotation> scopeType)
     {
-        ContextsService service = ServiceLoader.getService(ContextsService.class);
+        ContextsService service = webBeansContext.getService(ContextsService.class);
         Context ctx = service.getCurrentContext(scopeType);
         
         if(scopeType == RequestScoped.class)
@@ -433,7 +431,7 @@ public class OpenWebBeansEjbInterceptor 
         //Not found
         if(ejbBean == null)
         {
-            Set<Bean<?>> beans = manager.getComponents();
+            Set<Bean<?>> beans = webBeansContext.getBeanManagerImpl().getComponents();
             for(Bean<?> bean : beans)
             {
                 if(bean instanceof BaseEjbBean)
@@ -615,7 +613,7 @@ public class OpenWebBeansEjbInterceptor 
         if (logger.wblWillLogDebug())
         {
             logger.debug("manager = {0} interceptor_instance = {1} contextual = {2} ", 
-                    new Object[] { this.manager, this, this.contextual});
+                    new Object[] { this.webBeansContext.getBeanManagerImpl(), this, this.contextual});
         }
         lifecycleCommon(context, InterceptorType.PRE_PASSIVATE);
     }
@@ -632,7 +630,7 @@ public class OpenWebBeansEjbInterceptor 
         if (logger.wblWillLogDebug())
         {
             logger.debug("manager = {0} interceptor_instance = {1} contextual = {2} ", 
-                    new Object[] { this.manager, this, this.contextual});
+                    new Object[] { this.webBeansContext.getBeanManagerImpl(), this, this.contextual});
         }
 
         lifecycleCommon(context, InterceptorType.POST_ACTIVATE);
@@ -653,7 +651,7 @@ public class OpenWebBeansEjbInterceptor 
         if (logger.wblWillLogDebug())
         {
             logger.debug("manager = {0} interceptor_instance = {1} contextual = {2} ", 
-                          new Object[] { this.manager, this, this.contextual});
+                          new Object[] { this.webBeansContext.getBeanManagerImpl(), this, this.contextual});
         }
         
         /* notably our stashed CreationalContext */
@@ -677,12 +675,12 @@ public class OpenWebBeansEjbInterceptor 
         s.defaultReadObject();
 
         /* restore transient BeanManager */
-        this.manager = WebBeansContext.getInstance().getBeanManagerImpl();
+        this.webBeansContext = WebBeansContext.getInstance();
 
         if (logger.wblWillLogDebug())
         {
             logger.debug("manager = {0} interceptor_instance = {1} contextual = {2} ", 
-                          new Object[] { this.manager, this, this.contextual});
+                          new Object[] { this.webBeansContext.getBeanManagerImpl(), this, this.contextual});
         }
         
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/boot/Bootstrap.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/boot/Bootstrap.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/boot/Bootstrap.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/boot/Bootstrap.java Fri Jan  7 00:54:06 2011
@@ -22,7 +22,7 @@ import java.util.Properties;
 import java.util.concurrent.CountDownLatch;
 
 import org.apache.webbeans.config.OWBLogConst;
-import org.apache.webbeans.lifecycle.LifecycleFactory;
+import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.logger.WebBeansLogger;
 import org.apache.webbeans.spi.ContainerLifecycle;
 
@@ -30,7 +30,7 @@ public class Bootstrap
 {
     private static final WebBeansLogger log = WebBeansLogger.getLogger(Bootstrap.class);
     
-    private CountDownLatch latch = new CountDownLatch(1);
+    private final CountDownLatch latch = new CountDownLatch(1);
     
     private ContainerLifecycle containerLifecycle = null;
     
@@ -39,7 +39,7 @@ public class Bootstrap
     public void init(Properties properties)
     {
         log.info(OWBLogConst.INFO_0006);
-        this.containerLifecycle = LifecycleFactory.getInstance().getLifecycle();
+        this.containerLifecycle = WebBeansContext.getInstance().getService(ContainerLifecycle.class);
     }
     
     public void start() throws Exception

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java Fri Jan  7 00:54:06 2011
@@ -34,13 +34,11 @@ import javax.enterprise.inject.spi.Annot
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.Decorator;
 import javax.enterprise.inject.spi.InjectionPoint;
-
 import org.apache.webbeans.annotation.DefaultLiteral;
 import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.config.inheritance.BeanInheritedMetaData;
 import org.apache.webbeans.config.inheritance.IBeanInheritedMetaData;
-import org.apache.webbeans.corespi.ServiceLoader;
 import org.apache.webbeans.decorator.WebBeansDecorator;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.exception.WebBeansException;
@@ -402,7 +400,7 @@ public abstract class AbstractInjectionT
                 ResourceInjectionService service = null;
                 try
                 {
-                    service = ServiceLoader.getService(ResourceInjectionService.class);
+                    service = getWebBeansContext().getService(ResourceInjectionService.class);
                     
                 }
                 catch(Exception e)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java Fri Jan  7 00:54:06 2011
@@ -32,7 +32,6 @@ import javax.enterprise.context.spi.Crea
 import javax.enterprise.inject.CreationException;
 import javax.enterprise.inject.Disposes;
 import javax.enterprise.inject.spi.InjectionPoint;
-
 import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.container.BeanManagerImpl;
@@ -103,11 +102,9 @@ public abstract class AbstractOwbBean<T>
      */
     protected String passivatingId = null;
     
-    /**Bean Manager*/
-    private final BeanManagerImpl manager;
+    private final WebBeansContext webBeansContext;
+
 
-    
-            
     /**
      * Constructor definiton. Each subclass redefines its own constructor with
      * calling this.
@@ -119,7 +116,7 @@ public abstract class AbstractOwbBean<T>
     {
         this.webBeansType = webBeansType;
         this.returnType = returnType;
-        this.manager = WebBeansContext.getInstance().getBeanManagerImpl();
+        webBeansContext = WebBeansContext.getInstance();
     }
     
     /**
@@ -131,6 +128,16 @@ public abstract class AbstractOwbBean<T>
     {
         this(webBeanType, null);
     }
+
+    /**
+     * Get the web beans context this bean is associated with
+     *
+     * @return WebBeansContext this bean is associated with
+     */
+    public WebBeansContext getWebBeansContext()
+    {
+        return webBeansContext;
+    }
     
     /**
      * Gets manager instance
@@ -139,7 +146,7 @@ public abstract class AbstractOwbBean<T>
      */
     protected BeanManagerImpl getManager()
     {
-        return manager;
+        return webBeansContext.getBeanManagerImpl();
     }
     
     

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ConversationBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ConversationBean.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ConversationBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ConversationBean.java Fri Jan  7 00:54:06 2011
@@ -20,10 +20,7 @@ package org.apache.webbeans.component;
 
 import javax.enterprise.context.Conversation;
 import javax.enterprise.context.spi.CreationalContext;
-
-import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.conversation.ConversationImpl;
-import org.apache.webbeans.corespi.ServiceLoader;
 import org.apache.webbeans.spi.ConversationService;
 
 /**
@@ -49,7 +46,7 @@ public class ConversationBean extends Ab
     {
         Conversation conversation = null;
         //Gets conversation service
-        ConversationService conversationService = ServiceLoader.getService(ConversationService.class);        
+        ConversationService conversationService = getWebBeansContext().getService(ConversationService.class);
         //Gets conversation id
         String conversationId = conversationService.getConversationId();       
         //Gets session id that conversation is created
@@ -60,7 +57,7 @@ public class ConversationBean extends Ab
         if (conversationId != null)
         {
             //Gets propogated conversation
-            conversation = WebBeansContext.getInstance().getConversationManager().getPropogatedConversation(conversationId,sessionId);
+            conversation = getWebBeansContext().getConversationManager().getPropogatedConversation(conversationId,sessionId);
         }
         
         if (conversation == null)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java Fri Jan  7 00:54:06 2011
@@ -22,10 +22,7 @@ import java.lang.annotation.Annotation;
 import java.lang.reflect.Modifier;
 
 import javax.enterprise.context.spi.CreationalContext;
-
 import javassist.util.proxy.ProxyObject;
-import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.corespi.ServiceLoader;
 import org.apache.webbeans.exception.WebBeansException;
 import org.apache.webbeans.proxy.ResourceProxyHandler;
 import org.apache.webbeans.spi.ResourceInjectionService;
@@ -50,7 +47,7 @@ public class ResourceBean<X, T extends A
     {
         try
         {
-            ResourceInjectionService resourceService = ServiceLoader.getService(ResourceInjectionService.class);
+            ResourceInjectionService resourceService = getWebBeansContext().getService(ResourceInjectionService.class);
             X instance = resourceService.getResourceReference(this.resourceReference);
 
             if (instance == null || Modifier.isFinal(instance.getClass().getModifiers()))
@@ -58,7 +55,7 @@ public class ResourceBean<X, T extends A
                 return instance;
             }
 
-            X proxyInstance = (X) WebBeansContext.getInstance().getJavassistProxyFactory().getResourceBeanProxyClass(this).newInstance();
+            X proxyInstance = (X) getWebBeansContext().getJavassistProxyFactory().getResourceBeanProxyClass(this).newInstance();
             ((ProxyObject) proxyInstance).setHandler(new ResourceProxyHandler(this,instance));
             return proxyInstance;
         }
@@ -77,7 +74,7 @@ public class ResourceBean<X, T extends A
      */
     public X getActualInstance() 
     {
-        ResourceInjectionService resourceService = ServiceLoader.getService(ResourceInjectionService.class);
+        ResourceInjectionService resourceService = getWebBeansContext().getService(ResourceInjectionService.class);
         X instance = resourceService.getResourceReference(this.resourceReference);
         return instance;
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java Fri Jan  7 00:54:06 2011
@@ -38,7 +38,6 @@ import javax.enterprise.inject.spi.Decor
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.ProcessAnnotatedType;
 import javax.interceptor.Interceptor;
-
 import org.apache.webbeans.annotation.AnnotationManager;
 import org.apache.webbeans.component.AbstractInjectionTargetBean;
 import org.apache.webbeans.component.AbstractProducerBean;
@@ -50,12 +49,11 @@ import org.apache.webbeans.component.Man
 import org.apache.webbeans.component.NewBean;
 import org.apache.webbeans.component.OwbBean;
 import org.apache.webbeans.component.WebBeansType;
-import org.apache.webbeans.component.creation.ManagedBeanCreatorImpl;
 import org.apache.webbeans.component.creation.BeanCreator.MetaDataProvider;
+import org.apache.webbeans.component.creation.ManagedBeanCreatorImpl;
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.container.InjectableBeanManager;
 import org.apache.webbeans.container.InjectionResolver;
-import org.apache.webbeans.corespi.ServiceLoader;
 import org.apache.webbeans.corespi.se.DefaultJndiService;
 import org.apache.webbeans.decorator.WebBeansDecorator;
 import org.apache.webbeans.deployment.StereoTypeModel;
@@ -76,10 +74,10 @@ import org.apache.webbeans.spi.plugins.O
 import org.apache.webbeans.spi.plugins.OpenWebBeansWebPlugin;
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.ClassUtil;
+import org.apache.webbeans.util.InjectionExceptionUtils;
 import org.apache.webbeans.util.WebBeansAnnotatedTypeUtil;
 import org.apache.webbeans.util.WebBeansConstants;
 import org.apache.webbeans.util.WebBeansUtil;
-import org.apache.webbeans.util.InjectionExceptionUtils;
 import org.apache.webbeans.xml.WebBeansXMLConfigurator;
 
 /**
@@ -135,7 +133,7 @@ public class BeansDeployer
                 webBeansContext.getExtensionLoader().loadExtensionServices();
 
                 // Bind manager
-                JNDIService service = ServiceLoader.getService(JNDIService.class);
+                JNDIService service = webBeansContext.getService(JNDIService.class);
                 
                 //Default jndi is just a map
                 if(service instanceof DefaultJndiService)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java Fri Jan  7 00:54:06 2011
@@ -29,9 +29,9 @@ import org.apache.webbeans.container.Bea
 import org.apache.webbeans.container.SerializableBeanVault;
 import org.apache.webbeans.context.creational.CreationalContextFactory;
 import org.apache.webbeans.conversation.ConversationManager;
-import org.apache.webbeans.corespi.se.DefaultContextsService;
-import org.apache.webbeans.corespi.se.DefaultJndiService;
-import org.apache.webbeans.corespi.se.DefaultScannerService;
+//import org.apache.webbeans.corespi.se.DefaultContextsService;
+//import org.apache.webbeans.corespi.se.DefaultJndiService;
+//import org.apache.webbeans.corespi.se.DefaultScannerService;
 import org.apache.webbeans.decorator.DecoratorsManager;
 import org.apache.webbeans.deployment.StereoTypeManager;
 import org.apache.webbeans.exception.WebBeansException;
@@ -42,6 +42,8 @@ import org.apache.webbeans.plugins.Plugi
 import org.apache.webbeans.portable.AnnotatedElementFactory;
 import org.apache.webbeans.portable.events.ExtensionLoader;
 import org.apache.webbeans.proxy.JavassistProxyFactory;
+import org.apache.webbeans.spi.ContextsService;
+import org.apache.webbeans.spi.ScannerService;
 import org.apache.webbeans.spi.plugins.OpenWebBeansPlugin;
 import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.xml.WebBeansNameSpaceContainer;
@@ -57,12 +59,9 @@ public class WebBeansContext
     private AlternativesManager alternativesManager = new AlternativesManager(this);
     private AnnotatedElementFactory annotatedElementFactory = new AnnotatedElementFactory();
     private BeanManagerImpl beanManagerImpl = new BeanManagerImpl(this);
-    private ConversationManager conversationManager = new ConversationManager();
+    private ConversationManager conversationManager = new ConversationManager(this);
     private CreationalContextFactory creationalContextFactory = new CreationalContextFactory();
     private DecoratorsManager decoratorsManager = new DecoratorsManager(this);
-    private DefaultContextsService defaultContextsService = new DefaultContextsService();
-    private DefaultJndiService defaultJndiService = new DefaultJndiService();
-    private DefaultScannerService defaultScannerService = new DefaultScannerService();
     private ExtensionLoader extensionLoader = new ExtensionLoader(this);
     private InterceptorsManager interceptorsManager = new InterceptorsManager(this);
     private JMSManager jmsManager = new JMSManager();
@@ -92,9 +91,6 @@ public class WebBeansContext
         managerMap.put(ConversationManager.class.getName(), conversationManager);
         managerMap.put(CreationalContextFactory.class.getName(), creationalContextFactory);
         managerMap.put(DecoratorsManager.class.getName(), decoratorsManager);
-        managerMap.put(DefaultContextsService.class.getName(), defaultContextsService);
-        managerMap.put(DefaultJndiService.class.getName(), defaultJndiService);
-        managerMap.put(DefaultScannerService.class.getName(), defaultScannerService);
         managerMap.put(ExtensionLoader.class.getName(), extensionLoader);
         managerMap.put(InterceptorsManager.class.getName(), interceptorsManager);
         managerMap.put(JMSManager.class.getName(), jmsManager);
@@ -118,7 +114,7 @@ public class WebBeansContext
 
     public <T> T getService(Class<T> clazz)
     {
-        T t = (T) serviceMap.get(clazz);
+        T t = clazz.cast(serviceMap.get(clazz));
         if (t == null)
         {
             t = doServiceLoader(clazz);
@@ -157,7 +153,7 @@ public class WebBeansContext
 //            }
             return null;
         }
-        return (T) WebBeansFinder.getSingletonInstance(implName);
+        return serviceInterface.cast(WebBeansFinder.getSingletonInstance(implName));
     }
 
     public AnnotationManager getAnnotationManager()
@@ -195,21 +191,6 @@ public class WebBeansContext
         return creationalContextFactory;
     }
 
-    public DefaultContextsService getDefaultContextsService()
-    {
-        return defaultContextsService;
-    }
-
-    public DefaultJndiService getDefaultJndiService()
-    {
-        return defaultJndiService;
-    }
-
-    public DefaultScannerService getDefaultScannerService()
-    {
-        return defaultScannerService;
-    }
-
     public DecoratorsManager getDecoratorsManager()
     {
         return decoratorsManager;
@@ -265,6 +246,17 @@ public class WebBeansContext
         return xmlSpecializesManager;
     }
 
+    //candidates for fields
+    public ScannerService getScannerService()
+    {
+        return getService(ScannerService.class);
+    }
+
+    public ContextsService getContextsService()
+    {
+        return getService(ContextsService.class);
+    }
+
     public Object get(String singletonName)
     {
         //util.Track.get(singletonName);

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java Fri Jan  7 00:54:06 2011
@@ -44,7 +44,15 @@ import javax.enterprise.context.spi.Cont
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.Default;
 import javax.enterprise.inject.Stereotype;
-import javax.enterprise.inject.spi.*;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.Decorator;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.InjectionTarget;
+import javax.enterprise.inject.spi.InterceptionType;
+import javax.enterprise.inject.spi.Interceptor;
+import javax.enterprise.inject.spi.ObserverMethod;
 import javax.enterprise.util.TypeLiteral;
 import javax.inject.Scope;
 import javax.interceptor.InterceptorBinding;
@@ -52,7 +60,6 @@ import javax.naming.NamingException;
 import javax.naming.Reference;
 import javax.naming.Referenceable;
 import javax.naming.StringRefAddr;
-
 import org.apache.webbeans.component.AbstractOwbBean;
 import org.apache.webbeans.component.EnterpriseBeanMarker;
 import org.apache.webbeans.component.InjectionTargetBean;
@@ -65,7 +72,6 @@ import org.apache.webbeans.component.thi
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.context.ContextFactory;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
-import org.apache.webbeans.corespi.ServiceLoader;
 import org.apache.webbeans.decorator.DecoratorComparator;
 import org.apache.webbeans.decorator.WebBeansDecorator;
 import org.apache.webbeans.decorator.WebBeansDecoratorConfig;
@@ -89,7 +95,9 @@ import org.apache.webbeans.util.ClassUti
 import org.apache.webbeans.util.WebBeansAnnotatedTypeUtil;
 import org.apache.webbeans.util.WebBeansUtil;
 import org.apache.webbeans.xml.WebBeansXMLConfigurator;
-import static org.apache.webbeans.util.InjectionExceptionUtils.*;
+
+import static org.apache.webbeans.util.InjectionExceptionUtils.throwAmbiguousResolutionException;
+import static org.apache.webbeans.util.InjectionExceptionUtils.throwAmbiguousResolutionExceptionForBeanName;
 
 /**
  * Implementation of the {@link BeanManager} contract of the web beans
@@ -138,14 +146,14 @@ public class BeanManagerImpl implements 
     private List<Class<?>> additionalInterceptorClasses = new CopyOnWriteArrayList<Class<?>>();
     
     /**
-     * This list contains additional qualifiers which got set via the {@link BeforeBeanDiscovery#addQualifier(Class)} 
+     * This list contains additional qualifiers which got set via the {@link javax.enterprise.inject.spi.BeforeBeanDiscovery#addQualifier(Class)}
      * event function.
      */
     private List<Class<? extends Annotation>> additionalQualifiers = Collections.synchronizedList(new ArrayList<Class<? extends Annotation>>());
     
     /**
      * This list contains additional scopes which got set via the 
-     * {@link BeforeBeanDiscovery#addScope(Class, boolean, boolean)} event function.
+     * {@link javax.enterprise.inject.spi.BeforeBeanDiscovery#addScope(Class, boolean, boolean)} event function.
      */
     private List<ExternalScope> additionalScopes =  Collections.synchronizedList(new ArrayList<ExternalScope>());
     
@@ -154,7 +162,7 @@ public class BeanManagerImpl implements 
     private List<AnnotatedType<?>> additionalAnnotatedTypes = new CopyOnWriteArrayList<AnnotatedType<?>>();
 
     /**
-     * This map stores all beans along with their unique {@link PassivationCapable} id.
+     * This map stores all beans along with their unique {@link javax.enterprise.inject.spi.PassivationCapable} id.
      * This is used as a reference for serialization.
      */
     private ConcurrentHashMap<String, Bean<?>> passivationBeans = new ConcurrentHashMap<String, Bean<?>>(); 
@@ -168,19 +176,8 @@ public class BeanManagerImpl implements 
 
     private AnnotatedElementFactory annotatedElementFactory;
 
-    /**
-     * Scanner Service ref
-     */
-    private ScannerService scannerService;
     private final WebBeansContext webBeansContext;
 
-    //private WebBeansLogger logger = WebBeansLogger.getLogger(BeanManagerImpl.class);
-
-    public synchronized void setScannerService(ScannerService scannerService)
-    {
-        this.scannerService = scannerService;
-    }
-
     /**
      * Creates a new {@link BeanManager} instance.
      * Called by the system. Do not use outside of the
@@ -189,8 +186,8 @@ public class BeanManagerImpl implements 
     public BeanManagerImpl(WebBeansContext webBeansContext)
     {
         this.webBeansContext = webBeansContext;
-        injectionResolver = new InjectionResolver(this);
-        notificationManager = new NotificationManager();
+        injectionResolver = new InjectionResolver(webBeansContext);
+        notificationManager = new NotificationManager(webBeansContext);
         annotatedElementFactory = webBeansContext.getAnnotatedElementFactory();
     }
 
@@ -712,7 +709,7 @@ public class BeanManagerImpl implements 
     @Override
     public ELResolver getELResolver()
     {
-        ELAdaptor elAdaptor = ServiceLoader.getService(ELAdaptor.class);
+        ELAdaptor elAdaptor = webBeansContext.getService(ELAdaptor.class);
         return elAdaptor.getOwbELResolver();
     }
 
@@ -736,7 +733,8 @@ public class BeanManagerImpl implements 
         //Find the injection point Bean
         Bean<Object> injectedBean = (Bean<Object>)injectionResolver.getInjectionPointBean(injectionPoint);
         
-        boolean isSetIPForProducers=false;        
+        boolean isSetIPForProducers=false;
+        ScannerService scannerService = webBeansContext.getScannerService();
         if ((scannerService != null && scannerService.isBDABeansXmlScanningEnabled()))
         {
             if (injectedBean instanceof AbstractOwbBean<?>)
@@ -1110,7 +1108,7 @@ public class BeanManagerImpl implements 
     @Override
     public ExpressionFactory wrapExpressionFactory(ExpressionFactory expressionFactory)
     {
-        ELAdaptor elAdaptor = ServiceLoader.getService(ELAdaptor.class);
+        ELAdaptor elAdaptor = webBeansContext.getService(ELAdaptor.class);
         return elAdaptor.getOwbWrappedExpressionFactory(expressionFactory);
     }
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java Fri Jan  7 00:54:06 2011
@@ -18,11 +18,25 @@
  */
 package org.apache.webbeans.container;
 
+import java.lang.annotation.Annotation;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Instance;
+import javax.enterprise.inject.New;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionPoint;
 import org.apache.webbeans.annotation.AnyLiteral;
 import org.apache.webbeans.annotation.DefaultLiteral;
 import org.apache.webbeans.component.AbstractOwbBean;
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.corespi.ServiceLoader;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.exception.inject.NullableDependencyException;
 import org.apache.webbeans.logger.WebBeansLogger;
@@ -33,21 +47,6 @@ import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.WebBeansUtil;
 
-import javax.enterprise.event.Event;
-import javax.enterprise.inject.Instance;
-import javax.enterprise.inject.New;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.InjectionPoint;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
 /**
  * Injection point resolver class. 
  * 
@@ -65,7 +64,7 @@ public class InjectionResolver
     private final WebBeansLogger logger = WebBeansLogger.getLogger(InjectionResolver.class);
 
     /**Bean Manager*/
-    private BeanManagerImpl manager;
+    private WebBeansContext webBeansContext;
     
     /**
      * This Map contains all resolved beans via it's type and qualifiers.
@@ -83,11 +82,11 @@ public class InjectionResolver
     /**
      * Creates a new injection resolve for given bean manager.
      * 
-     * @param manager bean manager
+     * @param webBeansContext WebBeansContext
      */
-    public InjectionResolver(BeanManagerImpl manager)
+    public InjectionResolver(WebBeansContext webBeansContext)
     {
-        this.manager = manager;
+        this.webBeansContext = webBeansContext;
 
     }
     
@@ -299,7 +298,7 @@ public class InjectionResolver
         }
 
         resolvedComponents = new HashSet<Bean<?>>();        
-        Set<Bean<?>> deployedComponents = this.manager.getBeans();
+        Set<Bean<?>> deployedComponents = this.webBeansContext.getBeanManagerImpl().getBeans();
         
         Iterator<Bean<?>> it = deployedComponents.iterator();
         //Finding all beans with given name
@@ -408,7 +407,7 @@ public class InjectionResolver
             return null;
         }
 
-        ScannerService scannerService = ServiceLoader.getService(ScannerService.class);
+        ScannerService scannerService = webBeansContext.getScannerService();
         BDABeansXmlScanner beansXMLScanner = scannerService.getBDABeansXmlScanner();
         return beansXMLScanner.getBeansXml(injectionPointBeanClass);
     }
@@ -422,7 +421,7 @@ public class InjectionResolver
      */
     public Set<Bean<?>> implResolveByType(Type injectionPointType, Class<?> injectinPointClass, Annotation... qualifiers)
     {
-        ScannerService scannerService = ServiceLoader.getService(ScannerService.class);
+        ScannerService scannerService = webBeansContext.getScannerService();
         String bdaBeansXMLFilePath =null;
         if (scannerService.isBDABeansXmlScanningEnabled())
         {
@@ -450,7 +449,7 @@ public class InjectionResolver
         
         resolvedComponents = new HashSet<Bean<?>>();
         
-        Set<Bean<?>> deployedComponents = this.manager.getBeans();
+        Set<Bean<?>> deployedComponents = this.webBeansContext.getBeanManagerImpl().getBeans();
 
         boolean currentQualifier = false;
         boolean returnAll = false;
@@ -650,7 +649,7 @@ public class InjectionResolver
     private boolean isAltBeanInInjectionPointBDA(String bdaBeansXMLFilePath, Bean<?> altBean)
     {
 
-        ScannerService scannerService = ServiceLoader.getService(ScannerService.class);
+        ScannerService scannerService = webBeansContext.getScannerService();
         BDABeansXmlScanner beansXMLScanner = scannerService.getBDABeansXmlScanner();
 
         Set<Class<?>> definedAlternatives = beansXMLScanner.getAlternatives(bdaBeansXMLFilePath);

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java Fri Jan  7 00:54:06 2011
@@ -20,12 +20,15 @@ package org.apache.webbeans.context;
 
 import java.lang.annotation.Annotation;
 
-import javax.enterprise.context.*;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.ContextNotActiveException;
+import javax.enterprise.context.ConversationScoped;
+import javax.enterprise.context.Dependent;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.SessionScoped;
 import javax.enterprise.context.spi.Context;
 import javax.inject.Singleton;
-
 import org.apache.webbeans.context.type.ContextTypes;
-import org.apache.webbeans.corespi.ServiceLoader;
 import org.apache.webbeans.logger.WebBeansLogger;
 import org.apache.webbeans.spi.ContextsService;
 
@@ -51,7 +54,7 @@ public final class ContextFactory
      */
     private static ContextsService getContextsService()
     {
-        return ServiceLoader.getService(ContextsService.class);
+        return org.apache.webbeans.config.WebBeansContext.getInstance().getService(ContextsService.class);
     }
     
     

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationManager.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationManager.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationManager.java Fri Jan  7 00:54:06 2011
@@ -31,7 +31,6 @@ import javax.enterprise.inject.spi.BeanM
 
 import org.apache.webbeans.annotation.DefaultLiteral;
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.config.WebBeansFinder;
 import org.apache.webbeans.context.ConversationContext;
 import org.apache.webbeans.util.Asserts;
 
@@ -45,26 +44,15 @@ import org.apache.webbeans.util.Asserts;
 public class ConversationManager
 {
     /**Current conversations*/
-    private ConcurrentHashMap<Conversation, ConversationContext> conversations = new ConcurrentHashMap<Conversation, ConversationContext>();
+    private final ConcurrentHashMap<Conversation, ConversationContext> conversations = new ConcurrentHashMap<Conversation, ConversationContext>();
+    private final WebBeansContext webBeansContext;
 
     /**
      * Creates new conversation manager
      */
-    public ConversationManager()
+    public ConversationManager(WebBeansContext webBeansContext)
     {
-        
-    }
-
-    /**
-     * Gets conversation manager instance.
-     * @return conversation manager
-     */
-    @Deprecated
-    public static ConversationManager getInstance()
-    {
-        ConversationManager manager = (ConversationManager) WebBeansFinder.getSingletonInstance(ConversationManager.class.getName());
-
-        return manager;
+        this.webBeansContext = webBeansContext;
     }
 
     /**
@@ -210,7 +198,7 @@ public class ConversationManager
     @SuppressWarnings("unchecked")
     public Conversation getConversationBeanReference()
     {
-        BeanManager beanManager = WebBeansContext.getInstance().getBeanManagerImpl();
+        BeanManager beanManager = webBeansContext.getBeanManagerImpl();
         Bean<Conversation> bean = (Bean<Conversation>)beanManager.getBeans(Conversation.class, new DefaultLiteral()).iterator().next();
         Conversation conversation =(Conversation) beanManager.getReference(bean, Conversation.class, beanManager.createCreationalContext(bean));
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java Fri Jan  7 00:54:06 2011
@@ -42,7 +42,7 @@ public abstract class AbstractMetaDataDi
     //private Map<String, InputStream> EJB_XML_LOCATIONS = new HashMap<String, InputStream>();
 
     /** Annotation Database */
-    private BeansXmlAnnotationDB annotationDB = null;
+    private final BeansXmlAnnotationDB annotationDB;
 
     protected boolean isBDAScannerEnabled = false;
     protected BDABeansXmlScanner bdaBeansXmlScanner;
@@ -51,16 +51,13 @@ public abstract class AbstractMetaDataDi
     {
         try
         {
-            if (annotationDB == null)
-            {
-                annotationDB = new BeansXmlAnnotationDB();
-                annotationDB.setBdaBeansXmlScanner(this);
-                annotationDB.setScanClassAnnotations(true);
-                annotationDB.crossReferenceMetaAnnotations();    
-                annotationDB.setScanFieldAnnotations(false);
-                annotationDB.setScanMethodAnnotations(false);
-                annotationDB.setScanParameterAnnotations(false);
-            }            
+            annotationDB = new BeansXmlAnnotationDB();
+            annotationDB.setBdaBeansXmlScanner(this);
+            annotationDB.setScanClassAnnotations(true);
+            annotationDB.crossReferenceMetaAnnotations();
+            annotationDB.setScanFieldAnnotations(false);
+            annotationDB.setScanMethodAnnotations(false);
+            annotationDB.setScanParameterAnnotations(false);
         }
         catch(Exception e)
         {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java Fri Jan  7 00:54:06 2011
@@ -31,14 +31,12 @@ import javax.enterprise.context.Dependen
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.Decorator;
-
 import org.apache.webbeans.annotation.DefaultLiteral;
 import org.apache.webbeans.component.AbstractInjectionTargetBean;
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
-import org.apache.webbeans.corespi.ServiceLoader;
 import org.apache.webbeans.decorator.xml.WebBeansXMLDecorator;
 import org.apache.webbeans.inject.xml.XMLInjectionPointModel;
 import org.apache.webbeans.logger.WebBeansLogger;
@@ -118,7 +116,7 @@ public final class WebBeansDecoratorConf
     private static void filterDecoratorsPerBDA(AbstractInjectionTargetBean<?> component, List<Decorator<?>> stack)
     {
 
-        ScannerService scannerService = ServiceLoader.getService(ScannerService.class);
+        ScannerService scannerService = component.getWebBeansContext().getScannerService();
         if (!scannerService.isBDABeansXmlScanningEnabled())
         {
             return;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java Fri Jan  7 00:54:06 2011
@@ -19,12 +19,31 @@
 
 package org.apache.webbeans.event;
 
+import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.enterprise.event.ObserverException;
+import javax.enterprise.event.Observes;
+import javax.enterprise.event.Reception;
+import javax.enterprise.event.TransactionPhase;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.ObserverMethod;
+import javax.enterprise.inject.spi.ProcessObserverMethod;
+import javax.enterprise.util.TypeLiteral;
 import org.apache.webbeans.annotation.AnyLiteral;
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.container.BeanManagerImpl;
-import org.apache.webbeans.corespi.ServiceLoader;
 import org.apache.webbeans.exception.WebBeansException;
 import org.apache.webbeans.logger.WebBeansLogger;
 import org.apache.webbeans.portable.events.generics.GenericBeanEvent;
@@ -36,36 +55,17 @@ import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.WebBeansUtil;
 
-import javax.enterprise.event.ObserverException;
-import javax.enterprise.event.Observes;
-import javax.enterprise.event.Reception;
-import javax.enterprise.event.TransactionPhase;
-import javax.enterprise.inject.spi.AnnotatedMethod;
-import javax.enterprise.inject.spi.ObserverMethod;
-import javax.enterprise.inject.spi.ProcessObserverMethod;
-import javax.enterprise.util.TypeLiteral;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
 @SuppressWarnings("unchecked")
 public final class NotificationManager
 {
     private final WebBeansLogger logger = WebBeansLogger.getLogger(NotificationManager.class);
 
     private final Map<Type, Set<ObserverMethod<?>>> observers = new ConcurrentHashMap<Type, Set<ObserverMethod<?>>>();
+    private final WebBeansContext webBeansContext;
 
-    public NotificationManager()
+    public NotificationManager(WebBeansContext webBeansContext)
     {
-
+        this.webBeansContext = webBeansContext;
     }
 
     public static NotificationManager getInstance()
@@ -426,7 +426,7 @@ public final class NotificationManager
                 
                 if(phase != null && !phase.equals(TransactionPhase.IN_PROGRESS))
                 {
-                    TransactionService transactionService = ServiceLoader.getService(TransactionService.class);
+                    TransactionService transactionService = webBeansContext.getService(TransactionService.class);
                     if(transactionService != null)
                     {
                         transactionService.registerTransactionSynchronization(phase, observer, event);

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java Fri Jan  7 00:54:06 2011
@@ -24,7 +24,6 @@ import org.apache.webbeans.component.Abs
 import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.config.inheritance.IBeanInheritedMetaData;
-import org.apache.webbeans.corespi.ServiceLoader;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.intercept.webbeans.WebBeansInterceptor;
 import org.apache.webbeans.logger.WebBeansLogger;
@@ -271,7 +270,7 @@ public final class WebBeansInterceptorCo
     private static void filterInterceptorsPerBDA(AbstractInjectionTargetBean<?> component, List<InterceptorData> stack)
     {
 
-        ScannerService scannerService = ServiceLoader.getService(ScannerService.class);
+        ScannerService scannerService = component.getWebBeansContext().getScannerService();
         if (!scannerService.isBDABeansXmlScanningEnabled())
         {
             return;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java Fri Jan  7 00:54:06 2011
@@ -30,7 +30,6 @@ import org.apache.webbeans.config.WebBea
 import org.apache.webbeans.config.WebBeansFinder;
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.container.InjectionResolver;
-import org.apache.webbeans.corespi.ServiceLoader;
 import org.apache.webbeans.logger.WebBeansLogger;
 import org.apache.webbeans.portable.events.discovery.BeforeShutdownImpl;
 import org.apache.webbeans.spi.ContainerLifecycle;
@@ -78,12 +77,16 @@ public abstract class AbstractLifeCycle 
         this.beanManager = webBeansContext.getBeanManagerImpl();
         this.xmlDeployer = new WebBeansXMLConfigurator();
         this.deployer = new BeansDeployer(xmlDeployer);
-        this.jndiService = ServiceLoader.getService(JNDIService.class);    
+        this.jndiService = webBeansContext.getService(JNDIService.class);
         this.beanManager.setXMLConfigurator(this.xmlDeployer);
-        this.scannerService = ServiceLoader.getService(ScannerService.class);
-        this.contextsService = ServiceLoader.getService(ContextsService.class);
-        this.beanManager.setScannerService(scannerService);
-        initApplication(properties);                
+        this.scannerService = webBeansContext.getScannerService();
+        this.contextsService = webBeansContext.getService(ContextsService.class);
+        initApplication(properties);
+    }
+
+    public WebBeansContext getWebBeansContext()
+    {
+        return webBeansContext;
     }
 
     @Override
@@ -195,10 +198,10 @@ public abstract class AbstractLifeCycle 
     /**
      * @return the scannerService
      */
-    protected ScannerService getScannerService()
-    {
-        return scannerService;
-    }
+//    protected ScannerService getScannerService()
+//    {
+//        return scannerService;
+//    }
 
     /**
      * @return the contextsService
@@ -211,26 +214,26 @@ public abstract class AbstractLifeCycle 
     /**
      * @return the deployer
      */
-    protected BeansDeployer getDeployer()
-    {
-        return deployer;
-    }
+//    protected BeansDeployer getDeployer()
+//    {
+//        return deployer;
+//    }
 
     /**
      * @return the xmlDeployer
      */
-    protected WebBeansXMLConfigurator getXmlDeployer()
-    {
-        return xmlDeployer;
-    }
+//    protected WebBeansXMLConfigurator getXmlDeployer()
+//    {
+//        return xmlDeployer;
+//    }
 
     /**
      * @return the jndiService
      */
-    protected JNDIService getJndiService()
-    {
-        return jndiService;
-    }
+//    protected JNDIService getJndiService()
+//    {
+//        return jndiService;
+//    }
 
     @Override
     public void initApplication(Properties properties)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/test/OpenWebBeansTestLifeCycle.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/test/OpenWebBeansTestLifeCycle.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/test/OpenWebBeansTestLifeCycle.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/test/OpenWebBeansTestLifeCycle.java Fri Jan  7 00:54:06 2011
@@ -20,6 +20,7 @@ package org.apache.webbeans.lifecycle.te
 
 import java.util.Properties;
 
+import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.lifecycle.StandaloneLifeCycle;
 import org.apache.webbeans.spi.ScannerService;
 
@@ -39,13 +40,9 @@ public class OpenWebBeansTestLifeCycle e
     }
     
     @Override
-    public void initApplication(Properties properties)
+    public void beforeInitApplication(Properties properties)
     {
-        this.scannerService = new OpenWebBeansTestMetaDataDiscoveryService();
+        WebBeansContext.getInstance().registerService(ScannerService.class, new OpenWebBeansTestMetaDataDiscoveryService());
     }    
     
-    public ScannerService getScannerService()
-    {
-        return this.scannerService;
-    }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/AbstractUnitTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/AbstractUnitTest.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/AbstractUnitTest.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/AbstractUnitTest.java Fri Jan  7 00:54:06 2011
@@ -30,9 +30,12 @@ import javax.enterprise.inject.spi.BeanM
 import javax.enterprise.inject.spi.Extension;
 
 import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.config.WebBeansFinder;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.lifecycle.test.OpenWebBeansTestLifeCycle;
 import org.apache.webbeans.lifecycle.test.OpenWebBeansTestMetaDataDiscoveryService;
+import org.apache.webbeans.spi.ScannerService;
+import org.apache.webbeans.util.WebBeansUtil;
 import org.junit.Assert;
 
 
@@ -40,52 +43,38 @@ public abstract class AbstractUnitTest
 {
     private OpenWebBeansTestLifeCycle testLifecycle;
     private List<Extension>  extensions = new ArrayList<Extension>();
+    private WebBeansContext webBeansContext;
 
     protected AbstractUnitTest()
     {
-        
+
     }
     
     protected void startContainer(Collection<Class<?>> beanClasses)
     {
-        //Creates a new container
-        testLifecycle = new OpenWebBeansTestLifeCycle();
-        
-        for (Extension ext : extensions)
-        {
-            WebBeansContext.getInstance().getExtensionLoader().addExtension(ext);
-        }
-        
-        //Deploy bean classes
-        OpenWebBeansTestMetaDataDiscoveryService discoveyService = (OpenWebBeansTestMetaDataDiscoveryService)testLifecycle.getScannerService();
-        discoveyService.deployClasses(beanClasses);
-        
-        //Start application
-        try
-        {
-            testLifecycle.startApplication(null);
-        }
-        catch (Exception e)
-        {
-            throw new WebBeansConfigurationException(e);
-        }
+        startContainer(beanClasses, null);
     }
     
     protected void startContainer(Collection<Class<?>> beanClasses, Collection<URL> beanXmls)
     {
+        WebBeansFinder.clearInstances(WebBeansUtil.getCurrentClassLoader());
         //Creates a new container
         testLifecycle = new OpenWebBeansTestLifeCycle();
         
+        webBeansContext = WebBeansContext.getInstance();
         for (Extension ext : extensions)
         {
-            WebBeansContext.getInstance().getExtensionLoader().addExtension(ext);
+            webBeansContext.getExtensionLoader().addExtension(ext);
         }
         
         //Deploy bean classes
-        OpenWebBeansTestMetaDataDiscoveryService discoveyService = (OpenWebBeansTestMetaDataDiscoveryService)testLifecycle.getScannerService();
-        discoveyService.deployClasses(beanClasses);
-        discoveyService.deployXMLs(beanXmls);
-        
+        OpenWebBeansTestMetaDataDiscoveryService discoveryService = (OpenWebBeansTestMetaDataDiscoveryService)webBeansContext.getScannerService();
+        discoveryService.deployClasses(beanClasses);
+        if (beanXmls != null)
+        {
+            discoveryService.deployXMLs(beanXmls);
+        }
+
         //Start application
         try
         {
@@ -107,15 +96,15 @@ public abstract class AbstractUnitTest
             this.testLifecycle.stopApplication(null);
         }        
     }
-    
-    protected OpenWebBeansTestLifeCycle getLifecycle()
+        
+    protected WebBeansContext getWebBeansContext()
     {
-        return this.testLifecycle;
+        return this.webBeansContext;
     }
     
     protected BeanManager getBeanManager()
     {
-        return this.testLifecycle.getBeanManager();
+        return this.webBeansContext.getBeanManagerImpl();
     }
     
     @SuppressWarnings("unchecked")

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/SerializationTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/SerializationTest.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/SerializationTest.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/SerializationTest.java Fri Jan  7 00:54:06 2011
@@ -76,8 +76,8 @@ public class SerializationTest extends A
         classes.add(CircularApplicationScopedBean.class);
         startContainer(classes);
 
-        BeanManager bm = getLifecycle().getBeanManager();
-        Set<Bean<?>> beans = getLifecycle().getBeanManager().getBeans(PersonalDataBean.class);
+        BeanManager bm = getBeanManager();
+        Set<Bean<?>> beans = getBeanManager().getBeans(PersonalDataBean.class);
         Assert.assertNotNull(beans);
         Assert.assertTrue(beans.size() == 1);
         Bean pdbBean = beans.iterator().next();
@@ -115,7 +115,7 @@ public class SerializationTest extends A
 
         startContainer(classes);
 
-        Set<Bean<?>> beans = getLifecycle().getBeanManager().getBeans(Object.class);
+        Set<Bean<?>> beans = getBeanManager().getBeans(Object.class);
         Assert.assertNotNull(beans);
         Assert.assertTrue(beans.size() > 7);
 
@@ -159,7 +159,7 @@ public class SerializationTest extends A
 
         startContainer(classes);
 
-        Set<Bean<?>> beans = getLifecycle().getBeanManager().getBeans(SessScopedBean.class);
+        Set<Bean<?>> beans = getBeanManager().getBeans(SessScopedBean.class);
         Assert.assertNotNull(beans);
         Assert.assertTrue(beans.size() == 1);
         

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/tests/SessionContextTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/tests/SessionContextTest.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/tests/SessionContextTest.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/tests/SessionContextTest.java Fri Jan  7 00:54:06 2011
@@ -82,8 +82,8 @@ public class SessionContextTest extends 
         Assert.assertNotNull(pdb1);
         
         // now we reset the session Context so we should get a new contextual instance.
-        getLifecycle().getContextService().endContext(SessionScoped.class, null);
-        getLifecycle().getContextService().startContext(SessionScoped.class, null);
+        getWebBeansContext().getContextsService().endContext(SessionScoped.class, null);
+        getWebBeansContext().getContextsService().startContext(SessionScoped.class, null);
         
         PersonalDataBean pdb2 = appBeanInstance.getPdb().getInstance();
         Assert.assertNotNull(pdb2);

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/threadsafety/ThreadSafeBeanInitialisationTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/threadsafety/ThreadSafeBeanInitialisationTest.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/threadsafety/ThreadSafeBeanInitialisationTest.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/threadsafety/ThreadSafeBeanInitialisationTest.java Fri Jan  7 00:54:06 2011
@@ -54,11 +54,11 @@ public class ThreadSafeBeanInitialisatio
         classes.add(LongInitApplicationBean.class);
         startContainer(classes);
 
-        BeanManager bm = getLifecycle().getBeanManager();
+        BeanManager bm = getBeanManager();
 
-        ParallelBeanStarter bs1 = new ParallelBeanStarter(bm, getLifecycle().getContextService());
-        ParallelBeanStarter bs2 = new ParallelBeanStarter(bm, getLifecycle().getContextService());
-        ParallelBeanStarter bs3 = new ParallelBeanStarter(bm, getLifecycle().getContextService());
+        ParallelBeanStarter bs1 = new ParallelBeanStarter(bm, getWebBeansContext().getContextsService());
+        ParallelBeanStarter bs2 = new ParallelBeanStarter(bm, getWebBeansContext().getContextsService());
+        ParallelBeanStarter bs3 = new ParallelBeanStarter(bm, getWebBeansContext().getContextsService());
 
         bs1.start();
         bs2.start();

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/ExtensionTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/ExtensionTest.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/ExtensionTest.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/ExtensionTest.java Fri Jan  7 00:54:06 2011
@@ -70,7 +70,7 @@ public class ExtensionTest extends Abstr
         
         Assert.assertNotNull(instance);
         
-        Assert.assertTrue(getLifecycle().getBeanManager().isPassivatingScope(ExternalTestScoped.class));
+        Assert.assertTrue(getBeanManager().isPassivatingScope(ExternalTestScoped.class));
         
         //Fire shut down
         getBeanManager().fireEvent(new BeforeShutdownImpl(), new Annotation[0]);

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/config/WebBeansScannerTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/config/WebBeansScannerTest.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/config/WebBeansScannerTest.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/config/WebBeansScannerTest.java Fri Jan  7 00:54:06 2011
@@ -45,7 +45,7 @@ public class WebBeansScannerTest extends
         //Start test container
         startContainer(classes);
         
-        ScannerService scanner = getLifecycle().getScannerService();
+        ScannerService scanner = getWebBeansContext().getScannerService();
         Set<Class<?>> classMap = scanner.getBeanClasses();
         Assert.assertNotNull(classMap);
         Assert.assertFalse(classMap.isEmpty());

Modified: openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/java/org/apache/webbeans/resource/spi/ee/ExtendedStandaloneResourceInjectionService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/java/org/apache/webbeans/resource/spi/ee/ExtendedStandaloneResourceInjectionService.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/java/org/apache/webbeans/resource/spi/ee/ExtendedStandaloneResourceInjectionService.java (original)
+++ openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/java/org/apache/webbeans/resource/spi/ee/ExtendedStandaloneResourceInjectionService.java Fri Jan  7 00:54:06 2011
@@ -19,6 +19,7 @@
 package org.apache.webbeans.resource.spi.ee;
 
 import org.apache.webbeans.annotation.DefaultLiteral;
+import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.resource.spi.se.StandaloneResourceInjectionService;
 import org.apache.webbeans.spi.api.ResourceReference;
@@ -36,6 +37,12 @@ import java.util.Iterator;
  */
 public class ExtendedStandaloneResourceInjectionService extends StandaloneResourceInjectionService
 {
+
+    public ExtendedStandaloneResourceInjectionService(WebBeansContext webBeansContext)
+    {
+        super(webBeansContext);
+    }
+
     @Override
     public <X, T extends Annotation> X getResourceReference(ResourceReference<X, T> resourceReference)
     {
@@ -66,7 +73,7 @@ public class ExtendedStandaloneResourceI
         catch (NamingException e)
         {
             //fallback for a servlet container
-            BeanManagerImpl beanManager = BeanManagerImpl.getManager();
+            BeanManagerImpl beanManager = getWebBeansContext().getBeanManagerImpl();
 
             Iterator<Bean<?>> beansIterator = beanManager.getBeans(resourceType, new DefaultLiteral()).iterator();
 

Modified: openwebbeans/trunk/webbeans-jms/src/main/java/org/apache/webbeans/jms/util/JmsUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-jms/src/main/java/org/apache/webbeans/jms/util/JmsUtil.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-jms/src/main/java/org/apache/webbeans/jms/util/JmsUtil.java (original)
+++ openwebbeans/trunk/webbeans-jms/src/main/java/org/apache/webbeans/jms/util/JmsUtil.java Fri Jan  7 00:54:06 2011
@@ -41,7 +41,6 @@ import javax.jms.TopicSession;
 import javax.jms.TopicSubscriber;
 
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.corespi.ServiceLoader;
 import org.apache.webbeans.exception.WebBeansCreationException;
 import org.apache.webbeans.exception.WebBeansException;
 import org.apache.webbeans.jms.JMSModel;
@@ -126,7 +125,7 @@ public final class JmsUtil
     
     private static JNDIService getJNDIService()
     {
-       JNDIService jndiService = ServiceLoader.getService(JNDIService.class);
+       JNDIService jndiService = WebBeansContext.getInstance().getService(JNDIService.class);
         
         if(jndiService == null)
         {

Modified: openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/OwbApplication.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/OwbApplication.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/OwbApplication.java (original)
+++ openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/OwbApplication.java Fri Jan  7 00:54:06 2011
@@ -52,7 +52,6 @@ import javax.faces.event.SystemEventList
 import javax.faces.validator.Validator;
 
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.corespi.ServiceLoader;
 import org.apache.webbeans.spi.adaptor.ELAdaptor;
 
 public class OwbApplication extends Application
@@ -63,7 +62,7 @@ public class OwbApplication extends Appl
     
     public OwbApplication(Application wrappedApplication)
     {
-        ELAdaptor elAdaptor = ServiceLoader.getService(ELAdaptor.class);
+        ELAdaptor elAdaptor = WebBeansContext.getInstance().getService(ELAdaptor.class);
         this.wrappedApplication = wrappedApplication;
     }
 

Modified: openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/resource/OpenEjbResourceInjectionService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/resource/OpenEjbResourceInjectionService.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/resource/OpenEjbResourceInjectionService.java (original)
+++ openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/resource/OpenEjbResourceInjectionService.java Fri Jan  7 00:54:06 2011
@@ -32,7 +32,7 @@ import javax.enterprise.inject.spi.Bean;
 
 import org.apache.webbeans.component.ResourceBean;
 import org.apache.webbeans.config.OWBLogConst;
-import org.apache.webbeans.corespi.ServiceLoader;
+import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.exception.WebBeansException;
 import org.apache.webbeans.logger.WebBeansLogger;
@@ -52,6 +52,13 @@ public class OpenEjbResourceInjectionSer
 
     private static final WebBeansLogger logger = WebBeansLogger.getLogger(OpenEjbResourceInjectionService.class);
 
+    private final WebBeansContext webBeansContext;
+
+    public OpenEjbResourceInjectionService(WebBeansContext webBeansContext)
+    {
+        this.webBeansContext = webBeansContext;
+    }
+
     @Override
     public void clear()
     {
@@ -118,7 +125,7 @@ public class OpenEjbResourceInjectionSer
     public <T> void writeExternal(Bean<T> bean, T actualResource, ObjectOutput out) throws IOException
     {
         // try fail over service to serialize the resource object
-        FailOverService failoverService = ServiceLoader.getService(FailOverService.class);
+        FailOverService failoverService = webBeansContext.getService(FailOverService.class);
         if (failoverService != null)
         {
             Object ret = failoverService.handleResource(bean, actualResource, null, out);
@@ -150,7 +157,7 @@ public class OpenEjbResourceInjectionSer
     {
         T actualResource = null;
         // try fail over service to serialize the resource object
-        FailOverService failoverService = ServiceLoader.getService(FailOverService.class);
+        FailOverService failoverService = webBeansContext.getService(FailOverService.class);
         if (failoverService != null)
         {
             actualResource = (T) failoverService.handleResource(bean, actualResource, in, null);

Modified: openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/StandaloneContainersImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/StandaloneContainersImpl.java?rev=1056145&r1=1056144&r2=1056145&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/StandaloneContainersImpl.java (original)
+++ openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/StandaloneContainersImpl.java Fri Jan  7 00:54:06 2011
@@ -46,10 +46,8 @@ import org.apache.openejb.jee.SingletonB
 import org.apache.openejb.jee.StatefulBean;
 import org.apache.openejb.jee.StatelessBean;
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.corespi.ServiceLoader;
 import org.apache.webbeans.ejb.EjbPlugin;
 import org.apache.webbeans.lifecycle.StandaloneLifeCycle;
-import org.apache.webbeans.spi.ScannerService;
 import org.apache.webbeans.test.tck.mock.TCKMetaDataDiscoveryImpl;
 import org.jboss.testharness.api.DeploymentException;
 import org.jboss.testharness.spi.StandaloneContainers;
@@ -63,7 +61,7 @@ public class StandaloneContainersImpl im
     public void deployInternal(Iterable<Class<?>> classes) throws DeploymentException
     {
         // Scanner service
-        final TCKMetaDataDiscoveryImpl discovery = (TCKMetaDataDiscoveryImpl) ServiceLoader.getService(ScannerService.class);
+        final TCKMetaDataDiscoveryImpl discovery = (TCKMetaDataDiscoveryImpl) WebBeansContext.getInstance().getScannerService();
 
         // Lifecycle container
         this.lifeCycle = new StandaloneLifeCycle()
@@ -98,7 +96,7 @@ public class StandaloneContainersImpl im
     {
         try
         {
-            final TCKMetaDataDiscoveryImpl discovery = (TCKMetaDataDiscoveryImpl) ServiceLoader.getService(ScannerService.class);
+            final TCKMetaDataDiscoveryImpl discovery = (TCKMetaDataDiscoveryImpl) WebBeansContext.getInstance().getScannerService();
 
             // Lifecycle container
             this.lifeCycle = new StandaloneLifeCycle()



Mime
View raw message