|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.wicketstuff.security.swarm.actions.SwarmActionFactory
public class SwarmActionFactory
Default implementation of an action factory. It handles access, inherit, render and enable actions. Because actions are immutable and in order to improve performance, generated actions are cached.
| Nested Class Summary | |
|---|---|
protected static class |
SwarmActionFactory.ImpliesOtherAction
Any class that implies another action. |
| Field Summary | |
|---|---|
protected static int |
maxAssingableAction
Maximum power of 2 that can be used to assign to an action. |
| Constructor Summary | |
|---|---|
SwarmActionFactory(Object key)
Registers the default actions: access, inherit, render and enable. |
|
| Method Summary | |
|---|---|
protected void |
appendActionString(org.apache.wicket.util.string.AppendingStringBuffer buff,
int actions,
int waspAction)
Appends the string value of the action only if the actions imply the waspAction |
protected String |
buildActionString(int actions)
Builds a logically ordered comma separated string of all the actions this permission has. |
protected void |
cacheAction(Integer actions,
SwarmAction ja)
Caches an action under its int form. |
protected void |
cacheAction(String name,
SwarmAction action)
Caches an action under its string form. |
protected String |
convertWicket2Wasp(String name)
Renames build in wicket actions to there wasp counterpart. |
void |
destroy()
Clears registration and cached values. |
org.wicketstuff.security.actions.WaspAction |
getAction(org.apache.wicket.authorization.Action action)
|
SwarmAction |
getAction(Class<? extends org.wicketstuff.security.actions.WaspAction> waspActionClass)
|
SwarmAction |
getAction(int actions)
Returns an action based on its int value. |
org.wicketstuff.security.actions.WaspAction |
getAction(String actions)
|
protected SwarmAction |
getCachedAction(int actions)
Returns a cached action. |
protected SwarmAction |
getCachedAction(String name)
Returns a cached action. |
protected Object |
getFactoryKey()
Gets key. |
int |
getNumberOfRegisteredClasses()
Returns the number of registered classes. |
List<org.wicketstuff.security.actions.WaspAction> |
getRegisteredActions()
|
protected boolean |
implies(int actions,
int action)
Check if the action is available in the actions. |
protected int |
nextPowerOf2()
The next action value. |
protected int |
parseActions(String actions)
Parses a comma separated String containing actions. |
SwarmAction |
register(Class<? extends org.wicketstuff.security.actions.WaspAction> waspActionClass,
String name)
|
protected SwarmAction |
register(Class<? extends org.wicketstuff.security.actions.WaspAction> waspActionClass,
SwarmAction action)
Registers a new action. |
protected String |
valueOf(Integer action)
Returns the registered string value of the given action. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final int maxAssingableAction
| Constructor Detail |
|---|
public SwarmActionFactory(Object key)
key - using this key the factory registers itself to the Actions object.| Method Detail |
|---|
public org.wicketstuff.security.actions.WaspAction getAction(org.apache.wicket.authorization.Action action)
getAction in interface org.wicketstuff.security.actions.WaspActionFactoryWaspActionFactory.getAction(org.apache.wicket.authorization.Action)public org.wicketstuff.security.actions.WaspAction getAction(String actions)
getAction in interface org.wicketstuff.security.actions.ActionFactoryactions - empty string means AccessActionFactory.getAction(String)
protected final void cacheAction(String name,
SwarmAction action)
name - action - protected final SwarmAction getCachedAction(String name)
name -
public SwarmAction getAction(int actions)
actions -
IllegalArgumentException - if no action can be formed based on the input
protected final void cacheAction(Integer actions,
SwarmAction ja)
actions - ja - protected final SwarmAction getCachedAction(int actions)
actions -
protected final String valueOf(Integer action)
action - the internal value of the action
protected String buildActionString(int actions)
actions - the internal action value
protected final void appendActionString(org.apache.wicket.util.string.AppendingStringBuffer buff,
int actions,
int waspAction)
buff - where the string will be appended to.actions - the available actionswaspAction - the action it should imply in order to append the string
protected final boolean implies(int actions,
int action)
actions - the actions that might contain actionaction - the action we check for in actions
protected int parseActions(String actions)
actions -
IllegalArgumentException - if (one of) the action(s) is not recognized.public SwarmAction getAction(Class<? extends org.wicketstuff.security.actions.WaspAction> waspActionClass)
getAction in interface org.wicketstuff.security.actions.ActionFactoryActionFactory.getAction(java.lang.Class)
public SwarmAction register(Class<? extends org.wicketstuff.security.actions.WaspAction> waspActionClass,
String name)
throws org.wicketstuff.security.actions.RegistrationException
register in interface org.wicketstuff.security.actions.ActionFactoryorg.wicketstuff.security.actions.RegistrationExceptionActionFactory.register(java.lang.Class,
java.lang.String)public final int getNumberOfRegisteredClasses()
protected final int nextPowerOf2()
Integer.MAX_VALUE
protected final String convertWicket2Wasp(String name)
name - the name of the action
protected final SwarmAction register(Class<? extends org.wicketstuff.security.actions.WaspAction> waspActionClass,
SwarmAction action)
throws org.wicketstuff.security.actions.RegistrationException
SwarmAction#SwarmAction(int, String, ActionFactory). Example:
register(Enable.class, new ImpliesReadAction(nextPowerOf2(), "enable", this));
class ImpliesReadAction extends SwarmAction
{
public ImpliesReadAction(int actions, String name, ActionFactory factory)
{
super(actions
| ((SwarmAction)factory.getAction(org.wicketstuff.security.actions.Render.class))
.actions(), name);
}
}
Note all actions registered in this way must use nextPowerOf2() and then immediately register
the action to preserve consistency.
waspActionClass - the class under which to register the actionaction - the actual implementation (note that it does not need to implement the supplied
waspActionClass)
org.wicketstuff.security.actions.RegistrationException - if the action can not be registered.nextPowerOf2(),
SwarmAction#SwarmAction(int, String, ActionFactory)public List<org.wicketstuff.security.actions.WaspAction> getRegisteredActions()
getRegisteredActions in interface org.wicketstuff.security.actions.ActionFactoryActionFactory.getRegisteredActions()public void destroy()
destroy in interface org.wicketstuff.security.actions.ActionFactoryActionFactory.destroy()protected final Object getFactoryKey()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||