org.openrdf.sail.helpers
Class SailBase

java.lang.Object
  extended by org.openrdf.sail.helpers.SailBase
All Implemented Interfaces:
Sail
Direct Known Subclasses:
MemoryStore, NativeStore, RdbmsStore

public abstract class SailBase
extends Object
implements Sail

SailBase is an abstract Sail implementation that takes care of common sail tasks, including proper closing of active connections and a grace period for active connections during shutdown of the store.

Author:
Herko ter Horst, jeen, Arjohn Kampman

Field Summary
protected  long connectionTimeOut
          Connection timeout on shutdown (in ms).
protected static long DEFAULT_CONNECTION_TIMEOUT
          Default connection timeout on shutdown: 20,000 milliseconds.
protected  Logger logger
           
 
Constructor Summary
SailBase()
           
 
Method Summary
 void addSailChangedListener(SailChangedListener listener)
          Adds the specified SailChangedListener to receive events when the data in this Sail object changes.
protected  void connectionClosed(SailConnection connection)
          Signals to the store that the supplied connection has been closed.
 SailConnection getConnection()
          Opens a connection on the Sail which can be used to query and update data.
protected abstract  SailConnection getConnectionInternal()
          returns a store-specific SailConnection object.
 File getDataDir()
           
 void notifySailChanged(SailChangedEvent event)
          Notifies all registered SailChangedListener's of changes to the contents of this Sail.
 void removeSailChangedListener(SailChangedListener listener)
          Removes the specified SailChangedListener so that it no longer receives events from this Sail object.
 void setDataDir(File dataDir)
           
 void shutDown()
          Shuts down the Sail, giving it the opportunity to synchronize any stale data.
protected abstract  void shutDownInternal()
          Do store-specific operations to ensure proper shutdown of the store.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openrdf.sail.Sail
getValueFactory, initialize, isWritable
 

Field Detail

logger

protected final Logger logger

DEFAULT_CONNECTION_TIMEOUT

protected static final long DEFAULT_CONNECTION_TIMEOUT
Default connection timeout on shutdown: 20,000 milliseconds.

See Also:
Constant Field Values

connectionTimeOut

protected long connectionTimeOut
Connection timeout on shutdown (in ms). Defaults to DEFAULT_CONNECTION_TIMEOUT.

Constructor Detail

SailBase

public SailBase()
Method Detail

setDataDir

public void setDataDir(File dataDir)
Specified by:
setDataDir in interface Sail

getDataDir

public File getDataDir()
Specified by:
getDataDir in interface Sail

getConnection

public SailConnection getConnection()
                             throws SailException
Description copied from interface: Sail
Opens a connection on the Sail which can be used to query and update data. Depending on how the implementation handles concurrent access, a call to this method might block when there is another open connection on this Sail.

Specified by:
getConnection in interface Sail
Throws:
SailException - If no transaction could be started, for example because the Sail is not writable.

getConnectionInternal

protected abstract SailConnection getConnectionInternal()
                                                 throws SailException
returns a store-specific SailConnection object.

Returns:
a SailConnection
Throws:
SailException

shutDown

public void shutDown()
              throws SailException
Description copied from interface: Sail
Shuts down the Sail, giving it the opportunity to synchronize any stale data. Care should be taken that all initialized Sails are being shut down before an application exits to avoid potential loss of data. Once shut down, a Sail can no longer be used until it is re-initialized.

Specified by:
shutDown in interface Sail
Throws:
SailException - If the Sail object encountered an error or unexpected situation internally.

shutDownInternal

protected abstract void shutDownInternal()
                                  throws SailException
Do store-specific operations to ensure proper shutdown of the store.

Throws:
SailException

connectionClosed

protected void connectionClosed(SailConnection connection)
Signals to the store that the supplied connection has been closed.

Parameters:
connection -

addSailChangedListener

public void addSailChangedListener(SailChangedListener listener)
Description copied from interface: Sail
Adds the specified SailChangedListener to receive events when the data in this Sail object changes.

Specified by:
addSailChangedListener in interface Sail

removeSailChangedListener

public void removeSailChangedListener(SailChangedListener listener)
Description copied from interface: Sail
Removes the specified SailChangedListener so that it no longer receives events from this Sail object.

Specified by:
removeSailChangedListener in interface Sail

notifySailChanged

public void notifySailChanged(SailChangedEvent event)
Notifies all registered SailChangedListener's of changes to the contents of this Sail.



Copyright © 2001-2008 Aduna. All Rights Reserved.