|
Terracotta Integration Modules ManualBefore you start
IntroductionTerracotta Integration Modules (TIMs) are sets of configuration elements and supporting Java classes packaged together as a single, includable module within the Terracotta configuration. A TIM allows you to integrate Terracotta DSO with the framework or platform that your application is based on.
The catalog of available TIMs continues to grow as new technologies are integrated with Terracotta DSO. Community-developed TIMs are also being added. For the complete list of currently supported modules, see the [Index of Integrations]. If a TIM isn't available for your environment, this document shows you how to build one.
Integration Module VersioningVersioning a TIM to fit with the Terracotta development scheme is crucial for a smooth integration path. The Terracotta development scheme takes the Apache Maven approach of appending "SNAPSHOT" to build versions still in flux. A typical TIM filename looks like the following: clustered-hibernate-3.2.5-2.6.0.jar where a descriptive name (clustered-hibernate) is followed by the named application's version (3.2.5), and finally the TIM version (2.6.0). To facilitate a consistent and functional version-control process, an official management policy for TIM publishing is in place. If you pursue creating and publishing a TIM, follow these guidelines:
Create Your Own Terracotta Integration ModuleTODO: http://jira.terracotta.org/jira/browse/DOC-285 TIMs are very similar to OSGi bundles or Eclipse plugins. Logically, a TIM is a specification loaded at runtime that tells the Terracotta software how to instrument certain Java objects. Structurally, a TIM is a jar file with special headers in the manifest. While a TIM can contain code that modifies bytecode directly, normally it's nothing more than an XML file containing a subtree of the tc-config.xml file. To meet Terracotta integration specification, the TIM requires at least one of the following: a) A terracotta.xml file (located in the root of the jar) Case b) supports a special use case where custom bytecode manipulation is required. Case b) is not likely to be encountered and is not covered here.
You can build your TIM using Apache Maven and the Maven TIM archetype, or manually. The procedures for each of these methods are given below.
Procedure Using the Maven TIM ArchetypeThis procedure assumes that you have Maven installed and are familiar with Maven projects.
Manual Procedure
terracotta.xmlThe terracotta.xml file contains a subtree of the application/dso element of the <tc-config.xml> file, wrapped in an <xml-fragment> element. If the content of your tc-config.xml file is similar to the following: <tc:tc-config xmlns:tc="http://www.terracotta.org/config"> <!-- ...stuff... --> <application> <dso> <instrumented-classes> <!-- ...other stuff... --> </instrumented-classes> <locks> <!-- ...yet more stuff... --> </locks> </dso> </application> <!-- ...trailing stuff... --> </tc:tc-config> then the content of your terracotta.xml file should be similar to the following: <xml-fragment> <instrumented-classes> <!-- ...other stuff... --> </instrumented-classes> <locks> <!-- ...yet more stuff... --> </locks> </xml-fragment> META-INF/MANIFEST.MFThe manifest file has one required OSGi header: Bundle-SymbolicName. Optional headers can be added to make the manifest file more useful.
The following is an example of set of headers in a MANIFEST.MF file: Bundle-Description: MyApp/MyFramework Cluster Configuration Bundle-DocURL: http://www.myorg.org/doc/terracotta-integration-module/ Bundle-Name: Terracotta integration module for MyApp/MyFramework Bundle-SymbolicName: org.myorg.myapp.integration_module Bundle-Vendor: MyOrg, Inc. Bundle-Version: 1.0 See the OSGi R4 documentation for more information on headers. Eclipse offers a manifest editor that makes it easier to work with manifest files. Using Your TIMTo use your TIM, save the TIM jar file to a module repository and add the following element to clients/modules in your tc-config.xml file: <module name="MyApp-cluster-config" version="1.0"/>
Adding this element effectively embeds the terracotta.xml in tc-config.xml. See these usage guidelines for a more detailed procedure. Using a TIM to Replace a Shared ClassUnder certain circumstances, you may want to replace a class with your own version. This can be done using a TIM. The TIM's contents should be similar to the following: public class FooModule extends TerracottaConfiguratorModule { protected void addInstrumentation(BundleContext context) { super.addInstrumentation(context); Bundle bundle = getExportedBundle(context, "org.foo.tim-foo"); addClassReplacement(bundle, "org.foo.Impl", "org.foo.ClusteredImpl"); } } where:
Additional ReadingSee Juris Galang's blog entry on using the TIM archetype. |
Terracotta Integration Modules Manual
(None)