Package com.caucho.jaxb.property

Examples of com.caucho.jaxb.property.Property


    for (XmlElement element : elements.value()) {
      if (XmlElement.DEFAULT.class.equals(element.type()))
        throw new JAXBException(L.l("@XmlElement annotations in @XmlElements must specify a type"));

      QName qname = qnameFromXmlElement(element);
      Property property = _context.createProperty(element.type());

      qnameToPropertyMap.put(qname, property);
      classToPropertyMap.put(element.type(), property);
      _qnameMap.put(element.type(), qname);

      if (! property.isXmlPrimitiveType())
        _context.createSkeleton(element.type());
    }

    _property = new MultiProperty(qnameToPropertyMap, classToPropertyMap);
View Full Code Here


    throws IOException, XMLStreamException, JAXBException
  {
    ClassSkeleton skeleton = _context.findSkeletonForObject(obj);

    if (skeleton == null) {
      Property property = _context.getSimpleTypeProperty(obj.getClass());

      if (property == null)
        throw new JAXBException(L.l("Unknown class {0}", obj.getClass()));

      property.write(m, out, obj, namer); // XXX attributes
    }
    else
      skeleton.write(m, out, obj, null, attributes);
  }
View Full Code Here

      while (reader.getEventType() != XMLStreamReader.START_ELEMENT)
        reader.next();

      QName name = reader.getName();

      Property property = _context.createProperty(declaredType);

      T val = (T) property.read(this, reader, null);

      return new JAXBElement<T>(name, declaredType, val);
    }
    catch (Exception e) {
      throw new RuntimeException(e);
View Full Code Here

    if (type != null) {
      QName typeQName = StaxUtil.resolveStringToQName(type, in);
      Class cl = JAXBUtil.getClassForDatatype(typeQName);
     
      Property property = _context.createProperty(cl);

      return property.read(u, in, null);
    }
    else {
      DOMResult result = new DOMResult();
      XMLOutputFactory factory = _context.getXMLOutputFactory();
      XMLStreamWriter out = factory.createXMLStreamWriter(result);
View Full Code Here

        skeleton.write(m, out, obj, null, attributes);
        return;
      }

      Property property = _context.getSimpleTypeProperty(obj.getClass());

      if (property != null) {
        XmlInstanceWrapper instanceWrapper =
          XmlInstanceWrapper.getInstance(property.getSchemaType());

        if (attributes == null)
          attributes = new ArrayList<XmlMapping>(1);

        attributes.add(instanceWrapper);

        // XXX the second obj here is a hack: we just need it not to be null.
        // Figure out if the api is wrong or there is a reasonable value for
        // the fifth argument instead of this second obj.
        property.write(m, out, obj, namer, obj, attributes);
        return;
      }

      if (obj instanceof Node) {
        XMLInputFactory factory = _context.getXMLInputFactory();
View Full Code Here

    for (int i = 0; i < skeletons.size(); i++) {
      ClassSkeleton skeleton = skeletons.get(i);
      map.put(skeleton.getElementName(), this);

      QName qname = skeleton.getElementName();
      Property property = _context.createProperty(skeleton.getType());

      qnameToPropertyMap.put(qname, property);
      classToPropertyMap.put(skeleton.getType(), property);
    }
View Full Code Here

      out.writeEmptyElement(XML_SCHEMA_PREFIX,
                            "element",
                            W3C_XML_SCHEMA_NS_URI);
      out.writeAttribute("name", _operationName);

      Property property = _bodyArgs[_inputArgument].getProperty();
      String type = StaxUtil.qnameToString(out, property.getSchemaType());

      out.writeAttribute("type", type);
    }

    if (_returnMarshal != null) {
View Full Code Here

      if (name == null)
        name = new QName(localName);

      Type type = JAXBUtil.getActualParameterType(genericParams[i]);
      Property property = _jaxbContext.createProperty(type, true);

      ParameterMarshal pMarshal
        = ParameterMarshal.create(i, property, name, mode,
                                  marshaller, unmarshaller);

      if (isHeader) {
        if (pMarshal instanceof InParameterMarshal)
          _headerInputs++;
        else if (pMarshal instanceof OutParameterMarshal)
          _headerOutputs++;
        else {
          _headerInputs++;
          _headerOutputs++;
        }

        headerList.add(pMarshal);
        _headerArguments.put(localName, pMarshal);
      }
      else if (isAttachment) {
        if (! (property instanceof AttachmentProperty))
          throw new WebServiceException(L.l("Argument {0} of method {1} is of type {2}: Attachment argument types must map to base64Binary", i, method.getName(), params[i]));

        if (pMarshal instanceof InParameterMarshal)
          _attachmentInputs++;
        else if (pMarshal instanceof OutParameterMarshal)
          _attachmentOutputs++;
        else {
          _attachmentInputs++;
          _attachmentOutputs++;
        }

        attachmentList.add(pMarshal);
        _attachmentArguments.put(localName, pMarshal);
      }
      else {
        if (pMarshal instanceof InParameterMarshal)
          _bodyInputs++;
        else if (pMarshal instanceof OutParameterMarshal)
          _bodyOutputs++;
        else {
          _bodyInputs++;
          _bodyOutputs++;
        }

        bodyList.add(pMarshal);
        _bodyArguments.put(localName, pMarshal);
      }
    }

    _attachmentArgs = new ParameterMarshal[attachmentList.size()];
    attachmentList.toArray(_attachmentArgs);

    _headerArgs = new ParameterMarshal[headerList.size()];
    headerList.toArray(_headerArgs);

    _bodyArgs = new ParameterMarshal[bodyList.size()];
    bodyList.toArray(_bodyArgs);

    //
    // Return type
    //

    if (! Void.TYPE.equals(method.getReturnType())) {
      if (_isOneway)
        throw new WebServiceException(L.l("Method {0} annotated with @Oneway, but has non-void return", method.getName()));

      Property property =
        _jaxbContext.createProperty(method.getGenericReturnType());

      WebResult webResult = method.getAnnotation(WebResult.class);

      if (webResult == null && eiMethod != null)
        webResult = eiMethod.getAnnotation(WebResult.class);

      if (webResult != null) {
        _headerReturn = webResult.header();

        String localName = webResult.name();

        if ("".equals(localName))
          localName = "return";

        if ("".equals(webResult.targetNamespace()))
          _resultName = new QName(localName);
        else
          _resultName = new QName(webResult.targetNamespace(), localName);
      }
      else {
        _headerReturn = false;
        _resultName = new QName("return"); // XXX namespace?
      }

      _returnMarshal = ParameterMarshal.create(0, property, _resultName,
                                               WebParam.Mode.OUT,
                                               marshaller, unmarshaller);

      _bodyOutputs++;

      if (_headerReturn)
        _headerOutputs++;
    }
    else {
      _headerReturn = false;
      _returnMarshal = null;
    }

    //
    // Exceptions
    //

    Class[] exceptions = method.getExceptionTypes();

    for (Class exception : exceptions) {
      QName faultName = new QName(targetNamespace,
                                  exception.getSimpleName(),
                                  TARGET_NAMESPACE_PREFIX);
      // XXX check for generated exception classes versus raw exceptions
      // i.e. things like getFaultInfo()
      Property property = jaxbContext.createProperty(exception);
      ParameterMarshal marshal =
        ParameterMarshal.create(0, property, faultName,
                                WebParam.Mode.OUT,
                                marshaller, unmarshaller);
View Full Code Here

      out.writeEmptyElement(XML_SCHEMA_PREFIX,
                            "element",
                            W3C_XML_SCHEMA_NS_URI);
      out.writeAttribute("name", _operationName);

      Property property = _bodyArgs[_inputArgument].getProperty();
      String type = StaxUtil.qnameToString(out, property.getSchemaType());

      out.writeAttribute("type", type);
    }

    if (_returnMarshal != null) {
View Full Code Here

      if (name == null)
        name = new QName(localName);

      Type type = JAXBUtil.getActualParameterType(genericParams[i]);
      Property property = _jaxbContext.createProperty(type, true);

      ParameterMarshal pMarshal
        = ParameterMarshal.create(i, property, name, mode,
                                  marshaller, unmarshaller);

      if (isHeader) {
        if (pMarshal instanceof InParameterMarshal)
          _headerInputs++;
        else if (pMarshal instanceof OutParameterMarshal)
          _headerOutputs++;
        else {
          _headerInputs++;
          _headerOutputs++;
        }

        headerList.add(pMarshal);
        _headerArguments.put(localName, pMarshal);
      }
      else if (isAttachment) {
        if (! (property instanceof AttachmentProperty))
          throw new WebServiceException(L.l("Argument {0} of method {1} is of type {2}: Attachment argument types must map to base64Binary", i, method.getName(), params[i]));

        if (pMarshal instanceof InParameterMarshal)
          _attachmentInputs++;
        else if (pMarshal instanceof OutParameterMarshal)
          _attachmentOutputs++;
        else {
          _attachmentInputs++;
          _attachmentOutputs++;
        }

        attachmentList.add(pMarshal);
        _attachmentArguments.put(localName, pMarshal);
      }
      else {
        if (pMarshal instanceof InParameterMarshal)
          _bodyInputs++;
        else if (pMarshal instanceof OutParameterMarshal)
          _bodyOutputs++;
        else {
          _bodyInputs++;
          _bodyOutputs++;
        }

        bodyList.add(pMarshal);
        _bodyArguments.put(localName, pMarshal);
      }
    }

    _attachmentArgs = new ParameterMarshal[attachmentList.size()];
    attachmentList.toArray(_attachmentArgs);

    _headerArgs = new ParameterMarshal[headerList.size()];
    headerList.toArray(_headerArgs);

    _bodyArgs = new ParameterMarshal[bodyList.size()];
    bodyList.toArray(_bodyArgs);

    //
    // Return type
    //

    if (! Void.TYPE.equals(method.getReturnType())) {
      if (_isOneway)
        throw new WebServiceException(L.l("Method {0} annotated with @Oneway, but has non-void return", method.getName()));

      Property property =
        _jaxbContext.createProperty(method.getGenericReturnType());

      WebResult webResult = method.getAnnotation(WebResult.class);

      if (webResult == null && eiMethod != null)
        webResult = eiMethod.getAnnotation(WebResult.class);

      if (webResult != null) {
        _headerReturn = webResult.header();

        String localName = webResult.name();

        if ("".equals(localName))
          localName = "return";

        if ("".equals(webResult.targetNamespace()))
          _resultName = new QName(localName);
        else
          _resultName = new QName(webResult.targetNamespace(), localName);
      }
      else {
        _headerReturn = false;
        _resultName = new QName("return"); // XXX namespace?
      }

      _returnMarshal = ParameterMarshal.create(0, property, _resultName,
                                               WebParam.Mode.OUT,
                                               marshaller, unmarshaller);

      _bodyOutputs++;

      if (_headerReturn)
        _headerOutputs++;
    }
    else {
      _headerReturn = false;
      _returnMarshal = null;
    }

    //
    // Exceptions
    //

    Class[] exceptions = method.getExceptionTypes();

    for (Class exception : exceptions) {
      QName faultName = new QName(targetNamespace,
                                  exception.getSimpleName(),
                                  TARGET_NAMESPACE_PREFIX);
      // XXX check for generated exception classes versus raw exceptions
      // i.e. things like getFaultInfo()
      Property property = jaxbContext.createProperty(exception);
      ParameterMarshal marshal =
        ParameterMarshal.create(0, property, faultName,
                                WebParam.Mode.OUT,
                                marshaller, unmarshaller);
View Full Code Here

TOP

Related Classes of com.caucho.jaxb.property.Property

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.