|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jcama.Scope
public final class Scope
Provides scoping and communication operations to agents. It implements all the basic Linda operations and a set of additional tuple space operations. Along with data input/output through tuple space this class provide interface to CAMA scoping mechanism.
Field Summary | |
---|---|
protected java.io.ByteArrayOutputStream |
buffer
|
static int |
BUFFER_SIZE_INIT
|
protected int |
contextNum
|
protected int |
eKey
|
protected java.lang.String |
litName
|
protected Location |
location
|
protected ScopeName |
name
|
Method Summary | |
---|---|
Scope |
CreateScope(java.lang.String name,
ScopeDescr descr)
Creates a new scope with the given scope requirements. |
void |
DeleteScope()
Deletes a scope. |
void |
Disengage()
Disconnect from the location |
void |
gd(int roleid,
java.lang.String templ)
|
void |
gd(int roleid,
Templ templ)
|
ScopeName |
GetScopes(CamaKey scopeType)
Returns all the public sub-scopes of the curent scope |
void |
gr(int roleid,
java.lang.String templ)
|
void |
gr(int roleid,
Templ templ)
|
void |
gw(int roleid,
java.lang.String templ)
|
void |
gw(int roleid,
Templ templ)
|
Tuple |
in(java.lang.String templ)
|
Tuple |
in(Templ templ)
Reads and removes a tuple from the scope, blocks and waits if there are no matching tuples |
Tuple[] |
ina(Templ templ)
Reads and removes all the matching tuples from the scope, blocks and waits until there is at least one matching tuple |
Tuple |
inn(Templ templ)
Reads and removes a fresh tuple from the scope, blocks and waits if there are no fresh matching tuples |
Tuple |
inp(Templ templ)
Reads and removes a tuple from the scope, returns an empty tuple if there are no matching tuples available immediately |
Tuple[] |
inpa(Templ templ)
Reads and removes all the matching tuples from the scope, returns an empty tuple list if there are no matching tuples available immediately |
Tuple |
inpn(Templ templ)
Reads and removes a fresh tuple from the scope, returns an empty tuple if there are no fresh matching tuples available immediately |
Scope |
JoinScope(ScopeName name,
int roleid,
CamaKey key)
Joins a scope with the specified role. |
void |
LeaveScope()
Leaves the current scope |
void |
out(Tuple tuple)
Outputs a single tuple |
void |
outa(Tuple[] tuple_list)
Atomically outputs a list of tuples |
void |
pd(int roleid,
java.lang.String templ)
|
void |
pd(int roleid,
Templ templ)
|
void |
pr(int roleid,
java.lang.String templ)
|
void |
pr(int roleid,
Templ templ)
|
void |
PutScope()
Make the curent scope public. |
void |
pw(int roleid,
java.lang.String templ)
|
void |
pw(int roleid,
Templ templ)
|
void |
raise(Tuple t,
AgentException exc)
Exception raising Throws an exception E to the producer of a tuple t. |
Tuple |
rd(Pred pr)
|
Tuple |
rd(java.lang.String templ)
|
Tuple |
rd(Templ templ)
Reads a tuple without removing it from the scope, blocks and waits if there are no matching tuples |
Tuple[] |
rda(Templ templ)
Reads all the matching tuples without removing them from the scope, blocks and waits until there is at least one matching tuple |
Tuple |
rdn(Templ templ)
Reads a fresh tuple (such that is produced at the same time or after the last read tuple) without removing it from the scope, blocks and waits if there are no fresh matching tuples |
Tuple |
rdp(Templ templ)
Reads a tuple without removing it from the scope, returns an empty tuple if there are no matching tuples available immediately |
Tuple[] |
rdpa(Templ templ)
Reads all the matching tuples without removing them from the scope, returns an empty tuple list if there are no matching tuples available immediately |
Tuple |
rdpn(Templ templ)
Reads a fresh tuple without removing it from the scope, returns an empty tuple if there are no fresh matching tuples available immediately |
ScopeName |
scopeName()
Returns literal name of the scope. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int BUFFER_SIZE_INIT
protected Location location
protected java.io.ByteArrayOutputStream buffer
protected java.lang.String litName
protected int contextNum
protected ScopeName name
protected int eKey
Method Detail |
---|
public ScopeName scopeName()
public void Disengage() throws CamaException
CamaException
public Scope CreateScope(java.lang.String name, ScopeDescr descr) throws CamaException
This operation requests CAMA server middleware to create a new sub-scope of the current scope. The creating agent becomes owner of the scope and can later detroy with DeleteScope opeartion. A scope is created in private mode, that is it is not visible by to other agents. Creating agent may make the scope public with PutScope operation.
Sample usage:
// Create scope description with the single role
ScopeDescr sd = new ScopeDescr(2, new CamaKey("Messageboard")).add(new ScopeRoleRest(1, 0, 100), new CamaKey("Client"));
// Create new scope
Scope ms = sc.CreateScope("MyBoard", sd);
name
- arbitrary string. Literal name of the scope. May be used to distinguish between several scopes
of the same typedescr
- the scope requirements structure.
CamaExceptionNoAccess
- this exception is thrown if the agent has no rights to create a sub-scope in a given scope
(e.g. it is not a member of that scope)
CamaExceptionInvalidReqs
- CAMA server may reject scope create request if it finds that scope requirements are
malformed or unconsistent
CamaException
ScopeDescr, DeleteScope, PutScope, JoinScope
public void DeleteScope() throws CamaException
ms.DeleteScope();
CamaExceptionNotInScope
- if there is no current scope associated with the agent
CamaExceptionBadName
- if the name of the scope to delete is invalid (e.g. scope is was already removed)
CamaExceptionNoPriviledges
- when the requesting agent is not the owner of the scope
CamaException
public Scope JoinScope(ScopeName name, int roleid, CamaKey key) throws CamaException
name
- canonical scope nameroleid
- id of role to take in the scopekey
- associated with the role
CamaExceptionInvalidRole
- the supplied role id is invalid for the scope
CamaExceptionInvalidRoleKey
- the supplied role is not compatible with the scope (key mismatch)
CamaExceptionNoAccess
- if the calling agent is not part of the parent scope of the scope to join.
CamaExceptionBadName
- if the supplied scope name is invalid
CamaExceptionClosed
- if the scope cannot accept any more agent
CamaExceptionNoRoles
- when there no vacant places for the requested role
CamaException
public void LeaveScope() throws CamaException
CamaException
public ScopeName GetScopes(CamaKey scopeType) throws CamaException
CamaException
public void PutScope() throws CamaException
CamaException
public void out(Tuple tuple) throws CamaException
CamaException
public void outa(Tuple[] tuple_list) throws CamaException
CamaException
public void gr(int roleid, Templ templ) throws CamaException
CamaException
public void gw(int roleid, Templ templ) throws CamaException
CamaException
public void gd(int roleid, Templ templ) throws CamaException
CamaException
public void pr(int roleid, Templ templ) throws CamaException
CamaException
public void pw(int roleid, Templ templ) throws CamaException
CamaException
public void pd(int roleid, Templ templ) throws CamaException
CamaException
public void gr(int roleid, java.lang.String templ) throws CamaException
CamaException
public void gw(int roleid, java.lang.String templ) throws CamaException
CamaException
public void gd(int roleid, java.lang.String templ) throws CamaException
CamaException
public void pr(int roleid, java.lang.String templ) throws CamaException
CamaException
public void pw(int roleid, java.lang.String templ) throws CamaException
CamaException
public void pd(int roleid, java.lang.String templ) throws CamaException
CamaException
public Tuple rd(Templ templ) throws CamaException
CamaException
public Tuple rd(java.lang.String templ) throws CamaException
CamaException
public Tuple rd(Pred pr) throws CamaException
CamaException
public Tuple rdp(Templ templ) throws CamaException
CamaException
public Tuple in(Templ templ) throws CamaException
CamaException
public Tuple in(java.lang.String templ) throws CamaException
CamaException
public Tuple inp(Templ templ) throws CamaException
CamaException
public Tuple rdn(Templ templ) throws CamaException
CamaException
public Tuple rdpn(Templ templ) throws CamaException
CamaException
public Tuple inn(Templ templ) throws CamaException
CamaException
public Tuple inpn(Templ templ) throws CamaException
CamaException
public Tuple[] rda(Templ templ) throws CamaException
CamaException
public Tuple[] rdpa(Templ templ) throws CamaException
CamaException
public Tuple[] inpa(Templ templ) throws CamaException
CamaException
public Tuple[] ina(Templ templ) throws CamaException
CamaException
public void raise(Tuple t, AgentException exc) throws CamaException, jCamaException
CamaException
jCamaException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |