Search in sources :

Example 1 with DataStruct

use of si.ijs.acs.objectexplorer.engine.DataStruct in project ACS by ACS-Community.

the class BACIIntrospector method extractTypedef.

/**
 * Insert the method's description here.
 * Creation date: (7.11.2000 1:00:12)
 * @return java.lang.Object
 * @param argument org.omg.CORBA.Any
 */
public java.lang.Object extractTypedef(TypeCode tc, Any argument) {
    if (argument == null)
        throw new NullPointerException("argument");
    DynAny dany;
    try {
        dany = ra.getDynFact().create_dyn_any(argument);
    } catch (org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode e) {
        e.printStackTrace();
        return null;
    }
    DynStruct str = (DynStruct) dany;
    try {
        if (tc.kind() == TCKind.tk_struct) {
            DataStruct ds = new DataStruct(dany.type().id());
            for (int i = 0; i < str.component_count(); i++) {
                ds.add(str.current_member_name(), extractAny(str.current_component().to_any()));
                str.next();
            }
            return ds;
        } else {
            DataException de = new DataException(dany.type().id());
            for (int i = 0; i < str.component_count(); i++) {
                de.add(str.current_member_name(), extractAny(str.current_component().to_any()));
                str.next();
            }
            return de;
        }
    } catch (org.omg.DynamicAny.DynAnyPackage.TypeMismatch e) {
        e.printStackTrace();
        return null;
    } catch (org.omg.DynamicAny.DynAnyPackage.InvalidValue e) {
        e.printStackTrace();
        return null;
    } catch (org.omg.CORBA.TypeCodePackage.BadKind e) {
        e.printStackTrace();
        return null;
    }
}
Also used : DynStruct(org.omg.DynamicAny.DynStruct) DataStruct(si.ijs.acs.objectexplorer.engine.DataStruct) DataException(si.ijs.acs.objectexplorer.engine.DataException) DynAny(org.omg.DynamicAny.DynAny)

Example 2 with DataStruct

use of si.ijs.acs.objectexplorer.engine.DataStruct in project ACS by ACS-Community.

the class BACIIntrospector method getStructDef.

private DataStruct getStructDef(TypeCode tc) {
    if (tc.kind() != TCKind.tk_struct)
        return null;
    try {
        DataStruct ds = new DataStruct(tc.id());
        Contained ctd = ra.lookupId(tc.id());
        StructDef sd = StructDefHelper.narrow(ctd);
        StructMember[] mems = sd.members();
        for (int i = 0; i < mems.length; i++) {
            DataType dt = new BACIDataType(getClassType(mems[i].type));
            dt.setElement(getDef(mems[i].type));
            ds.add(mems[i].name, dt);
        }
        return ds;
    } catch (org.omg.CORBA.TypeCodePackage.BadKind e) {
        e.printStackTrace();
        return null;
    }
}
Also used : DataStruct(si.ijs.acs.objectexplorer.engine.DataStruct) Contained(org.omg.CORBA.Contained) DataType(si.ijs.acs.objectexplorer.engine.DataType) StructMember(org.omg.CORBA.StructMember) StructDef(org.omg.CORBA.StructDef)

Example 3 with DataStruct

use of si.ijs.acs.objectexplorer.engine.DataStruct in project ACS by ACS-Community.

the class BACIRemoteAccess method internalInvokeInvocation.

/**
	 * Insert the method's description here.
	 * Creation date: (2.11.2000 18:08:47)
	 * @return si.ijs.acs.objectexplorer.engine.Invocation
	 * @param target si.ijs.acs.objectexplorer.engine.BACI.BACIRemoteNode
	 * @param op si.ijs.acs.objectexplorer.engine.Operation
	 */
private Invocation internalInvokeInvocation(//TODO update secondary tree???
BACIRemote target, BACIOperation op, java.lang.Object[] params, RemoteResponseCallback cb) {
    int callbackIndex = baciIntrospector.getCallbackLocation(op);
    if (callbackIndex == -1)
        throw new IntrospectionInconsistentException("Asynchronous operation '" + op + "' must take exactly one callback parameter.");
    /* create callback */
    CallbackImpl cbImpl = null;
    try {
        cbImpl = new CallbackImpl(op.getOperationDesc().parameters[callbackIndex].type.id(), cb);
    } catch (org.omg.CORBA.TypeCodePackage.BadKind bk) {
        throw new RemoteException("Error while trying to analyze typecode: " + bk);
    }
    org.omg.CORBA.Object cbIF = cbImpl._this_object(orb);
    notifier.reportDebug("BACIRemoteAccess::internalInvokeInvocation", "Activated callback object for '" + op + "'.");
    DataStruct desc = new DataStruct("IDL:alma/ACS/CBDescIn:1.0");
    desc.add("normal_timeout", new Long(1000000));
    desc.add("negotiable_timeout", new Long(5000000));
    desc.add("id_tag", new Integer(0));
    params[callbackIndex] = cbIF;
    if (callbackIndex == params.length - 1) {
        if (!isStrict())
            notifier.reportDebug("BACIRemoteAccess::internalInvokeInvocation", "Non-strict BACI invocation signature: callback is not followed by a descriptor.");
        else
            throw new IntrospectionInconsistentException("Callback cannot be the last argument, because it must be followed by the descriptor.");
    } else
        params[callbackIndex + 1] = desc;
    BACIInvocation invoc = new BACIInvocation(TRANSIENT, op.getName(), null, cb, parent.getTree(), this);
    cbImpl.setInvocation(invoc);
    invoc.setRemoteCall(internalInvokeTrivial(target, op, params));
    synchronized (invocations) {
        invocations.add(invoc);
    }
    notifier.reportDebug("BACIRemoteAccess::internalInvokeInvocation", "Remote call ended, constructed Invocation. Returning...");
    return invoc;
}
Also used : IntrospectionInconsistentException(si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException) DataStruct(si.ijs.acs.objectexplorer.engine.DataStruct) NonStickyConnectFailedRemoteException(si.ijs.acs.objectexplorer.engine.NonStickyConnectFailedRemoteException) RemoteException(si.ijs.acs.objectexplorer.engine.RemoteException)

Example 4 with DataStruct

use of si.ijs.acs.objectexplorer.engine.DataStruct in project ACS by ACS-Community.

the class BACIIntrospector method insertTypedef.

public Any insertTypedef(TypeCode tc, java.lang.Object obj) {
    DynAny dany;
    try {
        dany = ra.getDynFact().create_dyn_any_from_type_code(tc);
    } catch (org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode e) {
        e.printStackTrace();
        return null;
    }
    //Class<?> cl = getClassType(tc);
    DynStruct str = (DynStruct) dany;
    NameDynAnyPair[] mems = str.get_members_as_dyn_any();
    try {
        if (tc.kind() == TCKind.tk_struct) {
            DataStruct ds = (DataStruct) obj;
            for (int i = 0; i < mems.length; i++) {
                mems[i].value.from_any(insertAny(mems[i].value.to_any(), ds.get(mems[i].id)));
            }
        } else {
            DataException de = (DataException) obj;
            for (int i = 0; i < mems.length; i++) {
                mems[i].value.from_any(insertAny(mems[i].value.to_any(), de.get(mems[i].id)));
            }
        }
        str.set_members_as_dyn_any(mems);
    } catch (org.omg.DynamicAny.DynAnyPackage.TypeMismatch e) {
        e.printStackTrace();
        return null;
    } catch (org.omg.DynamicAny.DynAnyPackage.InvalidValue e) {
        e.printStackTrace();
        return null;
    }
    //displayAny(dany.to_any());
    return dany.to_any();
}
Also used : DynStruct(org.omg.DynamicAny.DynStruct) DataStruct(si.ijs.acs.objectexplorer.engine.DataStruct) DataException(si.ijs.acs.objectexplorer.engine.DataException) NameDynAnyPair(org.omg.DynamicAny.NameDynAnyPair) DynAny(org.omg.DynamicAny.DynAny)

Aggregations

DataStruct (si.ijs.acs.objectexplorer.engine.DataStruct)4 DynAny (org.omg.DynamicAny.DynAny)2 DynStruct (org.omg.DynamicAny.DynStruct)2 DataException (si.ijs.acs.objectexplorer.engine.DataException)2 Contained (org.omg.CORBA.Contained)1 StructDef (org.omg.CORBA.StructDef)1 StructMember (org.omg.CORBA.StructMember)1 NameDynAnyPair (org.omg.DynamicAny.NameDynAnyPair)1 DataType (si.ijs.acs.objectexplorer.engine.DataType)1 IntrospectionInconsistentException (si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException)1 NonStickyConnectFailedRemoteException (si.ijs.acs.objectexplorer.engine.NonStickyConnectFailedRemoteException)1 RemoteException (si.ijs.acs.objectexplorer.engine.RemoteException)1