org.apache.openjpa.kernel
Class FetchConfigurationImpl

java.lang.Object
  extended by org.apache.openjpa.kernel.FetchConfigurationImpl
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, FetchConfiguration, LockLevels, LockScopes, QueryFlushModes
Direct Known Subclasses:
JDBCFetchConfigurationImpl

public class FetchConfigurationImpl
extends java.lang.Object
implements FetchConfiguration, java.lang.Cloneable

Allows configuration and optimization of how objects are loaded from the data store.

Since:
0.3.0
Author:
Abe White, Pinaki Poddar
See Also:
Serialized Form

Nested Class Summary
protected static class FetchConfigurationImpl.ConfigurationState
          Configurable state shared throughout a traversal chain.
 
Field Summary
 
Fields inherited from interface org.apache.openjpa.kernel.FetchConfiguration
DEFAULT, FETCH_LOAD, FETCH_NONE, FETCH_REF
 
Fields inherited from interface org.apache.openjpa.kernel.LockLevels
LOCK_NONE, LOCK_READ, LOCK_WRITE
 
Fields inherited from interface org.apache.openjpa.kernel.LockScopes
LOCKSCOPE_EXTENDED, LOCKSCOPE_NORMAL
 
Fields inherited from interface org.apache.openjpa.kernel.QueryFlushModes
FLUSH_FALSE, FLUSH_TRUE, FLUSH_WITH_CONNECTION
 
Constructor Summary
  FetchConfigurationImpl()
           
protected FetchConfigurationImpl(FetchConfigurationImpl.ConfigurationState state)
           
 
Method Summary
 FetchConfiguration addFetchGroup(java.lang.String name)
          Adds group to the set of fetch group names to use when loading objects.
 FetchConfiguration addFetchGroups(java.util.Collection<java.lang.String> groups)
          Adds groups to the set of fetch group names to use when loading objects.
 FetchConfiguration addField(java.lang.String field)
          Adds field to the set of fully-qualified field names to use when loading objects.
 FetchConfiguration addFields(java.util.Collection<java.lang.String> fields)
          Adds fields to the set of fully-qualified field names to use when loading objects.
 FetchConfiguration clearFetchGroups()
          Clears the set of fetch group names to use when loading data.
 FetchConfiguration clearFields()
          Clears the set of field names to use when loading data.
 java.lang.Object clone()
          Clone this instance.
 void copy(FetchConfiguration fetch)
          Copy the state from the given fetch configuration to this one.
 DataCacheRetrieveMode getCacheRetrieveMode()
          Gets the current retrieve mode for data cache.
 DataCacheStoreMode getCacheStoreMode()
          Gets the current storage mode for data cache.
 StoreContext getContext()
          Return the context associated with this configuration; may be null if it has not been set or this object has been serialized.
 boolean getExtendedPathLookup()
          Affirms if extended path lookup feature is active.
 int getFetchBatchSize()
          Return the fetch batch size for large result set support.
 java.util.Set<java.lang.String> getFetchGroups()
          Returns immutable set of names of the fetch groups that this component will use when loading objects.
 java.util.Set<java.lang.String> getFields()
          Returns the set of fully-qualified field names that this component will use when loading objects.
 int getFlushBeforeQueries()
          The query automatic flush configuration.
 java.lang.Object getHint(java.lang.String name)
          Get the hint value for the specific key as originally set by the caller, or null if the hint is not specified.
 java.util.Map<java.lang.String,java.lang.Object> getHints()
          Gets the current hints set on this receiver.
 int getLockScope()
          The lock scope for next fetch.
 int getLockTimeout()
          The number of milliseconds to wait for an object lock, or -1 for no limit.
 int getMaxFetchDepth()
          Return the maximum depth of fetched instance graph.
 boolean getQueryCacheEnabled()
          Return whether or not query caching is enabled.
 int getQueryTimeout()
          The number of milliseconds to wait for a query, or -1 for no limit.
 int getReadLockLevel()
          The lock level to use for locking loaded objects.
 java.util.Set<java.lang.Class<?>> getRootClasses()
          Root classes for recursive operations.
 java.util.Set<java.lang.Object> getRootInstances()
          Root instances for recursive operations.
 java.util.Collection<java.lang.String> getSupportedHints()
           
 int getWriteLockLevel()
          The lock level to use for locking dirtied objects.
 boolean hasFetchGroup(java.lang.String group)
          Return true if the given fetch group has been added.
 boolean hasFetchGroupAll()
           
 boolean hasFetchGroupDefault()
           
 boolean hasField(java.lang.String field)
          Return true if the given fully-qualified field has been added.
 boolean isHintSet(java.lang.String key)
          Affirms if the given key is set as a hint.
 void lock()
          Synchronize on internal lock if multithreaded is true.
protected  FetchConfigurationImpl newInstance(FetchConfigurationImpl.ConfigurationState state)
          Return a new hollow instance.
 ResultList<?> newResultList(ResultObjectProvider rop)
          Return a new result list for the current fetch configuration.
protected static void populateHintSetter(java.lang.Class<?> target, java.lang.String hint, java.lang.Class<?> type, java.lang.String... prefixes)
          Populate static registry of hints.
protected static void populateHintSetter(java.lang.Class<?> target, java.lang.String method, java.lang.String hint, java.lang.Class<?> type, java.lang.String... prefixes)
          Populate static registry of hints.
 FetchConfiguration removeFetchGroup(java.lang.String group)
          Remove the given fetch group.
 FetchConfiguration removeFetchGroups(java.util.Collection<java.lang.String> groups)
          Removes groups from the set of fetch group names to use when loading objects.
 FetchConfiguration removeField(java.lang.String field)
          Remove the given fully-qualified field.
 FetchConfiguration removeFields(java.util.Collection<java.lang.String> fields)
          Removes fields from the set of fully-qualified field names to use when loading objects.
 void removeHint(java.lang.String... keys)
          Removes the given keys and their hint value.
 java.lang.Object removeHint(java.lang.String name)
           
 int requiresFetch(FieldMetaData fm)
          Affirms if the given field requires to be fetched in the context of current fetch operation.
 boolean requiresLoad()
          Return false if we know that the object being fetched with this configuration does not require a load, because this configuration came from a traversal of a FetchConfiguration.FETCH_REF field.
 FetchConfiguration resetFetchGroups()
          Resets the set of fetch groups to the list in the global configuration.
 void setCacheRetrieveMode(DataCacheRetrieveMode mode)
          Sets the current retrieve mode for data cache.
 void setCacheStoreMode(DataCacheStoreMode mode)
          Sets the current storage mode for data cache.
 void setContext(StoreContext ctx)
          Called automatically by the system to associate the fetch configuration with a context before use.
 FetchConfiguration setExtendedPathLookup(boolean flag)
          Sets extended path lookup feature.
 FetchConfiguration setFetchBatchSize(int fetchBatchSize)
          Set the fetch batch size for large result set support.
 FetchConfiguration setFlushBeforeQueries(int flush)
          The query automatic flush configuration.
 void setHint(java.lang.String key, java.lang.Object value)
          Same as setHint(key, value, value).
 void setHint(java.lang.String key, java.lang.Object value, java.lang.Object original)
          Sets the hint to the given value.
 FetchConfiguration setLockScope(int scope)
          The lock scope for next fetch.
 FetchConfiguration setLockTimeout(int timeout)
          The number of milliseconds to wait for an object lock, or -1 for no limit.
 FetchConfiguration setMaxFetchDepth(int depth)
          Set the maximum depth of the fetched instance graph.
 FetchConfiguration setQueryCacheEnabled(boolean cache)
          Control whether or not query caching is enabled.
 FetchConfiguration setQueryTimeout(int timeout)
          The number of milliseconds to wait for a query, or -1 for no limit.
 FetchConfiguration setReadLockLevel(int level)
          The lock level to use for locking loaded objects.
 FetchConfiguration setRootClasses(java.util.Collection<java.lang.Class<?>> classes)
          Root classes for recursive operations.
 FetchConfiguration setRootInstances(java.util.Collection<?> instances)
          Root instances for recursive operations.
 FetchConfiguration setWriteLockLevel(int level)
          The lock level to use for locking dirtied objects.
 java.lang.String toString()
           
protected  java.lang.String toString(java.lang.Object o)
           
 FetchConfiguration traverse(FieldMetaData fm)
          Traverse the given field to generate (possibly) a new configuration state.
 void unlock()
          Release internal lock if multithreaded is true.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FetchConfigurationImpl

public FetchConfigurationImpl()

FetchConfigurationImpl

protected FetchConfigurationImpl(FetchConfigurationImpl.ConfigurationState state)
Method Detail

populateHintSetter

protected static void populateHintSetter(java.lang.Class<?> target,
                                         java.lang.String hint,
                                         java.lang.Class<?> type,
                                         java.lang.String... prefixes)
Populate static registry of hints.

Parameters:
target - The name of the target class that will receive this hint.
hint - the simple name of the hint without a prefix.
type - the value argument type of the target setter method.
prefixes - the prefixes will be added to the simple hint name.

populateHintSetter

protected static void populateHintSetter(java.lang.Class<?> target,
                                         java.lang.String method,
                                         java.lang.String hint,
                                         java.lang.Class<?> type,
                                         java.lang.String... prefixes)
Populate static registry of hints.

Parameters:
target - The name of the target class that will receive this hint.
method - The name of the method in the target class that will receive this hint.
hint - the simple name of the hint without a prefix.
type - the value argument type of the target setter method.
prefixes - the prefixes will be added to the simple hint name.

getContext

public StoreContext getContext()
Description copied from interface: FetchConfiguration
Return the context associated with this configuration; may be null if it has not been set or this object has been serialized.

Specified by:
getContext in interface FetchConfiguration

setContext

public void setContext(StoreContext ctx)
Description copied from interface: FetchConfiguration
Called automatically by the system to associate the fetch configuration with a context before use. The fetch configuration properties should be synchronized with the context's configuration object. Subclasses for specific back ends cannot rely on the context's configuration implementing their back end's configuration sub-interface.

Specified by:
setContext in interface FetchConfiguration

clone

public java.lang.Object clone()
Clone this instance.

Specified by:
clone in interface FetchConfiguration
Overrides:
clone in class java.lang.Object

newInstance

protected FetchConfigurationImpl newInstance(FetchConfigurationImpl.ConfigurationState state)
Return a new hollow instance.


copy

public void copy(FetchConfiguration fetch)
Description copied from interface: FetchConfiguration
Copy the state from the given fetch configuration to this one.

Specified by:
copy in interface FetchConfiguration

getFetchBatchSize

public int getFetchBatchSize()
Description copied from interface: FetchConfiguration
Return the fetch batch size for large result set support. Defaults to the openjpa.FetchBatchSize setting. Note that this property will be ignored under some data stores.

Specified by:
getFetchBatchSize in interface FetchConfiguration

setFetchBatchSize

public FetchConfiguration setFetchBatchSize(int fetchBatchSize)
Description copied from interface: FetchConfiguration
Set the fetch batch size for large result set support. Defaults to the openjpa.FetchBatchSize setting. Note that this property will be ignored under some data stores.

Specified by:
setFetchBatchSize in interface FetchConfiguration

getMaxFetchDepth

public int getMaxFetchDepth()
Description copied from interface: FetchConfiguration
Return the maximum depth of fetched instance graph. Defaults to 1

Specified by:
getMaxFetchDepth in interface FetchConfiguration

setMaxFetchDepth

public FetchConfiguration setMaxFetchDepth(int depth)
Description copied from interface: FetchConfiguration
Set the maximum depth of the fetched instance graph.

Specified by:
setMaxFetchDepth in interface FetchConfiguration
Parameters:
depth - denotes limiting length of traversal path from a root instance. -1 implies no limit. 0 is not permissible.

getQueryCacheEnabled

public boolean getQueryCacheEnabled()
Description copied from interface: FetchConfiguration
Return whether or not query caching is enabled. If this returns true but the datacache plugin is not installed, caching will not be enabled. If this returns false, query caching will not be used even if the datacache plugin is installed.

Specified by:
getQueryCacheEnabled in interface FetchConfiguration

setQueryCacheEnabled

public FetchConfiguration setQueryCacheEnabled(boolean cache)
Description copied from interface: FetchConfiguration
Control whether or not query caching is enabled. This has no effect if the datacache plugin is not installed, or if the query cache size is set to zero.

Specified by:
setQueryCacheEnabled in interface FetchConfiguration

getFlushBeforeQueries

public int getFlushBeforeQueries()
Description copied from interface: FetchConfiguration
The query automatic flush configuration.

Specified by:
getFlushBeforeQueries in interface FetchConfiguration

getExtendedPathLookup

public boolean getExtendedPathLookup()
Description copied from interface: FetchConfiguration
Affirms if extended path lookup feature is active.

Specified by:
getExtendedPathLookup in interface FetchConfiguration

setExtendedPathLookup

public FetchConfiguration setExtendedPathLookup(boolean flag)
Description copied from interface: FetchConfiguration
Sets extended path lookup feature.

Specified by:
setExtendedPathLookup in interface FetchConfiguration

setFlushBeforeQueries

public FetchConfiguration setFlushBeforeQueries(int flush)
Description copied from interface: FetchConfiguration
The query automatic flush configuration.

Specified by:
setFlushBeforeQueries in interface FetchConfiguration

getFetchGroups

public java.util.Set<java.lang.String> getFetchGroups()
Description copied from interface: FetchConfiguration
Returns immutable set of names of the fetch groups that this component will use when loading objects. Defaults to the openjpa.FetchGroups setting. This set is not thread safe.

Specified by:
getFetchGroups in interface FetchConfiguration

hasFetchGroup

public boolean hasFetchGroup(java.lang.String group)
Description copied from interface: FetchConfiguration
Return true if the given fetch group has been added.

Specified by:
hasFetchGroup in interface FetchConfiguration

hasFetchGroupDefault

public boolean hasFetchGroupDefault()

hasFetchGroupAll

public boolean hasFetchGroupAll()

addFetchGroup

public FetchConfiguration addFetchGroup(java.lang.String name)
Description copied from interface: FetchConfiguration
Adds group to the set of fetch group names to use when loading objects.

Specified by:
addFetchGroup in interface FetchConfiguration

addFetchGroups

public FetchConfiguration addFetchGroups(java.util.Collection<java.lang.String> groups)
Description copied from interface: FetchConfiguration
Adds groups to the set of fetch group names to use when loading objects.

Specified by:
addFetchGroups in interface FetchConfiguration

removeFetchGroup

public FetchConfiguration removeFetchGroup(java.lang.String group)
Description copied from interface: FetchConfiguration
Remove the given fetch group.

Specified by:
removeFetchGroup in interface FetchConfiguration

removeFetchGroups

public FetchConfiguration removeFetchGroups(java.util.Collection<java.lang.String> groups)
Description copied from interface: FetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the igurationFetchConfiguration
Removes groups from the iguration