Search in sources :

Example 1 with OperationDescription

use of org.omg.CORBA.OperationDescription in project ACS by ACS-Community.

the class BACIRemoteAccess method internalParentConnect.

/**
	 * Insert the method's description here.
	 * Creation date: (2.11.2000 0:35:23)
	 * @param baciNode si.ijs.acs.objectexplorer.engine.BACI.BACIRemoteNode
	 */
private void internalParentConnect(BACIRemoteNode baciNode, boolean doSync) {
    /* we are using the parent to query the object as either an IDL attribute or
			   Java property accessor design pattern (returns Object type, takes no parameters)
		*/
    //	System.out.println("IPC");
    String targetName = null;
    TypeCode retType = null;
    String id = null;
    if (baciNode.getNodeType() == ATTRIBUTE) {
        AttributeDescription ad = (AttributeDescription) baciNode.getUserObject();
        try {
            id = ad.type.id();
        } catch (org.omg.CORBA.TypeCodePackage.BadKind bk) {
            throw new RemoteException("IDL: BadKind thrown on type id lookup for PROPERTY child of the remote node: " + bk);
        }
        targetName = BACIIntrospector.attributeNameToMethodName(ad.name);
        retType = ad.type;
        notifier.reportDebug("BACIRemoteAccess::internalParentConnect", "Obtaining IDL attribute reference for '" + ad.name + "'.");
    } else if (baciNode.getNodeType() == PROPERTY) {
        OperationDescription od = (OperationDescription) baciNode.getUserObject();
        try {
            id = od.result.id();
        } catch (org.omg.CORBA.TypeCodePackage.BadKind bk) {
            throw new RemoteException("IDL: BadKind thrown on type id lookup for PROPERTY child of the remote node: " + bk);
        }
        targetName = od.name;
        retType = od.result;
        notifier.reportDebug("BACIRemoteAccess::internalParentConnect", "Obtaining reference to contained object through property accessor design pattern for '" + od.name + ".");
    } else
        throw new IntrospectionInconsistentException("Devices can contain objects only as IDL attributes or property accessor design patterns. Failed on '" + baciNode + "'.");
    BACIRemoteNode parentNode = (BACIRemoteNode) baciNode.getParent();
    if (parentNode.getCORBARef() == null) {
        parentNode.connect();
        if (parentNode.getCORBARef() == null)
            throw new RemoteException("Child node is accessible although the parent node CORBA reference is null. Failed on '" + baciNode + ".");
    }
    /* begin DII stanza */
    Request req = parentNode.getCORBARef()._request(targetName);
    req.set_return_type(retType);
    notifier.reportDebug("BACIRemoteAccess::internalParentConnect", "Invoking remote call...");
    req.invoke();
    Any returnValue = req.return_value();
    if (returnValue.type().kind() != TCKind.tk_objref)
        throw new IntrospectionInconsistentException("Return type of '" + targetName + "' is not of type object reference, expected object reference because of BACI containment specifications.");
    baciNode.setCORBARef(returnValue.extract_Object());
    //
    baciNode.setIFDesc(getIFDesc(id));
    //
    if (baciNode.getCORBARef() != null)
        notifier.reportDebug("BACIRemoteAccess::internalParentConnect", "Connection to contained object OK.");
    else
        notifier.reportError("Reference returned when resolving contained object '" + targetName + "' is null.");
/* end DII stanza */
}
Also used : TypeCode(org.omg.CORBA.TypeCode) Request(org.omg.CORBA.Request) IntrospectionInconsistentException(si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException) Any(org.omg.CORBA.Any) OperationDescription(org.omg.CORBA.OperationDescription) AttributeDescription(org.omg.CORBA.AttributeDescription) NonStickyConnectFailedRemoteException(si.ijs.acs.objectexplorer.engine.NonStickyConnectFailedRemoteException) RemoteException(si.ijs.acs.objectexplorer.engine.RemoteException)

Example 2 with OperationDescription

use of org.omg.CORBA.OperationDescription in project ACS by ACS-Community.

the class BACIRemoteAccess method internalInvokeTrivial.

/**
	 * Insert the method's description here.
	 * Creation date: (2.11.2000 18:08:01)
	 * @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 BACIRemoteCall internalInvokeTrivial(BACIRemote target, Operation op, java.lang.Object[] params) {
    if (target.getCORBARef() == null)
        throw new RemoteException("Cannot invoke operation '" + op.getName() + "' on object '" + target.getName() + "' because it is not connected.");
    notifier.reportDebug("BACIRemoteAccess::internalInvokeTrivial", "Preparing DII parameters for '" + target.getName() + "." + op.getName() + "()'.");
    java.lang.Object[] allArguments = baciIntrospector.prepareDIIparameters(((BACIOperation) op).getOperationDesc(), params);
    org.omg.CORBA.Object remote = target.getCORBARef();
    OperationDescription desc = ((BACIOperation) op).getOperationDesc();
    if (allArguments.length != desc.parameters.length)
        throw new IllegalStateException("BACI introspector returned an array of values the length of which does not match CORBA parameter list, object = '" + target.getName() + "', operation = '" + op.getName() + "'.");
    StringBuffer buf = new StringBuffer(200);
    for (int i = 0; i < params.length; i++) {
        buf.append("'");
        buf.append(op.getParameterNames()[i]);
        buf.append("' = '");
        buf.append(params[i]);
        buf.append("' ");
    }
    notifier.reportDebug("BACIRemoteAccess::internalInvokeTrivial", "Parameters for '" + op.getName() + "': " + buf.toString());
    notifier.reportMessage("Invoking '" + target.getName() + "." + op.getName() + "()', parameters: " + buf.toString());
    /* begin DII stanza */
    Request req = remote._request(op.getName());
    req.set_return_type(desc.result);
    /* set exceptions */
    org.omg.CORBA.ExceptionList exceptions = req.exceptions();
    org.omg.CORBA.ExceptionDescription[] exceptionsDesc = desc.exceptions;
    for (int i = 0; i < exceptionsDesc.length; i++) {
        // TAO IFR bug workaround
        if (exceptionsDesc[i].type.kind().value() != TCKind._tk_except) {
            // System.out.println("--> Invalid user exception kind, fixing...");
            Class c = null;
            String className = null;
            try {
                className = baciIntrospector.IDtoClassName(exceptionsDesc[i].type.id()) + "Helper";
                c = Class.forName(className);
            } catch (Exception e) {
                throw new JavaIDLIntrospectionException("Failed to load class '" + className + "'. Introspection failed on typedef argument: " + e);
            }
            Class[] paramTypes = {};
            java.lang.Object[] paramVals = {};
            try {
                java.lang.Object retVal = c.getMethod("type", paramTypes).invoke(null, paramVals);
                exceptions.add((TypeCode) retVal);
            } catch (Exception e1) {
                throw new JavaIDLIntrospectionException("Dynamic invocation of 'internalInvokeTrivial' failed on a typedef argument. Class instance: " + c.getName() + ". Exception:" + e1);
            }
        } else
            exceptions.add(exceptionsDesc[i].type);
    }
    for (int i = 0; i < allArguments.length; i++) {
        Any argument = orb.create_any();
        argument.type(desc.parameters[i].type);
        if (desc.parameters[i].mode != ParameterMode.PARAM_OUT) {
            argument = baciIntrospector.insertAny(desc.parameters[i].type, argument, allArguments[i]);
        //baciIntrospector.displayAny(argument);
        }
        //org.omg.CORBA.ParameterMode.PARAM_xxx is defined in [0-2] and in org.jacorb.orb.ARG_xxx is defined in [1-3].
        req.arguments().add_value(desc.parameters[i].name, argument, desc.parameters[i].mode.value() + 1);
    }
    // invoke request
    if (desc.mode == OperationMode.OP_ONEWAY) {
        notifier.reportDebug("BACIRemoteAccess::internalInvokeTrivial", "Sending oneway request '" + target.getName() + "." + op.getName() + "()'...");
        try {
            req.send_oneway();
            return new BACIRemoteCall(target, (BACIOperation) op, params, null, null);
        } catch (Exception e) {
            notifier.reportError("Exception during oneway remote invocation.", e);
            return new BACIRemoteCall(target, (BACIOperation) op, params, e);
        }
    } else {
        int time = 0;
        boolean errorResponse = false;
        notifier.reportDebug("BACIRemoteAccess::internalInvokeTrivial", "Sending deferred request '" + target.getName() + "." + op.getName() + "()'.");
        try {
            req.send_deferred();
            while (!req.poll_response()) {
                try {
                    Thread.sleep(POLL_SLEEP);
                    time += POLL_SLEEP;
                } catch (InterruptedException ie) {
                }
                if (time > POLL_TIMEOUT) {
                    notifier.reportError("Timeout (" + POLL_TIMEOUT + " ms) while polling for response from '" + op.getName() + "' on '" + target.getName() + "'.");
                    return new BACIRemoteCall(target, (BACIOperation) op, params, true);
                }
            }
            // check exception
            checkException(target, req);
            notifier.reportDebug("BACIRemoteAccess::internalInvokeTrivial", "Received response for '" + target.getName() + "." + op.getName() + "()'.");
            //	req.get_response();
            Any anyRet = req.return_value();
            java.lang.Object oRet = null;
            if (anyRet != null)
                oRet = baciIntrospector.extractAny(anyRet);
            java.lang.Object[] outs = baciIntrospector.extractOuts(req, desc);
            // check for error-type ACSCompletion-s
            errorResponse = checkFromACSCompletion(oRet);
            for (int i = 0; i < outs.length; i++) errorResponse |= checkFromACSCompletion(outs[i]);
            if (target instanceof Invocation && baciIntrospector.isInvocationDestroyMethod(op.getName()))
                new CBTimer((BACIInvocation) target).start();
            notifier.reportDebug("BACIRemoteAccess::internalInvokeTrivial", "Successfully unpacked response for '" + target.getName() + "." + op.getName() + "()'.");
            BACIRemoteCall remoteCall = new BACIRemoteCall(target, (BACIOperation) op, params, oRet, outs);
            remoteCall.setErrorResponse(errorResponse);
            return remoteCall;
        } catch (Exception e) {
            notifier.reportError("Exception during deferred remote invocation.", e);
            return new BACIRemoteCall(target, (BACIOperation) op, params, e);
        }
    }
/* end DII stanza */
}
Also used : Invocation(si.ijs.acs.objectexplorer.engine.Invocation) Any(org.omg.CORBA.Any) Request(org.omg.CORBA.Request) OperationDescription(org.omg.CORBA.OperationDescription) IntrospectionInconsistentException(si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException) AcsJException(alma.acs.exceptions.AcsJException) DataException(si.ijs.acs.objectexplorer.engine.DataException) NonStickyConnectFailedRemoteException(si.ijs.acs.objectexplorer.engine.NonStickyConnectFailedRemoteException) RemoteException(si.ijs.acs.objectexplorer.engine.RemoteException) NonStickyConnectFailedRemoteException(si.ijs.acs.objectexplorer.engine.NonStickyConnectFailedRemoteException) RemoteException(si.ijs.acs.objectexplorer.engine.RemoteException)

Example 3 with OperationDescription

use of org.omg.CORBA.OperationDescription in project wildfly by wildfly.

the class ValueDefImpl method describe_value.

public FullValueDescription describe_value() {
    if (fullValueDescription != null)
        return fullValueDescription;
    // Has to create the FullValueDescription
    // TODO
    OperationDescription[] operations = new OperationDescription[0];
    AttributeDescription[] attributes = new AttributeDescription[0];
    String defined_in_id = "IDL:Global:1.0";
    if (defined_in instanceof org.omg.CORBA.ContainedOperations)
        defined_in_id = ((org.omg.CORBA.ContainedOperations) defined_in).id();
    fullValueDescription = new FullValueDescription(name, id, is_abstract, is_custom, defined_in_id, version, operations, attributes, getValueMembers(), // TODO
    new Initializer[0], supported_interfaces, abstract_base_valuetypes, false, baseValue, typeCode);
    return fullValueDescription;
}
Also used : Initializer(org.omg.CORBA.Initializer) FullValueDescription(org.omg.CORBA.ValueDefPackage.FullValueDescription) OperationDescription(org.omg.CORBA.OperationDescription) AttributeDescription(org.omg.CORBA.AttributeDescription)

Example 4 with OperationDescription

use of org.omg.CORBA.OperationDescription in project wildfly by wildfly.

the class InterfaceDefImpl method describe_interface.

public FullInterfaceDescription describe_interface() {
    if (fullInterfaceDescription != null)
        return fullInterfaceDescription;
    // Has to create the FullInterfaceDescription
    // TODO
    OperationDescription[] operations = new OperationDescription[0];
    AttributeDescription[] attributes = new AttributeDescription[0];
    String defined_in_id = "IDL:Global:1.0";
    if (defined_in instanceof org.omg.CORBA.ContainedOperations)
        defined_in_id = ((org.omg.CORBA.ContainedOperations) defined_in).id();
    fullInterfaceDescription = new FullInterfaceDescription(name, id, defined_in_id, version, operations, attributes, base_interfaces, type(), is_abstract);
    return fullInterfaceDescription;
}
Also used : FullInterfaceDescription(org.omg.CORBA.InterfaceDefPackage.FullInterfaceDescription) OperationDescription(org.omg.CORBA.OperationDescription) AttributeDescription(org.omg.CORBA.AttributeDescription)

Example 5 with OperationDescription

use of org.omg.CORBA.OperationDescription in project wildfly by wildfly.

the class OperationDefImpl method describe.

// ContainedImpl implementation ----------------------------------
public Description describe() {
    String defined_in_id = "IR";
    if (defined_in instanceof ContainedOperations)
        defined_in_id = ((ContainedOperations) defined_in).id();
    ExceptionDescription[] exds;
    exds = new ExceptionDescription[exceptions.length];
    for (int i = 0; i < exceptions.length; ++i) {
        Description d = exceptions[i].describe();
        exds[i] = ExceptionDescriptionHelper.extract(d.value);
    }
    OperationDescription od;
    od = new OperationDescription(name, id, defined_in_id, version, typeCode, mode(), contexts(), params(), exds);
    Any any = getORB().create_any();
    OperationDescriptionHelper.insert(any, od);
    return new Description(DefinitionKind.dk_Operation, any);
}
Also used : OperationDescription(org.omg.CORBA.OperationDescription) ExceptionDescription(org.omg.CORBA.ExceptionDescription) ParameterDescription(org.omg.CORBA.ParameterDescription) Description(org.omg.CORBA.ContainedPackage.Description) ExceptionDescription(org.omg.CORBA.ExceptionDescription) ContainedOperations(org.omg.CORBA.ContainedOperations) Any(org.omg.CORBA.Any) OperationDescription(org.omg.CORBA.OperationDescription)

Aggregations

OperationDescription (org.omg.CORBA.OperationDescription)6 Any (org.omg.CORBA.Any)3 AttributeDescription (org.omg.CORBA.AttributeDescription)3 IntrospectionInconsistentException (si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException)3 RemoteException (si.ijs.acs.objectexplorer.engine.RemoteException)3 ParameterDescription (org.omg.CORBA.ParameterDescription)2 Request (org.omg.CORBA.Request)2 DataException (si.ijs.acs.objectexplorer.engine.DataException)2 NonStickyConnectFailedRemoteException (si.ijs.acs.objectexplorer.engine.NonStickyConnectFailedRemoteException)2 AcsJException (alma.acs.exceptions.AcsJException)1 ArrayList (java.util.ArrayList)1 ContainedOperations (org.omg.CORBA.ContainedOperations)1 Description (org.omg.CORBA.ContainedPackage.Description)1 ExceptionDescription (org.omg.CORBA.ExceptionDescription)1 Initializer (org.omg.CORBA.Initializer)1 FullInterfaceDescription (org.omg.CORBA.InterfaceDefPackage.FullInterfaceDescription)1 TypeCode (org.omg.CORBA.TypeCode)1 FullValueDescription (org.omg.CORBA.ValueDefPackage.FullValueDescription)1 DataType (si.ijs.acs.objectexplorer.engine.DataType)1 Invocation (si.ijs.acs.objectexplorer.engine.Invocation)1