net.ontopia.topicmaps.entry
Class XMLConfigSource

java.lang.Object
  extended by net.ontopia.topicmaps.entry.XMLConfigSource

public class XMLConfigSource
extends java.lang.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 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
static TopicMapRepositoryIF getRepository(java.io.Reader config_file)
          PUBLIC: Gets the topic map repository that is created by reading the configuration file from the reader.
static TopicMapRepositoryIF getRepository(java.io.Reader config_file, java.util.Map<java.lang.String,java.lang.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(java.lang.String config_file)
          PUBLIC: Gets the topic map repository that is created by reading the configuration file.
static TopicMapRepositoryIF getRepository(java.lang.String config_file, java.util.Map<java.lang.String,java.lang.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(java.util.Map<java.lang.String,java.lang.String> environ)
          INTERNAL:
static TopicMapRepositoryIF getRepositoryFromClassPath(java.lang.String resourceName)
          PUBLIC: Get the topic map repository that is created by loading the named resource from the classpath.
static TopicMapRepositoryIF getRepositoryFromClassPath(java.lang.String resourceName, java.util.Map<java.lang.String,java.lang.String> environ)
          INTERNAL:
static java.util.List<TopicMapSourceIF> readSources(java.lang.String config_file)
          INTERNAL: Returns a collection containing the topic map sources created by reading the configuration file.
static java.util.List<TopicMapSourceIF> readSources(java.lang.String config_file, java.util.Map<java.lang.String,java.lang.String> environ)
          INTERNAL: Returns a collection containing the topic map sources created by reading the configuration file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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(java.lang.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(java.util.Map<java.lang.String,java.lang.String> environ)
INTERNAL:


getRepositoryFromClassPath

public static TopicMapRepositoryIF getRepositoryFromClassPath(java.lang.String resourceName,
                                                              java.util.Map<java.lang.String,java.lang.String> environ)
INTERNAL:


getRepository

public static TopicMapRepositoryIF getRepository(java.lang.String config_file)
PUBLIC: Gets the topic map repository that is created by reading the configuration file.


getRepository

public static TopicMapRepositoryIF getRepository(java.lang.String config_file,
                                                 java.util.Map<java.lang.String,java.lang.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(java.io.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(java.io.Reader config_file,
                                                 java.util.Map<java.lang.String,java.lang.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 java.util.List<TopicMapSourceIF> readSources(java.lang.String config_file)
INTERNAL: Returns a collection containing the topic map sources created by reading the configuration file.


readSources

public static java.util.List<TopicMapSourceIF> readSources(java.lang.String config_file,
                                                           java.util.Map<java.lang.String,java.lang.String> environ)
INTERNAL: Returns a collection containing the topic map sources created by reading the configuration file.



Copyright © 2000-2012 Ontopia.