Spring Data Commons

org.springframework.data.repository.core.support
Class RepositoryFactorySupport

java.lang.Object
  extended by org.springframework.data.repository.core.support.RepositoryFactorySupport

public abstract class RepositoryFactorySupport
extends Object

Factory bean to create instances of a given repository interface. Creates a proxy implementing the configured repository interface and apply an advice handing the control to the QueryExecuterMethodInterceptor. Query detection strategy can be configured by setting QueryLookupStrategy.Key.

Author:
Oliver Gierke

Nested Class Summary
 class RepositoryFactorySupport.QueryExecutorMethodInterceptor
          This MethodInterceptor intercepts calls to methods of the custom implementation and delegates the to it if configured.
 
Constructor Summary
RepositoryFactorySupport()
           
 
Method Summary
 void addQueryCreationListener(QueryCreationListener<?> listener)
          Adds a QueryCreationListener to the factory to plug in functionality triggered right after creation of RepositoryQuery instances.
 void addRepositoryProxyPostProcessor(RepositoryProxyPostProcessor processor)
          Adds RepositoryProxyPostProcessors to the factory to allow manipulation of the ProxyFactory before the proxy gets created.
abstract
<T,ID extends Serializable>
EntityInformation<T,ID>
getEntityInformation(Class<T> domainClass)
          Returns the EntityInformation for the given domain class.
protected  QueryLookupStrategy getQueryLookupStrategy(QueryLookupStrategy.Key key)
          Returns the QueryLookupStrategy for the given QueryLookupStrategy.Key.
protected  List<QueryMethod> getQueryMethods()
           
<T> T
getRepository(Class<T> repositoryInterface)
          Returns a repository instance for the given interface.
<T> T
getRepository(Class<T> repositoryInterface, Object customImplementation)
          Returns a repository instance for the given interface backed by an instance providing implementation logic for custom logic.
protected abstract  Class<?> getRepositoryBaseClass(RepositoryMetadata metadata)
          Returns the base class backing the actual repository instance.
protected  RepositoryInformation getRepositoryInformation(RepositoryMetadata metadata, Class<?> customImplementationClass)
          Returns the RepositoryInformation for the given repository interface.
protected abstract  Object getTargetRepository(RepositoryMetadata metadata)
          Create a repository instance as backing for the query proxy.
 void setNamedQueries(NamedQueries namedQueries)
          Configures a NamedQueries instance to be handed to the QueryLookupStrategy for query creation.
 void setQueryLookupStrategyKey(QueryLookupStrategy.Key key)
          Sets the strategy of how to lookup a query to execute finders.
protected  void validate(RepositoryMetadata repositoryMetadata)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RepositoryFactorySupport

public RepositoryFactorySupport()
Method Detail

setQueryLookupStrategyKey

public void setQueryLookupStrategyKey(QueryLookupStrategy.Key key)
Sets the strategy of how to lookup a query to execute finders.

Parameters:
queryLookupStrategy - the createFinderQueries to set

setNamedQueries

public void setNamedQueries(NamedQueries namedQueries)
Configures a NamedQueries instance to be handed to the QueryLookupStrategy for query creation.

Parameters:
namedQueries - the namedQueries to set

addQueryCreationListener

public void addQueryCreationListener(QueryCreationListener<?> listener)
Adds a QueryCreationListener to the factory to plug in functionality triggered right after creation of RepositoryQuery instances.

Parameters:
listener -

addRepositoryProxyPostProcessor

public void addRepositoryProxyPostProcessor(RepositoryProxyPostProcessor processor)
Adds RepositoryProxyPostProcessors to the factory to allow manipulation of the ProxyFactory before the proxy gets created. Note that the RepositoryFactorySupport.QueryExecutorMethodInterceptor will be added to the proxy after the RepositoryProxyPostProcessors are considered.

Parameters:
processor -

getRepository

public <T> T getRepository(Class<T> repositoryInterface)
Returns a repository instance for the given interface.

Type Parameters:
T -
Parameters:
repositoryInterface -
Returns:

getRepository

public <T> T getRepository(Class<T> repositoryInterface,
                           Object customImplementation)
Returns a repository instance for the given interface backed by an instance providing implementation logic for custom logic.

Type Parameters:
T -
Parameters:
repositoryInterface -
customImplementation -
Returns:

getRepositoryInformation

protected RepositoryInformation getRepositoryInformation(RepositoryMetadata metadata,
                                                         Class<?> customImplementationClass)
Returns the RepositoryInformation for the given repository interface.

Parameters:
repositoryInterface -
customImplementationClass -
Returns:

getQueryMethods

protected List<QueryMethod> getQueryMethods()

getEntityInformation

public abstract <T,ID extends Serializable> EntityInformation<T,ID> getEntityInformation(Class<T> domainClass)
Returns the EntityInformation for the given domain class.

Type Parameters:
T - the entity type
ID - the id type
Parameters:
domainClass -
Returns:

getTargetRepository

protected abstract Object getTargetRepository(RepositoryMetadata metadata)
Create a repository instance as backing for the query proxy.

Parameters:
metadata -
Returns:

getRepositoryBaseClass

protected abstract Class<?> getRepositoryBaseClass(RepositoryMetadata metadata)
Returns the base class backing the actual repository instance. Make sure getTargetRepository(RepositoryMetadata) returns an instance of this class.

Parameters:
metadata -
Returns:

getQueryLookupStrategy

protected QueryLookupStrategy getQueryLookupStrategy(QueryLookupStrategy.Key key)
Returns the QueryLookupStrategy for the given QueryLookupStrategy.Key.

Parameters:
key - can be null
Returns:
the QueryLookupStrategy to use or null if no queries should be looked up.

validate

protected void validate(RepositoryMetadata repositoryMetadata)

Spring Data Commons

Copyright © 2012. All Rights Reserved.