org.ow2.jonas.discovery.base
Class DiscHelper

java.lang.Object
  extended by org.ow2.jonas.discovery.base.DiscHelper
Direct Known Subclasses:
DiscoveryHelper, JGroupsDiscoveryUtils

public class DiscHelper
extends Object

Discovery Helper. Convert objects to bytes and vice versa.

Author:
eyindanga

Constructor Summary
DiscHelper()
           
 
Method Summary
static Object bytesToObject(byte[] bytes)
          Gets DiscEvenet, DiscMessage, or DiscGreeting from bytes array.
static byte[] objectToBytes(Object obj)
          Construct a byte[] containing type info about a DiscMessage object to be sent, plus the content of this message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DiscHelper

public DiscHelper()
Method Detail

objectToBytes

public static byte[] objectToBytes(Object obj)
                            throws IOException
Construct a byte[] containing type info about a DiscMessage object to be sent, plus the content of this message.

Parameters:
obj - Object to be send. Only supported DiscMessage objects.
Returns:
Null if the object is not an instance of DiscMessage or one of its subclasses.
Throws:
IOException - Could not create an ObjectOutputStream to write into the underlying ByteArrayOutputStream.

bytesToObject

public static Object bytesToObject(byte[] bytes)
                            throws IOException,
                                   ClassNotFoundException
Gets DiscEvenet, DiscMessage, or DiscGreeting from bytes array.

Parameters:
bytes - byte[] containing a received message
Returns:
Null if the object in the received message is not of one of the known types, or the object which have been sent.
Throws:
IOException - Could not create an ObjectInputStream to read in it
ClassNotFoundException - Class of a serialized object cannot be found


Copyright © 2010 OW2 Consortium. All Rights Reserved.