OSGi Learning One (using Apache Felix to build an OSGi development environment)

Source: Internet
Author: User
Brief introduction to OSGi           First we need to get to know what is Osgi,osgi also known as the Java Dynamic module, its biggest function is to help us implement Java modular application. OSGi is first a set of specifications, then a container, so we can easily compare it to Java EE technology, we know that Java EE architecture is divided into a container and multiple applications (that is, Web projects), Tomcat, JBoss These application servers are containers, Some of the JSP and servlet programs we write based on this standard only need to be deployed into the appropriate containers to run well; similar to the Java EE Architecture, OSGi is also composed of a container and multiple plug-ins (which are often called bundle), All we need to do is deploy these plug-ins to the container in a certain specification, and the entire OSGi program works well, and of course the biggest difference between Java EE and OSGi is that Java EE servers and Web applications are often separated from different Web applications with little dependency, While OSGi containers and plug-ins are commonly used together, plug-ins and plug-ins generally have dependencies, so Java EE Server and Web applications can be viewed as multiple projects, and OSGi can be viewed as multiple modules of the same project.           So why do we use OSGi technology? Or what are the advantages of OSGi? Simply put, the use of OSGi can make our large applications more stable, easier to maintain and modify. In the common development process, we often according to the module for the division of the task, but the function of each module and rely on we do not have a unified management standards, as the development of the project, the problem will continue to highlight, resulting in higher maintenance costs, and OSGi technology provides us with a more standard module maintenance format, An advantage of the OSGi framework is that it supports hot-swappable and version-substitution of Plug-ins, which facilitates the stability and upgrading of programs. Practice OSGi          apache Felix is an open source framework for OSGi technology, similar implementations include the OSGi framework Knoflerfish under the famous Eclipse, Equinox, We use Felix to build an OSGi environment here.       First download Apache Felix's binary release on the Apache web site, create a Java project under Eclipse, overwrite Felix decompression, and then add Felix.jar to the Lib directory to CIn Lasspath, Felix's startup portal is the main method in its Org.apache.felix.main.Main class, and we can call this method ourselves in the class to start the entire container.       Startup, the console will display:      hello world!!
______________
Welcome to Apache Felix Gogo

G!
Enter LB command, carriage return: START Level 1
id| State | level| Name
0|    Active | 0| System Bundle (4.0.1)
1|    Active | 1| Apache Felix Bundle Repository (1.6.6)
2|    Active | 1| Apache Felix Gogo Command (0.12.0)
3|    Active | 1| Apache Felix Gogo Runtime (0.10.0)
4|    Active | 1| Apache Felix Gogo Shell (0.10.0)
This interface shows that the OSGi framework is started, and that this table shows all the plug-ins and their status running under the OSGi framework.

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.