openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1074497 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/config/ main/java/org/apache/webbeans/container/ test/java/org/apache/webbeans/test/mock/ test/java/org/apache/webbeans/test/unittests/inject/ test/java/org/...
Date Fri, 25 Feb 2011 12:27:00 GMT
Author: struberg
Date: Fri Feb 25 12:27:00 2011
New Revision: 1074497

URL: http://svn.apache.org/viewvc?rev=1074497&view=rev
Log:
OWB-532 create a new BeanManager#isInUse() flag 

this is set once a custom bean got added

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/mock/MockManager.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/InjectedInstanceComponentTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/resolution/ManagerResolutionTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/typedliteral/TypeLiteralTest.java

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=1074497&r1=1074496&r2=1074497&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 Feb 25 12:27:00 2011
@@ -146,7 +146,7 @@ public class BeansDeployer
                 }
 
                 // Register Manager built-in component
-                webBeansContext.getBeanManagerImpl().addBean(webBeansContext.getWebBeansUtil().getManagerBean());
+                webBeansContext.getBeanManagerImpl().addInternalBean(webBeansContext.getWebBeansUtil().getManagerBean());
 
                 //Fire Event
                 fireBeforeBeanDiscoveryEvent();
@@ -200,16 +200,16 @@ public class BeansDeployer
         WebBeansUtil webBeansUtil = webBeansContext.getWebBeansUtil();
 
         // Register Conversation built-in component
-        beanManager.addBean(webBeansUtil.getConversationBean());
+        beanManager.addInternalBean(webBeansUtil.getConversationBean());
         
         // Register InjectionPoint bean
-        beanManager.addBean(webBeansUtil.getInjectionPointBean());
+        beanManager.addInternalBean(webBeansUtil.getInjectionPointBean());
         
         //Register Instance Bean
-        beanManager.addBean(webBeansUtil.getInstanceBean());
+        beanManager.addInternalBean(webBeansUtil.getInstanceBean());
         
         //Register Event Bean
-        beanManager.addBean(webBeansUtil.getEventBean());
+        beanManager.addInternalBean(webBeansUtil.getEventBean());
         
         //REgister Provider Beans
         OpenWebBeansJavaEEPlugin beanEeProvider = webBeansContext.getPluginLoader().getJavaEEPlugin();
@@ -241,7 +241,7 @@ public class BeansDeployer
         
         if(bean != null)
         {
-            manager.addBean(bean);
+            manager.addInternalBean(bean);
         }
     }
     

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=1074497&r1=1074496&r2=1074497&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 Feb 25 12:27:00 2011
@@ -177,6 +177,13 @@ public class BeanManagerImpl implements 
     private final WebBeansContext webBeansContext;
 
     /**
+     * This flag will get set to <code>true</code> if a custom bean
+     * (all non-internal beans like {@link org.apache.webbeans.component.BeanManagerBean;}
etc)
+     * gets set.
+     */
+    private boolean inUse = false;
+
+    /**
      * Creates a new {@link BeanManager} instance.
      * Called by the system. Do not use outside of the
      * system.
@@ -306,14 +313,26 @@ public class BeanManagerImpl implements 
     }
 
     /**
-     * Add new bean.
+     * Add new bean to the BeanManager.
+     * This will also set OWBs {@link #inUse} status.
      * 
      * @param newBean new bean instance
      * @return the this manager
      */
-    
     public BeanManager addBean(Bean<?> newBean)
     {
+        inUse = true;
+        return addInternalBean(newBean);
+    }
+
+    /**
+     * This method is reserved for adding 'internal beans'
+     * like e.g. a BeanManagerBean,
+     * @param newBean
+     * @return
+     */
+    public BeanManager addInternalBean(Bean<?> newBean)
+    {
         if(newBean instanceof AbstractOwbBean)
         {
             addPassivationInfo((OwbBean)newBean);
@@ -325,11 +344,11 @@ public class BeanManagerImpl implements 
             addPassivationInfo(bean);
             this.deploymentBeans.add(bean);
         }
-        
 
         return this;
     }
 
+
     /**
      * Check if the bean is has a passivation id and add it to the id store.
      *
@@ -1155,4 +1174,9 @@ public class BeanManagerImpl implements 
         this.webBeansDecorators.clear();
         this.webBeansInterceptors.clear();
     }
+
+    public boolean isInUse()
+    {
+        return inUse;
+    }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/mock/MockManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/mock/MockManager.java?rev=1074497&r1=1074496&r2=1074497&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/mock/MockManager.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/mock/MockManager.java
Fri Feb 25 12:27:00 2011
@@ -91,7 +91,13 @@ public class MockManager implements Bean
         manager.addBean(bean);
         return this;
     }
-    
+
+    public BeanManager addInternalBean(Bean<?> bean)
+    {
+        manager.addInternalBean(bean);
+        return this;
+    }
+
     public BeanManager addContext(Context context)
     {
         return manager.addContext(context);

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/InjectedInstanceComponentTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/InjectedInstanceComponentTest.java?rev=1074497&r1=1074496&r2=1074497&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/InjectedInstanceComponentTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/InjectedInstanceComponentTest.java
Fri Feb 25 12:27:00 2011
@@ -48,7 +48,7 @@ public class InjectedInstanceComponentTe
     public void testInstanceInjectedComponent()
     {
         WebBeansContext webBeansContext = WebBeansContext.getInstance();
-        getManager().addBean(webBeansContext.getWebBeansUtil().getInstanceBean());
+        getManager().addInternalBean(webBeansContext.getWebBeansUtil().getInstanceBean());
 
         webBeansContext.getContextFactory().initRequestContext(null);
         Bean<PaymentProcessorComponent> bean =  defineManagedBean(PaymentProcessorComponent.class);

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/resolution/ManagerResolutionTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/resolution/ManagerResolutionTest.java?rev=1074497&r1=1074496&r2=1074497&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/resolution/ManagerResolutionTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/resolution/ManagerResolutionTest.java
Fri Feb 25 12:27:00 2011
@@ -40,7 +40,7 @@ public class ManagerResolutionTest exten
     public void beforeTest()
     {
         super.init();
-        getManager().addBean(WebBeansContext.getInstance().getWebBeansUtil().getManagerBean());
+        getManager().addInternalBean(WebBeansContext.getInstance().getWebBeansUtil().getManagerBean());
     }
 
     @Test

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/typedliteral/TypeLiteralTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/typedliteral/TypeLiteralTest.java?rev=1074497&r1=1074496&r2=1074497&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/typedliteral/TypeLiteralTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/typedliteral/TypeLiteralTest.java
Fri Feb 25 12:27:00 2011
@@ -72,7 +72,7 @@ public class TypeLiteralTest extends Tes
         clear();
 
         WebBeansContext webBeansContext = WebBeansContext.getInstance();
-        webBeansContext.getBeanManagerImpl().addBean(webBeansContext.getWebBeansUtil().getInstanceBean());
+        webBeansContext.getBeanManagerImpl().addInternalBean(webBeansContext.getWebBeansUtil().getInstanceBean());
         
         defineManagedBean(StringOrder.class);
         defineManagedBean(IntegerOrder.class);



Mime
View raw message