java大型项目 模块化,如何模块化(大型)Java App?

I have a rather large (several MLOC) application at hand that I'd like to split up into more maintainable separate parts. Currently the product is comprised of about 40 Eclipse projects, many of them having inter-dependencies. This alone makes a continuous build system unfeasible, because it would have to rebuild very much with each checkin.

Is there a "best practice" way of how to

identify parts that can immediately be separated

document inter-dependencies visually

untangle the existing code

handle "patches" we need to apply to libraries (currently handled by putting them in the classpath before the actual library)

If there are (free/open) tools to support this, I'd appreciate pointers.

Even though I do not have any experience with Maven it seems like it forces a very modular design. I wonder now whether this is something that can be retrofitted iteratively or if a project that was to use it would have to be layouted with modularity in mind right from the start.

Edit 2009-07-10

We are in the process of splitting out some core modules using Apache Ant/Ivy. Really helpful and well designed tool, not imposing as much on you as maven does.

I wrote down some more general details and personal opinion about why we are doing that on my blog - too long to post here and maybe not interesting to everyone, so follow at your own discretion: www.danielschneller.com

解决方案

Using OSGi could be a good fit for you. It would allow to create modules out of the application. You can also organize dependencies in a better way. If you define your interfaces between the different modules correctly, then you can use continuous integration as you only have to rebuild the module that you affected on check-in.

The mechanisms provided by OSGi will help you untangle the existing code. Because of the way the classloading works, it also helps you handle the patches in an easier way.

The framework is conceptually divided into the following areas:

Bundles - Bundles are normal jar components with extra manifest headers.

Services - The services layer connects bundles in a dynamic way by offering a publish-find-bind model for plain old Java objects(POJO).

Services Registry - The API for management services (ServiceRegistration, ServiceTracker and ServiceReference).

Life-Cycle - The API for life cycle management (install, start, stop, update, and uninstall bundles).

Modules - The layer that defines encapsulation and declaration of dependencies (how a bundle can import and export code).

Security - The layer that handles the security aspects by limiting bundle functionality to pre-defined capabilities.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值