org.schemarepo
Class LocalFileSystemRepository
java.lang.Object
org.schemarepo.BaseRepository
org.schemarepo.AbstractBackendRepository
org.schemarepo.LocalFileSystemRepository
- All Implemented Interfaces:
- Closeable, Repository
public class LocalFileSystemRepository
- extends AbstractBackendRepository
A Repository that persists content to file.
The Repository stores all of its data in a single base directory.
Within this directory each Subject is represented by a nested
directory with the same name as the Subject. Within each
Subject directory there are three file types:
A properties file named 'subject.properties' containing the configured
properties for the Subject. At this time, the only used property is
"schema-repo.validator.class".
A text file named 'schema_ids' containing the schema ids, in order of their
creation, delimited by newline, encoded in UTF-8. This is used to track the
order of schema registration for Subject.latest() and
Subject.allEntries()
One file per schema the contents of which are the schema encoded in UTF-8 and
the name of which is the schema id followed by the postfix '.schema'.
LocalFileSystemRepository
@Inject
public LocalFileSystemRepository(@Named(value="schema-repo.local-file-system.path")
String repoPath,
ValidatorFactory validators)
- Create a LocalFileSystemRepository in the directory path provided. Locks a file
"repository.lock" to ensure no other object or process is running a
LocalFileSystemRepository from the same place. The lock is released if
close() is called, the object is finalized, or the JVM exits.
Not all platforms support file locks. See FileLock
- Parameters:
repoPath - The path where to store the Repository's state
close
public void close()
- Specified by:
close in interface Closeable- Overrides:
close in class BaseRepository
getSubjectInstance
protected Subject getSubjectInstance(String subjectName)
- Description copied from class:
AbstractBackendRepository
- Concrete subclasses must override to return specific implementation of
Subject.
Note that this instantiates the "right" subject only, any "side effects" (such as mutating persistent state)
must be implemented in AbstractBackendRepository.registerSubjectInBackend(String, SubjectConfig)
- Specified by:
getSubjectInstance in class AbstractBackendRepository
- Parameters:
subjectName - subject name
- Returns:
- Subject
registerSubjectInBackend
protected void registerSubjectInBackend(String subjectName,
SubjectConfig config)
- Description copied from class:
AbstractBackendRepository
- Backend-specific registration logic. This is called during registration upon cache miss.
Responsible for the persistent "side effects".
- Specified by:
registerSubjectInBackend in class AbstractBackendRepository
- Parameters:
subjectName - subject nameconfig - subject config
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.