没有合适的资源?快使用搜索试试~ 我知道了~
首页Osgi in action.pdf
Welcome to the OSGi™ Service Platform. The OSGi Service Platform is an industry standard defined by the OSGi Alliance to specifically address the lack of support for modularity in the Java platform. Additionally, it also introduces a new service-oriented programming model, referred to by some as “SOA in a VM.”
资源详情
资源评论
资源推荐
Table of Contents
1. OSGi Revealed
2. Mastering Modularity
3. Learning Lifecycle
4. Studying Services
5. Delving Deeper into Modularity
6. Moving Toward Bundles
7. Managing Bundles and Applications
8. Testing Applications
9. Debugging Applications
10. Component Models
11. Launching and Embedding an OSGi
Framework
12. Security
13. Web Applications and Services
©Manning Publications Co. Please post comments or corrections to the Author Online forum:
http://www.manning-sandbox.com/forum.jspa?forumID=507
1
OSGi Revealed
The Java™ platform is an unqualified success story. It is used to develop applications for
small mobile devices to massive enterprise endeavors. This is a testament to its well thought
out design and continued evolution. However, this success has come in spite of the fact that
Java does not have explicit support for building modular systems beyond ordinary object-
oriented data encapsulation.
So, what does this mean to you? If Java is a success despite its lack of advanced
modularization support, then you might wonder if its absence is a problem. Most well
managed projects have to build up a repertoire of comparable, but project specific,
techniques to compensate for the lack of modularization in Java. These include:
Programming practices,
Tricks with multiple class loaders, and
Serialization between in-process components.
However these techniques are inherently brittle and error prone since they are not
enforceable via any specific compile-time or run-time checks. The end result has detrimental
impacts on multiple stages of an application's lifecycle:
Development – you are unable to clearly and explicitly partition development into
independent pieces.
Deployment – you are unable to easily analyze, understand, and resolve requirements
imposed by the collection of independently developed pieces that make up the
system.
Execution – you are unable to manage and evolve the constituent pieces of a running
system, nor minimize the impact of doing so.
It is definitely possible to manage these issues in Java, and lots of projects do so using
the custom techniques mentioned above, but it is much more difficult than it should be.
We're tying ourselves in knots to work around the lack of a fundamental feature. If Java had
explicit support for modularity, then you would be freed from such issues and could
©Manning Publications Co. Please post comments or corrections to the Author Online forum:
http://www.manning-sandbox.com/forum.jspa?forumID=507
concentrate on what you really want to do, which is developing the functionality of your
application.
Welcome to the OSGi™ Service Platform. The OSGi Service Platform is an industry
standard defined by the OSGi Alliance to specifically address the lack of support for
modularity in the Java platform. Additionally, it also introduces a new service-oriented
programming model, referred to by some as “SOA in a VM.” This chapter will give you an
overview of the OSGi Service Platform and the issues it is intended to address. Once we have
finished this chapter we will have enough background knowledge to start digging into the
details in chapter 2.
1.1 The what and why of OSGi
The sixty-four-thousand dollar question is, “What is OSGi?” The simplest answer to this
question is it is a modularity layer for the Java platform. Of course, the next question that
might spring to mind is, “What do you mean by modularity?” Here we use modularity more
or less in the traditional computer science sense, where the code of your software application
is divided into logical parts representing separate concerns as in Figure 1.1.1. If your
software is modular, then you can simplify development and improve maintainability by
enforcing the logical module boundaries; we will discuss more modularity details in Chapter
2.
The notion of modularity is not new. The concept actually became fashionable back in the
1970s. So, why is OSGi all the rage right now? To better understand what OSGi can do for
you, it is worthwhile to understand what Java is not doing for you with respect to modularity.
Once you understand that, then you can see how OSGi can help.
1.1.1 Java's modularity limitations
Java was never intended to support modular programming, so we admit that criticizing its
inability to do so is a little unfair. Java has been promoted as a platform for building all sorts
©Manning Publications Co. Please post comments or corrections to the Author Online forum:
http://www.manning-sandbox.com/forum.jspa?forumID=507
Figure 1.1.1 Modularity refers to the logical
decomposition of a large system into smaller
collaborating pieces
Module
A
Module
B
Module
C
uses
uses
uses
uses
of applications for all sorts of domains ranging from mobile phone to enterprise applications.
Most of these endeavors require, or could at least benefit from, modularity, so Java's lack of
explicit support does cause some amount of pain for developers. From this point of view, we
do feel the following criticisms are valid.
LOW-LEVEL CODE VISIBILITY CONTROL
While Java provides a fair complement of access modifiers to control visibility (e.g., public,
protected, private, and package private), these tend to address low-level object-
oriented encapsulation and do not really address logical system partitioning. Java has the
notion of a package, which is typically used for partitioning code. For code to be visible from
one Java package to another, the code must be declared public (or protected if using
inheritance). Sometimes the logical structure of your application calls for specific code to
belong in different packages, but then this means any dependencies among the packages
must be exposed as public, which makes it accessible to everyone else too. Often this can
expose implementation details, which makes future evolution more difficult since users may
end up with dependencies on your non-public API.
To illustrate this, let's consider a trivial hello world application that provides a public
interface in one package, a private implementation in another and a main class in yet
another.
Listing 1.1.1 Trivial example of the limitations of Java's object-orientated encapsulation
package org.foo.hello;
public interface Greeting { #1
void sayHello();
}
package org.foo.hello.impl;
import org.foo.hello.Greeting;
public class GreetingImpl implements Greeting {
final String m_name;
public GreetingImpl(String name) { #2
m_name = name;
}
public void sayHello() {
System.out.println("Hello, " + m_name + "!");
}
}
package org.foo.hello.main;
import org.foo.hello.Greeting;
import org.foo.hello.impl.GreetingImpl;
©Manning Publications Co. Please post comments or corrections to the Author Online forum:
http://www.manning-sandbox.com/forum.jspa?forumID=507
剩余507页未读,继续阅读
Meta-Soft
- 粉丝: 0
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- 2023年中国辣条食品行业创新及消费需求洞察报告.pptx
- 2023年半导体行业20强品牌.pptx
- 2023年全球电力行业评论.pptx
- 2023年全球网络安全现状-劳动力资源和网络运营的全球发展新态势.pptx
- 毕业设计-基于单片机的液体密度检测系统设计.doc
- 家用清扫机器人设计.doc
- 基于VB+数据库SQL的教师信息管理系统设计与实现 计算机专业设计范文模板参考资料.pdf
- 官塘驿林场林防火(资源监管)“空天地人”四位一体监测系统方案.doc
- 基于专利语义表征的技术预见方法及其应用.docx
- 浅谈电子商务的现状及发展趋势学习总结.doc
- 基于单片机的智能仓库温湿度控制系统 (2).pdf
- 基于SSM框架知识产权管理系统 (2).pdf
- 9年终工作总结新年计划PPT模板.pptx
- Hytera海能达CH04L01 说明书.pdf
- 数据中心运维操作标准及流程.pdf
- 报告模板 -成本分析与报告培训之三.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论3