|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjawiro.Role
public class Role
From the modeling perspective, roles are different types of
behavior that different types of entities can perform.
Roles are modeled by the Role class in JAWIRO.
Definition of the basic features of roles varies slightly among different researchers. According to our experience, the basic features of a role model should contain the following:
These basic features do not cover all that can be done with roles. JAWIRO implements the following extended features of roles as well:
Actor,
AggregateRole| Field Summary | |
|---|---|
java.lang.Class |
myClass
Keeps the type name to eliminate the need of calling the costly Object.getClass() method. |
java.lang.String |
myClassName
Keeps the type name to eliminate the need of calling the costly Object.getClass().getName() method. |
| Constructor Summary | |
|---|---|
Role()
Default constructor. |
|
| Method Summary | |
|---|---|
boolean |
addRole(Role aNewRole)
Adds a new role to this object if it will not cause any ambiguities or role binding anomalies. |
java.lang.Object |
as(java.lang.Class roleClass)
The role switching command for regular roles. |
java.lang.Object |
as(java.lang.Class roleClass,
java.lang.String identifier)
The role switching command for aggregate roles. |
java.lang.Object |
as(java.lang.String className)
The role switching command for regular roles. |
java.lang.Object |
as(java.lang.String className,
java.lang.String identifier)
The role switching command for aggregate roles. |
java.lang.Object |
bringLocalMember(java.lang.String name)
Method for accessing a member field of a role object. |
java.lang.Object |
bringMember(java.lang.String name)
Method for member field access without referring its owner. |
boolean |
canDelegate(Role aRole)
Checks whether a given role object exists in the same role hierarchy with this object. |
boolean |
canSwitch(java.lang.Class roleClass)
Checks whether this object has the given role type. |
boolean |
canSwitch(java.lang.Class roleClass,
java.lang.String identifier)
Checks whether this object has the given role type. |
boolean |
canSwitch(java.lang.String className)
Checks whether this object has the given role type. |
boolean |
canSwitch(java.lang.String className,
java.lang.String identifier)
Checks whether this object has the given role type. |
void |
dominateSearch(boolean dominate)
Method for determining this object as dominant. |
java.lang.Object |
executeLocalMethod(java.lang.String name,
java.lang.Object... parameters)
Method for executing a member method of a Role object. |
java.lang.Object |
executeMethod(java.lang.String name,
java.lang.Object... parameters)
Method for member method access without referring its owner. |
Actor |
getActor()
Method for accessing the root of the role hierarchy, e.g. the modeled real-world entity. |
java.lang.String |
getClassName()
Method for finding the class name of an object. |
int |
getDepth()
Returns how deep this JAWIRO object resides in its role hierarchy. |
java.lang.String |
getOwnerClassName()
Returns the class name of the owner of this role. |
jawiro.RoleList |
getRoleList()
Used for internal operations of JAWIRO. |
java.lang.Object |
getSelf()
Gives access to the self member which is used
in the delegation mechanism. |
boolean |
isDominant()
Method for checking whether this object is dominant or not. |
boolean |
isReadableWhileSuspended()
Normally, suspended roles cannot be used with the commands of JAWIRO API. |
boolean |
isSuspended()
Method for checking whether this role is suspended or not. |
java.lang.Object |
playedBy()
Method for accessing this role's owner. |
boolean |
receiveRole(Role r)
Although this method is public, it belongs
to the inner workings of JAWIRO and a flagging mechanism
prevents its usage from outside of the jawiro
package. |
boolean |
resign()
Permanently removes this role from the role hierarchy. |
boolean |
resume()
Resumes a suspended role if a reference to this role exists or the reference can be obtained by role switching. |
void |
setReadableWhileSuspended(boolean isReadable)
Normally, suspended roles cannot be used with the commands of JAWIRO API. |
boolean |
suspend()
Temporarily suspends a role. |
boolean |
transfer(RoleInterface newOwner)
Transfers this role, without dropping its sub roles, to another owner. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public final java.lang.String myClassName
Object.getClass().getName() method.
public final java.lang.Class myClass
Object.getClass() method.
| Constructor Detail |
|---|
public Role()
| Method Detail |
|---|
public java.lang.Object playedBy()
null.
null,
as described above.public boolean addRole(Role aNewRole)
addRole in interface RoleInterfaceaNewRole - The new role to be added.
true if this operation is successful.RoleInterface.addRole(jawiro.Role),
ConstraintStrategy,
ConstraintStrategy.approveAddRole(String,String)public boolean canDelegate(Role aRole)
canDelegate in interface RoleInterfaceaRole - The role object whose existence to be checked.
true if aRole exists in this hierarchy.RoleInterface.canDelegate(jawiro.Role)public boolean canSwitch(java.lang.String className)
canSwitch in interface RoleInterfaceclassName - The fully qualified class name of a role type
of whose existence is to be checked.
For example, a customer role defined by the
Customer class of package examples,
the correct name is "examples.Customer"
true if this object is currently playing the
given role type.RoleInterface.canSwitch(java.lang.String)public boolean canSwitch(java.lang.Class roleClass)
canSwitch in interface RoleInterfaceroleClass - The Class object representing the
role type of whose existence is to be checked.
true if this object is currently playing the
given role type.RoleInterface.canSwitch(java.lang.Class)
public boolean canSwitch(java.lang.String className,
java.lang.String identifier)
canSwitch in interface RoleInterfaceclassName - The fully qualified class name of an aggregate
role type of whose existence is to be checked.
For example, a customer role defined by the
Customer class of package examples,
the correct name is "examples.Customer"identifier - The identifier of the aggregate role
of whose existence is to be checked.
true if this object is currently playing
the given role type.RoleInterface.canSwitch(java.lang.String, java.lang.String)
public boolean canSwitch(java.lang.Class roleClass,
java.lang.String identifier)
canSwitch in interface RoleInterfaceroleClass - The Class object representing the
role type of whose existence is to be checked.identifier - The identifier of the aggregate role
of whose existence is to be checked.
true if this object is currently playing
the given role type.RoleInterface.canSwitch(java.lang.Class, java.lang.String)public java.lang.Object as(java.lang.String className)
as in interface RoleInterfaceclassName - The fully qualified class name of the
'destination' role. For example, a customer role defined by the
Customer class of package examples,
the correct name is "examples.Customer"
RoleInterface.as(java.lang.String)public java.lang.Object as(java.lang.Class roleClass)
as in interface RoleInterfaceroleClass - The Class object representing
the 'destination' role.
RoleInterface.as(java.lang.Class)
public java.lang.Object as(java.lang.String className,
java.lang.String identifier)
as in interface RoleInterfaceclassName - The fully qualified class name of the
'destination' role. For example, a customer role defined by the
Customer class of package examples,
the correct name is "examples.Customer"identifier - The identifier of the 'destination'
aggregate role
RoleInterface.as(java.lang.String, java.lang.String)
public java.lang.Object as(java.lang.Class roleClass,
java.lang.String identifier)
as in interface RoleInterfaceroleClass - The Class object representing the
type of the 'destination' aggregate role.identifier - The identifier of the 'destination'
aggregate role
RoleInterface.as(java.lang.Class, java.lang.String)public boolean resign()
public boolean suspend()
Role.resume or
Actor.resumeRole.
A constraint manager can prevent the suspension
if its rules dictate so.
Actor.suspendRole(String),
ConstraintStrategy,
ConstraintStrategy#approveSuspend(String, String)public boolean isSuspended()
true if this role is suspended.public boolean resume()
ConstraintStrategy,
ConstraintStrategy#approveResume(String, String),
Actor.resumeRole(String)public jawiro.RoleList getRoleList()
jawiro.RoleList instance, which
represents the list of the child roles of this role object.
However, all member fields of jawiro.RoleList
are private and all of its member methods are only visible
for the jawiro package.
public boolean transfer(RoleInterface newOwner)
A role object is not added to a hierarchy where another role object of the same type already exists. In case of aggregate roles, one is not added to a hierarchy where another role object having both the same type and identifier already exists. However, the transfer command does not check for these constraints for subroles of the object that is to be transferred.
newOwner -
public boolean receiveRole(Role r)
public, it belongs
to the inner workings of JAWIRO and a flagging mechanism
prevents its usage from outside of the jawiro
package.
public void dominateSearch(boolean dominate)
dominateSearch in interface RoleInterfacedominate - Determines whether this participant is dominant or not.RoleInterface.dominateSearch(boolean)public boolean isDominant()
isDominant in interface RoleInterfacetrue is this object is dominant.RoleInterface.isDominant()public java.lang.Object bringMember(java.lang.String name)
bringMember in interface RoleInterfacename - The name of the requested field.
RoleInterface.bringMember(java.lang.String)public java.lang.Object bringLocalMember(java.lang.String name)
bringLocalMember in interface RoleInterfacename - The name of the requested field.
RoleInterface.bringLocalMember(java.lang.String)public int getDepth()
getDepth in interface RoleInterfaceRoleInterface.getDepth()
public java.lang.Object executeMethod(java.lang.String name,
java.lang.Object... parameters)
executeMethod in interface RoleInterfacename - The name of the requested method.parameters - The parameters for the requested method.
RoleInterface.executeMethod(java.lang.String, java.lang.Object[])
public java.lang.Object executeLocalMethod(java.lang.String name,
java.lang.Object... parameters)
Role object.
executeLocalMethod in interface RoleInterfacename - The name of the requested field.parameters - The parameters for the requested method.
RoleInterface.executeLocalMethod(java.lang.String, java.lang.Object[])public java.lang.String getClassName()
Method for finding the class name of an object.
getClassName in interface RoleInterfacepublic java.lang.Object getSelf()
Gives access to the self member which is used
in the delegation mechanism.
getSelf in interface RoleInterfaceActor.enableDelegation(boolean)public Actor getActor()
null.
public java.lang.String getOwnerClassName()
RoleInterface
getOwnerClassName in interface RoleInterfacepublic boolean isReadableWhileSuspended()
Normally, suspended roles cannot be used with the commands of JAWIRO API. Each role can be thought as a responsibility and a suspended responsibility should not be used. Otherwise, it would be either 'illegal' or 'abnormal'.
However, one may need to read a member variable or
execute a method of a role which will not cause anything
'illegal' or 'abnormal', although it is not allowed by
default.
Therefore, this rule can be overridden. This method
returns true if it is done so,
false otherwise.
Role checking controls (canSwitch and canDelegate)
will return false and member variable/method
access calls (Role.bringMember and Role.executeMethod)
will remain to be inaccessible, regardless of that
assignment.
setReadableWhileSuspended(boolean)public void setReadableWhileSuspended(boolean isReadable)
Normally, suspended roles cannot be used with the commands of JAWIRO API. Each role can be thought as a responsibility and a suspended responsibility should not be used. Otherwise, it would be either 'illegal' or 'abnormal'.
However, one may need to read a member variable or execute a method of a role which will not cause anything 'illegal' or 'abnormal', although it is not allowed by default.
In order to override the enforcement described above,
and to let someone to switch a suspended role,
assign true to the isReadable
parameter of this method.
Role checking controls (canSwitch and canDelegate)
will return false, regardless of that
assignment. Moreover, member variable and method access
calls (Role.bringMember and Role.executeMethod) will
remain to be inaccessible while this role is suspended.
The default behaviour is to disallow role switching while the role is suspended.
isReadable - Determines whether this role can be
accessed via role switching while it is suspended.isReadableWhileSuspended()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||