Class PIHandlerImpl
- java.lang.Object
-
- com.sun.corba.ee.impl.interceptors.PIHandlerImpl
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
PIHandlerImpl.RequestInfoStack<C extends RequestInfoImpl>
-
Field Summary
Fields Modifier and Type Field Description (package private) java.lang.String[]
arguments
(package private) CodecFactory
codecFactory
private PICurrent
current
private boolean
hasClientInterceptors
private boolean
hasIORInterceptors
private boolean
hasServerInterceptors
private InterceptorInvoker
interceptorInvoker
private InterceptorList
interceptorList
(package private) static OMGSystemException
omgWrapper
private ORB
orb
(package private) static ORBUtilSystemException
orbutilWrapper
private java.util.Map<java.lang.Integer,PolicyFactory>
policyFactoryTable
private static short[]
REPLY_MESSAGE_TO_PI_REPLY_STATUS
private int
serverRequestIdCounter
private java.lang.ThreadLocal<PIHandlerImpl.RequestInfoStack<ClientRequestInfoImpl>>
threadLocalClientRequestInfoStack
private java.lang.ThreadLocal<PIHandlerImpl.RequestInfoStack<ServerRequestInfoImpl>>
threadLocalServerRequestInfoStack
(package private) static InterceptorsSystemException
wrapper
-
Constructor Summary
Constructors Constructor Description PIHandlerImpl(ORB orb, java.lang.String[] args)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
adapterManagerStateChanged(int managerId, short newState)
Called whenever a state change occurs in an adapter manager.void
adapterStateChanged(ObjectReferenceTemplate[] templates, short newState)
Called whenever a state change occurs in an object adapter that was not caused by an adapter manager state change.int
allocateServerRequestId()
void
cleanupClientPIRequest()
Invoked when a request is about to be cleaned up.void
cleanupServerPIRequest()
Invoked when a request is about to be cleaned up.private void
clientInfoStackWasPopped()
private void
clientInfoStackWasPushed()
void
close()
private int
convertPIReplyStatusToReplyMessage(short replyStatus)
Utility method to convert a PI reply status short to a ReplyMessage constant.Policy
create_policy(int type, Any val)
This is the implementation of standard API defined in org.omg.CORBA.ORB class.private ORBInitInfoImpl
createORBInitInfo()
Creates the ORBInitInfo object to be passed to ORB intializers' pre_init and post_init methodsvoid
destroyInterceptors()
ptc/00-08-06 p 205: "When an application calls ORB::destroy, the ORB 1) waits for all requests in progress to complete 2) calls the Interceptor::destroy operation for each interceptor 3) completes destruction of the ORB" This must be called at the end of ORB.destroy.void
disableInterceptorsThisThread()
Called for pseudo-ops to temporarily disable portable interceptor hooks for calls on this thread.void
enableInterceptorsThisThread()
Called for pseudo-ops to re-enable portable interceptor hooks for calls on this thread.Current
getPICurrent()
(package private) static java.lang.String
getReplyStatus(int piReplyStatus)
java.lang.Exception
handleClientPIEndingPoint(int replyStatus, java.lang.Exception exception, boolean invokeEndingPoint)
void
initialize()
Complete the initialization of the PIHandler.void
initializeServerPIInfo(MessageMediator request, ObjectAdapter oa, byte[] objectId, ObjectKeyTemplate oktemp)
Notifies PI to start a new server request and set initial information for server-side interceptors.void
initiateClientPIRequest(boolean diiRequest)
Invoked when a request is about to be created.java.lang.Exception
invokeClientPIEndingPoint(int replyStatus, java.lang.Exception exception)
Called when the appropriate client ending interception point is to be invoked for all apporpriate client-side request interceptors.void
invokeClientPIStartingPoint()
Called when the send_request or send_poll portable interception point is to be invoked for all appropriate client-side request interceptors.void
invokeServerPIEndingPoint(ReplyMessage replyMessage)
Called when the appropriate server ending interception point is to be invoked for all appropriate server-side request interceptors.void
invokeServerPIIntermediatePoint()
Called when the appropriate server intermediate interception point is to be invoked for all appropriate server-side request interceptors.void
invokeServerPIStartingPoint()
Called when the appropriate server starting interception point is to be invoked for all appropriate server-side request interceptors.private boolean
isClientPIEnabledForThisThread()
Convenience method to determine whether Client PI is enabled for requests on this thread.java.lang.Exception
makeCompletedClientRequest(int replyStatus, java.lang.Exception exception)
Called when a retry is needed after initiateClientPIRequest but before invokeClientPIRequest.private void
normalCall()
private void
nullParam()
Called when an invalid null parameter was passed.void
objectAdapterCreated(ObjectAdapter oa)
Called when a new object adapter is created.private ClientRequestInfoImpl
peekClientRequestInfoImplStack()
Convenience method to get the ClientRequestInfoImpl object off the top of the ThreadLocal stack.private ServerRequestInfoImpl
peekServerRequestInfoImplStack()
Convenience method to get the ServerRequestInfoImpl object off the top of the ThreadLocal stack.private void
postInitORBInitializers(ORBInitInfoImpl info)
Call post_init on all ORB initializersprivate void
preInitORBInitializers(ORBInitInfoImpl info)
Call pre_init on all ORB initializersvoid
register_interceptor(Interceptor interceptor, int type)
Called by ORBInitInfo when an interceptor needs to be registered.void
registerPolicyFactory(int type, PolicyFactory factory)
This method registers the Policy Factory in the policyFactoryTable, which is a HashMap.private void
secondCallForADIIRequest()
private void
serverInfoStackWasPopped()
private void
serverInfoStackWasPushed()
private void
serverPIHandleExceptions(ServerRequestInfoImpl info)
Handles exceptions for the starting and intermediate points for server request interceptors.void
setClientPIInfo(RequestImpl requestImpl)
Notifies PI of additional information for client-side interceptors.void
setClientPIInfo(MessageMediator messageMediator)
Notify PI of the MessageMediator for the request.void
setServerPIExceptionInfo(Any exception)
Notifies PI of additional information for server-side interceptors.void
setServerPIInfo(java.lang.Exception exception)
Notifies PI of additional information required for ServerRequestInfo.void
setServerPIInfo(java.lang.Object servant, java.lang.String targetMostDerivedInterface)
Notifies PI of additional information reqired for ServerRequestInfo.void
setServerPIInfo(Any result)
Notifies PI of additional information for server-side interceptors.void
setServerPIInfo(NVList arguments)
Notifies PI of additional information for server-side interceptors.
-
-
-
Field Detail
-
orb
private ORB orb
-
wrapper
static final InterceptorsSystemException wrapper
-
orbutilWrapper
static final ORBUtilSystemException orbutilWrapper
-
omgWrapper
static final OMGSystemException omgWrapper
-
serverRequestIdCounter
private int serverRequestIdCounter
-
codecFactory
CodecFactory codecFactory
-
arguments
java.lang.String[] arguments
-
interceptorList
private InterceptorList interceptorList
-
hasIORInterceptors
private boolean hasIORInterceptors
-
hasClientInterceptors
private boolean hasClientInterceptors
-
hasServerInterceptors
private boolean hasServerInterceptors
-
interceptorInvoker
private InterceptorInvoker interceptorInvoker
-
current
private PICurrent current
-
policyFactoryTable
private java.util.Map<java.lang.Integer,PolicyFactory> policyFactoryTable
-
REPLY_MESSAGE_TO_PI_REPLY_STATUS
private static final short[] REPLY_MESSAGE_TO_PI_REPLY_STATUS
-
threadLocalClientRequestInfoStack
private java.lang.ThreadLocal<PIHandlerImpl.RequestInfoStack<ClientRequestInfoImpl>> threadLocalClientRequestInfoStack
-
threadLocalServerRequestInfoStack
private java.lang.ThreadLocal<PIHandlerImpl.RequestInfoStack<ServerRequestInfoImpl>> threadLocalServerRequestInfoStack
-
-
Constructor Detail
-
PIHandlerImpl
public PIHandlerImpl(ORB orb, java.lang.String[] args)
-
-
Method Detail
-
getReplyStatus
static java.lang.String getReplyStatus(int piReplyStatus)
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
initialize
public void initialize()
Description copied from interface:PIHandler
Complete the initialization of the PIHandler. This will execute the methods on the ORBInitializers, if any are defined. This must be done here so that the ORB can obtain the PIHandler BEFORE the ORBInitializers run, since they will need access to the PIHandler through the ORB.- Specified by:
initialize
in interfacePIHandler
-
destroyInterceptors
public void destroyInterceptors()
ptc/00-08-06 p 205: "When an application calls ORB::destroy, the ORB 1) waits for all requests in progress to complete 2) calls the Interceptor::destroy operation for each interceptor 3) completes destruction of the ORB" This must be called at the end of ORB.destroy. Note that this is not part of the PIHandler interface, since ORBImpl implements the ORB interface.- Specified by:
destroyInterceptors
in interfacePIHandler
-
objectAdapterCreated
public void objectAdapterCreated(ObjectAdapter oa)
Description copied from interface:PIHandler
Called when a new object adapter is created.- Specified by:
objectAdapterCreated
in interfacePIHandler
- Parameters:
oa
- The adapter associated with the interceptors to be invoked.
-
adapterManagerStateChanged
public void adapterManagerStateChanged(int managerId, short newState)
Description copied from interface:PIHandler
Called whenever a state change occurs in an adapter manager.- Specified by:
adapterManagerStateChanged
in interfacePIHandler
- Parameters:
managerId
- managerId The adapter manager idnewState
- newState The new state of the adapter manager, and by implication of all object adapters managed by this manager.
-
adapterStateChanged
public void adapterStateChanged(ObjectReferenceTemplate[] templates, short newState)
Description copied from interface:PIHandler
Called whenever a state change occurs in an object adapter that was not caused by an adapter manager state change.- Specified by:
adapterStateChanged
in interfacePIHandler
- Parameters:
templates
- The templates that are changing state.newState
- The new state of the adapters identified by the templates.
-
disableInterceptorsThisThread
public void disableInterceptorsThisThread()
Description copied from interface:PIHandler
Called for pseudo-ops to temporarily disable portable interceptor hooks for calls on this thread. Keeps track of the number of times this is called and increments the disabledCount.- Specified by:
disableInterceptorsThisThread
in interfacePIHandler
-
enableInterceptorsThisThread
public void enableInterceptorsThisThread()
Description copied from interface:PIHandler
Called for pseudo-ops to re-enable portable interceptor hooks for calls on this thread. Decrements the disabledCount. If disabledCount is 0, interceptors are re-enabled.- Specified by:
enableInterceptorsThisThread
in interfacePIHandler
-
invokeClientPIStartingPoint
public void invokeClientPIStartingPoint() throws RemarshalException
Description copied from interface:PIHandler
Called when the send_request or send_poll portable interception point is to be invoked for all appropriate client-side request interceptors.- Specified by:
invokeClientPIStartingPoint
in interfacePIHandler
- Throws:
RemarshalException
- - Thrown when this request needs to be retried.
-
makeCompletedClientRequest
public java.lang.Exception makeCompletedClientRequest(int replyStatus, java.lang.Exception exception)
Description copied from interface:PIHandler
Called when a retry is needed after initiateClientPIRequest but before invokeClientPIRequest. In this case, we need to properly balance initiateClientPIRequest/cleanupClientPIRequest calls, but WITHOUT extraneous calls to invokeClientPIEndingPoint (see bug 6763340).- Specified by:
makeCompletedClientRequest
in interfacePIHandler
- Parameters:
replyStatus
- One of the constants in iiop.messages.ReplyMessage indicating which reply status to set.exception
- The exception before ending interception points have been invoked, or null if no exception at the moment.- Returns:
- The exception to be thrown, after having gone through all ending points, or null if there is no exception to be thrown. Note that this exception can be either the same or different from the exception set using setClientPIException. There are four possible return types: null (no exception), SystemException, UserException, or RemarshalException.
-
invokeClientPIEndingPoint
public java.lang.Exception invokeClientPIEndingPoint(int replyStatus, java.lang.Exception exception)
Description copied from interface:PIHandler
Called when the appropriate client ending interception point is to be invoked for all apporpriate client-side request interceptors.- Specified by:
invokeClientPIEndingPoint
in interfacePIHandler
- Parameters:
replyStatus
- One of the constants in iiop.messages.ReplyMessage indicating which reply status to set.exception
- The exception before ending interception points have been invoked, or null if no exception at the moment.- Returns:
- The exception to be thrown, after having gone through all ending points, or null if there is no exception to be thrown. Note that this exception can be either the same or different from the exception set using setClientPIException. There are four possible return types: null (no exception), SystemException, UserException, or RemarshalException.
-
handleClientPIEndingPoint
public java.lang.Exception handleClientPIEndingPoint(int replyStatus, java.lang.Exception exception, boolean invokeEndingPoint)
-
secondCallForADIIRequest
@InfoMethod private void secondCallForADIIRequest()
-
normalCall
@InfoMethod private void normalCall()
-
clientInfoStackWasPushed
@InfoMethod private void clientInfoStackWasPushed()
-
initiateClientPIRequest
public void initiateClientPIRequest(boolean diiRequest)
Description copied from interface:PIHandler
Invoked when a request is about to be created. Must be called before any of the setClientPI* methods so that a new info object can be prepared for information collection.- Specified by:
initiateClientPIRequest
in interfacePIHandler
- Parameters:
diiRequest
- True if this is to be a DII request, or false if it is a "normal" request. In the DII case, initiateClientPIRequest is called twice and we need to ignore the second one.
-
clientInfoStackWasPopped
@InfoMethod private void clientInfoStackWasPopped()
-
cleanupClientPIRequest
public void cleanupClientPIRequest()
Description copied from interface:PIHandler
Invoked when a request is about to be cleaned up. Must be called after ending points are called so that the info object on the stack can be deinitialized and popped from the stack at the appropriate time.- Specified by:
cleanupClientPIRequest
in interfacePIHandler
-
setClientPIInfo
public void setClientPIInfo(MessageMediator messageMediator)
Description copied from interface:PIHandler
Notify PI of the MessageMediator for the request.- Specified by:
setClientPIInfo
in interfacePIHandler
- Parameters:
messageMediator
- Mediator to notify
-
setClientPIInfo
public void setClientPIInfo(RequestImpl requestImpl)
Description copied from interface:PIHandler
Notifies PI of additional information for client-side interceptors. PI will use this information as a source of information for the ClientRequestInfo object.- Specified by:
setClientPIInfo
in interfacePIHandler
- Parameters:
requestImpl
- request used as source of information
-
invokeServerPIStartingPoint
public void invokeServerPIStartingPoint()
Description copied from interface:PIHandler
Called when the appropriate server starting interception point is to be invoked for all appropriate server-side request interceptors.- Specified by:
invokeServerPIStartingPoint
in interfacePIHandler
-
invokeServerPIIntermediatePoint
public void invokeServerPIIntermediatePoint()
Description copied from interface:PIHandler
Called when the appropriate server intermediate interception point is to be invoked for all appropriate server-side request interceptors.- Specified by:
invokeServerPIIntermediatePoint
in interfacePIHandler
-
invokeServerPIEndingPoint
public void invokeServerPIEndingPoint(ReplyMessage replyMessage)
Description copied from interface:PIHandler
Called when the appropriate server ending interception point is to be invoked for all appropriate server-side request interceptors.- Specified by:
invokeServerPIEndingPoint
in interfacePIHandler
- Parameters:
replyMessage
- The iiop.messages.ReplyMessage containing the reply status.
-
setServerPIInfo
public void setServerPIInfo(java.lang.Exception exception)
Description copied from interface:PIHandler
Notifies PI of additional information required for ServerRequestInfo.- Specified by:
setServerPIInfo
in interfacePIHandler
- Parameters:
exception
- the exception that will be returned
-
setServerPIInfo
public void setServerPIInfo(NVList arguments)
Description copied from interface:PIHandler
Notifies PI of additional information for server-side interceptors. PI will use this information as a source of information for the ServerRequestInfo object. These are the arguments for a DSI request.- Specified by:
setServerPIInfo
in interfacePIHandler
- Parameters:
arguments
- Arguments for a DSI request.
-
setServerPIExceptionInfo
public void setServerPIExceptionInfo(Any exception)
Description copied from interface:PIHandler
Notifies PI of additional information for server-side interceptors. PI will use this information as a source of information for the ServerRequestInfo object. This is the exception of a DSI request.- Specified by:
setServerPIExceptionInfo
in interfacePIHandler
- Parameters:
exception
- Exception of a DSI request
-
setServerPIInfo
public void setServerPIInfo(Any result)
Description copied from interface:PIHandler
Notifies PI of additional information for server-side interceptors. PI will use this information as a source of information for the ServerRequestInfo object. This is the result of a DSI request.- Specified by:
setServerPIInfo
in interfacePIHandler
- Parameters:
result
- Result of a DSI request
-
serverInfoStackWasPushed
@InfoMethod private void serverInfoStackWasPushed()
-
serverInfoStackWasPopped
@InfoMethod private void serverInfoStackWasPopped()
-
initializeServerPIInfo
public void initializeServerPIInfo(MessageMediator request, ObjectAdapter oa, byte[] objectId, ObjectKeyTemplate oktemp)
Description copied from interface:PIHandler
Notifies PI to start a new server request and set initial information for server-side interceptors. PI will use this information as a source of information for the ServerRequestInfo object. poaimpl is declared as an Object so that we need not introduce a dependency on the POA package.- Specified by:
initializeServerPIInfo
in interfacePIHandler
- Parameters:
request
- Request holder, included the Connectionoa
- Object AdapterobjectId
- id of objectoktemp
- template for object
-
setServerPIInfo
public void setServerPIInfo(java.lang.Object servant, java.lang.String targetMostDerivedInterface)
Description copied from interface:PIHandler
Notifies PI of additional information reqired for ServerRequestInfo.- Specified by:
setServerPIInfo
in interfacePIHandler
- Parameters:
servant
- The servant. This is java.lang.Object because in the POA case, this will be a org.omg.PortableServer.Servant whereas in the ServerRequestDispatcher case this will be an ObjectImpl.targetMostDerivedInterface
- The most derived interface. This is passed in instead of calculated when needed because it requires extra information in the POA case that we didn't want to bother creating extra methods for to pass in.
-
cleanupServerPIRequest
public void cleanupServerPIRequest()
Description copied from interface:PIHandler
Invoked when a request is about to be cleaned up. Must be called after ending points are called so that the info object on the stack can be deinitialized and popped from the stack at the appropriate time.- Specified by:
cleanupServerPIRequest
in interfacePIHandler
-
serverPIHandleExceptions
private void serverPIHandleExceptions(ServerRequestInfoImpl info)
Handles exceptions for the starting and intermediate points for server request interceptors. This is common code that has been factored out into this utility method.This method will NOT work for ending points.
-
convertPIReplyStatusToReplyMessage
private int convertPIReplyStatusToReplyMessage(short replyStatus)
Utility method to convert a PI reply status short to a ReplyMessage constant. This is a reverse lookup on the table defined in REPLY_MESSAGE_TO_PI_REPLY_STATUS. The reverse lookup need not be performed as quickly since it is only executed in exception conditions.
-
peekClientRequestInfoImplStack
private ClientRequestInfoImpl peekClientRequestInfoImplStack()
Convenience method to get the ClientRequestInfoImpl object off the top of the ThreadLocal stack. Throws an INTERNAL exception if the Info stack is empty.
-
peekServerRequestInfoImplStack
private ServerRequestInfoImpl peekServerRequestInfoImplStack()
Convenience method to get the ServerRequestInfoImpl object off the top of the ThreadLocal stack. Returns null if there are none.
-
isClientPIEnabledForThisThread
private boolean isClientPIEnabledForThisThread()
Convenience method to determine whether Client PI is enabled for requests on this thread.
-
preInitORBInitializers
private void preInitORBInitializers(ORBInitInfoImpl info)
Call pre_init on all ORB initializers
-
postInitORBInitializers
private void postInitORBInitializers(ORBInitInfoImpl info)
Call post_init on all ORB initializers
-
createORBInitInfo
private ORBInitInfoImpl createORBInitInfo()
Creates the ORBInitInfo object to be passed to ORB intializers' pre_init and post_init methods
-
register_interceptor
public void register_interceptor(Interceptor interceptor, int type) throws DuplicateName
Called by ORBInitInfo when an interceptor needs to be registered. The type is one of:- INTERCEPTOR_TYPE_CLIENT - ClientRequestInterceptor
- INTERCEPTOR_TYPE_SERVER - ServerRequestInterceptor
- INTERCEPTOR_TYPE_IOR - IORInterceptor
- Specified by:
register_interceptor
in interfacePIHandler
- Throws:
DuplicateName
- Thrown if an interceptor of the given name already exists for the given type.
-
getPICurrent
public Current getPICurrent()
- Specified by:
getPICurrent
in interfacePIHandler
-
nullParam
private void nullParam() throws BAD_PARAM
Called when an invalid null parameter was passed. Throws a BAD_PARAM with a minor code of 1- Throws:
BAD_PARAM
-
create_policy
public Policy create_policy(int type, Any val) throws PolicyError
This is the implementation of standard API defined in org.omg.CORBA.ORB class. This method finds the Policy Factory for the given Policy Type and instantiates the Policy object from the Factory. It will throw PolicyError exception, If the PolicyFactory for the given type is not registered. _REVISIT_, Once Policy Framework work is completed, Reorganize this method to com.sun.corba.ee.spi.orb.ORB.- Specified by:
create_policy
in interfacePIHandler
- Throws:
PolicyError
-
registerPolicyFactory
public void registerPolicyFactory(int type, PolicyFactory factory)
This method registers the Policy Factory in the policyFactoryTable, which is a HashMap. This method is made package private, because it is used internally by the Interceptors.- Specified by:
registerPolicyFactory
in interfacePIHandler
-
allocateServerRequestId
public int allocateServerRequestId()
- Specified by:
allocateServerRequestId
in interfacePIHandler
-
-