What are the benefits of IOC?
· It minimizes
the amount of code in your application.It makes your application easy to test as it doesn't require any
singletons or JNDI lookup mechanisms in your unit test cases. Loose coupling
is promoted with minimal effort and least intrusive mechanism.IOC containers support eager instantiation
and lazy loading of services.
What is Spring IoC container?
The Spring IoC creates the objects, wire them together, configure
them, and manage their complete lifecycle from creation till destruction. The
Spring container uses dependency injection (DI) to manage the components that
make up an application.
What are types of IoC containers? Explain them.
· Bean Factory container: This is the
simplest container providing basic support for DI .The BeanFactory is usually
preferred where the resources are limited like mobile devices or applet based
applications
· Spring ApplicationContext Container:
This container adds more enterprise-specific functionality such as the ability
to resolve textual messages from a properties file and the ability to publish
application events to interested event listeners.
What is the difference between singleton and prototype bean?
Prototype scope = A new object is created each time it
is
injected/looked up. It
will use
new SomeClass()
each
time.
Singleton scope = The same object is returned each time
it
is injected/looked up.
Here it will instantiate one instance
of
SomeClass
and
then return it each time.
No comments:
Post a Comment