In the OSGi v4.2 specification, the unified standard of remote invocation is defined, which further deepens the modular idea. As one of these implementations, R-OSGI provides a Service-oriented remote invocation component that allows us to easily implement the invocation of two OSGi Service in different geographies. This paper introduces the implementation of traditional OSGi application and R-osgi, and expounds the implementation of R-OSGI for OSGi specification. Then through a simple function to tell the traditional OSGi and R-osgi on the two different implementations, so that you can deepen the impression of the actual operation. Finally, the current usage of R-OSGI and the http://www.aliyun.com/zixun/aggregation/11291.html of the whole distributed OSGi application are discussed. Hope to be able to do further discussion and research with the general readers.
OSGi Application Architecture
The traditional OSGi based application architecture is shown in the following illustration:
Figure 1. OSGi-based application architecture
While this architecture is widely used in large projects in many enterprises, when the Bundle of OSGi (modules in OSGi, unit components with independent operations to handle business logic) grow, the following problems are discovered:
The overall running of the program is slow and unstable, it is difficult to locate runtime error large program subject issue.
We're wondering if there's a framework that can split a stand-alone OSGi application into several, each distributed application providing its own Service in its own domain, which can theoretically solve the problem if it finds a suitable segmentation method.
And R-osgi is a framework that has already implemented such a function, let's take a look at the next R-osgi.
Implementing distributed OSGi applications using R-OSGI
R-osgi is a set of distributed communication components that are suitable for any OSGi architecture. It is released in the form of a jar, easy to deploy and convenient to use.
As a general rule, users only need to complete the following steps.
On the server side:
The reference to R-osgi in Menifest file in the Bundle of the Bundle Service that initiates r-osgi within the OSGi container will expose the Client-invoked interface to the R-osgi module.
On the client side:
In the OSGi container, the Bundle Client that initiates R-osgi in the Bundle menifest file, import references to R-osgi obtain the R-OSGI exposed Service invocation interface.
R-OSGI Running Process
The following figure briefly describes the process and principle of R-OSGI implementation:
Figure 2. R-OSGI implementation Process
The remote Service is registered with the OGSi container through the R-OSGI framework. R-osgi open a port on the OS (default 9278) to create the Socket listener. Client-side Bundle calls the default port of the specified Server when it starts, requesting Socket traffic. Generates a proxy Bundle in this OSGi container for local Client invocation. Sign the same Service on the client side. The client invokes the service, actually calling the remote service via proxy Bundle, waiting for the communication to return.