|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.locomotive.directory.NameService
A naming service for Java components. This is the core functionality provided by NameService :
The configurations is organized in a tree structure of DirectoryContexts.
Fields inherited from interface org.locomotive.directory.DirectoryEventTypes |
DEBUG,
ERROR,
WARNING |
Constructor Summary | |
NameService()
|
|
NameService(BeanParser beanParser,
java.lang.String[] configPath)
Create a new NameService. |
|
NameService(java.lang.String[] configPath)
Create a new NameService. |
Method Summary | |
void |
addDirectoryEventListener(DirectoryEventListener listener)
Add a directory event listener. |
void |
addPropertyConverter(java.lang.Class clazz,
PropertyConverter converter)
Add property converter. |
void |
dispatchErrorEvent(java.lang.Object source,
java.lang.String message,
BeanConfiguration beanConfig,
BeanProperty beanProperty,
java.lang.Throwable throwable)
Convenience method for creating and dispatching an event event. |
void |
dispatchEvent(DirectoryEvent event)
Dispatch a DirectoryEvent to event listeners. |
void |
dispatchEvent(int type,
java.lang.Object source,
java.lang.String message,
BeanConfiguration beanConfig,
BeanProperty beanProperty,
java.lang.Throwable throwable)
Convenience method for creating and dispatching an event event. |
protected BeanConfiguration |
getBeanConfiguration(DirectoryContext context,
java.lang.String name)
Get the BeanConfiguration for a given component. |
BeanParser |
getBeanParser()
The parser to use when parsing bean configuration files. |
int |
getCheckIntervalSeconds()
Get the check interval seconds property. |
boolean |
getLogDebug()
Control logging of debug messages for the bean directory. |
PropertyConverter |
getPropertyConverter(java.lang.Class clazz)
Get the property converter for a specific class. |
void |
logDebug(BeanConfiguration beanConfig,
java.lang.String message)
Log a debug message for the bean directory. |
protected BeanConfiguration |
readBeanConfiguration(DirectoryContext context,
java.lang.String name)
Search the config path for a bean configuration file matching a name, and return a BeanConfiguration object describing the configuration. |
void |
registerComponent(ScopeLookup scopeLookup,
java.lang.String scopeType,
java.lang.String name,
java.lang.Object component)
Register a component with a given name and scope. |
void |
removeDirectoryEventListener(DirectoryEventListener listener)
Remove a directory event listener. |
void |
removeScope(java.lang.Object scope)
Remove a scope from the NameService. |
java.lang.Object |
resolve(ScopeLookup scopeLookup,
DirectoryContext context,
java.lang.String name)
Resolve a component relative to a given directory context. |
java.lang.Object |
resolve(ScopeLookup scopeLookup,
java.lang.String name)
Resolve a component with a given scope. |
void |
setBeanParser(BeanParser beanParser)
Set the parser to use when parsing bean configuration files. |
void |
setCheckIntervalSeconds(int checkIntervalSeconds)
Check seconds defines how many seconds a BeanConfiguration read from file is valid before it will be reread if changed. |
void |
setConfigPath(java.lang.String[] configPath)
|
void |
setLogDebug(boolean logDebug)
Control logging of debug messages for the bean directory. |
protected void |
updateBeanConfigFromDir(BeanConfiguration beanConfig,
java.lang.String configDir,
java.lang.String name)
Search one directory in the filesystem for a bean configuration file, and update the associated with the values in this file. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public NameService(java.lang.String[] configPath)
configPath
- A String array containing the configuration path.public NameService(BeanParser beanParser, java.lang.String[] configPath)
beanParser
- The parser to use when parsing configuration files.configPath
- A String array containing the configuration path.public NameService()
Method Detail |
public void setConfigPath(java.lang.String[] configPath)
public java.lang.Object resolve(ScopeLookup scopeLookup, DirectoryContext context, java.lang.String name)
scopeLookup
- The object responsible for looking up the scope
for this component.context
- The directory context to resolve this name relative to.name
- The name of the component.public java.lang.Object resolve(ScopeLookup scopeLookup, java.lang.String name)
scopeLookup
- The object responsible for looking up the scope
for this component.name
- The name of the component.public void registerComponent(ScopeLookup scopeLookup, java.lang.String scopeType, java.lang.String name, java.lang.Object component)
scopeLookup
- The object used to lookup the scope for this
component.scopeType
- The scope type for this component. This is only
set if no configuration file is found for the
component.name
- The full name of the component.component
- The component to register.public void removeScope(java.lang.Object scope)
scope
- The scope to remove.protected BeanConfiguration getBeanConfiguration(DirectoryContext context, java.lang.String name)
context
- The DirectoryContext to get this component is in.name
- The name of the component.protected void updateBeanConfigFromDir(BeanConfiguration beanConfig, java.lang.String configDir, java.lang.String name)
beanConfig
- The BeanConfiguration object to update.configDir
- The filesystem directory used as the root when
looking up this component.name
- The name of the bean configuration.protected BeanConfiguration readBeanConfiguration(DirectoryContext context, java.lang.String name)
context
- The directory context of the bean configuration.name
- The name of the bean configuration.public void setCheckIntervalSeconds(int checkIntervalSeconds)
checkSeconds
- How often a BeanConfiguration should be checked
for changes on file.
-1 is the default value means that configuration
files not will be reparsed. If the value is 0 the
configuration file will always be reread if changed.public int getCheckIntervalSeconds()
public BeanParser getBeanParser()
public void setBeanParser(BeanParser beanParser)
beanParser
- Object implementing the BeanParser interface.public void addPropertyConverter(java.lang.Class clazz, PropertyConverter converter)
clazz
- The class of objects this PropertyConverter creates.converter
- An object implementing the PropertyConverter interface.public PropertyConverter getPropertyConverter(java.lang.Class clazz)
clazz
- The class the class to get the property converter for.public void addDirectoryEventListener(DirectoryEventListener listener)
listener
- The DirectoryEventListener to add.public void removeDirectoryEventListener(DirectoryEventListener listener)
listener
- The DirectoryEventListener to remove.public void dispatchEvent(DirectoryEvent event)
TODO: Implement an event queue, so we can have asynchronous event logging.
event
- The event to dispatch.public void dispatchEvent(int type, java.lang.Object source, java.lang.String message, BeanConfiguration beanConfig, BeanProperty beanProperty, java.lang.Throwable throwable)
type
- The type of this event.source
- The object that generated the event.message
- Descriptive message of the event.beanConfig
- The BeanConfiguration processed when the event occured,
or null.beanProperty
- The BeanProperty processed when the event occured,
or null.throwable
- The Throwable that triggered the event, or null.public void dispatchErrorEvent(java.lang.Object source, java.lang.String message, BeanConfiguration beanConfig, BeanProperty beanProperty, java.lang.Throwable throwable)
source
- The object that generated the event.message
- Descriptive message of the event.beanConfig
- The BeanConfiguration processed when the event occured,
or null.beanProperty
- The BeanProperty processed when the event occured,
or null.throwable
- The Throwable that triggered the event, or null.public void setLogDebug(boolean logDebug)
logDebug
- True if debug messages should be logged,
false otherwise.public boolean getLogDebug()
public void logDebug(BeanConfiguration beanConfig, java.lang.String message)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |