FileDocCategorySizeDatePackage
IORInterceptorImpl.javaAPI DocGlassfish v2 API5723Fri May 04 22:36:42 BST 2007com.sun.jts.pi

IORInterceptorImpl

public class IORInterceptorImpl extends org.omg.CORBA.LocalObject implements org.omg.PortableInterceptor.IORInterceptor
This class implements the IORInterceptor for JTS. When an instance of this class is called by the ORB (during POA creation), it supplies appropriate IOR TaggedComponents for the OTSPolicy / InvocationPolicy associated with the POA, which will be used by the ORB while publishing IORs.
author
Ram Jeyaraman 11/11/2000
version
1.0

Fields Summary
private static final String
name
private org.omg.IOP.Codec
codec
Constructors Summary
public IORInterceptorImpl(org.omg.IOP.Codec codec)


       
        this.codec = codec;
    
Methods Summary
public voiddestroy()

public voidestablish_components(org.omg.PortableInterceptor.IORInfo info)


        // get the OTSPolicy and InvocationPolicy objects

        OTSPolicy otsPolicy = null;

        try {
            otsPolicy = (OTSPolicy)
                info.get_effective_policy(OTS_POLICY_TYPE.value);
        } catch (INV_POLICY e) {
            // ignore. This implies an policy was not explicitly set.
            // A default value will be used instead.
        }

        InvocationPolicy invPolicy = null;
        try {
            invPolicy = (InvocationPolicy)
                info.get_effective_policy(INVOCATION_POLICY_TYPE.value);
        } catch (INV_POLICY e) {
            // ignore. This implies an policy was not explicitly set.
            // A default value will be used instead.
        }

        // get OTSPolicyValue and InvocationPolicyValue from policy objects.

        short otsPolicyValue = FORBIDS.value; // default value
        short invPolicyValue = EITHER.value;  // default value

        if (otsPolicy != null) {
            otsPolicyValue = otsPolicy.value();
        }

        if (invPolicy != null) {
            invPolicyValue = invPolicy.value();
        }

        // use codec to encode policy value into an CDR encapsulation.

        Any otsAny = ORB.init().create_any();
        Any invAny = ORB.init().create_any();

        otsAny.insert_short(otsPolicyValue);
        invAny.insert_short(invPolicyValue);

        byte[] otsCompValue = null;
        byte[] invCompValue = null;
        try {
            otsCompValue = this.codec.encode_value(otsAny);
            invCompValue = this.codec.encode_value(invAny);
        } catch (InvalidTypeForEncoding e) {
            throw new INTERNAL();
        }

        // create IOR TaggedComponents for OTSPolicy and InvocationPolicy.

        TaggedComponent otsComp = new TaggedComponent(TAG_OTS_POLICY.value,
                                                      otsCompValue);
        TaggedComponent invComp = new TaggedComponent(TAG_INV_POLICY.value,
                                                      invCompValue);

        // add ior components.

        info.add_ior_component(otsComp);
        info.add_ior_component(invComp);
    
public java.lang.Stringname()

        return IORInterceptorImpl.name;