Best Spring Training course provider Navi Mumbai, Spring Training course details, Spring Training coaching center Navi Mumbai,Spring Training course syllabus navi mumbai,Spring Training courses Navi Mumbai,Spring Training course training center Navi Mumbai,Spring Training administration courses
2. B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173
springtraining.vibranttechnologies.co.in
enquiry@vibrantgroup.co.in
springtraining.vibranttechnologies.co.in
What is Spring?
2 Things:
An Inversion of Control (IoC) Container
Utilities that provide a consistent (and simple!
API to many other technologies (JDBC, ORM,
AOP, Declarative Transactions, etc)
3. B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173
advancedaixadministration.vibranttechnologies.co.in
enquiry@vibrantgroup.co.in
businessanalyst.vibranttechnologies.co.in
Guiding Principles of Spring
Minimize dependencies on Spring
Minimize dependencies between all layers of an
application.
All application code should be testable, without an
application server or other complex environment
Fully factor the APIs (the 90% case should be
accomplished in one line of code!)
4. B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173
advancedaixadministration.vibranttechnologies.co.in
enquiry@vibrantgroup.co.in
businessanalyst.vibranttechnologies.co.inWhat is Inversion of Control (IoC)?
(besides yet another confusing term for a simple concept)
IoC is all about Object dependencies.
Traditional "Pull" approach:
Direct instantiation
Asking a Factory for an implementation
Looking up a service via JNDI
"Push" approach:
Something outside of the Object "pushes" its
dependencies into it. The Object has no knowledge
of how it gets its dependencies, it
5. B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173
advancedaixadministration.vibranttechnologies.co.in
enquiry@vibrantgroup.co.in
businessanalyst.vibranttechnologies.co.in
The BookDemo Application:
(A simple CRUD app)
User Interface
Service Layer
Data Access Layer
DB
Domain
Model
6. B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173
advancedaixadministration.vibranttechnologies.co.in
enquiry@vibrantgroup.co.in
businessanalyst.vibranttechnologies.co.in
Pull Example
public class BookDemoServicePullImpl implements BookDemoServic
public void addPublisherToBook(Book book) {
BookDemoFactory factory = BookDemoFactory.getFactory()
BookDemoDao dao = factory.getBookDemoDao();
String isbn = book.getIsbn();
if (book.getPublisher() == null && isbn != null) {
Publisher publisher = dao.findPublisherByIsbn(isbn
book.setPublisher(publisher);
}
}
}
7. B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173
advancedaixadministration.vibranttechnologies.co.in
enquiry@vibrantgroup.co.in
businessanalyst.vibranttechnologies.co.in
Push Example
(Dependency Injection)public class BookDemoServiceImpl implements
BookDemoService {
private BookDemoDao dao;
public void addPublisherToBook(Book book) {
String isbn = book.getIsbn();
if (book.getPublisher() == null && isbn !=
null) {
Publisher publisher =
dao.findPublisherByIsbn(isbn);
book.setPublisher(publisher);
}
}
8. B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173
advancedaixadministration.vibranttechnologies.co.in
enquiry@vibrantgroup.co.in
businessanalyst.vibranttechnologies.co.in
Why is Dependency Injection better?
2 reasons:
Loose Coupling
Testability
Loose Coupling is improved because you don't hard-code depende
between layers and modules. Instead you configure them outside
the code. This makes it easy to swap in a new implementation of
service, or break off a module and reuse it elsewhere.
Testability is improved because your Objects don't know or care wh
environment they're in as long as someone injects their
dependencies. Hence you can deploy Objects into a test environm
and inject Mock Objects for their dependencies with ease.
9. B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173
advancedaixadministration.vibranttechnologies.co.in
enquiry@vibrantgroup.co.in
businessanalyst.vibranttechnologies.co.in
How Spring does Inversion of Control
Write a configuration file in which you name
concrete "beans" for the interfaces between your
layers.
"Wire" the application together by stating which
beans are dependent on each other.
11. B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173
advancedaixadministration.vibranttechnologies.co.in
enquiry@vibrantgroup.co.in
businessanalyst.vibranttechnologies.co.in
Bootstapping the IoC container
To start an app using IoC:
Create an ApplicationContext object and tell it
where applicationContext.xml is.
ApplicationContext appContext =
new ClassPathXmlApplicationContext("classpath*:applicationContext.xml");
This just has to be done once on startup, and can be done in the main
method or whatever code bootstraps the application.
12. B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173
advancedaixadministration.vibranttechnologies.co.in
enquiry@vibrantgroup.co.in
businessanalyst.vibranttechnologies.co.in
Bootstapping the IoC container
For web applications the situation is simpler:
Web applications are bootstrapped by the web
container based on the web.xml file. Hence
creating an ApplicationContext on startup is as
simple as a single declaration in web.xml:
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
13. B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173
advancedaixadministration.vibranttechnologies.co.in
enquiry@vibrantgroup.co.in
androidtraining.vibranttechnologies.co.in
Where to Get More Information
Vibrant Group:
www.vibrantgroup.co.in
Vibrant Technologies & Computers
www.vibranttechnologies.co.in/technologies.vibrantgroup.co.
in
Vibrant HR Team
www.hr.vibrangroup.co.in