Java Reference
In-Depth Information
Framework
Framework
Bundle cache
Bundle cache
Bundle cache
l
l
Framework
stop
Framework
restart
Bundle
Bundle
Bundle
Figure 3.6 Bundle cache during framework restarts
Bundle installation isn't the only lifecycle operation to impact the bundle cache.
When a bundle is started using Bundle.start() , the framework persistently marks the
bundle as started, even if Bundle.start() throws an exception, such as when the bun-
dle can't be resolved or the bundle's BundleActivator.start() method throws an
exception. When a bundle is persistently marked as started, subsequent executions of
the framework not only reinstall the bundle but also attempt to start it. From a man-
agement perspective, you deploy a configuration of your application by installing a set
of bundles and activating them. Subsequent framework executions automatically
restart your application. If you stop a bundle using Bundle.stop() , this removes the
persistently started status of the bundle; subsequent framework executions no longer
restart the bundle, although it's still reinstalled. This is another means of modifying
your application's configuration.
You may want to ask, “What about updating and uninstalling a bundle? These must
impact the bundle cache, right?” The short answer is, yes, but this isn't the whole
answer. Bundle.update() and Bundle.uninstall() impact the bundle cache by sav-
ing a new bundle JAR file or removing an existing bundle JAR file, respectively. But
these operations may not affect the cache immediately. We'll explain these oddities
when we discuss the relationship between the modularity and lifecycle layers in sec-
tion 3.5. Next, we'll delve into the details of the shell bundle as we more fully explore
how to use the lifecycle layer API .
3.3
Using the lifecycle API in your bundles
So far, you haven't implemented much functionality for the shell—you just created the
activator to start it up and shut it down. In this section, we'll show you how to implement
the bulk of its functionality. You'll use a simple command pattern to provide the exe-
cutable actions to let you interactively install, start, stop, update, and uninstall bundles.
You'll even add a persistent history to keep track of previously executed commands.
A high-level understanding of the approach will be useful before you start.
The main piece is the telnet binding, which listens to the configured port for
Search WWH ::




Custom Search