OSGi Learning Summary

Source: Internet
Author: User

A recent study, which learned about OSGi Technology, felt that OSGi was somewhat difficult to learn. But finally mastered and popularized will be a more practical technology for system development. Here and everyone to share their own sentiment.

1. What is OSGI

OSGi , an "open service Gateway", is a Dynamic modular specification initiated by the OSGi Consortium with a Java -based technology platform. The basic implementation now is:apache Felix,Eclipse 's Equinox wait

2 . Advantages of using OSGI

OSGI can be seen as a tool and methodology for system architecture. Enables system development and designers to develop and design systems in a modular mindset.

In the previous Java -based system development process can not effectively constrain the program ape in accordance with a certain level and dependency on the class or interface between the call, resulting in the whole system is more and more difficult to understand and maintain, the system development to the later stage will appear when maintenance, reaching situation appears. the OSGi Framework, or OSGi container, can control dependencies between modules in the form of import and export packages, which is more binding on dependencies between modules. It is also more convenient to manage dependencies.

     For example in your jar There is a in the package. com.ynet.service.userservice interface. This interface has a corresponding com.ynet.service.impl.userserviceimpl implementation class, in traditional development, you cannot prevent others from userservice down into the de facto class, and then calls those methods that are not defined in the interface. These methods were originally not intended to be exposed to the outside.

Now developed based on the OSGI framework. to include an OSGI Metadata definition file in this Jar package , you just have to com.ynet.service This package Export out. The external module has the ability to invoke classes or interfaces in this package. Because you did not export the com.ynet.service.impl . External will not be able to refer to the Userserviceimpl class.

The most important thing for developers and designers is how to decouple the appropriate classes into a single module and how to expose the appropriate package .

The OSGI specification now includes many commonly used sub-specifications such as user Management Service specification, log service specification,Http Service specification, and so on. We can speed up the development process by using specifications developed by others to implement it. Avoid "repeatedly making wheels". Even if we choose ourselves to implement these specifications, because of the normative guidance. It is also possible to develop a service implementation that is well-functioning, easy to use, and extensible.

In addition,OSGI provides the ability to dynamically deploy and maintain systems. This is useful for systems that are very restrictive in terms of downtime. You can add or disable a feature and update a module in a non-stop state.

3. OSGI approximate execution mechanism

The OSGI container's control of dependencies between modules is achieved by isolating the Java class loader. Different modules have different class-loader. If There is a class User in module A that relies on the class Addressin module B , the module when A is loaded into the Address class, the class loader for module B is completed.

4. OSGI support for enterprise-level development

The OSGI Enterprise-level specification defines JDBC,JPA,JMX,JTA , and various java EE Technologies, such as JNDI, and some enterprise-class technologies that are not Java EE standards, now have many OSGI Enterprise-class service implementation framework such as Apache Aries.

The actual use of OSGI is far more than the above mentioned. Deeper and more complex issues, such as the use of declarative services to decouple from the OSGI framework, need to be studied and addressed in depth . Integration of non- OSGi Jar packages in OSGi.

I am now also in the theoretical debugging of the learning phase, some code examples, the above content if there are errors. Hope to remind and learn together.

Copyright notice: This article blog original article. Blogs, without consent, may not be reproduced.

OSGi Learning Summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.