Advanced Java Spring Questions & Answers on “Getting Started with OSGi”.
1. OSGi—which was formerly known as the:-
a) Open Services Gateway initiative
b) Open Source Gateway initiative
c) Open Services Gateway initialisation
d) None of the mentioned
Answer: a
Clarification: OSGi—which was formerly known as the Open Services Gateway initiative, though the name’s obsolete now—has its roots in the embedded space, where dynamic service provisioning is far more important than it is in the gridiron world of enterprise applications.
2. OSGi provides a layer on top of the JVM’s default class loader.
a) True
b) False
Answer: a
Clarification: The deployment unit for OSGi is a bundle, which is essentially a JAR with an augmented MANIFEST.MF.
3. On top of Spring Dynamic Modules, SpringSource built SpringSource dm Server, which is a server wired from top to bottom with OSGi and Spring.
a) True
b) False
Answer: a
Clarification: SpringSource dm Server supports dynamic deployment, enhanced tooling, HTTP, and native .war deployment.
4. OSGi is a framework.
a) True
b) False
Answer: b
Clarification: OSGi is a specification, not a framework. There are many implementations of the specification, just as there are many implementations of the Java EE specification.
5. User component models are:-
a) OSGi
b) Spring
c) All of the mentioned
d) None of the mentioned
Answer: b
Clarification: OSGi is not a user component model, like Spring or EJB 3. Instead, it sits below your components, providing life-cycle management for Java classes.
6. In OSGi, anything used by something else is a state.
a) True
b) False
Answer: b
Clarification: In OSGi, anything used by something else is a service. “Service” doesn’t imply any concrete inheritance.
7. “Service” doesn’t imply any:-
a) RPC
b) inheritance
c) transactional qualities
d) all of the mentioned
Answer: d
Clarification: “Service” doesn’t imply any concrete inheritance; it doesn’t imply transactional qualities, and it doesn’t imply RPC. It’s merely a class on whose concrete, black-box functionality and interface your class relies.
8. OSGi bundles are simply standard .jar files with customized MANIFESTs that OSGi consumes at runtime.
a) True
b) False
Answer: a
Clarification: The plug-in wraps the bnd command line tool.
9. Tool which dynamically interrogates classes for their imports and generates OSGi–compliant entries.
a) pnd
b) jndi
c) bnd
d) none of the mentioned
Answer: c
Clarification: We repeat it here mainly for illustrative purposes.
10. The plug-in produces OSGi–compliant bundles that work in any container.
a) True
b) False
Answer: c
Clarification: To read more on the plug-in itself, see http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html.
11. The Bundle-Activator directive describes to the OSGi environment, which class implements :-
a) BundleActivator
b) BundleActivate
c) All of the mentioned
d) None of the mentioned
Answer: a
Clarification: The Bundle-Activator directive describes to the OSGi environment, which class implements BundleActivator, and should be consulted when life cycle events occur.
12. When the bundle begins to load and start, it calls the start method of the:-
a) BundleActivator
b) Activator
c) All of the mentioned
d) None of the mentioned
