T - public abstract class ConfigBase<T extends ConfigBase> extends Object implements Comparable<T>, Serializable
The class itself requires an element name annotation
@ConfInfo(elementName="example-conf",
type="defining-class")
The type parameter is optional. If not specified the annotated class is the defining class otherwise it is the named class or interface
The defining class specifies the getters and setters for the configuration fields. The actual class may have other getters and setters but these will not be dumped or restored.
Collection fields MUST be either Set or List and the element class MUST
be specified. For example:
private List
Also collection getters require a name for the collection element
@ConfInfo(collectionElementName = "prop")
public List
The ConfInfo annotation
@ConfInfo(dontSave = true)
allows for getters and setters of values used internally only.
The dumped XML will have start elements with a type attribute. The value of that attribute is the actual class being dumped/restored.
An example:
public interface MyConf extends Serializable {
...
void setMaxLength(final Integer val);
...
@MBeanInfo("Max length")
Integer getLength();
...
}
@ConfInfo(elementName = "my-conf",
type = "my.package.MyConf")
public class MyConfImpl extends ConfigBase
implements MyConf {
...
}
| Modifier and Type | Field and Description |
|---|---|
static String |
ns
The default namespace for the XML elements.
|
| Constructor and Description |
|---|
ConfigBase() |
| Modifier and Type | Method and Description |
|---|---|
<L extends List> |
addListProperty(L list,
String name,
String val) |
int |
compareTo(ConfigBase that) |
static ConfigBase |
fromXml(InputStream is) |
static ConfigBase |
fromXml(InputStream is,
Class cl) |
long |
getLastChanged() |
String |
getName()
Name for the configuration.
|
String |
getProperty(Collection<String> col,
String name)
Get a property stored as a String name = val
|
int |
hashCode() |
void |
markChanged() |
void |
removeProperty(Collection<String> col,
String name)
Remove a property stored as a String name = val
|
<L extends List> |
setListProperty(L list,
String name,
String val)
Set a property
|
void |
setName(String val) |
static Properties |
toProperties(List<String> vals) |
String |
toString() |
void |
toStringSegment(ToString ts)
Add our stuff to the StringBuilder
|
void |
toXml(Writer wtr)
Output to a writer
|
public static final String ns
public void setName(String val)
val - the namepublic String getName()
public void markChanged()
public long getLastChanged()
public void toStringSegment(ToString ts)
ts - ToString for resultpublic int compareTo(ConfigBase that)
compareTo in interface Comparable<T extends ConfigBase>public <L extends List> L addListProperty(L list, String name, String val)
list - name - val - public String getProperty(Collection<String> col, String name)
col - of property name+valname - public void removeProperty(Collection<String> col, String name)
col - name - public <L extends List> L setListProperty(L list, String name, String val)
list - the list - possibly nullname - of propertyval - of propertypublic static Properties toProperties(List<String> vals)
vals - to be converted to a Properties objectpublic void toXml(Writer wtr) throws ConfigException
wtr - ConfigExceptionpublic static ConfigBase fromXml(InputStream is) throws ConfigException
is - ConfigExceptionpublic static ConfigBase fromXml(InputStream is, Class cl) throws ConfigException
is - cl - ConfigExceptionCopyright © 2016 Bedework. All rights reserved.