|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.inria.ns.reflex.processor.core.AbstractAction
public class AbstractAction
Base support for all active tags.
All actions are derived from this class.
This class is also the entry point for unmarshalling. Each specific action
should be built by unmarshalling an XML document.
An action is processed by using its run(DataSet) method.
Notice that each class that extends AbstractAction must define
a constructor that calls AbstractAction's constructor.
/**
* Create a new instance of FooAction.
* @param node The node from which the action has been unmarshalled.
* Used for namespace prefix resolution when performing XPath expressions.
* @param parent The action depending from.
* /
public class FooAction extends AbstractAction {
public FooAction(Node node, AbstractAction parent) {
super(node, parent);
}
}
Usually, an action contains a set of subactions to run. Sometimes, several of these subactions have to be removed, because they can't be applied to the runtime context. This is done in two step :
UselessAction.
UselessAction is invoked, it tries to invoke the
inner class AbstracAction.Organizer to clean all
UselessActions from the set of actions, by copying all the
actions except those to remove (thus, removing an action became thread safe).
The AbstracAction.Organizer is a singleton that works as a
background task.
All action set will gain stability and efficiency after a few invokations.
org.inria.ns.reflex.processor| Nested Class Summary | |
|---|---|
class |
AbstractAction.ParameterAdapter
A class used to find the parameters set when performing subactions, and use them on behalf of any component. |
static class |
AbstractAction.UselessAction
An action that does nothing except trying to reorganize the set of actions that is depending from. |
| Field Summary | |
|---|---|
Vector |
actions
The dependent subactions. |
AbstractAction |
parent
The action that is depending from. |
ProcessorInstance |
processorInstance
The processor instance that own this action. |
| Constructor Summary | |
|---|---|
AbstractAction(Node node,
AbstractAction parent)
Create a new instance of AbstractAction. |
|
| Method Summary | |
|---|---|
void |
addAction(AbstractAction action)
Adds the AbstractAction to the child list of the current
action. |
void |
addFallbackAction(Fallback fallback)
Add a fallback action. |
XPathContext |
createContext(DataSet dataSet)
Create a context based : on this action for mapping namespace URIs, on the given data set for resolving variables, on its processor instance's module bindings for resolving XPath functions. |
CanonicalPath |
getCanonicalPath()
Return the canonical path that lead to this action. |
Fallback |
getFallbackAction(QName id)
Return a fallback action. |
Fallback |
getLocalFallbackAction(QName id)
Return the fallback action defined locally by this action. |
Logger |
getLogger()
Returns the logger used by the processor. |
NamespaceContext |
getNamespaceContext()
Get the namespace context used by this action. |
Node |
getNode()
Returns the node from which the action has been unmarshalled. |
AbstractAction |
getParent()
Returns the action from which the current one depends. |
boolean |
recover(DataSet dataSet,
Exception e)
Try to recover an error with a fallback action. |
boolean |
recover(DataSet dataSet,
RecoverableException re)
Try to recover an error with a fallback action. |
void |
removeFallbackAction(QName fallbackId)
Remove a fallback action. |
void |
reorganize(boolean reorganization)
Set the reorganization indicator. |
void |
run(DataSet dataSet)
A wrapper that executes the action safely ; this method simply calls runAction(DataSet). |
void |
runAction(DataSet dataSet)
Execute the action by doing what the action was intending for. |
void |
runActions(DataSet dataSet)
Execute the action by processing all dependant actions sequentially. |
StringBuffer |
toPrettyString()
Return the pretty print representation of this action. |
StringBuffer |
toPrettyString(StringBuffer buf)
Return the pretty print representation of this action. |
String |
toString()
Return this action as a string. |
static AbstractAction |
unmarshal(AbstractAction parent,
Element element)
XML unmarshaller for AbstractAction. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public Vector actions
public AbstractAction parent
public ProcessorInstance processorInstance
| Constructor Detail |
|---|
public AbstractAction(Node node,
AbstractAction parent)
AbstractAction.
node - The node from which the action has been unmarshalled. Used for
namespace prefix resolution when performing XPath expressions.parent - The action depending from.| Method Detail |
|---|
public static AbstractAction unmarshal(AbstractAction parent,
Element element)
throws XMLException
AbstractAction. Are unmarshalled the
child nodes of the element given.
*** Each active tag to unmarshal must return a non-null
instance of its class ; if necessary, use NoAction instead of
null that would cause an exception
because at this stage, the underlying active tag must exist. ***
parent - The non-null action depending from.element - The XML element to unmarshall.
XMLException - When the element and its content is not those expected.NoActionpublic void reorganize(boolean reorganization)
reorganization - true if the actions are currently reorganized,
false otherwise.public Logger getLogger()
public Node getNode()
public AbstractAction getParent()
public void addAction(AbstractAction action)
AbstractAction to the child list of the current
action. The child may retrieved its parent with the parent property.
Special registration for Fallback action, which is not added
to the subactions list.
*** If overriden, the subactions won't be added and the fallback
actions won't be processed. Usually, a custom implementation of this method
requires a call to super.addAction(). ***
action - The child action to add, or to register as a fallback action.public void addFallbackAction(Fallback fallback)
fallback - The action to add.getFallbackAction(QName)public void removeFallbackAction(QName fallbackId)
fallbackId - The ID of the action to remove.addFallbackAction(Fallback)public Fallback getFallbackAction(QName id)
If this action defines a fallback action with the ID given, it will be returned ; otherwise, if its parent defines a fallback action with the ID given, it will be returned ; otherwise, it will use the default fallback action if it defines one, or the default fallback action of its parent.
Any action may define a default fallback action ; the fallback action of an action that has no ID is the default fallback action.
See <xcl:fallback>.
id - The ID of the fallback action to retrieve, or null.
null.addFallbackAction(Fallback),
#getFallbackAction(),
LogicActionpublic Fallback getLocalFallbackAction(QName id)
id - The ID of the fallback action to get, maybe null.
getFallbackAction(QName)
public boolean recover(DataSet dataSet,
Exception e)
throws ExecutionException
dataSet - The data set in use.e - The exception to recover,
which is assimilable to a recoverable exception
which ID is the class name of the exception given.
true if a fallback action was used to recover the error,
false otherwise.
ExecutionException - If an exception occurs while running the fallback action.recover(DataSet, RecoverableException)
public boolean recover(DataSet dataSet,
RecoverableException re)
throws ExecutionException
dataSet - The data set in use.re - The exception to recover.
true if a fallback action was used to recover the error,
false otherwise.
ExecutionException - If an exception occurs while running the fallback action.
public final void run(DataSet dataSet)
throws ExecutionException
runAction(DataSet).
runAction(DataSet) is invoked with safe
exception processing, that is to say that :
User defined processes should be defined in the
runAction(DataSet) method.
run in interface ExecutabledataSet - The set of datas used when the action is running.
ExecutionException - If the action can't be performed.RecoverableException,
UnrecoverableException,
Fallback
public void runAction(DataSet dataSet)
throws ExecutionException,
XPathException
A specific subclasse may override this method to perform specific
processing. The default behaviour is to call runActions(DataSet).
If this behaviour doesn't suit an action, this method must be overriden.
Particularly, although this behaviour suits procedural-oriented actions,
it may not suit for declarative-oriented actions.
If this method is overriden, the implementation must process abnormal
exceptions. Other exceptions (ExecutionExceptions) are
processed by the run(DataSet) method.
This method should not be called directly : users should call the
run(DataSet) method that wraps this method for exception
processing and recovering.
dataSet - The set of datas used when the action is running.
ExecutionException - If the action can't be performed.
XPathException
public final void runActions(DataSet dataSet)
throws ExecutionException,
XPathException
runAction(DataSet) is not overriden by an implementation
of this class, it will call this method.
dataSet - The set of datas used when the action is running.
ExecutionException - If the action can't be performed.
XPathExceptionpublic XPathContext createContext(DataSet dataSet)
dataSet - The data set to use by the context.
DataSet.createContext(NamespaceContextFactory)public NamespaceContext getNamespaceContext()
getNamespaceContext in interface NamespaceContextFactorypublic CanonicalPath getCanonicalPath()
public StringBuffer toPrettyString()
toPrettyString in interface PresentabletoPrettyString(StringBuffer),
Presentable.toPrettyString()public StringBuffer toPrettyString(StringBuffer buf)
toPrettyString in interface Presentablebuf - The buffer to append to.
Presentable.toPrettyString(java.lang.StringBuffer)public String toString()
toString in class ObjecttoPrettyString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||