问题描述
我在 osgi 上看到了很多演讲,我认为实施更好的模块化听起来很有希望.显然," HotDeployment"和"在并行运行X的不同版本"也是市长的卖点.
我想知道OSGI是否承诺要解决的问题甚至是一个问题...?它使我想起了OO的早期,当时有类似的索赔:
当Oo 是新的时,大的论点是可重复使用.人们普遍认为,当使用OO时,只需要"写一次",然后就可以"在任何地方使用".
在实践中,我只看到此功能用于一些相当低的示例.我认为这样做的原因是编写可重复使用的代码很难.从技术上讲不是从界面设计的角度来看.您必须预测未来的客户将如何使用您的课程并提前做出正确的选择.根据定义,这很困难,因此潜在的可重复使用益处通常无法实现.
使用OSGI ,我怀疑我们可以再次兑现诺言,这是我们没有真正遇到的问题的潜在解决方案.或者,如果我们拥有它们,我们就不会有足够的数量和严重性,这将证明是合理地购买OSGI寻求帮助的.例如," hotdeployment"一个模块的子集绝对是一个好主意,但是 真正起作用?经常不是因为事实证明您对特定问题的模块化错误?多个模块之间共享的模型实体怎么样?这些模块是否必须同时更改?或者,您是否将对象弄平到原语,并仅使用模块间通信中的对象,以便能够保留接口合同?
最困难的问题在应用OSGI时,我想,以获取模块化"正确" .类似于与OO中正确的类界面,与OSGI中的界面相同,这次,该问题在更大的规模上,包装级甚至服务级别都保持不变.
您可能已经猜到了,我目前正在尝试评估OSGI用于项目.我们遇到的主要问题是随着代码库的增长而增加复杂性,我想将系统分解为具有较小和更明确的交互的较小模块.
- 没有任何框架可以帮助决定 要模块化,奥斯基曾经为您偿还吗?
- 在团队中工作时,这是否使您的生活更加轻松?
- 它有助于减少错误计数吗?
- 您是否曾经成功地" hotdeploy"主要组件?
- OSGI是否有助于随着时间的推移降低复杂性?
- Osgi是否兑现了诺言?
- 它是否满足您的期望?
谢谢!
推荐答案
OSGI有钱,因为它在运行时强制实施模块化,因此您以前没有的东西通常会导致纸张上的设计和实施中的设计分开.这可能是开发过程中的大胜利.
,如果您让团队专注于单个模块(可能是一组捆绑包),并且如果您正确的模块化,则无疑使其更容易在团队中工作.有人可能会说,一个人可以使用ANT+IVY或MAVEN和依赖项等构建工具做同样的事情,我认为Osgi使用的依赖关系的粒度要优越得多,不会导致典型的"在所有事物中拖动所有东西,再加上厨房水槽"" jar级依赖性原因.
依赖性较少的模块化代码往往会导致更清洁和更少的代码,进而导致更少的错误,更易于测试和解决.它还促进了尽可能简单明了的设计组件,同时可以选择插入更复杂的实现,或者添加诸如单独组件之类的方面.
.热部署即使您在运行时不使用它,也是一个很好的测试,可以验证如果您正确模块化了应用程序.如果您根本无法按随机顺序启动捆绑包,则应调查原因.另外,如果您可以更新任意捆绑包,它可以使您的开发周期更快.
只要您可以管理模块和依赖项,大项目就可以保持可管理并且很容易发展(可以从可说的不好的"完全重写"中拯救您).
OSGI的缺点?这是一个非常低级的框架,尽管它解决了旨在很好的问题,但您仍然需要解决自己的问题.尤其是如果您来自Java EE环境,您可以在其中获得免费线程安全以及其他一些概念,如果您需要它们,则需要在OSGI中提出解决方案.
一个常见的陷阱是不要在OSGI之上使用抽象来使普通开发人员更容易.永远不要让他们手动与服务人员或服务器混乱.仔细考虑捆绑包是什么,不允许这样做:您是否愿意让开发人员使用BundleContext,还是使用某种形式的声明模型将所有这些隐藏.
其他推荐答案
我已经与OSGI合作了几年(尽管在Eclipse项目的背景下,而不是在Web项目中).显然,该框架并不能使您无法思考如何模块化.但是它使您能够定义规则.
如果您使用软件包并定义(在设计文档中?口头?),某些软件包可能无法在其他软件包中访问类,而无需执行此约束,则将破坏.如果您雇用新开发人员,他们将不知道规则.他们将违反规则.使用OSGI,您可以在代码中定义规则.对我们来说,这是一个巨大的胜利,因为它帮助我们维护了系统的体系结构.
OSGI不会降低复杂性.但这绝对有助于处理它.
其他推荐答案
我已经使用OSGI已有8年以上了,每次我参加一个非OSGI项目时,我都会感到过度速度而没有安全带. OSGI使项目设置和部署更加努力,并强迫您预先考虑模块化,但是让您轻松地在运行时执行规则. 以Maven Apache骆驼为例.当您创建一个新的Maven项目并添加Apache Camel作为依赖关系时,应用程序似乎具有所有依赖关系,您只会在运行时注意到ClassNotFoundExceptions,这很不好.当您在OSGI容器中运行并加载Apache骆驼模块时,未启动具有未满足依赖的模块,并且您知道问题是什么.
我还一直使用热门部门,并随时更新我的应用程序的部分而无需重新启动.
问题描述
I saw lots of presentations on OSGi and i think it sounds promising for enforcing better modularization. Apparently "hotdeployment" and "running different versions of x in parallel" are mayor selling points too.
I wonder whether what OSGi promises to solve is even an issue...? It reminded me of the early days of OO when similar claims were maid:
When OO was new, the big argument was reusability. It was widely claimed that when using OO, one would only have to "write once" and could then "use everywhere".
In practice I only saw this working for some pretty low level examples. I think the reason for this is that writing reusable code is hard. Not technically but from a interface design point of view. You have to anticipate how future clients will want to use your classes and take the right choices up front. This is difficult by definition and thus the potential reusability benefit often failed to deliver.
With OSGi, I have the suspicion that here again we could fall for promises, potential solutions for problems that we don't really have. Or if we have them, we don't have them in a big enough quantity and severity that would justify to buy into OSGi for help. "Hotdeployment" for example of a subset of modules is definitely a great idea, but how often does it really work? How often not because it turned out you got the modularization wrong for the particular issue? How about model entities that are shared between multiple modules? Do these modules all have to be changed at the same time? Or do you flatten your objects to primitives and use only those in inter-module communication, in order to be able to keep interface contracts?
The hardest problem when applying OSGi is, I would presume, to get the modularization "right". Similar to getting the interfaces of your classes right in OO, with OSGi, the problem stays the same, on a bigger scale this time, the package or even service level.
As you might have guessed, I'm currently trying to evaluate OSGi for use in a project. The major problem we have, is increasing complexity as the codebase grows and I would like to break the system up in smaller modules that have less and more defined interactions.
- Given no framework can ever help deciding what to modularize, has OSGi ever payed off for you?
- Has it made your life easier when working in teams?
- Has it helped to reduce bug count?
- Do you ever successfully "hotdeploy" major components?
- Does OSGi help to reduce complexity over time?
- Did OSGi keep its promises?
- Did it fulfill your expectations?
Thanks!
推荐答案
OSGi pays off because it enforces modularization at runtime, something you previously did not have, often causing the design on paper and implementation to drift apart. This can be a big win during development.
It definitely helps make it easier to work in teams, if you let teams focus on a single module (possibly a set of bundles), and if you get your modularization right. One could argue that one can do the same thing with a build tool like Ant+Ivy or Maven and dependencies, the granularity of dependencies that OSGi uses is in my opinion far superior, not causing the typical "dragging in everything plus the kitchen sink" that JAR level dependencies cause.
Modular code with less dependencies tends to lead to cleaner and less code, in turn leading to less bugs that are easier to test for and solve. It also promotes designing components as simple and straightforward as possible, whilst at the same time having the option to plug in more complicated implementations, or adding aspects such as caching as separate components.
Hot deployment, even if you do not use it at runtime, is a very good test to validate if you modularized your application correctly. If you cannot start your bundles in a random order at all, you should investigate why. Also, it can make your development cycle a lot quicker if you can update an arbitrary bundle.
As long as you can manage your modules and dependencies, big projects stay manageable and can be easily evolved (saving you from the arguably bad "complete rewrite").
The downside of OSGi? It's a very low-level framework, and whilst it solves the problems it is intended for quite well, there are things that you still need to resolve yourself. Especially if you come from a Java EE environment, where you get free thread-safety and some other concepts that can be quite useful if you need them, you need to come up with solutions for these in OSGi yourself.
A common pitfall is to not use abstractions on top of OSGi to make this easier for the average developer. Never ever let them mess with ServiceListeners or ServiceTrackers manually. Carefully consider what bundles are and are not allowed to do: Are you willing to give developers access to the BundleContext or do you hide all of this from them by using some form of declarative model.
其他推荐答案
I've worked with OSGi for some years now (although in the context of an eclipse project, not in a web project). It is clear that the framework does not free you from thinking how to modularize. But it enables you to define the rules.
If you use packages and defines (In a design document? Verbal?) that certain packages may not access classes in other packages, without an enforcement of this constraint, it will be broken. If you hire new developers they don't know the rules. They WILL break the rules. With OSGi you can define the rules in code. For us this was a big win, as it has helped us to maintain the architecture of our system.
OSGi does not reduce complexity. But it definitely helps to handle it.
其他推荐答案
I am using OSGI for over 8 years now, and every time I dive in a non-OSGI project I get the feeling over overspeeding without a seatbelt on. OSGI makes project setup and deployment harder, and forces you to think about modularization upfront, but gives you the easy of mind of enforcing the rules at runtime. Take maven apache camel as an example. When you create a new maven project and add apache camel as a dependency, the applications seems to have all its dependencies, and you will only notice the ClassNotFoundExceptions at runtime, which is bad. When you run in an OSGI container and load the apache camel modules, the modules with unmet dependencies are not started, and you know upfront what the problem is.
I also use the hot-deployment all the time, and update parts of my application on the fly without the need for a restart.