Announcement Announcement Module
Collapse
No announcement yet.
Spring expression challenge with content enricher Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring expression challenge with content enricher

    Hi there,

    I am trying to use the content enricher to apply some instance-specific properties to my domain objects. One of the properties on my domain object is an XmlGregorianCalendar (let's call it instanceDate). What I'd ideally like to do is configure my instance-specific property in a properties file, and then apply it to my domain object using the enricher and a Spring expression.

    Properties file extract:
    Code:
    <properties>
        <entry key="instance.date">2012-01-01</entry>
    </properties>
    Spring Integration file extract:
    Code:
    <int:enricher id="instanceProperties">
        <int:property name="instanceDate" expression="SPRING EXPRESSION(${instance.date})" />
    </int:enricher>
    Is this possible, and if so, what would the expression look like?

    I'm relatively new to Java, BTW, so apologies if this is all a naive question. If it were possible to call some kind of utility class, I guess that would probably solve it also.

    The desired chain seems to be
    (1) string-->DateFormat --or-- Date --or-- SimpleDateFormat
    (2) Datey Thing --> GregorianCalendar
    (3) GregorianCalendar --> XmlGregorianCalendar

    Best wishes,

    Ben

  • #2
    It could be done, but the expression would be very ugly.

    A simply utility class that does the conversion would probably be easiest

    Code:
    <bean id="toXMLGreg" class="foo.MyConverter">
        <constructor-arg value="${instance.date}" />
    </bean>
    
    <int:enricher id="instanceProperties">
        <int:property name="instanceDate" expression="@toXMLGreg.getInstanceDate()" />
    </int:enricher>

    Comment


    • #3
      Thanks Gary - that method worked for me. Best wishes, Ben

      Comment

      Working...
      X