没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
Spring Dynamic Modules Reference Guide
1.2.0
Adrian M Colyer (SpringSource), Hal Hildebrand (Oracle), Costin Leau (SpringSource), Andy
Piper (BEA)
Copyright © 2006-2009
Copies of this document may be made for your own use and for distribution to others, provided that you do not
charge any fee for such copies and further provided that each copy contains this Copyright Notice, whether
distributed in print or electronically.
Preface .............................................................................................................................................v
I. Introduction ..................................................................................................................................1
1. Why Spring Dynamic Modules? ............................................................................................2
2. Requirements ........................................................................................................................3
3. Getting Started ......................................................................................................................4
3.1. First Steps .................................................................................................................. 4
3.1.1. Knowing Spring ..............................................................................................4
3.1.2. Knowing OSGi ................................................................................................4
3.1.3. Trying Out The Samples .................................................................................. 4
3.2. Need Help? ................................................................................................................5
3.2.1. Community Support ........................................................................................5
3.2.2. Professional Support ........................................................................................5
3.3. Following Development .............................................................................................5
4. What is new? ........................................................................................................................6
4.1. 1.2.x .......................................................................................................................... 6
4.1.1. Java 2 Security Integration ...............................................................................6
4.1.2. Compendium Services Support ......................................................................... 6
4.1.3. Changed Spring DM Symbolic Names ..............................................................6
4.1.4. Usage of SpringSource Enterprise Bundle Repository (EBR) .............................6
4.2. 1.1.x .......................................................................................................................... 6
4.2.1. Web Support ...................................................................................................6
4.2.2. Classpath Resource Abstraction ........................................................................ 7
4.2.3. Pluggable Extender Configuration ....................................................................7
4.2.4. Improved Class Loading ..................................................................................7
II. Reference Documentation .............................................................................................................8
5. Bundles and Application Contexts ..........................................................................................9
5.1. The Spring Dynamic Modules Extender bundle ............................................................9
5.2. Application Context Creation ......................................................................................9
5.2.1. Mandatory Service Dependencies ................................................................... 10
5.2.2. Application Context Service Publication ......................................................... 11
5.3. Bundle Lifecycle ...................................................................................................... 11
5.4. The Resource Abstraction ......................................................................................... 12
5.5. Accessing the BundleContext .................................................................................... 13
5.6. Application Context Destruction ............................................................................... 14
5.7. Stopping the Extender Bundle ................................................................................... 14
6. Packaging and Deploying Spring-based OSGi applications .................................................... 16
6.1. Bundle Format And Manifest Headers ....................................................................... 17
6.2. Extender Configuration Options ................................................................................ 19
6.2.1. Listening To Extender Events ......................................................................... 22
6.3. Required Spring Framework And Spring Dynamic Modules Bundles .......................... 22
6.4. Spring XML Authoring Support ................................................................................ 23
6.5. Importing and Exporting Packages ............................................................................ 24
6.6. Considerations When Using External Libraries .......................................................... 24
6.7. Diagnosing Problems ............................................................................................... 25
7. The Service Registry ........................................................................................................... 26
7.1. Exporting A Spring Bean As An OSGi Service .......................................................... 27
7.1.1. Controlling The Set Of Advertised Service Interfaces For An Exported Service . 27
7.1.2. Controlling The Set Of Advertised Properties For An Exported Service ............ 29
7.1.3. The depends-on Attribute ............................................................................... 29
7.1.4. The context-class-loader Attribute .................................................................. 29
7.1.5. The ranking Attribute .................................................................................... 30
7.1.6. service Element Attributes ........................................................................... 30
Spring Dynamic Modules(1.2.0) ii
7.1.7. Service Registration And Unregistration Lifecycle .......................................... 31
7.2. Defining References To OSGi Services ..................................................................... 33
7.2.1. Referencing An Individual Service ................................................................. 33
7.2.2. Referencing A Collection Of Services ............................................................. 37
7.2.3. Dealing With The Dynamics Of OSGi Imported Services ................................ 43
7.2.4. Listener And Service Proxies ......................................................................... 44
7.2.5. Accessing The Caller BundleContext ............................................................. 45
7.3. Exporter/Importer Listener Best Practices .................................................................. 45
7.3.1. Listener And Cyclic Dependencies ................................................................. 46
7.4. Service Importer Global Defaults .............................................................................. 47
7.5. Relationship Between The Service Exporter And Service Importer .............................. 48
8. Working With Bundles ........................................................................................................ 50
9. Web Support ...................................................................................................................... 52
9.1. Supported Web Containers ....................................................................................... 52
9.2. Web Support Usage .................................................................................................. 52
9.3. WAR Classpath In OSGi .......................................................................................... 53
9.3.1. Static Resources ............................................................................................ 53
9.3.2. Servlets ......................................................................................................... 53
9.3.3. Java Server Pages .......................................................................................... 54
9.4. Configuring The Web Extender ................................................................................. 55
9.4.1. Changing The War Deployer .......................................................................... 56
9.5. Customizing The Standard Deployers ........................................................................ 56
9.6. OSGi-ready Libraries And Web Development ............................................................ 57
9.6.1. Deploying Web Containers As OSGi Bundles ................................................. 57
9.6.2. Common Libraries ......................................................................................... 58
9.7. Spring-MVC Integration ........................................................................................... 58
10. Compendium Services ....................................................................................................... 60
10.1. Configuration Admin .............................................................................................. 60
10.1.1. Exposing Configuration Admin Entries As Properties ................................. 60
10.1.2. Managed Properties ..................................................................................... 62
10.1.3. Managed Service Factories ........................................................................... 64
10.1.4. Direct Access To Configuration Data ............................................................ 67
11. Testing OSGi based Applications ....................................................................................... 68
11.1. OSGi Mocks .......................................................................................................... 68
11.2. Integration Testing ................................................................................................. 69
11.2.1. Creating A Simple OSGi Integration Test ...................................................... 69
11.2.2. Installing Test Prerequisites .......................................................................... 70
11.2.3. Advanced Testing Framework Topics ........................................................... 71
11.2.4. Creating An OSGi Application Context ......................................................... 74
11.2.5. Specifying The OSGi Platform To Use ......................................................... 74
11.2.6. Waiting For The Test Dependencies ............................................................. 74
11.2.7. Testing Framework Performance .................................................................. 74
III. Other Resources ........................................................................................................................ 76
12. Useful Links ..................................................................................................................... 77
IV. Appendixes .............................................................................................................................. 78
A. Extensions ......................................................................................................................... 79
A.1. Annotation-Based Injection ...................................................................................... 79
A.1.1. Enabling/Disabling Annotation Processing ..................................................... 79
B. Security Integration ............................................................................................................ 81
C. Eclipse Plug-in Development integration ............................................................................. 82
D. Spring Dynamic Modules Maven Archetype ........................................................................ 86
D.1. Generated Project Features At-A-Glance ................................................................... 86
Spring Dynamic Modules Reference Guide
Spring Dynamic Modules(1.2.0) iii
E. Useful OSGi tips ................................................................................................................ 88
E.1. OSGi Fragments ...................................................................................................... 88
F. Roadmap ............................................................................................................................ 90
F.1. Access to Service References for Collections ............................................................. 90
F.2. Start Level Integration .............................................................................................. 90
F.3. Web Library Integration ........................................................................................... 90
F.4. ORM/Persistence Support ......................................................................................... 90
F.5. OSGi Standards ....................................................................................................... 90
G. Spring DM OSGi Repository .............................................................................................. 91
G.1. Spring DM Temporary OSGi Repository .................................................................. 91
G.1.1. Repository Conventions ................................................................................ 91
G.1.2. Browsing The Repository Content ................................................................. 91
G.1.3. Using The Repository With Maven ................................................................ 91
G.1.4. Using The Repository With Ant/Ivy ............................................................... 92
H. Spring Dynamic Modules Schema ....................................................................................... 93
I. Acknowledgments ............................................................................................................. 104
Spring Dynamic Modules Reference Guide
Spring Dynamic Modules(1.2.0) iv
Preface
Application development has seen significant changes in the last years, moving towards a simpler, more agile,
POJO-based programming model in order to keep a fast pace. Dependency injection and Aspect Oriented
Programming, which were once bleeding edge ideas, are used on a daily basis by most developers to manage
and simplify the complexity of their applications.
However, in terms of deployment, things have remained mainly unchanged. Even though code bases are
divided into modules, whether logical, conceptual or physical, at runtime they are seen as one monolithic
application in which, making a change (be it large or small), requires a restart. OSGi aims to change this by
allowing applications to be divided into modules that can have different life cycles, dependencies and still exist
as a whole.
Spring Dynamic Modules focuses on integrating Spring Framework powerful, non-invasive programming
model and concepts with the dynamics and modularity of OSGi platform. It allows transparent exporting and
importing of OSGi services, life cycle management and control.
While every effort has been made to ensure that this documentation is comprehensive and there are no errors,
nevertheless some topics might require more explanation and some typos might have crept in. If you do spot
any mistakes or even more serious errors and you can spare a few cycles during lunch, please do bring the error
to the attention of the Spring Dynamic Modules team by raising an issue. Thank you.
Spring Dynamic Modules(1.2.0) v
剩余108页未读,继续阅读
资源评论
lsh_0731
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功