Search in sources :

Example 11 with CorbaObjectHandler

use of org.apache.cxf.binding.corba.types.CorbaObjectHandler in project cxf by apache.

the class CorbaObjectWriter method writeUnion.

public void writeUnion(CorbaObjectHandler obj) throws CorbaBindingException {
    Union unionType = (Union) obj.getType();
    List<Unionbranch> branches = unionType.getUnionbranch();
    if (!branches.isEmpty()) {
        CorbaObjectHandler discriminator = ((CorbaUnionHandler) obj).getDiscriminator();
        this.write(discriminator);
        CorbaObjectHandler unionValue = ((CorbaUnionHandler) obj).getValue();
        if (unionValue != null) {
            this.write(unionValue);
        }
    }
}
Also used : CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler) CorbaUnionHandler(org.apache.cxf.binding.corba.types.CorbaUnionHandler) Union(org.apache.cxf.binding.corba.wsdl.Union) Unionbranch(org.apache.cxf.binding.corba.wsdl.Unionbranch)

Example 12 with CorbaObjectHandler

use of org.apache.cxf.binding.corba.types.CorbaObjectHandler in project cxf by apache.

the class CorbaStreamInInterceptor method prepareDIIArgsList.

protected NVList prepareDIIArgsList(CorbaMessage corbaMsg, BindingOperationInfo boi, CorbaStreamable[] streamables, List<ParamType> paramTypes, CorbaTypeMap map, ORB orb, ServiceInfo service) {
    try {
        // Build the list of DII arguments, returns, and exceptions
        NVList list = orb.create_list(streamables.length);
        OperationInfo opInfo = boi.getOperationInfo();
        MessageInfo input = opInfo.getInput();
        MessageInfo output = opInfo.getOutput();
        String inWrapNSUri = null;
        String outWrapNSUri = null;
        boolean wrap = false;
        if (boi.isUnwrappedCapable()) {
            wrap = true;
            if (input != null) {
                inWrapNSUri = getWrappedParamNamespace(input);
                if (!CorbaUtils.isElementFormQualified(service, inWrapNSUri)) {
                    inWrapNSUri = "";
                }
            }
            if (output != null) {
                outWrapNSUri = getWrappedParamNamespace(output);
                if (!CorbaUtils.isElementFormQualified(service, outWrapNSUri)) {
                    outWrapNSUri = "";
                }
            }
        }
        int inMsgIndex = 0;
        int outMsgIndex = 0;
        for (int i = 0; i < paramTypes.size(); i++) {
            ParamType param = paramTypes.get(i);
            QName paramIdlType = param.getIdltype();
            QName paramName;
            ModeType paramMode = param.getMode();
            if (paramMode.value().equals("in")) {
                if (wrap) {
                    paramName = new QName(inWrapNSUri, param.getName());
                } else {
                    paramName = getMessageParamQName(input, param.getName(), inMsgIndex);
                    inMsgIndex++;
                }
            } else {
                if (wrap) {
                    paramName = new QName(outWrapNSUri, param.getName());
                } else {
                    paramName = getMessageParamQName(output, param.getName(), outMsgIndex);
                    outMsgIndex++;
                }
            }
            CorbaObjectHandler obj = CorbaHandlerUtils.initializeObjectHandler(orb, paramName, paramIdlType, map, service);
            streamables[i] = corbaMsg.createStreamableObject(obj, paramName);
            Any value = CorbaAnyHelper.createAny(orb);
            if (paramMode.value().equals("in")) {
                streamables[i].setMode(org.omg.CORBA.ARG_IN.value);
                streamables[i].getObject().setIntoAny(value, streamables[i], false);
            } else if (paramMode.value().equals("out")) {
                streamables[i].setMode(org.omg.CORBA.ARG_OUT.value);
                streamables[i].getObject().setIntoAny(value, streamables[i], true);
            } else {
                streamables[i].setMode(org.omg.CORBA.ARG_INOUT.value);
                streamables[i].getObject().setIntoAny(value, streamables[i], false);
            }
            list.add_value(streamables[i].getName(), value, streamables[i].getMode());
            corbaMsg.addStreamableArgument(streamables[i]);
        }
        return list;
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) QName(javax.xml.namespace.QName) Any(org.omg.CORBA.Any) Endpoint(org.apache.cxf.endpoint.Endpoint) ParamType(org.apache.cxf.binding.corba.wsdl.ParamType) MessageInfo(org.apache.cxf.service.model.MessageInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) ModeType(org.apache.cxf.binding.corba.wsdl.ModeType) CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler) NVList(org.omg.CORBA.NVList)

Example 13 with CorbaObjectHandler

use of org.apache.cxf.binding.corba.types.CorbaObjectHandler in project cxf by apache.

the class CorbaStreamOutEndingInterceptor method handleInBoundMessage.

private void handleInBoundMessage(CorbaMessage message, BindingOperationInfo boi) {
    OperationInfo opInfo = boi.getOperationInfo();
    OperationType opType = boi.getExtensor(OperationType.class);
    List<ParamType> paramTypes = opType.getParam();
    MessageInfo msgInInfo = opInfo.getInput();
    String wrapNSUri = null;
    boolean wrap = false;
    if (boi.isUnwrappedCapable()) {
        wrap = true;
        if (msgInInfo != null) {
            wrapNSUri = getWrappedParamNamespace(msgInInfo);
            if (!CorbaUtils.isElementFormQualified(service, wrapNSUri)) {
                wrapNSUri = "";
            }
        }
    }
    CorbaStreamWriter writer = (CorbaStreamWriter) message.getContent(XMLStreamWriter.class);
    CorbaObjectHandler[] objs = writer.getCorbaObjects();
    int count = 0;
    int msgIndex = 0;
    ArgType returnParam = opType.getReturn();
    if (returnParam != null) {
        CorbaObjectHandler obj = objs[count++];
        QName retName = obj.getName();
        CorbaStreamable streamable = message.createStreamableObject(obj, retName);
        message.setStreamableReturn(streamable);
    }
    for (Iterator<ParamType> iter = paramTypes.iterator(); iter.hasNext(); ) {
        ParamType param = iter.next();
        QName idlType = param.getIdltype();
        QName paramName;
        CorbaObjectHandler obj = null;
        if (param.getMode().equals(ModeType.IN)) {
            if (wrap) {
                paramName = new QName(wrapNSUri, param.getName());
            } else {
                paramName = getMessageParamQName(msgInInfo, param.getName(), msgIndex);
            }
            obj = CorbaHandlerUtils.initializeObjectHandler(orb, paramName, idlType, typeMap, service);
            msgIndex++;
        } else {
            obj = objs[count++];
            paramName = obj.getName();
        }
        CorbaStreamable streamable = message.createStreamableObject(obj, paramName);
        ModeType paramMode = param.getMode();
        if (paramMode.value().equals("in")) {
            streamable.setMode(org.omg.CORBA.ARG_IN.value);
        } else if (paramMode.value().equals("inout")) {
            streamable.setMode(org.omg.CORBA.ARG_INOUT.value);
        } else if (paramMode.value().equals("out")) {
            streamable.setMode(org.omg.CORBA.ARG_OUT.value);
        }
        message.addStreamableArgument(streamable);
    }
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) ArgType(org.apache.cxf.binding.corba.wsdl.ArgType) CorbaStreamable(org.apache.cxf.binding.corba.CorbaStreamable) QName(javax.xml.namespace.QName) ParamType(org.apache.cxf.binding.corba.wsdl.ParamType) MessageInfo(org.apache.cxf.service.model.MessageInfo) CorbaStreamWriter(org.apache.cxf.binding.corba.runtime.CorbaStreamWriter) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler) ModeType(org.apache.cxf.binding.corba.wsdl.ModeType) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType)

Example 14 with CorbaObjectHandler

use of org.apache.cxf.binding.corba.types.CorbaObjectHandler in project cxf by apache.

the class CorbaObjectReader method readUnion.

public void readUnion(CorbaUnionHandler unionHandler) throws CorbaBindingException {
    Union unionType = (Union) unionHandler.getType();
    List<Unionbranch> branches = unionType.getUnionbranch();
    CorbaObjectHandler discriminator = unionHandler.getDiscriminator();
    if (!branches.isEmpty()) {
        String discLabel = null;
        if (discriminator.getTypeCodeKind().value() == TCKind._tk_enum) {
            CorbaEnumHandler disc = (CorbaEnumHandler) discriminator;
            readEnumDiscriminator(unionHandler, disc);
            discLabel = disc.getValue();
        } else {
            read(discriminator);
            discLabel = ((CorbaPrimitiveHandler) discriminator).getDataFromValue();
        }
        // Now find the label in the union to get the right case
        Unionbranch defaultBranch = null;
        boolean caseFound = false;
        for (Iterator<Unionbranch> branchIter = branches.iterator(); branchIter.hasNext(); ) {
            Unionbranch branch = branchIter.next();
            if (branch.isSetDefault() && branch.isDefault()) {
                defaultBranch = branch;
            }
            List<CaseType> cases = branch.getCase();
            for (Iterator<CaseType> caseIter = cases.iterator(); caseIter.hasNext(); ) {
                CaseType c = caseIter.next();
                if (c.getLabel().equalsIgnoreCase(discLabel)) {
                    CorbaObjectHandler branchObj = unionHandler.getBranchByName(branch.getName());
                    this.read(branchObj);
                    unionHandler.setValue(branch.getName(), branchObj);
                    caseFound = true;
                    break;
                }
            }
            if (caseFound) {
                break;
            }
        }
        // found the default case.
        if (!caseFound && defaultBranch != null) {
            CorbaObjectHandler branchObj = unionHandler.getBranchByName(defaultBranch.getName());
            this.read(branchObj);
            unionHandler.setValue(defaultBranch.getName(), branchObj);
        }
    }
}
Also used : CaseType(org.apache.cxf.binding.corba.wsdl.CaseType) CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler) CorbaEnumHandler(org.apache.cxf.binding.corba.types.CorbaEnumHandler) Union(org.apache.cxf.binding.corba.wsdl.Union) Unionbranch(org.apache.cxf.binding.corba.wsdl.Unionbranch)

Example 15 with CorbaObjectHandler

use of org.apache.cxf.binding.corba.types.CorbaObjectHandler in project cxf by apache.

the class CorbaObjectWriter method writeException.

public void writeException(CorbaExceptionHandler exHandler) throws CorbaBindingException {
    Exception exType = (Exception) exHandler.getType();
    List<CorbaObjectHandler> exMembers = exHandler.getMembers();
    stream.write_string(exType.getRepositoryID());
    for (int i = 0; i < exMembers.size(); ++i) {
        this.write(exMembers.get(i));
    }
}
Also used : CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler) Exception(org.apache.cxf.binding.corba.wsdl.Exception) CorbaBindingException(org.apache.cxf.binding.corba.CorbaBindingException)

Aggregations

CorbaObjectHandler (org.apache.cxf.binding.corba.types.CorbaObjectHandler)16 QName (javax.xml.namespace.QName)10 CorbaStreamable (org.apache.cxf.binding.corba.CorbaStreamable)4 TypeCode (org.omg.CORBA.TypeCode)4 OutputStream (org.omg.CORBA.portable.OutputStream)4 CorbaBindingException (org.apache.cxf.binding.corba.CorbaBindingException)3 CorbaPrimitiveHandler (org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler)3 CorbaSequenceHandler (org.apache.cxf.binding.corba.types.CorbaSequenceHandler)3 ModeType (org.apache.cxf.binding.corba.wsdl.ModeType)3 ParamType (org.apache.cxf.binding.corba.wsdl.ParamType)3 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)3 Test (org.junit.Test)3 Any (org.omg.CORBA.Any)3 InputStream (org.omg.CORBA.portable.InputStream)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)2 CorbaFaultStreamWriter (org.apache.cxf.binding.corba.runtime.CorbaFaultStreamWriter)2 CorbaStreamWriter (org.apache.cxf.binding.corba.runtime.CorbaStreamWriter)2 CorbaArrayHandler (org.apache.cxf.binding.corba.types.CorbaArrayHandler)2