On Platform-Plugin Architecture Take Eclipse as an Example 魏恒峰.

27
On Platform-Plugin A On Platform-Plugin A rchitecture rchitecture Take Eclipse as an Exampl e 魏魏魏

Transcript of On Platform-Plugin Architecture Take Eclipse as an Example 魏恒峰.

On Platform-Plugin ArchitecOn Platform-Plugin Architectureture

Take Eclipse as an Example

魏恒峰

Overview

Motivations for Plugins What is platform-plugin architecture? Eclipse Example

platform plugin extension model

Runtime consideration Some challenging issues

Motivation for Plugins(1)

Customers' requirements control the creation and deployment of software.

rapid changes in requirements upgradeablity support for integrating other vendor's comp

ents at any time

more flexible and extensible

Motivation for Plugins(3)

What can we do ……?

traditional software architecture add new functionality modify existing functionality add new functionality again modify existing functionality again ……

What a mess!

Motivation for Plugins(4)

How about Platform-Plugin Architecture? providing modular functionality to users platform is small + integrated offer a consistent use experience

Support composing a larger system that is not pre-structured, or to extend it in ways you don't foresee.

Maybe elegant

What is Platform-Plugin?

Sounds familiar……

History: While working on Silicon Beach Software’s Digital Dark-room--one of the first digital imaging programs--programmers envisioned using XCMD-like bits of software to extend Digital Darkroom’s capabilities to include access to flat-bed scanners and software “filters” that could manipulate a photograph’s look. They called this concept a “plug-in” and the name stuck.

What is Platform-Plugin?

more familiar…… Actually, it is much more than a wonderful IDE……

What is Platform-Plugin?A platform describes some sort of hardware architecture or software framework (including application frameworks), that allows software to run. —— from Wikipedia

A plug-in is a structured component that contributes code (or documentation or both) to the system and describes it in a structured way.

Eclipse Platform Architecture(1)

Platform Runtime:

Finding,loading,and running the right plugin code.

Maintaining a registry of installed plugins and the functions they provide.

Managing the plugin extension model and inter-plugin dependencies.

org.eclipse.osgiorg.eclipse.osgiorg.eclipse.core.runtimeorg.eclipse.core.runtime

Eclipse Platform Architecture(2)

core plugincore plugin

Workspace(ModelModel) Resource

Project File

SWT JFace

Workbench(ViewView) View Editor Perspectives Wizards Action Sets

Eclipse Platform Architecture(3)

The JDT is implemented by a The JDT is implemented by a group of plugins,with the user group of plugins,with the user interface in a UI plugin and thinterface in a UI plugin and the non-UI infrastructure in a se non-UI infrastructure in a separate core plugin.eparate core plugin.

Eclipse Plugin Plugin

A plug-in is a structured component that contributes code (or documentation or both) to the system and describes it in a structuredstructured way.

Plug-ins can define extension pointsextension points, well-defined function points that can be extended by other plug-ins. When a plug-in contributes an implementation for an extension point, we say that it adds an extensionextension to the platform. These extensions and extension points are declared in the plug-ins's manifest (plugmanifest (plugin.xml) filein.xml) file.

—— From Eclipse online Help

Eclipse Extension Model

Define Extension Point

Host PluginHost Plugin

Interface

Extender PluginExtender Plugin

Extension

ClassImplementsImplements

extends

looking up its extenders, looking up its extenders, instantiating the associated callback class,instantiating the associated callback class,

invoking the interface methodsinvoking the interface methods

Extension Model(con.)

the extensibility of plugins by plugins

Much like defining any contractual obligation: an extension model provides a structured way f

or plugins to describe the ways they can be extended and for client plugins to describe the extensions they supply.

Interface

Schema

Extension Model(an example:popupMenus)

org.eclipse.ui plugin extension org.eclipse.ui plugin extension point —— popupMenuspoint —— popupMenus

CONFORMANCE RULE:CONFORMANCE RULE:Contributions must conform to Contributions must conform to expected interfaces.expected interfaces.

public class RunTestAction implements public class RunTestAction implements IObjectActionDelegateIObjectActionDelegate

Extension Model(an example:popupMenus)

Eclipse Extension Model

Define Extension Point

Host PluginHost Plugin

Interface

Extender PluginExtender Plugin

Extension

ClassImplementsImplements

extends

looking up its extenders, looking up its extenders, instantiating the associated callback class,instantiating the associated callback class,

invoking the interface methodsinvoking the interface methods

Extension Model(Extension Processing)

In extension model,the host plugin is responsible for: looking uplooking up its extenders instaniatinginstaniating the associated callback class invoking invoking the appropriate interface methods

The extension declarations in all plugins that extend it must be processed. Contributing to host plugin's UI what callback objects to call

Extension Model(Extension Processing)

Platform Runtime

Extension Model(Extension Processing)

Contributing to host plugin's Contributing to host plugin's UIUI

Code is not necessary!Code is not necessary!

Extension Model(Extension Processing)A principal function of extension processing is the A principal function of extension processing is the instantiationinstantiation and and initializiinitializi

ng ng of an extension's callback objects.of an extension's callback objects.

instantiation:instantiation:

Actually,it is performed in a lazy manner

initializing:initializing:

Plugin Runtime Considerations(Lazy Loading)

LAZY LOADING RULAZY LOADING RULE:LE: Contributions are only

loaded when they are nneededeeded.

This requires support for plugin declarativedeclarative functionality.

Plugin Runtime Considerations(Lazy Loading)

virtual proxyvirtual proxy may may cache additional incache additional in

formationformation about the rea about the real subject so that they cal subject so that they can postpone accessing it.n postpone accessing it.

The Eclipse workbench populates a PluginAction from the information in the manifest (title, icon, tooltip).

UIUI

PluginAction loads the extension class and forwards the run() request to it.

Action Action On DemandOn Demand

Challenging Issues(1) Installing and updating

the ability to roll back,migrate existing program data and preferences,or ensure the installation is not corrupted

various providers => do not test fully Security

downloading from third parties (digitally signed)

controlling a plugin's access to other code and data

(sandbox)

Challenging Issues(2)

Concurrent plugin version support confusing UI versions are part of plugin dependency specifications eclipse's solution: Generally,the latest version first.

Scalability,up and down too many plugins (fast start-up) install/update(changed,featuresfeatures) scaling down(limited resources,minimal configuration)

Epilogue

Motivations for Plugins What is platform-plugin architecture? Eclipse Example

platform plugin extension model

Runtime consideration Some challenging issues