Example usage for javax.xml.namespace QName toString

List of usage examples for javax.xml.namespace QName toString

Introduction

In this page you can find the example usage for javax.xml.namespace QName toString.

Prototype

public String toString() 

Source Link

Document

<p><code>String</code> representation of this <code>QName</code>.</p> <p>The commonly accepted way of representing a <code>QName</code> as a <code>String</code> was <a href="http://jclark.com/xml/xmlns.htm">defined</a> by James Clark.

Usage

From source file:org.apache.axis2.schema.SchemaCompiler.java

/**
 * Finds a class name from the given Qname
 *
 * @param qName//  w ww .java2  s.c  o  m
 * @param isArray
 * @return FQCN
 */
private String findClassName(QName qName, boolean isArray) throws SchemaCompilationException {

    //find the class name
    String className;
    if (processedTypemap.containsKey(qName)) {
        className = processedTypemap.get(qName);
    } else if (simpleTypesMap.containsKey(qName)) {
        className = simpleTypesMap.get(qName);
    } else if (baseSchemaTypeMap.containsKey(qName)) {
        className = baseSchemaTypeMap.get(qName);
    } else {
        if (isSOAP_ENC(qName.getNamespaceURI())) {
            throw new SchemaCompilationException(
                    SchemaCompilerMessages.getMessage("schema.soapencoding.error", qName.toString()));

        }
        // We seem to have failed in finding a class name for the
        //contained schema type. We better set the default then
        //however it's better if the default can be set through the
        //property file
        className = writer.getDefaultClassName();
        log.warn(SchemaCompilerMessages.getMessage("schema.typeMissing", qName.toString()));
    }

    if (isArray) {
        //append the square braces that say this is an array
        //hope this works for all cases!!!!!!!
        //todo this however is a thing that needs to be
        //todo fixed to get complete language support
        className = className + "[]";
    }
    return className;
}

From source file:org.apache.axis2.schema.SchemaCompiler.java

/**
 *
 * @param parentElementQName - this could either be the complex type parentElementQName or element parentElementQName
 * @param items/*w ww. java2  s .  c o m*/
 * @param metainfHolder
 * @param order
 * @param parentSchema
 * @throws SchemaCompilationException
 */
private void process(QName parentElementQName, XmlSchemaObjectCollection items,
        BeanWriterMetaInfoHolder metainfHolder, boolean order, XmlSchema parentSchema)
        throws SchemaCompilationException {
    int count = items.getCount();
    Map<XmlSchemaObject, Boolean> processedElementArrayStatusMap = new LinkedHashMap<XmlSchemaObject, Boolean>();
    Map processedElementTypeMap = new LinkedHashMap(); // TODO: not sure what is the correct generic type here
    List<QName> localNillableList = new ArrayList<QName>();

    Map<XmlSchemaObject, QName> particleQNameMap = new HashMap<XmlSchemaObject, QName>();

    // this list is used to keep the details of the
    // elements within a choice withing sequence
    List<QName> innerChoiceElementList = new ArrayList<QName>();

    Map<XmlSchemaObject, Integer> elementOrderMap = new HashMap<XmlSchemaObject, Integer>();

    int sequenceCounter = 0;
    for (int i = 0; i < count; i++) {
        XmlSchemaObject item = items.getItem(i);

        if (item instanceof XmlSchemaElement) {
            //recursively process the element
            XmlSchemaElement xsElt = (XmlSchemaElement) item;

            boolean isArray = isArray(xsElt);
            processElement(xsElt, processedElementTypeMap, localNillableList, parentSchema); //we know for sure this is not an outer type
            processedElementArrayStatusMap.put(xsElt, isArray);
            if (order) {
                //we need to keep the order of the elements. So push the elements to another
                //hashmap with the order number
                elementOrderMap.put(xsElt, sequenceCounter);
            }

            //handle xsd:any ! We place an OMElement (or an array of OMElements) in the generated class
        } else if (item instanceof XmlSchemaAny) {
            XmlSchemaAny any = (XmlSchemaAny) item;
            processedElementTypeMap.put(new QName(ANY_ELEMENT_FIELD_NAME), any);
            //any can also be inside a sequence
            if (order) {
                elementOrderMap.put(any, new Integer(sequenceCounter));
            }
            //we do not register the array status for the any type
            processedElementArrayStatusMap.put(any, isArray(any));
        } else if (item instanceof XmlSchemaSequence) {
            // we have to process many sequence types

            XmlSchemaSequence xmlSchemaSequence = (XmlSchemaSequence) item;
            if (xmlSchemaSequence.getItems().getCount() > 0) {
                BeanWriterMetaInfoHolder beanWriterMetaInfoHolder = new BeanWriterMetaInfoHolder();
                process(parentElementQName, xmlSchemaSequence.getItems(), beanWriterMetaInfoHolder, true,
                        parentSchema);
                beanWriterMetaInfoHolder.setParticleClass(true);
                String localName = parentElementQName.getLocalPart() + "Sequence";
                QName sequenceQName = new QName(parentElementQName.getNamespaceURI(),
                        localName + getNextTypeSuffix(localName));
                String javaClassName = writeComplexParticle(sequenceQName, beanWriterMetaInfoHolder);
                processedTypemap.put(sequenceQName, javaClassName);

                //put the partical to array
                Boolean isArray = xmlSchemaSequence.getMaxOccurs() > 1 ? Boolean.TRUE : Boolean.FALSE;
                processedElementArrayStatusMap.put(item, isArray);
                particleQNameMap.put(item, sequenceQName);

                if (order) {
                    elementOrderMap.put(item, new Integer(sequenceCounter));
                }
            }

        } else if (item instanceof XmlSchemaChoice) {
            // we have to process many sequence types

            XmlSchemaChoice xmlSchemaChoice = (XmlSchemaChoice) item;
            if (xmlSchemaChoice.getItems().getCount() > 0) {
                BeanWriterMetaInfoHolder beanWriterMetaInfoHolder = new BeanWriterMetaInfoHolder();
                beanWriterMetaInfoHolder.setChoice(true);
                process(parentElementQName, xmlSchemaChoice.getItems(), beanWriterMetaInfoHolder, false,
                        parentSchema);
                beanWriterMetaInfoHolder.setParticleClass(true);
                String localName = parentElementQName.getLocalPart() + "Choice";
                QName choiceQName = new QName(parentElementQName.getNamespaceURI(),
                        localName + getNextTypeSuffix(localName));
                String javaClassName = writeComplexParticle(choiceQName, beanWriterMetaInfoHolder);
                processedTypemap.put(choiceQName, javaClassName);

                //put the partical to array
                Boolean isArray = xmlSchemaChoice.getMaxOccurs() > 1 ? Boolean.TRUE : Boolean.FALSE;
                processedElementArrayStatusMap.put(item, isArray);
                particleQNameMap.put(item, choiceQName);

                if (order) {
                    elementOrderMap.put(item, new Integer(sequenceCounter));
                }
            }

        } else if (item instanceof XmlSchemaGroupRef) {

            XmlSchemaGroupRef xmlSchemaGroupRef = (XmlSchemaGroupRef) item;
            QName groupQName = xmlSchemaGroupRef.getRefName();
            if (groupQName != null) {
                if (!processedGroupTypeMap.containsKey(groupQName)) {
                    // processe the schema here
                    XmlSchema resolvedParentSchema = getParentSchema(parentSchema, groupQName, COMPONENT_GROUP);
                    if (resolvedParentSchema == null) {
                        throw new SchemaCompilationException("Can not find the group with the qname"
                                + groupQName + " from the parent schema " + parentSchema.getTargetNamespace());
                    } else {
                        XmlSchemaGroup xmlSchemaGroup = (XmlSchemaGroup) resolvedParentSchema.getGroups()
                                .getItem(groupQName);
                        if (xmlSchemaGroup != null) {
                            processGroup(xmlSchemaGroup, groupQName, resolvedParentSchema);
                        }
                    }
                }

                Boolean isArray = xmlSchemaGroupRef.getMaxOccurs() > 1 ? Boolean.TRUE : Boolean.FALSE;
                processedElementArrayStatusMap.put(item, isArray);
                particleQNameMap.put(item, groupQName);

                if (order) {
                    elementOrderMap.put(item, new Integer(sequenceCounter));
                }

            } else {
                throw new SchemaCompilationException("Referenced name is null");
            }
        } else {
            //there may be other types to be handled here. Add them
            //when we are ready
        }
        sequenceCounter++;
    }

    // loop through the processed items and add them to the matainf object
    int startingItemNumberOrder = metainfHolder.getOrderStartPoint();
    for (XmlSchemaObject child : processedElementArrayStatusMap.keySet()) {

        // process the XmlSchemaElement
        if (child instanceof XmlSchemaElement) {
            XmlSchemaElement elt = (XmlSchemaElement) child;
            QName referencedQName = null;

            if (elt.getQName() != null) {
                referencedQName = elt.getQName();
                QName schemaTypeQName = elt.getSchemaType() != null ? elt.getSchemaType().getQName()
                        : elt.getSchemaTypeName();
                if (schemaTypeQName != null) {
                    String clazzName = (String) processedElementTypeMap.get(elt.getQName());
                    metainfHolder.registerMapping(referencedQName, schemaTypeQName, clazzName,
                            processedElementArrayStatusMap.get(elt) ? SchemaConstants.ARRAY_TYPE
                                    : SchemaConstants.ELEMENT_TYPE);
                    if (innerChoiceElementList.contains(referencedQName)) {
                        metainfHolder.addtStatus(referencedQName, SchemaConstants.INNER_CHOICE_ELEMENT);
                    }
                    // register the default value as well
                    if (elt.getDefaultValue() != null) {
                        metainfHolder.registerDefaultValue(referencedQName, elt.getDefaultValue());
                    }

                }
            }

            if (elt.getRefName() != null) { //probably this is referenced
                referencedQName = elt.getRefName();
                boolean arrayStatus = processedElementArrayStatusMap.get(elt);
                String clazzName = findRefClassName(referencedQName, arrayStatus);
                if (clazzName == null) {
                    clazzName = findClassName(referencedQName, arrayStatus);
                }
                XmlSchema resolvedParentSchema = getParentSchema(parentSchema, referencedQName,
                        COMPONENT_ELEMENT);
                if (resolvedParentSchema == null) {
                    throw new SchemaCompilationException("Can not find the element " + referencedQName
                            + " from the parent schema " + parentSchema.getTargetNamespace());
                } else {
                    XmlSchemaElement refElement = resolvedParentSchema.getElementByName(referencedQName);

                    // register the mapping if we found the referenced element
                    // else throw an exception
                    if (refElement != null) {
                        metainfHolder.registerMapping(referencedQName, refElement.getSchemaTypeName(),
                                clazzName,
                                arrayStatus ? SchemaConstants.ARRAY_TYPE : SchemaConstants.ELEMENT_TYPE);
                    } else {
                        if (referencedQName.equals(SchemaConstants.XSD_SCHEMA)) {
                            metainfHolder.registerMapping(referencedQName, null, writer.getDefaultClassName(),
                                    SchemaConstants.ANY_TYPE);
                        } else {
                            throw new SchemaCompilationException(SchemaCompilerMessages.getMessage(
                                    "schema.referencedElementNotFound", referencedQName.toString()));
                        }
                    }
                }
            }

            if (referencedQName == null) {
                throw new SchemaCompilationException(SchemaCompilerMessages.getMessage("schema.emptyName"));
            }

            //register the occurence counts
            metainfHolder.addMaxOccurs(referencedQName, elt.getMaxOccurs());
            // if the strict validation off then we consider all elements have minOccurs zero on it
            if (this.options.isOffStrictValidation()) {
                metainfHolder.addMinOccurs(referencedQName, 0);
            } else {
                metainfHolder.addMinOccurs(referencedQName, elt.getMinOccurs());
            }
            //we need the order to be preserved. So record the order also
            if (order) {
                //record the order in the metainf holder
                metainfHolder.registerQNameIndex(referencedQName,
                        startingItemNumberOrder + elementOrderMap.get(elt));
            }

            //get the nillable state and register that on the metainf holder
            if (localNillableList.contains(elt.getQName())) {
                metainfHolder.registerNillableQName(elt.getQName());
            }

            //get the binary state and add that to the status map
            if (isBinary(elt)) {
                metainfHolder.addtStatus(elt.getQName(), SchemaConstants.BINARY_TYPE);
            }
            // process the XMLSchemaAny
        } else if (child instanceof XmlSchemaAny) {
            XmlSchemaAny any = (XmlSchemaAny) child;

            //since there is only one element here it does not matter
            //for the constant. However the problem occurs if the users
            //uses the same name for an element decalration
            QName anyElementFieldName = new QName(ANY_ELEMENT_FIELD_NAME);

            //this can be an array or a single element
            boolean isArray = processedElementArrayStatusMap.get(any);
            metainfHolder.registerMapping(anyElementFieldName, null,
                    isArray ? writer.getDefaultClassArrayName() : writer.getDefaultClassName(),
                    SchemaConstants.ANY_TYPE);
            //if it's an array register an extra status flag with the system
            if (isArray) {
                metainfHolder.addtStatus(anyElementFieldName, SchemaConstants.ARRAY_TYPE);
            }
            metainfHolder.addMaxOccurs(anyElementFieldName, any.getMaxOccurs());
            metainfHolder.addMinOccurs(anyElementFieldName, any.getMinOccurs());

            if (order) {
                //record the order in the metainf holder for the any
                metainfHolder.registerQNameIndex(anyElementFieldName,
                        startingItemNumberOrder + elementOrderMap.get(any));
            }
        } else if (child instanceof XmlSchemaSequence) {
            XmlSchemaSequence xmlSchemaSequence = (XmlSchemaSequence) child;
            QName sequenceQName = particleQNameMap.get(child);
            boolean isArray = xmlSchemaSequence.getMaxOccurs() > 1;

            // add this as an array to the original class
            metainfHolder.registerMapping(sequenceQName, sequenceQName, findClassName(sequenceQName, isArray));
            if (isArray) {
                metainfHolder.addtStatus(sequenceQName, SchemaConstants.ARRAY_TYPE);
            }
            metainfHolder.addtStatus(sequenceQName, SchemaConstants.PARTICLE_TYPE_ELEMENT);
            metainfHolder.addMaxOccurs(sequenceQName, xmlSchemaSequence.getMaxOccurs());
            metainfHolder.addMinOccurs(sequenceQName, xmlSchemaSequence.getMinOccurs());
            metainfHolder.setHasParticleType(true);

            if (order) {
                //record the order in the metainf holder for the any
                metainfHolder.registerQNameIndex(sequenceQName,
                        startingItemNumberOrder + elementOrderMap.get(child));
            }
        } else if (child instanceof XmlSchemaChoice) {
            XmlSchemaChoice xmlSchemaChoice = (XmlSchemaChoice) child;
            QName choiceQName = particleQNameMap.get(child);
            boolean isArray = xmlSchemaChoice.getMaxOccurs() > 1;

            // add this as an array to the original class
            metainfHolder.registerMapping(choiceQName, choiceQName, findClassName(choiceQName, isArray));
            if (isArray) {
                metainfHolder.addtStatus(choiceQName, SchemaConstants.ARRAY_TYPE);
            }
            metainfHolder.addtStatus(choiceQName, SchemaConstants.PARTICLE_TYPE_ELEMENT);
            metainfHolder.addMaxOccurs(choiceQName, xmlSchemaChoice.getMaxOccurs());
            metainfHolder.addMinOccurs(choiceQName, xmlSchemaChoice.getMinOccurs());
            metainfHolder.setHasParticleType(true);

            if (order) {
                //record the order in the metainf holder for the any
                metainfHolder.registerQNameIndex(choiceQName,
                        startingItemNumberOrder + elementOrderMap.get(child));
            }
        } else if (child instanceof XmlSchemaGroupRef) {
            XmlSchemaGroupRef xmlSchemaGroupRef = (XmlSchemaGroupRef) child;
            QName groupQName = particleQNameMap.get(child);
            boolean isArray = xmlSchemaGroupRef.getMaxOccurs() > 1;

            // add this as an array to the original class
            String groupClassName = processedGroupTypeMap.get(groupQName);
            if (isArray) {
                groupClassName = groupClassName + "[]";
            }
            metainfHolder.registerMapping(groupQName, groupQName, groupClassName);
            if (isArray) {
                metainfHolder.addtStatus(groupQName, SchemaConstants.ARRAY_TYPE);
            }
            metainfHolder.addtStatus(groupQName, SchemaConstants.PARTICLE_TYPE_ELEMENT);
            metainfHolder.addMaxOccurs(groupQName, xmlSchemaGroupRef.getMaxOccurs());
            metainfHolder.addMinOccurs(groupQName, xmlSchemaGroupRef.getMinOccurs());
            metainfHolder.setHasParticleType(true);

            if (order) {
                //record the order in the metainf holder for the any
                metainfHolder.registerQNameIndex(groupQName,
                        startingItemNumberOrder + elementOrderMap.get(child));
            }
        }
    }

    //set the ordered flag in the metainf holder
    metainfHolder.setOrdered(order);
}

From source file:org.apache.axis2.schema.writer.JavaBeanWriter.java

/**
 * @param metainf//from w  w w  .j  a va 2 s  .  c om
 * @param model
 * @param rootElt
 * @param propertyNames
 * @param typeMap
 * @throws SchemaCompilationException
 */
private void addPropertyEntries(BeanWriterMetaInfoHolder metainf, Document model, Element rootElt,
        ArrayList<String> propertyNames, Map<QName, String> typeMap, Map<QName, String> groupTypeMap,
        boolean isInherited) throws SchemaCompilationException {
    // go in the loop and add the part elements
    QName[] qName;
    String javaClassNameForElement;
    ArrayList<QName> missingQNames = new ArrayList<QName>();
    ArrayList<QName> qNames = new ArrayList<QName>();

    BeanWriterMetaInfoHolder parentMetaInf = metainf.getParent();

    if (metainf.isOrdered()) {
        qName = metainf.getOrderedQNameArray();
    } else {
        qName = metainf.getQNameArray();
    }

    for (int i = 0; i < qName.length; i++) {
        qNames.add(qName[i]);
    }

    //adding missing QNames to the end, including elements & attributes.
    // for the simple types we have already add the parent elements
    // it is almost consider as an extension
    if (metainf.isRestriction() && !metainf.isSimple()) {
        addMissingQNames(metainf, qNames, missingQNames);
    }

    List<BeanWriterMetaInfoHolder> parents = new ArrayList<BeanWriterMetaInfoHolder>();
    BeanWriterMetaInfoHolder immediateParent = metainf.getParent();
    while (immediateParent != null) {
        parents.add(immediateParent);
        immediateParent = immediateParent.getParent();
    }

    for (QName name : qNames) {
        Element property = XSLTUtils.addChildElement(model, "property", rootElt);

        String xmlName = name.getLocalPart();

        String xmlNameNew = identifyUniqueNameForQName(parents, xmlName, metainf, name, name);
        while (!xmlName.equalsIgnoreCase(xmlNameNew)) {
            xmlName = xmlNameNew;
            xmlNameNew = identifyUniqueNameForQName(parents, xmlNameNew, metainf, name, new QName(xmlNameNew));
        }

        XSLTUtils.addAttribute(model, "name", xmlName, property);
        XSLTUtils.addAttribute(model, "nsuri", name.getNamespaceURI(), property);

        String javaName;
        if (metainf.isJavaNameMappingAvailable(xmlName)) {
            javaName = metainf.getJavaName(xmlName);
        } else {
            javaName = makeUniqueJavaClassName(propertyNames, xmlName);
            // in a restriction if this element already there and array status have changed
            // then we have to generate a new  name for this
            if (parentMetaInf != null && metainf.isRestriction() && !missingQNames.contains(name)
                    && (parentMetaInf.getArrayStatusForQName(name) && !metainf.getArrayStatusForQName(name))) {
                javaName = makeUniqueJavaClassName(propertyNames, xmlName);
            }
            metainf.addXmlNameJavaNameMapping(xmlName, javaName);
        }

        XSLTUtils.addAttribute(model, "javaname", javaName, property);

        if (parentMetaInf != null && metainf.isRestriction() && missingQNames.contains(name)) {
            javaClassNameForElement = parentMetaInf.getClassNameForQName(name);
        } else {
            javaClassNameForElement = metainf.getClassNameForQName(name);
        }

        if (javaClassNameForElement == null) {
            javaClassNameForElement = getDefaultClassName();
            log.warn(SchemaCompilerMessages.getMessage("schema.typeMissing", name.toString()));
        }

        if (metainf.isRestriction() && typeChanged(name, missingQNames, metainf)) {
            XSLTUtils.addAttribute(model, "typeChanged", "yes", property);
            //XSLTUtils.addAttribute(model, "restricted", "yes", property);
        }

        long minOccurs = metainf.getMinOccurs(name);
        if (PrimitiveTypeFinder.isPrimitive(javaClassNameForElement) && isUseWrapperClasses
                && ((minOccurs == 0) || metainf.isNillable(name))) {
            // if this is an primitive class and user wants to use the
            // wrapper type we change the type to wrapper type.
            javaClassNameForElement = PrimitiveTypeWrapper.getWrapper(javaClassNameForElement);
        }

        XSLTUtils.addAttribute(model, "type", javaClassNameForElement, property);

        if (PrimitiveTypeFinder.isPrimitive(javaClassNameForElement)) {

            XSLTUtils.addAttribute(model, "primitive", "yes", property);
        }

        // add the default value
        if (metainf.isDefaultValueAvailable(name)) {
            QName schemaQName = metainf.getSchemaQNameForQName(name);
            if (baseTypeMap.containsKey(schemaQName)) {
                XSLTUtils.addAttribute(model, "defaultValue", metainf.getDefaultValueForQName(name), property);
            }
        }

        //in the case the original element is an array but the derived one is not.
        if (parentMetaInf != null && metainf.isRestriction() && !missingQNames.contains(name)
                && (parentMetaInf.getArrayStatusForQName(name) && !metainf.getArrayStatusForQName(name))) {

            XSLTUtils.addAttribute(model, "rewrite", "yes", property);
            XSLTUtils.addAttribute(model, "occuranceChanged", "yes", property);
        } else if (metainf.isRestriction() && !missingQNames.contains(name)
                && (minOccursChanged(name, missingQNames, metainf)
                        || maxOccursChanged(name, missingQNames, metainf))) {

            XSLTUtils.addAttribute(model, "restricted", "yes", property);
            XSLTUtils.addAttribute(model, "occuranceChanged", "yes", property);
        }

        // set the is particle class
        if (metainf.getParticleTypeStatusForQName(name)) {
            XSLTUtils.addAttribute(model, "particleClassType", "yes", property);
        }

        // if we have an particle class in a extension class then we have
        // to consider the whole class has a particle type.

        if (metainf.isHasParticleType()) {
            XSLTUtils.addAttribute(model, "hasParticleType", "yes", rootElt);
        }

        // what happed if this contain attributes
        // TODO: check the meaning of this removed property

        if (metainf.isRestriction() && missingQNames.contains(name) && !metainf.isSimple()) {
            //XSLTUtils.addAttribute(model, "restricted", "yes", property);
            XSLTUtils.addAttribute(model, "removed", "yes", property);
        }

        if (isInherited) {
            XSLTUtils.addAttribute(model, "inherited", "yes", property);
        }

        if (metainf.getInnerChoiceStatusForQName(name)) {
            XSLTUtils.addAttribute(model, "innerchoice", "yes", property);
        }

        if ((parentMetaInf != null) && metainf.isRestriction() && missingQNames.contains(name)) {
            // this element details should be there with the parent meta Inf
            addAttributesToProperty(parentMetaInf, name, model, property, typeMap, groupTypeMap,
                    javaClassNameForElement);

        } else {
            addAttributesToProperty(metainf, name, model, property, typeMap, groupTypeMap,
                    javaClassNameForElement);
        }
    } // end of foo
}

From source file:org.apache.camel.component.cxf.CxfProducer.java

/**
 * Get operation name from header and use it to lookup and return a 
 * {@link BindingOperationInfo}.// ww w. j a  v  a 2s  . c  om
 */
private BindingOperationInfo getBindingOperationInfo(Exchange ex) {
    CxfEndpoint endpoint = (CxfEndpoint) this.getEndpoint();
    BindingOperationInfo answer = null;
    String lp = ex.getIn().getHeader(CxfConstants.OPERATION_NAME, String.class);
    if (lp == null) {
        lp = endpoint.getDefaultOperationName();
    }
    if (lp == null) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Try to find a default operation.  You should set '" + CxfConstants.OPERATION_NAME
                    + "' in header.");
        }
        Collection<BindingOperationInfo> bois = client.getEndpoint().getEndpointInfo().getBinding()
                .getOperations();

        Iterator<BindingOperationInfo> iter = bois.iterator();
        if (iter.hasNext()) {
            answer = iter.next();
        }

    } else {
        String ns = ex.getIn().getHeader(CxfConstants.OPERATION_NAMESPACE, String.class);
        if (ns == null) {
            ns = endpoint.getDefaultOperationNamespace();
        }
        if (ns == null) {
            ns = client.getEndpoint().getService().getName().getNamespaceURI();
            if (LOG.isTraceEnabled()) {
                LOG.trace("Operation namespace not in header.  Set it to: " + ns);
            }
        }

        QName qname = new QName(ns, lp);

        if (LOG.isTraceEnabled()) {
            LOG.trace("Operation qname = " + qname.toString());
        }

        answer = client.getEndpoint().getEndpointInfo().getBinding().getOperation(qname);
    }
    return answer;
}

From source file:org.apache.hise.utils.XQueryEvaluator.java

public List evaluateExpression(String expr, org.w3c.dom.Node contextNode) {
    try {//w w  w .  ja  v a2 s .  com
        contextObjectTL.set(contextObject);
        {
            FunctionLibraryList fll = new FunctionLibraryList();
            fll.addFunctionLibrary(jel);
            config.setExtensionBinder("java", fll);
        }

        StaticQueryContext sqc = new StaticQueryContext(config);
        for (Map.Entry<String, String> namespace : namespaces.entrySet()) {
            sqc.declareNamespace(namespace.getKey(), namespace.getValue());
        }
        for (QName var : vars.keySet()) {
            sqc.declareGlobalVariable(StructuredQName.fromClarkName(var.toString()), SequenceType.SINGLE_ITEM,
                    convertJavaToSaxon(vars.get(var)), false);
        }
        DynamicQueryContext dqc = new DynamicQueryContext(config);
        XQueryExpression e = sqc.compileQuery(expr);

        if (contextNode != null) {
            if (!(contextNode instanceof Document || contextNode instanceof DocumentFragment)) {
                try {
                    contextNode = DOMUtils.parse(DOMUtils.domToString(contextNode));
                } catch (Exception e1) {
                    throw new RuntimeException("", e1);
                }
                //                    DocumentFragment frag = contextNode.getOwnerDocument().createDocumentFragment();
                //                    frag.appendChild(contextNode);
                //                    contextNode = frag;
            }
            dqc.setContextItem(new DocumentWrapper(contextNode, "", config));
        }

        List value = e.evaluate(dqc);
        List value2 = new ArrayList();
        for (Object o : value) {
            Object o2 = o;
            if (o2 instanceof NodeInfo) {
                try {
                    Node o3 = DOMUtils.parse(DOMUtils.domToString(NodeOverNodeInfo.wrap((NodeInfo) o2)))
                            .getDocumentElement();
                    o2 = o3;
                } catch (Exception e1) {
                    throw new RuntimeException("Error converting result", e1);
                }
            }
            //                o2 = JavaDOMWrapper.unwrap(o2);
            value2.add(o2);
        }
        __log.debug("result for expression " + expr + " " + value2 + " value class "
                + (value2 == null ? null : value2.getClass()));
        return value2;
    } catch (XPathException e) {
        __log.error("Expression: \n" + expr, e);
        throw new RuntimeException(e);
    } finally {
        contextObjectTL.set(null);
    }
}

From source file:org.apache.ode.bpel.engine.BpelEngineImpl.java

private List<BpelProcess> getAllProcesses(QName processId) {
    String qName = processId.toString();
    if (qName.lastIndexOf("-") > 0) {
        qName = qName.substring(0, qName.lastIndexOf("-"));
    }/*from  w  ww . j av a  2s . c o  m*/
    List<BpelProcess> ret = new ArrayList<BpelProcess>();
    Iterator<Map.Entry<QName, BpelProcess>> it = _activeProcesses.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry<QName, BpelProcess> pairs = it.next();
        if (pairs.getKey().toString().startsWith(qName)) {
            ret.add(pairs.getValue());
        }
    }
    return ret;
}

From source file:org.apache.ode.dao.jpa.bpel.BpelDAOConnectionImpl.java

@SuppressWarnings("unchecked")
public ProcessDAO getProcess(QName processId) {
    _txCtx.begin();/* ww  w  .ja  va2 s  .  c o  m*/
    List l = _em.createQuery("select x from ProcessDAOImpl x where x._processId = ?1")
            .setParameter(1, processId.toString()).getResultList();
    _txCtx.commit();
    if (l.size() == 0)
        return null;
    ProcessDAOImpl p = (ProcessDAOImpl) l.get(0);
    return p;
}

From source file:org.apache.ode.dao.jpa.bpel.MessageDAOImpl.java

public MessageDAOImpl(QName type, MessageExchangeDAOImpl me) {
    _type = type.toString();
    _messageExchange = me;
}

From source file:org.apache.ode.dao.jpa.bpel.MessageDAOImpl.java

public void setType(QName type) {
    _type = type.toString();
}

From source file:org.apache.ode.dao.jpa.bpel.MessageExchangeDAOImpl.java

public void setCallee(QName callee) {
    _callee = callee.toString();
}