by Uwe Meding

The Interoperable Object Reference (IOR) is a key element in the world of CORBA. It refers uniquely to an object on the server. The actual content is typically small and (in its binary form) transferred directly though the TCP/IP sockets. The IOR contains everything needed to materialize (or re-materialize) an object on the server.

One of the neat aspects of CORBA is that there are many hooks to influence how the IOR is created. From an application developers point of view, there are two big steps:

  1. Create the raw object reference
  2. Add decorations, or tweak the reference
The first step is to create an IOR such that we can indeed instantiate the object implementation. The second step allows us to augment the IOR before it is sent to the client. So in effect we have a separation between the application server and the functions it provides (the implementation) and the deployment of  the server application. 
For example, we can attach references to resources in we need for the application server, keeping track of the server invocations, facilitate some kind of cache or garbage collection etc.

Use the following recipe to the create an IOR interceptor:

1. Add a custom ORB initializer during the CORBA server setup phase:

// CORBA properties, like host, port, ip address etc.
Properties orbProps = new Properties();
String interceptorPropName = "org.omg.PortableInterceptor.ORBInitializerClass.";
orbProps.put(interceptorPropName+MyORBInitializer.class.getName(), "");
// Create the ORB
ORB orb = ORB.init(new String[0], orbProps);

2. Create a custom ORB initializer

public class MyORBInitializer extends LocalObject implements ORBInitializer {
    private final ORB orb;
    public void pre_init(ORBInitInfo info) {

    public void post_init(ORBInitInfo info) {
        try {
            CodecFactory codecFactory = CodecFactoryHelper.narrow(
            Encoding encoding = new Encoding((short) 0, (byte) 1, (byte) 2);
            Codec codec = codecFactory.create_codec(encoding);
            MyIORInterceptor iorInterceptor = new MyIORInterceptor(orb,codec);
        } catch (Throwable t) {
            throw new IllegalStateException("ORB initializer failed");

3. Create the IOR interceptor

public class MyIORInterceptor extends LocalObject implements IORInterceptor {
    private final static String ALT_ADDRESS = "";
    private final static short ALT_PORT = 20223;
    private final ORB orb;
    private final Codec codec;

    public MyIORInterceptor(ORB orb,Codec codec) {
        this.orb = orb;
        this.codec = codec;

    public void establish_components(IORInfo iorInfo) {
        // Example: create the tag for an alternate address
        try {
            IIOPAddress iiopAddress = new IIOPAddress(ALT_ADDRESS, ALT_PORT);
            Any any = corbaService.getORB().create_any();
            IIOPAddressHelper.insert(any, iiopAddress);

            byte[] data = codec.encode_value(any);
            TaggedComponent alt = new TaggedComponent(
        } catch (Exception e) {
            throw new IllegalStateException("Failed to add alternate address");

    public void destroy() {

    public String name() {
        return "MyIORInterceptor";

That’s it!

Leave a Reply