org.jboss.cache.loader
Class JDBCCacheLoader

java.lang.Object
  extended by org.jboss.cache.loader.AbstractCacheLoader
      extended by org.jboss.cache.loader.AdjListJDBCCacheLoader
          extended by org.jboss.cache.loader.JDBCCacheLoader
All Implemented Interfaces:
CacheLoader

@ThreadSafe
public class JDBCCacheLoader
extends AdjListJDBCCacheLoader

JDBC implementation of AdjListJDBCCacheLoader. Represents a faster alternative than JDBCCacheLoaderOld and relies on the same database structrure. It is backward compatible with data created by existing JDBCCacheLoaderOld implemetation. All configuration elements described there JDBCCacheLoaderOld also apply for this implementation.

Additional configuration info:
cache.jdbc.sql-concat : DBMS specific function for concat strings. Most likely this will be concat(1,2), but might be different for proprietary systems.

Version:
1.0
Author:
Mircea.Markus@iquestint.com, Galder Zamarreno

Field Summary
 
Fields inherited from class org.jboss.cache.loader.AdjListJDBCCacheLoader
cf, driverName, lock, NULL_NODE_IN_ROW
 
Fields inherited from class org.jboss.cache.loader.AbstractCacheLoader
cache, regionManager, transactions
 
Constructor Summary
JDBCCacheLoader()
           
 
Method Summary
 CacheLoaderConfig.IndividualCacheLoaderConfig getConfig()
          Gets the configuration.
protected  org.apache.commons.logging.Log getLogger()
           
 int getNodeCount()
          Returns a number representing the count of persisted children.
protected  void getNodeDataList(Fqn fqn, java.util.List<NodeData> list)
          Subscribes to contract.
protected  AdjListJDBCCacheLoaderConfig processConfig(CacheLoaderConfig.IndividualCacheLoaderConfig base)
          Builds a AdjListJDBCCacheLoaderConfig based on the supplied base config.
 void put(Fqn name, java.util.Map attributes)
          As per interface's contract.
 java.lang.Object put(Fqn name, java.lang.Object key, java.lang.Object value)
          As per interface's contract.
 void remove(Fqn fqn)
          As per interface's contrect.
 void start()
          Start is overwritten for the sake of backward compatibility only.
 
Methods inherited from class org.jboss.cache.loader.AdjListJDBCCacheLoader
commit, exists, get, getChildrenNames, getDriverName, insertNode, loadNode, marshall, prepare, remove, removeData, reportAndRethrowError, rollback, safeClose, safeClose, safeClose, setConfig, stop, tableExists, unmarshall, updateNode
 
Methods inherited from class org.jboss.cache.loader.AbstractCacheLoader
create, destroy, getMarshaller, loadEntireState, loadState, loadStateHelper, put, put, setCache, setRegionManager, storeEntireState, storeState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBCCacheLoader

public JDBCCacheLoader()
Method Detail

processConfig

protected AdjListJDBCCacheLoaderConfig processConfig(CacheLoaderConfig.IndividualCacheLoaderConfig base)
Builds a AdjListJDBCCacheLoaderConfig based on the supplied base config.

Specified by:
processConfig in class AdjListJDBCCacheLoader

put

public java.lang.Object put(Fqn name,
                            java.lang.Object key,
                            java.lang.Object value)
                     throws java.lang.Exception
As per interface's contract. Performance Note: Optimised O(nodeDepth) db calls.

Throws:
java.lang.Exception

put

public void put(Fqn name,
                java.util.Map attributes)
         throws java.lang.Exception
As per interface's contract. Performance Note: Optimised O(nodeDepth) db calls.

Parameters:
name - The fully qualified name of the node
attributes - A Map of attributes. Can be null
Throws:
java.lang.Exception

remove

public void remove(Fqn fqn)
            throws java.lang.Exception
As per interface's contrect. Performance Note: O(1) db calls.

Parameters:
fqn - the Fqn of the node
Throws:
java.lang.Exception

getNodeDataList

protected void getNodeDataList(Fqn fqn,
                               java.util.List<NodeData> list)
                        throws java.lang.Exception
Subscribes to contract. Performance Note: O(2) db calls.

Overrides:
getNodeDataList in class AbstractCacheLoader
Throws:
java.lang.Exception

getLogger

protected org.apache.commons.logging.Log getLogger()
Specified by:
getLogger in class AdjListJDBCCacheLoader

start

public void start()
           throws java.lang.Exception
Start is overwritten for the sake of backward compatibility only. Here is the issue: old implementation does not create a Fqn.ROOT if not specifically told so. As per put's contract, when calling put('/a/b/c', 'key', 'value') all parent nodes should be created up to root. Root is not created, though. The compatibility problem comes in the case of loade ENTIRE state. The implementation checks node's existence firstly, and based on that continues or not. As root is not persisted nothing is loaded etc.

Specified by:
start in interface CacheLoader
Overrides:
start in class AdjListJDBCCacheLoader
Throws:
java.lang.Exception

getNodeCount

public int getNodeCount()
                 throws java.lang.Exception
Returns a number representing the count of persisted children.

Throws:
java.lang.Exception

getConfig

public CacheLoaderConfig.IndividualCacheLoaderConfig getConfig()
Description copied from interface: CacheLoader
Gets the configuration.

Returns:
the configuration, represented by a CacheLoaderConfig.IndividualCacheLoaderConfig object.