com.zphinx.spine.core.viewprocessors
Class ViewProcessor

java.lang.Object
  extended by com.zphinx.spine.core.viewprocessors.ViewProcessor
Direct Known Subclasses:
DefaultViewProcessor, MultiViewProcessor

public abstract class ViewProcessor
extends Object

The ViewProcessor abstracts the view process from any MVC framework in use by the spine framework. It ensures that processes to be invoked in the system are delegated to it and serves as a interface to Spine for controller classes.

Version:
$1.0

Copyright ©Zphinx Software Solutions

Author:
David Ladapo
See Also:
DefaultViewProcessor, MultiViewProcessor

Field Summary
protected static String DATABASE_DATASOURCE
           
protected static String GENERAL_EXCEPTION
           
protected  ArrayList messages
          The list Object used by this object to persist messages in its result object
protected  String[] newClass
          The new className to set
 
Constructor Summary
ViewProcessor()
          Default Constructor - instantiates a messages array list
 
Method Summary
protected  CommandComponent createAssembler(DataTransferObject dto, Object obj, DAOInput daoConstructor, int operation)
           Creates a DataTransferAssembler which will be used to ferry objects to and from the back end using the command design pattern.
protected  AbstractBusinessDelegate delegateFactory(CommandComponent command)
          Creates and and initializes a suitable AbstractBusinessDelegate
protected  Object getDelegate(DataTransferAssembler command, boolean b)
          Gets the appropriate AbstractBusinessDelegate, initializes it and may call its run method if the boolean is set to true
 String getProcessorAliasName()
          Gets the processorAliasName
 ResultObject processData(DataTransferObject dto, Object obj)
          Calls the used methods of this View processor and sends the DataTransferAssembler to the business layer
 ResultObject processData(DataTransferObject dto, Object obj, DAOInput daoConstructor, int operation)
          Calls the used methods of this View processor and sends the DataTransferAssembler to the business layer
abstract  int processNavigation(ResultObject result)
          Uses the returned data to determine which navigational element to return to the user.
protected  void resetDelegateName()
          Resets the delegate in use.
protected  void resetPackageName(String[] className)
          Reset the delegate names used by this Action
protected  void setDelegateFullName(String className)
          Sets the delegateFullName where the delegate resides
 void setProcessorAliasName(String processorAliasName)
          Sets the processorAliasName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATABASE_DATASOURCE

protected static final String DATABASE_DATASOURCE
See Also:
Constant Field Values

GENERAL_EXCEPTION

protected static final String GENERAL_EXCEPTION
See Also:
Constant Field Values

messages

protected ArrayList messages
The list Object used by this object to persist messages in its result object


newClass

protected String[] newClass
The new className to set

Constructor Detail

ViewProcessor

public ViewProcessor()
Default Constructor - instantiates a messages array list

Method Detail

processData

public ResultObject processData(DataTransferObject dto,
                                Object obj)
Calls the used methods of this View processor and sends the DataTransferAssembler to the business layer

Parameters:
dto - The DataTransferObject used to create a DataTransferAssembler
obj - The object used by the proxy, usually a dataSource if the proxy type is database
Returns:
An instance of the resultObject obtained from the bussiness layer

processData

public ResultObject processData(DataTransferObject dto,
                                Object obj,
                                DAOInput daoConstructor,
                                int operation)
Calls the used methods of this View processor and sends the DataTransferAssembler to the business layer

Parameters:
dto - The DataTransferObject used to create a DataTransferAssembler
obj - The object used to initialize this transaction, usually a dataSource when a database proxy is in use
daoConstructor - The construct object used to instantiate a dao
operation - The operation to call within the dto
Returns:
An instance of the resultObject obtained from the bussiness layer

createAssembler

protected CommandComponent createAssembler(DataTransferObject dto,
                                           Object obj,
                                           DAOInput daoConstructor,
                                           int operation)

Creates a DataTransferAssembler which will be used to ferry objects to and from the back end using the command design pattern.

This implementation adds a data object ( eg a dataSource ) and a dto to a new instance of a CommandComponent and adds a DAOInput object for use by the data access object invoked by the system.

client developers wishing to add an additional operation should override this method in their implementation

Parameters:
dto - The DataTransferObject sent tro this object
obj - The object used to initialize this transaction, usually a dataSource when a database proxy is in use
daoConstructor - The construct object used to instantiate a dao
operation - The operation to call within the dto
Returns:
An instance of a command object

processNavigation

public abstract int processNavigation(ResultObject result)
Uses the returned data to determine which navigational element to return to the user.

Parameters:
result - The result object obtained from the processData method
Returns:
An int specifying the navigation to return to user

getDelegate

protected Object getDelegate(DataTransferAssembler command,
                             boolean b)
                      throws SpineException
Gets the appropriate AbstractBusinessDelegate, initializes it and may call its run method if the boolean is set to true

Parameters:
command - The DataTransferAssembler used to configure the Delegate
b - A boolean dictating if we should call the delegates run method
Returns:
The required AbstractBusinessDelegate Object
Throws:
SpineException

resetPackageName

protected void resetPackageName(String[] className)
Reset the delegate names used by this Action

Parameters:
className - The array of simple Delegate names used by this action

resetDelegateName

protected void resetDelegateName()
Resets the delegate in use. Sub classes which utilise multiple delegates should call this method on execution failure to clear all buffers #bug 0011


setDelegateFullName

protected void setDelegateFullName(String className)
Sets the delegateFullName where the delegate resides

Parameters:
className - The delegateFullName to set.

delegateFactory

protected AbstractBusinessDelegate delegateFactory(CommandComponent command)
                                            throws SpineException
Creates and and initializes a suitable AbstractBusinessDelegate

Parameters:
command - The CommandComponent used to configure the Delegate
Returns:
The required AbstractBusinessDelegate Object
Throws:
SpineException

getProcessorAliasName

public String getProcessorAliasName()
Gets the processorAliasName

Returns:
the processorAliasName

setProcessorAliasName

public void setProcessorAliasName(String processorAliasName)
Sets the processorAliasName

Parameters:
processorAliasName - the processorAliasName to set