|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.extensions.surf.util.AbstractLifecycleBean org.springframework.extensions.config.BaseConfigService
public abstract class BaseConfigService
Base class for all config service implementations. This class implements the basic algorithm for performing lookups, concrete classes read their configuration medium and populate this object ready for lookups. The algorithm used is as follows:
Lookup methods go through the list of sections (maybe restricted to an area) and looks at the evaluator for each one. The Evaluator implementation is extracted and applies() is called on it. If applies() returns true all the ConfigElements from it are added to the Config object. If the ConfigElement already exists in the Config object being built up the new one is combined() with the existing one.
Field Summary | |
---|---|
protected List<ConfigDeployer> |
configDeployers
|
protected ConfigSource |
configSource
|
Fields inherited from class org.springframework.extensions.surf.util.AbstractLifecycleBean |
---|
log |
Constructor Summary | |
---|---|
BaseConfigService(ConfigSource configSource)
Construct the service with the source from which it must read |
Method Summary | |
---|---|
protected void |
addConfigSection(ConfigSection section,
String area)
Adds the given config section to the config service and optionally within a named area |
void |
addDeployer(ConfigDeployer configDeployer)
Register deployer |
protected void |
addEvaluator(String name,
Evaluator evaluator)
Adds the evaluator to the config service |
List<ConfigDeployment> |
appendConfig(ConfigSource configSource)
|
protected Evaluator |
createEvaluator(String name,
String className)
Instantiate the evaluator with the given name and class |
void |
destroy()
Cleans up all the resources used by the config service |
Config |
getConfig(Object object)
Retrieves the configuration for the given object |
Config |
getConfig(Object object,
ConfigLookupContext context)
Retrieves the configuration for the given object using the given context |
protected Evaluator |
getEvaluator(String name)
Retrieves the implementation of the named evaluator |
protected Map<String,Evaluator> |
getEvaluators()
Get evaluators from the in-memory 'cache' |
Config |
getGlobalConfig()
Returns just the global configuration, this allows the config service to be used independently of objects if desired (all config is placed in a global section). |
protected ConfigImpl |
getGlobalConfigImpl()
Get globalConfig from the in-memory 'cache' |
protected List<ConfigSection> |
getSections()
Get the sections from the in-memory 'cache' |
protected Map<String,List<ConfigSection>> |
getSectionsByArea()
Get the sectionsByArea from the in-memory 'cache' |
void |
init()
Deprecated. Should now be initialised via bootstrap mechanism. |
List<ConfigDeployment> |
initConfig()
Initialises the config service - via bootstrap |
protected void |
onBootstrap(org.springframework.context.ApplicationEvent event)
Initialise config on bootstrap |
protected void |
onShutdown(org.springframework.context.ApplicationEvent event)
Destroy config in shutdown |
protected List<ConfigDeployment> |
parse()
Parses all the files passed to this config service |
protected abstract void |
parse(InputStream stream)
Parses the given config stream |
protected void |
processSection(ConfigSection section,
Object object,
ConfigLookupContext context,
ConfigImpl results)
Determines whether the given section applies for the given object, if it does, the section is added to given results object. |
protected void |
putEvaluators(Map<String,Evaluator> evaluators)
Put evaluators into the in-memory 'cache' |
protected void |
putGlobalConfig(ConfigImpl globalConfig)
Put globalConfig into the in-memory 'cache' |
protected void |
putSections(List<ConfigSection> sections)
Put the sections into the in-memory 'cache' |
protected void |
putSectionsByArea(Map<String,List<ConfigSection>> sectionsByArea)
Put the sectionsByArea into the in-memory 'cache' |
protected void |
removeEvaluators()
Remove evaluators from in-memory 'cache' |
protected void |
removeGlobalConfig()
Remove globalConfig from the in-memory 'cache' |
protected void |
removeSections()
Remove the sections from the in-memory 'cache' |
protected void |
removeSectionsByArea()
Remove the sectionsByArea from the in-memory 'cache' |
void |
reset()
Resets the config service |
Methods inherited from class org.springframework.extensions.surf.util.AbstractLifecycleBean |
---|
getApplicationContext, onApplicationEvent, setApplicationContext |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ConfigSource configSource
protected List<ConfigDeployer> configDeployers
Constructor Detail |
---|
public BaseConfigService(ConfigSource configSource)
configSource
- the source of the configurationsMethod Detail |
---|
public void init()
public List<ConfigDeployment> initConfig()
public void destroy()
public void reset()
reset
in interface ConfigService
public void addDeployer(ConfigDeployer configDeployer)
addDeployer
in interface ConfigService
configDeployer
- public Config getConfig(Object object)
ConfigService
getConfig
in interface ConfigService
object
- The object to use as the basis of the lookup
ConfigService.getConfig(java.lang.Object)
public Config getConfig(Object object, ConfigLookupContext context)
ConfigService
getConfig
in interface ConfigService
object
- The object to use as the basis of the lookupcontext
- The context to use for the lookup
ConfigService.getConfig(java.lang.Object, org.springframework.extensions.config.ConfigLookupContext)
public Config getGlobalConfig()
ConfigService
getGlobalConfig
in interface ConfigService
ConfigService.getGlobalConfig()
public List<ConfigDeployment> appendConfig(ConfigSource configSource)
appendConfig
in interface ConfigService
ConfigService.appendConfig(org.springframework.extensions.config.ConfigSource)
protected List<ConfigDeployment> parse()
protected abstract void parse(InputStream stream)
stream
- The input stream representing the config dataprotected void addConfigSection(ConfigSection section, String area)
section
- The config section to addarea
- The name of the area to add the section to, if null the
section is only added to the global section listprotected Evaluator getEvaluator(String name)
name
- Name of the evaluator to retrieve
protected void addEvaluator(String name, Evaluator evaluator)
name
- Name of the evaluatorevaluator
- The evaluatorprotected Evaluator createEvaluator(String name, String className)
name
- Name of the evaluatorclassName
- Class name of the evaluatorprotected void processSection(ConfigSection section, Object object, ConfigLookupContext context, ConfigImpl results)
section
- The section to processobject
- The object to retrieve config forcontext
- The context to use for the lookupresults
- The resulting config object for the searchprotected ConfigImpl getGlobalConfigImpl()
protected void putGlobalConfig(ConfigImpl globalConfig)
globalConfig
- protected void removeGlobalConfig()
protected Map<String,Evaluator> getEvaluators()
protected void putEvaluators(Map<String,Evaluator> evaluators)
evaluators
- protected void removeEvaluators()
protected Map<String,List<ConfigSection>> getSectionsByArea()
protected void putSectionsByArea(Map<String,List<ConfigSection>> sectionsByArea)
sectionsByArea
- protected void removeSectionsByArea()
protected List<ConfigSection> getSections()
protected void putSections(List<ConfigSection> sections)
sections
- protected void removeSections()
protected void onBootstrap(org.springframework.context.ApplicationEvent event)
onBootstrap
in class AbstractLifecycleBean
protected void onShutdown(org.springframework.context.ApplicationEvent event)
onShutdown
in class AbstractLifecycleBean
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |