SimpleTimer.jws Sample
A simple web service that demonstrates use of the Timer control. Uses the @jws:timer timeout= tag.
Use of a Timer control
Declaration and use of a client callback
Use of Conversations
This sample is located in the timer folder of the samples WebLogic Workshop project. In the file system the location is:
BEA_HOME\weblogic700\samples\workshop\applications\samples\timer\SimpleTimer.jws
To run this web service:
Start WebLogic Server in the appropriate domain.
On Microsoft Windows systems, from the Start menu navigate to:
BEA WebLogic Platform 7.0->WebLogic Workshop->WebLogic Workshop Examples->Start Examples Server.
On Linux or Solaris systems, run:
BEA_HOME/weblogic700/samples/workshop/startWebLogic.sh
Launch the service either by opening it in WebLogic Workshop and selecting the Start operation or by entering http://localhost:7001/samples/timer/SimpleTimer.jws in the address bar of your browser. If WebLogic Server is running in the appropriate domain on this machine, you may click here to run the sample.
Navigate to the Test Form tab of Test View, if necessary.
Invoke the createTimer method to create a new conversational instance.
Click on the conversation ID (the large number) in the Message Log to access this conversation's continue and finish methods.
Invoke the setAlarm method. This starts the Timer control, which will expire in 5 seconds.
When the timer expires, it calls its onTimeout callback, which arrives at SimpleTimer via the timer_onTimeout callback handler.
The timer_onTimeout callback handler in turn invokes SimpleTimer's onAlarm callback to the client.
You must refresh the browser to see callbacks arriving from the service. The use of a browser for Test View does not allow WebLogic Server to push notification to the browser when callbacks execute.
setAlarm uses the Timer control's restart method, so invoking setAlarm before the timer expires will reset it so that it will expire 5 seconds from the invocation of setAlarm.
Refresh the browser periodically until the callback.onAlarm callback entry appears in the Message Log.
Select log entries in the Message Log to see the message traffic involved in each interaction.
Controls: Using Resources from a Web Service
Timer Control: Using Timers in Your Web Service
Maintaining State with Conversations