Zest™
Introduction
Tutorials
Javadoc
Samples
Core
Libraries
Extensions
Tools
Glossary 

OSGi

code

docs

tests

OSGi Library allows you to import OSGi services as Zest™ Services and to export Zest™ Services as OSGi Services both leveraging the Zest™ Availability and OSGi FallbackStrategy mechanisms.

Table 39. Artifact

Group IDArtifact IDVersion

org.apache.zest.library

org.apache.zest.library.osgi

0


Export Zest™ services to an OSGi Bundle

interface MyZestService
    extends OSGiEnabledService
{
    // ...
}
  [...snip...]

public void assemble( ModuleAssembly module )
    throws AssemblyException
{
    BundleContext bundleContext = // ...
      [...snip...]

    module.services( OSGiServiceExporter.class ).
        setMetaInfo( bundleContext );
    module.services( MyZestService.class );
}

Import OSGi services in a Zest™ Module

public void assemble( ModuleAssembly module )
    throws AssemblyException
{
  [...snip...]

    module.services( OSGiServiceImporter.class ).
        setMetaInfo( new OSGiImportInfo( bundleContext,
                                         MyOSGiService.class,
                                         MyOtherOSGiService.class ) ).
        setMetaInfo( new MyFallbackStrategy() );
}

The fallback strategy is invoked when the OSGi service is not available and a method call is invoked.