Working With OSGi

To allow Enterprise Ehcache to behave as an OSGi component, the following attributes should be set as shown:

<cache ... copyOnRead="true" ... > 
... 
  <terracotta ... clustered="true" ... /> 
... 
</cache>

Your OSGi bundle will require the following JAR files (showing versions from a BigMemory Max 4.0.0):

  • ehcache-ee-2.7.0.jar
  • terracotta-toolkit-runtime-ee-4.0.0.jar
  • slf4j-api-1.6.6.jar
  • slf4j-nop-1.6.1.jar

    Or use another appropriate logger binding.

Use the following directory structure:

 -- net.sf.ehcache 
          | 
          | - ehcache.xml 
          |- ehcache-ee-2.7.0.jar 
      | 
      |- terracotta-toolkit-runtime-ee-4.0.0.jar 
          | 
          | - slf4j-api-1.6.6.jar 
          | 
          | - slf4j-nop-1.6.6.jar 
          | 
          | - META-INF/ 
              | - MANIFEST.MF

The following is an example manifest file:

Manifest-Version: 1.0 
 Export-Package: net.sf.ehcache;version="2.7.0" 
 Bundle-Vendor: Terracotta 
 Bundle-ClassPath: .,ehcache-ee-2.7.0.jar,terracotta-toolkit-runtime-ee-4.0.0.jar 
     ,slf4j-api-1.6.6.jar,slf4j-nop-1.6.6.jar 
 Bundle-Version: 2.7.0 
 Bundle-Name: EHCache bundle 
 Created-By: 1.6.0_15 (Apple Inc.) 
 Bundle-ManifestVersion: 2 
 Import-Package: org.osgi.framework;version="1.3.0" 
 Bundle-SymbolicName: net.sf.ehcache 
 Bundle-RequiredExecutionEnvironment: J2SE-1.5

Use versions appropriate to your setup.

To create the bundle, execute the following command in the net.sf.ehcache directory:

jar cvfm net.sf.ehcache.jar MANIFEST.MF *