Announcement Announcement Module
Collapse
No announcement yet.
Superseeding the default Rome Atom converter with a user defined one. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Superseeding the default Rome Atom converter with a user defined one.

    Hi Folks,

    I'm having a problem whereby I'm trying to convert my company's proprietary type of Atom feed (with extra information not contained in the standard) to it's associated object type.

    I created the relevant converter (which I inherited from AbstractWireFeedHttpMessageConverter), along with the generator, and added all the information to the rome.properties file. Everything works fine, and registers correctly with the spring integration framework.

    The problem I'm having is that when I post our proprietary Atom feed to my server, it keeps on picking up spring's default converter (AtomFeedHttpMessageConverter) for "atom+xml" media types, and not my user defined implementation. I realise that they both work off the same media type, but is there any way to make my implementation the default?

    Any advice would be greatly received.

    Thanks,
    R.

  • #2
    A good place to start would be to also include your configuration so we can see how/why things may or may not work

    Comment


    • #3
      Hi Oleg,

      Apologies for the (really) late response, I was dragged off to do other work :-( Here are the relevant parts of my xml configuration:

      <int-http:inbound-gateway request-channel="requestChannel"
      name="/{application}/{contract}/**"
      path="/{application}/{contract}/**"
      mapped-request-headers="accept-charset:utf-8"
      supported-methods="GET, POST"
      message-converters="messageConverters">
      <int-http:header name="application" expression="#pathVariables.application"/>
      <int-http:header name="contract" expression="#pathVariables.contract"/>
      </int-http:inbound-gateway>

      <util:list id="messageConverters">
      <ref bean="customAtomConverter"/>
      </util:list>

      <bean id="customAtomConverter" class="com.xxx.xxx.xxx.converter.CustomAtomFeedHtt pMessageConverter">
      <property name="supportedMediaTypes" value="application/atom+xml"/>
      </bean>

      Following is the relevant class implementation of the custom atom feed:

      public class CustomAtomFeedHttpMessageConverter extends AbstractWireFeedHttpMessageConverter<CustomFeed> {

      public CustomAtomFeedHttpMessageConverter() {
      super(new MediaType("application", "atom+xml"));
      }

      @Override
      protected boolean supports(Class<?> clazz) {
      return true;
      }
      }

      I manage to register my custom generator (using rome.properties file) which extends from Atom10Generator, and that works fine. The relevant code is below:

      public class Custom10Generator extends Atom10Generator {

      public Custom10Generator() {
      this("custom_1.0", "1.0");
      }

      protected Custom10Generator(String type, String version) {
      super(type, version);
      }

      public Document generate(WireFeed wireFeed) throws FeedException {
      CustomFeed customFeed = (CustomFeed) wireFeed;
      Element root = createRootElement(customFeed);
      populateFeed(customFeed,root);
      return createDocument(root);
      }

      ....
      }

      rome.properties
      ---------------
      # Feed Generator implementation classes
      #
      WireFeedGenerator.classes=com.xxx.xxxx.xxxx.genera tor.Custom10Generator

      # Parsers for Custom 1.0 customFeed modules
      #
      # atom_0.3.customFeed.ModuleParser.classes=com.sun.s yndication.io.impl.SyModuleParser \
      com.sun.syndication.io.impl.DCModuleParser
      custom_1.0.customFeed.ModuleParser.classes=com.sun .syndication.io.impl.SyModuleParser

      # Parsers for Custom 1.0 entries modules
      #
      # atom_0.3.item.ModuleParser.classes=com.sun.syndica tion.io.impl.DCModuleParser
      custom_1.0.item.ModuleParser.classes=com.sun.syndi cation.io.impl.DCModuleParser

      However because there's already a default generator dealing with "application/atom+xml" content within the rome project, I'm unable to use my proprietary generator, as it picks up the default one automatically, and I can't figure out a way to change that. I hope that this is clear enough, and thanks for the response.

      R.

      Comment


      • #4
        Any ideas Oleg?

        Thanks,
        Rowan.

        Comment

        Working...
        X