List all existing timer tasks

D

Deepa

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
 
D

Deepa

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.
 
C

Chris Smith

Deepa said:
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?

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

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
D

Deepa

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...
 
J

jlowery05

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.
 
F

Frank Seidinger

Deepa said:
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.
 
C

Chris Smith

Deepa said:
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.)

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

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
O

Oliver Wong

Deepa said:
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
 
R

Roedy Green

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.
 
D

Deepa

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.
 
D

Deepa

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top