`
q445862108
  • 浏览: 82931 次
  • 性别: Icon_minigender_1
  • 来自: 湖南
社区版块
存档分类
最新评论

强大的OSGI开发工具BndTools和命令

阅读更多

bndTools为我们提供了一种使用Eclipse开发OSGi bundles的方式。

它没有通过直接编辑Manifest.MF的方式定义依赖关系,

而是使用Bnd文件基于Bnd工具驱动工具链(toolchain)

。它还提供了介绍性的教程。

此外,BndTools还具有自动化语义版本控制功能(automated semantic versioning),它会将已构建的组件和之前发布的组件相比较,让算法来决定是否对大、中、小三种版本号进行升级,而不是让用户人为决定。

 

命令:

felix:bundlelevel

felix:cd

felix:frameworklevel

felix:headers

felix:help

felix:inspect

felix:install

felix:lb

felix:log

felix:ls

felix:refresh

felix:resolve

felix:start

felix:stop

felix:uninstall

felix:update

felix:which

gogo:cat

gogo:each

gogo:echo

gogo:format

gogo:getopt

gogo:gosh

gogo:grep

gogo:not

gogo:set

gogo:sh

gogo:source

gogo:tac

gogo:telnetd

gogo:type

gogo:until

obr:deploy

obr:info

obr:javadoc

obr:list

obr:repos

obr:source

scr:config

scr:disable

scr:enable

scr:info

scr:list

牛人的谈话

Neil Bartlett, preeminent OSGi expert and current maintainer of the popular Bndtools Eclipse plugin for OSGi has announced the release of Bndtools 2.0. Some of the features he has highlighted are:

Support for OSGi Release 5 Resolver and Repository specifications

Export run descriptors as standalone executables

Baselining (build errors for incorrectly versioned bundles)

Enhanced Semantic Versioning, using annotations for Consumer and Provider roles

Exported Package Decorations

Improved Incremental Builder

Support for Apache ACE

Lots of bug fixes and performance improvements.

This is a long awaited release. The previous release 1.1 became available in March 2012.

InfoQ spoke to Neil Bartlett about Bndtools and about OSGi in general.

Can you please explain a bit about OSGi and Bndtools to the non-OSGi audience?

OSGi is a way of developing modular applications on the JVM. It allows you to build modules (which we call "bundles") that are cleanly isolated from each other, and with explicit, managed dependencies. Because of our focus on dependencies, we can always tell whether a particular bundle can be installed into our environment, whether additional dependencies will need to be added as well, what effect it will have on other modules, and so on.

Bndtools is an IDE for developing OSGi bundles and applications. It is based on Eclipse, and can be installed from the Eclipse Marketplace.

Is OSGi important to Java projects of all sizes and kinds, or is it more appropriate to larger or smaller projects?

OSGi means modularity, which is beneficial to almost all sizes of projects. It should be clear enough why large projects benefit from modularity: it helps to isolate complexity and divide the work into manageable chunks. But even small projects benefit, for example if you write a small piece of code it's likely that you will want to reuse it later in another project. If you develop that as an OSGi bundle then it will be much easier to reuse.

Having said that, some very small projects don't really need modularity; for example "Hello World" doesn't benefit much from a modular approach!

OSGi seems to have some loyal followers, but it does not seem to have huge traction. What is the reason for that?

Well, the traction is increasing fast, but I agree it's not mainstream yet. OSGi is actually very ambitious because it aims to improve the entire software development process, therefore it has an impact on everything from code repositories through testing to team structures. So it takes time for the benefits to be realized, and many businesses are understandably nervous about taking on a known up-front cost in return for uncertain future gains. However this is changing as more businesses become successful with it.

Another problem is technical, in that OSGi has had quite poor tool support for a long time. Bndtools – and the ecosystem of tools that can integrate with it – have started to improve that situation.

There is a lot of focus on Android right now, is OSGi relevant for Android development?

Yes, I think that as Android applications get bigger and more complicated, they are going to need to look at modularity seriously as well. OSGi has been used successfully in some Android projects, however Android is sufficiently different from standard Java – in subtle but important ways – that this is still a bit of an experimental area right now.

How does Bndtools help in OSGi projects?

OSGi has a reputation for being difficult to use, however it really just needs certain information about our code to be stated explicitly. Nearly all of this information is available inside the Java classes that we put into the bundle... it just needs to be teased out. Bndtools does this as part of the build process, which allows developers just to concentrate on their own code and not repeat anything they have already written into the source.

Bndtools also hooks into the Eclipse build system, which means that as soon as you save a change in a source file, your bundle will be immediately built and ready. Then if you happen to have an OSGi runtime going already (e.g. in debugging or testing) then we push the new bundle straight into it, by taking advantage of OSGi's ability to dynamically update modules at runtime. This leads to an extremely fast code/run/test workflow, since basically your code is already running as soon as you save it.

Finally in Bndtools 2.0 we added support for the new Resolver and Repositories specifications from OSGi Release 5. This lets you compose applications by focusing on the small number of "top-level" modules that provide your core functionality – the resolver takes care of providing all of the static and runtime dependencies from that core. So you no longer have to manage long lists of JARs that need to go on your classpath.

Does Bndtools provide any collaboration tools?

Yes. One of the major difficulties in collaborating with other developers is maintaining compatibility of shared APIs, and how to coordinate when those APIs need to change. The key to getting this right is a proper versioning strategy, but most developers apply versions to their artifacts in a manual and fairly arbitrary way. Bndtools has the ability to analyze your classes and work out the changes that were made compared with the previously released version. Then it can automatically bump the version for you. Also for consumers of an API it works out what range of versions your code is going to be compatible with, and automatically generates an import of that range.

Are there any competitors?

Probably the closest competitor is PDE, the Plug-in Development Environment, which is also an Eclipse-based IDE but takes a very different approach. Naturally I believe that Bndtools is much better and more productive; in fact I'm confident of this because I used PDE for many years before Bndtools existed.

Is Eclipse required, or does it standalone? Do you support other IDEs such as IntelliJ and Netbeans?

Yes and no. Bndtools is built on top of bnd, developed by Peter Kriens. Bnd is a headless tool that can be used from the command line, or from ANT, or from Maven, and so on. Therefore developers using NetBeans, IDEA or even a plain text editor can still work with the projects because they are just using bnd.

Bndtools does require Eclipse and it isn't directly usable in other IDEs. However those IDEs could build their own support for OSGi by using bnd themselves. Most of the smarts are in bnd, and Bndtools only provides things like pretty editors for the bnd descriptor files, a launcher, hooks into the Eclipse build lifecycle, and so on.

I hope that other IDEs spend some effort on this, because really I just want people to use OSGi. I have no interest in forcing them to use Eclipse if that is not their preference.

As well as the Bndtools Tutorial Bartlett recommends the books "Java Application Architecture" by Kirk Knoernschild (previously covered on InfoQ) and "Enterprise OSGi in Action" by Tim Ward and Holly Cummins, which discusses tooling options for OSGi including bnd and Bndtools, as good sources for further information.

 

InfoQ has also run a series of articles discussing modularity in general: Modular Java: What is it?, Modular Java: Static Modularity, Modular Java: Dynamic Modularity, Modular Java: Declarative Modularity.

 

分享到:
评论

相关推荐

    OSGI Felix BndTools例子(一步一步指导)

    标题 "OSGI Felix BndTools例子(一步一步指导)" 指向的是一个关于使用OSGI框架,特别是Felix实现,并配合BndTools工具进行模块化开发的教程。在这个教程中,作者逐步指导如何构建和管理OSGI服务。下面将详细阐述OSGI...

    BndTools工具

    **BndTools详解** ...总的来说,BndTools是OSGi开发的强大工具,它简化了OSGi项目的构建和管理,提升了开发效率。通过深入理解和熟练使用BndTools,开发者可以更好地驾驭OSGi的魅力,实现模块化的高效开发。

    Equinox开发OSGi应用程序

    2. **作为独立的Java应用程序部署**:如果需要将OSGi应用程序作为一个独立的Java应用程序部署,可以使用特定的工具(如Bndtools)来打包应用程序,使其能够脱离Eclipse环境独立运行。 通过遵循上述指南,您可以顺利...

    bndtools插件

    总的来说,bndtools是OSGi开发者不可或缺的工具,它简化了OSGi应用的开发流程,提高了开发效率,同时也为理解和掌握OSGi技术提供了便利。随着OSGi技术的不断发展,bndtools的持续更新和优化将继续为开发者带来更好的...

    BndTools安装及使用教程

    ### BndTools安装及使用教程 ...通过以上步骤,我们不仅了解了如何使用BndTools进行组件开发,还掌握了如何构建和部署OSGi框架下的项目。这对于希望利用OSGi框架的强大特性的开发者来说是非常有用的。

    osgi 构建模块化云应用之中文版

    OSGi技术为构建模块化云应用提供了一种强大而灵活的解决方案,但是它的复杂性要求开发者必须深入了解其规范和工具。本书为读者提供了一本实用的指南,涵盖了从OSGi基础到云应用构建的全面知识,帮助开发者掌握构建、...

    IntelliJ IDEA OSGI helloworld

    IntelliJ IDEA作为一款强大的Java集成开发环境,支持对OSGi应用的开发。下面我们将详细探讨如何在IntelliJ IDEA中创建和运行一个简单的OSGi HelloWorld程序。 **1. OSGi基础知识** OSGi的核心概念包括: - **...

    osgi felix plug in

    - **开发和调试OSGi应用通常需要使用特定的工具,如Eclipse PDE OSGi工具,Bndtools等,它们可以帮助构建、部署和调试bundle**。 - **对于Felix Plugin的开发,可能还需要了解如Maven或Gradle的构建工具,以及如何...

    很久之前的osgi整理

    描述中的“NULL”意味着没有具体的描述内容提供,但我们可以从标签“源码”和“工具”中推测,这篇整理可能包含了OSGi框架的源代码解析和如何将其作为开发工具来使用的实践指导。 标签“源码”提示我们,文章可能...

    两个osgi的例子程序

    标题中的“两个OSGi的例子程序”表明我们将探讨的是与OSGi(Open Service Gateway Initiative)...通过研究源码和工具,我们可以深入理解OSGi如何实现模块化,以及如何利用这一技术来构建更灵活、更可维护的Java应用。

    OSGI

    而工具的使用则可以加速这一过程,例如使用Equinox或Felix作为OSGI容器,使用Bnd或Bndtools进行bundle的构建和管理。 总的来说,OSGI是一种强大的技术,尤其适合大型企业级应用或需要高度模块化和动态性的场景。...

    OSGI in action.pdf

    8. **工具支持**:介绍有助于OSGI开发的工具和框架,如Bndtools、Eclipse IDE对OSGI的支持,以及如何使用它们提高开发效率。 9. **与其他技术的集成**:OSGI如何与Spring、Hibernate等流行框架协同工作,实现模块化...

    osgi&spring规范

    **源码和工具** 标签中的“源码”可能是指分析或理解OSGi和Spring如何在底层实现其功能,这通常需要对Java和相关框架的源代码有一定了解。开发者可能会通过阅读源码来优化自己的模块设计或解决特定问题。 “工具”...

    osgi资料

    - 开发工具:介绍支持OSGi的IDE(如Eclipse)和构建工具(如Bndtools),以及如何配置和使用它们。 - 应用场景:探讨OSGi在企业级应用、嵌入式系统、物联网等领域的应用案例。 - 框架集成:讲解如何将OSGi与...

    OSGI.rar_OSGI eclipse_eclipse osgi_java OSGI_osgi

    8. **打包与打包工具**:如BNDTools,用于创建和管理OSGI Bundle的工具。 9. **例子**:压缩包中提到的“osgi编程的例子”,可能包含一个或多个示例项目,演示了如何从零开始创建和运行OSGI应用,以及如何在Eclipse...

    浅析OSGI的bundle依赖

    例如,BndTools是一个流行的OSGI开发工具,它可以帮助创建、构建和管理bundle及其依赖。通过这样的工具,开发者可以更方便地管理MANIFEST.MF文件,进行版本控制,并确保bundle间的兼容性。 总的来说,理解OSGI的...

    bnd, bnd,用于OSGi的瑞士军刀 构建OSGi包的工具.zip

    bnd, bnd,用于OSGi的瑞士军刀 构建OSGi包的工具 自述文件bnd是针对OSGi的军刀,它基于分析类代码,验证设置,验证你的设置,并对项目的依赖关系进行验证,并提供了相应的日期和时间。关于bnd的信息可以在 ...

    Intellij 13下OSGi的Maven例子

    IntelliJ IDEA 13是JetBrains公司推出的一款强大的Java集成开发环境,它以其智能代码助手、高效的项目管理和丰富的插件系统而广受开发者喜爱。OSGi(Open Service Gateway Initiative)则是一种模块化运行时环境,它...

    bndtools2.1 插件 离线安装包

    bndtools2.1 离线插件安装包,网上其他地方找不到的,识货的下载吧。 安装步骤同Eclipse其他插件安装一样。下载下来解压,然后新建link文件链接到你解压的目录,然后把Link文件放到eclipse根目录下面的links文件夹...

Global site tag (gtag.js) - Google Analytics