The VisiBroker ORB provides a set of interfaces known as interceptors which provide a framework for plugging-in additional ORB behavior such as security, transactions, or logging. These interceptor interfaces are based on a
callback mechanism. For example, using the interceptors, you can be notified of communications between clients and servers, and modify these communications if you wish, effectively altering the behavior of the VisiBroker ORB.
All the interceptor classes listed above are derived from a common class: Interceptor. This
Interceptor class has defined common methods that are available to its inherited classes.
A request interceptor is used to intercept the flow of a request/reply sequence at specific interception points so that services can transfer context information between clients and servers. For each interception point, the VisiBroker ORB gives an object through which the interceptor can access request information. There are two kinds of request interceptor and their respective request information interfaces:
ClientRequestInterceptor has its interception points implemented on the client-side. There are five interception points defined in
ClientRequestInterceptor by the OMG as shown in the following table:
|
send_request is followed by receive_reply; a start point is followed by an end point
|
|
send_request is followed by receive_other; a start point is followed by an end point
|
ServerRequestInterceptor has its interception points implemented on the server-side. There are five interception points defined in
ServerRequestInterceptor. The following table shows the
ServerRequestInterceptor Interception points.
|
The order of interception points: receive_request_service_contexts, receive_request, send_reply; a start point is followed by an intermediate point which is followed by an end point.
|
IORInterceptor give applications the ability to add information describing the server's or object's ORB service related capabilities to object references to enable the VisiBroker ORB service implementation in the client to function properly. This is done by calling the interception point,
establish_components. An instance of
IORInfo is passed to the interception point. For more information on
IORInfo, see the
VisiBroker for Java APIs documentation.
The PortableInterceptor::Current object (hereafter referred to as
PICurrent) is a table of slots that can be used by Portable Interceptors to transfer thread context information to request context. Use of
PICurrent may not be required. However, if client's thread context information is required at interception point,
PICurrent can be used to transfer this information.
PICurrent is obtained through a call to:
Codec provides a mechanism for interceptors to transfer components between their IDL data types and their CDR encapsulation representations. A
Codec is obtained from
CodecFactory. For more information, see
“CodecFactory”.
This class is used to create a Codec object by specifying the encoding format, the major and minor versions.
CodecFactory can be obtained with a call to:
Portable Interceptors must be registered with the VisiBroker ORB before they can be used. To register a Portable Interceptor, an ORBInitializer object must be implemented and registered. Portable Interceptors are instantiated and registered during ORB initialization by registering an associated
ORBInitializer object which implements its
pre_init( ) or
post_init( ) method, or both. The VisiBroker ORB will call each registered
ORBInitializer with an
ORBInitInfo object during the initializing process.
To register an ORBInitializer, the global method
register_orb_initializer is provided. Each service that implements Interceptors provides an instance of
ORBInitializer. To use a service, an application:
Since the register_orb_initializer( ) is a global method, it would break applet security with respect to the ORB. As a result,
ORBInitializers are registered with VisiBroker ORB by using Java ORB properties instead of calling
register_orb_initializer( ).
where <Service> is the string name of a class which implements
org.omg.PortableInterceptor.ORBInitializer.
Portable Interceptors specified by OMG are scoped globally. VisiBroker has defined “POA scoped Server Request Interceptor”, a public extension to the Portable Interceptors, by adding a new module call PortableInterceptorExt. This new module holds a local interface,
IORInfoExt, which is inherited from
PortableInterceptor::IORInfo and has additional methods to install POA scoped server request interceptor.
To conveniently insert and extract SystemExceptions to and from an
Any, a utility helper class is provided only for VisiBroker for Java. The
com.inprise.vbroker.PortableInterceptor.SystemExceptionHelper class provides the methods to insert and extract the
SystemExceptions into and out of an
Any respectively. You need to import the following package:
To load a client-side request interceptor, a class that uses the ORBInitializer interface must be implemented. This is also applicable for server-side request interceptor as far as initialization is concerned. The following example shows the code for loading:
Each object that implements the interface, ORBInitializer, is also required to inherit from the object
LocalObject. This is necessary because the IDL definition of
ORBInitializer uses the keyword
local.
During the initialization of the ORB, each request Interceptor is added through the implementation of the interface, pre_init(). Inside this interface, the client request Interceptor is added through the method,
add_client_request_interceptor(). The related client request interceptor is required to be instantiated before adding itself into the ORB.
where <Service> is the string name of a class which implements
org.omg.PortableInterceptor.ORBInitializer. For more information, see
“Developing the Client and Server Application”.
The name() is important here because it provides the name to the ORB to identify the correct interceptor that it will load and call during any request or reply. According to the CORBA specification, an interceptor may be anonymous, for example, it has an empty string as the name attribute. In this example, the name,
SampleClientInterceptor, is assigned to the client-side interceptor and
SampleServerInterceptor is assigned to the server-side interceptor.
For the client request interceptor, it is necessary to implement the ClientRequestInterceptor interface for the request interceptor to work properly.
send_request—provides an interception point for querying request information and modifying the service context before the request is sent to the server.
send_poll—provides an interception point for querying information during a Time-Independent Invocation (TII) polling to get the reply sequence.
receive_reply—provides an interception point for querying information on a reply after it is returned from the server and before control is returned to the client.
receive_exception—provides an interception point for querying the exception's information before it is raised to the client.
receive_other—provides an interception point for querying information when a request results in something other than a normal reply or an exception. For example, a request could result in a retry (for example, a GIOP Reply with a
LOCATION_FORWARD status was received); or on asynchronous calls, the reply does not immediately follow the request. However, the control is returned to the client and an ending interception point is called.
receive_request_service_contexts—provides an interception point for getting service context information from the incoming request and transferring it to
PortableInterceptor::Current slot. This interception point is called before the Servant Manager. For more information, see
“Using servants and servant managers”.
receive_request—provides an interception point for querying all the information, including operation parameters.
send_reply—provides an interception point for querying reply information and modifying the reply service context after the target operation has been invoked and before the reply is returned to the client.
send_exception—provides an interception point for querying the exception information and modifying the reply service context before the exception is raised to the client.
send_other—provides an interception point for querying the information available when a request results in something other than a normal reply or an exception. For example, a request could result in a retry (such as, a GIOP Reply with a
LOCATION_FORWARD status was received); or, on asynchronous calls, the reply does not immediately follow the request, but control is returned to the client and an ending interception point is called.
The OMG specification has been strictly followed to implement the mappings of register_orb_initializer, which is registered using Java ORB properties. In the example, the client and server applications actually read the property files,
client.properties, and
server.properties containing the property
where <Service> is the string name of a class which implements
org.omg.PortableInterceptor.ORBInitializer. In this case, the two classes are
SampleClientLoader and
SampleServerLoader.
or double-click the batch file icon if the environment variable, <install_dir>\bin, has already been added to the environment variable,
PATH).