01 package localControls.asynch;
02
03 /**
04 * This Java control illustrates how you can add message buffering to
05 * control operations to handle heavy loads. With a buffered method,
06 * requests to the method are queued and processed as the control has
07 * resources available.
08 *
09 * @jcs:jc-jar
10 * label="Buffered Java Control"
11 * palette-priority="3"
12 * group-name="SampleControls"
13 * version="1.0"
14 * description="A control whose methods are buffered for asynchronous use."
15 * @editor-info:code-gen control-interface="true"
16 */
17 public class BufferJCImpl implements BufferJC, com.bea.control.ControlSource
18 {
19 /**
20 * @common:control
21 * @jc:timer timeout="5 seconds"
22 */
23 private com.bea.control.TimerControl delayTimer;
24
25 public Callback callback;
26
27 /**
28 * The startRequest method starts a timer. When the timer's
29 * onTimeout callback executes, this control's onResultsReady
30 * callback executes, notifying the client that the results
31 * are ready.
32 *
33 * @common:operation
34 * @common:message-buffer enable="true"
35 */
36 public void startRequest()
37 {
38 delayTimer.start();
39 }
40
41 /**
42 * This onTimeout callback handler receive the delayTimer control's
43 * callback five seconds after the control's start method was called.
44 * This code invokes the BufferJC control's onResultsReady callback,
45 * which is in turn received by its client.
46 */
47 public void delayTimer_onTimeout(long arg0)
48 {
49 delayTimer.stop();
50 callback.onResultsReady("Results are ready!");
51 }
52 }
|