KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > providers > rmi > RmiMessageAdapter


1 /*
2  * $Id: RmiMessageAdapter.java 3982 2006-11-22 14:28:01Z lajos $
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.rmi;
12
13 import org.mule.providers.AbstractMessageAdapter;
14 import org.mule.umo.provider.MessageTypeNotSupportedException;
15
16 /**
17  * Wraps an object obtained by calling a method on a Remote object
18  */

19
20 public class RmiMessageAdapter extends AbstractMessageAdapter
21 {
22     /**
23      * Serial version
24      */

25     private static final long serialVersionUID = -1765089871661318129L;
26
27     private final Object JavaDoc message;
28
29     public RmiMessageAdapter(Object JavaDoc message) throws MessageTypeNotSupportedException
30     {
31         if (message == null)
32         {
33             throw new MessageTypeNotSupportedException(null, getClass());
34         }
35         this.message = message;
36     }
37
38     public byte[] getPayloadAsBytes() throws Exception JavaDoc
39     {
40         return convertToBytes(getPayload());
41     }
42
43     /**
44      * Converts the message implementation into a String representation
45      *
46      * @param encoding The encoding to use when transforming the message (if
47      * necessary). The parameter is used when converting from a byte array
48      * @return String representation of the message payload
49      * @throws Exception Implementation may throw an endpoint specific exception
50      */

51     public String JavaDoc getPayloadAsString(String JavaDoc encoding) throws Exception JavaDoc
52     {
53         return message.toString();
54     }
55
56     public Object JavaDoc getPayload()
57     {
58         return message;
59     }
60 }
61
Popular Tags