Search in sources :

Example 36 with TypeCode

use of org.omg.CORBA.TypeCode in project cxf by apache.

the class CorbaAnyEventProducer method getAnyContainedType.

private CorbaObjectHandler getAnyContainedType(Any a) {
    CorbaObjectHandler result = null;
    TypeCode tc = a.type();
    QName containedName = new QName("AnyContainedType");
    QName idlType = null;
    if (CorbaUtils.isPrimitiveTypeCode(tc)) {
        idlType = CorbaAnyHelper.getPrimitiveIdlTypeFromTypeCode(tc);
        result = new CorbaPrimitiveHandler(containedName, idlType, tc, null);
    } else if (tc.kind().value() == TCKind._tk_any) {
        idlType = CorbaConstants.NT_CORBA_ANY;
        result = new CorbaAnyHandler(containedName, idlType, tc, null);
        ((CorbaAnyHandler) result).setTypeMap(handler.getTypeMap());
    } else {
        idlType = handler.getTypeMap().getIdlType(tc);
        result = CorbaHandlerUtils.initializeObjectHandler(orb, containedName, idlType, handler.getTypeMap(), serviceInfo);
    }
    InputStream is = a.create_input_stream();
    CorbaObjectReader reader = new CorbaObjectReader(is);
    reader.read(result);
    return result;
}
Also used : TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) InputStream(org.omg.CORBA.portable.InputStream) CorbaObjectReader(org.apache.cxf.binding.corba.runtime.CorbaObjectReader)

Example 37 with TypeCode

use of org.omg.CORBA.TypeCode in project cxf by apache.

the class CorbaHandlerUtils method getTypeListener.

public static CorbaTypeListener getTypeListener(QName name, QName idlType, CorbaTypeMap typeMap, ORB orb, ServiceInfo serviceInfo) throws CorbaBindingException {
    CorbaObjectHandler handler = null;
    TypeCode tc = CorbaUtils.getTypeCode(orb, idlType, typeMap);
    try {
        while (tc.kind().value() == TCKind._tk_alias) {
            Alias alias = (Alias) CorbaUtils.getCorbaType(idlType, typeMap);
            if (alias == null) {
                throw new CorbaBindingException("Couldn't find corba alias type: " + idlType);
            }
            tc = tc.content_type();
            idlType = alias.getBasetype();
        }
    } catch (Throwable ex) {
        throw new CorbaBindingException(ex);
    }
    CorbaTypeListener result = null;
    if (CorbaUtils.isPrimitiveIdlType(idlType)) {
        handler = new CorbaPrimitiveHandler(name, idlType, tc, null);
        result = new CorbaPrimitiveListener(handler);
    } else {
        CorbaType type = CorbaUtils.getCorbaType(idlType, typeMap);
        switch(tc.kind().value()) {
            case TCKind._tk_any:
                handler = new CorbaAnyHandler(name, idlType, tc, type);
                ((CorbaAnyHandler) handler).setTypeMap(typeMap);
                result = new CorbaAnyListener(handler, typeMap, orb, serviceInfo);
                break;
            case TCKind._tk_array:
                handler = new CorbaArrayHandler(name, idlType, tc, type);
                result = new CorbaArrayListener(handler, typeMap, orb, serviceInfo);
                break;
            case TCKind._tk_enum:
                handler = new CorbaEnumHandler(name, idlType, tc, type);
                result = new CorbaEnumListener(handler);
                break;
            case TCKind._tk_except:
                handler = new CorbaExceptionHandler(name, idlType, tc, type);
                result = new CorbaExceptionListener(handler, typeMap, orb, serviceInfo);
                break;
            case TCKind._tk_fixed:
                handler = new CorbaFixedHandler(name, idlType, tc, type);
                result = new CorbaFixedListener(handler);
                break;
            case TCKind._tk_sequence:
                if (isOctets(type)) {
                    handler = new CorbaOctetSequenceHandler(name, idlType, tc, type);
                    result = new CorbaOctetSequenceListener(handler);
                } else {
                    handler = new CorbaSequenceHandler(name, idlType, tc, type);
                    result = new CorbaSequenceListener(handler, typeMap, orb, serviceInfo);
                }
                break;
            case TCKind._tk_string:
            case TCKind._tk_wstring:
                // These can be handled just like regular strings
                handler = new CorbaPrimitiveHandler(name, idlType, tc, type);
                result = new CorbaPrimitiveListener(handler);
                break;
            case TCKind._tk_struct:
                handler = new CorbaStructHandler(name, idlType, tc, type);
                result = new CorbaStructListener(handler, typeMap, orb, serviceInfo);
                break;
            case TCKind._tk_union:
                handler = new CorbaUnionHandler(name, idlType, tc, type);
                result = new CorbaUnionListener(handler, typeMap, orb, serviceInfo);
                break;
            case TCKind._tk_objref:
                handler = new CorbaObjectReferenceHandler(name, idlType, tc, type);
                result = new CorbaObjectReferenceListener(handler, orb);
                break;
            default:
                throw new CorbaBindingException("Unsupported complex type " + idlType);
        }
    }
    return result;
}
Also used : CorbaBindingException(org.apache.cxf.binding.corba.CorbaBindingException) TypeCode(org.omg.CORBA.TypeCode) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) Alias(org.apache.cxf.binding.corba.wsdl.Alias)

Example 38 with TypeCode

use of org.omg.CORBA.TypeCode in project cxf by apache.

the class CorbaHandlerUtils method getTypeEventProducer.

public static CorbaTypeEventProducer getTypeEventProducer(CorbaObjectHandler handler, ServiceInfo serviceInfo, ORB orb) throws CorbaBindingException {
    QName idlType = handler.getIdlType();
    TypeCode tc = handler.getTypeCode();
    CorbaTypeEventProducer result = null;
    if (CorbaUtils.isPrimitiveIdlType(idlType)) {
        result = new CorbaPrimitiveTypeEventProducer(handler);
    } else {
        switch(tc.kind().value()) {
            case TCKind._tk_any:
                result = new CorbaAnyEventProducer(handler, serviceInfo, orb);
                break;
            case TCKind._tk_array:
                result = new CorbaArrayEventProducer(handler, serviceInfo, orb);
                break;
            case TCKind._tk_enum:
                result = new CorbaEnumEventProducer(handler);
                break;
            case TCKind._tk_except:
                result = new CorbaExceptionEventProducer(handler, serviceInfo, orb);
                break;
            case TCKind._tk_fixed:
                result = new CorbaFixedEventProducer(handler);
                break;
            case TCKind._tk_sequence:
                if (isOctets(handler.getType())) {
                    result = new CorbaOctetSequenceEventProducer(handler);
                } else {
                    result = new CorbaSequenceEventProducer(handler, serviceInfo, orb);
                }
                break;
            case TCKind._tk_string:
            case TCKind._tk_wstring:
                // These can be handled just like regular strings
                result = new CorbaPrimitiveTypeEventProducer(handler);
                break;
            case TCKind._tk_struct:
                if (handler.isAnonymousType()) {
                    result = new CorbaAnonStructEventProducer(handler, serviceInfo, orb);
                } else {
                    result = new CorbaStructEventProducer(handler, serviceInfo, orb);
                }
                break;
            case TCKind._tk_union:
                result = new CorbaUnionEventProducer(handler, serviceInfo, orb);
                break;
            case TCKind._tk_objref:
                result = new CorbaObjectReferenceEventProducer(handler, serviceInfo, orb);
                break;
            default:
                throw new CorbaBindingException("Unsupported complex type " + idlType);
        }
    }
    return result;
}
Also used : CorbaBindingException(org.apache.cxf.binding.corba.CorbaBindingException) TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName)

Example 39 with TypeCode

use of org.omg.CORBA.TypeCode in project cxf by apache.

the class CorbaHandlerUtils method createTypeHandler.

public static CorbaObjectHandler createTypeHandler(ORB orb, QName name, QName idlType, CorbaTypeMap typeMap) {
    CorbaObjectHandler handler = null;
    TypeCode tc = CorbaUtils.getTypeCode(orb, idlType, typeMap);
    try {
        while (tc.kind().value() == TCKind._tk_alias) {
            Alias alias = (Alias) CorbaUtils.getCorbaType(idlType, typeMap);
            if (alias == null) {
                throw new CorbaBindingException("Couldn't find corba alias type: " + idlType);
            }
            tc = tc.content_type();
            idlType = alias.getBasetype();
        }
    } catch (Throwable ex) {
        throw new CorbaBindingException(ex);
    }
    if (CorbaUtils.isPrimitiveIdlType(idlType)) {
        handler = new CorbaPrimitiveHandler(name, idlType, tc, null);
    } else if (tc.kind().value() == TCKind._tk_any) {
        // Any is a special kind of primitive so it gets its own handler
        handler = new CorbaAnyHandler(name, idlType, tc, null);
        ((CorbaAnyHandler) handler).setTypeMap(typeMap);
    } else {
        CorbaType type = CorbaUtils.getCorbaType(idlType, typeMap);
        switch(tc.kind().value()) {
            case TCKind._tk_array:
                handler = new CorbaArrayHandler(name, idlType, tc, type);
                break;
            case TCKind._tk_enum:
                handler = new CorbaEnumHandler(name, idlType, tc, type);
                break;
            case TCKind._tk_except:
                handler = new CorbaExceptionHandler(name, idlType, tc, type);
                break;
            case TCKind._tk_fixed:
                handler = new CorbaFixedHandler(name, idlType, tc, type);
                break;
            case TCKind._tk_sequence:
                if (isOctets(type)) {
                    handler = new CorbaOctetSequenceHandler(name, idlType, tc, type);
                } else {
                    handler = new CorbaSequenceHandler(name, idlType, tc, type);
                }
                break;
            case TCKind._tk_struct:
                handler = new CorbaStructHandler(name, idlType, tc, type);
                break;
            case TCKind._tk_union:
                handler = new CorbaUnionHandler(name, idlType, tc, type);
                break;
            case TCKind._tk_string:
            case TCKind._tk_wstring:
                // These need to be here to catch the anonymous string types.
                handler = new CorbaPrimitiveHandler(name, idlType, tc, type);
                break;
            case TCKind._tk_objref:
                handler = new CorbaObjectReferenceHandler(name, idlType, tc, type);
                break;
            default:
                handler = new CorbaObjectHandler(name, idlType, tc, type);
        }
    }
    return handler;
}
Also used : CorbaBindingException(org.apache.cxf.binding.corba.CorbaBindingException) TypeCode(org.omg.CORBA.TypeCode) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) Alias(org.apache.cxf.binding.corba.wsdl.Alias)

Example 40 with TypeCode

use of org.omg.CORBA.TypeCode in project cxf by apache.

the class CorbaUtils method getTypeCode.

public static TypeCode getTypeCode(ORB orb, QName type, CorbaType obj, CorbaTypeMap typeMap, Stack<QName> seenTypes) {
    if (type == null) {
        throw new CorbaBindingException("corba:typemap type or elemtype information required" + (obj == null ? "" : " for " + obj) + (seenTypes.empty() ? "" : ", Enclosing type: " + seenTypes.elementAt(0)));
    }
    TypeCode tc = null;
    // first see if it is a primitive
    tc = getPrimitiveTypeCode(orb, type);
    if (tc == null && type.equals(CorbaConstants.NT_CORBA_ANY)) {
        // Anys are handled in a special way
        tc = orb.get_primitive_tc(TCKind.from_int(TCKind._tk_any));
    } else if (tc == null) {
        if (typeMap == null) {
            throw new CorbaBindingException("Unable to locate typemap for namespace \"" + type.getNamespaceURI() + "\"");
        }
        tc = typeMap.getTypeCode(type);
        if (tc == null) {
            if (obj == null) {
                obj = typeMap.getType(type.getLocalPart());
                if (obj == null) {
                    throw new CorbaBindingException("Unable to locate object definition");
                }
            }
            tc = getComplexTypeCode(orb, type, obj, typeMap, seenTypes);
            if (tc != null) {
                typeMap.addTypeCode(type, tc);
            }
        }
    }
    if (tc == null) {
        throw new CorbaBindingException("Corba type node with qname " + type + " is not supported");
    }
    return tc;
}
Also used : CorbaBindingException(org.apache.cxf.binding.corba.CorbaBindingException) TypeCode(org.omg.CORBA.TypeCode)

Aggregations

TypeCode (org.omg.CORBA.TypeCode)69 QName (javax.xml.namespace.QName)49 Test (org.junit.Test)44 CorbaPrimitiveHandler (org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler)18 InputStream (org.omg.CORBA.portable.InputStream)15 OutputStream (org.omg.CORBA.portable.OutputStream)14 StructMember (org.omg.CORBA.StructMember)9 CorbaBindingException (org.apache.cxf.binding.corba.CorbaBindingException)6 MemberType (org.apache.cxf.binding.corba.wsdl.MemberType)6 Any (org.omg.CORBA.Any)6 NVList (org.omg.CORBA.NVList)6 CorbaStreamable (org.apache.cxf.binding.corba.CorbaStreamable)5 CorbaObjectHandler (org.apache.cxf.binding.corba.types.CorbaObjectHandler)4 Array (org.apache.cxf.binding.corba.wsdl.Array)4 Enum (org.apache.cxf.binding.corba.wsdl.Enum)4 Enumerator (org.apache.cxf.binding.corba.wsdl.Enumerator)4 Sequence (org.apache.cxf.binding.corba.wsdl.Sequence)4 Struct (org.apache.cxf.binding.corba.wsdl.Struct)4 IOException (java.io.IOException)3 Alias (org.apache.cxf.binding.corba.wsdl.Alias)3