org.omg.CORBA.Any Java Examples

The following examples show how to use org.omg.CORBA.Any. 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: DynUnionImpl.java    From openjdk-8 with GNU General Public License v2.0 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 #2
Source File: PIHandlerImpl.java    From jdk8u60 with GNU General Public License v2.0 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 #3
Source File: PIHandlerImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 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 #4
Source File: DynAnyImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 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() ;
     }
     if ((any != null) && (! any.type().equal(value.type()))) {
         throw new TypeMismatch();
     }
     // If the passed Any does not contain a legal value
     // (such as a null string), the operation raises InvalidValue.
     Any tempAny = null;
     try {
         tempAny = DynAnyUtil.copy(value, orb);
     } catch (Exception e) {
         throw new InvalidValue();
     }
     if ( ! DynAnyUtil.isInitialized(tempAny)) {
         throw new InvalidValue();
     }
     any = tempAny;
}
 
Example #5
Source File: CDREncapsCodec.java    From TencentKona-8 with GNU General Public License v2.0 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 #6
Source File: AnyImpl.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * See the description of the <a href="#anyOps">general Any operations.</a>
 */
public void insert_any(Any a)
{
    //debug.log ("insert_any");
    typeCode = orb.get_primitive_tc(TCKind._tk_any);
    object = a;
    stream = null;
    isInitialized = true;
}
 
Example #7
Source File: DynUnionImpl.java    From openjdk-8 with GNU General Public License v2.0 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 #8
Source File: RequestImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void unmarshalReply(InputStream is)
{
    // First unmarshal the return value if it is not void
    if ( _result != null ) {
        Any returnAny = _result.value();
        TypeCode returnType = returnAny.type();
        if ( returnType.kind().value() != TCKind._tk_void )
            returnAny.read_value(is, returnType);
    }

    // Now unmarshal the out/inout args
    try {
        for ( int i=0; i<_arguments.count() ; i++) {
            NamedValue nv = _arguments.item(i);
            switch( nv.flags() ) {
            case ARG_IN.value:
                break;
            case ARG_OUT.value:
            case ARG_INOUT.value:
                Any any = nv.value();
                any.read_value(is, any.type());
                break;
            }
        }
    }
    catch ( org.omg.CORBA.Bounds ex ) {
        // Cannot happen since we only iterate till _arguments.count()
    }
}
 
Example #9
Source File: SlotTable.java    From openjdk-jdk8u with GNU General Public License v2.0 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 #10
Source File: DynAnyUtil.java    From hottub with GNU General Public License v2.0 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 #11
Source File: AnyImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 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
Source File: DynAnyComplexImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 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);
}
 
Example #13
Source File: DynAnyConstructedImpl.java    From jdk1.8-source-analysis with Apache License 2.0 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 #14
Source File: ORBUtility.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 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 #15
Source File: DynAnyConstructedImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 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 #16
Source File: ServerRequestImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/** This is called from the ORB after the DynamicImplementation.invoke
 *  returns. Here we set the result if result() has not already been called.
 *  @return the exception if there is one (then ORB will not call
 *  marshalReplyParams()) otherwise return null.
 */
public Any checkResultCalled()
{
    // Two things to be checked (CORBA 2.2 spec, section 6.3):
    // 1. Unless it calls set_exception(), the DIR must call arguments()
    //    exactly once, even if the operation signature contains
    //    no parameters.
    // 2. Unless set_exception() is called, if the invoked operation has a
    //    non-void result type, set_result() must be called exactly once
    //    before the DIR returns.

    if ( _paramsCalled && _resultSet ) // normal invocation return
        return null;
    else if ( _paramsCalled && !_resultSet && !_exceptionSet ) {
        try {
            // Neither a result nor an exception has been set.
            // Assume that the return type is void. If this is not so,
            // the client will throw a MARSHAL exception while
            // unmarshaling the return value.
            TypeCode result_tc = _orb.get_primitive_tc(
                org.omg.CORBA.TCKind.tk_void);
            _resultAny = _orb.create_any();
            _resultAny.type(result_tc);
            _resultSet = true;

            return null;
        } catch ( Exception ex ) {
            throw _wrapper.dsiResultException(
                CompletionStatus.COMPLETED_MAYBE, ex ) ;
        }
    } else if ( _exceptionSet )
        return _exception;
    else {
        throw _wrapper.dsimethodNotcalled(
            CompletionStatus.COMPLETED_MAYBE ) ;
    }
}
 
Example #17
Source File: DynValueBoxImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 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 #18
Source File: DynSequenceImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 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 #19
Source File: CorbaAnyHelper.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static Any createAny(ORB orb) {
    Any value = orb.create_any();
    if ("com.sun.corba.se.impl.corba.AnyImpl".equals(value.getClass().getName())) {
        value = createFixedAny(orb, value);
    }
    return value;
}
 
Example #20
Source File: SlotTable.java    From TencentKona-8 with GNU General Public License v2.0 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 #21
Source File: DynAnyCollectionImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 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 #22
Source File: DynAnyConstructedImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public org.omg.CORBA.Any get_any()
    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();
    return currentComponent.get_any();
}
 
Example #23
Source File: Util.java    From hottub with GNU General Public License v2.0 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 #24
Source File: CDREncapsCodec.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Convert the given any into a CDR encapsulated octet sequence.  Only
 * the data is stored.  The type code is not.
 */
public byte[] encode_value( Any data )
    throws InvalidTypeForEncoding
{
    if( data == null )
        throw wrapper.nullParam() ;
    return encodeImpl( data, false );
}
 
Example #25
Source File: DynAnyConstructedImpl.java    From openjdk-8 with GNU General Public License v2.0 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 #26
Source File: SlotTable.java    From openjdk-jdk9 with GNU General Public License v2.0 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 #27
Source File: SlotTable.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This method get the slot data for the given slot id (index).
 */
public Any get_slot( int id ) throws InvalidSlot
{
    // First check whether the slot is allocated
    // If not, raise the invalid slot exception
    if( id >= theSlotData.length ) {
        throw new InvalidSlot();
    }
    if( theSlotData[id] == null ) {
        theSlotData [id] = new AnyImpl(orb);
    }
    return theSlotData[ id ];
}
 
Example #28
Source File: DynAnyBasicImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 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 #29
Source File: CorbaServerRequestDispatcherImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 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 #30
Source File: AnyImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public Any extractAny(TypeCode memberType, ORB orb) {
    Any returnValue = orb.create_any();
    OutputStream out = returnValue.create_output_stream();
    TypeCodeImpl.convertToNative(orb, memberType).copy((InputStream)stream, out);
    returnValue.read_value(out.create_input_stream(), memberType);
    return returnValue;
}