1. /*
  2. * @(#)Delegate.java 1.26 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package org.omg.CORBA.portable;
  8. import org.omg.CORBA.Request;
  9. import org.omg.CORBA.NamedValue;
  10. import org.omg.CORBA.NVList;
  11. import org.omg.CORBA.Context;
  12. import org.omg.CORBA.ContextList;
  13. import org.omg.CORBA.ExceptionList;
  14. import org.omg.CORBA.TypeCode;
  15. import org.omg.CORBA.SystemException;
  16. /** The Delegate abstract class specifies a portable API for
  17. * ORB-vendor-specific implementation of the org.omg.CORBA.Object methods.
  18. * Each stub (proxy) contains a delegate
  19. * object, to which all org.omg.CORBA.Object methods are forwarded.
  20. * This allows a stub generated by one vendor's ORB to work with the delegate
  21. * from another vendor's ORB.
  22. *
  23. * @see org.omg.CORBA.Object
  24. */
  25. public abstract class Delegate {
  26. /** Return an InterfaceDef for the object reference provided.
  27. * @param obj The object reference whose InterfaceDef needs to be returned
  28. * @return the InterfaceDef
  29. */
  30. public org.omg.CORBA.Object get_interface_def(org.omg.CORBA.Object self)
  31. {
  32. throw new org.omg.CORBA.NO_IMPLEMENT();
  33. }
  34. /** Returns a duplicate of the object reference provided.
  35. * @param obj The object reference whose duplicate needs to be returned
  36. * @return the duplicate object reference
  37. */
  38. public abstract org.omg.CORBA.Object duplicate(org.omg.CORBA.Object obj);
  39. /** Releases resources associated with the object reference provided.
  40. * @param obj The object reference whose resources need to be released
  41. */
  42. public abstract void release(org.omg.CORBA.Object obj);
  43. /**
  44. * Check if the object reference is an instance of the given interface.
  45. * @param obj The object reference to be checked.
  46. * @param repository_id The repository identifier of the interface
  47. * to check against.
  48. * @return true if the object reference supports the interface
  49. */
  50. public abstract boolean is_a(org.omg.CORBA.Object obj, String repository_id);
  51. /**
  52. * Determines whether the server object for the object reference has been
  53. * destroyed.
  54. * @param obj The object reference which delegated to this delegate.
  55. * @result true if the ORB knows authoritatively that the server object does
  56. * not exist, false otherwise
  57. */
  58. public abstract boolean non_existent(org.omg.CORBA.Object obj);
  59. /** Determines if the two object references are equivalent.
  60. * @param obj The object reference which delegated to this delegate.
  61. * @param other The object reference to check equivalence against.
  62. */
  63. public abstract boolean is_equivalent(org.omg.CORBA.Object obj,
  64. org.omg.CORBA.Object other);
  65. /**
  66. * Returns an ORB-internal identifier (hashcode) for this object reference.
  67. * @param obj The object reference which delegated to this delegate.
  68. * @param maximum specifies an upper bound on the hash value returned by
  69. * the ORB.
  70. * @return ORB-internal hash identifier for object reference
  71. */
  72. public abstract int hash(org.omg.CORBA.Object obj, int max);
  73. /**
  74. * Creates a Request instance for use in the Dynamic Invocation Interface.
  75. * @param obj The object reference which delegated to this delegate.
  76. * @param operation The name of the operation to be invoked using the
  77. * Request instance.
  78. * @return the created Request instance
  79. */
  80. public abstract Request request(org.omg.CORBA.Object obj, String operation);
  81. /**
  82. * Creates a Request instance for use in the Dynamic Invocation Interface.
  83. *
  84. * @param obj The object reference which delegated to this delegate.
  85. * @param ctx The context to be used.
  86. * @param operation The name of the operation to be
  87. * invoked.
  88. * @param arg_list The arguments to the operation in the
  89. * form of an NVList.
  90. * @param result A container for the result as a NamedValue.
  91. * @return The created Request object.
  92. *
  93. */
  94. public abstract Request create_request(org.omg.CORBA.Object obj,
  95. Context ctx,
  96. String operation,
  97. NVList arg_list,
  98. NamedValue result);
  99. /**
  100. * Create a Request instance for use in the Dynamic Invocation Interface.
  101. *
  102. * @param obj The object reference which delegated to this delegate.
  103. * @param ctx The context to be used.
  104. * @param operation The name of the operation to be
  105. * invoked.
  106. * @param arg_list The arguments to the operation in the
  107. * form of an NVList.
  108. * @param result A container for the result as a NamedValue.
  109. * @param exclist A list of possible exceptions the
  110. * operation can throw.
  111. * @param ctxlist A list of context strings that need
  112. * to be resolved and sent with the
  113. * Request.
  114. * @return The created Request object.
  115. */
  116. public abstract Request create_request(org.omg.CORBA.Object obj,
  117. Context ctx,
  118. String operation,
  119. NVList arg_list,
  120. NamedValue result,
  121. ExceptionList exclist,
  122. ContextList ctxlist);
  123. /**
  124. * Return the ORB that created this delegate.
  125. * @see <a href="package-summary.html#unimpl"><code>portable</code>
  126. * package comments for unimplemented features</a>
  127. */
  128. public org.omg.CORBA.ORB orb(org.omg.CORBA.Object obj) {
  129. throw new org.omg.CORBA.NO_IMPLEMENT();
  130. }
  131. /**
  132. * Returns the <code>Policy</code> object of the specified type
  133. * which applies to this object.
  134. *
  135. * @param self The object reference which delegated to this delegate.
  136. * @param policy_type The type of policy to be obtained.
  137. * @return A <code>Policy</code> object of the type specified by
  138. * the policy_type parameter.
  139. * @exception org.omg.CORBA.BAD_PARAM raised when the value of policy type
  140. * is not valid either because the specified type is not supported by this
  141. * ORB or because a policy object of that type is not associated with this
  142. * Object.
  143. * @see <a href="package-summary.html#unimpl"><code>portable</code>
  144. * package comments for unimplemented features</a>
  145. */
  146. public org.omg.CORBA.Policy get_policy(org.omg.CORBA.Object self,
  147. int policy_type) {
  148. throw new org.omg.CORBA.NO_IMPLEMENT();
  149. }
  150. /**
  151. * Retrieves the <code>DomainManagers</code> of this object.
  152. * This allows administration services (and applications) to retrieve the
  153. * domain managers, and hence the security and other policies applicable
  154. * to individual objects that are members of the domain.
  155. *
  156. * @param self The object reference which delegated to this delegate.
  157. * @return The list of immediately enclosing domain managers of this object.
  158. * At least one domain manager is always returned in the list since by
  159. * default each object is associated with at least one domain manager at
  160. * creation.
  161. * @see <a href="package-summary.html#unimpl"><code>portable</code>
  162. * package comments for unimplemented features</a>
  163. */
  164. public org.omg.CORBA.DomainManager[] get_domain_managers(
  165. org.omg.CORBA.Object
  166. self) {
  167. throw new org.omg.CORBA.NO_IMPLEMENT();
  168. }
  169. /**
  170. *
  171. * @see <a href="package-summary.html#unimpl"><code>portable</code>
  172. * package comments for unimplemented features</a>
  173. */
  174. public org.omg.CORBA.Object set_policy_override(org.omg.CORBA.Object self,
  175. org.omg.CORBA.Policy[] policies,
  176. org.omg.CORBA.SetOverrideType set_add) {
  177. throw new org.omg.CORBA.NO_IMPLEMENT();
  178. }
  179. /**
  180. * Returns true if this object is implemented by a local servant.
  181. *
  182. * @param self The object reference which delegated to this delegate.
  183. * @return true only if the servant incarnating this object is located in
  184. * this Java VM. Return false if the servant is not local or the ORB
  185. * does not support local stubs for this particular servant. The default
  186. * behavior of is_local() is to return false.
  187. */
  188. public boolean is_local(org.omg.CORBA.Object self) {
  189. return false;
  190. }
  191. /**
  192. * Returns a Java reference to the servant which should be used for this
  193. * request. servant_preinvoke() is invoked by a local stub.
  194. * If a ServantObject object is returned, then its servant field
  195. * has been set to an object of the expected type (Note: the object may
  196. * or may not be the actual servant instance). The local stub may cast
  197. * the servant field to the expected type, and then invoke the operation
  198. * directly. The ServantRequest object is valid for only one invocation,
  199. * and cannot be used for more than one invocation.
  200. *
  201. * @param self The object reference which delegated to this delegate.
  202. *
  203. * @param operation a string containing the operation name.
  204. * The operation name corresponds to the operation name as it would be
  205. * encoded in a GIOP request.
  206. *
  207. * @param a Class object representing the expected type of the servant.
  208. * The expected type is the Class object associated with the operations
  209. * class of the stub's interface (e.g. A stub for an interface Foo,
  210. * would pass the Class object for the FooOperations interface).
  211. *
  212. * @return a ServantObject object.
  213. * The method may return a null value if it does not wish to support
  214. * this optimization (e.g. due to security, transactions, etc).
  215. * The method must return null if the servant is not of the expected type.
  216. */
  217. public ServantObject servant_preinvoke(org.omg.CORBA.Object self,
  218. String operation,
  219. Class expectedType) {
  220. return null;
  221. }
  222. /**
  223. * servant_postinvoke() is invoked by the local stub after the operation
  224. * has been invoked on the local servant.
  225. * This method must be called if servant_preinvoke() returned a non-null
  226. * value, even if an exception was thrown by the servant's method.
  227. * For this reason, the call to servant_postinvoke() should be placed
  228. * in a Java finally clause.
  229. *
  230. * @param self The object reference which delegated to this delegate.
  231. *
  232. * @param servant the instance of the ServantObject returned from
  233. * the servant_preinvoke() method.
  234. */
  235. public void servant_postinvoke(org.omg.CORBA.Object self,
  236. ServantObject servant) {
  237. }
  238. /**
  239. * request is called by a stub to obtain an OutputStream for
  240. * marshaling arguments. The stub must supply the operation name,
  241. * and indicate if a response is expected (i.e is this a oneway
  242. * call).
  243. *
  244. * @param self The object reference which delegated to this delegate.
  245. * @param operation a string containing the operation name.
  246. * The operation name corresponds to the operation name as it would be
  247. * encoded in a GIOP request.
  248. * @param responseExpected false if the operation is a one way operation,
  249. * and true otherwise.
  250. * @return OutputStream the OutputStream into which request arguments
  251. * can be marshaled.
  252. * @see <a href="package-summary.html#unimpl"><code>portable</code>
  253. * package comments for unimplemented features</a>
  254. */
  255. public OutputStream request(org.omg.CORBA.Object self,
  256. String operation,
  257. boolean responseExpected) {
  258. throw new org.omg.CORBA.NO_IMPLEMENT();
  259. }
  260. /**
  261. * invoke is called by a stub to invoke an operation. The stub provides an
  262. * OutputStream that was previously returned by a request()
  263. * call. invoke returns an InputStream which contains the
  264. * marshaled reply. If an exception occurs, invoke may throw an
  265. * ApplicationException object which contains an InputStream from
  266. * which the user exception state may be unmarshaled.
  267. *
  268. * @param self The object reference which delegated to this delegate.
  269. * @param output the OutputStream which contains marshaled arguments
  270. * @return input the InputStream from which reply parameters can be
  271. * unmarshaled.
  272. * @see <a href="package-summary.html#unimpl"><code>portable</code>
  273. * package comments for unimplemented features</a>
  274. */
  275. public InputStream invoke(org.omg.CORBA.Object self,
  276. OutputStream output)
  277. throws ApplicationException, RemarshalException {
  278. throw new org.omg.CORBA.NO_IMPLEMENT();
  279. }
  280. /**
  281. * releaseReply may optionally be called by a stub to release a
  282. * reply stream back to the ORB when the unmarshaling has
  283. * completed. The stub passes the InputStream returned by
  284. * invoke() or ApplicationException.getInputStream(). A null
  285. * value may also be passed to releaseReply, in which case the
  286. * method is a noop.
  287. *
  288. * @param self The object reference which delegated to this delegate.
  289. * @param input the InputStream returned from invoke().
  290. * @see <a href="package-summary.html#unimpl"><code>portable</code>
  291. * package comments for unimplemented features</a>
  292. */
  293. public void releaseReply(org.omg.CORBA.Object self,
  294. InputStream input) {
  295. throw new org.omg.CORBA.NO_IMPLEMENT();
  296. }
  297. public String toString(org.omg.CORBA.Object self) {
  298. return self.getClass().getName() + ":" + this.toString();
  299. }
  300. public int hashCode(org.omg.CORBA.Object self) {
  301. return System.identityHashCode(self);
  302. }
  303. public boolean equals(org.omg.CORBA.Object self, java.lang.Object obj) {
  304. return (self == obj);
  305. }
  306. }