public class XMLConfigSource extends Object
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.
Modifier and Type | Method and 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(Map<String,String> environ)
INTERNAL:
|
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 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.
|
public static TopicMapRepositoryIF getRepositoryFromClassPath()
public static TopicMapRepositoryIF getRepositoryFromClassPath(String resourceName)
public static TopicMapRepositoryIF getRepositoryFromClassPath(Map<String,String> environ)
public static TopicMapRepositoryIF getRepositoryFromClassPath(String resourceName, Map<String,String> environ)
public static TopicMapRepositoryIF getRepository(String config_file)
public static TopicMapRepositoryIF getRepository(String config_file, Map<String,String> environ)
public static TopicMapRepositoryIF getRepository(Reader config_file)
public static TopicMapRepositoryIF getRepository(Reader config_file, Map<String,String> environ)
public static List<TopicMapSourceIF> readSources(String config_file)