|
Bees v0.5.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--bees.core.Packet | +--bees.core.ANEPPacket | +--bees.core.Capsule
Capsule defines the base for packets that can be sent or received by a node. Subclasses are expected to implement the encode() and decode() methods to marshal and unmarshal object state, and to implement the evaluate() method which handles the arrival of a new Capsule at a node. However, they are not expected to create a unique capsule identifier and transfer their code between nodes, the system will perform these functions.
Because of the need to restrict the propagation of Capsules in the system and network, each capsule object is associated with an authorization state. This state tracks the number of times the capsule can be used in some operation, such as sending the capsule to a neighbor. After a capsule has been used to perform these operations it is considered "depleted" and needs to be "replenished" before it can be used again. Capsules can be replenished through one of the following methods:
Protocol.addCapsule(String, PermissionSet)
,
Protocol
Constructor Summary | |
Capsule()
Create a Capsule with the default values. |
Method Summary | |
void |
addToPool()
Add this capsule back to the flow local pool. |
void |
checkPermission(Permission what)
Check the capsule for the given permission. |
java.lang.Object |
clone()
|
abstract void |
decode(Xdr xdr)
Decode this Capsule's state from the given Xdr. |
void |
decodingException(java.lang.Throwable th)
|
abstract void |
encode(Xdr xdr)
Encode this Capsule's state into the given Xdr. |
boolean |
equals(java.lang.Object obj)
|
void |
evaluate(Node node)
Evaluate this capsule. |
void |
evaluate(Node node,
ProtocolSession ps)
Evaluate this capsule. |
void |
fromCapsule(Capsule cap)
Replenish this capsule from the authorization in the given capsule. |
void |
fromExternal(ExternalCapsule ec)
Replenish this capsule from the authorization in the given external capsule. |
TypeID |
getCapsuleID()
|
PairChain |
getFlowDesc()
|
ProtocolSession |
getSession()
|
ProtocolSession |
getSession(java.lang.String companionSessionName)
Get the ProtocolSession for the given class name with the context of this Capsule's flow. |
Neighbor |
getSource()
|
protected void |
internalDecode(Xdr xdr)
|
protected void |
internalEncode(Xdr xdr)
|
protected void |
internalReset()
Reset any cached values so the capsule can be reused instead of left to garbage collector. |
void |
reset()
Reset this Capsule's state. |
protected void |
skipOptions(Xdr xdr)
Skip the options in the ANEP header leaving the Xdr pointing to the start of the payload. |
void |
specializeCapsule(Capsule cap)
Replenish this companion capsule and specialize it from the given Capsule. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Capsule()
Method Detail |
public final TypeID getCapsuleID()
public final PairChain getFlowDesc()
public final ProtocolSession getSession(java.lang.String companionSessionName) throws java.lang.ClassNotFoundException
companionSessionName
- The class name of the session to retrieve.java.lang.ClassNotFoundException
- if the given class name couldn't be
found.java.lang.IllegalStateException
- if the capsule has yet to be associated
with protocol session.public final ProtocolSession getSession()
public final void fromExternal(ExternalCapsule ec)
ec
- The external capsule to use as authorization.public final void fromCapsule(Capsule cap)
cap
- The capsule to use as authorization.public final void specializeCapsule(Capsule cap)
cap
- The capsule this one should be specialized to.protected final void internalDecode(Xdr xdr) throws InvalidPacketException, DroppedPacketException
internalDecode
in class bees.core.ANEPPacket
bees.core.ANEPPacket
bees.core.Packet#internalDecode(Xdr)
protected final void internalEncode(Xdr xdr)
public void reset()
public void decodingException(java.lang.Throwable th)
public abstract void decode(Xdr xdr) throws java.lang.Throwable
xdr
- An Xdr object that contains this Capsule's data.java.lang.Throwable
- if anything goes wrong.public abstract void encode(Xdr xdr) throws java.lang.Throwable
xdr
- An Xdr object that should be used to encode this Capsule's
state.java.lang.Throwable
- if anything goes wrong.public void evaluate(Node node) throws java.lang.Throwable
node
- The current Node object.java.lang.Throwable
- if anything goes wrong.public void evaluate(Node node, ProtocolSession ps) throws java.lang.Throwable
node
- The current Node object.ps
- The ProtocolSession bound to this capsule type.java.lang.Throwable
- if anything goes wrong.public final void checkPermission(Permission what) throws PermissionException
what
- The Permission to check for.PermissionException
- if the Capsule doesn't have the given
Permission.public void addToPool()
public boolean equals(java.lang.Object obj)
equals
in class bees.core.ANEPPacket
Object.equals(Object)
public java.lang.String toString()
toString
in class bees.core.ANEPPacket
Object.toString()
protected void internalReset()
bees.core.Packet
internalReset
in class bees.core.Packet
Packet.internalReset()
protected void skipOptions(Xdr xdr)
xdr
- The Xdr containing an encoded ANEP header.public final Neighbor getSource()
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
|
Bees v0.5.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |