Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2006

Tip: Looking for answers? Try searching our database.

List all existing timer tasks

Thread view: 
Deepa - 22 Mar 2006 05:02 GMT
Hi,

I am new to this group, I have a urgent query.
I will appreciate if someone can help me on this

I need to design a generic timer task tool.

Is there any JDK API through which I can list out all the timer task
running in the application?

Timer task are nothing but the threads, which are running through a
scheduler servlet.

Thanks in advance.

Deepa
Roedy Green - 22 Mar 2006 05:15 GMT
>Is there any JDK API through which I can list out all the timer task
>running in the application?

You would need to example the source for the two flavours of timer to
see if that is possible.  See http://mindprod.com/jgloss/timer.html

In general, in Java it is difficult to add instrumentation to a system
class.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Deepa - 22 Mar 2006 05:43 GMT
Thats fine but I really want to see the list of all timer task which
are running in my application.

How can I get that list.
Chris Smith - 22 Mar 2006 06:34 GMT
> Thats fine but I really want to see the list of all timer task which
> are running in my application.

Roedy gave the best answer you're going to get, which is that there's no
good way to do that.  If you don't like the answer, too bad.  It's still
true.

If you desperately need this, then perhaps you could accomplish your
task with JVMTI, which would allow you to intercept all calls to methods
of java.util.Timer or javax.swing.Timer and keep a list of the tasks.  
You may (or may not -- I really don't know) be able to do the same by
rigging an AOP implementation to do runtime instrumentation of the
bootclasspath and do the same thing that way.  Or, if you're willing to
depend on implementation details of the standard API, then do as Roedy
said and look at the source code to these two classes... and then use
reflection with setAccessible(true) to examine the private members and
get the list of tasks.

None of those are good things to do, though.  They might work for a
development tool (though the latter two are poor even for that purpose),
but won't be very good choices at all in production code.  To solve that
problem, you'd need to be willing to step back and consider other
solutions besides getting a list of all timer tasks in the system.  WHY
do you think that you need to do that, and what other mechanisms might
be available to reach the same goal?

Signature

www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Deepa - 22 Mar 2006 07:34 GMT
I will explain you in detail

We need to develop a admin tool for timer tasks
which will List all existing timer tasks with information ( current
state, last time run, next scheduled to, start and stop options).

so the tasks which are running how can I get the list...
jlowery05 - 22 Mar 2006 07:53 GMT
If you have access to the code, wrap the class and instrument the
wrapper with the information you need.

Other than that, it appears you're stuck.
Frank Seidinger - 22 Mar 2006 08:04 GMT
Deepa schrieb:

> We need to develop a admin tool for timer tasks
> which will List all existing timer tasks with information ( current
> state, last time run, next scheduled to, start and stop options).

Take a look at the JMX-API (java management extension). You can write a
MBean to administer your timer tasks. With the right interface methods you
will be able to start, stop and list timer tasks.

The timer task itself I would place into a simple list, that is a member of
your MBean.

The implementation part would not exceed a few days. If you are experienced
with java and MBeans it will be only one or two days.

If you are looking for a ready to use framework, have a look at quartz  at

http://www.opensymphony.com/quartz

Kind regards,

Frank.

Signature

Geld allein macht nicht glücklich.
Es kommt auch auf die Menge an...

Chris Smith - 22 Mar 2006 08:44 GMT
> We need to develop a admin tool for timer tasks
> which will List all existing timer tasks with information ( current
> state, last time run, next scheduled to, start and stop options).
>
> so the tasks which are running how can I get the list...

Are you acually reading the responses people write?  It doesn't seem
like it.  I spent a good paragraph listing three different ways to do
it. (Frank just added a fourth, which I haven't verified.)

Signature

www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Deepa - 22 Mar 2006 14:01 GMT
Hey Chris, I am reading all the responses.
Oliver Wong - 22 Mar 2006 17:46 GMT
> Hey Chris, I am reading all the responses.

   I was pretty sure there was a "How to ask smart questions" entry on
this, but I couldn't find it, so I'm gonna paraphrase the answer off the top
of my head here:

   Explain why the previous responces did not satisfy your question.

   - Oliver
Roedy Green - 22 Mar 2006 21:50 GMT
>Hey Chris, I am reading all the responses.

You got my back up dismissing my answer as if I had not responded. If
you dismiss an answer and want a different one, you pretty well have
to explain why the offered approach is not feasible for your case or
asking for more elaboration if that is the problem.

You came across like some precious princess stamping her foot
demanding someone find her strawberries in the snow served on a golden
plate.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Deepa - 23 Mar 2006 08:11 GMT
Hey I discussed with my client they didn't wnt the JMX thing...they
want it to do in a simple manner just using some of the APIs. I will
explore more and will get back to u on this.
Deepa - 23 Mar 2006 08:12 GMT
Hey I discussed with my client they don't wnt the JMX thing...they want
it to do in a simple manner just using some of the APIs. I will explore
more and will get back to u on this.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.