com.trendmicro.grid.acl.ds
Class RepositoriesContext

java.lang.Object
  extended by com.trendmicro.grid.acl.ds.RepositoriesContext
All Implemented Interfaces:
RepositorySelectorsRepository

@Component
public class RepositoriesContext
extends Object
implements RepositorySelectorsRepository

Is a central context that allows accessing all registered data repositories.

Note: Avoid using the context directly, instead just implement SelectorAware, inside your spring beans and an implementation of RepositorySelectorsRepository is injected whenever selector instances have changed.

Version:
1.0
Author:
juergen_kellerer, 2010-05-05

Constructor Summary
RepositoriesContext()
           
 
Method Summary
 List<RepositorySelector<?>> getAllSelectors()
           
<R extends Repository>
R
getRepository(Class<R> repositoryClass)
          Returns the selected repository implementation for the given repository interface.
<R extends Repository>
RepositorySelector<R>
getSelector(Class<R> repositoryClass)
          Returns a repository selector for the given class.
 void initializeAllSelectors()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RepositoriesContext

public RepositoriesContext()
Method Detail

initializeAllSelectors

@PostConstruct
public void initializeAllSelectors()

getAllSelectors

public List<RepositorySelector<?>> getAllSelectors()

getSelector

public <R extends Repository> RepositorySelector<R> getSelector(Class<R> repositoryClass)
Returns a repository selector for the given class.

Specified by:
getSelector in interface RepositorySelectorsRepository
Type Parameters:
R - the type of repository interface to return.
Parameters:
repositoryClass - the repository interface of the selector to return.
Returns:
a selector for the given class, returns an empty selector instance if no selector exists for a given repository.

getRepository

public <R extends Repository> R getRepository(Class<R> repositoryClass)
Returns the selected repository implementation for the given repository interface.

Type Parameters:
R - the type of repository interface to return.
Parameters:
repositoryClass - the repository interface of the repository to return.
Returns:
the selected repository implementation for the given repository interface or 'null' if no implementation is registered.