KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > impl > corba > AsynchInvoke


1 /*
2  * @(#)AsynchInvoke.java 1.14 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 /*
8  * Licensed Materials - Property of IBM
9  * RMI-IIOP v1.0
10  * Copyright IBM Corp. 1998 1999 All Rights Reserved
11  *
12  * US Government Users Restricted Rights - Use, duplication or
13  * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
14  */

15
16 package com.sun.corba.se.impl.corba;
17
18 import com.sun.corba.se.spi.orb.ORB ;
19
20 ///////////////////////////////////////////////////////////////////////////
21
// helper class for deferred invocations
22

23 /*
24  * The AsynchInvoke class allows for the support of asynchronous
25  * invocations. Instances of these are created with a request object,
26  * and when run, perform an invocation. The instance is also
27  * responsible for waking up a client that might be waiting on the
28  * 'get_response' method.
29  */

30
31 public class AsynchInvoke implements Runnable JavaDoc {
32
33     private RequestImpl _req;
34     private ORB _orb;
35     private boolean _notifyORB;
36
37     public AsynchInvoke (ORB o, RequestImpl reqToInvokeOn, boolean n)
38     {
39     _orb = o;
40     _req = reqToInvokeOn;
41     _notifyORB = n;
42     };
43
44
45     /*
46      * The run operation calls the invocation on the request object,
47      * updates the RequestImpl state to indicate that the asynchronous
48      * invocation is complete, and wakes up any client that might be
49      * waiting on a 'get_response' call.
50      *
51      */

52
53     public void run()
54     {
55     // do the actual invocation
56
_req.doInvocation();
57     
58     // for the asynchronous case, note that the response has been
59
// received.
60
synchronized (_req)
61         {
62         // update local boolean indicator
63
_req.gotResponse = true;
64
65         // notify any client waiting on a 'get_response'
66
_req.notify();
67         }
68       
69     if (_notifyORB == true) {
70         _orb.notifyORB() ;
71     }
72     }
73
74 };
75
76 ///////////////////////////////////////////////////////////////////////////
77
Popular Tags