|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.moremotion.process.Process
public abstract class Process
The process manager will call the interface methods of this abstract class as in the following example.
pro.prepare(pbc); for (int i = 0; i < pb.recordCount(); i++) { ProcessRecord prec = pb.getRecord(i); if (isThroughRecordFilter(prec)) { pro.processRecord(prec); } } int cc = pro.finalizeProcess();Please note that the process classes that extends this interface can have private data members safely since the process manager will create a new instance of them before calling their methods.
Constructor Summary | |
---|---|
Process()
|
Method Summary | |
---|---|
ADOMNode |
createMessage(java.lang.Exception exception)
Creates a new Request ADOM for the message if not already created, composes an message entry from the given Exception object and adds in it. |
ADOMNode |
createMessage(java.lang.String messageId,
java.lang.String[] arguments,
java.lang.Object details)
Creates a new Request ADOM for the message if not already created and adds the given message in it. |
abstract void |
finalizeProcess()
This method is called by the process manager after there is no more records to process. |
int |
getCompletionCode()
Returns the completion code of the current step. |
abstract void |
prepare()
The Process should prepare to be called for each process records existing in the configured process block. |
abstract void |
processRecord(ProcessRecord prec)
This method is called by the process manager for each process record in the configured process block that passes through the configured record filter. |
java.lang.String |
resolve(java.lang.String str)
Resolves the MScript functions existing in the given string and returns the resolved string. |
void |
setCompletionCode(int cc)
Sets the completion code of the current step. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Process()
Method Detail |
---|
public abstract void prepare() throws ProcessException
ProcessException
- indicates that the preparation failed and means
other methods of this process instance will not be called and the overall completion code of the
process execution will be set to 20.public abstract void processRecord(ProcessRecord prec) throws ProcessException
<callProcess name="x" blockName="PBx" recordFilter="PRICE < 100" ...then the process manager will call the processRecord() method for each record in the process block "PBx" that satisfies the "PRICE < 100" pre-condition.
prec
- The ProcessRecord Object that contains process fields
ProcessException
- indicates that there is an error and
the process cannot continue. This exception will set the overall completion code to 20.public abstract void finalizeProcess() throws ProcessException
Note that this method is called regardless of the completion code if the prepare method did not throw an exception.
The method should take care of the current completion code and act accordingly
public void finalizeProcess() throws ProcessException { if (getCompletionCode() <= 4) { // successfull completion } else { // unsuccessfull completion } }
ProcessException
- that indicates that finalization was in an unrecoverable error.
This exception will set the completion code to 20.public java.lang.String resolve(java.lang.String str) throws MScriptException
MScriptException
public void setCompletionCode(int cc)
cc
- the completion code
The value 0, which is the default, means everything was fine . A value between 1 and 4 means there were warnings but that's OK. A value between 5 and 8 means there were errors which should be interpretted as user errors and finally a value greater than 8 means process error.
It should be kept in mind that the process manager will not change the execution plan depending on the process completion codes. This is valid even if the process throws a ProcessException. in that case the process manager will catch the exception and set the completion code of the step to 20.
The process manager will attempt to execute all the processes in the processTemplate as long as the execution precondition (the expression defined in the "if" attribute) of the invocation elements, such as callProcess, callQueryProcess and callTemplate is satisfied.
Once the execution of process classes completed, the process manager decides what to do; If the maximum completion code is between 0 and 4, this means "success", the PM displays the configured "nextpage"; if it is between 5 and 8, this means "user-error" and the PM re-displays the "current page" to let the user to correct his/her errors; and if the code is greater than 8, the PM displays the configured "errorpage".
public int getCompletionCode()
public ADOMNode createMessage(java.lang.String messageId, java.lang.String[] arguments, java.lang.Object details)
This method will use the unitname
definition made in the Proceces Definition element
to name the data source to be created and the resource associated with it.
messageId
- Either a message text or a resource ID. The message will be taken from the resource file unitname.res
with this ID. If no resource
is found with the given id in the resource file then messageId
is used as the message text.arguments
- the message arguments which will be used to replace argument symbols (%0, %1, etc.) existing in the message text.details
- Either an Exception
object that keeps the original exception or a String
object that keeps theADOMNode
object to let you add extra information to the message created.
The XML representation of the created message ADOM is as follows:
<unitname_messages> <message id="messageId"> <text>Message text taken from the resource file with the given messageId</text> <unitname>Given unit name</unitname> <details>Message Details. Either the Stack Trace of the orginal exception or the given details as String</details> </message> </unitname_messages>
Example:
ADOMNode msg = createMessage(MISSING_TABLE",new String[]{databaseName, tableName},e); msg.setNodeValue("extrainfo","extra info ....."); p.setCC(12); // That will tell the Processs Manager the execution of the processes was not OK.
public ADOMNode createMessage(java.lang.Exception exception)
MoreMotionException
or
a ProcessException
this
method can extract the message id, arguments and details from it.
If the given exception is or contains a java.sql.SQLException
the returned ADOMNode object
contains two additional entries athat are "jdbc-error-code" and "jdbc-sql-state".
createMessage(String messageID, String[] arguments, Object details)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |