Spring Data Commmons

org.springframework.data.repository.support
Class RepositoryFactorySupport

java.lang.Object
  extended by org.springframework.data.repository.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.QueryExecuterMethodInterceptor
          This MethodInterceptor intercepts calls to methods of the custom implementation and delegates the to it if configured.
 
Constructor Summary
RepositoryFactorySupport()
           
 
Method Summary
protected  void addRepositoryProxyPostProcessor(RepositoryProxyPostProcessor processor)
          Adds RepositoryProxyPostProcessors to the factory to allow manipulation of the ProxyFactory before the proxy gets created.
protected abstract  QueryLookupStrategy getQueryLookupStrategy(QueryLookupStrategy.Key key)
          Returns the QueryLookupStrategy for the given QueryLookupStrategy.Key.
<T extends Repository<?,?>>
T
getRepository(Class<T> repositoryInterface)
          Returns a repository instance for the given interface.
<T extends Repository<?,?>>
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<? extends RepositorySupport> getRepositoryClass(Class<?> repositoryInterface)
          Determines the base class for the repository to be created.
protected abstract
<T,ID extends Serializable>
RepositorySupport<T,ID>
getTargetRepository(Class<T> domainClass, Class<?> repositoryInterface)
          Create a RepositorySupport instance as backing for the query proxy.
 void setQueryLookupStrategyKey(QueryLookupStrategy.Key key)
          Sets the strategy of how to lookup a query to execute finders.
protected  void validate(Class<? extends Repository<?,?>> repositoryInterface, Object customImplementation)
          Validates the given repository interface as well as the given custom implementation.
 
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

addRepositoryProxyPostProcessor

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

Parameters:
processor -

getRepository

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

Type Parameters:
T -
Parameters:
repositoryInterface -
Returns:

getRepository

public <T extends Repository<?,?>> 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:

getTargetRepository

protected abstract <T,ID extends Serializable> RepositorySupport<T,ID> getTargetRepository(Class<T> domainClass,
                                                                                           Class<?> repositoryInterface)
Create a RepositorySupport instance as backing for the query proxy.

Type Parameters:
T -
Parameters:
domainClass -
Returns:

getRepositoryClass

protected abstract Class<? extends RepositorySupport> getRepositoryClass(Class<?> repositoryInterface)
Determines the base class for the repository to be created.

Returns:

getQueryLookupStrategy

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

Parameters:
key - can be null
Returns:

validate

protected void validate(Class<? extends Repository<?,?>> repositoryInterface,
                        Object customImplementation)
Validates the given repository interface as well as the given custom implementation.

Parameters:
repositoryInterface -
customImplementation -

Spring Data Commmons

Copyright © 2011. All Rights Reserved.