• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Polling Design in java

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

i have to design polling in java, which keeps executing at certain interval.
How to deign this polling in java. I can use only java se.

I have to use this class in jboss environment and when server starts running this class should get loaded into memory and till the time server is up it should keep polling.

Please provide some solutions.
 
Bartender
Posts: 7645
178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
While it's a bit unclear what you mean by "polling", check out the java.util.Timer and TimerTask classes for recurring jobs.
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In addition to what Tim said, you can also look at Quartz.

You can use a framework to ease your job. One I have used in a project for a government agency here in Brazil is DWR. It is essentially a Reverse Ajax framework (which you should use instead of polling, if possible). It can also work in polling mode. Please take a look here for more details.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kumar Gaurav wrote:How to deign this polling in java. I can use only java se.


Is this a school exercise? Otherwise the restrictions seems quite artificial (and arbitrary) to me.

For example, on Unix this could probably be done by a single entry in a crontab. No programming needed whatsoever. I believe Windows also has a built-in scheduler.

Winston
 
Roberto Perillo
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Winston Gutkowski wrote:Is this a school exercise? Otherwise the restrictions seems quite artificial (and arbitrary) to me.



Agreed. Since you said "I have to use this class in jboss environment and when server starts", I assumed this was a web app.
reply
    Bookmark Topic Watch Topic
  • New Topic