Re: Event Lisner I Presume - Triggering Code
Re: Event Lisner I Presume - Triggering Code
- Subject: Re: Event Lisner I Presume - Triggering Code
- From: Jonathan Rochkind <email@hidden>
- Date: Tue, 17 Feb 2004 11:48:40 -0600
I believe you can use a java.util.Timer.
There used to be an NSTimer, but I think that disappeared with 5.0,
since you could use a standard java.util.Timer instead.
Of course, if you are setting the timer for a far distant time, like
seems to be indicated in your example code (days? weeks?), then if
your application instance is restarted before that time, you'll lose
the timer. So you'll need a more complicated scheme involving
external storage of the date and associated information.
Perhaps you could both set a timer, and store the date in a database
somewhere. When the timer fires, it removes the entry from the db.
When the app starts up, it creates timers for anything that is in the
database.
Or maybe even better, I'd just make an entirely seperate application
for sending the notifications. Your primary application(s) store info
in the database about notifications needed (and remove entries from
the db when account setup has occured, and notification isn't
needed). The seperate notifying application uses a Timer to check the
database periodically (once a day? Once an hour? Once every ten
minutes?) for notificatoins needed, and then sends them (and removes
the entries from the db). Of course, this notification stuff doesn't
need to occur in a seperate application, you could have it as part of
the primary application(s) too theoretically, but it seems somehow
safer and simpler just to put it in it's own application (sharing
frameworks with the other application(s) of course, in order to have
access to the model for the db and any other common code needed).
Basically, there are a variety of ways you could do it, but
java.util.Timer should be useful.
--Jonathan
At 5:18 PM +0000 2/17/04, Jonathan Fleming wrote:
I want to trigger a piece of code to run at a determined time, say
from code such as in this NSLog.out.appendln:
NSLog.out.appendln(" registration creationDate is:
" + creationDate + "\r" +
" account must be setup by:
" + timeLapse + "\r" +
" Date/Time now is:
" + now + ".\r" +
" 1st email reminder date:
" + timeLapseR1 +" " + now.equals(timeLapseR1) + ".\r" +
" 2nd email reminder date:
" + timeLapseR2 +" " + now.equals(timeLapseR2)+"\r");
When timeLapseR1 equals it's stated time the email sender will do
it's thing and all will be well...
again when the time reaches that for timeLapseR2 the same thing
happens another email is sent and we're happy.
How do I do that from application.java... trigger code to run at a
determined time.
I can use the after() method but that then means the code is
triggered everytime an app instance is restarted... I just don't
know what to use to do what is needed.
Offers of help greatly respected
Jonathan :^)
_________________________________________________________________
Express yourself with cool emoticons - download MSN Messenger today!
http://www.msn.co.uk/messenger
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.