1. /*
  2. * @(#)AsynchInvoke.java 1.12 03/01/23
  3. *
  4. * Copyright 2003 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. package com.sun.corba.se.internal.corba;
  16. ///////////////////////////////////////////////////////////////////////////
  17. // helper class for deferred invocations
  18. /*
  19. * The AsynchInvoke class allows for the support of asynchronous
  20. * invocations. Instances of these are created with a request object,
  21. * and when run, perform an invocation. The instance is also
  22. * responsible for waking up a client that might be waiting on the
  23. * 'get_response' method.
  24. */
  25. class AsynchInvoke implements Runnable {
  26. private RequestImpl _req;
  27. private ORB _orb;
  28. private boolean _notifyORB;
  29. AsynchInvoke (ORB o, RequestImpl reqToInvokeOn, boolean n)
  30. {
  31. _orb = o;
  32. _req = reqToInvokeOn;
  33. _notifyORB = n;
  34. };
  35. /*
  36. * The run operation calls the invocation on the request object,
  37. * updates the RequestImpl state to indicate that the asynchronous
  38. * invocation is complete, and wakes up any client that might be
  39. * waiting on a 'get_response' call.
  40. *
  41. */
  42. public void run()
  43. {
  44. // do the actual invocation
  45. _req.doInvocation();
  46. // for the asynchronous case, note that the response has been
  47. // received.
  48. synchronized (_req)
  49. {
  50. // update local boolean indicator
  51. _req.gotResponse = true;
  52. // notify any client waiting on a 'get_response'
  53. _req.notify();
  54. }
  55. if (_notifyORB == true) {
  56. synchronized(_orb._svResponseReceived) {
  57. _orb.notifyResponse();
  58. }
  59. }
  60. }
  61. };
  62. ///////////////////////////////////////////////////////////////////////////