Search in sources :

Example 1 with DataType

use of si.ijs.acs.objectexplorer.engine.DataType 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 2 with DataType

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

the class BACIIntrospector method getCallbackLocation.

/**
 * Insert the method's description here.
 * Creation date: (9.11.2000 0:23:33)
 * @return java.lang.Object[]
 * @param params java.lang.Object[]
 * @param cb si.ijs.acs.objectexplorer.engine.RemoteResponseCallback
 */
public int getCallbackLocation(Operation op) {
    if (op == null)
        throw new NullPointerException("op");
    DataType[] args = op.getParameterTypes();
    int count = -1;
    for (int i = 0; i < args.length; i++) {
        if (alma.ACS.Callback.class.isAssignableFrom(args[i].getType())) {
            if (count != -1)
                throw new IntrospectionInconsistentException("Operation '" + op + "' declares more than one parameter that extends 'Callback'");
            count = i;
            if (i == args.length - 1 && ra.isStrict())
                throw new IntrospectionInconsistentException("Operation '" + op + "' takes callback as its last parameter, but takes no 'CBDescIn' parameter.");
            if (ra.isStrict() && !args[i + 1].equals(alma.ACS.CBDescIn.class))
                throw new IntrospectionInconsistentException("Operation '" + op + "' does not take a 'CBDescIn' parameter after 'Callback' parameter.");
        }
    }
    return count;
}
Also used : DataType(si.ijs.acs.objectexplorer.engine.DataType) IntrospectionInconsistentException(si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException)

Example 3 with DataType

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

the class BACIIntrospector method getOperations.

/**
 * Insert the method's description here.
 * Creation date: (2.11.2000 0:44:52)
 */
public BACIOperation[] getOperations(BACIRemote target) {
    if (target == null)
        throw new NullPointerException("target");
    OperationDescription[] operations = target.getIFDesc().operations;
    ArrayList<BACIOperation> tempList = new ArrayList<BACIOperation>();
    for (int i = 0; i < operations.length; i++) {
        ra.getNotifier().reportDebug("BACIIntrospector::getOperations", "Analysing operation '" + operations[i].name + "'.");
        ParameterDescription[] ps = operations[i].parameters;
        String[] names = new String[ps.length];
        //Class[] types = new Class[ps.length];
        DataType[] types = new DataType[ps.length];
        boolean[] mask = new boolean[ps.length];
        int cb = -1;
        boolean unsupportedOperation = false;
        for (int j = 0; j < ps.length; j++) {
            try {
                names[j] = ps[j].name;
                types[j] = new BACIDataType(getClassType(ps[j].type));
                types[j].setElement(getDef(ps[j].type));
                types[j].setArrayType(getArrayType(ps[j].type));
                if (isOfType(ps[j].type, ID_CALLBACK)) {
                    if (cb != -1)
                        throw new IntrospectionInconsistentException("Operation '" + operations[i].name + "' declares more than one callback parameter.");
                    cb = j;
                    if (cb == ps.length - 1 && ra.isStrict())
                        throw new IntrospectionInconsistentException("A callback parameter for operation '" + operations[i].name + "' must be followed by a 'CBDescIn' parameter.");
                }
                if (ps[j].mode == ParameterMode.PARAM_OUT || cb == j) {
                    mask[j] = false;
                } else
                    mask[j] = true;
                if (cb != -1 && j == cb + 1) {
                    try {
                        if (ID_CBDESCIN.equals(ps[j].type.id())) {
                            mask[j] = false;
                        } else if (ra.isStrict())
                            throw new IntrospectionInconsistentException("A callback parameter for opration '" + operations[i].name + "' must be followed by a 'CBDescIn' parameter.");
                    } catch (Exception bk) {
                        throw new RemoteException("Exception while analyzing typecode (getting typecode name raises exception). Exception: " + bk);
                    }
                }
            } catch (Exception e) {
                ra.getNotifier().reportDebug("BACIIntrospector::getOperations", "Failed to analyse parameter '" + ps[j].name + "' for operation '" + operations[i].name + "'. Removing it from operation list... Exception:" + e);
                e.printStackTrace();
                unsupportedOperation = true;
                break;
            }
        }
        if (!unsupportedOperation)
            tempList.add(new BACIOperation(ra, operations[i], target, names, types, mask, !(cb == -1), false));
    }
    BACIOperation[] retVal = new BACIOperation[tempList.size()];
    tempList.toArray(retVal);
    return retVal;
}
Also used : ArrayList(java.util.ArrayList) IntrospectionInconsistentException(si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException) OperationDescription(org.omg.CORBA.OperationDescription) IntrospectionInconsistentException(si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException) RemoteException(si.ijs.acs.objectexplorer.engine.RemoteException) DataException(si.ijs.acs.objectexplorer.engine.DataException) DataType(si.ijs.acs.objectexplorer.engine.DataType) RemoteException(si.ijs.acs.objectexplorer.engine.RemoteException) ParameterDescription(org.omg.CORBA.ParameterDescription)

Aggregations

DataType (si.ijs.acs.objectexplorer.engine.DataType)3 IntrospectionInconsistentException (si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException)2 ArrayList (java.util.ArrayList)1 Contained (org.omg.CORBA.Contained)1 OperationDescription (org.omg.CORBA.OperationDescription)1 ParameterDescription (org.omg.CORBA.ParameterDescription)1 StructDef (org.omg.CORBA.StructDef)1 StructMember (org.omg.CORBA.StructMember)1 DataException (si.ijs.acs.objectexplorer.engine.DataException)1 DataStruct (si.ijs.acs.objectexplorer.engine.DataStruct)1 RemoteException (si.ijs.acs.objectexplorer.engine.RemoteException)1