没有合适的资源?快使用搜索试试~ 我知道了~
首页OSGi in Practice 完整版
Neil Bartlett 2008年9月出炉的最新OSGi in Practice 的完整版,目录如下: Introduction First Steps in OSGi Bundle Dependencies Introduction to Services Concurrency in OSGi Example: Mailbox Reader GUI The Whiteboard Pattern Declarative Services The Extender Model Integrating Third-party Libraries Building Web Applications
资源详情
资源评论
资源推荐
DRAFT
OSGi In Practice
Neil Bartlett
September 22, 2008
DRAFT
DRAFT
Contents
Preface xiii
1 Introduction 1
1.1 What is a Module? . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 The Problem(s) with JARs . . . . . . . . . . . . . . . . . . . . 3
1.2.1 Class Loading and the Global Classpath . . . . . . . . . 4
1.2.2 Conflicting Classes . . . . . . . . . . . . . . . . . . . . . 6
1.2.3 Lack of Explicit Depe ndencies . . . . . . . . . . . . . . . 7
1.2.4 Lack of Version Information . . . . . . . . . . . . . . . . 8
1.2.5 Lack of Information Hiding Across JARs . . . . . . . . . 10
1.2.6 Recap: JARs Are Not Modules . . . . . . . . . . . . . . 10
1.3 J2EE Class Loading . . . . . . . . . . . . . . . . . . . . . . . . 11
1.4 OSGi: A Simple Idea . . . . . . . . . . . . . . . . . . . . . . . . 13
1.4.1 From Trees to Graphs . . . . . . . . . . . . . . . . . . . 14
1.4.2 Information Hiding in OSGi Bundles . . . . . . . . . . . 16
1.4.3 Versioning and Side-by-Side Versions . . . . . . . . . . . 17
1.5 Dynamic Modules . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.6 The OSGi Alliance and Standards . . . . . . . . . . . . . . . . 18
1.7 OSGi Implementations . . . . . . . . . . . . . . . . . . . . . . . 19
1.8 Alternatives to OSGi . . . . . . . . . . . . . . . . . . . . . . . . 19
1.8.1 Build Tools: Maven and Ivy . . . . . . . . . . . . . . . . 20
1.8.2 Eclipse Plug-in System . . . . . . . . . . . . . . . . . . . 20
1.8.3 JSR 277 . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2 First Steps in OSGi 23
2.1 Bundle Construction . . . . . . . . . . . . . . . . . . . . . . . . 23
2.2 OSGi Development Tools . . . . . . . . . . . . . . . . . . . . . 24
2.2.1 Eclipse Plug-in Development Environment . . . . . . . . 24
2.2.2 Bnd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.3 Installing a Framework . . . . . . . . . . . . . . . . . . . . . . . 26
2.4 Setting up Eclipse . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.5 Running Felix . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.6 Installing bnd . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.7 Hello, World! . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.8 Bundle Lifecycle . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.9 Incremental Development . . . . . . . . . . . . . . . . . . . . . 37
2.10 Interacting with the Framework . . . . . . . . . . . . . . . . . . 38
DRAFT
iv Contents
2.11 Starting and Stopping Threads . . . . . . . . . . . . . . . . . . 41
2.12 Ma nipulating Bundles . . . . . . . . . . . . . . . . . . . . . . . 41
2.13 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3 Bundle Dependencies 45
3.1 Introducing the Example Application . . . . . . . . . . . . . . . 46
3.2 Defining an API . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.3 Exporting the API . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.4 Importing the AP I . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.5 Interlude: How B nd Work s . . . . . . . . . . . . . . . . . . . . 55
3.6 Requiring a Bundle . . . . . . . . . . . . . . . . . . . . . . . . . 57
3.7 Version Numbers and Ranges . . . . . . . . . . . . . . . . . . . 59
3.7.1 Version Numbers . . . . . . . . . . . . . . . . . . . . . . 60
3.7.2 Versioning Bundles . . . . . . . . . . . . . . . . . . . . . 61
3.7.3 Versioning Pack ages . . . . . . . . . . . . . . . . . . . . 61
3.7.4 Version Ranges . . . . . . . . . . . . . . . . . . . . . . . 62
3.7.5 Versioning Import-Package and Require-Bundle . . . 63
3.8 Class Loading in OSGi . . . . . . . . . . . . . . . . . . . . . . . 64
3.9 JRE Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
3.10 Execution Environments . . . . . . . . . . . . . . . . . . . . . . 68
3.11 Fragment Bundles . . . . . . . . . . . . . . . . . . . . . . . . . 70
3.12 Class Space Consistency and “Uses” Constraints . . . . . . . . 71
4 Introduction to Services 73
4.1 Late Binding in Java . . . . . . . . . . . . . . . . . . . . . . . . 73
4.1.1 Dependency Injection Frameworks . . . . . . . . . . . . 74
4.1.2 Dynamic Services . . . . . . . . . . . . . . . . . . . . . . 75
4.2 Registering a Service . . . . . . . . . . . . . . . . . . . . . . . . 77
4.3 Unregistering a Service . . . . . . . . . . . . . . . . . . . . . . . 79
4.4 Looking up a Service . . . . . . . . . . . . . . . . . . . . . . . . 82
4.5 Service Properties . . . . . . . . . . . . . . . . . . . . . . . . . 84
4.6 Introduction to Service Trackers . . . . . . . . . . . . . . . . . 86
4.7 Listening to Services . . . . . . . . . . . . . . . . . . . . . . . . 88
4.8 Tracking Services . . . . . . . . . . . . . . . . . . . . . . . . . . 90
4.9 Filtering on Properties . . . . . . . . . . . . . . . . . . . . . . . 93
4.10 Cardinality and Selection Rules . . . . . . . . . . . . . . . . . . 94
4.10.1 Optional, Unary . . . . . . . . . . . . . . . . . . . . . . 96
4.10.2 Optional, Multiple . . . . . . . . . . . . . . . . . . . . . 99
4.10.3 Mandatory, Unary . . . . . . . . . . . . . . . . . . . . . 99
4.10.4 Mandatory, Multiple . . . . . . . . . . . . . . . . . . . . 99
5 Examp le: Mailbox Reader GUI 101
5.1 The Ma ilbox Table Model and Panel . . . . . . . . . . . . . . . 101
5.2 The Ma ilbox Tracker . . . . . . . . . . . . . . . . . . . . . . . . 101
5.3 The Ma in Window . . . . . . . . . . . . . . . . . . . . . . . . . 104
DRAFT
Contents v
5.4 The Bundle Activator . . . . . . . . . . . . . . . . . . . . . . . 107
5.5 Putting it Together . . . . . . . . . . . . . . . . . . . . . . . . . 109
6 Concurrency and OSGi 113
6.1 The Price of Freedom . . . . . . . . . . . . . . . . . . . . . . . 113
6.2 Shared Mutable State . . . . . . . . . . . . . . . . . . . . . . . 115
6.3 Safe Publication . . . . . . . . . . . . . . . . . . . . . . . . . . 117
6.3.1 Safe Publication in Services . . . . . . . . . . . . . . . . 119
6.3.2 Safe Publication in Framework Callbacks . . . . . . . . 122
6.4 Don’t Hold Locks when Calling Foreign Code . . . . . . . . . . 124
6.5 GUI Development . . . . . . . . . . . . . . . . . . . . . . . . . 127
6.6 Using Executors . . . . . . . . . . . . . . . . . . . . . . . . . . 129
6.7 Interrupting Threads . . . . . . . . . . . . . . . . . . . . . . . . 136
6.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
7 The Whiteboard Pattern and Event Admin 141
7.1 The Classic Observer Pattern . . . . . . . . . . . . . . . . . . . 141
7.2 Problems with the Observer Pattern . . . . . . . . . . . . . . . 142
7.3 Fixing the Observer Pattern . . . . . . . . . . . . . . . . . . . . 143
7.4 Using the Whitebo ard Pattern . . . . . . . . . . . . . . . . . . 144
7.4.1 Registering the Listener . . . . . . . . . . . . . . . . . . 147
7.4.2 Sending Events . . . . . . . . . . . . . . . . . . . . . . . 149
7.5 Event Admin . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
7.5.1 Sending Events . . . . . . . . . . . . . . . . . . . . . . . 152
7.5.2 The Event O bject . . . . . . . . . . . . . . . . . . . . . 153
7.5.3 Receiving Events . . . . . . . . . . . . . . . . . . . . . . 156
7.5.4 Running the Example . . . . . . . . . . . . . . . . . . . 157
7.5.5 Synchronous versus Asynchronous Delivery . . . . . . . 159
7.5.6 Ordered Delivery . . . . . . . . . . . . . . . . . . . . . . 160
7.5.7 Reliable Delivery . . . . . . . . . . . . . . . . . . . . . . 160
7.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
8 The Extender Model 163
8.1 Looking for Bundle Entries . . . . . . . . . . . . . . . . . . . . 164
8.2 Inspe c ting Headers . . . . . . . . . . . . . . . . . . . . . . . . . 166
8.3 Tracking Bundles . . . . . . . . . . . . . . . . . . . . . . . . . . 167
8.4 Synchronous and Asynchronous Bundle Listeners . . . . . . . . 174
8.5 The Eclipse Extension Registry . . . . . . . . . . . . . . . . . . 179
8.6 Impersonating a Bundle . . . . . . . . . . . . . . . . . . . . . . 181
8.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
9 Configuration and Metadata 187
10 Declarative Services 189
11 Testing OSGi Bundles 191
剩余216页未读,继续阅读
evanz
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- 27页智慧街道信息化建设综合解决方案.pptx
- 计算机二级Ms-Office选择题汇总.doc
- 单链表的插入和删除实验报告 (2).docx
- 单链表的插入和删除实验报告.pdf
- 物联网智能终端项目设备管理方案.pdf
- 如何打造品牌的模式.doc
- 样式控制与页面布局.pdf
- 武汉理工Java实验报告(二).docx
- 2021线上新品消费趋势报告.pdf
- 第3章 Matlab中的矩阵及其运算.docx
- 基于Web的人力资源管理系统的必要性和可行性.doc
- 基于一阶倒立摆的matlab仿真实验.doc
- 速运公司物流管理模式研究教材
- 大数据与管理.pptx
- 单片机课程设计之步进电机.doc
- 大数据与数据挖掘.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论2