250+ TOP MCQs on Spring Dynamic Modules and Answers

tricky Java Spring questions and answers on “Spring Dynamic Modules”.

1. To create services and have those automatically installed in the registry.
a) Spring Dynamic Modules
b) Spring DM Server
c) Spring Tooling
d) None of the mentioned

Answer: a
Clarification: You can use Spring Dynamic Modules configuration schema to export a service. The service will be made available to other beans as well as other OSGi components.

2. Element to export the bean as an OSGi service, classified by the interface we specify.
a) osgix
b) osgi:service
c) all of the mentioned
d) none of the mentioned

Answer: b
Clarification: We’ll use the osgi:service element to export the bean as an OSGi service, classified by the interface we specify.

3. These beans are proxies, some may load asynchronously or take a longer time to register.

<osgi:service
      interface="com.apress.springrecipes.
      osgi.helloworld.service.GreeterService">
      <bean class="com.apress.springrecipes.osgi.helloworld.
      service.GreeterServiceImpl"/>
</osgi:service>

a) True
b) False

Answer: a
Clarification: This implies that you may have timing issues to resolve in configuring your service. For this, Spring Dynamic Modules provides the depends-on attribute, which lets your bean wait for another bean.

4. An anonymous bean specified inside of the osgi:service element allows you to avoid cluttering the namespace.
a) True
b) False

Answer: a
Clarification: You can abbreviate the syntax by using an anonymous bean.

<osgi:service auto-export="all-classes" ref="greeterService">
<osgi:interfaces>
<value>com.apress.springrecipes.osgi.helloworld.service.GreeterService</value>
<value>com.apress.springrecipes.osgi.helloworld.service.GreetingRecorderService</value>
</osgi:interfaces>
</osgi:service>

5. The first, most direct connection to OSGi is the bean that’s created on your behalf when you export a service. This bean, an instance of:-
a) org.osgi.framework.ServiceRegistration
b) org.osgi.framework.Service
c) org.osgi.framework.ServiceRegister
d) none of the mentioned

  250+ TOP MCQs on Securing URL Access and Answers

Answer: a
Clarification: This bean, an instance of org.osgi.framework.ServiceRegistration, is in turn a delegate to the Spring bean you have defined.

6. By default, beans created in a Spring application context are global to the entire OSGi runtime.
a) True
b) False

Answer: a
Clarification: By default, beans created in a Spring application context are global to the entire OSGi runtime, including all clients that use it.

7. Sometimes, you may want to limit the visibility of a service so that multiple clients each get their own instance of the bean.
a) time
b) scope
c) attr
d) none of the mentioned

Answer: b
Clarification: Spring Dynamic Modules provides a clever use of the scope attribute here, allowing you to limit beans exported as services to the client, or service importer.

8. Spring Dynamic Modules also supports injection and manipulation of bundles themselves. An injected bundle is of type:-
a) org.osgi.framework.savedBundle
b) org.osgi.framework.Bundle
c) org.osgi.framework.BundleInstance
d) none of the mentioned

Answer: b
Clarification: The simplest use case is that you want to obtain an instance of the org.osgi.framework.Bundle class from an already loaded bundle in the system.

9. Once acquired, the Bundle can be interrogated to introspect information about the bundle itself, including any entries, its current state.
a) True
b) False

Answer: a
Clarification: Once acquired, the Bundle can be interrogated to introspect information about the bundle itself, including any entries, its current state (which can be any of: UNINSTALLED, INSTALLED, RESOLVED, STARTING, STOPPING, or ACTIVE), and any headers specified on the bundle.

10. OSGi will let you maintain multiple versions of a service in your registry at the same time.
a) True
b) False

  250+ TOP MCQs on Getting Started with OSGi and Answers

Answer: a
Clarification: OSGi, and Spring Dynamic Modules on top of it, provides many tools for discriminating services both in publishing and consuming services.

11. Multiple services of the same interface may be registered inside of an OSGi environment, which necessitates a conflict-resolution process.
a) True
b) False

Answer: a
Clarification: To aid in that, Spring Dynamic Modules provides a few features to help.

12. When specified on a service element, allows the ascription of a rank relative to other beans with the same interface.
a) Ranking
b) Service
c) All of the mentioned
d) None of the mentioned

Answer: a
Clarification: Ranking is specified on the service element itself. When encountered, the OSGi runtime will return the service with the highest-ranking integer value.

13. A more robust solution to service discrimination is service attributes.
a) True
b) False

Answer: a
Clarification: A service attribute is an arbitrary key and value pair that the service exports, and on which lookups for a service with multiple matches can be predicated.

14. There are frequently situations where OSGi will return more than one instance of a service that satisfies the interface.
a) True
b) False

Answer: a
Clarification: Take, for example, a deployment where you have multiple GreeterServices deployed for various regions. Spring Dynamic Modules provides the set and list interfaces to retrieve multiple references and populate a java.util.Set and java.util.List, respectively.

15. Attribute, which, is the symbolic name of another bundle.
a) Fragment
b) Fragment-Host
c) All of the mentioned
d) None of the mentioned

Answer: b
Clarification: The Fragment-Host attribute, in turn, is the symbolic name of another bundle.

  250+ TOP MCQs on Securing and persisting objects in Web Flows and Answers

To practice tricky questions and answers on all areas of Java Spring,

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top