|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.schemarepo.BaseRepository
org.schemarepo.DelegatingRepository
org.schemarepo.CacheRepository
public class CacheRepository
CacheRepository is a Repository implementation that wraps another
Repository and acts as a write-through cache of Subjects and
schema to id mappings, shielding the inner Repository from repetitive
lookups.
CacheRepository can cache Subjects (which cannot be deleted) and returns an
implementation of Subject that caches schema to id mappings.
CacheRepository can only cache the immutable elements of a Repository, because
it is intended for use in any context -- in a client, in a proxy, or above a raw
implementation of a repository.
It cannot cache the entire list of subjects since the list is mutable.
Similarly, a cached subject cannot cache the list of schemas, the subject configuration,
or the latest() schema because those are mutable.
| Field Summary |
|---|
| Fields inherited from class org.schemarepo.DelegatingRepository |
|---|
repo |
| Fields inherited from class org.schemarepo.BaseRepository |
|---|
closed, logger |
| Constructor Summary | |
|---|---|
CacheRepository(Repository repo,
RepositoryCache cache)
Create a caching repository that wraps the provided repository using the cache provided |
|
| Method Summary | |
|---|---|
protected Map<String,String> |
exposeConfiguration()
Expose certain configuration elements as properties. |
Subject |
lookup(String subjectName)
Returns the subject if it exists, null otherwise. |
Subject |
register(String subjectName,
SubjectConfig config)
Attempt to create a Subject with the given name and validator. |
Iterable<Subject> |
subjects()
List all subjects. |
| Methods inherited from class org.schemarepo.DelegatingRepository |
|---|
close, isValid |
| Methods inherited from class org.schemarepo.BaseRepository |
|---|
toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
@Inject
public CacheRepository(Repository repo,
RepositoryCache cache)
repo - The repository to wrapcache - The cache to use| Method Detail |
|---|
public Subject register(String subjectName,
SubjectConfig config)
Repository
register in interface Repositoryregister in class DelegatingRepositorysubjectName - The name of the subject. Must not be null.config - The subject configuration. May be null.
public Subject lookup(String subjectName)
Repository
lookup in interface Repositorylookup in class DelegatingRepositorysubjectName - the subject name
public Iterable<Subject> subjects()
Repository
subjects in interface Repositorysubjects in class DelegatingRepositoryprotected Map<String,String> exposeConfiguration()
BaseRepositoryRemember to call
superwhen overriding!
exposeConfiguration in class DelegatingRepository
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||