org.exolab.jms.persistence
Class DatabaseService

java.lang.Object
  |
  +--org.exolab.jms.service.Service
        |
        +--org.exolab.jms.persistence.DatabaseService
All Implemented Interfaces:
Serviceable

public class DatabaseService
extends Service

The DatabaseService is used for managing the persistence aspect of this project.

Version:
$Revision: 1.4 $ $Date: 2006/02/23 11:17:39 $
Author:
Jim Alateras

Constructor Summary
DatabaseService(Configuration config)
          Construct a new DatabaseService.
 
Method Summary
 void begin()
          Begin a transaction.
 void commit()
          Commit the current transaction.
protected  void doStart()
          Start the service.
protected  void doStop()
          Stop the service.
 PersistenceAdapter getAdapter()
          Returns the PersistenceAdapter created by this service.
 java.sql.Connection getConnection()
          Returns the connection associated with the current thread.
static DatabaseService getInstance()
          Returns the database service associated with the current thread.
 boolean isTransacted()
          Determines if a transaction is in progress.
 void rollback()
          Rollback the current transaction.
 void setServiceThreadListener(ServiceThreadListener listener)
          Sets the service thread listener.
 
Methods inherited from class org.exolab.jms.service.Service
getName, isStarted, restart, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DatabaseService

public DatabaseService(Configuration config)
Construct a new DatabaseService.
Parameters:
config - the configuration
Method Detail

setServiceThreadListener

public void setServiceThreadListener(ServiceThreadListener listener)
Sets the service thread listener.
Parameters:
listener - the service thread listener

getInstance

public static DatabaseService getInstance()
                                   throws PersistenceException
Returns the database service associated with the current thread.
Returns:
the database service associated with the current thread
Throws:
PersistenceException - if no instance is registered

getAdapter

public PersistenceAdapter getAdapter()
Returns the PersistenceAdapter created by this service.
Returns:
the persistence adapter

begin

public void begin()
           throws PersistenceException
Begin a transaction.
Throws:
PersistenceException - if a transaction cannot be started

getConnection

public java.sql.Connection getConnection()
                                  throws PersistenceException
Returns the connection associated with the current thread.
Returns:
the connection associated with the current thread
Throws:
PersistenceException - if no connection is associated

commit

public void commit()
            throws PersistenceException
Commit the current transaction.
Throws:
PersistenceException - if the transaction can't be committed

rollback

public void rollback()
              throws PersistenceException
Rollback the current transaction.
Throws:
PersistenceException - if the transaction can't be rolled back

isTransacted

public boolean isTransacted()
Determines if a transaction is in progress.
Returns:
true if a transaction is in progress; otherwise false

doStart

protected void doStart()
                throws ServiceException
Start the service.
Overrides:
doStart in class Service
Throws:
ServiceException - if the service fails to start

doStop

protected void doStop()
               throws ServiceException
Stop the service.
Overrides:
doStop in class Service
Throws:
ServiceException - if the service fails to stop


Copyright © 1999-2007 The OpenJMS Group. All Rights Reserved.