• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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.
 
Saloon Keeper
Posts: 7590
177
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic