edu.rit.m2mi
Class M2MIMessagePrefix

java.lang.Object
  extended by edu.rit.m2mi.M2MIMessagePrefix

public class M2MIMessagePrefix
extends Object

Class M2MIMessagePrefix provides a bag of M2MI message prefixes registered with the M2MP Layer. Whenever a key is added to or removed from an ExportMap, the corresponding M2MI message prefix is added to or removed from the M2MI message prefix bag. The M2MI message prefix bag in turn adds the prefix to or removes the prefix from the M2MP Layer. A bag is needed to keep track of the M2MI message prefixes because multiple keys in the export maps may have the same M2MI message prefix.

Class M2MIMessagePrefix also provides static operations for obtaining the M2MI message prefixes for various kinds of export map keys.

Note: Class M2MIMessagePrefix is not multiple thread safe.


Constructor Summary
M2MIMessagePrefix(M2MP theM2MPLayer)
          Construct a new, empty M2MI message prefix bag.
 
Method Summary
 void addKey(Object theKey)
          Add the given export map key to this M2MI message prefix bag.
static byte[] getMessagePrefix(Eoid theEoid)
          Obtain the M2MP message prefix for the given EOID.
static byte[] getMessagePrefix(String theInterfaceName)
          Obtain the M2MP message prefix for the given target interface name.
static int getMessagePrefixLength()
          Returns the length in bytes of an M2MI message prefix.
 void removeKey(Object theKey)
          Remove the given export map key from this M2MI message prefix bag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

M2MIMessagePrefix

public M2MIMessagePrefix(M2MP theM2MPLayer)
Construct a new, empty M2MI message prefix bag.

Parameters:
theM2MPLayer - M2MP Layer, or null if the M2MI Layer is not broadcasting and receiving M2MI invocation messages.
Method Detail

getMessagePrefixLength

public static int getMessagePrefixLength()
Returns the length in bytes of an M2MI message prefix.


getMessagePrefix

public static byte[] getMessagePrefix(String theInterfaceName)
Obtain the M2MP message prefix for the given target interface name. The message prefix consists of a 4-byte magic number identifying the version of the M2MI Layer in use, followed by a 4-byte hash code of the given target interface name.

Parameters:
theInterfaceName - Fully-qualified name of the target interface.
Returns:
Message prefix.

getMessagePrefix

public static byte[] getMessagePrefix(Eoid theEoid)
Obtain the M2MP message prefix for the given EOID. The message prefix consists of a 4-byte magic number identifying the version of the M2MI Layer in use, followed by a 4-byte hash code of the given EOID.

Parameters:
theEoid - EOID.
Returns:
Message prefix.

addKey

public void addKey(Object theKey)
Add the given export map key to this M2MI message prefix bag. The corresponding M2MP message prefix is registered with the M2MP Layer when necessary.

Parameters:
theKey - Export map key, either a target interface name or an EOID.
Throws:
NullPointerException - (unchecked exception) Thrown if theKey is null.
ExportException - (unchecked exception) Thrown if there was a problem registering the M2MP message prefix with the M2MP Layer.

removeKey

public void removeKey(Object theKey)
Remove the given export map key from this M2MI message prefix bag. The corresponding M2MP message prefix is removed from the M2MP Layer when necessary.

Parameters:
theKey - Export map key, either a target interface name or an EOID.
Throws:
NullPointerException - (unchecked exception) Thrown if theKey is null.
ExportException - (unchecked exception) Thrown if there was a problem registering the M2MP message prefix with the M2MP Layer.


Copyright © 2001-2006 by Alan Kaminsky. All rights reserved. Send comments to ark­@­cs.rit.edu.