Package org.apache.schemas.yoko.bindings.corba

Examples of org.apache.schemas.yoko.bindings.corba.Exception


        throws CorbaBindingException {
        CorbaExceptionHandler obj = null;
        CorbaTypeImpl typeDefinition = CorbaUtils.getCorbaType(idlType, typeMaps);
       
        try {
            Exception exType = (Exception)typeDefinition;
            StartElement exStartEl = reader.nextEvent().asStartElement();
            obj = new CorbaExceptionHandler(exStartEl.getName(), idlType, tc, exType);
            List<MemberType> exMembers = exType.getMember();
            for (Iterator<MemberType> iter = exMembers.iterator(); iter.hasNext();) {
                MemberType m = iter.next();
                CorbaObjectHandler member = readObjectFromStax(reader, m.getIdltype(), true);
                obj.addMember(member);
            }
View Full Code Here


                mappingType.getStructOrExceptionOrUnion().add(enumType);
            } else if (currentNode.getNodeName().equals("corba:struct")) {
                Struct structType = getStructDefinition(currentNode, def);
                mappingType.getStructOrExceptionOrUnion().add(structType);
            } else if (currentNode.getNodeName().equals("corba:exception")) {
                Exception exceptType = getExceptionDefinition(currentNode, def);
                mappingType.getStructOrExceptionOrUnion().add(exceptType);
            } else if (currentNode.getNodeName().equals("corba:fixed")) {
                Fixed fixedType = getFixedDefinition(currentNode, def);
                mappingType.getStructOrExceptionOrUnion().add(fixedType);
            } else if (currentNode.getNodeName().equals("corba:union")) {
View Full Code Here

        }
        return structType;
    }

    public Exception getExceptionDefinition(Node node, Definition def) {
        Exception exceptType = new Exception();
        NamedNodeMap exceptAttributes = node.getAttributes();

        // Store information about the exception
        for (int i = 0; i < exceptAttributes.getLength(); ++i) {
            if (exceptAttributes.item(i).getNodeName().equals("name")) {
                exceptType.setName(exceptAttributes.item(i).getNodeValue());
            } else if (exceptAttributes.item(i).getNodeName().equals("repositoryID")) {
                exceptType.setRepositoryID(exceptAttributes.item(i).getNodeValue());
            }
        }

        // Store information about the exceptions members
        NodeList exceptChildNodes = node.getChildNodes();
        for (int i = 0; i < exceptChildNodes.getLength(); ++i) {
            Node currentNode = exceptChildNodes.item(i);

            if (currentNode.getNodeName().equals("corba:member")) {
                MemberType member = new MemberType();
                NamedNodeMap memberAttributes = currentNode.getAttributes();

                for (int j = 0; j < memberAttributes.getLength(); ++j) {
                    Node memberAttrNode = memberAttributes.item(j);
                    if (memberAttrNode.getNodeName().equals("name")) {
                        member.setName(memberAttrNode.getNodeValue());
                    } else if (memberAttrNode.getNodeName().equals("idltype")) {
                        String idlType = memberAttrNode.getNodeValue();
                        int seperatorIndex = idlType.indexOf(':');
                        String prefix = idlType.substring(0, seperatorIndex);
                        String localPart = idlType.substring(seperatorIndex + 1, idlType.length());
                        member.setIdltype(new QName(def.getNamespace(prefix), localPart, prefix));
                    }
                }
                exceptType.getMember().add(member);
            }
        }
        return exceptType;
    }
View Full Code Here

       
        QName exceptIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "exception", CorbaConstants.NP_WSDL_CORBA);
        QName shortIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "short", CorbaConstants.NP_WSDL_CORBA);
        QName stringIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "string", CorbaConstants.NP_WSDL_CORBA);
       
        Exception exceptType = new Exception();
        exceptType.setName("TestException");
        MemberType m1 = new MemberType();
        m1.setIdltype(shortIdlType);
        m1.setName("code");
        MemberType m2 = new MemberType();
        m2.setIdltype(stringIdlType);
        m2.setName("message");
        exceptType.getMember().add(m1);
        exceptType.getMember().add(m2);

        // build the object holder
        StructMember[] exceptMembers = new StructMember[2];
        exceptMembers[0] = new StructMember("code", orb.get_primitive_tc(TCKind.tk_short), null);
        exceptMembers[1] = new StructMember("message", orb.get_primitive_tc(TCKind.tk_string), null);
View Full Code Here

            for (int i = 0; i < members.length; ++i) {
                members[i] = ((Enumerator) enums.get(i)).getValue();
            }
            tc = orb.create_enum_tc(enumType.getRepositoryID(), name, members);
        } else if (obj instanceof Exception) {
            Exception exceptType = (Exception)obj;

            // TODO: check to see if this is a recursive type.
            List list = exceptType.getMember();
            StructMember[] members = new StructMember[list.size()];
            for (int i = 0; i < members.length; ++i) {
                MemberType member = (MemberType) list.get(i);
                members[i] = new StructMember(member.getName(),
                                              getTypeCode(orb, member.getIdltype(), typeMaps), null);
            }
            String name = exceptType.getName();
            tc = orb.create_exception_tc(exceptType.getRepositoryID(), name, members);
        } else if (obj instanceof Fixed) {
            Fixed fixedType = (Fixed) obj;
            tc = orb.create_fixed_tc((short) fixedType.getDigits(), (short) fixedType.getScale());
        } else if (obj instanceof Sequence) {
            Sequence seqType = (Sequence)obj;
View Full Code Here

    public CorbaStreamable createStreamableException(Any exception, RaisesType exRaises) {
        // first, we need to get the definition of the exception.  All we have from the raises type is the
        // exception idl type
        QName exIdlType = exRaises.getException();
        List<CorbaTypeMap> typeMaps = corbaBinding.getCorbaTypeMaps();
        Exception ex = null;
        for (Iterator i = typeMaps.iterator(); i.hasNext();) {
            CorbaTypeMap tm = (CorbaTypeMap)i.next();
            if (tm.getTargetNamespace().equals(exIdlType.getNamespaceURI())) {
                ex = (Exception)tm.getType(exIdlType.getLocalPart());
                break;
            }
        }
       
        if (ex == null) {
            throw new CorbaBindingException("Unable to find definition for thrown exception");
        }
       
        TypeCode tc = CorbaUtils.getTypeCode(orb, exIdlType, typeMaps);
        // TODO: Revisit - What should the name of the object holder be?
        CorbaExceptionHandler obj = new CorbaExceptionHandler(new QName(ex.getName()), exIdlType, tc, ex);
        List<MemberType> exMembers = ex.getMember();
        for (Iterator i = exMembers.iterator(); i.hasNext();) {
            MemberType member = (MemberType)i.next();
            QName memberName = new QName(member.getName());
            QName memberType = member.getIdltype();
            CorbaObjectHandler memberObj =
View Full Code Here

        }
    }

    public void writeException(CorbaObjectHandler obj) throws CorbaBindingException {
        CorbaExceptionHandler exHandler = (CorbaExceptionHandler)obj;
        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));
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.schemas.yoko.bindings.corba.Exception

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.