没有合适的资源?快使用搜索试试~ 我知道了~
首页Spring框架源码深度解析:依赖注入与模块化详解
Spring框架源码深度解析:依赖注入与模块化详解
需积分: 10 1 下载量 75 浏览量
更新于2024-07-24
收藏 4.55MB PDF 举报
Spring框架源码解析PDF文档,版本为3.2.3.RELEASE,由多位知名开发者共同编撰,包括Rod Johnson、Juergen Hoeller等人。Spring Framework是一个强大的开源应用框架,其核心理念是依赖注入(Dependency Injection, DI)和控制反转(Inversion of Control, IoC)。该文档详细介绍了Spring框架的主要模块:
1. **概述**:
- Spring Framework 提供了一个全面的集成解决方案,支持服务管理、数据访问/集成、Web开发以及面向切面编程(AOP)和性能监控。
- 框架的核心容器(Core Container)负责创建和管理对象实例,实现IoC和DI原则。
2. **模块详解**:
- **Core Container**:负责构建和管理应用中的对象关系,包括BeanFactory和ApplicationContext,它们是Spring应用上下文的基础。
- **Data Access/Integration**:提供数据访问抽象层(如JdbcTemplate、Hibernate等),支持多种数据库,以及与遗留系统或外部系统的集成。
- **Web**:Spring MVC是其Web开发的核心组件,提供轻量级的MVC架构,简化了HTTP请求处理和视图渲染。
- **AOP and Instrumentation**:支持面向切面编程,用于执行跨越方法的横切关注点,如日志记录、事务管理等,并通过AspectJ实现。
- **Test**:Spring提供了测试工具,如Spring Test,使得单元测试和集成测试更加方便。
3. **应用场景**:
- 提供了依赖管理(Dependency Management)和命名约定,帮助开发人员更有效地组织和管理项目中的依赖关系。
4. **版权声明**:
- 该文档允许用户复制传播,但必须保持原版权信息,并且免费分发,不得收费。
这份Spring框架源码解析文档对于理解Spring框架的工作原理、模块功能以及如何在实际项目中使用Spring至关重要,无论是初学者还是进阶开发者,都能从中受益匪浅。通过深入研究这些源码,开发者可以更好地掌握Spring框架的内部实现机制,提高代码质量和可维护性。
Spring Framework
3.2.3.RELEASE
Spring Framework
Reference Documentation xvi
'Plain-old' JSPs versus JSTL ........................................................................... 511
Additional tags facilitating development ............................................................ 511
Using Spring's form tag library ........................................................................ 511
Configuration .......................................................................................... 511
The form tag ......................................................................................... 511
The input tag ....................................................................................... 513
The checkbox tag ................................................................................. 513
The checkboxes tag ............................................................................. 516
The radiobutton tag ........................................................................... 516
The radiobuttons tag ......................................................................... 517
The password tag ................................................................................. 517
The select tag ..................................................................................... 517
The option tag ..................................................................................... 518
The options tag ................................................................................... 518
The textarea tag ................................................................................. 519
The hidden tag ..................................................................................... 519
The errors tag ..................................................................................... 519
HTTP Method Conversion ....................................................................... 522
HTML5 Tags .......................................................................................... 523
18.3. Tiles .............................................................................................................. 523
Dependencies ................................................................................................ 523
How to integrate Tiles ..................................................................................... 523
UrlBasedViewResolver .................................................................... 524
ResourceBundleViewResolver ........................................................ 524
SimpleSpringPreparerFactory and
SpringBeanPreparerFactory ............................................................ 524
18.4. Velocity & FreeMarker .................................................................................... 525
Dependencies ................................................................................................ 525
Context configuration ...................................................................................... 525
Creating templates ......................................................................................... 526
Advanced configuration ................................................................................... 527
velocity.properties ................................................................................... 527
FreeMarker ............................................................................................. 527
Bind support and form handling ....................................................................... 528
The bind macros .................................................................................... 528
Simple binding ........................................................................................ 528
Form input generation macros ................................................................. 529
HTML escaping and XHTML compliance ................................................. 533
18.5. XSLT ............................................................................................................. 534
My First Words ............................................................................................... 534
Bean definitions ...................................................................................... 534
Standard MVC controller code ................................................................. 534
Convert the model data to XML ............................................................... 535
Defining the view properties .................................................................... 535
Document transformation ........................................................................ 536
Summary ....................................................................................................... 536
18.6. Document views (PDF/Excel) .......................................................................... 537
Introduction .................................................................................................... 537
Configuration and setup .................................................................................. 537
Document view definitions ....................................................................... 537
Spring Framework
3.2.3.RELEASE
Spring Framework
Reference Documentation xvii
Controller code ....................................................................................... 537
Subclassing for Excel views .................................................................... 537
Subclassing for PDF views ..................................................................... 539
18.7. JasperReports ............................................................................................... 540
Dependencies ................................................................................................ 540
Configuration .................................................................................................. 540
Configuring the ViewResolver .............................................................. 540
Configuring the Views ............................................................................ 540
About Report Files .................................................................................. 541
Using JasperReportsMultiFormatView ............................................. 541
Populating the ModelAndView ....................................................................... 542
Working with Sub-Reports ............................................................................... 543
Configuring Sub-Report Files .................................................................. 543
Configuring Sub-Report Data Sources ..................................................... 544
Configuring Exporter Parameters ..................................................................... 544
18.8. Feed Views ................................................................................................... 544
18.9. XML Marshalling View .................................................................................... 545
18.10. JSON Mapping View .................................................................................... 546
19. Integrating with other web frameworks ....................................................................... 547
19.1. Introduction .................................................................................................... 547
19.2. Common configuration ................................................................................... 548
19.3. JavaServer Faces 1.1 and 1.2 ........................................................................ 549
DelegatingVariableResolver (JSF 1.1/1.2) ........................................................ 549
SpringBeanVariableResolver (JSF 1.1/1.2) ....................................................... 550
SpringBeanFacesELResolver (JSF 1.2+) ......................................................... 550
FacesContextUtils ........................................................................................... 550
19.4. Apache Struts 1.x and 2.x .............................................................................. 551
ContextLoaderPlugin ....................................................................................... 551
DelegatingRequestProcessor ................................................................... 552
DelegatingActionProxy ............................................................................ 552
ActionSupport Classes .................................................................................... 553
19.5. WebWork 2.x ................................................................................................. 553
19.6. Tapestry 3.x and 4.x ...................................................................................... 554
Injecting Spring-managed beans ..................................................................... 555
Dependency Injecting Spring Beans into Tapestry pages ........................... 557
Component definition files ....................................................................... 558
Adding abstract accessors ...................................................................... 559
Dependency Injecting Spring Beans into Tapestry pages - Tapestry 4.x
style ....................................................................................................... 561
19.7. Further Resources ......................................................................................... 562
20. Portlet MVC Framework ............................................................................................ 563
20.1. Introduction .................................................................................................... 563
Controllers - The C in MVC ............................................................................ 564
Views - The V in MVC .................................................................................... 564
Web-scoped beans ......................................................................................... 564
20.2. The DispatcherPortlet ............................................................................ 564
20.3. The ViewRendererServlet ........................................................................ 566
20.4. Controllers ..................................................................................................... 567
AbstractController and PortletContentGenerator ............................. 568
Other simple controllers .................................................................................. 569
Spring Framework
3.2.3.RELEASE
Spring Framework
Reference Documentation xviii
Command Controllers ..................................................................................... 569
PortletWrappingController .................................................................... 570
20.5. Handler mappings .......................................................................................... 570
PortletModeHandlerMapping .................................................................... 571
ParameterHandlerMapping ........................................................................ 571
PortletModeParameterHandlerMapping .................................................. 572
Adding HandlerInterceptors ..................................................................... 572
HandlerInterceptorAdapter .................................................................... 573
ParameterMappingInterceptor ................................................................ 573
20.6. Views and resolving them .............................................................................. 573
20.7. Multipart (file upload) support ......................................................................... 574
Using the PortletMultipartResolver ....................................................... 574
Handling a file upload in a form ...................................................................... 575
20.8. Handling exceptions ....................................................................................... 578
20.9. Annotation-based controller configuration ........................................................ 578
Setting up the dispatcher for annotation support ............................................... 578
Defining a controller with @Controller .......................................................... 579
Mapping requests with @RequestMapping ..................................................... 580
Supported handler method arguments ............................................................. 581
Binding request parameters to method parameters with @RequestParam .......... 583
Providing a link to data from the model with @ModelAttribute ....................... 583
Specifying attributes to store in a Session with @SessionAttributes ............. 584
Customizing WebDataBinder initialization ...................................................... 584
Customizing data binding with @InitBinder .......................................... 584
Configuring a custom WebBindingInitializer ................................... 585
20.10. Portlet application deployment ...................................................................... 585
VI. Integration ......................................................................................................................... 586
21. Remoting and web services using Spring ................................................................... 587
21.1. Introduction .................................................................................................... 587
21.2. Exposing services using RMI .......................................................................... 588
Exporting the service using the RmiServiceExporter ................................... 588
Linking in the service at the client ................................................................... 589
21.3. Using Hessian or Burlap to remotely call services via HTTP .............................. 589
Wiring up the DispatcherServlet for Hessian and co. ................................. 589
Exposing your beans by using the HessianServiceExporter ....................... 590
Linking in the service on the client .................................................................. 591
Using Burlap .................................................................................................. 591
Applying HTTP basic authentication to a service exposed through Hessian or
Burlap ............................................................................................................ 591
21.4. Exposing services using HTTP invokers .......................................................... 592
Exposing the service object ............................................................................ 592
Linking in the service at the client ................................................................... 593
21.5. Web services ................................................................................................. 593
Exposing servlet-based web services using JAX-RPC ....................................... 594
Accessing web services using JAX-RPC .......................................................... 595
Registering JAX-RPC Bean Mappings ............................................................. 597
Registering your own JAX-RPC Handler .......................................................... 597
Exposing servlet-based web services using JAX-WS ........................................ 598
Exporting standalone web services using JAX-WS ........................................... 599
Exporting web services using the JAX-WS RI's Spring support .......................... 600
Spring Framework
3.2.3.RELEASE
Spring Framework
Reference Documentation xix
Accessing web services using JAX-WS ........................................................... 600
21.6. JMS .............................................................................................................. 601
Server-side configuration ................................................................................. 602
Client-side configuration .................................................................................. 603
21.7. Auto-detection is not implemented for remote interfaces ................................... 604
21.8. Considerations when choosing a technology .................................................... 604
21.9. Accessing RESTful services on the Client ....................................................... 605
RestTemplate ................................................................................................. 605
Working with the URI .............................................................................. 607
Dealing with request and response headers ............................................. 608
HTTP Message Conversion ............................................................................ 608
StringHttpMessageConverter ................................................................... 609
FormHttpMessageConverter .................................................................... 609
ByteArrayHttpMessageConverter ............................................................. 609
MarshallingHttpMessageConverter ........................................................... 609
MappingJackson2HttpMessageConverter (or
MappingJacksonHttpMessageConverter with Jackson 1.x) ........................ 610
SourceHttpMessageConverter ................................................................. 610
BufferedImageHttpMessageConverter ...................................................... 610
22. Enterprise JavaBeans (EJB) integration ..................................................................... 611
22.1. Introduction .................................................................................................... 611
22.2. Accessing EJBs ............................................................................................. 611
Concepts ........................................................................................................ 611
Accessing local SLSBs ................................................................................... 611
Accessing remote SLSBs ................................................................................ 613
Accessing EJB 2.x SLSBs versus EJB 3 SLSBs ............................................... 613
22.3. Using Spring's EJB implementation support classes ......................................... 614
EJB 2.x base classes ..................................................................................... 614
EJB 3 injection interceptor .............................................................................. 616
23. JMS (Java Message Service) .................................................................................... 618
23.1. Introduction .................................................................................................... 618
23.2. Using Spring JMS .......................................................................................... 618
JmsTemplate ................................................................................................ 618
Connections ................................................................................................... 619
Caching Messaging Resources ............................................................... 619
SingleConnectionFactory ......................................................................... 619
CachingConnectionFactory ...................................................................... 620
Destination Management ................................................................................. 620
Message Listener Containers .......................................................................... 621
SimpleMessageListenerContainer ............................................................ 621
DefaultMessageListenerContainer ............................................................ 621
Transaction management ................................................................................ 621
23.3. Sending a Message ....................................................................................... 622
Using Message Converters ............................................................................. 623
SessionCallback and ProducerCallback ................................................ 624
23.4. Receiving a message ..................................................................................... 624
Synchronous Reception .................................................................................. 624
Asynchronous Reception - Message-Driven POJOs .......................................... 624
The SessionAwareMessageListener interface ........................................... 625
The MessageListenerAdapter ................................................................... 626
Spring Framework
3.2.3.RELEASE
Spring Framework
Reference Documentation xx
Processing messages within transactions ........................................................ 627
23.5. Support for JCA Message Endpoints ............................................................... 628
23.6. JMS Namespace Support ............................................................................... 630
24. JMX ......................................................................................................................... 634
24.1. Introduction .................................................................................................... 634
24.2. Exporting your beans to JMX .......................................................................... 634
Creating an MBeanServer ............................................................................. 636
Reusing an existing MBeanServer ................................................................. 636
Lazy-initialized MBeans ................................................................................... 637
Automatic registration of MBeans .................................................................... 637
Controlling the registration behavior ................................................................. 638
24.3. Controlling the management interface of your beans ........................................ 639
The MBeanInfoAssembler Interface ............................................................. 639
Using Source-Level Metadata (JDK 5.0 annotations) ........................................ 639
Source-Level Metadata Types ......................................................................... 641
The AutodetectCapableMBeanInfoAssembler interface ............................ 643
Defining management interfaces using Java interfaces ..................................... 643
Using MethodNameBasedMBeanInfoAssembler ........................................... 645
24.4. Controlling the ObjectNames for your beans .................................................. 645
Reading ObjectNames from Properties ...................................................... 645
Using the MetadataNamingStrategy ........................................................... 646
Configuring annotation based MBean export .................................................... 647
24.5. JSR-160 Connectors ...................................................................................... 648
Server-side Connectors ................................................................................... 648
Client-side Connectors .................................................................................... 649
JMX over Burlap/Hessian/SOAP ...................................................................... 649
24.6. Accessing MBeans via Proxies ....................................................................... 649
24.7. Notifications ................................................................................................... 650
Registering Listeners for Notifications .............................................................. 650
Publishing Notifications ................................................................................... 654
24.8. Further Resources ......................................................................................... 656
25. JCA CCI .................................................................................................................. 657
25.1. Introduction .................................................................................................... 657
25.2. Configuring CCI ............................................................................................. 657
Connector configuration .................................................................................. 657
ConnectionFactory configuration in Spring ................................................. 658
Configuring CCI connections ........................................................................... 658
Using a single CCI connection ........................................................................ 659
25.3. Using Spring's CCI access support ................................................................. 660
Record conversion .......................................................................................... 660
The CciTemplate ......................................................................................... 661
DAO support .................................................................................................. 662
Automatic output record generation ................................................................. 662
Summary ....................................................................................................... 663
Using a CCI Connection and Interaction directly ...................................... 664
Example for CciTemplate usage ................................................................... 665
25.4. Modeling CCI access as operation objects ...................................................... 667
MappingRecordOperation .......................................................................... 667
MappingCommAreaOperation ...................................................................... 667
Automatic output record generation ................................................................. 668
剩余846页未读,继续阅读
2020-01-12 上传
2009-11-18 上传
2010-05-30 上传
2008-07-08 上传
2008-05-23 上传
2014-12-30 上传
2021-03-23 上传
2017-08-14 上传
xiaolong199111
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- MATLAB新功能:Multi-frame ViewRGB制作彩色图阴影
- XKCD Substitutions 3-crx插件:创新的网页文字替换工具
- Python实现8位等离子效果开源项目plasma.py解读
- 维护商店移动应用:基于PhoneGap的移动API应用
- Laravel-Admin的Redis Manager扩展使用教程
- Jekyll代理主题使用指南及文件结构解析
- cPanel中PHP多版本插件的安装与配置指南
- 深入探讨React和Typescript在Alias kopio游戏中的应用
- node.js OSC服务器实现:Gibber消息转换技术解析
- 体验最新升级版的mdbootstrap pro 6.1.0组件库
- 超市盘点过机系统实现与delphi应用
- Boogle: 探索 Python 编程的 Boggle 仿制品
- C++实现的Physics2D简易2D物理模拟
- 傅里叶级数在分数阶微分积分计算中的应用与实现
- Windows Phone与PhoneGap应用隔离存储文件访问方法
- iso8601-interval-recurrence:掌握ISO8601日期范围与重复间隔检查
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功