Author: struberg
Date: Fri Apr 13 19:40:29 2018
New Revision: 1829096
URL: http://svn.apache.org/viewvc?rev=1829096&view=rev
Log:
OWB-1235 pimp our sample to allow testing Conversation serialisation
Added:
openwebbeans/trunk/samples/conversation-sample/src/main/webapp/META-INF/context.xml
Modified:
openwebbeans/trunk/samples/conversation-sample/pom.xml
openwebbeans/trunk/samples/conversation-sample/src/main/java/org/apache/webbeans/samples/conversation/ShoppingBean.java
openwebbeans/trunk/samples/conversation-sample/src/main/webapp/index.jsp
Modified: openwebbeans/trunk/samples/conversation-sample/pom.xml
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/samples/conversation-sample/pom.xml?rev=1829096&r1=1829095&r2=1829096&view=diff
==============================================================================
--- openwebbeans/trunk/samples/conversation-sample/pom.xml (original)
+++ openwebbeans/trunk/samples/conversation-sample/pom.xml Fri Apr 13 19:40:29
2018
@@ -49,6 +49,10 @@ under the License.
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-interceptor_1.2_spec</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-annotation_1.3_spec</artifactId>
+ </dependency>
<!-- JSF Plugin -->
<dependency>
Modified:
openwebbeans/trunk/samples/conversation-sample/src/main/java/org/apache/webbeans/samples/conversation/ShoppingBean.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/samples/conversation-sample/src/main/java/org/apache/webbeans/samples/conversation/ShoppingBean.java?rev=1829096&r1=1829095&r2=1829096&view=diff
==============================================================================
---
openwebbeans/trunk/samples/conversation-sample/src/main/java/org/apache/webbeans/samples/conversation/ShoppingBean.java
(original)
+++
openwebbeans/trunk/samples/conversation-sample/src/main/java/org/apache/webbeans/samples/conversation/ShoppingBean.java
Fri Apr 13 19:40:29 2018
@@ -22,9 +22,9 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
+import javax.annotation.PostConstruct;
import javax.enterprise.context.Conversation;
import javax.enterprise.context.ConversationScoped;
-import javax.enterprise.inject.New;
import javax.enterprise.inject.Produces;
import javax.faces.component.UIData;
import javax.inject.Inject;
@@ -42,17 +42,14 @@ public class ShoppingBean implements Ser
private List<Item> items = new ArrayList<>();
- private UIData uiTable;
+ private transient UIData uiTable;
- public ShoppingBean()
- {
-
- }
-
- @Inject
- public ShoppingBean(@New Item defaultItem)
+
+ @PostConstruct
+ public void init()
{
+ Item defaultItem = new Item();
defaultItem.setName("Default Item");
defaultItem.setPrice(1000L);
@@ -62,14 +59,20 @@ public class ShoppingBean implements Ser
public String startShopping()
{
- this.conversation.begin();
+ if (this.conversation.isTransient())
+ {
+ this.conversation.begin();
+ }
return null;
}
public String checkout()
{
- this.conversation.end();
+ if (!this.conversation.isTransient())
+ {
+ this.conversation.end();
+ }
return null;
}
Added:
openwebbeans/trunk/samples/conversation-sample/src/main/webapp/META-INF/context.xml
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/samples/conversation-sample/src/main/webapp/META-INF/context.xml?rev=1829096&view=auto
==============================================================================
---
openwebbeans/trunk/samples/conversation-sample/src/main/webapp/META-INF/context.xml
(added)
+++
openwebbeans/trunk/samples/conversation-sample/src/main/webapp/META-INF/context.xml
Fri Apr 13 19:40:29 2018
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+-->
+<Context>
+ <!--
+ Enable session passivation to disk.
+ That way we can test proper conversation serialisation.
+ Just shutdown tomcat and restart it again.
+ You should be able to continue working as if nothing has happened.
+ -->
+ <Manager className="org.apache.catalina.session.PersistentManager">
+ <Store className="org.apache.catalina.session.FileStore"
directory="mysessions.ser"/>
+ </Manager>
+</Context>
Modified:
openwebbeans/trunk/samples/conversation-sample/src/main/webapp/index.jsp
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/samples/conversation-sample/src/main/webapp/index.jsp?rev=1829096&r1=1829095&r2=1829096&view=diff
==============================================================================
--- openwebbeans/trunk/samples/conversation-sample/src/main/webapp/index.jsp
(original)
+++ openwebbeans/trunk/samples/conversation-sample/src/main/webapp/index.jsp
Fri Apr 13 19:40:29 2018
@@ -16,6 +16,6 @@
-->
<html>
<head>
-<meta HTTP-EQUIV="REFRESH" content="0; url=buy.jsf">
+<meta HTTP-EQUIV="REFRESH" content="0; url=buy.xhtml">
</head>
</html>