Interceptors

ADORB framework support two kinds of interceptors - the IOR interceptors and the request interceptors. Interceptors simply register themselves with the ORB notification center for specific notifications that are posted by ORB at specific interception points.
The ORB notification center is returned by the ORB class method + notificationCenter.

IOR Interceptors

An IOR interceptor registers with the ORB notification center for notification name ORBDidCreateObjectProfile. The notification is posted after the profile is created for a local CORBAObject.
This allows the interceptor to add IOR components (objects of class IDLTaggedComponent) to the CORBAObject profile, particularly when the CORBAObject is created implicitly for an activatable object (see Object Activation).
The notification object is the CORBAObject. The notification userInfo dictionary contains one key/value pair with the CORBAObject's profile for key @"profile".

Request Interceptors

A request Interceptor is designed to intercept the flow of a request/reply sequence through the ORB at specific points so that services can query the request information and manipulate the service contexts that are propagated between clients and servers. The primary use of request Interceptors is to enable ORB services to transfer context information between clients and servers. See OMG specification formal/04-03-12 (CORBA specification) for detailed specification.
ADORB implementation differs from the OMG specification in that that an interceptor can use any method names instead of fixed by the specification and that an interceptor registers with ORB simply by subscribing for specific notifications. The send_poll interception point is not supported by ADORB.

ORB posts the following notifications during the request/reply flow

NotificationDescription
ORBWillSendRequest This client-side interception point corresponds to send_request.
ORBDidReceiveRequestContext This server-side interception point corresponds to receive_request_service_contexts.
ORBDidReceiveRequest This server-side interception point corresponds to receive_request.
ORBWillSendResponse This server-side interception point corresponds to send_reply.
ORBWillSendException This server-side interception point corresponds to send_exception.
ORBWillSendOther This server-side interception point corresponds to send_other.
ORBDidReceiveResponse This client-side interception point corresponds to receive_reply.
ORBDidReceiveException This client-side interception point corresponds to receive_exception.
ORBDidReceiveOther This client-side interception point corresponds to receive_other.

The following values are used as keys in the userInfo dictionary for the interceptor notifications.

KeyDescription
ORBServiceContextKey Request Service Context dictionary for notifications ORBWillSendRequest, ORBDidReceiveRequestContext and ORBDidReceiveRequest. Response service context for other interceptor notifications.
ORBOperationNameKeyOperation name
ORBObjectKeyTarget object
ORBRequestIdKeyRequest ID, NSNumber
ORBExceptionKeyNSException, if any
ORBReplyStatusKeyReply status, NSNumber
ORBOnewayKeyNSNumber(BOOL), whether the operation is one-way.

This code shows registering the client-side interceptor with ORB in the interceptor's init method

- init
{
	self = [super init];
	... // other initialization
	[[ORB notificationCenter]addObserver:self selector:@selector(sendRequest:) name:ORBWillSendRequest object:nil];
	[[ORB notificationCenter]addObserver:self selector:@selector(receiveReply:) name:ORBDidReceiveResponse object:nil];
	[[ORB notificationCenter]addObserver:self selector:@selector(receiveException:) name:ORBDidReceiveException object:nil];
	[[ORB notificationCenter]addObserver:self selector:@selector(receiveOther:) name:ORBDidReceiveOther object:nil];
	...
	return self;
}

- (void) dealloc
{
	[[ORB notificationCenter]removeObserver:self];
	
	...
	[super dealloc];
}

Client-Side Request Interceptors

A client-side interceptor subscribes with ORB notification center for the notifications ORBWillSendRequest, ORBDidReceiveResponse, ORBDidReceiveException and ORBDidReceiveOther. There can be any number of client-side request interceptors.

ORBWillSendRequest notification is posted before the request is sent to the server. Interceptors can can query request information and modify service contexts before the request is sent to the server.
If interceptor's method for this notification returns normally the interceptor is put on a "flow stack". Interceptor may raise CORBASystemException or ForwardRequest exception. In this case the request is not sent to the server and the remaining interceptors are not notified. Instead the exception is added to the userInfo dictionary and notification ORBDidReceiveException or ORBDidReceiveOther is posted.

ORBDidReceiveResponse notification allows interceptors to query the information on a reply after it is returned from the server and before control is returned to the client. This notification is sent only to the interceptors on the "flow stack". An interceptor is popped from the "flow stack" and is notified (if it did subscribe for this notification).
An interceptor may raise CORBASystemException or ForwardRequest exception. In this case the remaining interceptors are not notified, instead the exception is added to the userInfo dictionary and ORBDidReceiveException or ORBDidReceiveOther notification is posted.

Server-Side Request Interceptors

Protocol ORBRequestInfo

- (SEL)selector

Returns the method selector.

- (SEL)selector

Returns the method selector.

- (NSDictionary*)requestContext

Returns the request contexts dictionary. The dictionary contains IDLServiceContext objects with contextId (NSNumber) as key.

- (IDLServiceContext*) requestContextWithContextId:(unsigned)contextId

Returns the request context for specified contextId or nil.

- (void) addRequestContext:(IDLServiceContext*)context

Adds specified context to the request contexts dictionary.

- (void) removeRequestContextWithContextId:(unsigned)contextId

Removes service context with specified contextId from the request contexts dictionary.

- (NSDictionary*) responseContext

Return response contexts dictionary.

- (IDLServiceContext*) responseContextWithContextId:(unsigned)contextId

Returns the response context for specified contextId or nil.

- (void) addResponseContext:(IDLServiceContext*)context

Adds specified context to the response contexts dictionary.

- (void) removeResponseContextWithContextId:(unsigned)contextId

Removes service context with specified contextId from the response contexts dictionary.

- (NSDictionary*) arguments

Return invocation arguments.

- (IDLFunction*) operationObject

Return definition object for the operation.

- (CORBAObject*) object

Return operation target object.

- (unsigned) completionStatus

Return operation's current completion status.