Flexibility Through Modularity: Alibaba’s JarsLink Modular Development Framework

Now open sourced! Find more about it here.

Image for post
Image for post

What are development frameworks?

Development frameworks have become an essential part of software and web application development, that include building and deployment standards. They are usually reusable and can be universally applied across applications. Nevertheless, usage has often proved troublesome and has been a drain on resources.

Common limitations of development frameworks

The requirements of development frameworks are often divided into either too many or too few applications, which can cause problems. Too many applications mean that many applications are published each time, resulting in high maintenance costs. Too few applications cause difficulty in the offline withdrawal of useless functions, leading to high division costs.

Designing a new development framework

To overcome the above constraints, the Alibaba tech team looked into how development frameworks could be designed differently. They reasoned that the following features and functions could be incorporated to improve isolation and accessibility and make the framework more dynamic:

A modular development approach

A modular development method can bring a number of advantages over a traditional application development method. The two methods are compared in the figure below.

Image for post
Image for post
Comparison of the application and modular development methods for development frameworks

JarsLink: Alibaba’s modular development framework

Alibaba’s JarsLink framework is based on a modular development method and the outline of which is illustrated below.

Image for post
Image for post
Outline of the JarsLink development framework

JarsLink features and functions

Module loading

JarsLink creates a new URLClassLoader for each module for loading JAR. It also supports breaking through the parental delegation mechanism setting that the overridePackages are loaded by subclass loaders and not taking priority to use packages that have been loaded by the parent class loader.

Module unloading

Unloading a module can only occur when certain conditions are met. Specifically, the instance object, classes, and class loaders cannot be referenced in the module. Therefore, the instances, classes, and class loaders need to be unloaded. The sequence of unloading the entire module is shown below.

Image for post
Image for post
JarsLink module unloading sequence

Isolation between modules

To prevent modules influencing each other, a key attribute of modular development is module isolation. There are three levels of isolation between modules:

Image for post
Image for post
Module isolation in the JarsLink framework

Communications between modules

The main methods to facilitate communications between modules include:

Image for post
Image for post
Module communication in the JarsLink Framework

Class loading mechanism

The OSGi class loading mechanism uses a mesh structure. Each module uses Export-Package to declare which classes it will give to others and uses Import-Package to declare which classes it wants to use. JarsLink adopts flat management. Each module has a common parent class. The parent class loader is used to load the ModuleLoader class. If it is a SOFA application, the parent loader of the module is KernelAceClassLoader.

Image for post
Image for post

JarsLink application scenarios

One of the major possible applications of JarsLink is in data management centers. These systems usually collect data from various system structures, with such interfaces as RPC, HTTP, etc., and various sources that need docking and developing. Frequent modification and publishing of the code is required due to a poor quality of data.

JarsLink applied in real-world scenarios

Currently the Microfinance Division of Alibaba’s Ant Financial uses the JarsLink framework on several of its systems, including dozens of modules. Results of this application are still being collected and analyzed and will be reported on in the not too distant future.

Open Source

Alibaba has made JarsLink open source. Find more about it here.

Alibaba Tech

First hand and in-depth information about Alibaba’s latest technology → Search “Alibaba Tech” on Facebook

First-hand & in-depth information about Alibaba's tech innovation in Artificial Intelligence, Big Data & Computer Engineering. Follow us on Facebook!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store