I'm thinking about the GlassFish platform 开发者_如何转开发for my new app.
My app env. doesn't have a big volume of data to handle, but a lot of users writing/reading the same data
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:
- 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.
- How do I persist to the DB? a. can I use JDO interface?
- How do I Schedule tasks to be performed in the future (something like the task queue in GAE)
thanks, J.S. Bach
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.
精彩评论