Uploaded image for project: 'Spring Web Services'
  1. Spring Web Services
  2. SWS-196

Lack of useAttributeFor in XStreamMarshaller

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0
    • Fix Version/s: 1.0.2
    • Component/s: OXM
    • Labels:
      None

      Description

      There is no possibility to set useAttributeFor in XStreamMarshaller class. I think this should be added. Followin code added to XStreamMarshaller should solve this problem

      public void setUseAttributeFor(Map aliases) {
      if (logger.isDebugEnabled())

      { logger.debug("setUseAttributeFor(Map) - start"); //$NON-NLS-1$ }

      for (Iterator iterator = aliases.entrySet().iterator(); iterator.hasNext() {
      Map.Entry entry = (Map.Entry) iterator.next();
      // Check whether we need to convert from String to Class.
      Class type = null;
      if (entry.getKey() instanceof Class)

      { type = (Class) entry.getKey(); }

      else

      { ClassEditor editor = new ClassEditor(); editor.setAsText(String.valueOf(entry.getKey())); type = (Class) editor.getValue(); }

      addAttribute((String) entry.getValue(), type);
      }

      if (logger.isDebugEnabled())

      { logger.debug("setUseAttributeFor(Map) - end"); //$NON-NLS-1$ }

      }

      public void addAttribute(String name, Class type) {
      if (logger.isDebugEnabled())

      { logger.debug("addAttribute(String, Class) - start"); //$NON-NLS-1$ logger.debug("addAttribute(String, Class) - name=" + name + ", type=" + type); //$NON-NLS-1$ //$NON-NLS-2$ }

      xstream.useAttributeFor(type, name);

      if (logger.isDebugEnabled())

      { logger.debug("addAttribute(String, Class) - end"); //$NON-NLS-1$ }

      }

      then using attributes can be defined as:

      <property name="useAttributeFor">
      <props>
      <prop key="pl.test.example">version</prop>
      <prop key="pl.test.sample">version</prop>
      </props>
      </property>

        Attachments

          Activity

            People

            • Assignee:
              arjen.poutsma Arjen Poutsma
              Reporter:
              tbrauncajs Tomek Brauncajs
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: