|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.ode.utils.HierarchicalProperties
public class HierarchicalProperties
This class load a list of regular property files (order matters). The main feature is that property can be chained in three levels. Then when querying for a property, if it's not found in the deepest level, the parent will be queryed and so on.
A prefix must be defined to discriminate the property name and the level-1, level-2 names. The default prefix isODE_PREFFIX
.
Properties must respect the following pattern: [level1.[level2.]prefix.]property
A concrete use case could be the definition of properties for wsdl services and ports.
alias.foo_ns=http://foo.com timeout=40000 a_namespace_with_no_alias_defined.film-service.port-of-cannes.ode.timeout=50000 max-redirects=30 foo_ns.brel-service.ode.max-redirects=40 foo_ns.brel-service.port-of-amsterdam.ode.max-redirects=60The following values may be expected:
getProperty("max-redirects") => 30 getProperty("http://foo.com", "brel-service", "max-redirects") => 40 getProperty("http://foo.com", "brel-service", "port-of-amsterdam", "max-redirects") => 60 getProperty("a_namespace_with_no_alias_defined", "film-service", "timeout") => 40000 getProperty("a_namespace_with_no_alias_defined", "film-service", "port-of-cannes", "timeout") => 50000 getProperty("http://foo.com", "port-of-amsterdam", "timeout") => 40000
Values may contain some environment variables. For instance, message=You're using ${java.version}.
If a property name ends with ".file" or ".path", the assumption is made that the associated value is a path and as such is resolved against the path of the file it was loaded from.
This class is not thread-safe.
Field Summary | |
---|---|
static java.lang.String |
ODE_PREFFIX
|
Constructor Summary | |
---|---|
HierarchicalProperties(java.io.File file)
|
|
HierarchicalProperties(java.io.File[] files)
|
|
HierarchicalProperties(java.io.File[] files,
java.lang.String prefix)
|
|
HierarchicalProperties(java.io.File file,
java.lang.String prefix)
|
|
HierarchicalProperties(java.util.List<java.io.File> propFiles)
|
Method Summary | |
---|---|
void |
clear()
Clear all content. |
java.lang.String |
getPrefix()
|
java.util.Map |
getProperties(javax.xml.namespace.QName service)
|
java.util.Map |
getProperties(javax.xml.namespace.QName service,
java.lang.String port)
Return a map containing all the properties for the given port. |
java.util.Map |
getProperties(java.lang.String serviceNamespaceURI,
java.lang.String serviceLocalPart)
|
java.util.Map |
getProperties(java.lang.String serviceNamespaceURI,
java.lang.String serviceLocalPart,
java.lang.String port)
|
java.lang.String |
getProperty(javax.xml.namespace.QName service,
java.lang.String property)
|
java.lang.String |
getProperty(javax.xml.namespace.QName service,
java.lang.String port,
java.lang.String property)
|
java.lang.String |
getProperty(java.lang.String property)
|
java.lang.String |
getProperty(java.lang.String serviceNamespaceURI,
java.lang.String serviceLocalPart,
java.lang.String property)
|
java.lang.String |
getProperty(java.lang.String serviceNamespaceURI,
java.lang.String serviceLocalPart,
java.lang.String port,
java.lang.String property)
|
protected org.apache.ode.utils.HierarchicalProperties.ChainedMap |
getRootMap()
|
protected void |
loadFile(java.io.File file)
|
void |
loadFiles()
Clear all existing content, then read the file and parse each property. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String ODE_PREFFIX
Constructor Detail |
---|
public HierarchicalProperties(java.io.File[] files, java.lang.String prefix) throws java.io.IOException
files
- the property file to be loaded. The file may not exist.
But if the file exists it has to be a file (not a directory), otherwhise an IOException is thrown.prefix
- the property prefix
java.io.IOException
public HierarchicalProperties(java.io.File[] files) throws java.io.IOException
java.io.IOException
public HierarchicalProperties(java.io.File file, java.lang.String prefix) throws java.io.IOException
java.io.IOException
public HierarchicalProperties(java.io.File file) throws java.io.IOException
java.io.IOException
public HierarchicalProperties(java.util.List<java.io.File> propFiles) throws java.io.IOException
java.io.IOException
Method Detail |
---|
public void loadFiles() throws java.io.IOException
java.io.IOException
- if the file is a Directoryprotected void loadFile(java.io.File file) throws java.io.IOException
java.io.IOException
public void clear()
loadFiles()
is not invoked later, all returned values will be null.
protected org.apache.ode.utils.HierarchicalProperties.ChainedMap getRootMap()
public java.util.Map getProperties(java.lang.String serviceNamespaceURI, java.lang.String serviceLocalPart)
public java.util.Map getProperties(javax.xml.namespace.QName service)
service
-
getProperties(String, String)
public java.util.Map getProperties(java.lang.String serviceNamespaceURI, java.lang.String serviceLocalPart, java.lang.String port)
public java.util.Map getProperties(javax.xml.namespace.QName service, java.lang.String port)
service
- port
-
public java.lang.String getProperty(java.lang.String property)
public java.lang.String getProperty(java.lang.String serviceNamespaceURI, java.lang.String serviceLocalPart, java.lang.String property)
public java.lang.String getProperty(javax.xml.namespace.QName service, java.lang.String property)
public java.lang.String getProperty(java.lang.String serviceNamespaceURI, java.lang.String serviceLocalPart, java.lang.String port, java.lang.String property)
public java.lang.String getProperty(javax.xml.namespace.QName service, java.lang.String port, java.lang.String property)
public java.lang.String getPrefix()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |