Author: pete.muir(a)jboss.org
Date: 2010-06-17 13:37:07 -0400 (Thu, 17 Jun 2010)
New Revision: 6479
Added:
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/PostTracker.java
Modified:
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/DatabasePopulater.java
Log:
missing class!
Modified:
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/DatabasePopulater.java
===================================================================
---
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/DatabasePopulater.java 2010-06-17
12:53:23 UTC (rev 6478)
+++
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/DatabasePopulater.java 2010-06-17
17:37:07 UTC (rev 6479)
@@ -44,10 +44,9 @@
* external database to run this example.
*
*/
-// TODO Make into an EJB Singleton which executes at startup
@ApplicationScoped
@Named("database")
-//TODO @Singleton @Startup
+// TODO @Singleton @Startup
public class DatabasePopulater
{
Added:
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/PostTracker.java
===================================================================
---
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/PostTracker.java
(rev 0)
+++
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/PostTracker.java 2010-06-17
17:37:07 UTC (rev 6479)
@@ -0,0 +1,40 @@
+package org.jboss.weld.examples.pastecode.session;
+
+import java.util.Date;
+import java.util.LinkedList;
+
+import javax.ejb.Stateful;
+import javax.enterprise.context.SessionScoped;
+import javax.inject.Inject;
+
+@SessionScoped
+@Stateful // Add passivation capabilities....
+public class PostTracker
+{
+
+ private LinkedList<Date> posts;
+
+ @Inject DatabasePopulater databasePopulater;
+
+ public PostTracker()
+ {
+ this.posts = new LinkedList<Date>();
+ }
+
+ public void addPost()
+ {
+ this.posts.offerFirst(new Date());
+ }
+
+ public boolean isNewPostAllowed()
+ {
+ // if we are populating the database, skip
+ if (!databasePopulater.isPopulated())
+ {
+ return true;
+ }
+ long diff = new Date().getTime() - posts.get(2).getTime();
+ return diff > 20 * 1000;
+ }
+
+}
Property changes on:
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/PostTracker.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Show replies by date