1. /*
  2. * @(#)PIHandler.java 1.25 04/06/21
  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.protocol;
  8. import org.omg.PortableInterceptor.ObjectReferenceTemplate ;
  9. import org.omg.PortableInterceptor.Interceptor ;
  10. import org.omg.PortableInterceptor.Current ;
  11. import org.omg.PortableInterceptor.PolicyFactory ;
  12. import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName ;
  13. import org.omg.CORBA.NVList ;
  14. import org.omg.CORBA.Any ;
  15. import org.omg.CORBA.Policy ;
  16. import org.omg.CORBA.PolicyError ;
  17. import org.omg.CORBA.portable.RemarshalException;
  18. import com.sun.corba.se.spi.oa.ObjectAdapter ;
  19. import com.sun.corba.se.spi.protocol.CorbaMessageMediator ;
  20. import com.sun.corba.se.spi.ior.ObjectKeyTemplate ;
  21. // XXX These need to go away.
  22. import com.sun.corba.se.impl.corba.RequestImpl ;
  23. import com.sun.corba.se.impl.protocol.giopmsgheaders.ReplyMessage ;
  24. /** This interface defines the PI interface that is used to interface the rest of the
  25. * ORB to the PI implementation.
  26. */
  27. public interface PIHandler {
  28. /** Complete the initialization of the PIHandler. This will execute the methods
  29. * on the ORBInitializers, if any are defined. This must be done here so that
  30. * the ORB can obtain the PIHandler BEFORE the ORBInitializers run, since they
  31. * will need access to the PIHandler through the ORB.
  32. */
  33. public void initialize() ;
  34. public void destroyInterceptors() ;
  35. /*
  36. ****************************
  37. * IOR interceptor PI hooks
  38. ****************************/
  39. /**
  40. * Called when a new object adapter is created.
  41. *
  42. * @param oa The adapter associated with the interceptors to be
  43. * invoked.
  44. */
  45. void objectAdapterCreated( ObjectAdapter oa ) ;
  46. /**
  47. * Called whenever a state change occurs in an adapter manager.
  48. *
  49. * @param managerId managerId The adapter manager id
  50. * @param newState newState The new state of the adapter manager,
  51. * and by implication of all object adapters managed by this manager.
  52. */
  53. void adapterManagerStateChanged( int managerId,
  54. short newState ) ;
  55. /** Called whenever a state change occurs in an object adapter that
  56. * was not caused by an adapter manager state change.
  57. *
  58. * @param templates The templates that are changing state.
  59. * @param newState The new state of the adapters identified by the
  60. * templates.
  61. */
  62. void adapterStateChanged( ObjectReferenceTemplate[] templates,
  63. short newState ) ;
  64. /*
  65. *****************
  66. * Client PI hooks
  67. *****************/
  68. /**
  69. * Called for pseudo-ops to temporarily disable portable interceptor
  70. * hooks for calls on this thread. Keeps track of the number of
  71. * times this is called and increments the disabledCount.
  72. */
  73. void disableInterceptorsThisThread() ;
  74. /**
  75. * Called for pseudo-ops to re-enable portable interceptor
  76. * hooks for calls on this thread. Decrements the disabledCount.
  77. * If disabledCount is 0, interceptors are re-enabled.
  78. */
  79. void enableInterceptorsThisThread() ;
  80. /**
  81. * Called when the send_request or send_poll portable interception point
  82. * is to be invoked for all appropriate client-side request interceptors.
  83. *
  84. * @exception RemarhsalException - Thrown when this request needs to
  85. * be retried.
  86. */
  87. void invokeClientPIStartingPoint()
  88. throws RemarshalException ;
  89. /**
  90. * Called when the appropriate client ending interception point is
  91. * to be invoked for all apporpriate client-side request interceptors.
  92. *
  93. * @param replyStatus One of the constants in iiop.messages.ReplyMessage
  94. * indicating which reply status to set.
  95. * @param exception The exception before ending interception points have
  96. * been invoked, or null if no exception at the moment.
  97. * @return The exception to be thrown, after having gone through
  98. * all ending points, or null if there is no exception to be
  99. * thrown. Note that this exception can be either the same or
  100. * different from the exception set using setClientPIException.
  101. * There are four possible return types: null (no exception),
  102. * SystemException, UserException, or RemarshalException.
  103. */
  104. Exception invokeClientPIEndingPoint(
  105. int replyStatus, Exception exception ) ;
  106. /**
  107. * Invoked when a request is about to be created. Must be called before
  108. * any of the setClientPI* methods so that a new info object can be
  109. * prepared for information collection.
  110. *
  111. * @param diiRequest True if this is to be a DII request, or false if it
  112. * is a "normal" request. In the DII case, initiateClientPIRequest
  113. * is called twice and we need to ignore the second one.
  114. */
  115. void initiateClientPIRequest( boolean diiRequest ) ;
  116. /**
  117. * Invoked when a request is about to be cleaned up. Must be called
  118. * after ending points are called so that the info object on the stack
  119. * can be deinitialized and popped from the stack at the appropriate
  120. * time.
  121. */
  122. void cleanupClientPIRequest() ;
  123. /**
  124. * Notifies PI of additional information for client-side interceptors.
  125. * PI will use this information as a source of information for the
  126. * ClientRequestInfo object.
  127. */
  128. void setClientPIInfo( RequestImpl requestImpl ) ;
  129. /**
  130. * Notify PI of the MessageMediator for the request.
  131. */
  132. void setClientPIInfo(CorbaMessageMediator messageMediator) ;
  133. /*
  134. *****************
  135. * Server PI hooks
  136. *****************/
  137. /**
  138. * Called when the appropriate server starting interception point is
  139. * to be invoked for all appropriate server-side request interceptors.
  140. *
  141. * @throws ForwardException Thrown if an interceptor raises
  142. * ForwardRequest. This is an unchecked exception so that we need
  143. * not modify the entire execution path to declare throwing
  144. * ForwardException.
  145. */
  146. void invokeServerPIStartingPoint() ;
  147. /**
  148. * Called when the appropriate server intermediate interception point is
  149. * to be invoked for all appropriate server-side request interceptors.
  150. *
  151. * @throws ForwardException Thrown if an interceptor raises
  152. * ForwardRequest. This is an unchecked exception so that we need
  153. * not modify the entire execution path to declare throwing
  154. * ForwardException.
  155. */
  156. void invokeServerPIIntermediatePoint() ;
  157. /**
  158. * Called when the appropriate server ending interception point is
  159. * to be invoked for all appropriate server-side request interceptors.
  160. *
  161. * @param replyMessage The iiop.messages.ReplyMessage containing the
  162. * reply status.
  163. * @throws ForwardException Thrown if an interceptor raises
  164. * ForwardRequest. This is an unchecked exception so that we need
  165. * not modify the entire execution path to declare throwing
  166. * ForwardException.
  167. */
  168. void invokeServerPIEndingPoint( ReplyMessage replyMessage ) ;
  169. /**
  170. * Notifies PI to start a new server request and set initial
  171. * information for server-side interceptors.
  172. * PI will use this information as a source of information for the
  173. * ServerRequestInfo object. poaimpl is declared as an Object so that
  174. * we need not introduce a dependency on the POA package.
  175. */
  176. void initializeServerPIInfo( CorbaMessageMediator request,
  177. ObjectAdapter oa, byte[] objectId, ObjectKeyTemplate oktemp ) ;
  178. /**
  179. * Notifies PI of additional information reqired for ServerRequestInfo.
  180. *
  181. * @param servant The servant. This is java.lang.Object because in the
  182. * POA case, this will be a org.omg.PortableServer.Servant whereas
  183. * in the ServerRequestDispatcher case this will be an ObjectImpl.
  184. * @param targetMostDerivedInterface. The most derived interface. This
  185. * is passed in instead of calculated when needed because it requires
  186. * extra information in the POA case that we didn't want to bother
  187. * creating extra methods for to pass in.
  188. */
  189. void setServerPIInfo( java.lang.Object servant,
  190. String targetMostDerivedInterface ) ;
  191. /**
  192. * Notifies PI of additional information required for ServerRequestInfo.
  193. */
  194. void setServerPIInfo( Exception exception ) ;
  195. /**
  196. * Notifies PI of additional information for server-side interceptors.
  197. * PI will use this information as a source of information for the
  198. * ServerRequestInfo object. These are the arguments for a DSI request.
  199. */
  200. void setServerPIInfo( NVList arguments ) ;
  201. /**
  202. * Notifies PI of additional information for server-side interceptors.
  203. * PI will use this information as a source of information for the
  204. * ServerRequestInfo object. This is the exception of a DSI request.
  205. */
  206. void setServerPIExceptionInfo( Any exception ) ;
  207. /**
  208. * Notifies PI of additional information for server-side interceptors.
  209. * PI will use this information as a source of information for the
  210. * ServerRequestInfo object. This is the result of a DSI request.
  211. */
  212. void setServerPIInfo( Any result ) ;
  213. /**
  214. * Invoked when a request is about to be cleaned up. Must be called
  215. * after ending points are called so that the info object on the stack
  216. * can be deinitialized and popped from the stack at the appropriate
  217. * time.
  218. */
  219. void cleanupServerPIRequest() ;
  220. Policy create_policy( int type, Any val ) throws PolicyError ;
  221. void register_interceptor( Interceptor interceptor, int type )
  222. throws DuplicateName ;
  223. Current getPICurrent() ;
  224. void registerPolicyFactory( int type, PolicyFactory factory ) ;
  225. int allocateServerRequestId() ;
  226. }