Java Reference
In-Depth Information
The waitForStop() method takes a timeout value in milliseconds and returns a
FrameworkEvent object whose type indicates why the framework stopped:
FrameworkEvent.STOPPED —The framework was stopped.
FrameworkEvent.STOPPED_UPDATE —The framework was updated.
FrameworkEvent.ERROR —An error forced the framework to shut down, or an
error occurred during shutdown.
FrameworkEvent.WAIT_TIMEDOUT —The timeout value expired before the
framework stopped.
When the framework has successfully stopped, it can be safely discarded or reused. To
start the framework again, call start() or init() / start() . The normal startup pro-
cess will commence, except the bundle cache won't be deleted again if the storage-
cleaning policy is onFirstInit , because that applies only the first time the framework
is initialized. Otherwise, you can stop and restart the framework as much as you like.
That's all there is to creating and launching frameworks with the standard frame-
work launching and embedding API from the R4.2 specification. Let's explore your
newfound knowledge by examining the generic bundle launcher.
Launching vs. embedding
Why is this called the framework launching and embedding API? The term launching
is largely self explanatory, but the term embedding is less clear. What is the differ-
ence between the two? The conceptual difference is that launching refers to creating
and starting a framework instance in isolation, whereas embedding refers to creating
and starting a framework instance within (embedded in) another application. Techni-
cally, there's very little difference between the two, because creating, configuring,
and starting a framework instance with the API is the same in either case.
The main technical differences are in your objectives. When you launch a framework,
all functionality is typically provided by installed bundles, and there's no concern
about the outside world. But when you embed a framework, you often have function-
ality on the outside that you want to expose somehow on the inside or vice versa.
Embedding a framework instance has some additional constraints and complications
that we'll discuss later in this chapter.
13.2 Launching the framework
The general steps for launching a framework are straightforward:
Set the desired configuration properties.
1
Create a framework instance using the configuration properties.
2
Start the framework instance.
3
Install some bundles.
4
 
Search WWH ::




Custom Search