Bees v0.5.0 API

bees.core
Class NeighborImpl

java.lang.Object
  |
  +--bees.core.Capability
        |
        +--bees.core.NeighborImpl
Direct Known Subclasses:
NodeOSNeighbor

public abstract class NeighborImpl
extends Capability

NeighborImpl is the base for classes that wish to implement neighbor capabilities. These capabilities can then be combined with Neighbor objects to send and receive Capsules of a certain type.

Implementations are expected to capture the parameters for connecting to the neighbor (e.g. IP address, UDP port) in this object. Setting up capsule senders and receivers is done by implementing the abstract methods in this class which will be called by the Neighbor and Neighborhood classes.

See Also:
Neighbor, Neighborhood

Field Summary
static Permission CAPSULE__READ_PERMISSION
          Permission to receive capsules from the neighbor.
static Permission CAPSULE__WRITE_PERMISSION
          Permission to send capsules to the neighbor.
static PermissionSet DEFAULT_PERMISSIONS
          The default permissions for a newly created NeighborImpl object.
 
Fields inherited from class bees.core.Capability
DELETE_PERMISSION, id, INVALID_ID
 
Constructor Summary
NeighborImpl()
           
 
Method Summary
protected abstract  void cancelReceivers(Neighbor neighbor, TypeID capsuleTypeID)
          Call back to be implemented by the class that will receive Capsules.
protected abstract  void dequeueKey()
           
protected abstract  void enqueueKey(java.security.Key sk, java.lang.String algorithm)
          Call back to be implemented by the class that will send and receive Capsules.
abstract  TypeID getFingerPrint()
           
abstract  java.lang.String getInterfaceName()
           
 Neighbor getNeighbor(ExternalCapsule ec)
          Get an ExternalCapsule to Neighbor mapping.
 Neighbor getNeighbor(ProtocolSession ps)
          Get a ProtocolSession to Neighbor mapping.
protected abstract  void receiveBuffer(CapsuleReceiver cr)
          Call back to be implemented by the class that will receive Capsules.
protected abstract  void sendBuffer(edu.utah.janos.nodeos.BufferHandle bh)
          Call back to be implemented by the class that will send Capsules.
protected abstract  void setKey(java.security.Key sk, java.lang.String algorithm)
           
 java.lang.String toString()
           
 
Methods inherited from class bees.core.Capability
checkPermission, clear, clonePermission, deleteCapability, equals, fromBytes, fromBytes, revoke, revokedPermission, revokePermission, revokePermissions, valid
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CAPSULE__READ_PERMISSION

public static final Permission CAPSULE__READ_PERMISSION
Permission to receive capsules from the neighbor.

CAPSULE__WRITE_PERMISSION

public static final Permission CAPSULE__WRITE_PERMISSION
Permission to send capsules to the neighbor.

DEFAULT_PERMISSIONS

public static final PermissionSet DEFAULT_PERMISSIONS
The default permissions for a newly created NeighborImpl object.
Constructor Detail

NeighborImpl

public NeighborImpl()
Method Detail

getNeighbor

public Neighbor getNeighbor(ProtocolSession ps)
Get a ProtocolSession to Neighbor mapping.
Parameters:
ps - The ProtocolSession to be mapped.
Returns:
The Neighbor the mapping should resolve to or null if there is no mapping.

getNeighbor

public Neighbor getNeighbor(ExternalCapsule ec)
Get an ExternalCapsule to Neighbor mapping.
Parameters:
ps - The ExternalCapsule to be mapped.
Returns:
The Neighbor the mapping should resolve to or null if there is no mapping.

receiveBuffer

protected abstract void receiveBuffer(CapsuleReceiver cr)
                               throws java.io.IOException
Call back to be implemented by the class that will receive Capsules. This method is used to setup the connection between the implementation specific mechanism for receiving packets and the Bees mechanism for decoding and dispatching them.
Parameters:
cr - The class that will receive and dispatch a type Capsule.
Throws:
java.io.IOException - if there is a problem attaching the receiver.

cancelReceivers

protected abstract void cancelReceivers(Neighbor neighbor,
                                        TypeID capsuleTypeID)
Call back to be implemented by the class that will receive Capsules. This method is used to tear down the implementation specific receiver for the given Capsule type.
Parameters:
neighbor - The Neighbor object that is being torn down. This should be matched to the Neighbor object held by the CapsuleReceiver given in receiveBuffer.
capsuleTypeID - The Capsule type whose receiver should be detached.

sendBuffer

protected abstract void sendBuffer(edu.utah.janos.nodeos.BufferHandle bh)
                            throws java.io.IOException
Call back to be implemented by the class that will send Capsules. This method is used to transmit an encoded buffer to the neighbor.
Parameters:
bh - The jnodeos BufferHandle to be transmitted.
Throws:
java.io.IOException - if there is a problem sending the given buffer.

setKey

protected abstract void setKey(java.security.Key sk,
                               java.lang.String algorithm)
                        throws java.security.NoSuchAlgorithmException,
                               java.security.InvalidKeyException

enqueueKey

protected abstract void enqueueKey(java.security.Key sk,
                                   java.lang.String algorithm)
                            throws java.security.NoSuchAlgorithmException,
                                   java.security.InvalidKeyException
Call back to be implemented by the class that will send and receive Capsules.
Parameters:
cr - The class that will receive and dispatch a type Capsule.
sk - The SecretKey to use when computing/verifying a MAC.
algorithm - The MAC algorithm to use.
Throws:
java.security.NoSuchAlgorithmException - if the MAC algorithm is not known.
java.security.InvalidKeyException - if the key is invalid.

dequeueKey

protected abstract void dequeueKey()

getInterfaceName

public abstract java.lang.String getInterfaceName()
Returns:
The name of the interface this neighbor uses to communicate with the network.

getFingerPrint

public abstract TypeID getFingerPrint()
Returns:
The FingerPrint for this neighbor. This value should be based on the data used to construct the connection between two neighbors.

toString

public java.lang.String toString()
Overrides:
toString in class Capability
Following copied from class: bees.core.Capability
See Also:
Object.toString()

Bees v0.5.0 API

This documentation is Copyright (C) 2002 The University of Utah. All Rights Reserved. See the individual source files for distribution terms.
Documentation, software, and mailing lists for Bees v0.5.0 can be found at the Janos Project: http://www.cs.utah.edu/flux/janos/