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.ow2.petals.binding.soapproxy.SoapComponentContext.java

/**
 * <p>//from   w  ww . ja  v a  2s  .co m
 * Get a service client associated to an axis service set with the good
 * operation. It is taken from a pool object.
 * </p>
 * <p>
 * <b>This service client must be returned to the pool after usage using
 * API:
 * <code>{@link #returnServiceClient(String, QName, URI, ServiceClient)}</code>
 * .</b>
 * </p>
 * 
 * @param address
 *            the address of the service, mainly used as key to retrieve the
 *            associated SU.
 * @param operation
 *            the target operation QName. Non null
 * @param mep
 *            the message exchange pattern used. Non null
 * @param cdkExtensions
 *            SU extensions used by the service client pool when the
 *            creation of a service client is needed
 * @param provides
 *            the provides block of the endpoint which is creating the
 *            external WS call
 * @param ramprtUserName
 * @return a ServiceClient. Not null. Must be returned to the pool after
 *         usage using API:
 *         <code>{@link #returnServiceClient(String, QName, URI, ServiceClient)}</code>
 * @throws HandlingException
 */
public ServiceClient borrowServiceClient(final String address, final QName operation, final String soapAction,
        final URI mep) throws MessagingException {

    try {

        String resolvedOp;
        if (operation != null) {
            resolvedOp = operation.toString();
        } else if (soapAction != null) {
            resolvedOp = soapAction;
        } else {
            throw new MessagingException(
                    "Unable to resolve the operation. Set it in the Jbi exchange or SoapAction.");
        }

        final ServiceClientKey key = new ServiceClientKey(address, resolvedOp, mep);
        ObjectPool pool = this.serviceClientPools.get(key);
        if (pool == null) {
            // TODO: The pool max size should be limited by the JBI worker
            // number
            pool = new GenericObjectPool(
                    // object factory
                    new ServiceClientPoolObjectFactory(address, operation, mep, this, this.logger, soapAction),

                    // max number of borrowed object sized to the number of
                    // JBI message processors
                    this.componentConfiguration.getProcessorPoolSize().getValue(),

                    // getting an object blocks until a new or idle object
                    // is available
                    GenericObjectPool.WHEN_EXHAUSTED_BLOCK,

                    // if getting an object is blocked for at most this
                    // delay, a NoSuchElementException will be thrown. In
                    // case of a synchronous call the delay is sized to the
                    // value of the SU's parameter "synchronous-timeout",
                    // otherwise it sized to 5 minutes.
                    MEPConstants.IN_OUT_PATTERN.equals(mep) || MEPConstants.IN_OPTIONAL_OUT_PATTERN.equals(mep)
                            ? 300000l
                            : 300000l,

                    // max number of idle object in the pool. Sized to the
                    // number of JBI acceptors.
                    this.componentConfiguration.getAcceptorPoolSize().getValue(),

                    // min number of idle object in the pool. Sized to 0
                    // (ie when no activity no object in pool)
                    GenericObjectPool.DEFAULT_MIN_IDLE,

                    // no validation test of the borrowed object
                    false,

                    // no validation test of the returned object
                    false,

                    // how long the eviction thread should sleep before
                    // "runs" of examining idle objects. Sized to 5min.
                    300000l,

                    // the number of objects examined in each run of the
                    // idle object evictor. Size to the default value (ie.
                    // 3)
                    GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,

                    // the minimum amount of time that an object may sit
                    // idle in the pool before it is eligible for eviction
                    // due to idle time. Sized to 30min
                    GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,

                    // no validation test of the idle object
                    false,

                    // the minimum amount of time an object may sit idle in
                    // the pool before it is eligible for eviction by the
                    // idle object evictor (if any), with the extra
                    // condition that at least "minIdle" amount of object
                    // remain in the pool.
                    GenericObjectPool.DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS,

                    // the pool returns idle objects in last-in-first-out
                    // order
                    true);

            this.serviceClientPools.put(key, pool);
        }

        return (ServiceClient) pool.borrowObject();

    } catch (final Exception e) {
        throw new MessagingException("Can't create get an Axis service client from the pool", e);
    }
}

From source file:org.petalslink.dsb.kernel.registry.BaseEndpointRegistry.java

protected String getKey(final String epName, final QName serviceName) {
    String rootPath = this.getRootPath();
    if ((rootPath == null) || (rootPath.trim().length() == 0)) {
        rootPath = "/";
    }/*from w w  w  .  j  a v a  2s.  c o m*/

    if (!rootPath.endsWith("/")) {
        rootPath = rootPath + "/";
    }
    return rootPath + serviceName.toString() + "@" + epName;
}

From source file:org.plasma.provisioning.xsd.ConverterSupport.java

public String findOpenAttributeValue(QName qname, OpenAttrs attrs, boolean supressError) {
    Iterator<QName> iter = attrs.getOtherAttributes().keySet().iterator();
    while (iter.hasNext()) {
        QName key = iter.next();/*from w ww . j a  va 2  s.  co m*/
        if (key.equals(qname)) {
            String result = attrs.getOtherAttributes().get(key);
            return result;
        }
    }
    if (!supressError)
        throw new IllegalArgumentException("attribute '" + qname.toString() + "' not found");
    return null;
}

From source file:org.plasma.provisioning.xsd.PropertyAssembler.java

/**
 * Creates non-reference property definitions. 
 * @param clss the owner class//from www. j a va  2s  . co m
 * @param complexType the Schema Complex Type
 * @param attribute the Schema Attribute
 * @return the property definition
 */
public Property buildDatatypeProperty(Class clss, AbstractComplexType complexType, Attribute attribute) {
    if (attribute.getName() == null || attribute.getName().trim().length() == 0)
        throw new IllegalStateException(
                "expected name for attribute while processing class, " + clss.getName());
    Property property = new Property();
    property.setId(UUID.randomUUID().toString());
    // set property names and aliases
    Alias alias = new Alias();
    property.setAlias(alias);
    setupNames(clss, property, alias, attribute.getName(), attribute.getName());
    XmlProperty xmlProp = new XmlProperty();
    xmlProp.setNodeType(XmlNodeType.ATTRIBUTE);
    property.setXmlProperty(xmlProp);

    Documentation documentation = new Documentation();
    documentation.setType(DocumentationType.DEFINITION);
    Body body = new Body();
    body.setValue(getDocumentationContent(attribute));
    documentation.setBody(body);
    property.getDocumentations().add(documentation);

    property.setVisibility(VisibilityType.PUBLIC); // FIXME

    // nullable
    if ("required".equals(attribute.getUse()))
        property.setNullable(false);
    else
        property.setNullable(true);

    // multiplicity
    property.setMany(false); // unless the type defined as a list below

    QName typeQName = attribute.getType();

    // if local restriction will not have a simple type
    ConstraintAssembler constraintAssembler = new ConstraintAssembler(this.support, this.destNamespaceURI,
            this.destNamespacePrefix);
    if (typeQName == null) {
        LocalSimpleType lst = attribute.getSimpleType();
        Restriction rest = lst.getRestriction();
        if (rest != null) {
            ValueConstraint constraint = constraintAssembler.buildValueConstraint(rest);
            property.setValueConstraint(constraint);
        }
    } else {
        if (typeQName.getNamespaceURI() != null
                && typeQName.getNamespaceURI().equals(this.support.getSchema().getTargetNamespace())) {
            SimpleType simpleType = this.support.getSimpleTypeMap().get(typeQName.getLocalPart());
            collect(clss, property, simpleType, constraintAssembler);
        } else if (typeQName.getNamespaceURI().equals(SchemaConstants.XMLSCHEMA_NAMESPACE_URI)) {
            buildDataTypeReference(property, typeQName);
        } else
            log.warn("could not process namespace URI found for type, " + typeQName.toString());
    }

    if (property.getType() == null) {
        DataType sdoType = this.support.mapType(XSDBuiltInType.xsd_string);
        DataTypeRef dataTypeRef = new DataTypeRef();
        dataTypeRef.setName(sdoType.name());
        dataTypeRef.setUri(PlasmaConfig.getInstance().getSDODataTypesNamespace().getUri());
        property.setType(dataTypeRef);
    }

    return property;
}

From source file:org.plasma.provisioning.xsd.PropertyAssembler.java

public Property buildElementContentDatatypeProperty(Class clss, QName xsdTypeNameQName) {
    Property property = new Property();
    property.setId(UUID.randomUUID().toString());
    // set property names and aliases
    Alias alias = new Alias();
    property.setAlias(alias);//from  ww w  .j a v  a 2s .co m
    setupNames(clss, property, alias, "value", "value");

    //TODO: how to annotate such that serialization can know
    // this property is an element text value
    XmlProperty xmlProp = new XmlProperty();
    xmlProp.setNodeType(XmlNodeType.ELEMENT);
    property.setXmlProperty(xmlProp);

    Documentation documentation = new Documentation();
    documentation.setType(DocumentationType.DEFINITION);
    Body body = new Body();
    body.setValue("A synthetic property to accommodate simple type, " + xsdTypeNameQName.toString());
    documentation.setBody(body);
    property.getDocumentations().add(documentation);

    property.setVisibility(VisibilityType.PUBLIC); // FIXME

    // nullable
    property.setNullable(false);

    // multiplicity
    property.setMany(false);

    buildDataTypeReference(property, xsdTypeNameQName);

    return property;
}

From source file:org.plasma.provisioning.xsd.PropertyAssembler.java

public void buildDataTypeReference(Property property, QName xsdTypeName) {
    XSDBuiltInType xsdType = null;//ww w .j a  va2s  .co m
    try {
        xsdType = XSDBuiltInType.valueOf("xsd_" + xsdTypeName.getLocalPart());
    } catch (IllegalArgumentException e) {
        throw new IllegalStateException("could not create SDO type from name, " + xsdTypeName.toString());
    }
    DataType sdoType = this.support.mapType(xsdType);
    if (property.getType() != null) {
        DataType existingSdoType = DataType.valueOf(property.getType().getName());
        if (existingSdoType.ordinal() == sdoType.ordinal()) {
            return;
        } else {
            log.warn("property '" + property.getName() + "' has an existing datatype (" + existingSdoType.name()
                    + ") - could not set to comflicting type, " + sdoType.name());
            return;
        }
    }

    DataTypeRef dataTypeRef = new DataTypeRef();
    dataTypeRef.setName(sdoType.name());
    dataTypeRef.setUri(PlasmaConfig.getInstance().getSDODataTypesNamespace().getUri());
    property.setType(dataTypeRef);
}

From source file:org.plasma.sdo.core.CoreType.java

/**
 * Returns the namespace qualified physical name of this Type as a byte array which may be cached
 * or lazily cached on demand, or null if no physical alias name exists. 
 * <p>/*www  . ja va 2 s . c om*/
 * Helps support {@link org.plasma.sdo.access.DataAccessService Data Access Services} for sparse, 
 * distributed "cloud" data stores typically storing lexicographically 
 * ordered row and column keys as uninterpreted arrays of bytes. Fast dynamic
 * construction of such keys is important as such services may necessarily construct
 * unique composite keys based in part on qualified or unqualified logical or physical
 * type names. 
 * </p>
 * @return the namespace qualified physical name of this Type as a byte array, or null if no physical alias name exists.
 */
public byte[] getQualifiedPhysicalNameBytes() {
    if (this.instancePropertiesMap == null)
        this.lazyLoadProperties();
    byte[] result = (byte[]) this.instancePropertiesMap
            .get(PlasmaProperty.INSTANCE_PROPERTY_BYTES_QUALIFIED_PHYSICAL_NAME_BYTES);
    if (result == null) {
        QName qname = getQualifiedPhysicalName();
        if (qname != null) {
            result = qname.toString().getBytes(Charset.forName(CoreConstants.UTF8_ENCODING));
            this.instancePropertiesMap.put(PlasmaProperty.INSTANCE_PROPERTY_BYTES_QUALIFIED_PHYSICAL_NAME_BYTES,
                    result);
        }
    }
    return result;
}

From source file:org.plasma.xml.schema.AbstractSimpleType.java

/**
 * Encapsulates the (breadth-first) /*from   w w w  . j  av a 2  s .co  m*/
 * traversal logic for XSD SimpleType hierarchies
 * across restrictions, lists, unions and other elements,
 * creating "visit" events ala. the Visitor pattern for the
 * given visitor. 
 * @see org.plasma.xml.schema.Restriction
 * @see org.plasma.xml.schema.List
 * @see org.plasma.xml.schema.Union
 */
private void accept(AbstractSimpleType target, AbstractSimpleType source, SimpleTypeVisitor visitor,
        int level) {

    // depth-first visit event
    visitor.visit(target, source, level);

    if (target.getRestriction() != null) {
        Restriction restriction = target.getRestriction();
        QName typeName = restriction.getBase();
        if (typeName != null) {
            if (typeName.getNamespaceURI() != null) {
                if (typeName.getNamespaceURI().equals(visitor.getTargetNamespace())) {
                    SimpleType baseType = visitor.getTopLevelSimpleType(typeName);
                    accept(baseType, target, visitor, level++);
                } else if (typeName.getNamespaceURI().equals(SchemaConstants.XMLSCHEMA_NAMESPACE_URI)) {
                    // leaf
                } else
                    log.warn("could not process namespace URI found for base type, " + typeName.toString());
            } else
                log.warn("could not process (no namespace) base type, " + typeName.toString());
        } else {
            LocalSimpleType localSimpleType = restriction.getSimpleType();
            if (localSimpleType != null) {
                accept(localSimpleType, target, visitor, level++);
            } else
                log.warn("no base type or local type found on restriction for type, " + target.getName());
        }
    } else if (target.getList() != null) {
        org.plasma.xml.schema.List typeList = target.getList();
        if (typeList.getSimpleType() != null)
            log.warn("ignoring local simple type child for simple type, " + target.getName());
        QName typeName = typeList.getItemType();
        if (typeName != null && typeName.getNamespaceURI() != null) {
            if (typeName.getNamespaceURI().equals(visitor.getTargetNamespace())) {
                SimpleType baseType = visitor.getTopLevelSimpleType(typeName);
                accept(baseType, target, visitor, level++);
            } else if (typeName.getNamespaceURI().equals(SchemaConstants.XMLSCHEMA_NAMESPACE_URI)) {
                // leaf
            } else
                log.warn("could not process namespace URI found for type, " + typeName.toString());
        } else
            log.warn("no namespace URI found for type, " + typeName.toString());
    } else if (target.getUnion() != null) {
        Union union = target.getUnion();
        for (QName member : union.getMemberTypes()) {
            SimpleType baseType = visitor.getTopLevelSimpleType(member);
            accept(baseType, target, visitor, level++);
        }

        // process leaf local simple types
        for (LocalSimpleType localBaseType : union.getSimpleTypes()) {
            accept(localBaseType, target, visitor, level++);
        }
    }
}

From source file:org.slc.sli.modeling.wadl.writer.WadlWriter.java

private static final String toLexicalForm(final QName name, final XMLStreamWriter xsw)
        throws XMLStreamException {
    final String namespaceURI = name.getNamespaceURI();
    if (namespaceURI.length() != 0) {
        final String prefix = xsw.getPrefix(namespaceURI);
        if (prefix == null) {
            throw new IllegalArgumentException(name.toString());
        }/*from w w w  . j  a va  2s  . c o m*/
        if (prefix.length() != 0) {
            return prefix.concat(":").concat(name.getLocalPart());
        } else {
            return name.getLocalPart();
        }
    } else {
        return name.getLocalPart();
    }
}

From source file:org.switchyard.rhq.plugin.ApplicationDiscoveryComponent.java

/**
 * Discover existing resources.//from   w w  w.j a  va  2 s  . co m
 * 
 * @param context
 *            The context for the current discovery component.
 * @return The discovered resources.
 */
@Override
public Set<DiscoveredResourceDetails> discoverResources(
        final ResourceDiscoveryContext<SwitchYardResourceComponent> context) {

    final HashSet<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>();

    final SwitchYardResourceComponent parent = context.getParentResourceComponent();

    final Map<String, Application> applications = parent.getApplications();

    if (applications != null) {
        for (Application application : applications.values()) {
            final Configuration pluginConfig = context.getDefaultPluginConfiguration();
            final QName name = application.getName();

            final DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(),
                    name.toString(), name.getLocalPart(), name.getNamespaceURI(), null, pluginConfig, null);

            discoveredResources.add(resource);

            if (LOG.isDebugEnabled()) {
                LOG.debug("Discovered SwitchYard Application " + application);
            }
        }
    }

    return discoveredResources;
}