|
SalesPoint Framework v3.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Capabilities guard activities and restrict the users' options in an application.
A capability is an immutable object associated with a user, that either grants or denies the user a specific service. In an ideal object oriented world each service that is guarded by a specific capability will only be reachable via a method in the capability object. Different implementations (achieved via subclasses) would then either perform the service or take suitable measures to indicate denial.
To achieve immutability it is vital that you do not offer any methods that allow
for the state of the capability to be manipulated directly after the object has been
created. Capabilities of different state shall only be achieved via the
getToggled()
method.
For convenience you may want to subclass AbstractCapability
rather than implementing
Capability
directly, as that already takes care of the name management.
User
,
UserManager
Method Summary | |
String |
getDisplayName()
Get the display name for this capability according to the default locale. |
String |
getDisplayName(Locale l)
Get the display name for this capability according to a locale. |
String |
getName()
Get the name of this capability. |
Capability |
getToggled()
Return a capability that is the inverse to this one. |
boolean |
isGranted()
Get information whether this capability grants or denies the right for the activity it guards. |
Method Detail |
public String getName()
public String getDisplayName()
The display name will be used when communicating with the user about the capability.
public String getDisplayName(Locale l)
The display name will be used when communicating with the user about the capability.
l
- the locale according to which the display name is to be returned.
public boolean isGranted()
This is only informational and should not be used to actually implement the service of guarding activities. Guarding should always be achieved by making the activity only available via methods of the Capability object.
public Capability getToggled()
This is the only way to toggle the Grant State of a capability as they are immutable
ojects. Immutability means in this case that you cannot simply say
capability.toggleGranted()
but have to create a new object to achieve
the purpose. It may help to think of a capability as something like an opera ticket
that is given to someone and must be explicitly demanded back to invalidate it.
|
SalesPoint Framework v3.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |