Java Code Examples for com.sun.corba.se.spi.ior.iiop.GIOPVersion

The following examples show how to use com.sun.corba.se.spi.ior.iiop.GIOPVersion. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: openjdk-8   Source File: CDROutputStream.java    License: GNU General Public License v2.0 6 votes vote down vote up
public CDROutputStream(ORB orb,
                       GIOPVersion version,
                       byte encodingVersion,
                       boolean littleEndian,
                       BufferManagerWrite bufferManager,
                       byte streamFormatVersion,
                       boolean usePooledByteBuffers)
{
    impl = OutputStreamFactory.newOutputStream(orb, version,
                                               encodingVersion);
    impl.init(orb, littleEndian, bufferManager,
              streamFormatVersion, usePooledByteBuffers);

    impl.setParent(this);
    this.orb = orb ;
    this.wrapper = ORBUtilSystemException.get( orb,
        CORBALogDomains.RPC_ENCODING ) ;
}
 
Example 2
public MessageMediator createMessageMediator(Broker broker,
                                             ContactInfo contactInfo,
                                             Connection connection,
                                             String methodName,
                                             boolean isOneWay)
{
    // REVISIT: Would like version, ior, requestid, etc., decisions
    // to be in client subcontract.  Cannot pass these to this
    // factory method because it breaks generic abstraction.
    // Maybe set methods on mediator called from subcontract
    // after creation?
    CorbaMessageMediator messageMediator =
        new CorbaMessageMediatorImpl(
            (ORB) broker,
            contactInfo,
            connection,
            GIOPVersion.chooseRequestVersion( (ORB)broker,
                 effectiveTargetIOR),
            effectiveTargetIOR,
            ((CorbaConnection)connection).getNextRequestId(),
            getAddressingDisposition(),
            methodName,
            isOneWay);

    return messageMediator;
}
 
Example 3
/**
 * If the RMI-IIOP maximum stream format version service context
 * is present, it indicates the maximum stream format version we
 * could use for the reply.  If it isn't present, the default is
 * 2 for GIOP 1.3 or greater, 1 for lower.
 *
 * This is only sent on requests.  Clients can find out the
 * server's maximum by looking for a tagged component in the IOR.
 */
public byte getStreamFormatVersionForReply() {

    // NOTE: The request service contexts may indicate the max.
    ServiceContexts svc = getRequestServiceContexts();

    MaxStreamFormatVersionServiceContext msfvsc
        = (MaxStreamFormatVersionServiceContext)svc.get(
            MaxStreamFormatVersionServiceContext.SERVICE_CONTEXT_ID);

    if (msfvsc != null) {
        byte localMaxVersion = ORBUtility.getMaxStreamFormatVersion();
        byte remoteMaxVersion = msfvsc.getMaximumStreamFormatVersion();

        return (byte)Math.min(localMaxVersion, remoteMaxVersion);
    } else {
        // Defaults to 1 for GIOP 1.2 or less, 2 for
        // GIOP 1.3 or higher.
        if (getGIOPVersion().lessThan(GIOPVersion.V1_3))
            return ORBConstants.STREAM_FORMAT_VERSION_1;
        else
            return ORBConstants.STREAM_FORMAT_VERSION_2;
    }
}
 
Example 4
private byte getStreamFormatVersionForThisRequest(IOR ior,
                                                  GIOPVersion giopVersion)
{

    byte localMaxVersion
        = ORBUtility.getMaxStreamFormatVersion();

    IOR effectiveTargetIOR =
        ((CorbaContactInfo)this.contactInfo).getEffectiveTargetIOR();
    IIOPProfileTemplate temp =
        (IIOPProfileTemplate)effectiveTargetIOR.getProfile().getTaggedProfileTemplate();
    Iterator iter = temp.iteratorById(TAG_RMI_CUSTOM_MAX_STREAM_FORMAT.value);
    if (!iter.hasNext()) {
        // Didn't have the max stream format version tagged
        // component.
        if (giopVersion.lessThan(GIOPVersion.V1_3))
            return ORBConstants.STREAM_FORMAT_VERSION_1;
        else
            return ORBConstants.STREAM_FORMAT_VERSION_2;
    }

    byte remoteMaxVersion
        = ((MaxStreamFormatVersionComponent)iter.next()).getMaxStreamFormatVersion();

    return (byte)Math.min(localMaxVersion, remoteMaxVersion);
}
 
Example 5
public BootstrapResolverImpl(ORB orb, String host, int port) {
    wrapper = ORBUtilSystemException.get( orb,
        CORBALogDomains.ORB_RESOLVER ) ;

    // Create a new IOR with the magic of INIT
    byte[] initialKey = "INIT".getBytes() ;
    ObjectKey okey = orb.getObjectKeyFactory().create(initialKey) ;

    IIOPAddress addr = IIOPFactories.makeIIOPAddress( orb, host, port ) ;
    IIOPProfileTemplate ptemp = IIOPFactories.makeIIOPProfileTemplate(
        orb, GIOPVersion.V1_0, addr);

    IORTemplate iortemp = IORFactories.makeIORTemplate( okey.getTemplate() ) ;
    iortemp.add( ptemp ) ;

    IOR initialIOR = iortemp.makeIOR( (com.sun.corba.se.spi.orb.ORB)orb,
        "", okey.getId() ) ;

    bootstrapDelegate = ORBUtility.makeClientDelegate( initialIOR ) ;
}
 
Example 6
/**
 * Write the service contexts in scMap in a desired order.
 * Right now, the only special case we have is UnknownExceptionInfo,
 * so I'm merely writing it last if present.
 */
private void writeServiceContextsInOrder(OutputStream os, GIOPVersion gv) {

    // Temporarily remove this rather than check it per iteration
    Integer ueInfoId
        = new Integer(UEInfoServiceContext.SERVICE_CONTEXT_ID);

    Object unknownExceptionInfo = scMap.remove(ueInfoId);

    Iterator iter = scMap.keySet().iterator();

    while (iter.hasNext()) {
        Integer id = (Integer)iter.next();

        writeMapEntry(os, id, scMap.get(id), gv);
    }

    // Write the UnknownExceptionInfo service context last
    // (so it will be after the CodeBase) and restore it in
    // the map.
    if (unknownExceptionInfo != null) {
        writeMapEntry(os, ueInfoId, unknownExceptionInfo, gv);

        scMap.put(ueInfoId, unknownExceptionInfo);
    }
}
 
Example 7
Source Project: openjdk-8   Source File: CDROutputStream.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static CDROutputStreamBase newOutputStream(
        ORB orb, GIOPVersion version, byte encodingVersion) {
    switch(version.intValue()) {
        case GIOPVersion.VERSION_1_0:
            return new CDROutputStream_1_0();
        case GIOPVersion.VERSION_1_1:
            return new CDROutputStream_1_1();
    case GIOPVersion.VERSION_1_2:
        if (encodingVersion != Message.CDR_ENC_VERSION) {
            return
                new IDLJavaSerializationOutputStream(encodingVersion);
        }
        return new CDROutputStream_1_2();
    default:
            ORBUtilSystemException wrapper = ORBUtilSystemException.get( orb,
                CORBALogDomains.RPC_ENCODING ) ;
            // REVISIT - what is appropriate?  INTERNAL exceptions
            // are really hard to track later.
            throw wrapper.unsupportedGiopVersion( version ) ;
    }
}
 
Example 8
Source Project: openjdk-8   Source File: ServiceContexts.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Write the given entry from the scMap to the OutputStream.
 * See note on giopVersion.  The service context should
 * know the GIOP version it is meant for.
 */
private void writeMapEntry(OutputStream os, Integer id, Object scObj, GIOPVersion gv) {

    // If it's still in byte[] form, we don't need to
    // unmarshal it here, just copy the bytes into
    // the new stream.

    if (scObj instanceof byte[]) {
        if (isDebugging(os))
            dprint( "Writing service context bytes for id " + id);

        OctetSeqHelper.write(os, (byte[])scObj);

    } else {

        // We actually unmarshaled it into a ServiceContext
        // at some point.
        ServiceContext sc = (ServiceContext)scObj;

        if (isDebugging(os))
            dprint( "Writing service context " + sc ) ;

        sc.write(os, gv);
    }
}
 
Example 9
Source Project: jdk1.8-source-analysis   Source File: MessageBase.java    License: Apache License 2.0 6 votes vote down vote up
public static LocateRequestMessage createLocateRequest(
        ORB orb, GIOPVersion gv, byte encodingVersion,
        int request_id, byte[] object_key) {

    if (gv.equals(GIOPVersion.V1_0)) { // 1.0
        return new LocateRequestMessage_1_0(orb, request_id, object_key);
    } else if (gv.equals(GIOPVersion.V1_1)) { // 1.1
        return new LocateRequestMessage_1_1(orb, request_id, object_key);
    } else if (gv.equals(GIOPVersion.V1_2)) { // 1.2
        TargetAddress target = new TargetAddress();
        target.object_key(object_key);
        LocateRequestMessage msg =
            new LocateRequestMessage_1_2(orb, request_id, target);
        msg.setEncodingVersion(encodingVersion);
        return msg;
    } else {
        throw wrapper.giopVersionError(
            CompletionStatus.COMPLETED_MAYBE);
    }
}
 
Example 10
private CDROutputObject createAppropriateOutputObject(
    CorbaMessageMediator messageMediator,
    Message msg, LocateReplyMessage reply)
{
    CDROutputObject outputObject;

    if (msg.getGIOPVersion().lessThan(GIOPVersion.V1_2)) {
        // locate msgs 1.0 & 1.1 :=> grow,
        outputObject = sun.corba.OutputStreamFactory.newCDROutputObject(
                         (ORB) messageMediator.getBroker(),
                         this,
                         GIOPVersion.V1_0,
                         (CorbaConnection) messageMediator.getConnection(),
                         reply,
                         ORBConstants.STREAM_FORMAT_VERSION_1);
    } else {
        // 1.2 :=> stream
        outputObject = sun.corba.OutputStreamFactory.newCDROutputObject(
                         (ORB) messageMediator.getBroker(),
                         messageMediator,
                         reply,
                         ORBConstants.STREAM_FORMAT_VERSION_1);
    }
    return outputObject;
}
 
Example 11
Source Project: openjdk-jdk8u   Source File: CDRInputStream.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static CDRInputStreamBase newInputStream(
        ORB orb, GIOPVersion version, byte encodingVersion) {
    switch(version.intValue()) {
        case GIOPVersion.VERSION_1_0:
            return new CDRInputStream_1_0();
        case GIOPVersion.VERSION_1_1:
            return new CDRInputStream_1_1();
        case GIOPVersion.VERSION_1_2:
            if (encodingVersion != Message.CDR_ENC_VERSION) {
                return
                  new IDLJavaSerializationInputStream(encodingVersion);
            }
            return new CDRInputStream_1_2();
            // else fall through and report exception.
        default:
            ORBUtilSystemException wrapper = ORBUtilSystemException.get( orb,
                CORBALogDomains.RPC_ENCODING ) ;
            throw wrapper.unsupportedGiopVersion( version ) ;
    }
}
 
Example 12
public CDROutputObject(ORB orb, CorbaMessageMediator mediator,
                       GIOPVersion giopVersion,
                       CorbaConnection connection, Message header,
                       byte streamFormatVersion)
{
    this(
        orb,
        giopVersion,
        header,
        BufferManagerFactory.
        newBufferManagerWrite(giopVersion,
                              header.getEncodingVersion(),
                              orb),
        streamFormatVersion,
        mediator);
    this.connection = connection ;
}
 
Example 13
Source Project: openjdk-8   Source File: MessageBase.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static LocateReplyMessage createLocateReply(
        ORB orb, GIOPVersion gv, byte encodingVersion,
        int request_id, int locate_status, IOR ior) {

    if (gv.equals(GIOPVersion.V1_0)) { // 1.0
        return new LocateReplyMessage_1_0(orb, request_id,
                                          locate_status, ior);
    } else if (gv.equals(GIOPVersion.V1_1)) { // 1.1
        return new LocateReplyMessage_1_1(orb, request_id,
                                          locate_status, ior);
    } else if (gv.equals(GIOPVersion.V1_2)) { // 1.2
        LocateReplyMessage msg =
            new LocateReplyMessage_1_2(orb, request_id,
                                       locate_status, ior);
        msg.setEncodingVersion(encodingVersion);
        return msg;
    } else {
        throw wrapper.giopVersionError(
            CompletionStatus.COMPLETED_MAYBE);
    }
}
 
Example 14
Source Project: hottub   Source File: ParserTable.java    License: GNU General Public License v2.0 6 votes vote down vote up
private Operation makeGVOperation() {
    Operation gvHelper = OperationFactory.listAction( ".",
        OperationFactory.integerAction() ) ;
    Operation gvMain = new Operation() {
        public Object operate( Object value )
        {
            Object[] nums = (Object[])value ;
            int major = ((Integer)(nums[0])).intValue() ;
            int minor = ((Integer)(nums[1])).intValue() ;

            return new GIOPVersion( major, minor ) ;
        }
    } ;

    Operation result = OperationFactory.compose( gvHelper, gvMain );
    return result ;
}
 
Example 15
public void write(org.omg.CORBA.portable.OutputStream ostream) {
    super.write(ostream);
    if (this.service_contexts != null) {
            service_contexts.write(
            (org.omg.CORBA_2_3.portable.OutputStream) ostream,
            GIOPVersion.V1_1);
        } else {
            ServiceContexts.writeNullServiceContext(
            (org.omg.CORBA_2_3.portable.OutputStream) ostream);
    }
    ostream.write_ulong(this.request_id);
    ostream.write_long(this.reply_status);
}
 
Example 16
public void sendCancelRequestWithLock(GIOPVersion giopVersion,
                                      int requestId)
    throws IOException
{
    writeLock();
    try {
        sendCancelRequest(giopVersion, requestId);
    } finally {
        writeUnlock();
    }
}
 
Example 17
Source Project: openjdk-jdk8u   Source File: CDRInputStream.java    License: GNU General Public License v2.0 5 votes vote down vote up
public CDRInputStream(org.omg.CORBA.ORB orb,
                      ByteBuffer byteBuffer,
                      int size,
                      boolean littleEndian,
                      GIOPVersion version,
                      byte encodingVersion,
                      BufferManagerRead bufMgr)
{
    impl = InputStreamFactory.newInputStream((ORB)orb, version,
                                             encodingVersion);

    impl.init(orb, byteBuffer, size, littleEndian, bufMgr);

    impl.setParent(this);
}
 
Example 18
public static BufferManagerWrite newBufferManagerWrite(
    GIOPVersion version, byte encodingVersion, ORB orb) {
    if (encodingVersion != Message.CDR_ENC_VERSION) {
        return new BufferManagerWriteGrow(orb);
    }
    return BufferManagerFactory.newBufferManagerWrite(
        orb.getORBData().getGIOPBuffMgrStrategy(version),
        encodingVersion, orb);
}
 
Example 19
public IIOPProfileTemplateImpl( InputStream istr )
{
    byte major = istr.read_octet() ;
    byte minor = istr.read_octet() ;
    giopVersion = GIOPVersion.getInstance( major, minor ) ;
    primary = new IIOPAddressImpl( istr ) ;
    orb = (ORB)(istr.orb()) ;
    // Handle any tagged components (if applicable)
    if (minor > 0)
        EncapsulationUtility.readIdentifiableSequence(
            this, orb.getTaggedComponentFactoryFinder(), istr ) ;

    makeImmutable() ;
}
 
Example 20
Source Project: TencentKona-8   Source File: Message_1_2.java    License: GNU General Public License v2.0 5 votes vote down vote up
Message_1_2(int _magic, GIOPVersion _GIOP_version, byte _flags,
        byte _message_type, int _message_size) {

    super(_magic,
          _GIOP_version,
          _flags,
          _message_type,
          _message_size);
}
 
Example 21
public IIOPProfileTemplateImpl( ORB orb, GIOPVersion version, IIOPAddress primary )
{
    this.orb = orb ;
    this.giopVersion = version ;
    this.primary = primary ;
    if (giopVersion.getMinor() == 0)
        // Adding tagged components is not allowed for IIOP 1.0,
        // so this template is complete and should be made immutable.
        makeImmutable() ;
}
 
Example 22
public CorbaMessageMediatorImpl(ORB orb,
                                ContactInfo contactInfo,
                                Connection connection,
                                GIOPVersion giopVersion,
                                IOR ior,
                                int requestId,
                                short addrDisposition,
                                String operationName,
                                boolean isOneWay)
{
    this( orb, connection ) ;

    this.contactInfo = (CorbaContactInfo) contactInfo;
    this.addrDisposition = addrDisposition;

    streamFormatVersion =
        getStreamFormatVersionForThisRequest(
            ((CorbaContactInfo)this.contactInfo).getEffectiveTargetIOR(),
            giopVersion);
    streamFormatVersionSet = true;

    requestHeader = (RequestMessage) MessageBase.createRequest(
        this.orb,
        giopVersion,
        ORBUtility.getEncodingVersion(orb, ior),
        requestId,
        !isOneWay,
        ((CorbaContactInfo)this.contactInfo).getEffectiveTargetIOR(),
        this.addrDisposition,
        operationName,
        new ServiceContexts(orb),
        null);
}
 
Example 23
Source Project: JDKSourceCode1.8   Source File: UnknownServiceContext.java    License: MIT License 5 votes vote down vote up
public void write( OutputStream os , GIOPVersion gv)
    throws SystemException
{
    os.write_long( id ) ;
    os.write_long( data.length ) ;
    os.write_octet_array( data, 0, data.length ) ;
}
 
Example 24
protected void addServiceContexts(CorbaMessageMediator messageMediator)
{
    ORB orb = (ORB)messageMediator.getBroker();
    CorbaConnection c = (CorbaConnection) messageMediator.getConnection();
    GIOPVersion giopVersion = messageMediator.getGIOPVersion();

    ServiceContexts contexts = messageMediator.getRequestServiceContexts();

    addCodeSetServiceContext(c, contexts, giopVersion);

    // Add the RMI-IIOP max stream format version
    // service context to every request.  Once we have GIOP 1.3,
    // we could skip it since we now support version 2, but
    // probably safer to always send it.
    contexts.put(MaxStreamFormatVersionServiceContext.singleton);

    // ORBVersion servicecontext needs to be sent
    ORBVersionServiceContext ovsc = new ORBVersionServiceContext(
                    ORBVersionFactory.getORBVersion() ) ;
    contexts.put( ovsc ) ;

    // NOTE : We only want to send the runtime context the first time
    if ((c != null) && !c.isPostInitialContexts()) {
        // Do not do c.setPostInitialContexts() here.
        // If a client interceptor send_request does a ForwardRequest
        // which ends up using the same connection then the service
        // context would not be sent.
        SendingContextServiceContext scsc =
            new SendingContextServiceContext( orb.getFVDCodeBaseIOR() ) ; //d11638
        contexts.put( scsc ) ;
    }
}
 
Example 25
public void write( OutputStream os , GIOPVersion gv)
    throws SystemException
{
    os.write_long( id ) ;
    os.write_long( data.length ) ;
    os.write_octet_array( data, 0, data.length ) ;
}
 
Example 26
public void sendCancelRequestWithLock(GIOPVersion giopVersion,
                                      int requestId)
    throws IOException
{
    writeLock();
    try {
        sendCancelRequest(giopVersion, requestId);
    } finally {
        writeUnlock();
    }
}
 
Example 27
LocateRequestMessage_1_2(ORB orb, int _request_id, TargetAddress _target) {
    super(Message.GIOPBigMagic, GIOPVersion.V1_2, FLAG_NO_FRAG_BIG_ENDIAN,
        Message.GIOPLocateRequest, 0);
    this.orb = orb;
    request_id = _request_id;
    target = _target;
}
 
Example 28
Source Project: jdk8u60   Source File: EncapsOutputStream.java    License: GNU General Public License v2.0 5 votes vote down vote up
public EncapsOutputStream(ORB orb,
                          GIOPVersion version,
                          boolean isLittleEndian)
{
    super(orb, version, Message.CDR_ENC_VERSION, isLittleEndian,
          BufferManagerFactory.newBufferManagerWrite(
                                    BufferManagerFactory.GROW,
                                    Message.CDR_ENC_VERSION,
                                    orb),
          ORBConstants.STREAM_FORMAT_VERSION_1,
          usePooledByteBuffers);
}
 
Example 29
public IIOPProfileTemplateImpl( InputStream istr )
{
    byte major = istr.read_octet() ;
    byte minor = istr.read_octet() ;
    giopVersion = GIOPVersion.getInstance( major, minor ) ;
    primary = new IIOPAddressImpl( istr ) ;
    orb = (ORB)(istr.orb()) ;
    // Handle any tagged components (if applicable)
    if (minor > 0)
        EncapsulationUtility.readIdentifiableSequence(
            this, orb.getTaggedComponentFactoryFinder(), istr ) ;

    makeImmutable() ;
}
 
Example 30
LocateRequestMessage_1_2(ORB orb, int _request_id, TargetAddress _target) {
    super(Message.GIOPBigMagic, GIOPVersion.V1_2, FLAG_NO_FRAG_BIG_ENDIAN,
        Message.GIOPLocateRequest, 0);
    this.orb = orb;
    request_id = _request_id;
    target = _target;
}