Class DATask

java.lang.Object
overit.geocall.da.DATask
All Implemented Interfaces:
Serializable, Runnable, Identified, Tool
Direct Known Subclasses:
BoundedTask, overit.geocallapp.replicator.basic.base.DataSource.DATaskReplicator, DATBindNotificationsToOdl, DATCalculateNotificationsStatuses, DATCalculateNotificationStatus, DATChangeNotificationsStatus, DATCheckNotificationNotModified, DATCreateOdlInSapFromNotification, overit.geocallapp.wfm.schedulazione.odl.DATCreazioneOdlBase, overit.geocallapp.wfm.schedulazione.cristallizzazione.monitorattivita.pianogiornaliero.dat.DATElaboraOttimizzazione, DATFindNotificationProfiloCatalogo, DATLoadFailureDD, DATLoadFailureInvestigation, DATLoadMRelChartData, DATLoadNotification, DATLoadStruggleFailure, DATManageBatchNotificationsIntegration, DATManageNotificationSapIntegration, DATNewNotificationCode, DATSaveNotification, DATSaveProfile, DATSendMessage, DATTakeInChargeNotification, DATUnbindNotificationsFromOdl, DATUser, overit.geocallapp.replicator.basic.base.DataSource.DBViewTaskReplicator, ErrorNotifier, RRTask, StaticView.SVTask, XMLTask

public abstract class DATask extends Object implements Identified, Runnable, Serializable, Tool
Abstract class to extend when you want to create a task that perform a database access.
To use the class you must implement the body() method, that is the one called when the task starts. To start the specific task, after the instantiation of the class, it's necessary to invoke the start() method (or the startInBackground() if you want to run the task in background).
The class provides a series of automatisms (automatic rollback) that allow to don't worry about the correct release of the connections that are opened during the task itself.
See Also:
  • Field Details

  • Constructor Details

    • DATask

      public DATask()
  • Method Details

    • getIdentity

      public Identity getIdentity()
      Retrieves an Identity object used to store the informations about the user currently logged in the application.
      Specified by:
      getIdentity in interface Identified
      Returns:
      The object that contains the informations about the user currently logged in the application
    • setIdentity

      public void setIdentity(Identity identity)
      Sets a Identity object used to store the informations about the user currently logged in the application.
      Specified by:
      setIdentity in interface Identified
      Parameters:
      identity - The object to set
    • start

      public void start() throws DAValidateException, DAException
      Starts the task.
      Throws:
      DAValidateException - If there are error in the data validation phase, a DAValidateException is thrown
      DAException - If there is a (blocking) data-access error, a DAException is thrown
    • getConnection

      protected PooledConnection getConnection(String poolName, String activity) throws DAException
      Retrieves a connection from the connection pool and the specific connection is stored in the list of the opened connections. All the connections stored in the list are released at the end of the run of the task.
      Parameters:
      poolName - The name of the pool from which extract the connection
      activity - Description of the activity to be carried out by using the connection
      Returns:
      The requested connection
      Throws:
      DAException - If there is a (blocking) data-access error, a DAException is thrown to the caller
    • getServiceConnection

      protected PooledConnection getServiceConnection(String poolName, String activity) throws DAException
      Retrieves a connection from the service connection pool and the specific connection is stored in the list of the opened connections. All the connections stored in the list are released at the end of the run of the task.
      Parameters:
      poolName - The name of the pool from which extract the connection
      activity - Description of the activity to be carried out by using the connection
      Returns:
      The requested connection
      Throws:
      DAException - If there is a (blocking) data-access error, a DAException is thrown to the caller
    • holdUserCourier

      protected Courier holdUserCourier(String name) throws DAException
      Throws:
      DAException
    • holdFactoryCourier

      protected Courier holdFactoryCourier(String name) throws DAException
      Throws:
      DAException
    • releaseConnection

      protected void releaseConnection(PooledConnection c) throws DAException
      Releases a connection and reinsert it into the connection pool. This method allows to explicit release a connection when you don't want to use it anymore. All connections obtained with the getConnection() method and not explicitly released by this method are automatically released anyway at the end of the run of the task.
      Parameters:
      c - The connection that you want to release
      Throws:
      DAException - If there is an error during the release, a DAException is raised to the caller
    • deliverCourier

      protected void deliverCourier(Courier c)
    • rollback

      protected void rollback(PooledConnection conn) throws DAException
      Makes an explicit rollback on the connection passed as parameter
      Parameters:
      conn - The specific connection on which do the rollback
      Throws:
      DAException - If there is an error during the rollback, a DAException is raised to the caller
    • commit

      protected void commit(PooledConnection conn) throws DAException
      Makes an explicit commit on the connection passed as parameter
      Parameters:
      conn - The specific connection on which do the commit
      Throws:
      DAException - If there is an error during the commit, a DAException is raised to the caller
    • getDA

      protected DABase getDA(String name)
      Creates, through the factory mechanism, a specific DA used to do the queries
      Parameters:
      name - The name of the DA
      Returns:
      The specific DA created by the factory
    • body

      protected abstract void body() throws DAException, DAValidateException
      Abstract method, that must be implemented, that represent the start point of the task. The method contains the application logic of the specific task.
      Throws:
      DAException - If there is a (blocking) data-access error, a DAException is thrown to the caller
      DAValidateException - If there are error in the data validation phase, a DAValidateException is thrown
    • run

      public final void run()
      Specified by:
      run in interface Runnable
    • startInBackground

      public void startInBackground()
      Starts the task in background.
    • synchronizeOn

      @Deprecated public static void synchronizeOn(PooledConnection pc, String table)
      Deprecated.
      this method should not be used anymore
      Synchronizes the task over a specific table to prevent concurrent modification of the table itself
      Parameters:
      pc - The connection used by the taks
      table - The table on which we want to synchronize