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

Allow CastorMarshaller to accept more than one mapping file

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0 M3
    • Fix Version/s: 1.0 RC1
    • Component/s: XML
    • Labels:
      None
    • Environment:
      All

      Description

      Allow CastorMarshaller to accept multiple mapping files, as descibed here: http://forum.springframework.org/showthread.php?t=34258

      Castor can accept more than one by calling mapping.loadMapping() multiple times. I modified the code for my purposes like so:

      private void createClassDescriptorResolver() throws MappingException, IOException {
      classDescriptorResolver = (XMLClassDescriptorResolver) ClassDescriptorResolverFactory
      .createClassDescriptorResolver(BindingType.XML);
      if(!Utils.isEmpty(mappingLocations)) {
      Mapping mapping = new Mapping();
      for(int i=0; i<mappingLocations.size(); i++)

      { logger.debug("Trying to load mapping resource: " + (String)mappingLocations.get(i)); Resource resource = new ClassPathResource((String)mappingLocations.get(i)); mapping.loadMapping(new InputSource(resource.getInputStream())); }

      MappingUnmarshaller mappingUnmarshaller = new MappingUnmarshaller();
      MappingLoader mappingLoader = mappingUnmarshaller.getMappingLoader(mapping, BindingType.XML);
      classDescriptorResolver.setMappingLoader(mappingLoader);
      classDescriptorResolver.setClassLoader(mapping.getClassLoader());
      }
      else if (targetClass != null)

      { classDescriptorResolver.setClassLoader(targetClass.getClassLoader()); }

      }

      (mappingLocations is now an ArrayList)

      Configuration as follows:

      <property name="mappingLocations">
      <list>
      <value>/com/lsb/uk/lasernet/oxm/castor/lasernetEnvelope-mapping.xml</value>
      <value>/com/lsb/uk/mqs/biz/bos/castor-mapping.xml</value>
      </list>
      </property>

      Does this method need to be private by the way? Could it be protected, so it can be overridden?

      Thanks

      Richard

        Activity

        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        Closing RC1 issues.

        Show
        arjen.poutsma Arjen Poutsma added a comment - Closing RC1 issues.

          People

          • Assignee:
            arjen.poutsma Arjen Poutsma
            Reporter:
            richardgundersen Richard Gundersen
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: