ch.ethz.iks.r_osgi.messages
Class RemoteOSGiMessage

java.lang.Object
  extended by ch.ethz.iks.r_osgi.messages.RemoteOSGiMessage
Direct Known Subclasses:
DeliverBundlesMessage, DeliverServiceMessage, LeaseMessage, LeaseUpdateMessage, RemoteCallMessage, RemoteCallResultMessage, RemoteEventMessage, RequestBundleMessage, RequestDependenciesMessage, RequestServiceMessage, StreamRequestMessage, StreamResultMessage, TimeOffsetMessage

public abstract class RemoteOSGiMessage
extends java.lang.Object

Abstract base class for all Messages.

Since:
0.1
Author:
Jan S. Rellermeyer, ETH Zurich

Field Summary
static short DELIVER_BUNDLE
          Deprecated.  
static short DELIVER_BUNDLES
          type code for deliver bundles message
static short DELIVER_SERVICE
          type code for deliver service messages.
static short LEASE
          type code for lease messages.
static short LEASE_UPDATE
          type code for service attribute updates.
static short REMOTE_CALL
          type code for invoke method messages.
static short REMOTE_CALL_RESULT
          type code for method result messages.
static short REMOTE_EVENT
          type code for remote event messages.
static short REQUEST_BUNDLE
          type code for request bundle message
static short REQUEST_DEPENDENCIES
          type code for request dependency message.
static short REQUEST_SERVICE
          type code for fetch service messages.
static short STREAM_REQUEST
          type code for stream request messages.
static short STREAM_RESULT
          type code for stream result messages.
static short TIME_OFFSET
          type code for time offset messages.
protected  int xid
          the transaction id.
 
Method Summary
 short getFuncID()
          Get the function ID (type code) of the message.
 int getXID()
          get the transaction ID.
static RemoteOSGiMessage parse(java.io.ObjectInputStream input)
          reads in a network packet and constructs the corresponding subtype of RemoteOSGiMessage from it.
protected static byte[] readBytes(java.io.ObjectInputStream input)
          reads the bytes encoded as SLP string.
protected static java.lang.String[] readStringArray(java.io.ObjectInputStream in)
          read a string array.
 void send(java.io.ObjectOutputStream out)
          write the RemoteOSGiMessage to an output stream.
 void setXID(int xid)
          set the xid.
protected abstract  void writeBody(java.io.ObjectOutputStream output)
          write the body of a RemoteOSGiMessage.
protected static void writeBytes(java.io.ObjectOutputStream out, byte[] bytes)
          writes a byte array.
protected static void writeStringArray(java.io.ObjectOutputStream out, java.lang.String[] strings)
          write a string array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LEASE

public static final short LEASE
type code for lease messages.

See Also:
Constant Field Values

REQUEST_SERVICE

public static final short REQUEST_SERVICE
type code for fetch service messages.

See Also:
Constant Field Values

DELIVER_SERVICE

public static final short DELIVER_SERVICE
type code for deliver service messages.

See Also:
Constant Field Values

DELIVER_BUNDLE

public static final short DELIVER_BUNDLE
Deprecated. 
type code for deliver bundle messages.

See Also:
Constant Field Values

REMOTE_CALL

public static final short REMOTE_CALL
type code for invoke method messages.

See Also:
Constant Field Values

REMOTE_CALL_RESULT

public static final short REMOTE_CALL_RESULT
type code for method result messages.

See Also:
Constant Field Values

REMOTE_EVENT

public static final short REMOTE_EVENT
type code for remote event messages.

See Also:
Constant Field Values

TIME_OFFSET

public static final short TIME_OFFSET
type code for time offset messages.

See Also:
Constant Field Values

LEASE_UPDATE

public static final short LEASE_UPDATE
type code for service attribute updates.

See Also:
Constant Field Values

STREAM_REQUEST

public static final short STREAM_REQUEST
type code for stream request messages.

See Also:
Constant Field Values

STREAM_RESULT

public static final short STREAM_RESULT
type code for stream result messages.

See Also:
Constant Field Values

REQUEST_DEPENDENCIES

public static final short REQUEST_DEPENDENCIES
type code for request dependency message.

See Also:
Constant Field Values

REQUEST_BUNDLE

public static final short REQUEST_BUNDLE
type code for request bundle message

See Also:
Constant Field Values

DELIVER_BUNDLES

public static final short DELIVER_BUNDLES
type code for deliver bundles message

See Also:
Constant Field Values

xid

protected int xid
the transaction id.

Method Detail

getXID

public final int getXID()
get the transaction ID.

Returns:
the xid.
Since:
0.6
See Also:
ch.ethz.iks.r_osgi.RemoteOSGiMessage#getXID()

setXID

public void setXID(int xid)
set the xid.

Parameters:
xid - set the xid.

getFuncID

public final short getFuncID()
Get the function ID (type code) of the message.

Returns:
the type code.
Since:
0.6
See Also:
ch.ethz.iks.r_osgi.RemoteOSGiMessage#getFuncID()

parse

public static RemoteOSGiMessage parse(java.io.ObjectInputStream input)
                               throws java.io.IOException,
                                      java.lang.ClassNotFoundException
reads in a network packet and constructs the corresponding subtype of RemoteOSGiMessage from it. The header is:
   0                   1                   2                   3
   0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |    Version    |         Function-ID           |     XID       |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |    XID cntd.  | 
  +-+-+-+-+-+-+-+-+
 
the body is processed by the subtype class.

Parameters:
input - the DataInput providing the network packet.
Returns:
the RemoteOSGiMessage.
Throws:
java.lang.ClassNotFoundException
java.net.SocketException - if something goes wrong.
java.io.IOException

send

public final void send(java.io.ObjectOutputStream out)
                throws java.io.IOException
write the RemoteOSGiMessage to an output stream.

Parameters:
out - the ObjectOutputStream.
Throws:
java.io.IOException - in case of IO failures.

writeBody

protected abstract void writeBody(java.io.ObjectOutputStream output)
                           throws java.io.IOException
write the body of a RemoteOSGiMessage.

Parameters:
output - the output stream.
Throws:
java.io.IOException - in case of IO failures.

readBytes

protected static byte[] readBytes(java.io.ObjectInputStream input)
                           throws java.io.IOException
reads the bytes encoded as SLP string.

Parameters:
input - the DataInput.
Returns:
the byte array.
Throws:
java.io.IOException - in case of IO failures.

writeBytes

protected static void writeBytes(java.io.ObjectOutputStream out,
                                 byte[] bytes)
                          throws java.io.IOException
writes a byte array.

Parameters:
out - the output stream.
bytes - the bytes.
Throws:
java.io.IOException - in case of IO failures.

writeStringArray

protected static void writeStringArray(java.io.ObjectOutputStream out,
                                       java.lang.String[] strings)
                                throws java.io.IOException
write a string array.

Parameters:
out - the output stream.
strings - the string array.
Throws:
java.io.IOException - in case of IO failures.

readStringArray

protected static java.lang.String[] readStringArray(java.io.ObjectInputStream in)
                                             throws java.io.IOException
read a string array.

Parameters:
in - the input stream
Returns:
the read string array.
Throws:
java.io.IOException - in case of IO failures.


Copyright © 2009 IKS, ETH Zurich. All Rights Reserved.