Spring is the most popular application development framework for
enterprise Java. Millions of developers around the world use Spring
Framework to create high performing, easily testable, reusable code.
পৃষ্ঠাসমূহ
Labels
Search Your Article
CS
Pageviews
Showing posts with label Spring Core Basics. Show all posts
Showing posts with label Spring Core Basics. Show all posts
Monday, January 23, 2017
Spring Framework - Architecture
Spring could potentially be a one-stop shop for all your enterprise
applications, however, Spring is modular, allowing you to pick and
choose which modules are applicable to you, without having to bring in
the rest. Following section gives detail about all the modules available
in Spring Framework.
Spring - Environment Setup
This tutorial will guide you on how to prepare a development
environment to start your work with Spring Framework. This tutorial will
also teach you how to setup JDK, Tomcat and Eclipse on your machine
before you setup Spring Framework:
Spring - Hello World Example
Let us start actual programming with Spring Framework. Before you
start writing your first example using Spring framework, you have to
make sure that you have setup your Spring environment properly as
explained in Spring - Environment Setup tutorial.
Spring - IoC Containers
The Spring container is at the core of the Spring Framework. The
container will create the objects, wire them together, configure them,
and manage their complete lifecycle from creation till destruction.
Spring - Bean Definition
The objects that form the backbone of your application and that are
managed by the Spring IoC container are called beans. A bean is an
object that is instantiated, assembled, and otherwise managed by a
Spring IoC container.
Spring - Bean Scopes
When defining a <bean> in Spring, you have the option of
declaring a scope for that bean. For example, To force Spring to produce
a new bean instance each time one is needed, you should declare the
bean's scope attribute to be prototype. Similar way if you want
Spring to return the same bean instance each time one is needed, you
should declare the bean's scope attribute to be singleton.
Spring - Bean Life Cycle
The life cycle of a Spring bean is easy to understand. When a bean is
instantiated, it may be required to perform some initialization to get
it into a usable state. Similarly, when the bean is no longer required
and is removed
from the container, some cleanup may be required.
Spring - Bean Post Processors
The BeanPostProcessor interface defines callback methods that
you can implement to provide your own instantiation logic,
dependency-resolution logic etc. You can also implement some custom
logic after the Spring container finishes instantiating, configuring,
and initializing a bean by plugging in one or more BeanPostProcessor
implementations.
Spring - Bean Definition Inheritance
A bean definition can contain a lot of configuration information,
including constructor arguments, property values, and container-specific
information such as initialization method, static factory method name,
and so on.
Spring - Dependency Injection
Every java based application has a few objects that work together to
present what the end-user sees as a working application.
Spring - Injecting Inner Beans
As you know Java inner classes are defined within the scope of other classes, similarly, inner beans
are beans that are defined within the scope of another bean. Thus, a
<bean/> element inside the <property/> or
<constructor-arg/> elements is called inner bean and it is shown
below.
Spring - Injecting Collection
You have seen how to configure primitive data type using value attribute and object references using ref
attribute of the <property> tag in your Bean configuration file.
Both the cases deal with passing singular value to a bean.
Spring - Beans Auto-Wiring
You have learnt how to declare beans using the <bean> element
and inject <bean> with using <constructor-arg> and
<property> elements in XML configuration file.
Spring - Annotation Based Configuration
Starting from Spring 2.5 it became possible to configure the dependency injection using annotations.
So instead of using XML to describe a bean wiring, you can move the
bean configuration into the component class itself by using annotations
on the relevant class, method, or field declaration.
Spring - Java Based Configuration
So far you have seen how we configure Spring beans using XML
configuration file. If you are comfortable with XML configuration, then I
will say it is really not required to learn how to proceed with Java
based configuration because you are going to achieve the same result
using either of the configurations available.
Event Handling in Spring
You have seen in all the chapters that core of Spring is the ApplicationContext,
which manages complete life cycle of the beans. The ApplicationContext
publishes certain types of events when loading the beans. For example, a
ContextStartedEvent is published when the context is started and ContextStoppedEvent is published when the context is stopped.
Custom Events in Spring
There are number of steps to be taken to write and publish your own
custom events. Follow the instructions given in this chapter to write,
publish and handle Custom Spring Events.
AOP with Spring Framework
One of the key components of Spring Framework is the Aspect oriented programming (AOP)
framework. Aspect Oriented Programming entails breaking down program
logic into distinct parts called so-called concerns.
Spring - JDBC Framework Overview
While working with database using plain old JDBC, it becomes
cumbersome to write unnecessary code to handle exceptions, opening and
closing database connections etc. But Spring JDBC Framework takes care
of all the low-level details starting from opening the connection,
prepare and execute the SQL statement, process exceptions, handle
transactions and finally close the connection.
Subscribe to:
Posts (Atom)