Simplified IOC implementation based on Eclipse RCP

Source: Internet
Author: User
Tags connection pooling

I. INTRODUCTION

The Eclipse Rich Client Platform (RCP) is a powerful software infrastructure that allows developers to build generic applications based on interconnected collaborative plug-ins. With RCP, developers simply focus on the development of application business code without having to spend time rewriting application management logic.

Both control inversion (IoC) and Dependency Injection (DI) are programming patterns that can be used to reduce the coupling between programs. They all follow a simple principle: you don't have to create your own objects, instead of simply describing how the object was created, you do not have to instantiate or directly locate the services that your component needs, but simply determine which services are required by which components, and then the other programs (usually a container) are responsible for hooking them together. This is the famous "Hollywood Principle"-Don't look for us, let's find you.

This article describes a simple way to add dependency injection support to an Eclipse RCP application. To avoid impacting the basic architecture of the eclipse platform and to transparently add the IOC framework to RCP, we will use the runtime bytecode operation technology (using the ObjectWeb ASM Library) together, Java class loads agents (using java.lang.instrument packages) and Java annotation techniques.

Two. What is the eclipse rich client platform?

In a nutshell, the Eclipse Rich client platform is a set of libraries, software frameworks, and a run-time environment for building applications that run both independently and in the network.

Although eclipse is used as the IDE for a development program, the entire software has been rebuilt into separate components since release 3.0 so that you can use the smallest subset of these components to build any application. Such a subset forms a rich client platform and includes different elements: basic runtime, user interface components (SWT and JFace), plug-ins, and OSGi layers. Figure 1 shows the main components of the Eclipse platform.

Figure 1. The main components of the Eclipse platform

The entire eclipse platform is based on two key concepts-plug-ins and extension points. A plug-in is a small functional unit that can be developed and published independently. Typically, Plug-ins are packaged as a jar file, and can be extended by adding some functionality to the Eclipse platform (for example, an editor, a toolbar button, or a compiler). In fact, the entire eclipse platform is a set of interconnected plug-ins that can communicate with each other. An extension point is an available connection point, and other plug-ins can be used to provide added functionality (in terms of "extension"). Both extension and extension points are defined in the XML configuration file that is bound to the plug-in.

Although plug-in mechanisms take advantage of important patterns-such as separation of relationships, strong connections, and so on-the communication required by Plug-ins can cause physical dependencies between these plug-ins. A typical example is that a plug-in needs to locate a single instance (singleton) service that can be used for an application-such as database connection pooling, log processing, or user-saved collection information. Control reversal and dependency injection are all feasible solutions to eliminate this dependency.

Related Article

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.