Package net.ontopia.topicmaps.entry
Class XMLConfigSource
java.lang.Object
net.ontopia.topicmaps.entry.XMLConfigSource
PUBLIC: Reads store configuration parameters from an XML
file. The config source is able to handle multiple sources at the
same time by using an instance of the
TopicMapRepositoryIF
class.The class understands XML documents using the following DTD:
<!ELEMENT repository (source+) >
<!ELEMENT source (param*) >
<!ATTLIST source id ID #IMPLIED >
<!ATTLIST source class CDATA #REQUIRED >
<!ELEMENT param EMPTY >
<!ATTLIST param name CDATA #REQUIRED
value CDATA #REQUIRED >
Example:
<repository>
<!-- source that references all .xtm files in a directory -->
<source class="net.ontopia.topicmaps.xml.XTMPathTopicMapSource">
<param name="path" value="/ontopia/topicmaps"/>
<param name="suffix" value=".xtm"/>
</source>
<!-- source that references a topic map in a relational database -->
<source class="net.ontopia.topicmaps.impl.rdbms.RDBMSSingleTopicMapSource">
<param name="topicMapId" value="5001"/>
<param name="title" value="My RDBMS Topic Map"/>
<param name="referenceId" value="mytm"/>
<param name="propertyFile" value="${CWD}/db.postgresql.props"/>
</source>
</repository>
This example makes XMLConfigSource use a TopicMapRepositoryIF that
contains two other topic maps sources, namely instances of the two
specifed in the class attributes of the source elements. Note that
the classes must have empty constructors for them to be used with
this class.
The two sources would locate all XTM files with the .xtm extension
in the /ontopia/topicmaps directory in which the config file is
located.
The param element is used to set bean properties on
the source instance. This way the config source can be configured.
Environment variables:
XMLConfigSource is able to replace environment variables in the param value attribute. The only environment variable available at this time is ${CWD}, which contains the full path of the directory in which the config file is located.
NOTE: Topic map sources with supportsCreate set to true will get ids assigned automatically. This is done so that the sources can be referred to from the outside.
-
Method Summary
Modifier and TypeMethodDescriptionstatic TopicMapRepositoryIFgetRepository(Reader config_file) PUBLIC: Gets the topic map repository that is created by reading the configuration file from the reader.static TopicMapRepositoryIFgetRepository(Reader config_file, Map<String, String> environ) INTERNAL: Gets the topic map repository that is created by reading the configuration file from the reader with the given environment.static TopicMapRepositoryIFgetRepository(String config_file) PUBLIC: Gets the topic map repository that is created by reading the configuration file.static TopicMapRepositoryIFgetRepository(String config_file, Map<String, String> environ) INTERNAL: Gets the topic map repository that is created by reading the configuration file with the given environment.static TopicMapRepositoryIFPUBLIC: Get the topic map repository that is created by loading the 'tm-sources.xml' configuration file from the classpath.static TopicMapRepositoryIFgetRepositoryFromClassPath(String resourceName) PUBLIC: Get the topic map repository that is created by loading the named resource from the classpath.static TopicMapRepositoryIFgetRepositoryFromClassPath(String resourceName, Map<String, String> environ) INTERNAL:static TopicMapRepositoryIFgetRepositoryFromClassPath(Map<String, String> environ) INTERNAL:static List<TopicMapSourceIF>readSources(String config_file) INTERNAL: Returns a collection containing the topic map sources created by reading the configuration file.static List<TopicMapSourceIF>readSources(String config_file, Map<String, String> environ) INTERNAL: Returns a collection containing the topic map sources created by reading the configuration file.
-
Method Details
-
getRepositoryFromClassPath
PUBLIC: Get the topic map repository that is created by loading the 'tm-sources.xml' configuration file from the classpath.- Since:
- 3.0
-
getRepositoryFromClassPath
PUBLIC: Get the topic map repository that is created by loading the named resource from the classpath.- Since:
- 3.0
-
getRepositoryFromClassPath
INTERNAL: -
getRepositoryFromClassPath
public static TopicMapRepositoryIF getRepositoryFromClassPath(String resourceName, Map<String, String> environ) INTERNAL: -
getRepository
PUBLIC: Gets the topic map repository that is created by reading the configuration file. -
getRepository
INTERNAL: Gets the topic map repository that is created by reading the configuration file with the given environment. -
getRepository
PUBLIC: Gets the topic map repository that is created by reading the configuration file from the reader.- Since:
- 3.0
-
getRepository
INTERNAL: Gets the topic map repository that is created by reading the configuration file from the reader with the given environment.- Since:
- 3.0
-
readSources
INTERNAL: Returns a collection containing the topic map sources created by reading the configuration file. -
readSources
INTERNAL: Returns a collection containing the topic map sources created by reading the configuration file.
-