Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top