|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
public interface RoleInterface
The methods of RoleInterface represent the common behaviour of the
participants of a role hierarchy, namely the Actor and
the Role objects.
| 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 JAWIRO 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 aggregate role type having a particular identifier. |
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 aggregate role type having a particular identifier. |
void |
dominateSearch(boolean dominate)
Method for determining a participant of a role hierarchy as dominant. |
java.lang.Object |
executeLocalMethod(java.lang.String name,
java.lang.Object... parameters)
Method for executing a member method of a JAWIRO object. |
java.lang.Object |
executeMethod(java.lang.String name,
java.lang.Object... parameters)
Method for member method access without referring its owner. |
java.lang.String |
getClassName()
Method for finding the class name of an object. |
int |
getDepth()
Method for finding how deep a participant in a role hierarchy resides. |
java.lang.String |
getOwnerClassName()
Returns the class name of the owner of this role. |
java.lang.Object |
getSelf()
Gives access to the self member which is used
for making the use of the delegation mechanism possible. |
boolean |
isDominant()
Method for checking whether a participant of a role hierarchy is dominant or not. |
| Method Detail |
|---|
boolean addRole(Role aNewRole)
The following precautions are hard-coded into the role model in order to prevent abnormal role bindings:
JAWIRO also allows users to take additional precautions by defining a constraint manager, which extends the ConstraintStrategy interface.
aNewRole - The new role to be added.
true if this operation is successful.ConstraintStrategyboolean canDelegate(Role aRole)
aRole - The role object whose existence to be checked.
true if aRole exists in this hierarchy.boolean canSwitch(java.lang.String className)
It is a wise move to check the existence of a role before attempting to switch that role, especially in persistent systems where keeping track of the participants of a role hierarchy gets harder in the long term.
Consequent checks for the same role type does not bring any
overhead as the latest query and its result are remembered.
Moreover, all variants of the as methods first
check this 'cache' of size 1.
Use canSwitch(String, String) or
canSwitch(Class, String) for checking the
existence of an aggregate role.
canSwitch(Class) returns the first encountered
instance (usually the least evolved) if it's used for checking
for aggregate roles.
className - 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.canSwitch(Class),
canSwitch(String, String),
canSwitch(Class, String)boolean canSwitch(java.lang.Class roleClass)
It is a wise move to check the existence of a role before attempting to switch that role, especially in persistent systems where keeping track of the participants of a role hierarchy gets harder in the long term.
Consequent checks for the same role type does not bring any
overhead as the latest query and its result are remembered.
Moreover, all variants of the as methods first
check this 'cache' of size 1.
Use canSwitch(String, String) or
canSwitch(Class, String) for checking the
existence of an aggregate role.
canSwitch(Class) returns the first encountered
instance (usually the least evolved) if it's used for checking
for aggregate roles.
roleClass - 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.canSwitch(String),
canSwitch(String, String),
canSwitch(Class, String)
boolean canSwitch(java.lang.String className,
java.lang.String identifier)
It is a wise move to check the existence of a role before attempting to switch that role, especially in persistent systems where keeping track of the participants of a role hierarchy gets harder in the long term. As multiple instances of an aggregate role type can be played simultaneously, it becomes even more important to 'Ask first, switch later'.
Consequent checks for the same role type does not bring any
overhead as the latest query and its result are remembered.
Moreover, all variants of the as methods first
check this 'cache' of size 1.
className - 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.canSwitch(String),
canSwitch(Class),
canSwitch(Class, String)
boolean canSwitch(java.lang.Class roleClass,
java.lang.String identifier)
It is a wise move to check the existence of a role before attempting to switch that role, especially in persistent systems where keeping track of the participants of a role hierarchy gets harder in the long term. As multiple instances of an aggregate role type can be played simultaneously, it becomes even more important to 'Ask first, switch later'.
Consequent checks for the same role type does not bring any
overhead as the latest query and its result are remembered.
Moreover, all variants of the as methods first
check this 'cache' of size 1.
roleClass - 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.canSwitch(String),
canSwitch(Class),
canSwitch(String, String)java.lang.Object as(java.lang.String className)
Any of the roles of an object (e.g. the destination role)
can be accessed from a reference to any other role
(e.g. the source role) by using the variants of
the as methods.
It is usually better to check the existence of a role before
attempting to switch that role. This check does not create any
overhead on method execution. See canSwitch
methods for more details.
Use as(String, String) or
as(Class, String) for switching to aggregate roles.
as(String) returns the first encountered instance
(usually the least evolved) if it's used for switching to an
aggregate role.
className - 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"
canSwitch(String),
as(Class),
as(String, String),
as(Class, String)java.lang.Object as(java.lang.Class roleClass)
Any of the roles of an object (e.g. the destination role)
can be accessed from a reference to any other role
(e.g. the source role) by using the variants of
the as methods.
It is usually better to check the existence of a role before
attempting to switch that role. This check does not create any
overhead on method execution. See canSwitch
methods for more details.
Use as(String, String) or
as(Class, String) for switching to aggregate roles.
as(Class) returns the first encountered instance
(usually the least evolved) if it's used for switching to an
aggregate role.
roleClass - The Class object representing
the 'destination' role.
canSwitch(Class),
as(String),
as(String, String),
as(Class, String)
java.lang.Object as(java.lang.String className,
java.lang.String identifier)
Any of the roles of an object (e.g. the destination role)
can be accessed from a reference to any other role
(e.g. the source role) by using the variants of
the as methods.
It is usually better to check the existence of a role before
attempting to switch that role. This check does not create any
overhead on method execution. See canSwitch
methods for more details.
className - 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
canSwitch(String, String)
java.lang.Object as(java.lang.Class roleClass,
java.lang.String identifier)
Any of the roles of an object (e.g. the destination role)
can be accessed from a reference to any other role
(e.g. the source role) by using the variants of
the as methods.
It is usually better to check the existence of a role before
attempting to switch that role. This check does not create any
overhead on method execution. See canSwitch
methods for more details.
roleClass - The Class object representing the
type of the 'destination' aggregate role.identifier - The identifier of the 'destination'
aggregate role
canSwitch(Class, String)java.lang.Object bringMember(java.lang.String name)
Method for member field access without referring its owner.
With JAWIRO, it is possible to access a member field
of any participant of a role hierarchy, without explicitly
referencing to the object having that field.
If there are multiple objects in the role hierarchy with
member fields having the same name, the most evolved
participant's field is returned. Therefore, the requested
field is searched in the entire hierarchy.
However, this behaviour can be altered by determining some
participants as dominant.
As a result, the bringMember and
executeMethod methods make modeling the
evolving behaviour of dynamic objects easier.
Limitations caused by the Java Reflection API:
name - The name of the requested field.
dominateSearch( boolean ),
executeMethod( String, Object... ),
bringLocalMember( String )java.lang.Object bringLocalMember(java.lang.String name)
Method for accessing a member field of a JAWIRO object.
bringLocalMember and
executeLocalMethod methods ease the use of the
multiple object level inheritance capability of JAWIRO.
When a sub role can be owned by objects of different types,
the type of the owner can only be determined in runtime.
However, the programmer needs a uniform way of access to the
owner, regardless of its type. Instead of creating the owner
types via class level inheritance from the same type,
or instead of implementing a common custom interface in the
owner types, one can acquire the owner of the sub role in
runtime with the Role.getOwner method
and then use the bringLocalMember method.
name - The name of the requested field.
executeLocalMethod( String, Object... ),
bringMember( String )
java.lang.Object executeMethod(java.lang.String name,
java.lang.Object... parameters)
Method for member method access without referring its owner.
With JAWIRO, it is possible to execute a member method
of any participant of a role hierarchy, without explicitly
referencing to the object having that method.
If there are multiple objects in the role hierarchy with
member methods having the same name, the most evolved
participant's method is executed. Therefore, the requested
method is searched in the entire hierarchy.
However, this behaviour can be altered by determining some
participants as dominant.
As a result, the executeMethod and
bringMember methods make modeling the
evolving behaviour of dynamic objects easier.
Methods to be executed this way should not contain any
primitive type in its signature. This is caused by the
reflection API as method signatures are calculated by
Class.getName which uses primitive type names,
while the methods are executed by Method.Invoke
which requires wrappers instead of primitive types.
As a result, methods containing primitive parameters
cannot be reached via this command.
name - The name of the requested method.parameters - The parameters for the requested method.
dominateSearch( boolean ),
bringMember( String ),
executeLocalMethod( String, Object... )
java.lang.Object executeLocalMethod(java.lang.String name,
java.lang.Object... parameters)
Method for executing a member method of a JAWIRO object.
executeLocalMethod and
bringLocalMember methods ease the use of the
multiple object level inheritance capability of JAWIRO.
When a sub role can be owned by objects of different types,
the type of the owner can only be determined in runtime.
However, the programmer needs a uniform way of access to the
owner, regardless of its type. Instead of creating the owner
types via class level inheritance from the same type,
or instead of implementing a common custom interface in the
owner types, one can acquire the owner of the sub role in
runtime with the Role.getOwner method
and then use the executeLocalMethod method.
Methods to be executed this way should not contain any
primitive type in its signature. This is caused by the
reflection API as method signatures are calculated by
Class.getName which uses primitive type names,
while the methods are executed by Method.Invoke
which requires wrappers instead of primitive types.
As a result, methods containing primitive parameters
cannot be reached via this command.
name - The name of the requested field.parameters - The parameters for the requested method.
executeMethod( String, Object... ),
bringMember( String )void dominateSearch(boolean dominate)
Method for determining a participant of a role hierarchy as dominant.
With JAWIRO, it is possible to access a member field
or to execute a member method of any participant of a role
hierarchy, without explicitly referencing to the object having
that member method or field.
Normally, JAWIRO uses the most evolved role object's member
method or field when executeMethod and
bringMember are called. Setting a member of a
role hierarchy as dominant alters this behaviour.
The rules of dominance are as follows:
Role object is dominant, always this
object's members are used, instead of the most evolved role's.
Role
objects, the most evolved one among these objects is used.
Actor object is dominant, always this
object's members are used, regardless of how many other
dominant Role objects exist in this hierarchy.
As a result, dominateSearch method adds more
flexibility on top of executeMethod and
bringMember methods when modeling the
evolving behaviour of dynamic objects.
dominate - Determines whether this participant is dominant or not.executeMethod( String, Object... ),
bringMember( String )boolean isDominant()
Method for checking whether a participant of a role hierarchy is dominant or not.
true is this object is dominant.dominateSearch( boolean )int getDepth()
Method for finding how deep a participant in a role hierarchy resides.
java.lang.String getClassName()
Method for finding the class name of an object.
java.lang.Object getSelf()
Gives access to the self member which is used
for making the use of the delegation mechanism possible.
Actor.enableDelegation(boolean)java.lang.String getOwnerClassName()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||