AsynchInvoke.java revision 608:7e06bf1dcb09
1/* 2 * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25/* 26 * Licensed Materials - Property of IBM 27 * RMI-IIOP v1.0 28 * Copyright IBM Corp. 1998 1999 All Rights Reserved 29 * 30 */ 31 32package com.sun.corba.se.impl.corba; 33 34import com.sun.corba.se.spi.orb.ORB ; 35 36/////////////////////////////////////////////////////////////////////////// 37// helper class for deferred invocations 38 39/* 40 * The AsynchInvoke class allows for the support of asynchronous 41 * invocations. Instances of these are created with a request object, 42 * and when run, perform an invocation. The instance is also 43 * responsible for waking up a client that might be waiting on the 44 * 'get_response' method. 45 */ 46 47public class AsynchInvoke implements Runnable { 48 49 private RequestImpl _req; 50 private ORB _orb; 51 private boolean _notifyORB; 52 53 public AsynchInvoke (ORB o, RequestImpl reqToInvokeOn, boolean n) 54 { 55 _orb = o; 56 _req = reqToInvokeOn; 57 _notifyORB = n; 58 }; 59 60 61 /* 62 * The run operation calls the invocation on the request object, 63 * updates the RequestImpl state to indicate that the asynchronous 64 * invocation is complete, and wakes up any client that might be 65 * waiting on a 'get_response' call. 66 * 67 */ 68 69 public void run() 70 { 71 // do the actual invocation 72 _req.doInvocation(); 73 74 // for the asynchronous case, note that the response has been 75 // received. 76 synchronized (_req) 77 { 78 // update local boolean indicator 79 _req.gotResponse = true; 80 81 // notify any client waiting on a 'get_response' 82 _req.notify(); 83 } 84 85 if (_notifyORB == true) { 86 _orb.notifyORB() ; 87 } 88 } 89 90}; 91 92/////////////////////////////////////////////////////////////////////////// 93