Spring Framework Interview Questions
Apr 22nd
1. What is IOC (or Dependency Injection)?
The basic concept of the Inversion of Control pattern (also known as dependency injection) is that you do not create your objects but describe how they should be created. You don’t directly connect your components and services together in code but describe which services are needed by which components in a configuration file. A container (in the case of the Spring framework, the IOC container) is then responsible for hooking it all up.
i.e., Applying IoC, objects are given their dependencies at creation time by some external entity that coordinates each object in the system. That is, dependencies are injected into objects. So, IoC means an inversion of responsibility with regard to how an object obtains references to collaborating objects.
2. What are the different types of IOC (dependency injection) ?
There are three types of dependency injection:
- Constructor Injection (e.g. Pico container, Spring etc): Dependencies are provided as constructor parameters.
- Setter Injection (e.g. Spring): Dependencies are assigned through JavaBeans properties (ex: setter methods).
- Interface Injection (e.g. Avalon): Injection is done through an interface.
Note: Spring supports only Constructor and Setter Injection
3. What are the benefits of IOC (Dependency Injection)?
Benefits of IOC (Dependency Injection) are as follows:
-
Minimizes the amount of code in your application. With IOC More >
Spring-managed Hibernate Listeners with JPA
Mar 8th
A standard use-case – you need an entity listener in order to execute some code on every update/insert/delete. For auditing, for example. But things are not straightforward if you need spring dependencies in your listeners and you are using JPA.
First of all, the JPA-only listeners are insufficient – you can annotate a method with @PreUpdate, but the most you can get as context is the entity it is about (documentation). But you may need the old values. Or the extracted ID of the entity. Or other metadata. All of that is not supported by JPA. So you need to implement hibernate interfaces like PreDeleteEventListener, PreUpdateEventListener, PostInsertEventListener, etc. and get their XEvent objects
VN:F [1.9.11_1134]please wait...Rating: 10.0/10 (1 vote cast)VN:F [1.9.11_1134]Rating: +1 (from 1 vote)70+ PSD to HTML Resources for Web Developers
Dec 1st
If you’re interested in learning more about doing the PSD to HTML coding yourself, these tutorials will be very helpful. (more…)
VN:F [1.9.11_1134]please wait...Rating: 10.0/10 (1 vote cast)VN:F [1.9.11_1134]Rating: +1 (from 1 vote)30+ Awesome jQuery Animation Tutorials
Dec 1st
50 Best Photoshop Text Effect Tutorials
Dec 1st
20+ Best Photoshop Effects Tutorials
Dec 1st
The 20 Most Popular Photoshop Tutorials
Nov 30th
Interview Questions for all type of Interview
Nov 30th
Emerging Web 3.0 Technologies You Need To Know
Nov 30th
(more…) VN:F [1.9.11_1134]please wait...Rating: 0.0/10 (0 votes cast)VN:F [1.9.11_1134]Rating: 0 (from 0 votes)