Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
JdbcMessageAdapter |
|
| 1.0;1 |
1 | /* | |
2 | * $Id: JdbcMessageAdapter.java 7976 2007-08-21 14:26:13Z 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.jdbc; | |
12 | ||
13 | import org.mule.impl.ThreadSafeAccess; | |
14 | import org.mule.providers.AbstractMessageAdapter; | |
15 | ||
16 | public class JdbcMessageAdapter extends AbstractMessageAdapter | |
17 | { | |
18 | /** | |
19 | * Serial version | |
20 | */ | |
21 | private static final long serialVersionUID = 6770314376258549559L; | |
22 | ||
23 | private final Object payload; | |
24 | ||
25 | public JdbcMessageAdapter(Object obj) | |
26 | 0 | { |
27 | 0 | this.payload = obj; |
28 | 0 | } |
29 | ||
30 | protected JdbcMessageAdapter(JdbcMessageAdapter template) | |
31 | { | |
32 | 0 | super(template); |
33 | 0 | payload = template.payload; |
34 | 0 | } |
35 | ||
36 | /** | |
37 | * Converts the message implementation into a String representation | |
38 | * | |
39 | * @param encoding The encoding to use when transforming the message (if | |
40 | * necessary). The parameter is used when converting from a byte array | |
41 | * @return String representation of the message payload | |
42 | * @throws Exception Implementation may throw an endpoint specific exception | |
43 | */ | |
44 | public String getPayloadAsString(String encoding) throws Exception | |
45 | { | |
46 | 0 | return payload.toString(); |
47 | } | |
48 | ||
49 | /* | |
50 | * (non-Javadoc) | |
51 | * | |
52 | * @see org.mule.umo.provider.UMOMessageAdapter#getPayloadAsBytes() | |
53 | */ | |
54 | public byte[] getPayloadAsBytes() throws Exception | |
55 | { | |
56 | 0 | return payload.toString().getBytes(); |
57 | } | |
58 | ||
59 | /* | |
60 | * (non-Javadoc) | |
61 | * | |
62 | * @see org.mule.umo.provider.UMOMessageAdapter#getPayload() | |
63 | */ | |
64 | public Object getPayload() | |
65 | { | |
66 | 0 | return payload; |
67 | } | |
68 | ||
69 | public ThreadSafeAccess newThreadCopy() | |
70 | { | |
71 | 0 | return new JdbcMessageAdapter(this); |
72 | } | |
73 | ||
74 | } |