org.tm4j.topicmap .TopicMapProviderFactory

Description

Abstract class to be extended by implementations which allow access to TopicMaps using the TopicMapProvider interface. This class enables an application to retrieve a TopicMapProvider.

TM4J applications retrieve instances of this class using the #newInstance() method, which selects, instantiates and returns the appropriate concrete implementation as determined by the following algorithm (listed here in descending order of precedence):

  1. Look for a system property named org.tm4j.topicmap.TopicMapProviderFactory; if found, it is expected to contain the fully-qualified class name of the concrete, back end-dependent implementing class. If that system property is found, but the corresponding class cannot be loaded or instantiated, this is considered an error condition and #newInstance() will throw a TopicMapProviderFactoryConfigurationError.
  2. Likewise, look for a system property named provider, handle it equivalently. This is purely for reasons of backwards compatibility and will go away in future releases.
  3. Find a resource on the Java classpath named META-INF/services/org.tm4j.topicmap.TopicMapProviderFactory; if found, it is expected to contain a single line of text denoting the fully-qualified class name of the concrete implementation class. This in line with the "Service Provider" section of the JAR File Specification. If that resource is found, but cannot be read, or the corresponding class cannot be loaded or instantiated, this is considered an error condition and #newInstance() will throw a TopicMapProviderFactoryConfigurationError.
  4. If neither an appropriate system property nor the service provider configuration file could be found, instantiate and return the default implementation, org.tm4j.topicmap.memory.TopicMapProviderFactoryImpl.

After the class has been properly instantiated, TopicMapProviders may be created using #newTopicMapProvider() or #newTopicMapProvider(Properties). The implementing subclass will ensure that the returned TopicMapProviders are appropriate for the underlying back-end implementation.

This approach enables TM4J application developers to write their applications in a back end-independent manner, leaving it up to the users to select the appropriate back-end implementation that best fits their requirements.

Inheritance Hierarchy

Method Summary
TopicMapProvider createTopicMapProvider(java.util.Properties props)
Creates and returns a TopicMapProvider object which may be used to retrieve one or more topic maps from the implementation's underlying store.
TopicMapProviderFactory newInstance()
Creates and returns a new instance of this class.
TopicMapProvider newTopicMapProvider()
Creates and returns a TopicMapProvider which may be used to retrieve one or more topic maps from the implementation's underlying store.
TopicMapProvider newTopicMapProvider(java.util.Properties props)
Creates and returns a TopicMapProvider which may be used to retrieve one or more topic maps from the implementation's underlying store.