|
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.Protocol
Protocol is used to describe the classes, data, and companion protocols that make up an Bees protocol. Subclasses are expected to override the constructor and use the functions in this class to build the protocol description. Once the constructor has finished executing, the resulting Protocol should describe a completely self contained entity that can be transferred between nodes.
Actual construction of the description is done on end nodes where the protocol has access to files on the local file system and capabilities that may not be available elsewhere. Besides simple byte arrays, the protocol can also specify "companion" protocols, which can be used to assist the protocol perform its task. For example, the system provides the "DLProtocol" and "IDTranslationProtocol" companions which take care of downloading the protocol to other nodes. Once the protocol has been successfully built, it can then be used as a companion for other protocols (if it implements CompanionProtocol) or it can be used as the primary protocol for a ProtocolFlow.
Starting a Protocol on a node is done by registering a ProtocolFlow through a Node object or by externally starting up a ProtocolBDomain with the Protocol class name as the first argument. Once the flow has been instantiated, the primary protocol will receive a "boot" capsule from the system and the rest is up to the implementation.
Example:
public class ExampleProtocol extends Protocol { public ExampleProtocol() { super.startProtocolDefn(); { super.addCapsule("MyCapsule", new PermissionSet(new Permission[] { new CountPermission("returns", 1), })); super.setBootStrap("MyBootCapsule", new PermissionSet()); super.addCode("MyHelperClass"); super.setSession("MySession"); super.addCompanion(new DLProtocol()); super.addCompanion(new IDTranslationProtocol()); } super.endProtocolDefn(); } }
Node
,
ProtocolFlow
,
DLProtocol
,
IDTranslationProtocol
,
CompanionProtocol
Constructor Summary | |
protected |
Protocol()
Construct an empty Protocol object. |
Method Summary | |
protected void |
addByteArray(java.lang.String byteArrayName,
byte[] ba)
Add a plain byte array to the protocol. |
protected void |
addByteArray(java.lang.String byteArrayName,
byte[] ba,
VersionString vs)
Add a plain byte array to the protocol. |
protected void |
addCapsule(java.lang.String className,
PermissionSet ps)
Add a full capsule class to the protocol. |
protected void |
addCapsule(java.lang.String className,
VersionString versionID,
PermissionSet ps)
Add a full capsule class to the protocol. |
protected void |
addCode(java.lang.String className)
Add a class to the protocol. |
protected void |
addCode(java.lang.String className,
VersionString versionID)
Add a class to the protocol. |
protected void |
addCompanion(CompanionProtocol protocol)
Add a companion to the protocol. |
protected void |
addFile(java.lang.String fileName)
Add a file from the class path to the protocol. |
protected void |
endProtocolDefn()
End the protocol definition, this will demarcate the end of the definition and finalize any internal hashed identifiers. |
int |
getByteArrayLength()
|
protected Node |
getNode()
|
protected void |
setBootStrap(java.lang.String className,
PermissionSet ps)
Set the boot strap capsule class name. |
protected void |
setSession(java.lang.String className)
Set the ProtocolSession class name. |
protected void |
startProtocolDefn()
Start the protocol definition, this is mostly for demarking the start of the definition. |
byte[] |
toByteArray()
|
void |
toByteArray(XdrByteArray xdr)
Encode this Protocol object in the given byte array. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
protected Protocol()
Method Detail |
protected final Node getNode()
protected void startProtocolDefn()
protected void endProtocolDefn() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- if startProtocolDefn() wasn't called
before calling this method.protected void addByteArray(java.lang.String byteArrayName, byte[] ba, VersionString vs) throws java.lang.IllegalStateException
byteArrayName
- The name of the byte array, used when addressing it
through the ProtocolSession.ba
- The actual byte array to store.vs
- The optional VersionString to use when computing the hash id
of "ba".java.lang.IllegalStateException
- if startProtocolDefn() wasn't called
before calling this method.protected void addByteArray(java.lang.String byteArrayName, byte[] ba) throws java.lang.IllegalStateException
byteArrayName
- The name of the byte array, used when addressing it
through the ProtocolSession.ba
- The actual byte array to store.java.lang.IllegalStateException
- if startProtocolDefn() wasn't called
before calling this method.protected void addFile(java.lang.String fileName) throws java.io.FileNotFoundException, java.lang.IllegalStateException
fileName
- The name of the file, used to load the file and address
through the ProtocolSession.java.lang.IllegalStateException
- if startProtocolDefn() wasn't called
before calling this method.protected void addCode(java.lang.String className, VersionString versionID) throws java.lang.ClassNotFoundException, java.lang.IllegalStateException
className
- The name of the class to add.versionID
- The optional VersionString to use when computing the
hash id of the class.java.lang.IllegalStateException
- if startProtocolDefn() wasn't called
before calling this method.protected void addCode(java.lang.String className) throws java.lang.ClassNotFoundException, java.lang.IllegalStateException
className
- The name of the class to add.java.lang.IllegalStateException
- if startProtocolDefn() wasn't called
before calling this method.protected void addCapsule(java.lang.String className, VersionString versionID, PermissionSet ps) throws java.lang.ClassNotFoundException, java.lang.IllegalStateException
The PermissionSet that gets passed to this method describes the properties of this Capsule type. The propagation properties, encoded as CountPermission objects, are:
className
- The name of the class to add.versionID
- The optional VersionString to use when computing the
hash id of the class.ps
- The PermissionSet describing the propagation properties of
Capsule classes.java.lang.IllegalStateException
- if startProtocolDefn() wasn't called
before calling this method.Capsule
protected void addCapsule(java.lang.String className, PermissionSet ps) throws java.lang.ClassNotFoundException, java.lang.IllegalStateException
className
- The name of the class to add.requiredPermissions
- The PermissionSet describing the propagation
properties of Capsule classes.java.lang.IllegalStateException
- if startProtocolDefn() wasn't called
before calling this method.addCapsule(String, VersionString, PermissionSet)
protected void addCompanion(CompanionProtocol protocol) throws java.lang.IllegalStateException
protocol
- A companion protocol.java.lang.IllegalStateException
- if startProtocolDefn() wasn't called
before calling this method.protected final void setSession(java.lang.String className) throws java.lang.ClassNotFoundException, java.lang.IllegalStateException
className
- The name of the ProtocolSession class to use.java.lang.IllegalStateException
- if startProtocolDefn() wasn't called
before calling this method.protected final void setBootStrap(java.lang.String className, PermissionSet ps) throws java.lang.ClassNotFoundException, java.lang.IllegalStateException
className
- The name of the class to add.requiredPermissions
- The PermissionSet describing the propagation
properties of Capsule classes.java.lang.IllegalStateException
- if startProtocolDefn() wasn't called
before calling this method.public final int getByteArrayLength()
public final void toByteArray(XdrByteArray xdr)
xdr
- An XdrByteArray large enough to hold the flattened version
of this Protocol.public final byte[] toByteArray()
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
|
Bees v0.5.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |