Package net.ontopia.topicmaps.entry
Class XMLConfigSource
- java.lang.Object
-
- net.ontopia.topicmaps.entry.XMLConfigSource
-
public class XMLConfigSource extends Object
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 theTopicMapRepositoryIF
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. Theparam
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
All Methods Static Methods Concrete Methods Modifier and Type Method Description static TopicMapRepositoryIF
getRepository(Reader config_file)
PUBLIC: Gets the topic map repository that is created by reading the configuration file from the reader.static TopicMapRepositoryIF
getRepository(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 TopicMapRepositoryIF
getRepository(String config_file)
PUBLIC: Gets the topic map repository that is created by reading the configuration file.static TopicMapRepositoryIF
getRepository(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 TopicMapRepositoryIF
getRepositoryFromClassPath()
PUBLIC: Get the topic map repository that is created by loading the 'tm-sources.xml' configuration file from the classpath.static TopicMapRepositoryIF
getRepositoryFromClassPath(String resourceName)
PUBLIC: Get the topic map repository that is created by loading the named resource from the classpath.static TopicMapRepositoryIF
getRepositoryFromClassPath(String resourceName, Map<String,String> environ)
INTERNAL:static TopicMapRepositoryIF
getRepositoryFromClassPath(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 Detail
-
getRepositoryFromClassPath
public static TopicMapRepositoryIF 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 static TopicMapRepositoryIF getRepositoryFromClassPath(String resourceName)
PUBLIC: Get the topic map repository that is created by loading the named resource from the classpath.- Since:
- 3.0
-
getRepositoryFromClassPath
public static TopicMapRepositoryIF getRepositoryFromClassPath(Map<String,String> environ)
INTERNAL:
-
getRepositoryFromClassPath
public static TopicMapRepositoryIF getRepositoryFromClassPath(String resourceName, Map<String,String> environ)
INTERNAL:
-
getRepository
public static TopicMapRepositoryIF getRepository(String config_file)
PUBLIC: Gets the topic map repository that is created by reading the configuration file.
-
getRepository
public static TopicMapRepositoryIF getRepository(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.
-
getRepository
public static TopicMapRepositoryIF getRepository(Reader config_file)
PUBLIC: Gets the topic map repository that is created by reading the configuration file from the reader.- Since:
- 3.0
-
getRepository
public static TopicMapRepositoryIF getRepository(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.- Since:
- 3.0
-
readSources
public static List<TopicMapSourceIF> readSources(String config_file)
INTERNAL: Returns a collection containing the topic map sources created by reading the configuration file.
-
-