org.omg.CORBA.MARSHAL Java Examples

The following examples show how to use org.omg.CORBA.MARSHAL. 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 File: CDRInputStream_1_0.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public Any read_any() {
    Any any = orb.create_any();
    TypeCodeImpl tc = new TypeCodeImpl(orb);

    // read off the typecode

    // REVISIT We could avoid this try-catch if we could peek the typecode
    // kind off this stream and see if it is a tk_value.  Looking at the
    // code we know that for tk_value the Any.read_value() below
    // ignores the tc argument anyway (except for the kind field).
    // But still we would need to make sure that the whole typecode,
    // including encapsulations, is read off.
    try {
        tc.read_value(parent);
    } catch (MARSHAL ex) {
        if (tc.kind().value() != TCKind._tk_value)
            throw ex;
        // We can be sure that the whole typecode encapsulation has been
        // read off.
        dprintThrowable(ex);
    }
    // read off the value of the any
    any.read_value(parent, tc);

    return any;
}
 
Example #2
Source File: IIOPInputStream.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public final int read(byte data[], int offset, int length) throws IOException{
    try{
        readObjectState.readData(this);

        orbStream.read_octet_array(data, offset, length);
        return length;
    } catch (MARSHAL marshalException) {
        if (marshalException.minor
            == OMGSystemException.RMIIIOP_OPTIONAL_DATA_INCOMPATIBLE1) {
            setState(IN_READ_OBJECT_NO_MORE_OPT_DATA);
            return -1;
        }

        throw marshalException;
    } catch(Error e) {
        IOException exc = new IOException(e.getMessage());
        exc.initCause(e) ;
        throw exc ;
    }

}
 
Example #3
Source File: IIOPInputStream.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public final int read(byte data[], int offset, int length) throws IOException{
    try{
        readObjectState.readData(this);

        orbStream.read_octet_array(data, offset, length);
        return length;
    } catch (MARSHAL marshalException) {
        if (marshalException.minor
            == OMGSystemException.RMIIIOP_OPTIONAL_DATA_INCOMPATIBLE1) {
            setState(IN_READ_OBJECT_NO_MORE_OPT_DATA);
            return -1;
        }

        throw marshalException;
    } catch(Error e) {
        IOException exc = new IOException(e.getMessage());
        exc.initCause(e) ;
        throw exc ;
    }

}
 
Example #4
Source File: IIOPInputStream.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public final int skipBytes(int len) throws IOException{
    try{
        readObjectState.readData(this);

        byte buf[] = new byte[len];
        orbStream.read_octet_array(buf, 0, len);
        return len;
    } catch (MARSHAL marshalException) {
        handleOptionalDataMarshalException(marshalException, false);

        throw marshalException;
    } catch(Error e) {
        IOException exc = new IOException(e.getMessage());
        exc.initCause(e) ;
        throw exc ;
    }
}
 
Example #5
Source File: CDRInputStream_1_0.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public Any read_any() {
    Any any = orb.create_any();
    TypeCodeImpl tc = new TypeCodeImpl(orb);

    // read off the typecode

    // REVISIT We could avoid this try-catch if we could peek the typecode
    // kind off this stream and see if it is a tk_value.  Looking at the
    // code we know that for tk_value the Any.read_value() below
    // ignores the tc argument anyway (except for the kind field).
    // But still we would need to make sure that the whole typecode,
    // including encapsulations, is read off.
    try {
        tc.read_value(parent);
    } catch (MARSHAL ex) {
        if (tc.kind().value() != TCKind._tk_value)
            throw ex;
        // We can be sure that the whole typecode encapsulation has been
        // read off.
        dprintThrowable(ex);
    }
    // read off the value of the any
    any.read_value(parent, tc);

    return any;
}
 
Example #6
Source File: ORBImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds and returns a value factory for the given repository ID.
 * The value factory returned was previously registered by a call to
 * {@link #register_value_factory} or is the default factory.
 *
 * @param repositoryID the repository ID.
 * @return the value factory.
 * @exception org.omg.CORBA.BAD_PARAM if unable to locate a factory.
 **/
public synchronized ValueFactory lookup_value_factory(String repositoryID)
{
    checkShutdownState();

    ValueFactory factory =
        (ValueFactory)valueFactoryCache.get(repositoryID);

    if (factory == null) {
        try {
            factory = Utility.getFactory(null, null, null, repositoryID);
        } catch(org.omg.CORBA.MARSHAL ex) {
            throw wrapper.unableFindValueFactory( ex ) ;
        }
    }

    return factory ;
}
 
Example #7
Source File: IIOPInputStream.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public final int skipBytes(int len) throws IOException{
    try{
        readObjectState.readData(this);

        byte buf[] = new byte[len];
        orbStream.read_octet_array(buf, 0, len);
        return len;
    } catch (MARSHAL marshalException) {
        handleOptionalDataMarshalException(marshalException, false);

        throw marshalException;
    } catch(Error e) {
        IOException exc = new IOException(e.getMessage());
        exc.initCause(e) ;
        throw exc ;
    }
}
 
Example #8
Source File: IIOPInputStream.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public final int skipBytes(int len) throws IOException{
    try{
        readObjectState.readData(this);

        byte buf[] = new byte[len];
        orbStream.read_octet_array(buf, 0, len);
        return len;
    } catch (MARSHAL marshalException) {
        handleOptionalDataMarshalException(marshalException, false);

        throw marshalException;
    } catch(Error e) {
        IOException exc = new IOException(e.getMessage());
        exc.initCause(e) ;
        throw exc ;
    }
}
 
Example #9
Source File: IIOPInputStream.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public final float readFloat() throws IOException{
    try{
        readObjectState.readData(this);

        return orbStream.read_float();
    } catch (MARSHAL marshalException) {
        handleOptionalDataMarshalException(marshalException, false);
        throw marshalException;
    } catch(Error e) {
        IOException exc = new IOException(e.getMessage());
        exc.initCause(e);
        throw exc ;
    }
}
 
Example #10
Source File: OMGSystemException.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public MARSHAL notAnObjectImpl( CompletionStatus cs, Throwable t ) {
    MARSHAL exc = new MARSHAL( NOT_AN_OBJECT_IMPL, cs ) ;
    if (t != null)
        exc.initCause( t ) ;
    
    if (logger.isLoggable( Level.WARNING )) {
        Object[] parameters = null ;
        doLog( Level.WARNING, "OMG.notAnObjectImpl",
            parameters, OMGSystemException.class, exc ) ;
    }
    
    return exc ;
}
 
Example #11
Source File: IIOPInputStream.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public final boolean readBoolean() throws IOException{
    try{
        readObjectState.readData(this);

        return orbStream.read_boolean();
    } catch (MARSHAL marshalException) {
        handleOptionalDataMarshalException(marshalException, false);
        throw marshalException;

    } catch(Error e) {
        IOException exc = new IOException(e.getMessage());
        exc.initCause(e);
        throw exc ;
    }
}
 
Example #12
Source File: ObjectKeyFactoryImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/** Creates an ObjectKeyTemplate from the InputStream.  Most of the
* decoding is done inside the handler.
*/
private ObjectKeyTemplate create( InputStream is, Handler handler,
    OctetSeqHolder osh )
{
    ObjectKeyTemplate oktemp = null ;

    try {
        is.mark(0) ;
        int magic = is.read_long() ;

        if (validMagic( magic )) {
            int scid = is.read_long() ;
            oktemp = handler.handle( magic, scid, is, osh ) ;
        }
    } catch (MARSHAL mexc) {
        // XXX log this error
        // ignore this: error handled below because oktemp == null
    }

    if (oktemp == null)
        // If we did not successfully construct a oktemp, reset the
        // stream so that WireObjectKeyTemplate can correctly construct the
        // object key.
        try {
            is.reset() ;
        } catch (IOException exc) {
            // XXX log this error
            // ignore this
        }

    return oktemp ;
}
 
Example #13
Source File: IIOPInputStream.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public final char readChar() throws IOException{
    try{
        readObjectState.readData(this);

        return orbStream.read_wchar();
    } catch (MARSHAL marshalException) {
        handleOptionalDataMarshalException(marshalException, false);
        throw marshalException;

    } catch(Error e) {
        IOException exc = new IOException(e.getMessage());
        exc.initCause(e);
        throw exc ;
    }
}
 
Example #14
Source File: IIOPInputStream.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public final double readDouble() throws IOException{
    try{
        readObjectState.readData(this);

        return orbStream.read_double();
    } catch (MARSHAL marshalException) {
        handleOptionalDataMarshalException(marshalException, false);
        throw marshalException;
    } catch(Error e) {
        IOException exc = new IOException(e.getMessage());
        exc.initCause(e);
        throw exc ;
    }
}
 
Example #15
Source File: ObjectKeyFactoryImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/** Creates an ObjectKeyTemplate from the InputStream.  Most of the
* decoding is done inside the handler.
*/
private ObjectKeyTemplate create( InputStream is, Handler handler,
    OctetSeqHolder osh )
{
    ObjectKeyTemplate oktemp = null ;

    try {
        is.mark(0) ;
        int magic = is.read_long() ;

        if (validMagic( magic )) {
            int scid = is.read_long() ;
            oktemp = handler.handle( magic, scid, is, osh ) ;
        }
    } catch (MARSHAL mexc) {
        // XXX log this error
        // ignore this: error handled below because oktemp == null
    }

    if (oktemp == null)
        // If we did not successfully construct a oktemp, reset the
        // stream so that WireObjectKeyTemplate can correctly construct the
        // object key.
        try {
            is.reset() ;
        } catch (IOException exc) {
            // XXX log this error
            // ignore this
        }

    return oktemp ;
}
 
Example #16
Source File: IIOPInputStream.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public final char readChar() throws IOException{
    try{
        readObjectState.readData(this);

        return orbStream.read_wchar();
    } catch (MARSHAL marshalException) {
        handleOptionalDataMarshalException(marshalException, false);
        throw marshalException;

    } catch(Error e) {
        IOException exc = new IOException(e.getMessage());
        exc.initCause(e);
        throw exc ;
    }
}
 
Example #17
Source File: IIOPInputStream.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public final int readInt() throws IOException{
    try{
        readObjectState.readData(this);

        return orbStream.read_long();
    } catch (MARSHAL marshalException) {
        handleOptionalDataMarshalException(marshalException, false);
        throw marshalException;
    } catch(Error e) {
        IOException exc = new IOException(e.getMessage());
        exc.initCause(e);
        throw exc ;
    }
}
 
Example #18
Source File: IIOPInputStream.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public final boolean readBoolean() throws IOException{
    try{
        readObjectState.readData(this);

        return orbStream.read_boolean();
    } catch (MARSHAL marshalException) {
        handleOptionalDataMarshalException(marshalException, false);
        throw marshalException;

    } catch(Error e) {
        IOException exc = new IOException(e.getMessage());
        exc.initCause(e);
        throw exc ;
    }
}
 
Example #19
Source File: IIOPInputStream.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public final short readShort() throws IOException{
    try{
        readObjectState.readData(this);

        return orbStream.read_short();
    } catch (MARSHAL marshalException) {
        handleOptionalDataMarshalException(marshalException, false);
        throw marshalException;
    } catch(Error e) {
        IOException exc = new IOException(e.getMessage());
        exc.initCause(e);
        throw exc ;
    }
}
 
Example #20
Source File: ObjectKeyFactoryImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/** Creates an ObjectKeyTemplate from the InputStream.  Most of the
* decoding is done inside the handler.
*/
private ObjectKeyTemplate create( InputStream is, Handler handler,
    OctetSeqHolder osh )
{
    ObjectKeyTemplate oktemp = null ;

    try {
        is.mark(0) ;
        int magic = is.read_long() ;

        if (validMagic( magic )) {
            int scid = is.read_long() ;
            oktemp = handler.handle( magic, scid, is, osh ) ;
        }
    } catch (MARSHAL mexc) {
        // XXX log this error
        // ignore this: error handled below because oktemp == null
    }

    if (oktemp == null)
        // If we did not successfully construct a oktemp, reset the
        // stream so that WireObjectKeyTemplate can correctly construct the
        // object key.
        try {
            is.reset() ;
        } catch (IOException exc) {
            // XXX log this error
            // ignore this
        }

    return oktemp ;
}
 
Example #21
Source File: ObjectKeyFactoryImpl.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/** Creates an ObjectKeyTemplate from the InputStream.  Most of the
* decoding is done inside the handler.
*/
private ObjectKeyTemplate create( InputStream is, Handler handler,
    OctetSeqHolder osh )
{
    ObjectKeyTemplate oktemp = null ;

    try {
        is.mark(0) ;
        int magic = is.read_long() ;

        if (validMagic( magic )) {
            int scid = is.read_long() ;
            oktemp = handler.handle( magic, scid, is, osh ) ;
        }
    } catch (MARSHAL mexc) {
        // XXX log this error
        // ignore this: error handled below because oktemp == null
    }

    if (oktemp == null)
        // If we did not successfully construct a oktemp, reset the
        // stream so that WireObjectKeyTemplate can correctly construct the
        // object key.
        try {
            is.reset() ;
        } catch (IOException exc) {
            // XXX log this error
            // ignore this
        }

    return oktemp ;
}
 
Example #22
Source File: ObjectKeyFactoryImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/** Creates an ObjectKeyTemplate from the InputStream.  Most of the
* decoding is done inside the handler.
*/
private ObjectKeyTemplate create( InputStream is, Handler handler,
    OctetSeqHolder osh )
{
    ObjectKeyTemplate oktemp = null ;

    try {
        is.mark(0) ;
        int magic = is.read_long() ;

        if (validMagic( magic )) {
            int scid = is.read_long() ;
            oktemp = handler.handle( magic, scid, is, osh ) ;
        }
    } catch (MARSHAL mexc) {
        // XXX log this error
        // ignore this: error handled below because oktemp == null
    }

    if (oktemp == null)
        // If we did not successfully construct a oktemp, reset the
        // stream so that WireObjectKeyTemplate can correctly construct the
        // object key.
        try {
            is.reset() ;
        } catch (IOException exc) {
            // XXX log this error
            // ignore this
        }

    return oktemp ;
}
 
Example #23
Source File: CDRInputStream_1_0.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private java.lang.Object readIDLValue(int indirection, String repId,
                                      Class clazz, String codebase)
{
    ValueFactory factory ;

    // Always try to find a ValueFactory first, as required by the spec.
    // There are some complications here in the IDL 3.0 mapping (see 1.13.8),
    // but basically we must always be able to override the DefaultFactory
    // or Helper mappings that are also used.  This appears to be the case
    // even in the boxed value cases.  The original code only did the lookup
    // in the case of class implementing either StreamableValue or CustomValue,
    // but abstract valuetypes only implement ValueBase, and really require
    // the use of the repId to find a factory (including the DefaultFactory).
    try {
        // use new-style OBV support (factory object)
        factory = Utility.getFactory(clazz, codebase, orb, repId);
    } catch (MARSHAL marshal) {
        // XXX log marshal at one of the INFO levels

        // Could not get a factory, so try alternatives
        if (!StreamableValue.class.isAssignableFrom(clazz) &&
            !CustomValue.class.isAssignableFrom(clazz) &&
            ValueBase.class.isAssignableFrom(clazz)) {
            // use old-style OBV support (helper object)
            BoxedValueHelper helper = Utility.getHelper(clazz, codebase, repId);
            if (helper instanceof ValueHelper)
                return readIDLValueWithHelper((ValueHelper)helper, indirection);
            else
                return helper.read_value(parent);
        } else {
            // must be a boxed IDLEntity, so make a reflective call to the
            // helper's static read method...
            return readBoxedIDLEntity(clazz, codebase);
        }
    }

    // If there was no error in getting the factory, use it.
    valueIndirection = indirection;  // for callback
    return factory.read_value(parent);
}
 
Example #24
Source File: IIOPInputStream.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public final byte readByte() throws IOException{
    try{
        readObjectState.readData(this);

        return orbStream.read_octet();
    } catch (MARSHAL marshalException) {
        handleOptionalDataMarshalException(marshalException, false);
        throw marshalException;

    } catch(Error e) {
        IOException exc = new IOException(e.getMessage());
        exc.initCause(e);
        throw exc ;
    }
}
 
Example #25
Source File: IIOPInputStream.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public final int readUnsignedShort() throws IOException{
    try{
        readObjectState.readData(this);

        return (orbStream.read_ushort() << 0) & 0x0000FFFF;
    } catch (MARSHAL marshalException) {
        handleOptionalDataMarshalException(marshalException, false);
        throw marshalException;
    } catch(Error e) {
        IOException exc = new IOException(e.getMessage());
        exc.initCause(e);
        throw exc ;
    }
}
 
Example #26
Source File: IIOPInputStream.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public final int readInt() throws IOException{
    try{
        readObjectState.readData(this);

        return orbStream.read_long();
    } catch (MARSHAL marshalException) {
        handleOptionalDataMarshalException(marshalException, false);
        throw marshalException;
    } catch(Error e) {
        IOException exc = new IOException(e.getMessage());
        exc.initCause(e);
        throw exc ;
    }
}
 
Example #27
Source File: IIOPInputStream.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public final byte readByte() throws IOException{
    try{
        readObjectState.readData(this);

        return orbStream.read_octet();
    } catch (MARSHAL marshalException) {
        handleOptionalDataMarshalException(marshalException, false);
        throw marshalException;

    } catch(Error e) {
        IOException exc = new IOException(e.getMessage());
        exc.initCause(e);
        throw exc ;
    }
}
 
Example #28
Source File: OMGSystemException.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public MARSHAL rmiiiopOptionalDataIncompatible2( CompletionStatus cs, Throwable t ) {
    MARSHAL exc = new MARSHAL( RMIIIOP_OPTIONAL_DATA_INCOMPATIBLE2, cs ) ;
    if (t != null)
        exc.initCause( t ) ;
    
    if (logger.isLoggable( Level.WARNING )) {
        Object[] parameters = null ;
        doLog( Level.WARNING, "OMG.rmiiiopOptionalDataIncompatible2",
            parameters, OMGSystemException.class, exc ) ;
    }
    
    return exc ;
}
 
Example #29
Source File: CDRInputStream_1_0.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private java.lang.Object readIDLValue(int indirection, String repId,
                                      Class clazz, String codebase)
{
    ValueFactory factory ;

    // Always try to find a ValueFactory first, as required by the spec.
    // There are some complications here in the IDL 3.0 mapping (see 1.13.8),
    // but basically we must always be able to override the DefaultFactory
    // or Helper mappings that are also used.  This appears to be the case
    // even in the boxed value cases.  The original code only did the lookup
    // in the case of class implementing either StreamableValue or CustomValue,
    // but abstract valuetypes only implement ValueBase, and really require
    // the use of the repId to find a factory (including the DefaultFactory).
    try {
        // use new-style OBV support (factory object)
        factory = Utility.getFactory(clazz, codebase, orb, repId);
    } catch (MARSHAL marshal) {
        // XXX log marshal at one of the INFO levels

        // Could not get a factory, so try alternatives
        if (!StreamableValue.class.isAssignableFrom(clazz) &&
            !CustomValue.class.isAssignableFrom(clazz) &&
            ValueBase.class.isAssignableFrom(clazz)) {
            // use old-style OBV support (helper object)
            BoxedValueHelper helper = Utility.getHelper(clazz, codebase, repId);
            if (helper instanceof ValueHelper)
                return readIDLValueWithHelper((ValueHelper)helper, indirection);
            else
                return helper.read_value(parent);
        } else {
            // must be a boxed IDLEntity, so make a reflective call to the
            // helper's static read method...
            return readBoxedIDLEntity(clazz, codebase);
        }
    }

    // If there was no error in getting the factory, use it.
    valueIndirection = indirection;  // for callback
    return factory.read_value(parent);
}
 
Example #30
Source File: IIOPInputStream.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public final String readUTF() throws IOException{
    try{
        readObjectState.readData(this);

        return internalReadUTF(orbStream);
    } catch (MARSHAL marshalException) {
        handleOptionalDataMarshalException(marshalException, false);
        throw marshalException;
    } catch(Error e) {
        IOException exc = new IOException(e.getMessage());
        exc.initCause(e);
        throw exc ;
    }
}