Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
JMSMessageToObject |
|
| 3.5;3.5 |
1 | /* | |
2 | * $Id: JMSMessageToObject.java 7963 2007-08-21 08:53:15Z dirk.olmes $ | |
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 CPAL v1.0 | |
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 org.mule.umo.transformer.TransformerException; | |
14 | import org.mule.util.ClassUtils; | |
15 | ||
16 | import javax.jms.Message; | |
17 | ||
18 | /** | |
19 | * <code>JMSMessageToObject</code> Will convert a <code>javax.jms.Message</code> | |
20 | * or sub-type into an object by extracting the message payload. Users of this | |
21 | * transformer can set different return types on the transform to control the way it | |
22 | * behaves. | |
23 | * <ul> | |
24 | * <li>javax.jms.TextMessage - java.lang.String</li> | |
25 | * <li>javax.jms.ObjectMessage - java.lang.Object</li> | |
26 | * <li>javax.jms.BytesMessage - Byte[]. Note that the transformer will check if the | |
27 | * payload is compressed and automatically uncompress the message.</li> | |
28 | * <li>javax.jms.MapMessage - java.util.Map</li> | |
29 | * <li>javax.jms.StreamMessage - java.util.Vector of objects from the Stream | |
30 | * Message.</li> | |
31 | * </ul> | |
32 | */ | |
33 | ||
34 | public class JMSMessageToObject extends AbstractJmsTransformer | |
35 | { | |
36 | ||
37 | public JMSMessageToObject() | |
38 | { | |
39 | 204 | super(); |
40 | 250 | registerSourceType(Message.class); |
41 | 204 | } |
42 | ||
43 | public Object doTransform(Object src, String encoding) throws TransformerException | |
44 | { | |
45 | try | |
46 | { | |
47 | 88 | if (logger.isDebugEnabled()) |
48 | { | |
49 | 0 | logger.debug("Source object is " + ClassUtils.getSimpleName(src.getClass())); |
50 | } | |
51 | ||
52 | 87 | Object result = transformFromMessage((Message)src); |
53 | ||
54 | 88 | if (logger.isDebugEnabled()) |
55 | { | |
56 | 0 | logger.debug("Resulting object is " + ClassUtils.getSimpleName(result.getClass())); |
57 | } | |
58 | ||
59 | 87 | return result; |
60 | } | |
61 | 0 | catch (Exception e) |
62 | { | |
63 | 0 | throw new TransformerException(this, e); |
64 | } | |
65 | } | |
66 | ||
67 | } |