![]() |
![]() |
![]() |
![]() |
![]() |
A request-level interceptor is a user-written CORBA object that provides a means to insert functionality, such as security or monitoring components, into the invocation path between the client and server components of a CORBA application. When you have an interceptor installed and registered with an Object Request Broker (ORB) on a particular machine, the interceptor is involved with all the CORBA applications on that machine. You can use interceptors to insert any additional functionality into the invocation path of an object invocation, at either the client, or the server, or both ends of the invocation.
•
a. When the request is first issued from the client application and arrives at the ORB (the client_invoke operation)
b. When the target response arrives back at the client application process (the client_response operation)
a. When the client request first arrives at the ORB (the target_invoke operation)
b. When the target object response arrives at the ORB (the target_response operation)
• Interceptors can short-circuit an invocation by returning a response directly to the client without involving the target object at all.
•
• Interceptors cannot write to the DataInputStream object.
• Interceptors cannot invoke methods on the Tobj_Bootstrap object.
• The REPLY_NO_EXCEPTION return status value is not supported, although it appears in the method signatures operations on interceptor classes.
• The method signatures for operations on classes derived from the RequestLevelInterceptor interface include parameters for the following interfaces:Each interceptor is called twice during the request-response cycle of an invocation: once when a request is going from the client towards the target, and again when a response returns back to the client. The client interceptor class, ClientRequestInterceptor, has two corresponding operations, among others, for these two calls:
• client_invoke()—called when the request made on an object reference arrives at the client-side ORB.
• client_response()—called when the response is returned back towards the entity making the request.The flow of execution of a CORBA application that uses a client-side interceptor is shown in Figure 1‑1. This figure shows a basic and successful request-response invocation cycle (that is, no exceptions are raised).Figure 1‑1 Client-side InterceptorIn Figure 1‑1, note the following events that are called out:
2. The ORB calls the client_invoke operation on the client-side interceptor. (The section “Using Multiple Request-Level Interceptors,” explains what happens when you have multiple client-side interceptors installed.)
4. If no exception is returned as a result of the client_invoke operation, the request resumes its path toward the target object.
6. The response arrives back at the ORB, and the ORB calls the client_response operation on the interceptor.The client_invoke and client_response operations each return a status value that indicates whether the client interceptor processing should continue. The interceptors may return exception status values, which cause exception handling to take place. Table 1‑1 shows what happens depending on what status value is returned from these operations, and shows how the interceptors, together with the ORB, handle exceptions.
Table 1‑1 Client Interceptor Return Status Values The interceptor has serviced the request and no further process toward the target is needed. The request will be considered serviced as if the target processed it. Thus, the ORB short circuits the invocation and starts calling interceptors back towards the client. The client_response operation is not called on the same interceptor, but this operation on any previously invoked interceptor is called. The interceptor returns an exception to the ORB. The ORB then calls each previous client-side interceptors’ exception_occurred operation. The exception_occurred method gives these previous interceptors an opportunity to clean up state before the ORB returns an exception back to the client application. Thus, the ORB short circuits the invocation, and the invocation is now complete. For more information about the exception_occurred method, see the section “The exception_occurred Method” on page 1‑12. The interceptor passes an exception back to the ORB, overriding any previous result of the request. The ORB invokes the exception_occurred method on each previous interceptor back towards the client, then returns an exception to the client application.As on the client side, a target-side interceptor is called twice during a request-response cycle. Target-side interceptors inherit from the TargetRequestInterceptor class, which includes the following operations:
• target_invoke()—called when the request arrives at the ORB that is part of the target object process.
• target_response()—called when the response is sent back to the client.The flow of execution of a CORBA application that uses a target-side interceptor is shown in Figure 1‑2. This figure shows a basic and successful request-response invocation cycle (that is, no exceptions are raised).Figure 1‑2 Target-side InterceptorIn Figure 1‑2, note the following events that are called out:
2. The ORB calls the target_invoke operation on the target-side interceptor. (The section “Using Multiple Request-Level Interceptors,” explains what happens when you have multiple target-side interceptors installed.)
4. If no exception is raised during the execution of the target_invoke operation, the request resumes its path toward the target object.
6. The target-side ORB calls the target_response operation on the interceptor.Table 1‑2 shows what happens to an invocation on the target side depending on what status values are returned by the target_invoke and target_response operations, explaining what happens when exceptions are thrown.
Table 1‑2 Target Interceptor Return Status Values The interceptor has serviced the request and no further process toward the target is needed. The request will be considered serviced as if the target processed it. Thus, the ORB short circuits the invocation and starts calling interceptors back towards the client. The target_response operation is not called on the same interceptor, but this operation on any previously invoked interceptor is called. The interceptor returns an exception to the ORB. The ORB then calls each previous target-side interceptors’ exception_occurred operation. The exception_occurred method gives these previous interceptors an opportunity to clean up state before the ORB returns an exception back to the client ORB. Thus, the target ORB short circuits the invocation, and the invocation is now complete. For more information about the exception_occurred method, see the section “The exception_occurred Method” on page 1‑12. The interceptor passes a new exception back ORB, overriding any previous result of the request. Instead of calling the target_response operation for interceptors on the way back to the client, the ORB calls the exception_occurred operation on those interceptors instead.Every interceptor has the exception_occurred method, which the ORB may call under the following circumstances:
• A different interceptor has set an exception (rather than an exception being generated by the ORB or the method). For example, the ORB is calling Interceptors A and B, respectively. Interceptor A has set an exception, so the ORB then calls the exception_occurred method on Interceptor B instead of the client_response or target_response methods. Your interceptor can take advantage of this behavior to examine both the context in which the response containing the exception is being processed and the actual value of the exception without reading the exception from the DataInputStream structure.
• The client application is using a deferred synchronous DII invocation on a Request object and then releases the Request object. In this case no response is delivered to the client.When one of the preceding situations has occurred, calling the exception_occurred method is an alternative to calling the client_response or target_response methods; however, the effect is essentially the same in that the client invocation is complete.For more information about keeping track of requests, see the section “Implementing the Interceptor’s Response Operation” on page 2‑5.This short-circuit behavior works only in the client_invoke or target_invoke methods. It doesn’t apply to the client_response or target_response methods.When an interceptor does not indicate success, a short circuit response results. This short circuit can be performed by the client_invoke or target_invoke operations. The status returned from the interceptor tells the ORB that the interceptor itself has decided to respond to the request with an exception, rather than to allow the target object to handle the request. (An interceptor’s client_response or target_response operation cannot perform any short-circuit behavior, but it can replace the target response.)Each interceptor is normally unaware of the other interceptors, unless they explicitly share information. This independent programming model is preserved by the execution semantics with regards to short circuits: When an interceptor indicates that a response should be short-circuited and not reach its intended destination (which is the transport on the client side, and the object implementation on the target side), the response circulates back through the interceptors through which it has successfully passed. For example, if Interceptor A returns the status value INVOKE_NO_EXCEPTION after processing a client_invoke operation, expecting the request to be delivered, and the next Interceptor, B, denies the request with an exception, that exception gets put into the response and is delivered to Interceptor A’s exception_occurred operation. The analogous execution model on the target side is in effect also.Figure 1‑3 shows the sequence of execution when multiple client-side interceptors are installed on an ORB. (A similar series of operations occur with multiple target-side interceptors.)Figure 1‑3 Multiple Interceptors on an ORBIn Figure 1‑3, note the following events that are called out:When the ORB receives a request, the ORB calls each client-side interceptor’s client_invoke operation in turn. If the return value INVOKE_NO_EXCEPTION is returned from each client_invoke operation (the normal case), the resulting request is marshaled into a message by the ORB and sent to the target object.Under the following circumstances, instead of calling the client_response operation on remaining interceptors back towards the client, the ORB calls the exception_occurred on those interceptors, and then returns an exception back to the client application:
•
• As with the client-side interceptor processing, the ORB calls each target-side interceptor’s target_invoke operation in succession. If the return value INVOKE_NO_EXCEPTION is returned from each target_invoke operation, the request is passed onto the target object.Under the following circumstances, instead of calling the target_response operation on remaining interceptors back towards the client, the ORB calls the exception_occurred on those interceptors, and then returns an exception back towards the client application:
•
• Meta-operations are operations that support the CORBA Object interface, such as is_a, get_interface, and non_existent. Some meta-operations can be performed by the ORB without issuing an invocation, but other operations sometimes need to invoke the object; namely, the is_a, get_interface, and non_existent methods. These operations can thus trigger interceptors.
•
• _non_existent (or _not_existent)