ca.uhn.cache.impl
Class SelfCachingDataSource

java.lang.Object
  extended byca.uhn.cache.impl.SelfCachingDataSource
All Implemented Interfaces:
IDataSource, org.springframework.beans.factory.InitializingBean

public class SelfCachingDataSource
extends java.lang.Object
implements IDataSource, org.springframework.beans.factory.InitializingBean

An IDataSource that is an underlying IDataSource wrapped in a read-through cache. TODO: We allow a single result to correspond to multiple queries in IDataSource ... this might create a cache consistency problem ... if a query is performed, then we get remainder results, then the cached portion is purged, then we populate the cache with the remainder, then the descriptor of the remainder will include the cached portion which has been purged. We don't get this problem if we only allow one query per result.

Version:
$Revision: 1.1 $ updated on $Date: 2005/01/24 22:52:33 $ by $Author: btripp $
Author:
Bryan Tripp

Constructor Summary
SelfCachingDataSource()
          Default constructor.
 
Method Summary
 void afterPropertiesSet()
          
 IQueryResult execute(IQuery[] theQueries)
          Note that there is no optimization for sending multiple queries at once (queries are executed in series).
 IDataSource getDataSource()
          The underlying data source.
 int getMaxQueryGroups()
           
 ISemanticCache getSemanticCache()
           
 void setDataSource(IDataSource theDataSource)
           
 void setMaxQueryGroups(int theMaxQueryGroups)
           
 void setSemanticCache(ISemanticCache theSemanticCache)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SelfCachingDataSource

public SelfCachingDataSource()
Default constructor.

Method Detail

execute

public IQueryResult execute(IQuery[] theQueries)
                     throws DataSourceException
Note that there is no optimization for sending multiple queries at once (queries are executed in series).

Specified by:
execute in interface IDataSource
Parameters:
theQueries - queries to run
Returns:
data matching the given queries (may return before all data are available)
Throws:
DataSourceException - If the execute operation could not be successfully completed.
See Also:
IDataSource.execute(ca.uhn.cache.IQuery[])

getSemanticCache

public ISemanticCache getSemanticCache()
Returns:
Semantic cache that holds query results and may partially or completely answer queries.

setSemanticCache

public void setSemanticCache(ISemanticCache theSemanticCache)
Parameters:
theSemanticCache - The semantic cache to set.

getMaxQueryGroups

public int getMaxQueryGroups()
Returns:
The maximum number of queries that will be sent to the underlying data source at a time.
See Also:
ISemanticCache.remainder(IQuery, int)

setMaxQueryGroups

public void setMaxQueryGroups(int theMaxQueryGroups)
Parameters:
theMaxQueryGroups - The maxQueryGroups to set.

getDataSource

public IDataSource getDataSource()
The underlying data source.

Returns:
Returns the source.

setDataSource

public void setDataSource(IDataSource theDataSource)
Parameters:
theDataSource - The source to set.

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception

Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
java.lang.Exception


Copyright © 2004-2005 University Health Network. All Rights Reserved.