Results 1 to 2 of 2

Thread: Newbie: How to chain transformers

  1. #1
    Join Date
    Apr 2005
    Posts
    4

    Default Newbie: How to chain transformers

    Hi, Im having troubles in order to realize how can SI let me get an Object from a JMS queue and then transform it to XML, then apply some transformation using xslt, then back to a new object with different type.

    I already did the JMS interaction but cant realize which component can let me do this kind of chain transformations. I dont know how to use marshalling-transformer, xslt-transformer and unmarshalling-transformer,My main configuration ffollows:

    <code>
    <message-bus/>
    <annotation-driven/>
    <channel id="main"/>
    <channel id="inicializarObra"/>
    <channel id="crearProveedor"/>

    <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
    <property name="environment">
    <props>
    <prop key="java.naming.factory.initial">weblogic.jndi.WL InitialContextFactory</prop>
    <prop key="java.naming.provider.url">t3://localhost:9001</prop>
    </props>
    </property>
    </bean>

    <bean id="queueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiTemplate" ref="jndiTemplate"/>
    <property name="jndiName" value="jms/ConnectionFactory"/>
    </bean>

    <bean id="receiveDestination" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiTemplate" ref="jndiTemplate"/>
    <property name="jndiName" value="jms/CocosinServiceRequest"/>
    </bean>

    <jms-gateway id="jmsSource" connection-factory="queueConnectionFactory"
    destination="receiveDestination" request-channel="main" />

    <router ref="processResolver" method="getProcessType" input-channel="main"/>


    <service-activator ref="logger" input-channel="inicializarObra"/>

    <beans:bean id="processResolver" class="gob.cocosin.integration.obras.contabilidad. ProcessResolver"/>
    <beans:bean id="logger" class="gob.cocosin.integration.obras.contabilidad. Logger"/>

    <!-- How to use this-->
    <marshalling-transformer id="marshaller" marshaller="castorMarshaller"/>

    <beans:bean id="castorMarshaller" class="org.springframework.oxm.castor.CastorMarsha ller" />
    </code>

  2. #2
    Join Date
    Oct 2007
    Location
    London, England
    Posts
    108

    Default

    There are two ways to apply transformations one is to use the transformer as a MessageHandler in conjunction with a HandlerEndpoint. The alternative is to carry out the transformation with a queue send or receive call, MessageTransformingChannelInterceptor is provided to allow this.

    Currently both approaches require that an instance of PayloadTransformer be wrapped in a PayloadTransformingMessageHandler.


    Code:
    <marshalling-transformer id="marshaller" marshaller="castorMarshaller"/>
    
    <beans:bean id="transformingHandler" class="org.springframework.integration.transformer.PayloadTransformingMessageHandler">
    		<beans:constructor-arg ref="marshaller" />
    </beans:bean>
    If you choose to apply the transformation on the channel then you have the option of having a series of interceptors for the channel each one representing an individual transformation.

    Code:
    	
    <channel id="tranformingChannel">
    	<interceptor ref="oxmTransformingInterceptor"/>
    	<interceptor ref="xsltTransformingInterceptor"/>
    </channel>
    Alternatively you can use a handler chain in conjunction with either a HandlerEndpoint or MessageTransformingChannelInterceptor.

    Code:
    <handler-chain id="transformationChain">
    	<handler ref="transformingHandlerOne"  />
    	<handler ref="transformingHandlerTwo" />
    </handler-chain>
    Jonas Partner
    OpenCredo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •