Figure 2.2 shows an overview of a sample
OSGi application consisting of five bundles, which illustrates the basic bundle
types discussed in the previous section. The application is driven by the
hello-consumer bundle, which imports a HelloParis
service from the hello-paris bundle and imports a
HelloBoston service from the hello-boston
bundle.
The sample OSGi application consists of the following bundles:
time-utilFits the pattern of a library bundle. The
time-utilbundle is a utility library that can createClockinstances that tell the time in a particular time zone.The
time-utilbundle is implemented using classes from the JDK and thus has no external package dependencies.hello-parisFits the pattern of an API bundle. The
hello-parisbundle consists of a single Java interface, which returns a greeting,getGreeting(), and gives the local time in Paris,getLocalTime().The
hello-parisbundle has the following external package dependency:org.fusesource.example.time
hello-paris-implFits the pattern of a provider bundle. The
hello-paris-implbundle implements thehello-parisAPI bundle.The
hello-paris-implbundle has the following external package dependencies:org.fusesource.example.hello.paris org.fusesource.example.time
hello-bostonFits the pattern of an API/provider combination bundle. The
hello-bostonbundle combines a Java interface and its implementation, where the Java interface returns a greeting,getGreeting(), and gives the local time in Boston,getLocalTime().The
hello-bostonbundle has the following external package dependency:org.fusesource.example.time
hello-consumerFits the pattern of a consumer bundle. The
hello-consumerbundle imports theHelloParisOSGi service and theHelloBostonOSGi service and then invokes on these services to report the local times in Paris and in Boston.The
hello-consumerbundle has the following external package dependencies:org.fusesource.example.hello.paris org.fusesource.example.hello.boston org.fusesource.example.time









