Modules Spring Framework
1 modules
1.1 inversion of control container (dependency injection)
1.2 aspect-oriented programming framework
1.3 data access framework
1.4 transaction management framework
1.5 model–view–controller framework
1.6 remote access framework
1.7 convention-over-configuration rapid application development
1.7.1 spring boot
1.7.2 spring roo
1.8 batch framework
1.9 integration framework
modules
the spring framework includes several modules provide range of services:
spring core container: base module of spring , provides spring containers (beanfactory , applicationcontext).
aspect-oriented programming: enables implementing cross-cutting concerns.
authentication , authorization: configurable security processes support range of standards, protocols, tools , practices via spring security sub-project (formerly acegi security system spring).
convention on configuration: rapid application development solution spring-based enterprise applications offered in spring roo module
data access: working relational database management systems on java platform using java database connectivity (jdbc) , object-relational mapping tools , nosql databases
inversion of control container: configuration of application components , lifecycle management of java objects, done via dependency injection
messaging: configurative registration of message listener objects transparent message-consumption message queues via java message service (jms), improvement of message sending on standard jms apis
model–view–controller: http- , servlet-based framework providing hooks extension , customization web applications , restful (representational state transfer) web services.
remote access framework: configurative remote procedure call (rpc)-style marshalling of java objects on networks supporting java remote method invocation (rmi), corba (common object request broker architecture) , http-based protocols including web services (soap (simple object access protocol))
transaction management: unifies several transaction management apis , coordinates transactions java objects
remote management: configurative exposure , management of java objects local or remote configuration via java management extensions (jmx)
testing: support classes writing unit tests , integration tests
inversion of control container (dependency injection)
central spring framework inversion of control (ioc) container, provides consistent means of configuring , managing java objects using reflection. container responsible managing object lifecycles of specific objects: creating these objects, calling initialization methods, , configuring these objects wiring them together.
objects created container called managed objects or beans. container can configured loading xml (extensible markup language) files or detecting specific java annotations on configuration classes. these data sources contain bean definitions provide information required create beans.
objects can obtained means of either dependency lookup or dependency injection. dependency lookup pattern caller asks container object object specific name or of specific type. dependency injection pattern container passes objects name other objects, via either constructors, properties, or factory methods.
in many cases 1 need not use container when using other parts of spring framework, although using make application easier configure , customize. spring container provides consistent mechanism configure applications , integrates java environments, small-scale applications large enterprise applications.
the container can turned partially compliant ejb (enterprise javabeans) 3.0 container means of pitchfork project. criticize spring framework not complying standards. however, springsource doesn t see ejb 3 compliance major goal, , claims spring framework , container allow more powerful programming models. not create object, describe how should created, defining in spring configuration file. not call services , components, tell services , components must called, defining them in spring configuration files. makes code easy maintain , easier test through ioc.
aspect-oriented programming framework
the spring framework has own aspect-oriented programming (aop) framework modularizes cross-cutting concerns in aspects. motivation creating separate aop framework comes belief should possible provide basic aop features without complexity in either design, implementation, or configuration. spring aop framework takes full advantage of spring container.
the spring aop framework proxy pattern-based, , configured @ run time. removes need compilation step or load-time weaving. on other hand, interception allows public method-execution on existing objects @ join point.
compared aspectj framework, spring aop less powerful, less complicated. spring 1.2 includes support configure aspectj aspects in container. spring 2.0 added more integration aspectj; example, pointcut language reused , can mixed spring aop-based aspects. further, spring 2.0 added spring aspects library uses aspectj offer common spring features such declarative transaction management , dependency injection via aspectj compile-time or load-time weaving. springsource uses aspectj aop in other spring projects such spring roo , spring insight, spring security offering aspectj-based aspect library.
spring aop has been designed make able work cross-cutting concerns inside spring framework. object created , configured container can enriched using spring aop.
the spring framework uses spring aop internally transaction management, security, remote access, , jmx.
since version 2.0 of framework, spring provides 2 approaches aop configuration:
schema-based approach and
@aspectj-based annotation style.
<beans xmlns= http://www.springframework.org/schema/beans
xmlns:mvc= http://www.springframework.org/schema/mvc
xmlns:xsi= http://www.w3.org/2001/xmlschema-instance
xmlns:aop= http://www.springframework.org/schema/aop
xmlns:context= http://www.springframework.org/schema/context
xsi:schemalocation= http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd >
the spring team decided not introduce new aop-related terminology; therefore, in spring reference documentation , api, terms such aspect, join point, advice, pointcut, introduction, target object (advised object), aop proxy, , weaving have same meanings in other aop frameworks (particularly aspectj).
data access framework
spring s data access framework addresses common difficulties developers face when working databases in applications. support provided popular data access frameworks in java: jdbc, ibatis/mybatis, hibernate, java data objects (jdo), java persistence api (jpa), oracle toplink, apache ojb, , apache cayenne, among others.
for of these supported frameworks, spring provides these features
resource management - automatically acquiring , releasing database resources
exception handling - translating data access related exception spring data access hierarchy
transaction participation - transparent participation in ongoing transactions
resource unwrapping - retrieving database objects connection pool wrappers
abstraction binary large object (blob) , character large object (clob) handling
all these features become available when using template classes provided spring each supported framework. critics have said these template classes intrusive , offer no advantage on using (for example) hibernate api directly. in response, spring developers have made possible use hibernate , jpa apis directly. requires transparent transaction management, application code no longer assumes responsibility obtain , close database resources, , not support exception translation.
together spring s transaction management, data access framework offers flexible abstraction working data access frameworks. spring framework doesn t offer common data access api; instead, full power of supported apis kept intact. spring framework framework available in java offers managed data access environments outside of application server or container.
while using spring transaction management hibernate, following beans may have configured:
a data source com.mchange.v2.c3p0.combopooleddatasource or org.apache.commons.dbcp.basicdatasource
a sessionfactory org.springframework.orm.hibernate3.localsessionfactorybean datasource attribute
a hibernateproperties org.springframework.beans.factory.config.propertiesfactorybean
a transactionmanager org.springframework.orm.hibernate3.hibernatetransactionmanager sessionfactory attribute
other points of configuration include:
an aop configuration of cutting points.
transaction semantics of aop advice.
transaction management framework
spring s transaction management framework brings abstraction mechanism java platform. abstraction capable of:
working local , global transactions (local transaction not require application server)
working nested transactions
working savepoints
working in environments of java platform
in comparison, java transaction api (jta) supports nested transactions , global transactions, , requires application server (and in cases deployment of applications in application server).
the spring framework ships platformtransactionmanager number of transaction management strategies:
transactions managed on jdbc connection
transactions managed on object-relational mapping units of work
transactions managed via jta transactionmanager , usertransaction
transactions managed on other resources, object databases
next abstraction mechanism framework provides 2 ways of adding transaction management applications:
programmatically, using spring s transactiontemplate
configuratively, using metadata xml or java annotations (@transactional, etc.)
together spring s data access framework — integrates transaction management framework — possible set transactional system through configuration without having rely on jta or ejb. transactional framework integrates messaging , caching engines.
model–view–controller framework
the spring framework features own model–view–controller (mvc) web application framework, wasn t planned. spring developers decided write own web framework reaction perceived poor design of (then) popular jakarta struts web framework, deficiencies in other available frameworks. in particular, felt there insufficient separation between presentation , request handling layers, , between request handling layer , model.
like struts, spring mvc request-based framework. framework defines strategy interfaces of responsibilities must handled modern request-based framework. goal of each interface simple , clear s easy spring mvc users write own implementations, if choose. mvc paves way cleaner front end code. interfaces tightly coupled servlet api. tight coupling servlet api seen failure on part of spring developers offer high-level abstraction web-based applications. however, coupling makes sure features of servlet api remain available developers while offering high abstraction framework ease working said api.
the dispatcherservlet class front controller of framework , responsible delegating control various interfaces during execution phases of http request.
the important interfaces defined spring mvc, , responsibilities, listed below:
controller: comes between model , view manage incoming requests , redirect proper response. acts gate directs incoming information. switches between going model or view.
handleradapter: execution of objects handle incoming requests
handlerinterceptor: interception of incoming requests comparable, not equal servlet filters (use optional , not controlled dispatcherservlet).
handlermapping: selecting objects handle incoming requests (handlers) based on attribute or condition internal or external requests
localeresolver: resolving , optionally saving of locale of individual user
multipartresolver: facilitate working file uploads wrapping incoming requests
view: responsible returning response client. requests may go straight view without going model part; others may go through three.
viewresolver: selecting view based on logical name view (use not strictly required)
each strategy interface above has important responsibility in overall framework. abstractions offered these interfaces powerful, allow set of variations in implementations, spring mvc ships implementations of these interfaces , offers feature set on top of servlet api. however, developers , vendors free write other implementations. spring mvc uses java java.util.map interface data-oriented abstraction model keys expected string values.
the ease of testing implementations of these interfaces seems 1 important advantage of high level of abstraction offered spring mvc. dispatcherservlet tightly coupled spring inversion of control container configuring web layers of applications. however, web applications can use other parts of spring framework—including container—and choose not use spring mvc.
remote access framework
spring s remote access framework abstraction working various rpc (remote procedure call)-based technologies available on java platform both client connectivity , marshalling objects on servers. important feature offered framework ease configuration , usage of these technologies as possible combining inversion of control , aop.
the framework provides fault-recovery (automatic reconnection after connection failure) , optimizations client-side use of ejb remote stateless session beans.
spring provides support these protocols , products out of box
http-based protocols
hessian: binary serialization protocol, open-sourced , maintained corba-based protocols
rmi (1): method invocations using rmi infrastructure yet specific spring
rmi (2): method invocations using rmi interfaces complying regular rmi usage
rmi-iiop (corba): method invocations using rmi-iiop/corba
enterprise javabean client integration
local ejb stateless session bean connectivity: connecting local stateless session beans
remote ejb stateless session bean connectivity: connecting remote stateless session beans
soap
integration apache axis web services framework
apache cxf provides integration spring framework rpc-style exporting of objects on server side.
both client , server setup rpc-style protocols , products supported spring remote access framework (except apache axis support) configured in spring core container.
there alternative open-source implementation (cluster4spring) of remoting subsystem included spring framework intended support various schemes of remoting (1-1, 1-many, dynamic services discovering)…
convention-over-configuration rapid application development
spring boot
spring boot spring s convention-over-configuration solution creating stand-alone, production-grade spring-based applications can run . preconfigured spring s opinionated view of best configuration , use of spring platform , third-party libraries can started minimum fuss. spring boot applications need little spring configuration. features:
create stand-alone spring applications
embed tomcat or jetty directly (no need deploy war files)
provide opinionated starter project object models (poms) simplify maven configuration
automatically configure spring whenever possible
provide production-ready features such metrics, health checks , externalized configuration
absolutely no code generation , no requirement xml configuration
spring roo
spring roo provides alternative, code-generation based approach @ using convention-over-configuration rapidly build applications in java. supports spring framework, spring security , spring web flow. roo differs other rapid application development frameworks focusing on:
extensibility (via add-ons)
java platform productivity (as opposed other languages)
lock-in avoidance (roo can removed within few minutes application)
runtime avoidance (with associated deployment advantages)
usability (particularly via shell features , usage patterns)
batch framework
spring batch framework batch processing provides reusable functions essential in processing large volumes of records, including:
logging/tracing
transaction management
job processing statistics
job restart
it provides more advanced technical services , features enable extremely high-volume , high performance batch jobs through optimizations , partitioning techniques. spring batch framework batch processing – execution of series of jobs. in spring batch, job consists of many steps , each step consists of read-process-write task or single operation task (tasklet).
the read-process-write process consists of these steps: read data resource (comma-separated values (csv), xml, or database), process it, write other resources (csv, xml, or database). example, step may read data csv file, process it, , write database. spring batch provides many classes read/write csv, xml, , database.
for single operation task (tasklet), means doing single task only, clean resources before or after step started or completed.
and steps can chained run job.
integration framework
spring integration framework enterprise application integration provides reusable functions essential messaging or event-driven architectures.
routers - routes message message channel based on conditions
transformers - converts/transforms/changes message payload , creates new message transformed payload
adapters - integrate other technologies , systems (http, amqp (advanced message queuing protocol), jms, xmpp (extensible messaging , presence protocol), smtp (simple mail transfer protocol), imap (internet message access protocol), ftp (file transfer protocol) ftps/sftp, file systems, etc.)
filters - filters message based on criteria. if criteria not met, message dropped
service activators - invoke operation on service object
management , auditing
spring integration supports pipe-and-filter based architectures.
Comments
Post a Comment