openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1677166 - in /openwebbeans/trunk: ./ samples/reservation/ samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/ samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/user/ samples/reservation/src/main/j...
Date Fri, 01 May 2015 15:23:48 GMT
Author: struberg
Date: Fri May  1 15:23:47 2015
New Revision: 1677166

URL: http://svn.apache.org/r1677166
Log:
upgrade myfaces and compiler plugin

Please note that we only use the latest MyFaces-2.0.x and not 2.2.x
as we don't like to accidently pick up newer JSF API methods

Added:
    openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/InitializeDatabase.java
Removed:
    openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/SessionContextManager.java
Modified:
    openwebbeans/trunk/pom.xml
    openwebbeans/trunk/samples/reservation/pom.xml
    openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/RegisterBean.java
    openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/user/UserReservationBean.java
    openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/security/JSFSecurityPhaseListener.java
    openwebbeans/trunk/samples/reservation/src/main/webapp/WEB-INF/web.xml
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContextsService.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/ConversationContext.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/SessionContext.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultContextsService.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
    openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/JsfConversationService.java
    openwebbeans/trunk/webbeans-jsf12/src/main/java/org/apache/webbeans/jsf12/Jsf12ConversationService.java
    openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/ContextsService.java
    openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/servlet/EndWebBeansConfigurationListener.java
    openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationFilter.java
    openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/WebContextsService.java
    openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/lifecycle/WebContainerLifecycle.java

Modified: openwebbeans/trunk/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/pom.xml?rev=1677166&r1=1677165&r2=1677166&view=diff
==============================================================================
--- openwebbeans/trunk/pom.xml (original)
+++ openwebbeans/trunk/pom.xml Fri May  1 15:23:47 2015
@@ -80,7 +80,7 @@
         <tomcat6.version>6.0.43</tomcat6.version>
         <tomcat7.version>7.0.61</tomcat7.version>
         <openejb.version>3.1.4</openejb.version>
-        <myfaces.version>2.0.7</myfaces.version>
+        <myfaces.version>2.0.23</myfaces.version>
         <xbean.version>4.1</xbean.version>
         <arquillian.version>1.1.2.Final</arquillian.version>
         <cdi.tck.version>1.2.4.Final</cdi.tck.version>
@@ -349,8 +349,9 @@
             </plugin>
 
             <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
-                <version>2.3.2</version>
+                <version>3.1</version>
                 <configuration>
                     <source>1.6</source>
                     <target>1.6</target>

Modified: openwebbeans/trunk/samples/reservation/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/reservation/pom.xml?rev=1677166&r1=1677165&r2=1677166&view=diff
==============================================================================
--- openwebbeans/trunk/samples/reservation/pom.xml (original)
+++ openwebbeans/trunk/samples/reservation/pom.xml Fri May  1 15:23:47 2015
@@ -36,102 +36,59 @@ under the License.
         <deploy.skip>true</deploy.skip>
     </properties>
 
-    <build>
-        <finalName>reservation</finalName>
-        <plugins>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>openjpa-maven-plugin</artifactId>
-                <version>1.2</version>
-                <configuration>
-                    <includes>org/apache/webbeans/reservation/entity/*.class</includes>
-                    <addDefaultConstructor>true</addDefaultConstructor>
-                    <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
-                    <sqlAction>build</sqlAction>
-                    <sqlFile>${project.build.directory}/database.sql</sqlFile>
-                </configuration>
-                <executions>
-                    <execution>
-                        <id>mappingtool</id>
-                        <phase>process-classes</phase>
-                        <goals>
-                            <goal>enhance</goal>
-                        </goals>
-                    </execution>
-                </executions>
-                <dependencies>
-                    <dependency>
-                        <groupId>log4j</groupId>
-                        <artifactId>log4j</artifactId>
-                        <version>1.2.14</version>
-                    </dependency>
-                    <dependency>
-                        <groupId>org.apache.openjpa</groupId>
-                        <artifactId>openjpa</artifactId>
-                        <version>2.0.1</version>
-                    </dependency>
-                </dependencies>
-            </plugin>
-
-        </plugins>
-    </build>
+    <!--
+     * Start this sample with
+     * $> mvn clean install tomcat7:run
+     *
+     * To debug it run with:
+     * $> mvnDebug tomcat7:run
+    -->
 
     <dependencies>
 
-        <!-- My Faces API -->
+        <!-- MyFaces IMPL -->
         <dependency>
             <groupId>org.apache.myfaces.core</groupId>
             <artifactId>myfaces-api</artifactId>
-            <scope>provided</scope>
         </dependency>
-
-        <!-- Servlet Api -->
         <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-servlet_3.0_spec</artifactId>
-            <scope>provided</scope>
+            <groupId>org.apache.myfaces.core</groupId>
+            <artifactId>myfaces-impl</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>jstl</artifactId>
+            <version>1.2</version>
         </dependency>
 
-        <!-- JPA API -->
+        <!-- CDI and atinject APIs -->
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-jpa_2.0_spec</artifactId>
-            <scope>provided</scope>
+            <artifactId>geronimo-jcdi_1.1_spec</artifactId>
         </dependency>
-
-        <!-- HSQLDB -->
         <dependency>
-            <groupId>hsqldb</groupId>
-            <artifactId>hsqldb</artifactId>
-            <version>1.8.0.7</version>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-atinject_1.0_spec</artifactId>
         </dependency>
-
-        <!-- EL API -->
+        <!-- Interceptor API -->
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-el_2.2_spec</artifactId>
-            <scope>provided</scope>
+            <artifactId>geronimo-interceptor_1.2_spec</artifactId>
         </dependency>
-
-        <!-- Common Validator -->
         <dependency>
-            <groupId>commons-validator</groupId>
-            <artifactId>commons-validator</artifactId>
-            <version>1.3.1</version>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-annotation_1.2_spec</artifactId>
         </dependency>
 
-        <!-- Interceptor API -->
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-interceptor_1.2_spec</artifactId>
+            <artifactId>geronimo-servlet_3.0_spec</artifactId>
             <scope>provided</scope>
         </dependency>
-
-        <!-- OWB Resource for Injections -->
         <dependency>
-            <groupId>org.apache.openwebbeans</groupId>
-            <artifactId>openwebbeans-resource</artifactId>
-            <version>${project.version}</version>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-el_2.2_spec</artifactId>
             <scope>provided</scope>
         </dependency>
 
@@ -140,19 +97,22 @@ under the License.
             <groupId>org.apache.openwebbeans</groupId>
             <artifactId>openwebbeans-impl</artifactId>
             <version>${project.version}</version>
-            <scope>provided</scope>
+            <scope>runtime</scope>
         </dependency>
 
+        <!-- Web Plugin -->
         <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-jcdi_1.1_spec</artifactId>
-            <scope>provided</scope>
+            <groupId>org.apache.openwebbeans</groupId>
+            <artifactId>openwebbeans-web</artifactId>
+            <version>${project.version}</version>
+            <scope>runtime</scope>
         </dependency>
-
+        <!-- pseudo PersistenceContext injection -->
         <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-atinject_1.0_spec</artifactId>
-            <scope>provided</scope>
+            <groupId>org.apache.openwebbeans</groupId>
+            <artifactId>openwebbeans-resource</artifactId>
+            <version>${project.version}</version>
+            <scope>runtime</scope>
         </dependency>
 
         <!-- JSF Plugin -->
@@ -160,24 +120,35 @@ under the License.
             <groupId>org.apache.openwebbeans</groupId>
             <artifactId>openwebbeans-jsf</artifactId>
             <version>${project.version}</version>
-            <scope>provided</scope>
+            <scope>runtime</scope>
         </dependency>
 
-        <!-- EL Plugin -->
+
+        <!-- OpenJPA -->
         <dependency>
-            <groupId>org.apache.openwebbeans</groupId>
-            <artifactId>openwebbeans-el10</artifactId>
-            <version>${project.version}</version>
-            <scope>provided</scope>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jpa_2.0_spec</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.openjpa</groupId>
+            <artifactId>openjpa</artifactId>
+            <version>2.4.0</version>
+            <scope>runtime</scope>
         </dependency>
 
+        <!-- HSQLDB -->
+        <dependency>
+            <groupId>hsqldb</groupId>
+            <artifactId>hsqldb</artifactId>
+            <version>1.8.0.7</version>
+            <scope>runtime</scope>
+        </dependency>
 
-        <!-- Web Plugin -->
+        <!-- Common Validator -->
         <dependency>
-            <groupId>org.apache.openwebbeans</groupId>
-            <artifactId>openwebbeans-web</artifactId>
-            <version>${project.version}</version>
-            <scope>provided</scope>
+            <groupId>commons-validator</groupId>
+            <artifactId>commons-validator</artifactId>
+            <version>1.3.1</version>
         </dependency>
 
         <dependency>
@@ -185,102 +156,51 @@ under the License.
             <artifactId>commons-logging</artifactId>
             <version>1.1.1</version>
         </dependency>
-
     </dependencies>
 
-    <profiles>
-        <profile>
-            <id>tomcat</id>
-            <build>
-                <plugins>
-                    <plugin>
-                        <groupId>org.apache.tomcat.maven</groupId>
-                        <artifactId>tomcat7-maven-plugin</artifactId>
-                    </plugin>
-                </plugins>
-            </build>
-            <dependencies>
-                <!-- MyFaces IMPL -->
-                <dependency>
-                    <groupId>org.apache.myfaces.core</groupId>
-                    <artifactId>myfaces-api</artifactId>
-                    <scope>compile</scope>
-                </dependency>
-                <dependency>
-                    <groupId>org.apache.myfaces.core</groupId>
-                    <artifactId>myfaces-impl</artifactId>
-                    <scope>compile</scope>
-                </dependency>
-
-                <!-- CDI and atinject APIs -->
-                <dependency>
-                    <groupId>org.apache.geronimo.specs</groupId>
-                    <artifactId>geronimo-jcdi_1.1_spec</artifactId>
-                    <scope>compile</scope>
-                </dependency>
-                <dependency>
-                    <groupId>org.apache.geronimo.specs</groupId>
-                    <artifactId>geronimo-atinject_1.0_spec</artifactId>
-                    <scope>compile</scope>
-                </dependency>
-                <!-- Interceptor API -->
-                <dependency>
-                    <groupId>org.apache.geronimo.specs</groupId>
-                    <artifactId>geronimo-interceptor_1.2_spec</artifactId>
-                    <scope>compile</scope>
-                </dependency>
-
-                <!-- OWB Impl -->
-                <dependency>
-                    <groupId>org.apache.openwebbeans</groupId>
-                    <artifactId>openwebbeans-impl</artifactId>
-                    <version>${project.version}</version>
-                    <scope>compile</scope>
-                </dependency>
-
-                <!-- Web Plugin -->
-                <dependency>
-                    <groupId>org.apache.openwebbeans</groupId>
-                    <artifactId>openwebbeans-web</artifactId>
-                    <version>${project.version}</version>
-                    <scope>compile</scope>
-                </dependency>
-
-                <!-- our tomcat7++ integration module -->
-                <dependency>
-                    <groupId>org.apache.openwebbeans</groupId>
-                    <artifactId>openwebbeans-tomcat7</artifactId>
-                    <version>${project.version}</version>
-                    <scope>compile</scope>
-                </dependency>
-
-                <!-- JSF Plugin -->
-                <dependency>
-                    <groupId>org.apache.openwebbeans</groupId>
-                    <artifactId>openwebbeans-jsf</artifactId>
-                    <version>${project.version}</version>
-                    <scope>compile</scope>
-                </dependency>
-
-
-                <!-- OpenJPA -->
-                <dependency>
-                    <groupId>org.apache.geronimo.specs</groupId>
-                    <artifactId>geronimo-jpa_2.0_spec</artifactId>
-                    <scope>compile</scope>
-                </dependency>
-
-
-                <dependency>
-                    <groupId>org.apache.openjpa</groupId>
-                    <artifactId>openjpa</artifactId>
-                    <version>2.0.1</version>
-                    <scope>compile</scope>
-                </dependency>
-
-
-
-            </dependencies>
-        </profile>
-    </profiles>
+    <build>
+        <finalName>reservation</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>openjpa-maven-plugin</artifactId>
+                <version>1.2</version>
+                <configuration>
+                    <includes>org/apache/webbeans/reservation/entity/*.class</includes>
+                    <addDefaultConstructor>true</addDefaultConstructor>
+                    <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
+                    <sqlAction>build</sqlAction>
+                    <sqlFile>${project.build.directory}/database.sql</sqlFile>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>mappingtool</id>
+                        <phase>process-classes</phase>
+                        <goals>
+                            <goal>enhance</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <dependencies>
+                    <dependency>
+                        <groupId>log4j</groupId>
+                        <artifactId>log4j</artifactId>
+                        <version>1.2.14</version>
+                    </dependency>
+                    <dependency>
+                        <groupId>org.apache.openjpa</groupId>
+                        <artifactId>openjpa</artifactId>
+                        <version>2.0.1</version>
+                    </dependency>
+                </dependencies>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.tomcat.maven</groupId>
+                <artifactId>tomcat7-maven-plugin</artifactId>
+            </plugin>
+
+        </plugins>
+    </build>
+
 </project>

Modified: openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/RegisterBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/RegisterBean.java?rev=1677166&r1=1677165&r2=1677166&view=diff
==============================================================================
--- openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/RegisterBean.java (original)
+++ openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/RegisterBean.java Fri May  1 15:23:47 2015
@@ -18,13 +18,10 @@
  */
 package org.apache.webbeans.reservation.beans;
 
-import javax.annotation.PostConstruct;
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.inject.Default;
 import javax.inject.Inject;
 import javax.inject.Named;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
 
 import org.apache.commons.logging.Log;
 import org.apache.webbeans.reservation.bindings.ApplicationLog;
@@ -35,29 +32,18 @@ import org.apache.webbeans.reservation.u
 @RequestScoped
 public class RegisterBean
 {
+    private @Inject @Default RegisterController personController;
     private @Inject @ApplicationLog Log logger;
-    
+
     private String name;
-    
     private String surname;
-    
     private Integer age;
-    
     private String userName;
-    
     private String password;
-    
+
     private boolean admin;
-    
-    private @Inject @Default RegisterController personController;
-    
-    private @Inject @Default BeanManager manager; 
-    
-    public RegisterBean()
-    {
-        
-    }
-    
+
+
     public String register()
     {   
         
@@ -71,14 +57,6 @@ public class RegisterBean
 
     }
 
-    @PostConstruct
-    public void init()
-    {
-        Bean<?> bean = manager.getBeans("logger").iterator().next();
-        
-        logger = (Log)manager.getReference(bean, null, manager.createCreationalContext(bean));
-    }
-    
     
     /**
      * @return the name

Modified: openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/user/UserReservationBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/user/UserReservationBean.java?rev=1677166&r1=1677165&r2=1677166&view=diff
==============================================================================
--- openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/user/UserReservationBean.java (original)
+++ openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/user/UserReservationBean.java Fri May  1 15:23:47 2015
@@ -84,11 +84,9 @@ public class UserReservationBean impleme
         try
         {
             date = new SimpleDateFormat("dd/MM/yyyy").parse(getReservationDate());
-            
         }
         catch(Exception e)
         {
-            
             JSFUtility.addErrorMessage("Please give a date with dd/MM/yyyy", "");
             return null;
         }

Added: openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/InitializeDatabase.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/InitializeDatabase.java?rev=1677166&view=auto
==============================================================================
--- openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/InitializeDatabase.java (added)
+++ openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/InitializeDatabase.java Fri May  1 15:23:47 2015
@@ -0,0 +1,47 @@
+/*
+ * 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.reservation.controller;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.Initialized;
+import javax.enterprise.event.Observes;
+import javax.inject.Inject;
+
+import org.apache.webbeans.reservation.controller.admin.AdminController;
+
+/**
+ * Initialize an admin and a normal user in the db.
+ */
+@ApplicationScoped
+public class InitializeDatabase
+{
+    private @Inject RegisterController registerController;
+    private @Inject AdminController adminController;
+
+    public void initUsers(@Observes @Initialized(ApplicationScoped.class) Object payload)
+    {
+        registerController.registerUser("administrator", "administrator", "administrator", "administrator", 66, true);
+        registerController.registerUser("customer", "customer", "customer", "customer", 27, false);
+
+        adminController.createNewHotel("Pillton", 5, "New York", "USA");
+        adminController.createNewHotel("Karriot", 5, "Paris", "France");
+        adminController.createNewHotel("Oper", 5, "Vienna", "Austria");
+    }
+
+}

Modified: openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/security/JSFSecurityPhaseListener.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/security/JSFSecurityPhaseListener.java?rev=1677166&r1=1677165&r2=1677166&view=diff
==============================================================================
--- openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/security/JSFSecurityPhaseListener.java (original)
+++ openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/security/JSFSecurityPhaseListener.java Fri May  1 15:23:47 2015
@@ -45,7 +45,7 @@ public class JSFSecurityPhaseListener im
             User user = null;
             try
             {
-                tracker = (SessionTracker)context.getApplication().evaluateExpressionGet(context, "#{sessionTracker}", SessionTracker.class);
+                tracker = context.getApplication().evaluateExpressionGet(context, "#{sessionTracker}", SessionTracker.class);
                 user = tracker.getUser();
                 
             }

Modified: openwebbeans/trunk/samples/reservation/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/reservation/src/main/webapp/WEB-INF/web.xml?rev=1677166&r1=1677165&r2=1677166&view=diff
==============================================================================
--- openwebbeans/trunk/samples/reservation/src/main/webapp/WEB-INF/web.xml (original)
+++ openwebbeans/trunk/samples/reservation/src/main/webapp/WEB-INF/web.xml Fri May  1 15:23:47 2015
@@ -46,4 +46,8 @@ under the License.
     <login-config>
         <auth-method>BASIC</auth-method>
     </login-config>
+
+    <listener>
+        <listener-class>org.apache.webbeans.servlet.WebBeansConfigurationListener</listener-class>
+    </listener>
 </web-app>

Modified: 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=1677166&r1=1677165&r2=1677166&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContextsService.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContextsService.java Fri May  1 15:23:47 2015
@@ -32,9 +32,14 @@ public abstract class AbstractContextsSe
 {
     protected final WebBeansContext webBeansContext;
 
+    protected boolean supportsConversation = false;
+
+
     protected AbstractContextsService(WebBeansContext webBeansContext)
     {
         this.webBeansContext = webBeansContext;
+        supportsConversation = webBeansContext.getOpenWebBeansConfiguration().supportsConversation();
+
     }
 
     @Override
@@ -122,5 +127,15 @@ public abstract class AbstractContextsSe
         conversationManager.destroyUnrequiredConversations();
     }
 
+    @Override
+    public void removeThreadLocals()
+    {
+        // no ThreadLocals to clean up by default
+    }
 
+    @Override
+    public void setSupportConversations(boolean supportConversations)
+    {
+        this.supportsConversation = supportConversations;
+    }
 }

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=1677166&r1=1677165&r2=1677166&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 Fri May  1 15:23:47 2015
@@ -48,7 +48,5 @@ public class ApplicationContext extends
     public void destroy(Contextual<?> contextual)
     {
         super.destroy(contextual);
-
-        // and now we also need to
     }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ConversationContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ConversationContext.java?rev=1677166&r1=1677165&r2=1677166&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ConversationContext.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ConversationContext.java Fri May  1 15:23:47 2015
@@ -49,9 +49,15 @@ public class ConversationContext extends
 
     private ConversationImpl conversation;
 
-    /*
-    * Constructor
-    */
+    // for serialisation
+    public ConversationContext()
+    {
+        this(WebBeansContext.currentInstance());
+    }
+
+    /**
+     * Constructor
+     */
     public ConversationContext(WebBeansContext webBeansContext)
     {
         super(ConversationScoped.class);

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=1677166&r1=1677165&r2=1677166&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 Fri May  1 15:23:47 2015
@@ -44,11 +44,23 @@ public class SessionContext extends Abst
 {
     private static final long serialVersionUID = 1L;
 
+    /**
+     * Whether this is a synthetic SessionContext or a 'real', means backed
+     * by a real servlet session
+     */
+    private boolean syntheticSession = false;
+
     public SessionContext()
     {
         super(SessionScoped.class);
     }
 
+    public SessionContext(boolean syntheticSession)
+    {
+        super(SessionScoped.class);
+        this.syntheticSession = syntheticSession;
+    }
+
     @Override
     public void setComponentInstanceMap()
     {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationManager.java?rev=1677166&r1=1677165&r2=1677166&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationManager.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationManager.java Fri May  1 15:23:47 2015
@@ -39,7 +39,6 @@ import org.apache.webbeans.context.Conve
 import org.apache.webbeans.context.RequestContext;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
-import org.apache.webbeans.spi.ContextsService;
 import org.apache.webbeans.spi.ConversationService;
 
 /**
@@ -56,7 +55,6 @@ public class ConversationManager
 
 
     private final WebBeansContext webBeansContext;
-    private final ContextsService contextsService;
 
     /**
      * Creates new conversation manager
@@ -64,7 +62,6 @@ public class ConversationManager
     public ConversationManager(WebBeansContext webBeansContext)
     {
         this.webBeansContext = webBeansContext;
-        this.contextsService = webBeansContext.getContextsService();
 
         // we need to register this for serialisation in clusters
         webBeansContext.getBeanManagerImpl().addInternalBean(ConversationStorageBean.INSTANCE);
@@ -80,10 +77,11 @@ public class ConversationManager
     {
         ConversationService conversationService = webBeansContext.getConversationService();
 
+        Set<ConversationContext> conversationContexts = getConversations(true);
+
         String conversationId = conversationService.getConversationId();
         if (conversationId != null && conversationId.length() > 0)
         {
-            Set<ConversationContext> conversationContexts = getConversations(false);
             if (conversationContexts != null)
             {
                 for (ConversationContext conversationContext : conversationContexts)
@@ -98,6 +96,7 @@ public class ConversationManager
 
         ConversationContext conversationContext = new ConversationContext(webBeansContext);
         conversationContext.setActive(true);
+        conversationContexts.add(conversationContext);
 
         webBeansContext.getBeanManagerImpl().fireEvent(getLifecycleEventPayload(conversationContext), InitializedLiteral.INSTANCE_CONVERSATION_SCOPED);
 
@@ -204,7 +203,7 @@ public class ConversationManager
 
         if (payLoad == null)
         {
-            RequestContext requestContext = (RequestContext) contextsService.getCurrentContext(RequestScoped.class);
+            RequestContext requestContext = (RequestContext) webBeansContext.getContextsService().getCurrentContext(RequestScoped.class);
             if (requestContext != null)
             {
                 payLoad = requestContext.getRequestObject();
@@ -226,7 +225,7 @@ public class ConversationManager
     private Set<ConversationContext> getConversations(boolean create)
     {
         Set<ConversationContext> conversationContexts = null;
-        Context sessionContext = contextsService.getCurrentContext(SessionScoped.class);
+        Context sessionContext = webBeansContext.getContextsService().getCurrentContext(SessionScoped.class);
         if (sessionContext != null)
         {
             if (!create)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultContextsService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultContextsService.java?rev=1677166&r1=1677165&r2=1677166&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultContextsService.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultContextsService.java Fri May  1 15:23:47 2015
@@ -451,4 +451,6 @@ public class DefaultContextsService exte
         cleanupConversations(conversationContext.get());
     }
 
+
+
 }

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=1677166&r1=1677165&r2=1677166&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java Fri May  1 15:23:47 2015
@@ -30,6 +30,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 
 import javax.enterprise.event.ObserverException;
 import javax.enterprise.event.TransactionPhase;
@@ -83,6 +84,13 @@ public final class NotificationManager
     private final Map<Type, Set<ObserverMethod<?>>> observers = new ConcurrentHashMap<Type, Set<ObserverMethod<?>>>();
     private final WebBeansContext webBeansContext;
 
+    /**
+     * Contains information whether certain Initialized and Destroyed events have observer methods.
+     */
+    private final ConcurrentMap<Annotation, Boolean> hasLifecycleEventObservers = new ConcurrentHashMap<Annotation, Boolean>();
+
+
+
     public static final Set<Class> CONTAINER_EVENT_CLASSES = new HashSet<Class>();
     static {
         CONTAINER_EVENT_CLASSES.add(AfterBeanDiscovery.class);
@@ -108,6 +116,31 @@ public final class NotificationManager
     {
         this.webBeansContext = webBeansContext;
     }
+
+    /**
+     *
+     * @param lifecycleEvent e.g. {@link org.apache.webbeans.annotation.DestroyedLiteral#INSTANCE_REQUEST_SCOPED}
+     * @return whether the given Initialized or Destroyed event has observer methods.
+     */
+    public boolean hasLifecycleObserver(Annotation lifecycleEvent)
+    {
+        Boolean hasObserver = hasLifecycleEventObservers.get(lifecycleEvent);
+        if (hasObserver == null)
+        {
+            hasObserver = Boolean.FALSE;
+            for (ObserverMethod<?> observerMethod : getObserverMethods())
+            {
+                if (observerMethod.getObservedQualifiers().contains(lifecycleEvent))
+                {
+                    hasObserver = Boolean.TRUE;
+                    break;
+                }
+            }
+            hasLifecycleEventObservers.putIfAbsent(lifecycleEvent, hasObserver);
+        }
+
+        return hasObserver;
+    }
     
     public List<ObserverMethod<?>> getObserverMethods()
     {

Modified: openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/JsfConversationService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/JsfConversationService.java?rev=1677166&r1=1677165&r2=1677166&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/JsfConversationService.java (original)
+++ openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/JsfConversationService.java Fri May  1 15:23:47 2015
@@ -34,7 +34,12 @@ public class JsfConversationService impl
     @Override
     public String getConversationId()
     {
-        return JSFUtil.getConversationId();
+        String conversationId = JSFUtil.getConversationId();
+        if (conversationId == null || conversationId.length() == 0)
+        {
+            return null;
+        }
+        return conversationId;
     }
 
     @Override

Modified: openwebbeans/trunk/webbeans-jsf12/src/main/java/org/apache/webbeans/jsf12/Jsf12ConversationService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-jsf12/src/main/java/org/apache/webbeans/jsf12/Jsf12ConversationService.java?rev=1677166&r1=1677165&r2=1677166&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-jsf12/src/main/java/org/apache/webbeans/jsf12/Jsf12ConversationService.java (original)
+++ openwebbeans/trunk/webbeans-jsf12/src/main/java/org/apache/webbeans/jsf12/Jsf12ConversationService.java Fri May  1 15:23:47 2015
@@ -34,7 +34,12 @@ public class Jsf12ConversationService im
     @Override
     public String getConversationId()
     {
-        return JSFUtil.getConversationId();
+        String conversationId = JSFUtil.getConversationId();
+        if (conversationId == null || conversationId.length() == 0)
+        {
+            return null;
+        }
+        return conversationId;
     }
 
     @Override

Modified: openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/ContextsService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/ContextsService.java?rev=1677166&r1=1677165&r2=1677166&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/ContextsService.java (original)
+++ openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/ContextsService.java Fri May  1 15:23:47 2015
@@ -107,4 +107,18 @@ public interface ContextsService
      * @param scopeType scope type
      */    
     public void deActivateContext(Class<? extends Annotation> scopeType);
+
+    /**
+     * Whenever a thread ends we need to remove any ThreadLocals from the ContextsService
+     */
+    public void removeThreadLocals();
+
+    /**
+     * This method can be used to disable conversation support in core CDI.
+     * This is needed as the spec defines that a user can define it's
+     * own Conversation handling by providing a Filter with the name
+     * "CDI Conversation Filter".
+     * @param supportConversations whether converstaions should be supported
+     */
+    public void setSupportConversations(boolean supportConversations);
 }

Modified: openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/servlet/EndWebBeansConfigurationListener.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/servlet/EndWebBeansConfigurationListener.java?rev=1677166&r1=1677165&r2=1677166&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/servlet/EndWebBeansConfigurationListener.java (original)
+++ openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/servlet/EndWebBeansConfigurationListener.java Fri May  1 15:23:47 2015
@@ -35,7 +35,8 @@ import org.apache.webbeans.config.WebBea
 import org.apache.webbeans.el.ELContextStore;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
 import org.apache.webbeans.spi.ContainerLifecycle;
-import org.apache.webbeans.web.context.WebContextsService;
+import org.apache.webbeans.spi.ContextsService;
+
 
 /**
  * This listener should be the last in the invocation chain.
@@ -50,6 +51,7 @@ public class EndWebBeansConfigurationLis
 
     private WebBeansContext webBeansContext;
     private ContainerLifecycle lifeCycle;
+    private ContextsService contextsService;
 
     /**
      * Default constructor
@@ -72,6 +74,7 @@ public class EndWebBeansConfigurationLis
     {
         // this must return the booted OWB container as the BeginWebBeansConfigurationListener did already run
         this.lifeCycle = webBeansContext.getService(ContainerLifecycle.class);
+        contextsService = webBeansContext.getContextsService();
     }
 
     /**
@@ -80,7 +83,10 @@ public class EndWebBeansConfigurationLis
     @Override
     public void contextDestroyed(ServletContextEvent event)
     {
-        lifeCycle.stopApplication(event);
+        if (lifeCycle != null)
+        {
+            lifeCycle.stopApplication(event);
+        }
 
         // just to be sure that we didn't lazily create anything...
         cleanupRequestThreadLocals();
@@ -161,7 +167,11 @@ public class EndWebBeansConfigurationLis
      */
     private void cleanupRequestThreadLocals()
     {
-        WebContextsService.removeThreadLocals();
+        if (contextsService != null)
+        {
+            contextsService.removeThreadLocals();
+        }
     }
 
 }
+

Modified: openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationFilter.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationFilter.java?rev=1677166&r1=1677165&r2=1677166&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationFilter.java (original)
+++ openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationFilter.java Fri May  1 15:23:47 2015
@@ -24,7 +24,6 @@ import org.apache.webbeans.config.WebBea
 import org.apache.webbeans.el.ELContextStore;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
 import org.apache.webbeans.spi.ContainerLifecycle;
-import org.apache.webbeans.spi.FailOverService;
 import org.apache.webbeans.util.WebBeansUtil;
 import org.apache.webbeans.web.context.WebContextsService;
 import org.apache.webbeans.web.util.ServletCompatibilityUtil;
@@ -39,8 +38,6 @@ import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletRequestEvent;
 import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
 import java.io.IOException;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -66,9 +63,9 @@ public class WebBeansConfigurationFilter
     /**Manages the container lifecycle*/
     protected ContainerLifecycle lifeCycle = null;
 
-    protected FailOverService failoverService = null;
     private WebBeansContext webBeansContext;
     private ServletContext servletContext;
+    private WebContextsService webContextsService;
 
     /**
      * Default constructor
@@ -76,7 +73,7 @@ public class WebBeansConfigurationFilter
     public WebBeansConfigurationFilter()
     {
         webBeansContext = WebBeansContext.getInstance();
-        failoverService = webBeansContext.getService(FailOverService.class);
+        webContextsService = (WebContextsService) webBeansContext.getContextsService();
     }
 
     /**
@@ -177,20 +174,6 @@ public class WebBeansConfigurationFilter
             logger.log(Level.FINE, "Destroying a request : [{0}]", request.getRemoteAddr());
         }
 
-        if (failoverService != null &&
-                failoverService.isSupportFailOver())
-        {
-            if(request instanceof HttpServletRequest)
-            {
-                HttpServletRequest httpRequest = (HttpServletRequest)request;
-                HttpSession session = httpRequest.getSession(false);
-                if (session != null)
-                {
-                    failoverService.sessionIsIdle(session);
-                }
-            }
-        }
-
         // clean up the EL caches after each request
         ELContextStore elStore = ELContextStore.getInstance(false);
         if (elStore != null)
@@ -224,7 +207,6 @@ public class WebBeansConfigurationFilter
      */
     private void cleanupRequestThreadLocals()
     {
-        // TODO maybe there are more to cleanup
-        WebContextsService.removeThreadLocals();
+        webContextsService.removeThreadLocals();
     }
 }

Modified: openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/WebContextsService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/WebContextsService.java?rev=1677166&r1=1677165&r2=1677166&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/WebContextsService.java (original)
+++ openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/WebContextsService.java Fri May  1 15:23:47 2015
@@ -64,29 +64,28 @@ public class WebContextsService extends
     private static final String OWB_SESSION_CONTEXT_ATTRIBUTE = "OPENWEBBEANS_SESSION_CONTEXT";
 
     /**Current request context*/
-    private static ThreadLocal<RequestContext> requestContexts = null;
+    protected static ThreadLocal<RequestContext> requestContexts = null;
 
     /**Current session context*/
-    private static ThreadLocal<SessionContext> sessionContexts = null;
+    protected static ThreadLocal<SessionContext> sessionContexts = null;
 
     /**
      * A single applicationContext
      */
-    private ApplicationContext sharedApplicationContext ;
+    protected ApplicationContext applicationContext;
 
-    private SingletonContext sharedSingletonContext;
+    protected SingletonContext singletonContext;
 
     /**Current conversation context*/
-    private static ThreadLocal<ConversationContext> conversationContexts = null;
+    protected static ThreadLocal<ConversationContext> conversationContexts = null;
     
     /**Current dependent context*/
-    private static DependentContext dependentContext;
+    protected static DependentContext dependentContext;
 
     /**Conversation context manager*/
-    private final ConversationManager conversationManager;
+    protected final ConversationManager conversationManager;
+
 
-    private boolean supportsConversation = false;
-    
 
     /**Initialize thread locals*/
     static
@@ -101,28 +100,28 @@ public class WebContextsService extends
     }
 
     /**
+     * Creates a new instance.
+     */
+    public WebContextsService(WebBeansContext webBeansContext)
+    {
+        super(webBeansContext);
+        conversationManager = webBeansContext.getConversationManager();
+
+        applicationContext = new ApplicationContext();
+        applicationContext.setActive(true);
+    }
+
+    /**
      * Removes the ThreadLocals from the ThreadMap to prevent memory leaks.
      */
-    public static void removeThreadLocals()
+    public void removeThreadLocals()
     {
         requestContexts.remove();
         sessionContexts.remove();
         conversationContexts.remove();
         RequestScopedBeanInterceptorHandler.removeThreadLocals();
     }
-    
-    /**
-     * Creates a new instance.
-     */
-    public WebContextsService(WebBeansContext webBeansContext)
-    {
-        super(webBeansContext);
-        supportsConversation = webBeansContext.getOpenWebBeansConfiguration().supportsConversation();
-        conversationManager = webBeansContext.getConversationManager();
 
-        sharedApplicationContext = new ApplicationContext();
-        sharedApplicationContext.setActive(true);
-    }
 
     /**
      * {@inheritDoc}
@@ -147,13 +146,13 @@ public class WebContextsService extends
         endContext(ApplicationScoped.class, destroyObject);
 
         // we also need to destroy the shared ApplicationContext
-        sharedApplicationContext.destroy();
+        applicationContext.destroy();
         
         //Destroy singleton context
         endContext(Singleton.class, destroyObject);
-        if (sharedSingletonContext != null)
+        if (singletonContext != null)
         {
-            sharedSingletonContext.destroy();
+            singletonContext.destroy();
         }
 
         //Thread local values to null
@@ -178,15 +177,15 @@ public class WebContextsService extends
     {        
         if(scopeType.equals(RequestScoped.class))
         {
-            destroyRequestContext((ServletRequestEvent)endParameters);
+            destroyRequestContext(endParameters);
         }
         else if(scopeType.equals(SessionScoped.class))
         {
-            destroySessionContext((HttpSession)endParameters);
+            destroySessionContext(endParameters);
         }
         else if(scopeType.equals(ApplicationScoped.class))
         {
-            destroyApplicationContext((ServletContext)endParameters);
+            destroyApplicationContext(endParameters);
         }
         else if(supportsConversation && scopeType.equals(ConversationScoped.class))
         {
@@ -198,7 +197,13 @@ public class WebContextsService extends
         }
         else if (scopeType.equals(Singleton.class))
         {
-            destroySingletonContext((ServletContext)endParameters);
+            destroySingletonContext(endParameters);
+        }
+        else
+        {
+            logger.warning("CDI-OpenWebBeans container does not support context scope "
+                    + scopeType.getSimpleName()
+                    + ". Scopes @Dependent, @RequestScoped, @ApplicationScoped and @Singleton are supported scope types");
         }
     }
 
@@ -218,7 +223,7 @@ public class WebContextsService extends
         }
         else if(scopeType.equals(ApplicationScoped.class))
         {
-            return sharedApplicationContext;
+            return applicationContext;
         }
         else if(supportsConversation && scopeType.equals(ConversationScoped.class))
         {
@@ -230,7 +235,7 @@ public class WebContextsService extends
         }
         else if (scopeType.equals(Singleton.class))
         {
-            return sharedSingletonContext;
+            return singletonContext;
         }
 
         return null;
@@ -244,15 +249,15 @@ public class WebContextsService extends
     {
         if (scopeType.equals(RequestScoped.class))
         {
-            initRequestContext((ServletRequestEvent)startParameter);
+            initRequestContext(startParameter);
         }
         else if (scopeType.equals(SessionScoped.class))
         {
-            initSessionContext((HttpSession)startParameter);
+            initSessionContext(startParameter);
         }
         else if (scopeType.equals(ApplicationScoped.class))
         {
-            initApplicationContext((ServletContext)startParameter);
+            initApplicationContext(startParameter);
         }
         else if (supportsConversation && scopeType.equals(ConversationScoped.class))
         {
@@ -264,7 +269,13 @@ public class WebContextsService extends
         }
         else if (scopeType.equals(Singleton.class))
         {
-            initSingletonContext((ServletContext)startParameter);
+            initSingletonContext(startParameter);
+        }
+        else
+        {
+            logger.warning("CDI-OpenWebBeans container does not support context scope "
+                    + scopeType.getSimpleName()
+                    + ". Scopes @Dependent, @RequestScoped, @ApplicationScoped and @Singleton are supported scope types");
         }
     }
 
@@ -289,45 +300,36 @@ public class WebContextsService extends
     
     /**
      * Initialize requext context with the given request object.
-     * @param event http servlet request event
+     * @param startupObject http servlet request event or system specific payload
      */
-    private void initRequestContext(ServletRequestEvent event)
+    protected void initRequestContext(Object startupObject )
     {
         
-        RequestContext rq = new ServletRequestContext();
-        rq.setActive(true);
+        ServletRequestContext requestContext = new ServletRequestContext();
+        requestContext.setActive(true);
 
-        requestContexts.set(rq);// set thread local
+        requestContexts.set(requestContext);// set thread local
 
-        if(event != null)
+        Object payload = null;
+
+        if(startupObject != null && startupObject instanceof ServletRequestEvent)
         {
-            HttpServletRequest request = (HttpServletRequest) event.getServletRequest();
-            ((ServletRequestContext)rq).setServletRequest(request);
+            HttpServletRequest request = (HttpServletRequest) ((ServletRequestEvent) startupObject).getServletRequest();
+            requestContext.setServletRequest(request);
             
             if (request != null)
             {
-                //Re-initialize thread local for session
-                HttpSession session = request.getSession(false);
-                
-                if(session != null)
-                {
-                    initSessionContext(session);
-                }
-
-                webBeansContext.getBeanManagerImpl().fireEvent(request, InitializedLiteral.INSTANCE_REQUEST_SCOPED);
+                payload = request;
             }
         }
-        else
-        {
-            webBeansContext.getBeanManagerImpl().fireEvent(new Object(), InitializedLiteral.INSTANCE_REQUEST_SCOPED);
-        }
+        webBeansContext.getBeanManagerImpl().fireEvent(payload != null ? payload : new Object(), InitializedLiteral.INSTANCE_REQUEST_SCOPED);
     }
     
     /**
      * Destroys the request context and all of its components. 
-     * @param requestEvent http servlet request object
+     * @param endObject http servlet request object or other payload
      */
-    private void destroyRequestContext(ServletRequestEvent requestEvent)
+    protected void destroyRequestContext(Object endObject)
     {
         // cleanup open conversations first
         if (supportsConversation)
@@ -335,7 +337,6 @@ public class WebContextsService extends
             cleanupConversations();
         }
 
-
         //Get context
         RequestContext context = getRequestContext();
 
@@ -352,20 +353,28 @@ public class WebContextsService extends
             elStore.destroyELContextStore();
         }
 
-        Object payload = requestEvent != null && requestEvent.getServletRequest() != null ? requestEvent.getServletRequest() : new Object();
-        webBeansContext.getBeanManagerImpl().fireEvent(payload, DestroyedLiteral.INSTANCE_REQUEST_SCOPED);
+        Object payload = null;
+
+        if (endObject != null && endObject instanceof ServletRequestEvent)
+        {
+            payload = ((ServletRequestEvent) endObject).getServletRequest();
+        }
+        webBeansContext.getBeanManagerImpl().fireEvent(payload != null ? payload : new Object(), DestroyedLiteral.INSTANCE_REQUEST_SCOPED);
 
         //Clear thread locals
         conversationContexts.set(null);
         conversationContexts.remove();
+
         sessionContexts.set(null);
         sessionContexts.remove();
+
         requestContexts.set(null);
         requestContexts.remove();
 
         RequestScopedBeanInterceptorHandler.removeThreadLocals();
     }
 
+
     private void cleanupConversations()
     {
         cleanupConversations(conversationContexts.get());
@@ -374,18 +383,22 @@ public class WebContextsService extends
     /**
      * Creates the session context at the session start.
      * Or assign a
-     * @param session http session object
+     * @param startupObject HttpSession object or other startup
      */
-    private void initSessionContext(HttpSession session)
+    protected void initSessionContext(Object startupObject)
     {
         SessionContext currentSessionContext;
 
+        HttpSession session = startupObject instanceof HttpSession ? (HttpSession) startupObject : null;
+
         if (session == null)
         {
             // no session -> create a dummy SessionContext
             // this is handy if you create asynchronous tasks or
             // batches which use a 'admin' user.
             currentSessionContext = new SessionContext();
+            currentSessionContext.setActive(true);
+
             webBeansContext.getBeanManagerImpl().fireEvent(new Object(), InitializedLiteral.INSTANCE_SESSION_SCOPED);
         }
         else
@@ -402,16 +415,18 @@ public class WebContextsService extends
                     if (currentSessionContext == null)
                     {
                         currentSessionContext = new SessionContext();
-                        //Activate
                         currentSessionContext.setActive(true);
                         webBeansContext.getBeanManagerImpl().fireEvent(session, InitializedLiteral.INSTANCE_SESSION_SCOPED);
+                        session.setAttribute(OWB_SESSION_CONTEXT_ATTRIBUTE, currentSessionContext);
                     }
                 }
             }
-
-            // we do that in any case.
-            // This is needed to trigger delta-replication on most servers
-            session.setAttribute(OWB_SESSION_CONTEXT_ATTRIBUTE, currentSessionContext);
+            else
+            {
+                // we do that in any case.
+                // This is needed to trigger delta-replication on most servers
+                session.setAttribute(OWB_SESSION_CONTEXT_ATTRIBUTE, currentSessionContext);
+            }
         }
 
 
@@ -422,67 +437,81 @@ public class WebContextsService extends
     /**
      * Destroys the session context and all of its components at the end of the
      * session. 
-     * @param session http session object. Can be {@code null} for non-http SessionContexts. Such a context only lives for one thread.
+     * @param endObject http session object. Can be {@code null} or different object for non-http SessionContexts. Such a context only lives for one thread.
      */
-    private void destroySessionContext(HttpSession session)
+    protected void destroySessionContext(Object endObject)
     {
-        //Get current session context from ThreadLocal
+        // Get current session context from ThreadLocal
         SessionContext context = sessionContexts.get();
 
-        if (session != null)
+        Object payload = null;
+
+        if (endObject != null && endObject instanceof HttpSession)
         {
+            HttpSession session = (HttpSession) endObject;
             if (context == null)
             {
+                // init in this case only attaches the existing session to the ThreadLocal
                 initSessionContext(session);
                 context = sessionContexts.get();
             }
+            payload = session;
         }
 
-        //Destroy context
+        // Destroy context
         if (context != null)
         {
             context.destroy();
-            webBeansContext.getBeanManagerImpl().fireEvent(session, DestroyedLiteral.INSTANCE_SESSION_SCOPED);
+            webBeansContext.getBeanManagerImpl().fireEvent(payload != null ? payload : new Object(), DestroyedLiteral.INSTANCE_SESSION_SCOPED);
         }
 
-        //Clear thread locals
+        // As the Conversations get stored inside the SessionContext we now also
+        // did destroy the ConversationContext implicitly
+        conversationContexts.set(null);
+        conversationContexts.remove();
+
+        // Clear thread locals
         sessionContexts.set(null);
         sessionContexts.remove();
 
+
     }
 
     /**
      * Creates the application context at the application startup 
-     * @param servletContext servlet context object
+     * @param startupObject servlet context object or other startup
+     *
      */
-    private void initApplicationContext(ServletContext servletContext)
+    protected void initApplicationContext(Object startupObject)
     {
-        if (sharedApplicationContext != null)
+        if (applicationContext != null)
         {
+            applicationContext.setActive(true);
             return;
         }
 
         ApplicationContext newApplicationContext = new ApplicationContext();
         newApplicationContext.setActive(true);
 
-        if (sharedApplicationContext == null)
+        if (applicationContext == null)
         {
-            sharedApplicationContext = newApplicationContext;
-            webBeansContext.getBeanManagerImpl().fireEvent(servletContext != null ? servletContext : new Object(), InitializedLiteral.INSTANCE_APPLICATION_SCOPED);
+            applicationContext = newApplicationContext;
+            Object payLoad = startupObject != null && startupObject instanceof ServletContext ? (ServletContext) startupObject : new Object();
+            webBeansContext.getBeanManagerImpl().fireEvent(payLoad, InitializedLiteral.INSTANCE_APPLICATION_SCOPED);
         }
     }
 
     /**
      * Destroys the application context and all of its components at the end of
      * the application. 
-     * @param servletContext servlet context object
+     * @param endObject servlet context object or other payload
      */
-    private void destroyApplicationContext(ServletContext servletContext)
+    protected void destroyApplicationContext(Object endObject)
     {
         //look for thread local
         //this can be set by initRequestContext
-        ApplicationContext context = sharedApplicationContext;
-        sharedSingletonContext = null;
+        ApplicationContext context = applicationContext;
+        singletonContext = null;
 
         //Destroy context
         if(context != null)
@@ -493,16 +522,17 @@ public class WebContextsService extends
         // this is needed to get rid of ApplicationScoped beans which are cached inside the proxies...
         webBeansContext.getBeanManagerImpl().clearCacheProxies();
 
-        webBeansContext.getBeanManagerImpl().fireEvent(servletContext != null ? servletContext : new Object(), DestroyedLiteral.INSTANCE_APPLICATION_SCOPED);
+        Object payload = endObject != null && endObject instanceof ServletContext ? endObject : new Object();
+        webBeansContext.getBeanManagerImpl().fireEvent(payload, DestroyedLiteral.INSTANCE_APPLICATION_SCOPED);
     }
     
     /**
      * Initialize singleton context.
-     * @param servletContext servlet context
+     * @param startupObject servlet context
      */
-    private void initSingletonContext(ServletContext servletContext)
+    protected void initSingletonContext(Object startupObject)
     {
-        if (sharedSingletonContext != null)
+        if (singletonContext != null)
         {
             return;
         }
@@ -510,35 +540,37 @@ public class WebContextsService extends
         SingletonContext newSingletonContext = new SingletonContext();
         newSingletonContext.setActive(true);
 
-        if (sharedSingletonContext == null)
+        if (singletonContext == null)
         {
-            sharedSingletonContext = newSingletonContext;
+            singletonContext = newSingletonContext;
         }
 
-        webBeansContext.getBeanManagerImpl().fireEvent(servletContext != null ? servletContext : new Object(), InitializedLiteral.INSTANCE_SINGLETON_SCOPED);
+        Object payLoad = startupObject != null && startupObject instanceof ServletContext ? (ServletContext) startupObject : new Object();
+        webBeansContext.getBeanManagerImpl().fireEvent(payLoad, InitializedLiteral.INSTANCE_SINGLETON_SCOPED);
     }
     
     /**
      * Destroy singleton context.
-     * @param servletContext servlet context
+     * @param endObject servlet context or other payload
      */
-    private void destroySingletonContext(ServletContext servletContext)
+    protected void destroySingletonContext(Object endObject)
     {
-        SingletonContext context = sharedSingletonContext;
+        SingletonContext context = singletonContext;
 
         if (context != null)
         {
             context.destroy();
         }
 
-        webBeansContext.getBeanManagerImpl().fireEvent(servletContext != null ? servletContext : new Object(), DestroyedLiteral.INSTANCE_SINGLETON_SCOPED);
+        Object payload = endObject != null && endObject instanceof ServletContext ? endObject : new Object();
+        webBeansContext.getBeanManagerImpl().fireEvent(payload, DestroyedLiteral.INSTANCE_SINGLETON_SCOPED);
     }
 
     /**
      * Initialize conversation context.
      * @param startObject either a ServletRequest or a ConversationContext
      */
-    private void initConversationContext(Object startObject)
+    protected void initConversationContext(Object startObject)
     {
         if (conversationContexts.get() != null)
         {
@@ -557,8 +589,13 @@ public class WebContextsService extends
     /**
      * Destroy conversation context.
      */
-    private void destroyConversationContext()
+    protected void destroyConversationContext()
     {
+        if (conversationContexts.get() == null)
+        {
+            return;
+        }
+
         ConversationContext context = getConversationContext();
 
         if (context != null)
@@ -623,7 +660,6 @@ public class WebContextsService extends
                 throw new BusyConversationException("Propogated conversation with cid=" + conversationId +
                         " is used by other request. It creates a new transient conversation");
             }
-
         }
 
         return conversationContext;
@@ -640,7 +676,12 @@ public class WebContextsService extends
             logger.log(Level.FINE, ">lazyStartSessionContext");
         }
 
-        Context context = getCurrentContext(RequestScoped.class);
+        RequestContext context = getRequestContext();
+        if (context == null)
+        {
+            logger.log(Level.WARNING, "Could NOT lazily initialize session context because NO active request context");
+        }
+
         if (context instanceof ServletRequestContext)
         {
             ServletRequestContext requestContext = (ServletRequestContext) context;
@@ -656,23 +697,19 @@ public class WebContextsService extends
                     {
                         logger.log(Level.FINE, "Lazy SESSION context initialization SUCCESS");
                     }
+
+                    return;
                 }
                 catch (Exception e)
                 {
                     logger.log(Level.SEVERE, WebBeansLoggerFacade.constructMessage(OWBLogConst.ERROR_0013, e));
                 }
-
-            }
-            else
-            {
-                logger.log(Level.WARNING, "Could NOT lazily initialize session context because NO active request context");
             }
         }
-        else
-        {
-            initSessionContext(null);
-            logger.log(Level.FINE, "Starting a non-web backed SessionContext");
-        }
+
+        // in any other case
+        initSessionContext(null);
+        logger.log(Level.FINE, "Starting a non-web backed SessionContext");
     }
 
 

Modified: openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/lifecycle/WebContainerLifecycle.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/lifecycle/WebContainerLifecycle.java?rev=1677166&r1=1677165&r2=1677166&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/lifecycle/WebContainerLifecycle.java (original)
+++ openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/lifecycle/WebContainerLifecycle.java Fri May  1 15:23:47 2015
@@ -20,26 +20,22 @@ package org.apache.webbeans.web.lifecycl
 
 import org.apache.webbeans.annotation.InitializedLiteral;
 import org.apache.webbeans.config.OWBLogConst;
-import org.apache.webbeans.config.OpenWebBeansConfiguration;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.exception.WebBeansException;
 import org.apache.webbeans.lifecycle.AbstractLifeCycle;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
 import org.apache.webbeans.spi.ResourceInjectionService;
 import org.apache.webbeans.spi.adaptor.ELAdaptor;
-import org.apache.webbeans.web.context.WebContextsService;
 import org.apache.webbeans.web.util.ServletCompatibilityUtil;
 
 import javax.el.ELResolver;
+import javax.enterprise.context.RequestScoped;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletContextEvent;
 import javax.servlet.jsp.JspApplicationContext;
 import javax.servlet.jsp.JspFactory;
-import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
 import java.util.logging.Level;
 
 /**
@@ -106,22 +102,6 @@ public final class WebContainerLifecycle
     @Override
     protected void afterStartApplication(final Object startupObject)
     {
-        String strDelay = getWebBeansContext().getOpenWebBeansConfiguration().getProperty(OpenWebBeansConfiguration.CONVERSATION_PERIODIC_DELAY,"150000");
-        long delay = Long.parseLong(strDelay);
-
-        service = Executors.newScheduledThreadPool(1, new ThreadFactory()
-        {            
-            @Override
-            public Thread newThread(Runnable runable)
-            {
-              Thread t = new Thread(runable, "OwbConversationCleaner-"
-                  + ServletCompatibilityUtil.getServletInfo((ServletContext) (startupObject)));
-                t.setDaemon(true);
-                return t;                
-            }
-        });
-        service.scheduleWithFixedDelay(new ConversationCleaner(), delay, delay, TimeUnit.MILLISECONDS);
-
         ELAdaptor elAdaptor = getWebBeansContext().getService(ELAdaptor.class);
         ELResolver resolver = elAdaptor.getOwbELResolver();
         //Application is configured as JSP
@@ -135,8 +115,16 @@ public final class WebContainerLifecycle
         // Add BeanManager to the 'javax.enterprise.inject.spi.BeanManager' servlet context attribute
         ServletContext servletContext = (ServletContext)(startupObject);
         servletContext.setAttribute(BeanManager.class.getName(), getBeanManager());
+        if (webBeansContext.getBeanManagerImpl().getNotificationManager().hasLifecycleObserver(InitializedLiteral.INSTANCE_APPLICATION_SCOPED))
+        {
+            // we need to temporarily start the ReqeustContext
+            webBeansContext.getContextsService().startContext(RequestScoped.class, null);
 
-        webBeansContext.getBeanManagerImpl().fireEvent(servletContext != null ? servletContext : new Object(), InitializedLiteral.INSTANCE_APPLICATION_SCOPED);
+            webBeansContext.getBeanManagerImpl().fireEvent(servletContext != null ? servletContext : new Object(), InitializedLiteral.INSTANCE_APPLICATION_SCOPED);
+
+            // shut down the RequestContext again
+            webBeansContext.getContextsService().endContext(RequestScoped.class, null);
+        }
     }
 
     @Override
@@ -199,7 +187,7 @@ public final class WebContainerLifecycle
      */
     private void cleanupShutdownThreadLocals()
     {
-        WebContextsService.removeThreadLocals();
+        contextsService.removeThreadLocals();
     }
     
     /**



Mime
View raw message