toolbox.app
Class BaseService

Package class diagram package BaseService
java.lang.Object
  extended by toolbox.app.BaseService

public class BaseService
extends java.lang.Object

Convenience base class for developing services.

The following is provided:

  • Provides access to configuration details as an XMLProperties instance or java Properties instance.
  • Provides a DaoWorker instance.

  • Constructor Summary
    BaseService()
               
     
    Method Summary
    protected  boolean checkConstraint(java.lang.String query, java.lang.Object[] params)
              Convenience method to check a single foreign key constraint.
     void create()
              Creates all the convenience members provided by this base service implementation.
     java.util.List customExec(Query query)
              Executes the given query and returns the result as a List instance.
    protected  java.util.List customExec(java.lang.String query)
              Convenience method to execute a query without parameters.
     void destroy()
              Destroy this service.
    protected  AppEnv getAppEnv()
              Returns the AppEnv instance for this service.
    protected  java.lang.String getConfigHome()
              Returns the location of the services configuration home
    protected  DaoWorker getDaoWorker()
              Returns the DaoWorker for this service.
     java.lang.String getName()
              Returns the name of this service
    protected  java.util.Properties getProperties()
              Return the configuration properties of this service.
    protected  java.lang.String getProperty(java.lang.String name)
              Returns the value of a single service property.
    protected  XMLProperties getXMLProperties()
              Returns the XML configuration properties of this service.
    protected  void insertAppBean(java.lang.String table, AppBean bean)
              Convenience method to insert the properties of the given AppBean into the named table.
    protected  void insertAppBean(java.lang.String table, AppBean bean, TransactionContext tc)
              Convenience method to insert the properties of the given AppBean into the named table within the given transaction context.
    protected  void setName(java.lang.String name)
              Set the name of this service.
    protected  void updateAppBean(java.lang.String table, AppBean bean)
              Convienience method to to update the properties of the given AppBean in the named table.
    protected  void updateAppBean(java.lang.String table, AppBean bean, TransactionContext tc)
              Convienience method to to update the properties of the given AppBean in the named table within the given TransactionContext.
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    BaseService

    public BaseService()
    Method Detail

    create

    public void create()
                throws AppException
    Creates all the convenience members provided by this base service implementation.

    Throws:
    AppException

    getName

    public java.lang.String getName()
    Returns the name of this service

    Returns:
    String containing the name of this service.

    setName

    protected void setName(java.lang.String name)
    Set the name of this service.

    Parameters:
    name - Set the name of this service.

    getXMLProperties

    protected XMLProperties getXMLProperties()
    Returns the XML configuration properties of this service.

    Returns:
    XMLProperties instance of this service.

    getProperties

    protected java.util.Properties getProperties()
    Return the configuration properties of this service.

    Returns:
    Properties instance containing the configuration of this service.

    getProperty

    protected java.lang.String getProperty(java.lang.String name)
    Returns the value of a single service property.

    Parameters:
    name - Name of property to return
    Returns:
    String containing property value.

    getConfigHome

    protected java.lang.String getConfigHome()
    Returns the location of the services configuration home

    Returns:
    String containing service configuraion home

    getDaoWorker

    protected DaoWorker getDaoWorker()
    Returns the DaoWorker for this service.

    Returns:
    DaoWorker instance.

    getAppEnv

    protected AppEnv getAppEnv()
    Returns the AppEnv instance for this service.

    Returns:
    AppEnv instance.

    customExec

    protected java.util.List customExec(java.lang.String query)
                                 throws AppException
    Convenience method to execute a query without parameters.

    Parameters:
    query - Query to execute.
    Returns:
    List instance of results.
    Throws:
    AppException

    customExec

    public java.util.List customExec(Query query)
                              throws AppException
    Executes the given query and returns the result as a List instance.

    Parameters:
    query - Query instance containing query information.
    Returns:
    List instance containing results.
    Throws:
    AppException - if the query cannot be executed.

    checkConstraint

    protected boolean checkConstraint(java.lang.String query,
                                      java.lang.Object[] params)
                               throws AppException
    Convenience method to check a single foreign key constraint.

    The query must return a single column named "count". If the count is greater than 0 the constraint succeeds.

    Parameters:
    query - Constraint query string.
    params - Constraint parameters
    Returns:
    boolean Indicating the existance of the constraint.
    Throws:
    AppException - if an exception occurs while checking the constraint.

    insertAppBean

    protected void insertAppBean(java.lang.String table,
                                 AppBean bean)
                          throws AppException
    Convenience method to insert the properties of the given AppBean into the named table.

    Parameters:
    table - Name of table to insert bean properties.
    bean - AppBean instance.
    Throws:
    AppException - if the bean properties cannot be inserted.

    insertAppBean

    protected void insertAppBean(java.lang.String table,
                                 AppBean bean,
                                 TransactionContext tc)
                          throws AppException
    Convenience method to insert the properties of the given AppBean into the named table within the given transaction context.

    Parameters:
    table - Name of table to insert bean properties.
    bean - AppBean instance.
    tc - Current TransactionContext.
    Throws:
    AppException - if the bean properties cannot be inserted.

    updateAppBean

    protected void updateAppBean(java.lang.String table,
                                 AppBean bean)
                          throws AppException
    Convienience method to to update the properties of the given AppBean in the named table.

    Parameters:
    table - Name of table to update.
    bean - AppBean instance.
    Throws:
    AppException - if the bean properties cannot be updated.

    updateAppBean

    protected void updateAppBean(java.lang.String table,
                                 AppBean bean,
                                 TransactionContext tc)
                          throws AppException
    Convienience method to to update the properties of the given AppBean in the named table within the given TransactionContext.

    Parameters:
    table - Name of table to update.
    bean - AppBean instance.
    tc - Current TransactionContext.
    Throws:
    AppException - if the bean properties cannot be updated.

    destroy

    public void destroy()
    Destroy this service.