You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2013/01/02 20:22:11 UTC
[2/3] git commit: Properly discard data when persistent page data is
cleared
Properly discard data when persistent page data is cleared
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/ce6fe847
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/ce6fe847
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/ce6fe847
Branch: refs/heads/master
Commit: ce6fe84799a6a9b5b7fb434e894a6de84861df31
Parents: bf46b0d
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Wed Jan 2 11:10:25 2013 -0800
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Wed Jan 2 11:10:25 2013 -0800
----------------------------------------------------------------------
.../integration/app1/pages/FormInjectorDemo.java | 32 ++++++++++-----
1 files changed, 21 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/ce6fe847/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/FormInjectorDemo.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/FormInjectorDemo.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/FormInjectorDemo.java
index e2cd05f..f18e844 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/FormInjectorDemo.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/FormInjectorDemo.java
@@ -14,12 +14,6 @@
package org.apache.tapestry5.integration.app1.pages;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicLong;
-
import org.apache.tapestry5.ValueEncoder;
import org.apache.tapestry5.annotations.Log;
import org.apache.tapestry5.annotations.Persist;
@@ -28,6 +22,12 @@ import org.apache.tapestry5.integration.app1.data.DoubleItem;
import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
import org.testng.Assert;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
+
public class FormInjectorDemo
{
private static final long DEMO_CONTEXT_VALUE = System.currentTimeMillis();
@@ -39,7 +39,8 @@ public class FormInjectorDemo
@Property(write = false)
private double sum;
- private static final Map<Long, DoubleItem> DB = CollectionFactory.newConcurrentMap();
+ @Persist
+ private Map<Long, DoubleItem> database;
private static final AtomicLong ID_ALLOCATOR = new AtomicLong(System.currentTimeMillis());
@@ -60,7 +61,7 @@ public class FormInjectorDemo
{
Long key = new Long(clientValue);
- return DB.get(key);
+ return database.get(key);
}
public String toClient(DoubleItem value)
@@ -70,6 +71,15 @@ public class FormInjectorDemo
};
}
+
+ void onActivate()
+ {
+ if (database == null)
+ {
+ database = CollectionFactory.newConcurrentMap();
+ }
+ }
+
public long getDemoContextValue()
{
return DEMO_CONTEXT_VALUE;
@@ -78,7 +88,7 @@ public class FormInjectorDemo
@Log
public List<DoubleItem> getDoubleItems()
{
- List<DoubleItem> items = CollectionFactory.newList(DB.values());
+ List<DoubleItem> items = CollectionFactory.newList(database.values());
Collections.sort(items, new DoubleItemComparator());
@@ -93,14 +103,14 @@ public class FormInjectorDemo
DoubleItem item = new DoubleItem();
item.setId(ID_ALLOCATOR.incrementAndGet());
- DB.put(item.getId(), item);
+ database.put(item.getId(), item);
return item;
}
void onRemoveRow(DoubleItem item)
{
- DB.remove(item.getId());
+ database.remove(item.getId());
}
void onPrepareForSubmit()