Search in sources :

Example 1 with CorbaType

use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.

the class CorbaTypeMap method getIdlType.

// This is used by the Any type when trying to re-construct the type stored inside a
// CORBA Any.
public QName getIdlType(TypeCode tc) {
    final String repId;
    try {
        repId = tc.id();
    } catch (org.omg.CORBA.TypeCodePackage.BadKind ex) {
        // No id has been set.
        return null;
    }
    if (repId == null) {
        return null;
    }
    Set<Map.Entry<String, CorbaType>> mapSet = typeMap.entrySet();
    for (Iterator<Map.Entry<String, CorbaType>> i = mapSet.iterator(); i.hasNext(); ) {
        Map.Entry<String, CorbaType> entry = i.next();
        if (entry.getValue() instanceof NamedType) {
            NamedType n = (NamedType) entry.getValue();
            if (n.getRepositoryID().equals(repId)) {
                return new QName(getTargetNamespace(), entry.getKey());
            }
        }
    }
    return null;
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) NamedType(org.apache.cxf.binding.corba.wsdl.NamedType) QName(javax.xml.namespace.QName) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with CorbaType

use of org.apache.cxf.binding.corba.wsdl.CorbaType 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 3 with CorbaType

use of org.apache.cxf.binding.corba.wsdl.CorbaType 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 {
    final CorbaObjectHandler handler;
    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 4 with CorbaType

use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.

the class CorbaTypeMapTest method testCorbaTypeMap.

@Test
public void testCorbaTypeMap() throws Exception {
    CorbaTypeMap typeMap = new CorbaTypeMap("http://yoko.apache.org/ComplexTypes");
    String targetNamespace = typeMap.getTargetNamespace();
    assertEquals(targetNamespace, "http://yoko.apache.org/ComplexTypes");
    QName type = new QName("http://yoko.apache.org/ComplexTypes", "xsd1:Test.MultiPart.Colour", "");
    CorbaType corbaTypeImpl = new CorbaType();
    corbaTypeImpl.setType(type);
    corbaTypeImpl.setName("Test.MultiPart.Colour");
    typeMap.addType("Test.MultiPart.Colour", corbaTypeImpl);
    CorbaType corbatype = typeMap.getType("Test.MultiPart.Colour");
    assertEquals(corbatype.getName(), "Test.MultiPart.Colour");
    assertEquals(corbatype.getType().getLocalPart(), "xsd1:Test.MultiPart.Colour");
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) Test(org.junit.Test)

Example 5 with CorbaType

use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.

the class CorbaStructListener method processStartElement.

public void processStartElement(QName name) {
    if (depth == 0 && (currentElement != null) && (!currentElement.equals(name))) {
        currentTypeListener = null;
    }
    depth++;
    if (currentTypeListener == null) {
        QName elName = name;
        MemberType member = null;
        while (true) {
            member = structMembers.get(memberCount++);
            // members - we have a chance to "catch up" and add required (empty sequences) members
            if (member.getName().equals(name.getLocalPart()) || (member.isSetAnonschematype() && member.isAnonschematype())) {
                break;
            }
            currentTypeListener = CorbaHandlerUtils.getTypeListener(elName, member.getIdltype(), typeMap, orb, serviceInfo);
            currentTypeListener.setNamespaceContext(ctx);
            ((CorbaStructHandler) handler).addMember(currentTypeListener.getCorbaObject());
        }
        boolean anonType = false;
        if (member.isSetAnonschematype() && member.isAnonschematype()) {
            anonType = true;
            elName = CorbaUtils.getEmptyQName();
            currentElement = null;
        } else {
            currentElement = name;
        }
        currentTypeListener = CorbaHandlerUtils.getTypeListener(elName, member.getIdltype(), typeMap, orb, serviceInfo);
        currentTypeListener.setNamespaceContext(ctx);
        ((CorbaStructHandler) handler).addMember(currentTypeListener.getCorbaObject());
        if (anonType) {
            currentTypeListener.getCorbaObject().setAnonymousType(true);
            currentTypeListener.processStartElement(name);
        } else {
            CorbaType type = CorbaUtils.getCorbaType(member.getIdltype(), typeMap);
            boolean wrapped = true;
            if (type instanceof Abstractsequence) {
                wrapped = ((Abstractsequence) type).isWrapped();
            } else if (type instanceof Abstractanonsequence) {
                wrapped = ((Abstractanonsequence) type).isWrapped();
            }
            // to process StartElement of first element of collection
            if (!wrapped) {
                currentTypeListener.processStartElement(name);
            }
        }
    } else {
        currentTypeListener.processStartElement(name);
    }
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) QName(javax.xml.namespace.QName) Abstractsequence(org.apache.cxf.binding.corba.wsdl.Abstractsequence) Abstractanonsequence(org.apache.cxf.binding.corba.wsdl.Abstractanonsequence)

Aggregations

CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)72 QName (javax.xml.namespace.QName)45 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)23 MemberType (org.apache.cxf.binding.corba.wsdl.MemberType)13 AST (antlr.collections.AST)9 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)9 TypeMappingType (org.apache.cxf.binding.corba.wsdl.TypeMappingType)8 Test (org.junit.Test)8 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)7 Alias (org.apache.cxf.binding.corba.wsdl.Alias)6 Anonsequence (org.apache.cxf.binding.corba.wsdl.Anonsequence)6 Sequence (org.apache.cxf.binding.corba.wsdl.Sequence)6 Struct (org.apache.cxf.binding.corba.wsdl.Struct)6 Union (org.apache.cxf.binding.corba.wsdl.Union)6 File (java.io.File)5 Definition (javax.wsdl.Definition)5 ArrayList (java.util.ArrayList)4 Anonarray (org.apache.cxf.binding.corba.wsdl.Anonarray)4 Anonstring (org.apache.cxf.binding.corba.wsdl.Anonstring)4 Array (org.apache.cxf.binding.corba.wsdl.Array)4