Search in sources :

Example 1 with Alias

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

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

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

the class DeclaratorVisitor method visitNewTypes.

private void visitNewTypes(Scope newScope) {
    CorbaType nextCorbaType = null;
    XmlSchemaType nextSchemaType = null;
    CorbaType oldCorbaType = getCorbaType();
    QName newQname = new QName(getCorbaType().getQName().getNamespaceURI(), newScope.toString());
    if (oldCorbaType instanceof Alias) {
        // Alias
        // 
        Alias oldAlias = (Alias) oldCorbaType;
        Alias alias = new Alias();
        alias.setQName(newQname);
        alias.setBasetype(oldAlias.getBasetype());
        alias.setType(oldAlias.getType());
        alias.setRepositoryID(newScope.toIDLRepositoryID());
        nextCorbaType = alias;
    } else if (oldCorbaType instanceof Sequence) {
        // Sequence
        // 
        nextSchemaType = duplicateXmlSchemaComplexType(newScope);
        Sequence oldSequence = (Sequence) oldCorbaType;
        Sequence newSequence = new Sequence();
        newSequence.setQName(newQname);
        newSequence.setType(nextSchemaType.getQName());
        newSequence.setElemtype(oldSequence.getElemtype());
        newSequence.setElemname(oldSequence.getElemname());
        newSequence.setBound(oldSequence.getBound());
        newSequence.setRepositoryID(newScope.toIDLRepositoryID());
        nextCorbaType = newSequence;
    } else if (oldCorbaType instanceof Fixed) {
        // Fixed
        // 
        nextSchemaType = duplicateXmlSchemaSimpleType(newScope);
        Fixed oldFixed = (Fixed) getCorbaType();
        Fixed newFixed = new Fixed();
        newFixed.setQName(newQname);
        newFixed.setDigits(oldFixed.getDigits());
        newFixed.setScale(oldFixed.getScale());
        newFixed.setType(oldFixed.getType());
        newFixed.setRepositoryID(newScope.toIDLRepositoryID());
        nextCorbaType = newFixed;
    } else {
        System.err.println("[DeclaratorVisitor: Unexpected CORBA type error!]");
        System.exit(1);
    }
    if (nextCorbaType != null) {
        typeMap.getStructOrExceptionOrUnion().add(nextCorbaType);
    }
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) Alias(org.apache.cxf.binding.corba.wsdl.Alias) Sequence(org.apache.cxf.binding.corba.wsdl.Sequence) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) Fixed(org.apache.cxf.binding.corba.wsdl.Fixed)

Example 4 with Alias

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

the class ScopedNameVisitor method populateAliasSchemaType.

protected static void populateAliasSchemaType(CorbaType corbaType, WSDLASTVisitor wsdlVisitor, VisitorTypeHolder holder) {
    XmlSchemaCollection schemas = wsdlVisitor.getSchemas();
    TypeMappingType typeMap = wsdlVisitor.getTypeMap();
    holder.setCorbaType(corbaType);
    Alias alias = (Alias) corbaType;
    // loop through alias base types, till you get a non-alias corba type
    CorbaType type = findCorbaType(typeMap, alias.getBasetype());
    while ((type != null) && (type instanceof Alias)) {
        alias = (Alias) type;
        type = findCorbaType(typeMap, alias.getBasetype());
    }
    QName tname;
    if (type == null) {
        // it must be a primitive type
        tname = xmlSchemaPrimitiveMap.get(alias.getBasetype());
    } else {
        tname = type.getType();
    }
    XmlSchemaType stype = schemas.getTypeByQName(tname);
    if (stype == null) {
        XmlSchema xmlSchema = wsdlVisitor.getManager().getXmlSchema(tname.getNamespaceURI());
        if (xmlSchema != null) {
            stype = xmlSchema.getTypeByName(tname);
        } else {
            stype = wsdlVisitor.getSchema().getTypeByName(tname);
        }
    }
    holder.setSchemaType(stype);
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) XmlSchema(org.apache.ws.commons.schema.XmlSchema) Alias(org.apache.cxf.binding.corba.wsdl.Alias) QName(javax.xml.namespace.QName) TypeMappingType(org.apache.cxf.binding.corba.wsdl.TypeMappingType) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaCollection(org.apache.ws.commons.schema.XmlSchemaCollection)

Example 5 with Alias

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

the class ScopedNameVisitor method findNonSchemaType.

protected static boolean findNonSchemaType(String name, WSDLASTVisitor wsdlVisitor, VisitorTypeHolder holder) {
    boolean result = false;
    TypeMappingType typeMap = wsdlVisitor.getTypeMap();
    XmlSchemaCollection schemas = wsdlVisitor.getSchemas();
    QName qname = new QName(typeMap.getTargetNamespace(), name);
    CorbaType corbaType = findCorbaType(typeMap, qname);
    if (corbaType != null) {
        if (corbaType instanceof Alias) {
            result = true;
            if (holder != null) {
                populateAliasSchemaType(corbaType, wsdlVisitor, holder);
            }
        } else if (((corbaType instanceof Sequence) || (corbaType instanceof Anonsequence)) && ((corbaType.getType().equals(Constants.XSD_BASE64)))) {
            // special case of sequence of octets
            result = true;
            if (holder != null) {
                holder.setCorbaType(corbaType);
                holder.setSchemaType(schemas.getTypeByQName(corbaType.getType()));
            }
        }
    }
    return result;
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) Alias(org.apache.cxf.binding.corba.wsdl.Alias) TypeMappingType(org.apache.cxf.binding.corba.wsdl.TypeMappingType) Sequence(org.apache.cxf.binding.corba.wsdl.Sequence) XmlSchemaCollection(org.apache.ws.commons.schema.XmlSchemaCollection) Anonsequence(org.apache.cxf.binding.corba.wsdl.Anonsequence)

Aggregations

Alias (org.apache.cxf.binding.corba.wsdl.Alias)10 QName (javax.xml.namespace.QName)8 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)7 Sequence (org.apache.cxf.binding.corba.wsdl.Sequence)4 CorbaBindingException (org.apache.cxf.binding.corba.CorbaBindingException)3 Fixed (org.apache.cxf.binding.corba.wsdl.Fixed)3 TypeCode (org.omg.CORBA.TypeCode)3 Anonsequence (org.apache.cxf.binding.corba.wsdl.Anonsequence)2 Array (org.apache.cxf.binding.corba.wsdl.Array)2 Enum (org.apache.cxf.binding.corba.wsdl.Enum)2 Struct (org.apache.cxf.binding.corba.wsdl.Struct)2 TypeMappingType (org.apache.cxf.binding.corba.wsdl.TypeMappingType)2 Union (org.apache.cxf.binding.corba.wsdl.Union)2 XmlSchemaCollection (org.apache.ws.commons.schema.XmlSchemaCollection)2 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)2 List (java.util.List)1 Anonarray (org.apache.cxf.binding.corba.wsdl.Anonarray)1 Anonfixed (org.apache.cxf.binding.corba.wsdl.Anonfixed)1 Anonstring (org.apache.cxf.binding.corba.wsdl.Anonstring)1 Anonwstring (org.apache.cxf.binding.corba.wsdl.Anonwstring)1