com.waveset.object
Class ObjectLoaderBase

java.lang.Object
  extended bycom.waveset.object.ObjectLoaderBase
All Implemented Interfaces:
CacheConsistencyNumberLoader, ObjectLoader

public abstract class ObjectLoaderBase
extends java.lang.Object
implements ObjectLoader

An implementation of the ObjectLoader interface that provides stub implementations for each of the methods. If your loader doesn't already extend something, its usually more convenient to extend this than implement all of the methods.


Constructor Summary
ObjectLoaderBase()
           
 
Method Summary
 int countObjects(RepositoryResult repoResult)
           
 long getCacheConsistencyNumber(Type type)
          Return a Cache Consistency Number.
 PersistentObject loadObject(Type type, java.lang.String id, boolean tolerateMissing, boolean tolerateAuthzFailure, java.util.Map options)
          Load an object from the storage manager.
 java.util.ArrayList loadObjects(Type type, AttributeCondition[] attrConds)
          Load all objects of a given type.
 void nextBlock(RepositoryResult previousResult)
          Load the next blockful of objects into the specified RepositoryResult.
 void previousBlock(RepositoryResult previousResult)
          Load the previous blockful of objects into the specified RepositoryResult.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectLoaderBase

public ObjectLoaderBase()
Method Detail

getCacheConsistencyNumber

public long getCacheConsistencyNumber(Type type)
                               throws WavesetException
Description copied from interface: CacheConsistencyNumberLoader
Return a Cache Consistency Number. This will be called by the ObjectCache prior to any operation that wants to keep the cache up to date. The number returned will be stored in the cache, when it changes, the cache will be flushed.

The loader typically runs a database query after some number of calls to this method, and returns the current CCN. The loader typically does NOT query the database on every call to this method. While that would ensure that the cache is always up to date, it would slow things down, defeating some of the purpose of the cache. The loader should maintain a timestamp of the last database query, and reissue the query after a configurable number of seconds has passed. This behavior is put into the loader rather than the cache so we have fewer objects to update in case the CCN "polling interval" changes.

Specified by:
getCacheConsistencyNumber in interface CacheConsistencyNumberLoader
Throws:
WavesetException

loadObject

public PersistentObject loadObject(Type type,
                                   java.lang.String id,
                                   boolean tolerateMissing,
                                   boolean tolerateAuthzFailure,
                                   java.util.Map options)
                            throws WavesetException
Description copied from interface: ObjectLoader
Load an object from the storage manager. If tolerateMissing is true, silently return null if the object did not exist. If tolerateAuthzFailure is true, silently return null if the requesting admin doesn't have access to the requested object

Specified by:
loadObject in interface ObjectLoader
Throws:
WavesetException - if the object was not found in the storage manager, or an internal error was encountered.

loadObjects

public java.util.ArrayList loadObjects(Type type,
                                       AttributeCondition[] attrConds)
                                throws WavesetException
Description copied from interface: ObjectLoader
Load all objects of a given type. If the optional attribute list is specified, only those objects with matching "query" attributes is returned.

Specified by:
loadObjects in interface ObjectLoader
Throws:
WavesetException - if an internal error was encountered.

countObjects

public int countObjects(RepositoryResult repoResult)
Specified by:
countObjects in interface ObjectLoader
Returns:
the estimated number of rows in the "virtual result" of the specified RepositoryResult. That is, the number of rows the result would contain if it were unbuffered.

nextBlock

public void nextBlock(RepositoryResult previousResult)
               throws WavesetException
Description copied from interface: ObjectLoader
Load the next blockful of objects into the specified RepositoryResult.

Specified by:
nextBlock in interface ObjectLoader
Throws:
WavesetException - if an internal error was encountered.

previousBlock

public void previousBlock(RepositoryResult previousResult)
                   throws WavesetException
Description copied from interface: ObjectLoader
Load the previous blockful of objects into the specified RepositoryResult.

Specified by:
previousBlock in interface ObjectLoader
Throws:
WavesetException - if an internal error was encountered.