Java Code Examples for org.omg.CORBA.Any

The following are top voted examples for showing how to use org.omg.CORBA.Any. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: OpenJSharp   File: AnyImpl.java   View source code 6 votes vote down vote up
public AnyImpl(ORB orb, Any obj) {
    this(orb);

    if ((obj instanceof AnyImpl)) {
        AnyImpl objImpl = (AnyImpl)obj;
        typeCode = objImpl.typeCode;
        value = objImpl.value;
        object = objImpl.object;
        isInitialized = objImpl.isInitialized;

        if (objImpl.stream != null)
            stream = objImpl.stream.dup();

    } else {
        read_value(obj.create_input_stream(), obj.type());
    }
}
 
Example 2
Project: OpenJSharp   File: DynUnionImpl.java   View source code 6 votes vote down vote up
public void set_to_default_member ()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    int defaultIndex = defaultIndex();
    if (defaultIndex == -1) {
        throw new TypeMismatch();
    }
    try {
        clearData();
        index = 1;
        currentMemberIndex = defaultIndex;
        currentMember = DynAnyUtil.createMostDerivedDynAny(memberType(defaultIndex), orb);
        components = new DynAny[] {discriminator, currentMember};
        Any discriminatorAny = orb.create_any();
        discriminatorAny.insert_octet((byte)0);
        discriminator = DynAnyUtil.createMostDerivedDynAny(discriminatorAny, orb, false);
        representations = REPRESENTATION_COMPONENTS;
    } catch (InconsistentTypeCode ictc) {}
}
 
Example 3
Project: openjdk-jdk10   File: Util.java   View source code 6 votes vote down vote up
/**
 * When using our own ORB and Any implementations, we need to get
 * the ORB version and create the type code appropriately.  This is
 * to overcome a bug in which the JDK 1.3.x ORBs used a tk_char
 * rather than a tk_wchar to describe a Java char field.
 *
 * This only works in RMI-IIOP with Util.writeAny since we actually
 * know what ORB and stream we're writing with when we insert
 * the value.
 *
 * Returns null if it wasn't possible to create the TypeCode (means
 * it wasn't our ORB or Any implementation).
 *
 * This does not handle null objs.
 */
private TypeCode createTypeCode(Serializable obj,
                                org.omg.CORBA.Any any,
                                org.omg.CORBA.ORB orb) {

    if (any instanceof com.sun.corba.se.impl.corba.AnyImpl &&
        orb instanceof ORB) {

        com.sun.corba.se.impl.corba.AnyImpl anyImpl
            = (com.sun.corba.se.impl.corba.AnyImpl)any;

        ORB ourORB = (ORB)orb;

        return anyImpl.createTypeCodeForClass(obj.getClass(), ourORB);

    } else
        return null;
}
 
Example 4
Project: OpenJSharp   File: ClientRequestInfoImpl.java   View source code 6 votes vote down vote up
/**
 * See RequestInfoImpl for javadoc.
 */
public Any result (){
    checkAccess( MID_RESULT );

    if( cachedResult == null ) {
        if( request == null ) {
            throw stdWrapper.piOperationNotSupported5() ;
        }
        // Get the result from the DII request data.
        NamedValue nvResult = request.result( );

        if( nvResult == null ) {
            throw wrapper.piDiiResultIsNull() ;
        }

        cachedResult = nvResult.value();
    }

    // Good citizen: In the interest of efficiency, we assume that
    // interceptors will not modify the contents of the result Any.
    // Otherwise, we would need to create a deep copy of the Any.

    return cachedResult;
}
 
Example 5
Project: openjdk-jdk10   File: DynUnionImpl.java   View source code 6 votes vote down vote up
public void set_to_no_active_member ()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    // _REVISIT_ How does one check for "entire range of discriminator values"?
    if (defaultIndex() != -1) {
        throw new TypeMismatch();
    }
    checkInitComponents();
    Any discriminatorAny = getAny(discriminator);
    // erase the discriminators value so that it does not correspond
    // to any of the unions case labels
    discriminatorAny.type(discriminatorAny.type());
    index = 0;
    currentMemberIndex = NO_INDEX;
    // Necessary to guarantee OBJECT_NOT_EXIST in member()
    currentMember.destroy();
    currentMember = null;
    components[0] = discriminator;
    representations = REPRESENTATION_COMPONENTS;
}
 
Example 6
Project: openjdk-jdk10   File: PIHandlerImpl.java   View source code 6 votes vote down vote up
/** This is the implementation of standard API defined in org.omg.CORBA.ORB
 *  class. This method finds the Policy Factory for the given Policy Type
 *  and instantiates the Policy object from the Factory. It will throw
 *  PolicyError exception, If the PolicyFactory for the given type is
 *  not registered.
 *  _REVISIT_, Once Policy Framework work is completed, Reorganize
 *  this method to com.sun.corba.se.spi.orb.ORB.
 */
public org.omg.CORBA.Policy create_policy(int type, org.omg.CORBA.Any val)
    throws org.omg.CORBA.PolicyError
{
    if( val == null ) {
        nullParam( );
    }
    if( policyFactoryTable == null ) {
        throw new org.omg.CORBA.PolicyError(
            "There is no PolicyFactory Registered for type " + type,
            BAD_POLICY.value );
    }
    PolicyFactory factory = (PolicyFactory)policyFactoryTable.get(
        new Integer(type) );
    if( factory == null ) {
        throw new org.omg.CORBA.PolicyError(
            " Could Not Find PolicyFactory for the Type " + type,
            BAD_POLICY.value);
    }
    org.omg.CORBA.Policy policy = factory.create_policy( type, val );
    return policy;
}
 
Example 7
Project: openjdk-jdk10   File: DynAnyBasicImpl.java   View source code 5 votes vote down vote up
public void from_any (org.omg.CORBA.Any value)
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
           org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    super.from_any(value);
    index = NO_INDEX;
}
 
Example 8
Project: openjdk-jdk10   File: DynUnionImpl.java   View source code 5 votes vote down vote up
protected boolean initializeComponentsFromAny() {
    try {
        InputStream input = any.create_input_stream();
        Any discriminatorAny = DynAnyUtil.extractAnyFromStream(discriminatorType(), input, orb);
        discriminator = DynAnyUtil.createMostDerivedDynAny(discriminatorAny, orb, false);
        currentMemberIndex = currentUnionMemberIndex(discriminatorAny);
        Any memberAny = DynAnyUtil.extractAnyFromStream(memberType(currentMemberIndex), input, orb);
        currentMember = DynAnyUtil.createMostDerivedDynAny(memberAny, orb, false);
        components = new DynAny[] {discriminator, currentMember};
    } catch (InconsistentTypeCode ictc) { // impossible
    }
    return true;
}
 
Example 9
Project: OpenJSharp   File: AnyImpl.java   View source code 5 votes vote down vote up
static AnyImpl convertToNative(ORB orb, Any any) {
    if (any instanceof AnyImpl) {
        return (AnyImpl)any;
    } else {
        AnyImpl anyImpl = new AnyImpl(orb, any);
        anyImpl.typeCode = TypeCodeImpl.convertToNative(orb, anyImpl.typeCode);
        return anyImpl;
    }
}
 
Example 10
Project: OpenJSharp   File: ORBUtility.java   View source code 5 votes vote down vote up
/**
 * Static method for writing a CORBA standard exception to an Any.
 * @param any The Any to write the SystemException into.
 */
public static void insertSystemException(SystemException ex, Any any) {
    OutputStream out = any.create_output_stream();
    ORB orb = (ORB)(out.orb());
    String name = ex.getClass().getName();
    String repID = ORBUtility.repositoryIdOf(name);
    out.write_string(repID);
    out.write_long(ex.minor);
    out.write_long(ex.completed.value());
    any.read_value(out.create_input_stream(),
        getSystemExceptionTypeCode(orb, repID, name));
}
 
Example 11
Project: OpenJSharp   File: AnyImpl.java   View source code 5 votes vote down vote up
/**
 * See the description of the <a href="#anyOps">general Any operations.</a>
 */
public Any extract_any()
{
    //debug.log ("extract_any");
    checkExtractBadOperation( TCKind._tk_any ) ;
    return (Any)object;
}
 
Example 12
Project: OpenJSharp   File: CDREncapsCodec.java   View source code 5 votes vote down vote up
/**
 * Convert the given any into a CDR encapsulated octet sequence.
 * If sendTypeCode is true, the type code is sent with the message, as in
 * a standard encapsulation.  If it is false, only the data is sent.
 * Either way, the endian type is sent as the first part of the message.
 */
private byte[] encodeImpl( Any data, boolean sendTypeCode )
    throws InvalidTypeForEncoding
{
    if( data == null )
        throw wrapper.nullParam() ;

    // _REVISIT_ Note that InvalidTypeForEncoding is never thrown in
    // the body of this method.  This is due to the fact that CDR*Stream
    // will never throw an exception if the encoding is invalid.  To
    // fix this, the CDROutputStream must know the version of GIOP it
    // is encoding for and it must check to ensure that, for example,
    // wstring cannot be encoded in GIOP 1.0.
    //
    // As part of the GIOP 1.2 work, the CDRInput and OutputStream will
    // be versioned.  This can be handled once this work is complete.

    // Create output stream with default endianness.
    EncapsOutputStream cdrOut =
        sun.corba.OutputStreamFactory.newEncapsOutputStream(
        (com.sun.corba.se.spi.orb.ORB)orb, giopVersion );

    // This is an encapsulation, so put out the endian:
    cdrOut.putEndian();

    // Sometimes encode type code:
    if( sendTypeCode ) {
        cdrOut.write_TypeCode( data.type() );
    }

    // Encode value and return.
    data.write_value( cdrOut );

    return cdrOut.toByteArray();
}
 
Example 13
Project: OpenJSharp   File: ORBImpl.java   View source code 5 votes vote down vote up
public synchronized org.omg.CORBA.Policy create_policy( int type,
    org.omg.CORBA.Any val ) throws org.omg.CORBA.PolicyError
{
    checkShutdownState() ;

    return pihandler.create_policy( type, val ) ;
}
 
Example 14
Project: openjdk-jdk10   File: SlotTable.java   View source code 5 votes vote down vote up
/**
 * This method sets the slot data at the given slot id (index).
 */
public void set_slot( int id, Any data ) throws InvalidSlot
{
    // First check whether the slot is allocated
    // If not, raise the invalid slot exception
    if( id >= theSlotData.length ) {
        throw new InvalidSlot();
    }
    dirtyFlag = true;
    theSlotData[id] = data;
}
 
Example 15
Project: openjdk-jdk10   File: ClientRequestInfoImpl.java   View source code 5 votes vote down vote up
/**
 * Contains the exception to be returned to the client.
 */
public Any received_exception (){
    checkAccess( MID_RECEIVED_EXCEPTION );

    if( cachedReceivedException == null ) {
        cachedReceivedException = exceptionToAny( exception );
    }

    // Good citizen: In the interest of efficiency, we assume interceptors
    // will not modify the returned Any in any way so we need
    // not make a deep copy of it.

    return cachedReceivedException;
}
 
Example 16
Project: OpenJSharp   File: ServerRequestImpl.java   View source code 5 votes vote down vote up
public void set_exception(Any exc)
{
    // except can be called by the DIR at any time (CORBA 2.2 section 6.3).

    if ( exc == null )
        throw _wrapper.setExceptionCalledNullArgs() ;

    // Ensure that the Any contains a SystemException or a
    // UserException. If the UserException is not a declared exception,
    // the client will get an UNKNOWN exception.
    TCKind kind = exc.type().kind();
    if ( kind != TCKind.tk_except )
        throw _wrapper.setExceptionCalledBadType() ;

    _exception = exc;

    // Inform Portable interceptors of the exception that was set
    // so sending_exception can return the right value.
    _orb.getPIHandler().setServerPIExceptionInfo( _exception );

    // The user can only call arguments once and not at all after
    // set_exception.  (internal flags ensure this).  However, the user
    // can call set_exception multiple times.  Therefore, we only
    // invoke receive_request the first time set_exception is
    // called (if they haven't already called arguments).
    if( !_exceptionSet && !_paramsCalled ) {
        // We need to invoke intermediate points here.
        _orb.getPIHandler().invokeServerPIIntermediatePoint();
    }

    _exceptionSet = true;

    // actual marshaling of the reply msg header and exception takes place
    // after the DSI returns control to the ORB.
}
 
Example 17
Project: openjdk-jdk10   File: DynAnyConstructedImpl.java   View source code 5 votes vote down vote up
public void from_any (org.omg.CORBA.Any value)
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
           org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    clearData();
    super.from_any(value);
    representations = REPRESENTATION_ANY;
    index = 0;
}
 
Example 18
Project: OpenJSharp   File: CDREncapsCodec.java   View source code 5 votes vote down vote up
/**
 * Decode the given octet sequence into an any based on a CDR
 * encapsulated octet sequence.  The type code is expected not to appear
 * in the octet sequence, and the given type code is used instead.
 */
public Any decode_value( byte[] data, TypeCode tc )
    throws FormatMismatch, TypeMismatch
{
    if( data == null )
        throw wrapper.nullParam() ;
    if( tc == null )
        throw  wrapper.nullParam() ;
    return decodeImpl( data, tc );
}
 
Example 19
Project: OpenJSharp   File: DynAnyConstructedImpl.java   View source code 5 votes vote down vote up
public void from_any (org.omg.CORBA.Any value)
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
           org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    clearData();
    super.from_any(value);
    representations = REPRESENTATION_ANY;
    index = 0;
}
 
Example 20
Project: OpenJSharp   File: DynAnyConstructedImpl.java   View source code 5 votes vote down vote up
public void insert_any(org.omg.CORBA.Any value)
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
           org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    if (index == NO_INDEX)
        throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
    DynAny currentComponent = current_component();
    if (DynAnyUtil.isConstructedDynAny(currentComponent))
        throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
    currentComponent.insert_any(value);
}
 
Example 21
Project: openjdk-jdk10   File: CorbaServerRequestDispatcherImpl.java   View source code 5 votes vote down vote up
protected CorbaMessageMediator handleDynamicResult(
    ServerRequestImpl sreq,
    CorbaMessageMediator req)
{
    try {
        if (orb.subcontractDebugFlag) {
            dprint(".handleDynamicResult->: " + opAndId(req));
        }

        CorbaMessageMediator response = null ;

        // Check if ServerRequestImpl.result() has been called
        Any excany = sreq.checkResultCalled();

        if (excany == null) { // normal return
            if (orb.subcontractDebugFlag) {
                dprint(".handleDynamicResult: " + opAndId(req)
                       + ": handling normal result");
            }

            // Marshal out/inout/return parameters into the ReplyMessage
            response = sendingReply(req);
            OutputStream os = (OutputStream) response.getOutputObject();
            sreq.marshalReplyParams(os);
        }  else {
            if (orb.subcontractDebugFlag) {
                dprint(".handleDynamicResult: " + opAndId(req)
                       + ": handling error");
            }

            response = sendingReply(req, excany);
        }

        return response ;
    } finally {
        if (orb.subcontractDebugFlag) {
            dprint(".handleDynamicResult<-: " + opAndId(req));
        }
    }
}
 
Example 22
Project: openjdk-jdk10   File: NamedValueImpl.java   View source code 5 votes vote down vote up
public NamedValueImpl(ORB orb,
                      String name,
                      Any value,
                      int flags)
{
    // Note: This orb could be an instanceof ORBSingleton or ORB
    _orb    = orb;
    _name   = name;
    _value  = value;
    _flags      = flags;
}
 
Example 23
Project: openjdk-jdk10   File: IDLJavaSerializationInputStream.java   View source code 5 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 (org.omg.CORBA.MARSHAL ex) {
            if (tc.kind().value() != org.omg.CORBA.TCKind._tk_value) {
                throw ex;
            }
            // We can be sure that the whole typecode encapsulation has been
            // read off.
            ex.printStackTrace();
        }

        // read off the value of the any.
        any.read_value(parent, tc);

        return any;
    }
 
Example 24
Project: openjdk-jdk10   File: Util.java   View source code 5 votes vote down vote up
/**
 * Reads a java.lang.Object as a CORBA any.
 * @param in the stream from which to read the any.
 * @return the object read from the stream.
 */
public Object readAny(InputStream in)
{
    Any any = in.read_any();
    if ( any.type().kind().value() == TCKind._tk_objref )
        return any.extract_Object ();
    else
        return any.extract_Value();
}
 
Example 25
Project: openjdk-jdk10   File: ORBImpl.java   View source code 5 votes vote down vote up
public synchronized org.omg.CORBA.Policy create_policy( int type,
    org.omg.CORBA.Any val ) throws org.omg.CORBA.PolicyError
{
    checkShutdownState() ;

    return pihandler.create_policy( type, val ) ;
}
 
Example 26
Project: OpenJSharp   File: PIHandlerImpl.java   View source code 5 votes vote down vote up
public void setServerPIExceptionInfo( Any exception )
{
    if( !hasServerInterceptors ) return;

    ServerRequestInfoImpl info = peekServerRequestInfoImplStack();
    info.setDSIException( exception );
}
 
Example 27
Project: OpenJSharp   File: DynUnionImpl.java   View source code 5 votes vote down vote up
private int currentUnionMemberIndex(Any discriminatorValue) {
    int memberCount = memberCount();
    Any memberLabel;
    for (int i=0; i<memberCount; i++) {
        memberLabel = memberLabel(i);
        if (memberLabel.equal(discriminatorValue)) {
            return i;
        }
    }
    if (defaultIndex() != -1) {
        return defaultIndex();
    }
    return NO_INDEX;
}
 
Example 28
Project: openjdk-jdk10   File: CDREncapsCodec.java   View source code 5 votes vote down vote up
/**
 * Convert the given any into a CDR encapsulated octet sequence
 */
public byte[] encode( Any data )
    throws InvalidTypeForEncoding
{
    if ( data == null )
        throw wrapper.nullParam() ;
    return encodeImpl( data, true );
}
 
Example 29
Project: OpenJSharp   File: DynValueBoxImpl.java   View source code 5 votes vote down vote up
public Any get_boxed_value()
    throws org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (isNull) {
        throw new InvalidValue();
    }
    checkInitAny();
    return any;
}
 
Example 30
Project: OpenJSharp   File: RequestInfoImpl.java   View source code 5 votes vote down vote up
/**
 * Returns the data from the given slot of the PortableInterceptor::Current
 * that is in the scope of the request.
 * <p>
 * If the given slot has not been set, then an any containing a type code
 * with a TCKind value of tk_null is returned.
 * <p>
 * If the ID does not define an allocated slot, InvalidSlot is raised.
 */
public Any get_slot (int id)
    throws InvalidSlot
{
    // access is currently valid for all states:
    //checkAccess( MID_GET_SLOT );
    // Delegate the call to the slotTable which was set when RequestInfo was
    // created.
    return slotTable.get_slot( id );
}
 
Example 31
Project: openjdk-jdk10   File: CDREncapsCodec.java   View source code 5 votes vote down vote up
/**
 * Convert the given any into a CDR encapsulated octet sequence.
 * If sendTypeCode is true, the type code is sent with the message, as in
 * a standard encapsulation.  If it is false, only the data is sent.
 * Either way, the endian type is sent as the first part of the message.
 */
private byte[] encodeImpl( Any data, boolean sendTypeCode )
    throws InvalidTypeForEncoding
{
    if( data == null )
        throw wrapper.nullParam() ;

    // _REVISIT_ Note that InvalidTypeForEncoding is never thrown in
    // the body of this method.  This is due to the fact that CDR*Stream
    // will never throw an exception if the encoding is invalid.  To
    // fix this, the CDROutputStream must know the version of GIOP it
    // is encoding for and it must check to ensure that, for example,
    // wstring cannot be encoded in GIOP 1.0.
    //
    // As part of the GIOP 1.2 work, the CDRInput and OutputStream will
    // be versioned.  This can be handled once this work is complete.

    // Create output stream with default endianness.
    EncapsOutputStream cdrOut =
        sun.corba.OutputStreamFactory.newEncapsOutputStream(
        (com.sun.corba.se.spi.orb.ORB)orb, giopVersion );

    // This is an encapsulation, so put out the endian:
    cdrOut.putEndian();

    // Sometimes encode type code:
    if( sendTypeCode ) {
        cdrOut.write_TypeCode( data.type() );
    }

    // Encode value and return.
    data.write_value( cdrOut );

    return cdrOut.toByteArray();
}
 
Example 32
Project: OpenJSharp   File: DynAnyCollectionImpl.java   View source code 5 votes vote down vote up
public void set_elements (org.omg.CORBA.Any[] value)
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
           org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    checkValue(value);

    components = new DynAny[value.length];
    anys = value;

    // We know that this is of kind tk_sequence or tk_array
    TypeCode expectedTypeCode = getContentType();
    for (int i=0; i<value.length; i++) {
        if (value[i] != null) {
            if (! value[i].type().equal(expectedTypeCode)) {
                clearData();
                // _REVISIT_ More info
                throw new TypeMismatch();
            }
            try {
                // Creates the appropriate subtype without copying the Any
                components[i] = DynAnyUtil.createMostDerivedDynAny(value[i], orb, false);
                //System.out.println(this + " created component " + components[i]);
            } catch (InconsistentTypeCode itc) {
                throw new InvalidValue();
            }
        } else {
            clearData();
            // _REVISIT_ More info
            throw new InvalidValue();
        }
    }
    index = (value.length == 0 ? NO_INDEX : 0);
    // Other representations are invalidated by this operation
    representations = REPRESENTATION_COMPONENTS;
}
 
Example 33
Project: openjdk-jdk10   File: DynAnyCollectionImpl.java   View source code 5 votes vote down vote up
public void set_elements (org.omg.CORBA.Any[] value)
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
           org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    checkValue(value);

    components = new DynAny[value.length];
    anys = value;

    // We know that this is of kind tk_sequence or tk_array
    TypeCode expectedTypeCode = getContentType();
    for (int i=0; i<value.length; i++) {
        if (value[i] != null) {
            if (! value[i].type().equal(expectedTypeCode)) {
                clearData();
                // _REVISIT_ More info
                throw new TypeMismatch();
            }
            try {
                // Creates the appropriate subtype without copying the Any
                components[i] = DynAnyUtil.createMostDerivedDynAny(value[i], orb, false);
                //System.out.println(this + " created component " + components[i]);
            } catch (InconsistentTypeCode itc) {
                throw new InvalidValue();
            }
        } else {
            clearData();
            // _REVISIT_ More info
            throw new InvalidValue();
        }
    }
    index = (value.length == 0 ? NO_INDEX : 0);
    // Other representations are invalidated by this operation
    representations = REPRESENTATION_COMPONENTS;
}
 
Example 34
Project: OpenJSharp   File: DynSequenceImpl.java   View source code 5 votes vote down vote up
protected boolean initializeComponentsFromAny() {
    // This typeCode is of kind tk_sequence.
    TypeCode typeCode = any.type();
    int length;
    TypeCode contentType = getContentType();
    InputStream input;

    try {
        input = any.create_input_stream();
    } catch (BAD_OPERATION e) {
        return false;
    }

    length = input.read_long();
    components = new DynAny[length];
    anys = new Any[length];

    for (int i=0; i<length; i++) {
        // _REVISIT_ Could use read_xxx_array() methods on InputStream for efficiency
        // but only for primitive types
        anys[i] = DynAnyUtil.extractAnyFromStream(contentType, input, orb);
        try {
            // Creates the appropriate subtype without copying the Any
            components[i] = DynAnyUtil.createMostDerivedDynAny(anys[i], orb, false);
        } catch (InconsistentTypeCode itc) { // impossible
        }
    }
    return true;
}
 
Example 35
Project: openjdk-jdk10   File: ServerRequestInfoImpl.java   View source code 5 votes vote down vote up
/**
 * Stores the various sources of information used for this info object.
 */
protected void setDSIException( Any exception ) {
    this.dsiException = exception;

    // Clear cached exception value:
    cachedSendingException = null;
}
 
Example 36
Project: OpenJSharp   File: DynAnyImpl.java   View source code 5 votes vote down vote up
protected Any getAny(DynAny dynAny) {
    if (dynAny instanceof DynAnyImpl)
        return ((DynAnyImpl)dynAny).getAny();
    else
        // _REVISIT_ Nothing we can do about copying at this point
        // if this is not our implementation of DynAny.
        // To prevent this we would need another representation,
        // one where component DynAnys are initialized but not the component Anys.
        return dynAny.to_any();
}
 
Example 37
Project: OpenJSharp   File: ServerRequestInfoImpl.java   View source code 5 votes vote down vote up
/**
 * Allows an Interceptor to set a slot in the Current that is in the scope
 * of the request.  If data already exists in that slot, it will be
 * overwritten.  If the ID does not define an allocated slot, InvalidSlot
 * is raised.
 */
public void set_slot (int id, Any data) throws InvalidSlot {
    // access is currently valid for all states:
    //checkAccess( MID_SET_SLOT );

    slotTable.set_slot( id, data );
}
 
Example 38
Project: OpenJSharp   File: DynAnyUtil.java   View source code 5 votes vote down vote up
static DynAny createMostDerivedDynAny(Any any, ORB orb, boolean copyValue)
    throws org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode
{
    if (any == null || ! DynAnyUtil.isConsistentType(any.type()))
        throw new org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode();

    switch (any.type().kind().value()) {
        case TCKind._tk_sequence:
            return new DynSequenceImpl(orb, any, copyValue);
        case TCKind._tk_struct:
            return new DynStructImpl(orb, any, copyValue);
        case TCKind._tk_array:
            return new DynArrayImpl(orb, any, copyValue);
        case TCKind._tk_union:
            return new DynUnionImpl(orb, any, copyValue);
        case TCKind._tk_enum:
            return new DynEnumImpl(orb, any, copyValue);
        case TCKind._tk_fixed:
            return new DynFixedImpl(orb, any, copyValue);
        case TCKind._tk_value:
            return new DynValueImpl(orb, any, copyValue);
        case TCKind._tk_value_box:
            return new DynValueBoxImpl(orb, any, copyValue);
        default:
            return new DynAnyBasicImpl(orb, any, copyValue);
    }
}
 
Example 39
Project: OpenJSharp   File: PICurrent.java   View source code 5 votes vote down vote up
/**
 * This method sets the slot data at the given slot id (index) in the
 * Slot Table which is on the top of the SlotTableStack.
 */
public void set_slot( int id, Any data ) throws InvalidSlot
{
    if( orbInitializing ) {
        // As per ptc/00-08-06 if the ORB is still initializing, disallow
        // calls to get_slot and set_slot.  If an attempt is made to call,
        // throw a BAD_INV_ORDER.
        throw wrapper.invalidPiCall3() ;
    }

    getSlotTable().set_slot( id, data );
}
 
Example 40
Project: openjdk-jdk10   File: DynAnyComplexImpl.java   View source code 5 votes vote down vote up
private void addComponent(int i, String memberName, Any memberAny, DynAny memberDynAny) {
    components[i] = memberDynAny;
    names[i] = (memberName != null ? memberName : "");
    nameValuePairs[i].id = memberName;
    nameValuePairs[i].value = memberAny;
    nameDynAnyPairs[i].id = memberName;
    nameDynAnyPairs[i].value = memberDynAny;
    if (memberDynAny instanceof DynAnyImpl)
        ((DynAnyImpl)memberDynAny).setStatus(STATUS_UNDESTROYABLE);
}