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

Jaxb2Marshaller.supports(Class clazz) is too eager

    Details

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

      Description

      When using multiple Jaxb2Marshallers for multiple endpoints, first encountered Jaxb2Marshaller is always used, because it's "support" method accepts every Jaxb class. My proposition for improvement is:

      public boolean supports(Class clazz) {
      boolean isJaxbClass = clazz.getAnnotation(XmlRootElement.class) != null

      JAXBElement.class.isAssignableFrom(clazz);
      if (isJaxbClass) {
      if (StringUtils.hasLength(getContextPath())) {
      String pckgName = clazz.getPackage().getName();
      StringTokenizer st = new StringTokenizer(getContextPath(), ":");
      while (st.hasMoreTokens())
      Unknown macro: { if (st.nextToken().equals(pckgName)) { return true; }
      }
      } else if (!ObjectUtils.isEmpty(classesToBeBound)) {
      for (Class clazzToBeBo : classesToBeBound) {
      if (clazzToBeBo.equals(clazz)) { return true; } }

      } else

      { throw new IllegalArgumentException( "setting either contextPath or classesToBeBound is required"); }

      }
      return false;
      }

        Attachments

          Activity

            People

            • Assignee:
              arjen.poutsma Arjen Poutsma
              Reporter:
              anthavio Martin Vanek
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: