Developing Web applications using Felix and Struts2

Source: Internet
Author: User
Tags local time jboss

Introduction: This article begins with a brief introduction to OSGi and Felix, followed by an example detailing how to develop WEB applications using Felix and Struts, while demonstrating the modularity and dynamic deployment characteristics of OSGi. It then explains the common command operations used by OSGi bundles management, as well as the solutions to several familiar problems in the development process.

Introduction

Open Service Gateway Initiative (OSGI) is a specification for Java dynamic module development. Middleware-based OSGi technology provides a service-oriented, component-based development environment and provides a standardized way to manage the entire software lifecycle. OSGi provides good support for systems that require long running, dynamic updates, and minimal impact on the running environment. The system developed based on OSGi has the characteristics of low complexity, reusable, dynamic deployment, sustainable operation and simple development.

OSGi technology combines all aspects of the above features to define a dynamic service deployment framework that can be managed remotely. OSGi technology was initially focused on embedded areas, such as set-top boxes, service gateways, mobile phones, and other application environments. But it works perfectly for any modular, component-oriented, service-oriented project. After Eclipse V3.0 uses OSGi as its modular and dynamic platform, it designs the Equinox kernel and uses OSGi technology to help with class loading, which greatly increases eclipse's start-up speed. On the application server, OSGi technology is supported or used by well-known servers such as Websphere,weblogic,jboss.

Felix is an open source framework for Apache's OSGi implementation, and its ultimate goal is to provide a fully compliant OSGI framework and implementation of standard services. Felix currently implements much of the OSGi spec 4, and the OSGi framework functionality that Felix provides is very stable.

The methodology for developing OSGI-based Web applications using Web containers such as Spring DM and Jetty has been mentioned in many books or technical articles. But this development method differs from the traditional WEB development, it is difficult for the developer to switch to this development mode, and its stability is not fully validated.

Many WEB developments use Struts as their control layer, and fortunately, the latest release of Struts2.1.8.1 has added support for Felix OSGi to integrate OSGi's modular management platform in traditional web development, and the development approach has not changed much, developing The application is still as easy to deploy on tomcat,jboss containers as it used to be.

This article will detail how to use Felix and Struts to develop WEB applications in the following example.

Developing WEB application samples using Felix and Struts

The example below is a simple example of getting time information and displaying it in a Web browser, which focuses on how to use Felix and Struts to combine to develop Web applications. In this example, there are two bundle that get the time information, the two bundle implement the same interface service, but there are different implementations, and these two bundle can be deployed dynamically in the application. This example demonstrates the ability of a project based on OSGi development to be modular and bundle dynamic deployment of OSGi to demonstrate that OSGi is suitable for developing systems that are constantly running and need to be dynamically updated.

In this example, a total of five projects, a WEB application project and four OSGi bundle projects are included. Web application engineering is used for Web deployments. Four OSGi bundle, including a Web bundle, for Web interaction, a Time service bundle, which contains an interface service to get the information of the Times, a local service bundle, implements interface services, and To obtain local time information, a UTC time Service bundle for obtaining world standard times (Universal-COORDINATED,UTC) information.

This example is structured as shown in Figure 1. The listener for Struts OSGi is registered in the Web Container that will start or stop the Apache Felix Host,apache Felix Host is the struts OSGi Plugin and Felix Framewo The connection point of RK. Felix Host will go to create and initialize the Felix Framework,felix Framework responsible for managing all the rest of the bundle,struts OSGi Plugin will listen for changes in bundle if a change occurs bundle is a struts bundle, it will load the configuration of struts.

Figure 1. Example structure schematic diagram

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.