Skip to content

Commit

Permalink
missing class!
Browse files Browse the repository at this point in the history
  • Loading branch information
pmuir committed Jun 17, 2010
1 parent ba73203 commit 75b8475
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
Expand Up @@ -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
{

Expand Down
@@ -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;
}

}

0 comments on commit 75b8475

Please sign in to comment.