Chapter 9. TMAPI Implementation

Table of Contents

TMAPI TopicMapSystem Creation
TMAPI Feature Support
Moving between TMAPI and TM4J APIs
The Future Of TMAPI in TM4J

TM4J provides support for the standard API for topic map processing, TMAPI. TMAPI is an open-source community effort to define a standard API for accessing topic maps and topic map data from a topic map processing system. For details on TMAPI please refer to the TMAPI.org site.

This chapter does not give a complete overview of TMAPI - for that, the TMAPI.org website should provide pointers and documentation. Instead, this chapter discusses the TM4J-specific aspects of using TMAPI.

TMAPI TopicMapSystem Creation

In the TM4J implementation, a TMAPI TopicMapSystem corresponds to a TM4J TopicMapProvider. All of the initialisation properties which are accepted and processed by each of the TM4J backends for the instantiation of a TopicMapProvider instance are also recognised and processed in the same way by the TM4J implementation of the TMAPI TopicMapSystemFactory. To specify which TM4J backend should be used, the TopicMapSystemFactory implementation also accepts a property named org.tm4j.topicmap.TopicMapProviderFactory the value of which must be the fully-qualified Java class name of the backend's TopicMapProviderFactory implementation. This defaults to the value org.tm4j.topicmap.memory.TopicMapProviderFactoryImpl.

The TM4J TMAPI implementation JAR file (tm4j-tmapi-1.0.jar) contains configuration resources that enables TMAPI to automatically load the TM4J implementation if there are no other conflicting TMAPI implementations on the CLASSPATH. In the event that you have two or more implementations available on the CLASSPATH, you can specify the use of the TM4J implementation by referring to its TopicMapSystemFactory implementation class org.tm4j.tmapi.core.TMAPITopicMapSystemFactoryImpl either as a System property or in the tmapi.properties files (see the TMAPI documentation for details).

Example 9.1. Initialising the TM4J TMAPI Implementation

The following code snippet shows how to initialise TM4J's TMAPI implementation. Note that there are no TM4J APIs referenced here at all.

  TopicMapSystemFactory tmsf = TopicMapSystemFactory.newInstance();
  tmsf.setProperty("org.tm4j.topicmap.TopicMapSystemFactory",
                   "org.tm4j.topicmap.ozone.OzoneTopicMapSystemFactory");
  // Set the Ozone-backend configuration properties
  tmsf.setProperty("dburl", "ozone:remote://localhost:3333");
  
  TopicMapSystem tms = tmsf.newTopicMapSystem();