Package rs.data.api

Interface IDaoFactory

All Known Implementing Classes:
AbstractDaoFactory

public interface IDaoFactory
A general interface describing a DAO factory.
Author:
ralph
  • Field Details

  • Method Details

    • getProperty

      java.lang.Object getProperty​(java.lang.String name)
      Returns the factory property.
      Parameters:
      name - name of property
      Returns:
      value or NULL
    • setProperty

      void setProperty​(java.lang.String name, java.lang.Object value)
      Sets the property.
      Parameters:
      name - name of property
      value - value of property
    • getParameter

      java.lang.String getParameter​(java.lang.String name)
      Returns the factory parameter.
      Parameters:
      name - name of parameter
      Returns:
      value or NULL
    • getParameterUrl

      java.net.URL getParameterUrl​(java.lang.String name) throws java.net.MalformedURLException
      Returns the factory parameter as a URL.
      Parameters:
      name - name of parameter
      Returns:
      value or NULL
      Throws:
      java.net.MalformedURLException - when the parameter URL cannot be created
    • getUrlTransformer

      IUrlTransformer getUrlTransformer()
      Returns the urlTransformer.
      Returns:
      the urlTransformer
    • setUrlTransformer

      void setUrlTransformer​(IUrlTransformer urlTransformer)
      Sets the urlTransformer.
      Parameters:
      urlTransformer - the urlTransformer to set
    • getDaoMaster

      IDaoMaster getDaoMaster​(java.lang.String id)
      Returns the DAO master with given ID.
      Parameters:
      id - ID of master
      Returns:
      the master or null
    • getParameterKeys

      java.util.Iterator<java.lang.String> getParameterKeys()
      Returns an iterator of all property keys.
      Returns:
      iterator
    • setCacheEnabled

      void setCacheEnabled​(boolean cacheEnabled)
      Enable or disable caching for all registered DAOs.
      Parameters:
      cacheEnabled - true when cache shall be enabled
      See Also:
      IGeneralDAO.setCacheEnabled(boolean)
    • getDaoFor

      <K extends java.io.Serializable,​ T extends GeneralDTO<K>> IGeneralDAO<K,​?> getDaoFor​(T o)
      Returns the correct DAO for the given transfer object.
      Type Parameters:
      K - the key class
      T - the transfer class
      Parameters:
      o - the object to look for
      Returns:
      DAO or null if not found
    • getDaoFor

      <B extends IGeneralBO<?>> IGeneralDAO<?,​B> getDaoFor​(B o)
      Returns the correct DAO for the given business object.
      Type Parameters:
      B - the BO class
      Parameters:
      o - the object to look for
      Returns:
      DAO or null if not found
    • getDaoFor

      <B extends IGeneralBO<?>> IGeneralDAO<?,​B> getDaoFor​(java.lang.Class<B> clazz)
      Returns the correct DAO for the given business object class.
      Type Parameters:
      B - the BO class
      Parameters:
      clazz - the BO clazz to look for
      Returns:
      DAO or null if not found
    • registerDao

      void registerDao​(IGeneralDAO<? extends java.io.Serializable,​? extends IGeneralBO<? extends java.io.Serializable>> dao)
      Registers a DAO with this factory (under its class name).
      Parameters:
      dao - the DAO to be registered.
    • registerDao

      void registerDao​(java.lang.String name, IGeneralDAO<? extends java.io.Serializable,​? extends IGeneralBO<? extends java.io.Serializable>> dao)
      Registers a DAO with this factory.
      Parameters:
      name - name of registration
      dao - the DAO to be registered.
      Since:
      1.2.7
    • getDao

      <X extends IGeneralDAO<?,​ ?>> X getDao​(java.lang.Class<X> clazz)
      Returns a registered DAO of given class (registered under its class name).

      The method will try to return the DAO registered under the class name. If that cannopt be found then the first object found being an instance of the class will be returned.

      Type Parameters:
      X - the DAO class
      Parameters:
      clazz - the class of the DAO to be returned
      Returns:
      the DAO or null if not registered
    • getDao

      <X extends IGeneralDAO<?,​ ?>> X getDao​(java.lang.String name, java.lang.Class<X> clazz)
      Returns a registered DAO of given class.
      Type Parameters:
      X - the DAO class
      Parameters:
      name - the name of the registration
      clazz - the class of the DAO to be returned
      Returns:
      the DAO or null if not registered
      Throws:
      java.lang.ClassCastException - when the registered object is not an instance of the given class.
      Since:
      1.2.7
    • getDaos

      java.lang.Iterable<IGeneralDAO<?,​?>> getDaos()
      Return an iterable of the registered DAOs.
      Returns:
      the iterable
    • clearCache

      void clearCache()
      Clear cache of all DAOs.
      Since:
      1.2.8
    • shutdown

      void shutdown()
      Shutdown the factory.
    • getTransactionManager

      javax.transaction.TransactionManager getTransactionManager()
      Returns the TX manager used.
      Returns:
      the transaction manager
    • setTransactionManager

      void setTransactionManager​(javax.transaction.TransactionManager txManager)
      Sets the given TX manager to be used.
      Parameters:
      txManager - the TX manager.
    • getDefaultTransactionTimeout

      long getDefaultTransactionTimeout()
      Returns the default timeout for transactions.
      Returns:
      timeout in ms
      Since:
      1.2.9
    • setDefaultTransactionTimeout

      void setDefaultTransactionTimeout​(long defaultTimeout)
      Sets the default timeout for transactions.
      Parameters:
      defaultTimeout - timeout in ms, DEFAULT_TX_TIMEOUT will be used when value is 0.
      Since:
      1.2.9
    • begin

      void begin()
      Begins a transaction. This method does nothing if the thread is already within a transaction.
    • begin

      void begin​(long timeout)
      Begins a transaction. This method does nothing if the thread is already within a transaction.
      Parameters:
      timeout - timeout of transaction in ms
    • commit

      void commit()
      Commits a transaction. If the last call to begin() did not start a new TX then this method does nothing.
    • rollback

      void rollback()
      Rolls back a transaction. If the last call to begin() did not start a new TX then this method does nothing.
    • getTransaction

      javax.transaction.Transaction getTransaction() throws javax.transaction.SystemException
      Returns the current active transaction.
      Returns:
      current transaction
      Throws:
      javax.transaction.SystemException - if there is a problem
    • getTransactionStartTime

      long getTransactionStartTime()
      Returns the start time of the current or last transaction in ms.
      Returns:
      the start time in ms
    • getTransactionEndTime

      long getTransactionEndTime()
      Returns the end time of the current or last transaction in ms.
      Returns:
      the end time in ms
    • getTransactionDuration

      long getTransactionDuration()
      Returns the duration of the current or last transaction in ms.
      Returns:
      the duration in ms
    • cleanTransactionContext

      void cleanTransactionContext()
      Ensures that the current thread has no left-overs from last TX activity.
      Since:
      1.2.9
    • addDaoFactoryListener

      void addDaoFactoryListener​(IDaoFactoryListener listener)
      Adds a factory listener.
      Parameters:
      listener - listener
    • removeDaoFactoryListener

      void removeDaoFactoryListener​(IDaoFactoryListener listener)
      Removes a factory listener.
      Parameters:
      listener - listener