openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r919885 [1/2] - in /openwebbeans/trunk/webbeans-impl: ./ src/main/java/org/apache/webbeans/boot/ src/main/java/org/apache/webbeans/component/javaee/ src/main/java/org/apache/webbeans/config/ src/main/java/org/apache/webbeans/context/ src/ma...
Date Sun, 07 Mar 2010 00:08:00 GMT
Author: gerdogdu
Date: Sun Mar  7 00:07:58 2010
New Revision: 919885

URL: http://svn.apache.org/viewvc?rev=919885&view=rev
Log:
[OWB-320] Remove Java EE Dependencies from WebBeans Core

Added:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/boot/
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/boot/Bootstrap.java   (with props)
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContextsService.java   (with props)
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/OWBInjector.java   (with props)
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java   (with props)
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/AbstractEnterpriseProviderPlugin.java   (with props)
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/OpenWebBeansJavaEEPlugin.java   (with props)
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/OpenWebBeansWebPlugin.java   (with props)
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/scanner/
      - copied from r916352, openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/scanner/AbstractMetaDataDiscovery.java
      - copied, changed from r919879, openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/AbstractMetaDataDiscovery.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/se/DefaultContextsService.java   (with props)
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/se/DefaultScannerService.java   (with props)
Removed:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/javaee/
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/SessionContextManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/DefaultLifecycle.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/test/EnterpriseTestLifeCycle.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/test/MockHttpSession.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/test/MockServletContext.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/test/MockServletContextEvent.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/servlet/
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/se/DefaultResourceInjectionService.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/se/DefaultSecurityService.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/se/DefaultTransactionService.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/se/DefaultValidatorService.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/se/deployer/
    openwebbeans/trunk/webbeans-impl/src/main/resources/log4j.properties
Modified:
    openwebbeans/trunk/webbeans-impl/pom.xml
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansFinder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ApplicationContext.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/RequestContext.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/SessionContext.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/SingletonContext.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WebBeansELResolver.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/xml/BeanObserverXMLImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InvocationContextImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/StandaloneLifeCycle.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/test/OpenWebBeansTestLifeCycle.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/test/OpenWebBeansTestMetaDataDiscoveryService.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/logger/WebBeansLogger.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/PluginLoader.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ServiceLoader.java
    openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans-default.properties
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/AbstractUnitTest.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/newtests/promethods/PersonProducerTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/broken/BrokenObserverComponent2.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/broken/BrokenObserverComponent3.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/broken/BrokenObserverComponent4.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/broken/BrokenObserverComponent5.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/broken/BrokenObserverComponent6.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/containertests/ComponentResolutionByTypeTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/servlet/ITestContext.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/servlet/TestListener.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/config/WebBeansScannerTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/decorator/DecoratorExceptionTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/decorator/DecoratorTest1.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/disposal/DisposalTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/EventTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/exception/EventExceptionTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/exception/ExceptionComponentTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/exception/ScopeTypeExceptionComponentTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/CurrentInjectedComponentTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/InjectedComponentTestWithMember.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/TypedInjectedComponentTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/UserComponentTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/EJBInterceptComponentTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/webbeans/SecureAndTransactionalInterceptorTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/webbeans/ShoppingCardInterceptorTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/webbeans/WebBeansInterceptComponentTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/portable/events/ExtensionTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/producer/ProducerComponentTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/scopes/ScopeAdapterTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/scopes/SingletonComponentTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/xml/XMLTest.java

Modified: openwebbeans/trunk/webbeans-impl/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/pom.xml?rev=919885&r1=919884&r2=919885&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/pom.xml (original)
+++ openwebbeans/trunk/webbeans-impl/pom.xml Sun Mar  7 00:07:58 2010
@@ -30,15 +30,6 @@
 	<dependencies>
 
 		<dependency>
-			<groupId>log4j</groupId>
-			<artifactId>log4j</artifactId>
-		</dependency>
-		<dependency>
-		    <groupId>org.apache.geronimo.specs</groupId>
-		    <artifactId>geronimo-servlet_2.5_spec</artifactId>
-		    <optional>true</optional>
-		</dependency>
-		<dependency>
 			<groupId>dom4j</groupId>
 			<artifactId>dom4j</artifactId>
 		</dependency>
@@ -56,35 +47,13 @@
 			<artifactId>scannotation</artifactId>
 		</dependency>
 		<dependency>
-		    <groupId>javax.annotation</groupId>
-		    <artifactId>jsr250-api</artifactId>
-		    <optional>true</optional>
-		</dependency>
-		<dependency>
-		    <groupId>org.apache.geronimo.specs</groupId>
-		    <artifactId>geronimo-interceptor_1.1_spec</artifactId>
-		    <optional>true</optional>
-		</dependency>
-		<dependency>
-		    <groupId>org.apache.geronimo.specs</groupId>
-		    <artifactId>geronimo-jta_1.1_spec</artifactId>
-		    <optional>true</optional>
-		</dependency>
-		<dependency>
-		    <groupId>org.apache.geronimo.specs</groupId>
-		    <artifactId>geronimo-jsp_2.1_spec</artifactId>
-		    <optional>true</optional>
-		</dependency>
-		<dependency>
 			<groupId>org.apache.geronimo.specs</groupId>
 			<artifactId>geronimo-jcdi_1.0_spec</artifactId>
 		</dependency>
-
-              <dependency>
+		<dependency>
                       <groupId>org.apache.geronimo.specs</groupId>
                       <artifactId>geronimo-atinject_1.0_spec</artifactId>
               </dependency>
-
 		<dependency>
             	    <groupId>junit</groupId>
 	            <artifactId>junit</artifactId>
@@ -93,14 +62,12 @@
 		<dependency>
 			<groupId>org.apache.openwebbeans</groupId>
 			<artifactId>openwebbeans-spi</artifactId>
+			<version>${project.version}</version>
 		</dependency>
 		<dependency>
 			<groupId>org.apache.geronimo.specs</groupId>
-			<artifactId>geronimo-validation_1.0_spec</artifactId>
-			<scope>provided</scope>
+			<artifactId>geronimo-interceptor_1.1_spec</artifactId>
 		</dependency>
-
-        <!-- the following dependencies are needed for tests only -->      
 	</dependencies>
 
     <build>

Added: 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=919885&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/boot/Bootstrap.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/boot/Bootstrap.java Sun Mar  7 00:07:58 2010
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.boot;
+
+import java.util.Properties;
+import java.util.concurrent.CountDownLatch;
+
+import org.apache.webbeans.lifecycle.LifecycleFactory;
+import org.apache.webbeans.logger.WebBeansLogger;
+import org.apache.webbeans.spi.ContainerLifecycle;
+
+public class Bootstrap
+{
+    private static final WebBeansLogger logger = WebBeansLogger.getLogger(Bootstrap.class);
+    
+    private CountDownLatch latch = new CountDownLatch(1);
+    
+    private ContainerLifecycle containerLifecycle = null;
+    
+    private Properties properties = null;
+    
+    public void init(Properties properties)
+    {
+        logger.info("Initializing OpenWebBeans Container");
+        this.containerLifecycle = LifecycleFactory.getInstance().getLifecycle();
+    }
+    
+    public void start() throws Exception
+    {
+        logger.info("Starting OpenWebBeans Container...");
+        long begin = System.currentTimeMillis();
+        
+        containerLifecycle.startApplication(this.properties);
+        Runtime.getRuntime().addShutdownHook(new Thread(){
+           
+            public void run()
+            {
+                Bootstrap.this.latch.countDown();
+            }
+            
+        });
+        
+        logger.info("OpenWebBeans Container has started within " + Long.toString(System.currentTimeMillis() - begin) + " mseconds.");
+        this.latch.await();
+        
+        logger.info("Stopping OpenWebBeans Container...");
+        
+        containerLifecycle.stopApplication(this.properties);
+        
+        logger.info("OpenWebBeans Container has stopped.");
+    }
+    
+    public static void main(String []args) throws Exception
+    {
+        Bootstrap boot = new Bootstrap();
+        boot.init(System.getProperties());
+    }
+
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/boot/Bootstrap.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=919885&r1=919884&r2=919885&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 Sun Mar  7 00:07:58 2010
@@ -41,9 +41,6 @@
 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.javaee.PrinicipalBean;
-import org.apache.webbeans.component.javaee.ValidatorBean;
-import org.apache.webbeans.component.javaee.ValidatorFactoryBean;
 import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.decorator.WebBeansDecorator;
@@ -54,6 +51,9 @@
 import org.apache.webbeans.exception.inject.InconsistentSpecializationException;
 import org.apache.webbeans.intercept.webbeans.WebBeansInterceptor;
 import org.apache.webbeans.logger.WebBeansLogger;
+import org.apache.webbeans.plugins.OpenWebBeansJavaEEPlugin;
+import org.apache.webbeans.plugins.OpenWebBeansWebPlugin;
+import org.apache.webbeans.plugins.PluginLoader;
 import org.apache.webbeans.portable.AnnotatedElementFactory;
 import org.apache.webbeans.portable.events.ExtensionLoader;
 import org.apache.webbeans.portable.events.ProcessAnnotatedTypeImpl;
@@ -194,14 +194,46 @@
         //Register Event Bean
         beanManager.addBean(WebBeansUtil.getEventBean());
         
-        //Register Validator Bean
-        beanManager.addBean(new ValidatorBean());
+        //REgister Provider Beans
+        OpenWebBeansJavaEEPlugin beanEeProvider = PluginLoader.getInstance().getJavaEEPlugin();
+        OpenWebBeansWebPlugin beanWebProvider = PluginLoader.getInstance().getWebPlugin();
         
-        //Register ValidatorFactory Bean
-        beanManager.addBean(new ValidatorFactoryBean());
-        
-        //Register Principal Bean
-        beanManager.addBean(new PrinicipalBean());
+        if(beanEeProvider != null)
+        {
+            if(beanEeProvider.getValidatorBean() != null)
+            {
+                //Register Validator Bean
+                beanManager.addBean(beanEeProvider.getValidatorBean());                
+            }
+            
+            if(beanEeProvider.getValidatorFactoryBean() != null)
+            {
+                //Register ValidatorFactory Bean
+                beanManager.addBean(beanEeProvider.getValidatorFactoryBean());                
+            }
+            
+            if(beanEeProvider.getPrincipalBean() != null)
+            {
+                //Register Principal Bean
+                beanManager.addBean(beanEeProvider.getPrincipalBean());                
+            }
+            
+            if(beanEeProvider.getUserTransactionBean() != null)
+            {
+                //User Transaction Bean
+                beanManager.addBean(beanEeProvider.getUserTransactionBean());                
+            }
+        }       
+        else if(beanWebProvider != null)
+        {
+            if(beanWebProvider.getPrincipalBean() != null)
+            {
+                //Register Principal Bean
+                beanManager.addBean(beanWebProvider.getPrincipalBean());                
+            }
+            
+        }
+            
     }
     
     /**

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java?rev=919885&r1=919884&r2=919885&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java Sun Mar  7 00:07:58 2010
@@ -37,37 +37,140 @@
  */
 public class OpenWebBeansConfiguration
 {
+    /**Logger instance*/
+    private static final WebBeansLogger logger = WebBeansLogger.getLogger(OpenWebBeansConfiguration.class);
+
+    /**Default configuration file*/
     private final static String DEFALULT_CONFIG_PROPERTIES_NAME = "META-INF/openwebbeans/openwebbeans-default.properties";
+    
+    /**Application specified file*/
     private final static String CONFIG_PROPERTIES_NAME = "META-INF/openwebbeans/openwebbeans.properties";
-
-    private Properties configProperties = new Properties();
-    private WebBeansLogger logger = WebBeansLogger.getLogger(OpenWebBeansConfiguration.class);
     
+    /**Property of application*/
+    private Properties configProperties = new Properties();
+        
     /**Conversation periodic delay in ms.*/
     public static final String CONVERSATION_PERIODIC_DELAY = "org.apache.webbeans.conversation.Conversation.periodicDelay";
     
     /**Use OWB Specific XML Configuration or Strict Spec XML*/
+    @Deprecated //Not use any more 
     public static final String USE_OWB_SPECIFIC_XML_CONFIGURATION = "org.apache.webbeans.useOwbSpecificXmlConfig";
     
     /**Use OWB Specific Field Injection*/
+    @Deprecated //Not use anymore
     public static final String USE_OWB_SPECIFIC_FIELD_INJECTION = "org.apache.webbeans.fieldInjection.useOwbSpecificInjection";    
     
     /**Use EJB Discovery or not*/
-    public static final String USE_EJB_DISCOVERY = "org.apache.webbeans.spi.deployer.UseEjbMetaDataDiscoveryService";
+    public static final String USE_EJB_DISCOVERY = "org.apache.webbeans.spi.deployer.useEjbMetaDataDiscoveryService";
+    
+    /**Container lifecycle*/
+    public static final String CONTAINER_LIFECYCLE = "org.apache.webbeans.spi.ContainerLifecycle";
+    
+    /**JNDI Service SPI*/
+    public static final String JNDI_SERVICE = "org.apache.webbeans.spi.JNDIService";    
+    
+    /**Scanner Service*/
+    public static final String SCANNER_SERVICE = "org.apache.webbeans.spi.ScannerService";
+
+    /**Contexts Service*/
+    public static final String CONTEXTS_SERVICE = "org.apache.webbeans.spi.ContextsService";
+    
+    /**Conversation Service*/
+    public static final String CONVERSATION_SERVICE = "org.apache.webbeans.spi.ConversationService";
+    
+    /**Resource Injection Service*/
+    public static final String RESOURCE_INJECTION_SERVICE = "org.apache.webbeans.spi.ResourceInjectionService";
+    
+    /**Security Service*/
+    public static final String SECURITY_SERVICE = "org.apache.webbeans.spi.SecurityService";
+    
+    /**Validator Service*/
+    public static final String VALIDATOR_SERVICE = "org.apache.webbeans.spi.ValidatorService";
     
-    public static final String CONTAINER_LIFECYCLE = "org.apache.webbeans.spi.lifecycle";
+    /**Transaction Service*/
+    public static final String TRANSACTION_SERVICE = "org.apache.webbeans.spi.TransactionService";
     
-    public static final String APPLICATION_IS_JSP = "org.apache.webbeans.application.jspf";
+    /**Application is core JSP*/
+    public static final String APPLICATION_IS_JSP = "org.apache.webbeans.application.jsp";
     
+    /**Use of JSF2 extnesions*/
     public static final String USE_JSF2_EXTENSIONS = "org.apache.webbeans.application.useJSF2Extensions";
     
-    public static OpenWebBeansConfiguration getInstance() {
+    /**
+     * Gets singleton instance.
+     * @return singleton instance
+     */
+    public static OpenWebBeansConfiguration getInstance() 
+    {
         return (OpenWebBeansConfiguration) WebBeansFinder.getSingletonInstance(OpenWebBeansConfiguration.class.getName());
     }
     
+    /**
+     * Parse configuration.
+     */
     public OpenWebBeansConfiguration()
     {
         parseConfiguration();
+        
+        logger.debug("Overriden properties from System prpoerties");
+        
+        //Look for System properties
+        loadFromSystemProperties();        
+    }
+    
+    /**
+     * Load from system properties
+     */
+    private void loadFromSystemProperties()
+    {
+        Properties properties = System.getProperties();
+        
+        String value = properties.getProperty(CONVERSATION_PERIODIC_DELAY);
+        setPropertyFromSystemProperty(CONVERSATION_PERIODIC_DELAY, value);        
+        
+        value = properties.getProperty(USE_EJB_DISCOVERY);
+        setPropertyFromSystemProperty(USE_EJB_DISCOVERY, value);
+        
+        value = properties.getProperty(CONTAINER_LIFECYCLE);
+        setPropertyFromSystemProperty(CONTAINER_LIFECYCLE, value);
+
+        value = properties.getProperty(USE_JSF2_EXTENSIONS);
+        setPropertyFromSystemProperty(USE_JSF2_EXTENSIONS, value);
+
+        value = properties.getProperty(APPLICATION_IS_JSP);
+        setPropertyFromSystemProperty(APPLICATION_IS_JSP, value);
+
+        value = properties.getProperty(TRANSACTION_SERVICE);
+        setPropertyFromSystemProperty(TRANSACTION_SERVICE, value);
+
+        value = properties.getProperty(VALIDATOR_SERVICE);
+        setPropertyFromSystemProperty(VALIDATOR_SERVICE, value);
+
+        value = properties.getProperty(SECURITY_SERVICE);
+        setPropertyFromSystemProperty(SECURITY_SERVICE, value);
+
+        value = properties.getProperty(RESOURCE_INJECTION_SERVICE);
+        setPropertyFromSystemProperty(RESOURCE_INJECTION_SERVICE, value);
+
+        value = properties.getProperty(CONVERSATION_SERVICE);
+        setPropertyFromSystemProperty(CONVERSATION_SERVICE, value);
+
+        value = properties.getProperty(CONTEXTS_SERVICE);
+        setPropertyFromSystemProperty(CONTEXTS_SERVICE, value);
+
+        value = properties.getProperty(SCANNER_SERVICE);
+        setPropertyFromSystemProperty(SCANNER_SERVICE, value);
+
+        value = properties.getProperty(JNDI_SERVICE);
+        setPropertyFromSystemProperty(JNDI_SERVICE, value);
+    }
+     
+    private void setPropertyFromSystemProperty(String key, String value)
+    {
+        if(value != null)
+        {
+            setProperty(key, value);
+        }
     }
     
     /**
@@ -120,6 +223,7 @@
     }
     
     /**
+     * Gets property.
      * @param key
      * @return String with the property value or <code>null</code>
      */
@@ -129,6 +233,7 @@
     }
     
     /**
+     * Gets property value.
      * @param key
      * @param defaultValue
      * @return String with the property value or <code>null</code>
@@ -138,11 +243,22 @@
         return configProperties.getProperty(key, defaultValue);
     }
     
-    public void setProperty(String key, Object value)
+    
+    /**
+     * Sets given property.
+     * @param key property name
+     * @param value property value
+     */
+    public synchronized void setProperty(String key, Object value)
     {
         configProperties.put(key, value);
     }
     
+    /**
+     * Returns true if owb specific injection
+     * false otherwise.
+     * @return true if owb specific injection
+     */
     public boolean isOwbSpecificFieldInjection()
     {
         String value = getProperty(USE_OWB_SPECIFIC_FIELD_INJECTION);
@@ -150,6 +266,10 @@
         return Boolean.valueOf(value);
     }
     
+    /**
+     * Return true if use JSF2.
+     * @return true if use JSF2
+     */
     public boolean isUseJSF2Extensions()
     {
         String value = getProperty(USE_JSF2_EXTENSIONS);
@@ -158,11 +278,15 @@
         
     }
     
+    /**
+     * Gets jsp property.
+     * @return true if jsp
+     */
     public boolean isJspApplication()
     {
         String value = getProperty(APPLICATION_IS_JSP);
         
         return Boolean.valueOf(value);
     }
-        
+    
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansFinder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansFinder.java?rev=919885&r1=919884&r2=919885&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansFinder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansFinder.java Sun Mar  7 00:07:58 2010
@@ -17,7 +17,6 @@
 import java.util.Map;
 
 import org.apache.webbeans.container.BeanManagerImpl;
-import org.apache.webbeans.context.SessionContextManager;
 import org.apache.webbeans.context.creational.CreationalContextFactory;
 import org.apache.webbeans.conversation.ConversationManager;
 import org.apache.webbeans.decorator.DecoratorsManager;
@@ -48,7 +47,7 @@
 
     public static final String SINGLETON_CREATIONAL_CONTEXT_FACTORY = CreationalContextFactory.class.getName();
     
-    public static final String SINGLETON_SESSION_CONTEXT_MANAGER = SessionContextManager.class.getName();
+    public static final String SINGLETON_SESSION_CONTEXT_MANAGER = "org.apache.webbeans.web.context.SessionContextManager";
     
     public static final String SINGLETON_WEBBEANS_NAMESPACE_CONTAINER = WebBeansNameSpaceContainer.class.getName();
 

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContextsService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContextsService.java?rev=919885&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContextsService.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContextsService.java Sun Mar  7 00:07:58 2010
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.context;
+
+import java.lang.annotation.Annotation;
+
+import javax.enterprise.context.ContextException;
+import javax.enterprise.context.spi.Context;
+
+import org.apache.webbeans.spi.ContextsService;
+
+public abstract class AbstractContextsService implements ContextsService
+{
+
+    @Override
+    public void destroy(Object destroyObject)
+    {
+        //Default no-op
+    }
+
+    @Override
+    public void endContext(Class<? extends Annotation> scopeType, Object endParameters)
+    {
+        //Default no-op
+    }
+
+    @Override
+    public Context getCurrentContext(Class<? extends Annotation> scopeType)
+    {
+        
+        return null;
+    }
+
+    @Override
+    public void init(Object initializeObject)
+    {
+        //Default no-op        
+    }
+
+    @Override
+    public void startContext(Class<? extends Annotation> scopeType, Object startParameter) throws ContextException
+    {
+        //Default no-op        
+    }
+
+    @Override
+    public boolean supportsContext(Class<? extends Annotation> scopeType)
+    {        
+        return false;
+    }
+
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContextsService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ApplicationContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ApplicationContext.java?rev=919885&r1=919884&r2=919885&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ApplicationContext.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ApplicationContext.java Sun Mar  7 00:07:58 2010
@@ -25,7 +25,7 @@
  */
 public class ApplicationContext extends AbstractContext
 {
-    protected ApplicationContext()
+    public ApplicationContext()
     {
         super(ContextTypes.APPLICATION);
     }

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=919885&r1=919884&r2=919885&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 Sun Mar  7 00:07:58 2010
@@ -14,102 +14,46 @@
 package org.apache.webbeans.context;
 
 import java.lang.annotation.Annotation;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
 
 import javax.enterprise.context.*;
 import javax.enterprise.context.spi.Context;
 import javax.inject.Singleton;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletRequestEvent;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
 
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.context.type.ContextTypes;
-import org.apache.webbeans.conversation.ConversationManager;
+import org.apache.webbeans.logger.WebBeansLogger;
+import org.apache.webbeans.spi.ContextsService;
+import org.apache.webbeans.spi.ServiceLoader;
 
 /**
- * Gets current {@link WebBeansContext} instances on the current thread context.
- * 
- * @see WebBeansContext
- * @see AbstractContext
+ * JSR-299 based standard context
+ * related operations.
  */
 public final class ContextFactory
 {
-    private static ThreadLocal<RequestContext> requestContext = null;
-
-    private static ThreadLocal<SessionContext> sessionContext = null;
-
-    private static ThreadLocal<ApplicationContext> applicationContext = null;
-
-    private static ThreadLocal<ConversationContext> conversationContext = null;
+    /**Logger instance*/
+    private static final WebBeansLogger logger = WebBeansLogger.getLogger(ContextFactory.class);
     
-    private static ThreadLocal<SingletonContext> singletonContext = null;
-
-    private static ThreadLocal<DependentContext> dependentContext = null;
-
-    private static Map<ServletContext, ApplicationContext> currentApplicationContexts = new ConcurrentHashMap<ServletContext, ApplicationContext>();
+    /**Underlying context service*/
+    private static ContextsService contextService = ServiceLoader.getService(ContextsService.class);
     
-    private static Map<ServletContext, SingletonContext> currentSingletonContexts = new ConcurrentHashMap<ServletContext, SingletonContext>();
-
-    private static SessionContextManager sessionCtxManager = SessionContextManager.getInstance();
-
-    private static ConversationManager conversationManager = ConversationManager.getInstance();
-
-    static
-    {
-        requestContext = new ThreadLocal<RequestContext>();
-        sessionContext = new ThreadLocal<SessionContext>();
-        applicationContext = new ThreadLocal<ApplicationContext>();
-        conversationContext = new ThreadLocal<ConversationContext>();
-        dependentContext = new ThreadLocal<DependentContext>();
-        singletonContext = new ThreadLocal<SingletonContext>();
-    }
-
+    /**
+     * Not-instantiate
+     */
     private ContextFactory()
     {
         throw new UnsupportedOperationException();
     }
     
-    public static void initializeThreadLocals()
+    public static void initRequestContext(Object request)
     {
-        requestContext.remove();
-        sessionContext.remove();
-        applicationContext.remove();
-        conversationContext.remove();
-        dependentContext.remove();
-        singletonContext.remove();
-    }
-
-    /**
-     * Initialize requext context with the given request object.
-     * 
-     * @param event http servlet request event
-     */
-    public static void initRequestContext(ServletRequestEvent event)
-    {
-        RequestContext rq = new RequestContext();
-        rq.setActive(true);
-
-        requestContext.set(rq);// set thread local
-        if(event != null)
+        try
         {
-            HttpServletRequest request = (HttpServletRequest) event.getServletRequest();
-            
-            if (request != null)
-            {
-                //Re-initialize thread local for session
-                HttpSession session = request.getSession(false);
-                
-                if(session != null)
-                {
-                    initSessionContext(session);    
-                }
-                            
-                initApplicationContext(event.getServletContext());                
-                initSingletonContext(event.getServletContext());
-            }            
+            contextService.startContext(RequestScoped.class, request);
+        }
+        catch (Exception e)
+        {
+            logger.error(e);
         }
     }
 
@@ -119,74 +63,30 @@
         {
             return new CustomPassivatingContextImpl(context);
         }
+        
         return new CustomContextImpl(context);
     }
     
-    /**
-     * Destroys the request context and all of its components.
-     * 
-     * @param request http servlet request object
-     */
-    public static void destroyRequestContext(HttpServletRequest request)
+    public static void destroyRequestContext(Object request)
     {
-        if (requestContext != null)
-        {
-            RequestContext context = getRequestContext();
-
-            if (context != null)
-            {
-                context.destroy();
-            }
-
-            requestContext.remove();
-            
-        }
+        contextService.endContext(RequestScoped.class, request);
     }
 
-    /**
-     * Creates the session context at the session start.
-     * 
-     * @param session http session object
-     */
-    public static void initSessionContext(HttpSession session)
+    public static void initSessionContext(Object session)
     {
-        String sessionId = session.getId();
-        SessionContext currentSessionContext = sessionCtxManager.getSessionContextWithSessionId(sessionId);
-
-        if (currentSessionContext == null)
+        try
         {
-            currentSessionContext = new SessionContext();
-            sessionCtxManager.addNewSessionContext(sessionId, currentSessionContext);
+            contextService.startContext(SessionScoped.class, session);
         }
-
-        currentSessionContext.setActive(true);
-
-        sessionContext.set(currentSessionContext);
-    }
-
-    /**
-     * Destroys the session context and all of its components at the end of the
-     * session.
-     * 
-     * @param session http session object
-     */
-    public static void destroySessionContext(HttpSession session)
-    {
-        if (sessionContext != null)
+        catch (Exception e)
         {
-            SessionContext context = getSessionContext();
-
-            if (context != null)
-            {
-                context.destroy();
-            }
-
-            sessionContext.remove();
-
+            logger.error(e);
         }
+    }
 
-        sessionCtxManager.destroySessionContextWithSessionId(session.getId());
-
+    public static void destroySessionContext(Object session)
+    {
+        contextService.endContext(SessionScoped.class, session);
     }
 
     /**
@@ -194,27 +94,15 @@
      * 
      * @param servletContext servlet context object
      */
-    public static void initApplicationContext(ServletContext servletContext)
+    public static void initApplicationContext(Object servletContext)
     {
-        
-        if(servletContext != null && currentApplicationContexts.containsKey(servletContext))
+        try
         {
-            applicationContext.set(currentApplicationContexts.get(servletContext));
+            contextService.startContext(ApplicationScoped.class, servletContext);
         }
-        
-        else
+        catch (Exception e)
         {
-            ApplicationContext currentApplicationContext = new ApplicationContext();         
-            currentApplicationContext.setActive(true);
-            
-            if(servletContext != null)
-            {
-                currentApplicationContexts.put(servletContext, currentApplicationContext);
-                
-            }
-            
-            applicationContext.set(currentApplicationContext);
-   
+            logger.error(e);
         }
     }
 
@@ -224,112 +112,43 @@
      * 
      * @param servletContext servlet context object
      */
-    public static void destroyApplicationContext(ServletContext servletContext)
+    public static void destroyApplicationContext(Object servletContext)
     {
-        if (applicationContext != null)
-        {
-            ApplicationContext context = getApplicationContext();
-
-            if (context != null)
-            {
-                context.destroy();
-            }
-
-            applicationContext.remove();
-
-        }
-        
-        if(servletContext != null)
-        {
-            currentApplicationContexts.remove(servletContext);   
-        }
-        
-        sessionCtxManager.destroyAllSessions();
-        conversationManager.destroyAllConversations();
+        contextService.endContext(ApplicationScoped.class, servletContext);
     }
     
-    public static void initSingletonContext(ServletContext servletContext)
+    public static void initSingletonContext(Object servletContext)
     {
-        if(servletContext != null && currentSingletonContexts.containsKey(servletContext))
+        try
         {
-            singletonContext.set(currentSingletonContexts.get(servletContext));
+            contextService.startContext(Singleton.class, servletContext);
         }
-        
-        else
+        catch (Exception e)
         {
-            SingletonContext context = new SingletonContext();
-            context.setActive(true);
-            
-            if(servletContext != null)
-            {
-                currentSingletonContexts.put(servletContext, context);
-                
-            }
-            
-            singletonContext.set(context);
-   
+            logger.error(e);            
         }
-                        
     }
     
-    public static void destroySingletonContext(ServletContext servletContext)
+    public static void destroySingletonContext(Object servletContext)
     {
-        if (singletonContext != null)
-        {
-            SingletonContext context = getSingletonContext();
-
-            if (context != null)
-            {
-                context.destroy();
-            }
-            
-            singletonContext.remove();            
-
-        }
-        
-        if(servletContext != null)
-        {
-            currentSingletonContexts.remove(servletContext);   
-        }                
+        contextService.endContext(Singleton.class, servletContext);
     }
 
-    public static void initConversationContext(ConversationContext context)
+    public static void initConversationContext(Object context)
     {
-        if (context == null)
+        try
         {
-            if(conversationContext.get() == null)
-            {
-                ConversationContext newContext = new ConversationContext();
-                newContext.setActive(true);
-                
-                conversationContext.set(newContext);                
-            }
-            else
-            {
-                conversationContext.get().setActive(true);
-            }
-            
+            contextService.startContext(ConversationScoped.class, context);
         }
-        else
+        catch (Exception e)
         {
-            context.setActive(true);
-            conversationContext.set(context);
+            logger.error(e);            
         }
     }
 
     public static void destroyConversationContext()
     {
-        if (conversationContext != null)
-        {
-            ConversationContext context = getConversationContext();
-
-            if (context != null)
-            {
-                context.destroy();
-            }
-
-            conversationContext.remove();
-        }
+        contextService.endContext(ConversationScoped.class, null);
     }
 
     /**
@@ -339,32 +158,36 @@
      * @throws ContextNotActiveException if context is not active
      * @throws IllegalArgumentException if the type is not a standard context
      */
-    public static WebBeansContext getStandartContext(ContextTypes type) throws ContextNotActiveException
+    public static Context getStandartContext(ContextTypes type) throws ContextNotActiveException
     {
-        WebBeansContext context = null;
+        Context context = null;
 
         switch (type.getCardinal())
         {
             case 0:
-                context = getRequestContext();
+                context = (Context)contextService.getCurrentContext(RequestScoped.class);
                 break;
     
             case 1:
-                context = getSessionContext();
+                context = (Context)contextService.getCurrentContext(SessionScoped.class);
                 break;
     
             case 2:
-                context = getApplicationContext();
+                context = (Context)contextService.getCurrentContext(ApplicationScoped.class);
                 break;
     
             case 3:
-                context = getConversationContext();
+                context = (Context)contextService.getCurrentContext(ConversationScoped.class);
                 break;
                 
             case 4:
-                context = getDependentContext();
+                context = (Context)contextService.getCurrentContext(Dependent.class);
+                break;
+
+            case 5:
+                context = (Context)contextService.getCurrentContext(Singleton.class);
                 break;
-            
+                
             default:
                 throw new IllegalArgumentException("There is no such a standard context with context id=" + type.getCardinal());
         }
@@ -377,83 +200,36 @@
      * 
      * @return the current context, or <code>null</code> if no standard context exists for the given scopeType
      */
-    public static WebBeansContext getStandardContext(Class<? extends Annotation> scopeType)
+    public static Context getStandardContext(Class<? extends Annotation> scopeType)
     {
-        WebBeansContext context = null;
+        Context context = null;
 
         if (scopeType.equals(RequestScoped.class))
         {
-            context = getRequestContext();
+            context = getStandartContext(ContextTypes.REQUEST);
         }
         else if (scopeType.equals(SessionScoped.class))
         {
-            context = getSessionContext();
+            context = getStandartContext(ContextTypes.SESSION);
         }
         else if (scopeType.equals(ApplicationScoped.class))
         {
-            context = getApplicationContext();
+            context = getStandartContext(ContextTypes.APPLICATION);
         }
         else if (scopeType.equals(ConversationScoped.class))
         {
-            context = getConversationContext();
+            context = getStandartContext(ContextTypes.CONVERSATION);
 
         }
         else if (scopeType.equals(Dependent.class))
         {
-            context = getDependentContext();
+            context = getStandartContext(ContextTypes.DEPENDENT);
         }
         else if (scopeType.equals(Singleton.class))
         {
-            context = getSingletonContext();
+            context = getStandartContext(ContextTypes.SINGLETON);
         }
         
         return context;
     }
-
-    /*
-     * Get current request ctx.
-     */
-    private static RequestContext getRequestContext()
-    {
-        return requestContext.get();
-    }
-
-    /*
-     * Get current session ctx.
-     */
-    private static SessionContext getSessionContext()
-    {
-        return sessionContext.get();
-    }
-
-    private static ApplicationContext getApplicationContext()
-    {
-        return applicationContext.get();
-    }
-
-    private static SingletonContext getSingletonContext()
-    {
-        return singletonContext.get();
-    }
-
-    /*
-     * Get current conversation ctx.
-     */
-    private static ConversationContext getConversationContext()
-    {
-        return conversationContext.get();
-    }
-
-    public static DependentContext getDependentContext()
-    {
-        DependentContext dependentCtx = dependentContext.get();
-
-        if (dependentCtx == null)
-        {
-            dependentCtx = new DependentContext();
-            dependentContext.set(dependentCtx);
-        }
-
-        return dependentCtx;
-    }     
 }
\ No newline at end of file

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/RequestContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/RequestContext.java?rev=919885&r1=919884&r2=919885&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/RequestContext.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/RequestContext.java Sun Mar  7 00:07:58 2010
@@ -30,7 +30,7 @@
     /*
      * Constructor
      */
-    protected RequestContext()
+    public RequestContext()
     {
         super(ContextTypes.REQUEST);
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/SessionContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/SessionContext.java?rev=919885&r1=919884&r2=919885&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/SessionContext.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/SessionContext.java Sun Mar  7 00:07:58 2010
@@ -24,7 +24,7 @@
  */
 public class SessionContext extends AbstractContext
 {
-    protected SessionContext()
+    public SessionContext()
     {
         super(ContextTypes.SESSION);
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/SingletonContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/SingletonContext.java?rev=919885&r1=919884&r2=919885&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/SingletonContext.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/SingletonContext.java Sun Mar  7 00:07:58 2010
@@ -25,7 +25,7 @@
  */
 public class SingletonContext extends AbstractContext
 {
-    protected SingletonContext()
+    public SingletonContext()
     {
         super(ContextTypes.SINGLETON);
     }

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=919885&r1=919884&r2=919885&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 Sun Mar  7 00:07:58 2010
@@ -88,6 +88,7 @@
         BeanManager manager = BeanManagerImpl.getManager();
         while (itList.hasNext())
         {
+            @SuppressWarnings("unchecked")
             WebBeansDecorator<Object> decorator = (WebBeansDecorator<Object>) itList.next();
             CreationalContext<Object> creationalContext = manager.createCreationalContext(decorator);
             Object decoratorInstance = manager.getReference(decorator, decorator.getBeanClass(), creationalContext);

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WebBeansELResolver.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WebBeansELResolver.java?rev=919885&r1=919884&r2=919885&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WebBeansELResolver.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WebBeansELResolver.java Sun Mar  7 00:07:58 2010
@@ -25,7 +25,6 @@
 import javax.enterprise.context.Dependent;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
-import javax.servlet.jsp.JspApplicationContext;
 
 import org.apache.webbeans.container.BeanManagerImpl;
 

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=919885&r1=919884&r2=919885&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 Sun Mar  7 00:07:58 2010
@@ -38,9 +38,6 @@
 import javax.enterprise.inject.spi.ObserverMethod;
 import javax.enterprise.inject.spi.ProcessObserverMethod;
 import javax.enterprise.util.TypeLiteral;
-import javax.transaction.Status;
-import javax.transaction.Synchronization;
-import javax.transaction.Transaction;
 
 import org.apache.webbeans.annotation.AnyLiteral;
 import org.apache.webbeans.component.InjectionTargetBean;
@@ -65,8 +62,6 @@
 
     private final Map<Type, Set<ObserverMethod<?>>> observers = new ConcurrentHashMap<Type, Set<ObserverMethod<?>>>();
 
-    private final TransactionService transactionService = ServiceLoader.getService(TransactionService.class);
-
     public NotificationManager()
     {
 
@@ -406,8 +401,6 @@
 
     public void fireEvent(Object event, Annotation... qualifiers)
     {
-        Transaction transaction = transactionService.getTransaction();
-
         Set<ObserverMethod<? super Object>> observers = resolveObservers(event, qualifiers);
 
         for (ObserverMethod<? super Object> observer : observers)
@@ -415,28 +408,10 @@
             try
             {
                 TransactionPhase phase = observer.getTransactionPhase();
-                if (transaction != null && phase != null)
+                TransactionService transactionService = ServiceLoader.getService(TransactionService.class);
+                if(transactionService != null)
                 {
-                    if (phase.equals(TransactionPhase.AFTER_COMPLETION))
-                    {
-                        transaction.registerSynchronization(new AfterCompletion(observer, event));
-                    }
-                    else if (phase.equals(TransactionPhase.AFTER_SUCCESS))
-                    {
-                        transaction.registerSynchronization(new AfterCompletionSuccess(observer, event));
-                    }
-                    else if (phase.equals(TransactionPhase.AFTER_FAILURE))
-                    {
-                        transaction.registerSynchronization(new AfterCompletionFailure(observer, event));
-                    }
-                    else if (phase.equals(TransactionPhase.BEFORE_COMPLETION))
-                    {
-                        transaction.registerSynchronization(new BeforeCompletion(observer, event));
-                    }
-                    else
-                    {
-                        throw new IllegalStateException(logger.getTokenString(OWBLogConst.EXCEPT_0007) + phase);
-                    }
+                    transactionService.registerTransactionSynchronization(phase, observer, event);
                 }
                 else
                 {
@@ -502,102 +477,4 @@
 
         return observerMethods;
     }
-
-
-    private static class AbstractSynchronization<T> implements Synchronization
-    {
-
-        private final ObserverMethod<T> observer;
-        private final T event;
-
-        public AbstractSynchronization(ObserverMethod<T> observer, T event)
-        {
-            this.observer = observer;
-            this.event = event;
-        }
-
-        public void beforeCompletion()
-        {
-            // Do nothing
-        }
-
-        public void afterCompletion(int i)
-        {
-            //Do nothing
-        }
-
-        public void notifyObserver()
-        {
-            try
-            {
-                observer.notify(event);
-            }
-            catch (Exception e)
-            {
-                logger.error(OWBLogConst.ERROR_0003, e);
-            }
-        }
-    }
-
-    private static class BeforeCompletion extends AbstractSynchronization
-    {
-        private BeforeCompletion(ObserverMethod observer, Object event)
-        {
-            super(observer, event);
-        }
-
-        @Override
-        public void beforeCompletion()
-        {
-            notifyObserver();
-        }
-    }
-
-    private static class AfterCompletion extends AbstractSynchronization
-    {
-        private AfterCompletion(ObserverMethod observer, Object event)
-        {
-            super(observer, event);
-        }
-
-        @Override
-        public void afterCompletion(int i)
-        {
-            notifyObserver();
-        }
-    }
-
-    private static class AfterCompletionSuccess extends AbstractSynchronization
-    {
-        private AfterCompletionSuccess(ObserverMethod observer, Object event)
-        {
-            super(observer, event);
-        }
-
-        @Override
-        public void afterCompletion(int i)
-        {
-            if (i == Status.STATUS_COMMITTED)
-            {
-                notifyObserver();
-            }
-        }
-    }
-
-    private static class AfterCompletionFailure extends AbstractSynchronization
-    {
-        private AfterCompletionFailure(ObserverMethod observer, Object event)
-        {
-            super(observer, event);
-        }
-
-        @Override
-        public void afterCompletion(int i)
-        {
-            if (i != Status.STATUS_COMMITTED)
-            {
-                notifyObserver();
-            }
-        }
-    }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/xml/BeanObserverXMLImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/xml/BeanObserverXMLImpl.java?rev=919885&r1=919884&r2=919885&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/xml/BeanObserverXMLImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/xml/BeanObserverXMLImpl.java Sun Mar  7 00:07:58 2010
@@ -48,6 +48,7 @@
      * .Object)
      */
     @Override
+    @SuppressWarnings("unchecked")
     protected List getMethodArguments(Object event)
     {
         List<Object> params = new ArrayList<Object>();

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/OWBInjector.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/OWBInjector.java?rev=919885&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/OWBInjector.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/OWBInjector.java Sun Mar  7 00:07:58 2010
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.inject;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.InjectionTarget;
+
+import org.apache.webbeans.container.BeanManagerImpl;
+import org.apache.webbeans.util.ClassUtil;
+
+/**
+ * Injects dependencies of the given Java EE component
+ * instance.
+ * 
+ * @version $Rev$ $Date$
+ *
+ */
+public final class OWBInjector
+{
+    private OWBInjector()
+    {
+        
+    }
+    
+    @SuppressWarnings("unchecked")
+    public static void inject(Object javaEeComponentInstance) throws Exception
+    {
+        BeanManager beanManager = BeanManagerImpl.getManager();
+        try
+        {
+            Class<?> injectableComponentClass = javaEeComponentInstance.getClass();
+            AnnotatedType<Object> annotated = (AnnotatedType<Object>) beanManager.createAnnotatedType(injectableComponentClass);
+            InjectionTarget<Object> injectionTarget = beanManager.createInjectionTarget(annotated);
+            Set<InjectionPoint> injectionPoints = injectionTarget.getInjectionPoints();
+            if(injectionPoints != null && injectionPoints.size() > 0)
+            {
+                for(InjectionPoint injectionPoint : injectionPoints)
+                {
+                    Object object = beanManager.getInjectableReference(injectionPoint, beanManager.createCreationalContext(injectionPoint.getBean()));
+                    if(injectionPoint.getMember() instanceof Method)
+                    {
+                        Method method = (Method)injectionPoint.getMember();
+                        ClassUtil.callInstanceMethod(method, javaEeComponentInstance, new Object[]{object});                        
+                    }
+                    else if(injectionPoint.getMember() instanceof Field)
+                    {
+                        Field field = (Field)injectionPoint.getMember();
+                        ClassUtil.setField(javaEeComponentInstance, field, object);
+                    }
+                }
+            }
+            
+            
+        }catch(Exception e)
+        {
+            throw e;
+        }
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/OWBInjector.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InvocationContextImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InvocationContextImpl.java?rev=919885&r1=919884&r2=919885&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InvocationContextImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InvocationContextImpl.java Sun Mar  7 00:07:58 2010
@@ -15,7 +15,6 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java?rev=919885&r1=919884&r2=919885&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java Sun Mar  7 00:07:58 2010
@@ -29,6 +29,7 @@
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
 
+@SuppressWarnings("unchecked")
 public class NormalScopedBeanInterceptorHandler extends InterceptorHandler 
 {
     private static final long serialVersionUID = -7169354477951284657L;
@@ -45,11 +46,10 @@
     @Override
     public Object invoke(Object instance, Method method, Method proceed, Object[] arguments) throws Exception
     {
-        @SuppressWarnings("unchecked")
         Object webbeansInstance = getContextualInstance((OwbBean<Object>) bean, (CreationalContext<Object>) creationalContext);
         return super.invoke(webbeansInstance, method, proceed, arguments, (CreationalContextImpl<?>) creationalContext);
     }
-    
+        
     protected <T> Object callAroundInvokes(Method proceed, Object[] arguments, List<InterceptorData> stack) throws Exception
     {
         InvocationContextImpl impl = new InvocationContextImpl(bean, 
@@ -81,8 +81,8 @@
         Context webbeansContext = getBeanManager().getContext(bean.getScope());
 
         //Get bean instance from context
-        @SuppressWarnings("unchecked")
         Object webbeansInstance = webbeansContext.get((Contextual<Object>)this.bean, (CreationalContext<Object>) creationalContext);
+        
         return webbeansInstance;
     }
 }

Added: 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=919885&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java Sun Mar  7 00:07:58 2010
@@ -0,0 +1,249 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.lifecycle;
+
+import java.lang.annotation.Annotation;
+import java.util.Properties;
+
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.apache.webbeans.WebBeansConstants;
+import org.apache.webbeans.config.BeansDeployer;
+import org.apache.webbeans.config.OWBLogConst;
+import org.apache.webbeans.config.WebBeansFinder;
+import org.apache.webbeans.container.BeanManagerImpl;
+import org.apache.webbeans.logger.WebBeansLogger;
+import org.apache.webbeans.plugins.PluginLoader;
+import org.apache.webbeans.portable.events.ExtensionLoader;
+import org.apache.webbeans.portable.events.discovery.BeforeShutdownImpl;
+import org.apache.webbeans.spi.ContainerLifecycle;
+import org.apache.webbeans.spi.ContextsService;
+import org.apache.webbeans.spi.JNDIService;
+import org.apache.webbeans.spi.ScannerService;
+import org.apache.webbeans.spi.ServiceLoader;
+import org.apache.webbeans.xml.WebBeansXMLConfigurator;
+
+public abstract class AbstractLifeCycle implements ContainerLifecycle
+{
+    //Logger instance
+    private final WebBeansLogger logger;
+    
+    /**Discover bean classes*/
+    protected ScannerService scannerService;
+    
+    protected final ContextsService contextsService;
+
+    /**Deploy discovered beans*/
+    private final BeansDeployer deployer;
+
+    /**XML discovery. */
+    //XML discovery is removed from the specification. It is here for next revisions of spec.
+    private final WebBeansXMLConfigurator xmlDeployer;
+    
+    /**Using for lookup operations*/
+    private final JNDIService jndiService;
+    
+    /**Root container.*/
+    private final BeanManagerImpl beanManager;
+    
+    protected AbstractLifeCycle()
+    {
+        this(null, WebBeansLogger.getLogger(AbstractLifeCycle.class));
+    }
+    
+    protected AbstractLifeCycle(Properties properties, WebBeansLogger logger)
+    {
+        beforeInitApplication(properties);
+        
+        this.beanManager = (BeanManagerImpl) WebBeansFinder.getSingletonInstance(WebBeansFinder.SINGLETON_MANAGER);
+        this.xmlDeployer = new WebBeansXMLConfigurator();
+        this.deployer = new BeansDeployer(xmlDeployer);
+        this.jndiService = ServiceLoader.getService(JNDIService.class);    
+        this.beanManager.setXMLConfigurator(this.xmlDeployer);
+        this.scannerService = ServiceLoader.getService(ScannerService.class);
+        this.contextsService = ServiceLoader.getService(ContextsService.class);
+        this.logger = logger;
+        
+        initApplication(properties);                
+    }
+
+    @Override
+    public BeanManager getBeanManager()
+    {        
+        return this.beanManager;
+    }
+    
+    @Override
+    public void startApplication(Object startupObject) throws Exception
+    {
+        // Initalize Application Context
+        logger.info("OpenWebBeans Container is starting...");
+        
+        long begin = System.currentTimeMillis();
+        
+        //Before Start
+        beforeStartApplication(startupObject);
+        
+        //Load all plugins
+        PluginLoader.getInstance().startUp();
+        
+        //Initialize contexts
+        this.contextsService.init(startupObject);
+        
+        //Scanning process
+        logger.debug("Scanning classpaths for beans artifacts.");
+
+        //Scan
+        this.scannerService.scan();
+        
+        //Deploy beans
+        logger.debug("Deploying scanned beans.");
+
+        //Deploy
+        deployer.deploy(this.scannerService);
+
+        //Start actual starting on sub-classes
+        afterStartApplication(startupObject);
+        
+        logger.info(OWBLogConst.INFO_0002, new Object[]{Long.toString(System.currentTimeMillis() - begin)});        
+    }
+
+    @Override
+    public void stopApplication(Object endObject)
+    {
+        logger.debug("OpenWebBeans Container is stopping.");
+
+        try
+        {
+            //Sub-classes operations            
+            beforeStopApplication(endObject);
+            
+            //Fire shut down
+            this.beanManager.fireEvent(new BeforeShutdownImpl(), new Annotation[0]);
+            
+            //Destroys context
+            this.contextsService.destroy(endObject);
+            
+            //Unbind BeanManager
+            jndiService.unbind(WebBeansConstants.WEB_BEANS_MANAGER_JNDI_NAME);
+
+            //Free all plugin resources
+            PluginLoader.getInstance().shutDown();
+            
+            //Clear extensions
+            ExtensionLoader.getInstance().clear();
+            
+            //Clear singleton list
+            WebBeansFinder.clearInstances();
+            
+            //After Stop
+            afterStopApplication(endObject);
+            
+        }
+        catch (Exception e)
+        {
+            logger.error("Error is occured while stopping the container",e);
+        }
+        
+    }
+
+    /**
+     * @return the logger
+     */
+    protected WebBeansLogger getLogger()
+    {
+        return logger;
+    }
+
+    /**
+     * @return the scannerService
+     */
+    protected ScannerService getScannerService()
+    {
+        return scannerService;
+    }
+
+    /**
+     * @return the contextsService
+     */
+    public ContextsService getContextService()
+    {
+        return contextsService;
+    }
+
+    /**
+     * @return the deployer
+     */
+    protected BeansDeployer getDeployer()
+    {
+        return deployer;
+    }
+
+    /**
+     * @return the xmlDeployer
+     */
+    protected WebBeansXMLConfigurator getXmlDeployer()
+    {
+        return xmlDeployer;
+    }
+
+    /**
+     * @return the jndiService
+     */
+    protected JNDIService getJndiService()
+    {
+        return jndiService;
+    }
+
+    @Override
+    public void initApplication(Properties properties)
+    {
+        afterInitApplication(properties);
+    }    
+    
+    protected void beforeInitApplication(Properties properties)
+    {
+        //Do nothing as default
+    }
+    
+    protected void afterInitApplication(Properties properties)
+    {
+        //Do nothing as default
+    }
+        
+    protected void afterStartApplication(Object startupObject) throws Exception
+    {
+        //Do nothing as default
+    }
+
+    protected void afterStopApplication(Object stopObject) throws Exception
+    {
+        //Do nothing as default
+    }
+    
+    protected void beforeStartApplication(Object startupObject) throws Exception
+    {
+        //Do nothing as default
+    }
+
+    protected void beforeStopApplication(Object stopObject) throws Exception
+    {
+        //Do nothing as default
+    }    
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/StandaloneLifeCycle.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/StandaloneLifeCycle.java?rev=919885&r1=919884&r2=919885&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/StandaloneLifeCycle.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/StandaloneLifeCycle.java Sun Mar  7 00:07:58 2010
@@ -13,177 +13,46 @@
  */
 package org.apache.webbeans.lifecycle;
 
-import java.lang.annotation.Annotation;
 import java.util.Properties;
-import java.util.concurrent.atomic.AtomicBoolean;
 
-import javax.enterprise.inject.spi.BeanManager;
-
-import org.apache.webbeans.WebBeansConstants;
-import org.apache.webbeans.config.BeansDeployer;
-import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.config.WebBeansFinder;
-import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.context.ContextFactory;
-import org.apache.webbeans.exception.WebBeansException;
 import org.apache.webbeans.logger.WebBeansLogger;
-import org.apache.webbeans.plugins.PluginLoader;
-import org.apache.webbeans.portable.events.ExtensionLoader;
-import org.apache.webbeans.portable.events.discovery.BeforeShutdownImpl;
-import org.apache.webbeans.spi.ContainerLifecycle;
-import org.apache.webbeans.spi.JNDIService;
-import org.apache.webbeans.spi.ScannerService;
-import org.apache.webbeans.spi.ServiceLoader;
-import org.apache.webbeans.spi.se.deployer.MetaDataDiscoveryStandard;
-import org.apache.webbeans.xml.WebBeansXMLConfigurator;
 
-public class StandaloneLifeCycle implements ContainerLifecycle
+public class StandaloneLifeCycle extends AbstractLifeCycle
 {
     private static final WebBeansLogger logger = WebBeansLogger.getLogger(StandaloneLifeCycle.class);
-    
-    /**Deploy discovered beans*/
-    private final BeansDeployer beansDeployer;
         
-    /**Root container.*/
-    protected final BeanManagerImpl beanManager;
-    
-    private AtomicBoolean inited = new AtomicBoolean(false);
-    
-    private AtomicBoolean started = new AtomicBoolean(false);
-    
-    private AtomicBoolean stopped = new AtomicBoolean(false);
-    
-    protected ScannerService discoveryService = null;
-    
-    protected final WebBeansXMLConfigurator xmlConfig;
-    
     public StandaloneLifeCycle()
     {
-        //Clear singletons
-        WebBeansFinder.clearInstances();
-
-        this.beanManager = BeanManagerImpl.getManager();
-        this.xmlConfig = new WebBeansXMLConfigurator();
-        this.beansDeployer = new BeansDeployer(this.xmlConfig);        
-
-        init();
+        super(null, logger);        
     }
     
-    public void init()
-    {
-        if(inited.compareAndSet(false, true))
-        {
-            discoveryService = ServiceLoader.getService(ScannerService.class);
-            
-            if(discoveryService == null)
-            {
-                logger.warn(OWBLogConst.WARN_0003);
-                
-                this.discoveryService = new MetaDataDiscoveryStandard();
-            }
-            else
-            {
-                logger.info(OWBLogConst.INFO_0001, new Object[]{discoveryService.getClass().toString()});
-            }
-            
-            beanManager.setXMLConfigurator(this.xmlConfig);        
-        }
-    }
-
-    public void applicationStarted(Object startupObject) throws WebBeansException
+    @Override
+    public void beforeInitApplication(Properties properties)
     {
-        if(this.started.compareAndSet(false, true))
-        {            
-            logger.debug("OpenWebBeans Container is starting.");
-            long begin = System.currentTimeMillis();
-            
-            //Singleton context
-            ContextFactory.initSingletonContext(null);
-
-            // load all optional plugins
-            PluginLoader.getInstance().startUp();
-
-            logger.debug("Scanning classpaths for beans artifacts.");
-
-            this.discoveryService.scan();
-
-            logger.debug("Deploying scanned beans.");
-
-            this.beansDeployer.deploy(this.discoveryService);
-                        
-            long end = System.currentTimeMillis();
-            
-            logger.info(OWBLogConst.INFO_0002, new Object[]{Long.toString(end - begin)});            
-            
-        }
-        else
-        {
-            logger.warn(OWBLogConst.WARN_0004);
-        }
-        
+        WebBeansFinder.clearInstances();
     }
     
-    public void applicationEnded(Object endObject)
-    {
-        if(this.stopped.compareAndSet(false, true))
-        {
-            logger.debug("OpenWebBeans Container is stopping.");
-            
-
-            //Fire shut down
-            this.beanManager.fireEvent(new BeforeShutdownImpl(), new Annotation[0]);
-            
-            JNDIService jndiService = ServiceLoader.getService(JNDIService.class);
-            
-            jndiService.unbind(WebBeansConstants.WEB_BEANS_MANAGER_JNDI_NAME);
-                    
-            ContextFactory.destroySingletonContext(null);
-
-            // finally free all plugin resources
-            PluginLoader.getInstance().shutDown();
-            
-            //Clear extensions
-            ExtensionLoader.getInstance().clear();
-
-            //Clear singleton list
-            WebBeansFinder.clearInstances();
-                    
-            logger.debug("OpenWebBeans Container has stopped.");        
-            
-        }
-        else
-        {
-            logger.warn(OWBLogConst.WARN_0005);
-        }        
-        
-    }
-
     @Override
-    public BeanManager getBeanManager()
+    public void beforeStartApplication(Object object)
     {
-        return this.beanManager;
+        ContextFactory.initRequestContext(null);
+        ContextFactory.initSessionContext(null);
+        ContextFactory.initConversationContext(null);
+        ContextFactory.initApplicationContext(null);       
+        ContextFactory.initSingletonContext(null);
     }
-
-    public ScannerService getDiscoveryService()
-    {
-        return this.discoveryService;
-    }
-
-    @Override
-    public void init(Properties properties)
-    {
         
-    }
-
-    @Override
-    public void start(Object startupObject) throws Exception
-    {
-        applicationStarted(startupObject);
-    }
-
+    
     @Override
-    public void stop(Object endObject)
+    public void beforeStopApplication(Object endObject)
     {
-      applicationEnded(endObject);        
+        ContextFactory.destroyRequestContext(null);
+        ContextFactory.destroySessionContext(null);
+        ContextFactory.destroyConversationContext();        
+        ContextFactory.destroyApplicationContext(null);   
+        ContextFactory.destroySingletonContext(null);
     }
-}
+    
+}
\ No newline at end of file

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=919885&r1=919884&r2=919885&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 Sun Mar  7 00:07:58 2010
@@ -13,9 +13,10 @@
  */
 package org.apache.webbeans.lifecycle.test;
 
-import org.apache.webbeans.context.ContextFactory;
-import org.apache.webbeans.exception.WebBeansException;
+import java.util.Properties;
+
 import org.apache.webbeans.lifecycle.StandaloneLifeCycle;
+import org.apache.webbeans.spi.ScannerService;
 
 /**
  * Ease the writing of the tests. Simulates container
@@ -27,47 +28,19 @@
  */
 public class OpenWebBeansTestLifeCycle extends StandaloneLifeCycle
 {
-    private MockServletContextEvent servletContextEvent;
-    
-    private MockHttpSession mockHttpSession;
-
     public OpenWebBeansTestLifeCycle()
     {
         super();
     }
     
     @Override
-    public void init()
+    public void initApplication(Properties properties)
     {
-        this.mockHttpSession = new MockHttpSession();
-        this.servletContextEvent = new MockServletContextEvent();
-        
-        ContextFactory.initRequestContext(null);
-        ContextFactory.initSessionContext(mockHttpSession);
-        ContextFactory.initConversationContext(null);
-        ContextFactory.initApplicationContext(this.servletContextEvent.getServletContext());        
-        
-        this.discoveryService = new OpenWebBeansTestMetaDataDiscoveryService();
-        
-        this.beanManager.setXMLConfigurator(this.xmlConfig);        
-    }
-
-    @Override
-    public void applicationEnded(Object endObject)
+        this.scannerService = new OpenWebBeansTestMetaDataDiscoveryService();        
+    }    
+    
+    public ScannerService getScannerService()
     {
-        ContextFactory.destroyRequestContext(null);
-        ContextFactory.destroySessionContext(this.mockHttpSession);
-        ContextFactory.destroyConversationContext();
-        
-        super.applicationEnded(this.servletContextEvent);
-        
-        ContextFactory.destroyApplicationContext(this.servletContextEvent.getServletContext());        
-    }
-
-    @Override
-    public void applicationStarted(Object startupObject) throws WebBeansException
-    {                
-        super.applicationStarted(this.servletContextEvent);
+        return this.scannerService;
     }
-        
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/test/OpenWebBeansTestMetaDataDiscoveryService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/test/OpenWebBeansTestMetaDataDiscoveryService.java?rev=919885&r1=919884&r2=919885&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/test/OpenWebBeansTestMetaDataDiscoveryService.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/test/OpenWebBeansTestMetaDataDiscoveryService.java Sun Mar  7 00:07:58 2010
@@ -19,7 +19,7 @@
 
 import javassist.ClassPool;
 
-import org.apache.webbeans.spi.deployer.AbstractMetaDataDiscovery;
+import org.apache.webbeans.spi.scanner.AbstractMetaDataDiscovery;
 import org.apache.webbeans.util.Asserts;
 
 /**



Mime
View raw message