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