|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.activemath.abstractcontent.SubconfImpl.AbstractSubconfiguration
org.activemath.abstractcontent.SubconfImpl.PropertiesConfig
public static class SubconfImpl.PropertiesConfig
This class provides the subconfiguration facilities provided by a property file and to create services on a property-file based configuration.
It does so by assuming the following properties in the property file:
service.<some_name>.interfaceName provides
the interface class-name that can be provided as getService(java.lang.String) argument.
The name <some_name> is a local-name that is meant to be irrelevant to
the rest of the applications and is only used to group together the properties
of this interface, all property-names for the definition of this service should
start with service.<some_name>..service.<some_name>.className describing the class
of the service-object to constructSubconfiguration, then a
one should find service.<some_name>.configPrefix providing the property-name
prefix that will be used to create SubconfImpl.ChildSubconfiguration with this object as parent
to use in the named constructor (for example, service.<some_name>.config).service.<some_name>.beanPrefix being the prefix whose children
(as obtained by getChildrenNames(java.lang.String)) provide the property-names and whose values
provide the values to set the properties of the bean (note that currently, only rudimentary
bean-support is provided, i.e. no converters are provided.service.<some_name>.init indicating the time
when the service should be initialized. Either
asap or whenNeeded.
| Nested Class Summary | |
|---|---|
static class |
SubconfImpl.PropertiesConfig.CyclicServiceInitException
An exception denoting the imposibility to initialize services as an infite loop would result instead. |
| Field Summary | |
|---|---|
protected Map |
services
This map has, as keys, the interfaceName (as used in getService(java.lang.String)) and as values
either the created service or a String object, the property child-name that
defines the service, or this same name followed by " BEING INITTED"
if it is being constructed, or a Throwable is the initialization of the service
went wrong (it is attempted only once). |
| Constructor Summary | |
|---|---|
SubconfImpl.PropertiesConfig(Map props,
SubconfImpl.PathResolver resolver)
Creates a subconfiguration from an existing properties object and with the the indicated SubconfImpl.PathResolver. |
|
SubconfImpl.PropertiesConfig(Map props,
SubconfImpl.PathResolver resolver,
Map services)
Creates a subconfiguration from an existing properties object and with the the indicated SubconfImpl.PathResolver. |
|
SubconfImpl.PropertiesConfig(URL url)
Reads the property-file in memory and initializes the possibility to start the services but does not create them. |
|
| Method Summary | |
|---|---|
protected void |
createService(String serviceInterfaceName)
Constructs the service according to the indicated specifications. |
Collection |
getChildrenNames(String prefix)
Returns the next step completion given the named prefix. |
URL |
getPath(String name)
Returns a file constructed relative to the path of the url provided in the sole constructor. |
String |
getProperty(String name)
Returns the values for the given name or null if there's none. |
Iterator |
getPropertyNames()
Returns an enumeration of all the property names. |
Object |
getService(String serviceInterfaceName)
This is the way to provide named services to users of the subconfiguation. |
URL |
getURL(String keyName)
Returns the URL relative to the baseURL provided at construction time provided by the property-value whose key is the given name, or null
if there is no such key. |
URL |
pathFromString(String pathString)
Computes the path for the obtained property value. |
void |
refreshServices()
Commodity method to request the configurator to re-read the services from whichever source it was given. |
void |
setDefaultProperties(Map defaultProps)
Expects a map with keys and values as Strings. |
void |
unload()
Unloads the probably expensive storage of the properties. |
| Methods inherited from class org.activemath.abstractcontent.SubconfImpl.AbstractSubconfiguration |
|---|
getBoolean, getInt, getSubconfiguration |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final Map services
getService(java.lang.String)) and as values
either the created service or a String object, the property child-name that
defines the service, or this same name followed by " BEING INITTED"
if it is being constructed, or a Throwable is the initialization of the service
went wrong (it is attempted only once).
| Constructor Detail |
|---|
public SubconfImpl.PropertiesConfig(URL url)
throws IOException
IOException
public SubconfImpl.PropertiesConfig(Map props,
SubconfImpl.PathResolver resolver)
SubconfImpl.PathResolver. Services are created using the same approach.
SubconfImpl.Util.makeBasedPathResolver(java.net.URL)
public SubconfImpl.PropertiesConfig(Map props,
SubconfImpl.PathResolver resolver,
Map services)
SubconfImpl.PathResolver. Services are created using the same approach
except if they are already defined in the services parameter
where they will be simply fetched (and not checked).
Do note that a service (i.e. a value in the services table)
is not allowed to be a String object.
SubconfImpl.Util.makeBasedPathResolver(java.net.URL)| Method Detail |
|---|
public URL getURL(String keyName)
null
if there is no such key.
public void refreshServices()
Subconfiguration
refreshServices in interface Subconfigurationprotected void createService(String serviceInterfaceName)
Subconfiguration
may request another service which may give rise to cycles.
In this case, a SubconfImpl.PropertiesConfig.CyclicServiceInitException will be thrown.
public Object getService(String serviceInterfaceName)
SubconfigurationNote that implementations of the Subconfiguration interface should only accept, as argument of this method, the class of a java-interface.
The service returned is not supposed to be twiddled or adjusted by the user of this service as such a service will presumably be shared by several users in a normal deployment.
Examples of such services could be an implementation of the JAXP's
TransformerFactory interface, or an implementation
of the MBaseRef interface.
Child-subconfigurations obtained through Subconfiguration.getSubconfiguration(java.lang.String)
should, so as to enforce the inversion-of-control pattern, restrict
the amount of services provided to the strict needed parts.
getService in interface SubconfigurationSubconfImpl.PropertiesConfigpublic String getProperty(String name)
Subconfigurationnull if there's none.
getProperty in interface SubconfigurationgetProperty in class SubconfImpl.AbstractSubconfigurationpublic void setDefaultProperties(Map defaultProps)
setDefaultProperties in interface SubconfigurationsetDefaultProperties in class SubconfImpl.AbstractSubconfigurationpublic Iterator getPropertyNames()
Subconfiguration
getPropertyNames in interface SubconfigurationgetPropertyNames in class SubconfImpl.AbstractSubconfigurationpublic Collection getChildrenNames(String prefix)
SubconfigurationAs an example, given
i.a.blop.c = val1
i.b.blip = val2
This method, called with "i", would return the enumeration made of the string "a" and the string "b".
getChildrenNames in interface SubconfigurationgetChildrenNames in class SubconfImpl.AbstractSubconfigurationprefix - the prefix string, without the trailing "."
or null if the root property names is wished.public void unload()
NullPointerException.
public URL getPath(String name)
File object will make no-sense.
For this reason, it is preferable, in a setting where remote communication at configuration
time may happen to call getURL(java.lang.String).
getPath in interface SubconfigurationgetPath in class SubconfImpl.AbstractSubconfigurationManager.getPath(java.lang.String)public URL pathFromString(String pathString)
Subconfiguration
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||