Miki/Andre

 

//i wasnt able to determine JMX ability to schedule a specific task for a 
specific time?

//could you reply with an example demonstrating that capability?


//in the meanwhile you *could* implement Axis2 SchedulerTimerTask

//granted java.util.Timer is weak on specific time but if you would be willing 
to deploy axis2 as a TC webapp you *could* use SchedulerTimerTask

    public class org.apache.axis2.deployment.scheduler.SchedulerTimerTask 
extends java.util.TimerTask {
        private org.apache.axis2.deployment.scheduler.DeploymentIterator 
iterator;
        private org.apache.axis2.deployment.scheduler.SchedulerTask 
schedulerTask;

        public 
SchedulerTimerTask(org.apache.axis2.deployment.scheduler.SchedulerTask 
schedulerTask, org.apache.axis2.deployment.scheduler.DeploymentIterator 
iterator) {
            this.schedulerTask = schedulerTask;
            this.iterator = iterator;
        }

        public void run() {
            schedulerTask.run();
            reschedule(schedulerTask, iterator);  //this will ultimately call 
to reschedule
        }

        private void reschedule(SchedulerTask schedulerTask, DeploymentIterator 
iterator) {
        Date time = iterator.next();    //DeploymentIterator next will acquire 
the date/time the Task will be scheduled

        if (time == null) {
            schedulerTask.cancel();
        } else {
            synchronized (schedulerTask.lock) {
                if (schedulerTask.state != SchedulerTask.CANCELLED) {
                    schedulerTask.timerTask = new 
SchedulerTimerTask(schedulerTask, iterator);
                    timer.schedule(schedulerTask.timerTask, time);
                }
            }
        }
    }


//DeploymentIterator handles the schedule date/time

public class org.apache.axis2.deployment.scheduler.DeploymentIterator {
    private java.util.Calendar calendar = java.util.Calendar.getInstance();

    public java.util.Date next() {

 

//tweak this for your specific Date/Time
//        calendar.add(Calendar.SECOND, 10);  //default date/time is current 
date/time and add 10 seconds

 

        return calendar.getTime();
    }
}


//org.apache.axis2.deployment.scheduler.Scheduler contains  test harness to 
test DeploymentIterator.next()

    public void schedule(SchedulerTask schedulerTask, DeploymentIterator 
iterator) {
        Date time = iterator.next();    

        if (time == null) {
            schedulerTask.cancel();
        } else {
            synchronized (schedulerTask.lock) {
                schedulerTask.state = SchedulerTask.SCHEDULED;
                schedulerTask.timerTask = new SchedulerTimerTask(schedulerTask, 
iterator);
                timer.schedule(schedulerTask.timerTask, time);
            }
        }
    }

dziekuje

Martin 
______________________________________________ 
Jogi és Bizalmassági kinyilatkoztatás/Note de déni et de confidentialitéCe 
message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est 
interdite. Ce message sert à l'information seulement et n'aura pas n'importe 
quel effet légalement obligatoire. Étant donné que les email peuvent facilement 
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité 
pour le contenu fourni.



 

> Date: Thu, 22 Jul 2010 11:19:19 +0200
> From: m...@ceti.pl
> To: users@tomcat.apache.org
> Subject: Re: Fire off asynch task in Tomcat.
> 
> On 07/22/2010 10:33 AM, André Warnier wrote:
> > Talking further to myself, I'll add that it also makes it easier to 
> > suspend/resume the sending of emails separately if you need to for 
> > some reason, without having to change anything to your running webapp.
> >
> > I know, it is certainly less exciting than using consumer/producer 
> > patterns or Executor classes.. sigh.
> 
> No no.
> 
> You have opportunity then to use JMX for altering anything inside 
> webapplication.
> It becomes more exciting :-)
> 
> -- 
> Mikolaj Rydzewski<m...@ceti.pl>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
> 
                                          
_________________________________________________________________
The New Busy is not the old busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_3

Reply via email to