com.zphinx.spine.core
Class AbstractBusinessDelegate

java.lang.Object
  extended by com.zphinx.spine.core.AbstractBusinessDelegate

public abstract class AbstractBusinessDelegate
extends Object

Core class used by the business tier to access business information and process activities.

It forms the core of the business layer and client programmers are advised to write all processing and business rules within the sub classes of this object to make their code more transparent to the view.

Version:
1.0

created 10-Jan-2005 16:03:12

copyright ©Zphinx Software Solutions

Author:
David Ladapo

Constructor Summary
AbstractBusinessDelegate()
           
 
Method Summary
protected  Object findBuilder()
          Gets the builder for this BusinessDelegate as defined in the configuration file
protected  DataTransferAssembler getCommand()
          Gets the DataTransferAssembler which configured this AbstractBusinessDelegate
protected  AbstractDataProxy getDataProxy()
          Gets the AbstractDataProxy in use by this delegate
protected  Locale getUserLocale()
          Gets the current users Locale from the DataTransferObject passed to this BusinessDelegate, otherwise returns the default Localein which this framework is been invoked
 AbstractBusinessDelegate init(DataTransferAssembler command)
          Initializes this AbstractBusinessDelegate and returns a copy to the user
 ResultObject initAndRun(DataTransferAssembler command)
          Performs initialization and runs the AbstractBusinessDelegate methods
protected  void initialize(DataTransferAssembler command)
          Initializes this AbstractBusinessDelegate,invokes the preconfigured proxy and prepares it for further processing.
protected  DataAccessObject initializeNewDAO(int pageIndex)
           Re initalizes this BusinessDelegate to use a new DataProxy and DataAccessObject where the processor is a MultiView Processor.
protected  ResultObject postProcessBusinessRules(ResultObject results1, DataTransferAssembler command1)
          Run all business rules associated with this delegate after processing in the data tier.
protected  boolean preProcessBusinessRules(DataTransferAssembler command)
          Run all business rules associated with this delegate before processing in the backend
protected  Object processDAO()
          Processes the call to DataAccessObject.fetchData(DataTransferObject) and returns the Object which is the result of this invocation.
protected abstract  ResultObject run()
          Performs the activities required by this delegate, then calls the close method of AbstractDataProxy
 void setProcessorName(String processorName)
          Sets the processorName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractBusinessDelegate

public AbstractBusinessDelegate()
Method Detail

initialize

protected void initialize(DataTransferAssembler command)
                   throws SpineException
Initializes this AbstractBusinessDelegate,invokes the preconfigured proxy and prepares it for further processing.

This method should be overidden if the use of a DataAccessObject is not necessary.

Parameters:
command - The CommandComponent used by this AbstractBusinessDelegate
Throws:
SpineException - Wrap errors in the message driven SpineException

processDAO

protected Object processDAO()
                     throws SpineException
Processes the call to DataAccessObject.fetchData(DataTransferObject) and returns the Object which is the result of this invocation.

Returns:
The object returned from the DAO
Throws:
SpineException

init

public final AbstractBusinessDelegate init(DataTransferAssembler command)
                                    throws SpineException
Initializes this AbstractBusinessDelegate and returns a copy to the user

Parameters:
command - The CommandComponent used by this AbstractBusinessDelegate
Throws:
SpineException

initAndRun

public final ResultObject initAndRun(DataTransferAssembler command)
                              throws SpineException
Performs initialization and runs the AbstractBusinessDelegate methods

  1. preProcessBusinessRules(DataTransferAssembler)
  2. run()
  3. postProcessBusinessRules(ResultObject, DataTransferAssembler)
in the order shown.

If calling run directly, you must directly invoke the methods preProcessBusinessRules(DataTransferAssembler) and postProcessBusinessRules(ResultObject, DataTransferAssembler) yourself. You must also ensure that you close the DataProxy to clean up resources by invoking AbstractDataProxy.close(DataAccessObject).

Parameters:
command - The CommandComponent used by this AbstractBusinessDelegate
Returns:
Returns the ResultObject which contains the components needed by the Action.
Throws:
SpineException - Wrap errors in the SpineException

postProcessBusinessRules

protected ResultObject postProcessBusinessRules(ResultObject results1,
                                                DataTransferAssembler command1)
                                         throws SpineException
Run all business rules associated with this delegate after processing in the data tier.

Parameters:
results1 - The ResultObject obtained from the run() method
command1 - The CommandComponent used by this AbstractBusinessDelegate
Returns:
The result object containing the results of this invocation
Throws:
SpineException - Wrap errors in the message driven SpineException

preProcessBusinessRules

protected boolean preProcessBusinessRules(DataTransferAssembler command)
                                   throws SpineException
Run all business rules associated with this delegate before processing in the backend

Parameters:
command - The command object associated with this delegate
Returns:
true if all business rules are met
Throws:
SpineException - Wrap errors in the message driven SpineException

run

protected abstract ResultObject run()
Performs the activities required by this delegate, then calls the close method of AbstractDataProxy

Returns:
Returns the ResultObject which contains the components obtained from the process flow.

getCommand

protected DataTransferAssembler getCommand()
Gets the DataTransferAssembler which configured this AbstractBusinessDelegate

Returns:
Returns the command.

getDataProxy

protected AbstractDataProxy getDataProxy()
Gets the AbstractDataProxy in use by this delegate

Returns:
Returns the abstractDataProxy.

findBuilder

protected Object findBuilder()
                      throws SpineException
Gets the builder for this BusinessDelegate as defined in the configuration file

Returns:
The AbstractBuider Object which was defined in configuration
Throws:
SpineException

initializeNewDAO

protected final DataAccessObject initializeNewDAO(int pageIndex)
                                           throws SpineException

Re initalizes this BusinessDelegate to use a new DataProxy and DataAccessObject where the processor is a MultiView Processor.

This method will not work for a simpl processor instance

Parameters:
pageIndex - The pageIndex of the DAO instance in configuration
Returns:
An initialized DataAccessObject which can be used to retrieve or persist data.
Throws:
SpineException

setProcessorName

public void setProcessorName(String processorName)
Sets the processorName

Parameters:
processorName - the processorName to set

getUserLocale

protected Locale getUserLocale()
Gets the current users Locale from the DataTransferObject passed to this BusinessDelegate, otherwise returns the default Localein which this framework is been invoked

Returns:
The current users Locale