Java Reference
In-Depth Information
extremely powerful, because it makes it possible to design as many different ways of
managing the OSG i framework as you can think of; in the end, you're limited only by
your imagination as a developer.
Because there's no standard way for users to interact with the lifecycle API , you
could use a framework-specific mechanism. But using this approach here would be a
disservice to you, because it's a great opportunity for learning. Instead of reusing
someone else's work in this chapter, we'll lead you through some basic steps for devel-
oping your own command line interface for interacting with the OSG i framework.
This gives you the perfect tool, alongside the paint program, to explore the rich capa-
bilities provided by the OSG i lifecycle API .
Shells, shells, everywhere
If you have some familiarity with using OSGi frameworks, you're likely aware that
most OSGi framework implementations (such as Apache Felix, Eclipse Equinox, and
Knopflerfish) have their own shells for interacting with a running framework. The OSGi
specification doesn't define a standard shell (although there has been some work to-
ward this goal recently; see http://felix.apache.org/site/apache-felix-gogo.html ) , but
shells need not be tied to a specific framework and can be implemented as bundles,
just as you'll do here.
3.2.1
Introducing lifecycle to the paint program
Enough with the talkā€”let's see the lifecycle API in action by kicking off the shell appli-
cation and using it to install the paint program. To do this, type the following into
your operating system console (Windows users, substitute \ for / ):
$ cd chapter03/shell-example/
$ ant
$ java -jar launcher.jar bundles
Bundle: org.foo.shell started with bundle id 1 - listening on port 7070
The shell is created as a bundle that, on starting, begins listening for user input on a
telnet socket. This allows clients to connect and perform install, start, stop, update,
and uninstall actions on bundles. It also provides some basic diagnostic facilities.
Here's a session that connects to the newly launched framework and uses the shell to
install the paint example:
$ telnet localhost 7070
-> install file:../paint-example/bundles/paint-3.0.jar
Bundle: 2
-> install file:../paint-example/bundles/shape-3.0.jar
Bundle: 3
-> start 2
-> install file:../paint-example/bundles/circle-3.0.jar
Bundle: 4
-> install file:../paint-example/bundles/square-3.0.jar
Bundle: 5
Search WWH ::




Custom Search