no.priv.garshol.duke
Class RDBMSLinkDatabase

java.lang.Object
  extended by no.priv.garshol.duke.RDBMSLinkDatabase
All Implemented Interfaces:
LinkDatabase
Direct Known Subclasses:
JDBCLinkDatabase, JNDILinkDatabase

public abstract class RDBMSLinkDatabase
extends Object
implements LinkDatabase

An abstract SQL-based link database implementation which can can maintain a set of links in an H2 or Oracle database over JDBC. It could be extended to work with more database implementations. What the abstract class cannot do is create a connection, which is left for subclasses to do.


Nested Class Summary
static class RDBMSLinkDatabase.DatabaseType
           
 
Field Summary
protected  Statement stmt
           
 
Constructor Summary
RDBMSLinkDatabase(String dbtype)
           
 
Method Summary
 void assertLink(Link link)
          Assert a link.
 void clear()
          Empties the link database.
 void close()
          Shuts down the database, releasing resources.
 void commit()
          Commit asserted links to persistent store.
 List<Link> getAllLinks()
          Get all links.
 Collection<Link> getAllLinksFor(String id)
          Get all links for this identity.
 List<Link> getChangesSince(long since)
          Returns all links modified since the given time.
 List<Link> getChangesSince(long since, long before)
           
 List<Link> getChangesSince(long since, long before, int pagesize)
           
 Link inferLink(String id1, String id2)
          Can we work out, based on what we know, the relationship between these two? Returns null if we don't know the relationship.
 void init()
          This method must be called to initialize the database.
 void setLogger(Logger logger)
           
 void setTablePrefix(String tblprefix)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface no.priv.garshol.duke.LinkDatabase
validateConnection
 

Field Detail

stmt

protected Statement stmt
Constructor Detail

RDBMSLinkDatabase

public RDBMSLinkDatabase(String dbtype)
Method Detail

init

public void init()
This method must be called to initialize the database. In order to avoid problems with constructor call sequencing (parent constructor must be called first), we had to move this out into a separate method.


setLogger

public void setLogger(Logger logger)

setTablePrefix

public void setTablePrefix(String tblprefix)

getAllLinks

public List<Link> getAllLinks()
Description copied from interface: LinkDatabase
Get all links.

Specified by:
getAllLinks in interface LinkDatabase

getChangesSince

public List<Link> getChangesSince(long since)
Description copied from interface: LinkDatabase
Returns all links modified since the given time.

Specified by:
getChangesSince in interface LinkDatabase

getChangesSince

public List<Link> getChangesSince(long since,
                                  long before)

getChangesSince

public List<Link> getChangesSince(long since,
                                  long before,
                                  int pagesize)

getAllLinksFor

public Collection<Link> getAllLinksFor(String id)
Description copied from interface: LinkDatabase
Get all links for this identity. If there are no links it returns an empty collection, never null.

Specified by:
getAllLinksFor in interface LinkDatabase

assertLink

public void assertLink(Link link)
Description copied from interface: LinkDatabase
Assert a link.

Specified by:
assertLink in interface LinkDatabase

inferLink

public Link inferLink(String id1,
                      String id2)
Description copied from interface: LinkDatabase
Can we work out, based on what we know, the relationship between these two? Returns null if we don't know the relationship.

Specified by:
inferLink in interface LinkDatabase

clear

public void clear()
Empties the link database. Used only for testing at the moment.

Specified by:
clear in interface LinkDatabase

commit

public void commit()
Description copied from interface: LinkDatabase
Commit asserted links to persistent store.

Specified by:
commit in interface LinkDatabase

close

public void close()
Description copied from interface: LinkDatabase
Shuts down the database, releasing resources.

Specified by:
close in interface LinkDatabase


Copyright © 2013. All Rights Reserved.