|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.smartlab.config.Element net.smartlab.config.Node net.smartlab.config.Configuration
public abstract class Configuration
This class provides a skeletal implementation of a configuration tree to provide a set of common operations with a generic implementation.
Field Summary | |
---|---|
protected java.util.Collection |
listeners
|
protected net.smartlab.config.Configuration.Monitor |
monitor
|
Fields inherited from class net.smartlab.config.Node |
---|
attributes, children, content, resolved |
Fields inherited from class net.smartlab.config.Element |
---|
name, parent |
Constructor Summary | |
---|---|
protected |
Configuration()
Creates an instance of the class as an Element without a
parent node. |
Method Summary | |
---|---|
void |
addListener(Listener listener)
Adds a configuration changes listener. |
protected void |
check()
Checks if the underling configuration has been changed and notifies listeners of the change. |
static Configuration |
getInstance(java.lang.String uri)
Returns an instance of a Configuration subclass
accordingly to the provided URI. |
static Configuration |
getInstance(java.lang.String uri,
java.util.Collection listeners)
Returns an instance of a Configuration subclass
accordingly to the provided URI monitoring it for updates which will be
notified to the provided collection of listeners. |
static Configuration |
getInstance(java.lang.String uri,
Listener listener)
Returns an instance of a Configuration subclass
accordingly to the provided URI monitoring it for updates which will be
notified to the provided listener. |
static Configuration |
getInstance(java.net.URI uri)
Returns an instance of a Configuration subclass
accordingly to the provided URI. |
static Configuration |
getInstance(java.net.URI uri,
java.util.Collection listeners)
Returns an instance of a Configuration subclass
accordingly to the provided URI monitoring it for updates which will be
notified to the provided collection of listeners. |
static Configuration |
getInstance(java.net.URI uri,
Listener listener)
Returns an instance of a Configuration subclass
accordingly to the provided URI monitoring it for updates which will be
notified to the provided listener. |
java.util.Collection |
getListeners()
Returns the registered changes listeners. |
boolean |
getResolve()
Returns the resolution method adopted by this configuration tree. |
protected void |
init(java.lang.String name,
org.xml.sax.Attributes attributes)
Initializes this configuration with a name and a set of attributes. |
abstract boolean |
isChanged()
This method checks if the source from the configuration structure was modified since it was last read. |
void |
removeListener(Listener listener)
Removes a configuration changes listener. |
protected Node |
resolve(java.lang.String name,
java.lang.String id)
Resolves the requested reference through its children nodes or, recursively in the parent node children. |
void |
setResolve(boolean resolve)
Sets the resolution method to adopt while querying this configuration tree. |
abstract void |
update()
Ensures the in memory representation of the configuration matches with the underlying representation. |
Methods inherited from class net.smartlab.config.Node |
---|
getAttribute, getAttributeNames, getAttributes, getContent, getElement, getElements, getElements, getId, resolve, setContent |
Methods inherited from class net.smartlab.config.Element |
---|
getAttributeValues, getElement, getElement, getName, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.util.Collection listeners
protected net.smartlab.config.Configuration.Monitor monitor
Constructor Detail |
---|
protected Configuration()
Element
without a
parent node. This constructor is providen for subclasses convenience.
Method Detail |
---|
protected void init(java.lang.String name, org.xml.sax.Attributes attributes)
name
- the name of the configuration tree.attributes
- a set of attributes relative to the global
configuration tree.protected Node resolve(java.lang.String name, java.lang.String id) throws ConfigurationException
Node
resolve
in class Node
name
- the referenced element name.id
- the referenced element identifier.
ConfigurationException
- if the referenced element cannot be found
in the wntire configuration tree.Node.resolve(java.lang.String, java.lang.String)
public abstract boolean isChanged() throws ConfigurationException
true
if the underlying representation of the
structure was modified since last read.
ConfigurationException
- if something wrong occurred while
checking the underlaying structure like the file is no more
readable or the stream no more available.public abstract void update() throws ConfigurationException
ConfigurationException
- if the underlying representation of the
structure is no more accessible or the decoding process fails
due to an unappropriately initialized Cipher
.public void setResolve(boolean resolve)
true
all internal references are
automatically resolved to the destination node if present in the
configuration tree.
resolve
- the resolution method to adopt.public boolean getResolve()
true
if internal references should be
automatically resolved.public java.util.Collection getListeners()
public void addListener(Listener listener)
listener
- the listener to add.public void removeListener(Listener listener)
listener
- the listener to remove.public static final Configuration getInstance(java.lang.String uri) throws ConfigurationException, java.net.URISyntaxException
Configuration
subclass
accordingly to the provided URI.
Monitoring interval can be set through the system property
smartconfig.monitor.delay
expressed in milliseconds and
defaulting to 60000.
uri
- the URI to access the configuration.
Configuration
subclass.
ConfigurationException
- if no handler matches the specified URI or
an error is encountered trying to access the configuration URI.
java.net.URISyntaxException
public static final Configuration getInstance(java.lang.String uri, Listener listener) throws ConfigurationException, java.net.URISyntaxException
Configuration
subclass
accordingly to the provided URI monitoring it for updates which will be
notified to the provided listener.
Monitoring interval can be set through the system property
smartconfig.monitor.delay
expressed in milliseconds and
defaulting to 60000.
uri
- the URI to access the configuration.listener
- a Listener interface implementation.
Configuration
subclass.
ConfigurationException
- if no handler matches the specified URI or
an error is encountered trying to access the configuration URI.
java.net.URISyntaxException
public static final Configuration getInstance(java.lang.String uri, java.util.Collection listeners) throws ConfigurationException, java.net.URISyntaxException
Configuration
subclass
accordingly to the provided URI monitoring it for updates which will be
notified to the provided collection of listeners.
Monitoring interval can be set through the system property
smartconfig.monitor.delay
expressed in milliseconds and
defaulting to 60000.
uri
- the URI to access the configuration.listeners
- a collection of Listener interface implementors.
Configuration
subclass.
ConfigurationException
- if no handler matches the specified URI or
an error is encountered trying to access the configuration URI.
java.net.URISyntaxException
public static final Configuration getInstance(java.net.URI uri) throws ConfigurationException
Configuration
subclass
accordingly to the provided URI.
Monitoring interval can be set through the system property
smartconfig.monitor.delay
expressed in milliseconds and
defaulting to 60000.
uri
- the URI to access the configuration.
Configuration
subclass.
ConfigurationException
- if no handler matches the specified URI or
an error is encountered trying to access the configuration URI.public static final Configuration getInstance(java.net.URI uri, Listener listener) throws ConfigurationException
Configuration
subclass
accordingly to the provided URI monitoring it for updates which will be
notified to the provided listener.
Monitoring interval can be set through the system property
smartconfig.monitor.delay
expressed in milliseconds and
defaulting to 60000.
uri
- the URI to access the configuration.listener
- a Listener interface implementation.
Configuration
subclass.
ConfigurationException
- if no handler matches the specified URI or
an error is encountered trying to access the configuration URI.public static final Configuration getInstance(java.net.URI uri, java.util.Collection listeners) throws ConfigurationException
Configuration
subclass
accordingly to the provided URI monitoring it for updates which will be
notified to the provided collection of listeners.
Monitoring interval can be set through the system property
smartconfig.monitor.delay
expressed in milliseconds and
defaulting to 60000.
uri
- the URI to access the configuration.listeners
- a collection of Listener interface implementors.
Configuration
subclass.
ConfigurationException
- if no handler matches the specified URI or
an error is encountered trying to access the configuration URI.protected final void check()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |