views:

63

answers:

1

Hi,

I'm thinking about the GlassFish platform for my new app.

  1. My app env. doesn't have a big volume of data to handle, but a lot of users writing/reading the same data

  2. A very volotile portion of the data updates every 200milsec by diff users. Therefore I'd like that type of data to be in memory only and accessible to the whole app

My questions:

  1. How do I use a global object in memory with GF? a. use a static variable object - for that I guess I need to make sure GF is running on only 1 JVM --> how to I configure GF to run on 1 jvm? b. use HttpContext - same as a.
  2. How do I persist to the DB? a. can I use JDO interface?
  3. How do I Schedule tasks to be performed in the future (something like the task queue in GAE)

thanks, J.S. Bach

A: 

How do I use a global object in memory with GF?

I would use a second level cache (that you get in JPA 2). The L2 cache implementation will depend on the JPA provider.

How do I persist to the DB? a. can I use JDO interface?

I'd stick with JPA 2.

How do I Schedule tasks to be performed in the future

I would use the enhanced Timer Service API of EJB 3.1 than allows to create cron-like schedules to trigger an EJB methods (simply annotate an EJB method with the @Schedule annotation):

@Stateless 
public class NewsLetterGeneratorBean implements NewsLetterGenerator {
    @Schedule(second="0", minute="0", hour="0", dayOfMonth="1", month="*", year="*") 
    public void generateMonthlyNewsLetter() { 
        ... Code to generate the monthly news letter goes here...
    }
}

The example above is taken from this article on TheServerSide.

Pascal Thivent
this site claims that JPA is 10x slower than JDBC (http://weblogs.java.net/blog/mkarg/archive/2010/01/03/jpa-great-damned-slow).how would i use JPA 2 to have global in memory variable? Any other simple option?
bach
@bach 1) You should reread that post more carefully, until the end (and not including the time spent in the database is ridiculous). 2) JPA 2 has a global cache, just use it. Or don't use JPA at all but still use a global cache (like EHCache) and do everything by hand.
Pascal Thivent