Friday, April 18, 2014

[Spring] Introduction to Spring



Introduction
  • Spring is an open source development framework for enterprise Java since February 2003. 
  • The core features of the Spring Framework can be used in developing any Java application, but there are extensions for building web applications on top of the Java EE platform. 
  • Address end-to-end requirements rather than one-tier.
  • Spring framework targets to make J2EE development easier to use and promote good programming practice by enabling a POJO-based (i.e POJO = Plain Old Java Object) programming model.(i.e. Enable Enterprise Java development while stick to old Java idioms, like interface-based programming and JavaBeans)
  • Spring focuses around providing a way to manage your business objects.
* Notes:
POJO - The name is used to emphasize that a given object is an ordinary Java Object, not a special object (that is, not a JavaBeam, EntityBean etc) and does not serve any other special role nor does it implement any special interfaces of any of the Java frameworks. Ideally speaking, a POJO is a Java object not bound by any restriction other than those forced by the Java Language Specification.

使用Framework代表著需要大型執行環境, 而POJO元件代表著在基本Java環境就能RUN.
http://supermand9362787.wordpress.com/ 
 
1. Spring is both comprehensive and modular. Spring has a layered architecture, meaning that you can choose to use just about any part of it in isolation, yet its architecture is internally consistent.
2. Spring is designed from the ground up to help you write code thats easy to test. Spring is an ideal framework for test driven projects.
3. Spring is an increasingly important integration technology, its role recognized by several large vendors.
4. Spring is a framework with many modules that simplify many different Java EE tasks.


Latest Version

Based on Spring Framework version 3.1.0 released in Dec 2011. 


What are benefits of using spring?

  • Lightweight: Spring is lightweight when it comes to size and transparency. The basic version of spring framework is around 2MB.
  • Inversion of control (IoC): Loose coupling is achieved in spring using the technique Inversion of Control. The objects give their dependencies instead of creating or looking for dependent objects. (i.e. Inversion of control (IoC) framework that allows bean dependencies to be automatically resolved upon object instantiation.)
  • Aspect oriented Programming (AOP): Spring supports Aspect oriented programming and enables cohesive development by separating application business logic from system services.
  • Container: Spring contains and manages the life cycle and configuration of application objects.
  • MVC Framework: Spring's web framework is a well-designed web MVC framework, which provides a great alternative to web frameworks such as Struts or other over engineered or less popular web frameworks.
  • Transaction Management: Spring provides a consistent transaction management interface that can scale down to a local transaction (using a single database, for example) and scale up to global transactions (using JTA, for example).
  • Exception Handling: Spring provides a convenient API to translate technology-specific exceptions (thrown by JDBC, Hibernate, or JDO, for example) into consistent, unchecked exceptions.
  • Fully portal across deployment environments.



Core Spring Framework Module




Spring Framework Triangle

<image>

Why Spring?
Spring promotes loose coupling among classes, isolating one class from changes in another.

Compared with EJB
???

safa


Spring Web
Spring Web refers to the collection of web frameworks from Spring, like Spring MVC for simple web apps and Spring Weblfow for the more sophisticated page flows.
·         Introduction
·         Using Spring in Web Applications
·         Overview of Spring Web
·         Dispatcher Servlet configuration
·         Extracting Request parameter
·         View Resolvers
·         Assignments


Spring Mobile
Spring Mobile is an extension to Spring MVC for development of mobile web applications. The Spring Mobile Device module provides a feature (DeviceResolver / LiteDeviceResolver) to detect devices like mobile and tablet in the server side.
Device aware view management is very useful specially when it is required to serve different optimized versions of same website based on request generating device type or specific devices.
Another feature called site preference management allows user to set his / her preference (SitePreference) to view a particular site in either "normal", "mobile" or "tablet" mode from a particular device.
Spring mobile also provides different types of site switchers (like mDot, dotMobi and urlPath SiteSwitcher) which automatically redirect users to the device specific site based on the device generating the request and site preference set by the user.


Installation and Setup
Note : Spring 3 requires at least JDK 5.
Java: JDK 5
Spring: Spring 3
IDE: Eclipse
Logging: Log4J
Maven



·         Dependency injection
·         Definition
·         Another name: Inversion of control (IoC)
·         Push configuration
·         How Non-IoC code looks like
·         How the code changed with dependency injection
·         What is AoP
·         It helps separate cross cutting concerns
·         AoP & POJOs
·         Some AoP terms

·         Spring IoC container
·         Manage components that make up an application
·         Managing the manage components that make up an application
·         Expressing the components as regular Java Beans
·         Configuration of the managed bean
·         Configuring beans & Manage the lifecycle of the beans

·         ApplicationContext & three implementations of the same
·         FileSystemXmlApplicationContext
·         ClassPathXmlApplicationContext
·         XMLWebApplicationContext

·         Practical Session -Setter Injection & Constructor Injection
·         Ref-Bean
·         Inner Bean
·         Compound properties
·         Aliasing beans
·         Bean scopes - singleton, prototype, request, session, global session

·         Practical Session - Configurations
·         Spring Configurations: Lazily-instantiated beans
·         Wiring collections
·         Creating beans from static factory methods
·         Creating beans from instance factory
·         Parent and child beans
·         Multiple config files
·         Init method, destroying beans
·         Autowiring
·         Post processing
·         PropertyPlaceholderConfigurer
·         Resolving text message
·         Beast Practice


No comments:

Post a Comment