Create a class, say "CheckRemoteTask" that extends java.util.TimerTask and put your webservice checking code in the run() method. If you are interaction with EOF, then create an editing context in your CheckRemoteTask and use a try/finally to make sure you unlock when finished with it like this....

myEditingContext();
try {
// Check webservice for new data
// do stuff here, create new EO's using the new data

myEditingContext().saveChanges();

} finally {
myEditingContext().unlock();
}


Then to schedule the task to run every 30 seconds just override didFinishLaunching in Application to scheduled the CheckRemoteTask, like this ...

    protected Timer myTimer;
    /**
     * Method invoked when the application has finished launching.
     */
    public void didFinishLaunching() {
        super.didFinishLaunching();

        myTimer = new Timer(true);
        
   // run it every 30 seconds starting first task 1 second from now
        myTimer.schedule(new CheckRemoteTask(), 1000l, 30*1000l);

    }


If you have multiple instances of your app running, then you need to create a separate "singleton" app that fires a direct action to your multiple instance app every 30 secs and the DA can run the code. This ensures the code runs only once every 30 secs in whichever of the multiple instances the adaptor passes the DA to ..... but don't worry about that if you have only one instance of your app running.

HTH, 


-Kieran

________________________________________________________________

Blog: http://webobjects.webhop.org/



On Apr 24, 2006, at 10:56 AM, Philippe Lafoucrière wrote:

Hello,

First of all, "hi list, I'm a complete noob in wo".

Is there a way to create a continous loop in wo ?
I have to check a distant webservice every 30 seconds and fetch new data if available.

Do I have to create a webpage to ensure this, and fetch it using wget and crontab ? It sounds like a quite old method for me.

Thank you by advance for your help

Philippe

-- 

Philippe Lafoucrière
C.T.O
Mobile : +33 (0)6.89.54.49.62

KAMAYO
Interactive Solutions
66, Ave de Landshut
Centre de Transert
BP 50149
60201 Compiègne Cedex - France
Tel : +33 (0)3.44.36.70.48
Fax : +33 (0)3.44.30.21.03
www.kamayo.com

***

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:

This email sent to [EMAIL PROTECTED]

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to