1. /*
  2. * @(#)OAInvocationInfo.java 1.8 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. package com.sun.corba.se.spi.oa;
  8. import javax.rmi.CORBA.Tie ;
  9. import org.omg.CORBA.portable.ServantObject;
  10. import org.omg.PortableServer.Servant;
  11. import org.omg.PortableServer.ServantLocatorPackage.CookieHolder;
  12. import com.sun.corba.se.spi.oa.ObjectAdapter ;
  13. import com.sun.corba.se.spi.copyobject.ObjectCopierFactory ;
  14. /** This class is a holder for the information required to implement POACurrent.
  15. * It is also used for the ServantObject that is returned by _servant_preinvoke calls.
  16. * This allows us to avoid allocating an extra object on each collocated invocation.
  17. */
  18. public class OAInvocationInfo extends ServantObject {
  19. // This is the container object for the servant.
  20. // In the RMI-IIOP case, it is the RMI-IIOP Tie, and the servant is the
  21. // target of the Tie.
  22. // In all other cases, it is the same as the Servant.
  23. private java.lang.Object servantContainer ;
  24. // These fields are to support standard OMG APIs.
  25. private ObjectAdapter oa;
  26. private byte[] oid;
  27. // These fields are to support the Object adapter implementation.
  28. private CookieHolder cookieHolder;
  29. private String operation;
  30. // This is the copier to be used by javax.rmi.CORBA.Util.copyObject(s)
  31. // For the current request.
  32. private ObjectCopierFactory factory ;
  33. public OAInvocationInfo(ObjectAdapter oa, byte[] id )
  34. {
  35. this.oa = oa;
  36. this.oid = id;
  37. }
  38. // Copy constructor of sorts; used in local optimization path
  39. public OAInvocationInfo( OAInvocationInfo info, String operation )
  40. {
  41. this.servant = info.servant ;
  42. this.servantContainer = info.servantContainer ;
  43. this.cookieHolder = info.cookieHolder ;
  44. this.oa = info.oa;
  45. this.oid = info.oid;
  46. this.factory = info.factory ;
  47. this.operation = operation;
  48. }
  49. //getters
  50. public ObjectAdapter oa() { return oa ; }
  51. public byte[] id() { return oid ; }
  52. public Object getServantContainer() { return servantContainer ; }
  53. // Create CookieHolder on demand. This is only called by a single
  54. // thread, so no synchronization is needed.
  55. public CookieHolder getCookieHolder()
  56. {
  57. if (cookieHolder == null)
  58. cookieHolder = new CookieHolder() ;
  59. return cookieHolder;
  60. }
  61. public String getOperation() { return operation; }
  62. public ObjectCopierFactory getCopierFactory() { return factory; }
  63. //setters
  64. public void setOperation( String operation ) { this.operation = operation ; }
  65. public void setCopierFactory( ObjectCopierFactory factory ) { this.factory = factory ; }
  66. public void setServant(Object servant)
  67. {
  68. servantContainer = servant ;
  69. if (servant instanceof Tie)
  70. this.servant = ((Tie)servant).getTarget() ;
  71. else
  72. this.servant = servant;
  73. }
  74. }