public abstract class AbstractDatabase extends Object implements LookupService, LifeCycle
This class is an abstract implementation of the LookupService which provides an in-memory lookup table that is populated from a data source. Specific non-abstract implementations will need to implement the way to read the in-memory lookup table (hashmap).
| Modifier and Type | Field and Description |
|---|---|
(package private) Map<String,Data> |
database |
(package private) String |
key |
(package private) static org.slf4j.Logger |
log |
(package private) SourceURL |
url |
| Constructor and Description |
|---|
AbstractDatabase() |
| Modifier and Type | Method and Description |
|---|---|
void |
finish() |
String |
getKey() |
SourceURL |
getUrl() |
void |
init(ApplicationContext context) |
Data |
lookup(String key) |
protected abstract void |
populateDatabase(SourceURL url,
Map<String,Data> database) |
protected void |
readDatabase(Stream stream,
Map<String,Data> database) |
void |
reset() |
void |
setKey(String key) |
void |
setUrl(SourceURL url) |
public void reset()
throws Exception
reset in interface ServiceExceptionService.reset()public void init(ApplicationContext context) throws Exception
protected abstract void populateDatabase(SourceURL url, Map<String,Data> database) throws Exception
Exceptionprotected void readDatabase(Stream stream, Map<String,Data> database) throws Exception
Exceptionpublic void finish()
throws Exception
finish in interface LifeCycleExceptionLifeCycle.finish()public Data lookup(String key)
lookup in interface LookupServiceLookupService.lookup(java.lang.String)public String getKey()
@Parameter(description="The lookup-key that is used for storing items in the lookup table. This key must be present in the items that are being read from the datasource while populating the database. Default value is \'@id\'.", required=false) public void setKey(String key)
key - the key to setpublic SourceURL getUrl()
@Parameter(description="The source URL from which data should be read at startup. This data is then used for populating the lookup table.", required=true) public void setUrl(SourceURL url)
url - the url to setCopyright © 2018. All rights reserved.