Spring Questions and Answers – Getting Started with OSGi

This set of Advanced Java Spring Questions & Answers focuses 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
View Answer

Answer: a
Explanation: 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
View Answer

Answer: a
Explanation: 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
View Answer

Answer: a
Explanation: SpringSource dm Server supports dynamic deployment, enhanced tooling, HTTP, and native .war deployment.
advertisement
advertisement

4. OSGi is a framework.
a) True
b) False
View Answer

Answer: b
Explanation: 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
View Answer

Answer: b
Explanation: 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.
Note: Join free Sanfoundry classes at Telegram or Youtube

6. In OSGi, anything used by something else is a state.
a) True
b) False
View Answer

Answer: b
Explanation: 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
View Answer

Answer: d
Explanation: “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.
advertisement

8. OSGi bundles are simply standard .jar files with customized MANIFESTs that OSGi consumes at runtime.
a) True
b) False
View Answer

Answer: a
Explanation: 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
View Answer

Answer: c
Explanation: We repeat it here mainly for illustrative purposes.
advertisement

10. The plug-in produces OSGi–compliant bundles that work in any container.
a) True
b) False
View Answer

Answer: c
Explanation: 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
View Answer

Answer: a
Explanation: 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
View Answer

Answer: b
Explanation: When the bundle begins to load and start, it calls the start method of the Activator.

13. To start using Spring to smooth over some of the minutiae of resource acquisition and to help build more reliable systems in an OSGi environment.
a) Spring DM server
b) Spring Dynamic Modules
c) All of the mentioned
d) None of the mentioned
View Answer

Answer: b
Explanation: Use Spring Dynamic Modules to provide the integration. Spring Dynamic Modules is a framework on top of OSGi that works with any OSGi environment.

14. Spring Dynamic Modules scans our deployed bundles and loads an ApplicationContext (actually, the specific type of the ApplicationContext is OsgiBundleXmlApplicationContext) into memory based on an event, or a trigger.
a) True
b) False
View Answer

Answer: a
Explanation: There are two ways to trigger this behavior. The first is to explicitly specify in the META-INF/MANIFEST.MF file the attribute Spring-Context, which allows you to override the default location it consults. Otherwise, by default, Spring Dynamic Modules will look for the XML file in the META-INF/spring directory of a bundle.

15. You’ll split your OSGi–specific Spring configuration and your plain-vanilla Spring configuration into:-
a) modulename-context.xml
b) modulename-osgi-context.xml
c) all of the mentioned
d) none of the mentioned
View Answer

Answer: a
Explanation: Typically, you’ll split your OSGi–specific Spring configuration and your plain-vanilla Spring configuration into two different files, of the form: modulename-context.xml and modulename-osgi-context.xml.

Sanfoundry Global Education & Learning Series – Java Spring.
To practice advanced questions on all areas of Java Spring, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.