org.schemarepo
Class DelegatingRepository

java.lang.Object
  extended by org.schemarepo.BaseRepository
      extended by org.schemarepo.DelegatingRepository
All Implemented Interfaces:
Closeable, Repository
Direct Known Subclasses:
CacheRepository, ReadOnlyRepository

public abstract class DelegatingRepository
extends BaseRepository

Base class for all delegating repositories. Implements decorator pattern.


Field Summary
protected  Repository repo
           
 
Fields inherited from class org.schemarepo.BaseRepository
closed, logger
 
Constructor Summary
protected DelegatingRepository(Repository delegate)
           
 
Method Summary
 void close()
           
protected  Map<String,String> exposeConfiguration()
          Expose certain configuration elements as properties.
 void isValid()
          Asserts the repository is in a valid state (for ex.
 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.BaseRepository
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

repo

protected final Repository repo
Constructor Detail

DelegatingRepository

protected DelegatingRepository(Repository delegate)
Method Detail

isValid

public void isValid()
Description copied from class: BaseRepository
Asserts the repository is in a valid state (for ex. not closed).

Overrides:
isValid in class BaseRepository

register

public Subject register(String subjectName,
                        SubjectConfig config)
Description copied from interface: Repository
Attempt to create a Subject with the given name and validator.

Parameters:
subjectName - The name of the subject. Must not be null.
config - The subject configuration. May be null.
Returns:
The newly created Subject, or an equivalent one if already created. Does not return null.

lookup

public Subject lookup(String subjectName)
Description copied from interface: Repository
Returns the subject if it exists, null otherwise.

Parameters:
subjectName - the subject name
Returns:
The subject if it exists, null otherwise.

subjects

public Iterable<Subject> subjects()
Description copied from interface: Repository
List all subjects. Does not return null.


close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class BaseRepository
Throws:
IOException

exposeConfiguration

protected Map<String,String> exposeConfiguration()
Description copied from class: BaseRepository
Expose certain configuration elements as properties. This can be used to construct a useful toString() response, for ex.

Remember to call

super
when overriding!

Overrides:
exposeConfiguration in class BaseRepository
Returns:
Map representing properties; note that the actual implementation may be immutable


Copyright © 2015. All rights reserved.