KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > providers > jms > transformers > JMSMessageToObject


1 /*
2  * $Id: JMSMessageToObject.java 3798 2006-11-04 04:07:14Z aperepel $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.providers.jms.transformers;
12
13 import javax.jms.Message JavaDoc;
14
15 import org.mule.umo.transformer.TransformerException;
16
17 /**
18  * <code>JMSMessageToObject</code> Will convert a <code>javax.jms.Message</code>
19  * or sub-type into an object by extracting the message payload. Users of this
20  * transformer can set different return types on the transform to control the way it
21  * behaves.
22  * <ul>
23  * <li>javax.jms.TextMessage - java.lang.String</li>
24  * <li>javax.jms.ObjectMessage - java.lang.Object</li>
25  * <li>javax.jms.BytesMessage - Byte[]. Note that the transformer will check if the
26  * payload is compressed and automatically uncompress the message.</li>
27  * <li>javax.jms.MapMessage - java.util.Map</li>
28  * <li>javax.jms.StreamMessage - java.util.Vector of objects from the Stream
29  * Message.</li>
30  * </ul>
31  */

32
33 public class JMSMessageToObject extends AbstractJmsTransformer
34 {
35     /**
36      * Serial version
37      */

38     private static final long serialVersionUID = -4458860619942940372L;
39
40     public JMSMessageToObject()
41     {
42         super();
43         registerSourceType(Message JavaDoc.class);
44     }
45
46     public Object JavaDoc doTransform(Object JavaDoc src, String JavaDoc encoding) throws TransformerException
47     {
48         try
49         {
50             if (logger.isDebugEnabled())
51             {
52                 logger.debug("Source object is " + src.getClass().getName());
53             }
54
55             Object JavaDoc result = transformFromMessage((Message JavaDoc)src);
56
57             if (logger.isDebugEnabled())
58             {
59                 logger.debug("Resulting object is " + result.getClass().getName());
60             }
61
62             return result;
63         }
64         catch (Exception JavaDoc e)
65         {
66             throw new TransformerException(this, e);
67         }
68     }
69
70 }
71
Popular Tags