single sourcing

44
© 2002 IBM Corporation Confidential  |  Date  |  Other Information, if necessary                                                                               Copyright EclipseSource – made available under the EPL 1.0 Single-Sourcing Techniques for RAP and RCP Ralf Sternberg rsternberg@eclipsesource.com Rüdiger Herrmann rherrmann@eclipsesource.com

Upload: ralf-sternberg

Post on 24-Jun-2015

1.188 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Single Sourcing

© 2002 IBM Corporation

Confidential  |  Date  |  Other Information, if necessary                                                                              Copyright EclipseSource – made available under the EPL 1.0

Single­Sourcing Techniques for RAP and RCP

Ralf [email protected]

Rüdiger [email protected]

Page 2: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 2

AgendaBasicsSetup

DependenciesExtensions

API DifferencesLift Off

API Differences IIMulti­User Environment

Page 3: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 3

AgendaBasicsSetup

DependenciesExtensions

API DifferencesLift Off

API Differences IIMulti­User Environment

Page 4: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 4

What is RAP?

rich internet application runtime platform

based on the Eclipse programming model

single sourcing for rich client­ and web­applications

Page 5: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 5

Cobbler, stay with your trade

Single Sourcing common codebase for rich- and web-clients

reuse of existing RCP code

70% - 90% is possible

RAP provides only a subset of RCP

applications need to become multi-user enabled

Page 6: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 6

Groundwork - OSGi

Plug-ins, Plug-ins, Plug-ins...

OSGi specifies a dynamic component model:

the Eclipse OSGi implementation is provided by the Equinox project

- Module – encapsulation and declaration of dependencies

- Life Cycle – API for life cycle management- Service Registry – providing functionality to

other bundles- Security layer – limit bundle functionality to

pre-defined capabilities

Page 7: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 7

On the surface

Contribution to a powerful UI Concept

Standard Widget Toolkit (SWT)delivers native widget functionality for

the Eclipse platform in an operating system independent manner

JFacesits on top of SWT and provides

classes for handling common UI programming tasks

Workbenchis responsible for the presentation and

coordination of the user interface

Page 8: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 8

Best of both worldsWorkbench Window

Tool BarMenu Bar

Page

Editor View

View

Page 9: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 9

Select a point of view

Page 10: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 10

Problem Cases

Differences between RCP and RAP

RAP runs in a multi-user environment

one OSGi instance for all sessions in RAP

singletons are shared between sessions

no implicit thread to session assignment

resources (images, colors und fonts) are shared

thin-client architecture

API limitations (no GC, no MouseMove events)

Page 11: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 11

AgendaBasicsSetup

DependenciesExtensions

API DifferencesLift Off

API Differences IIMulti­User Environment

Page 12: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 12

Hand tools

Download

Java Runtime Environmenthttp://www.java.com/de/download/

Eclipse SDK

http://www.eclipse.org/downloads/

RAP SDKhttp://www.eclipse.org/rap/downloads/

Eclipse Distributions z.B.

http://ondemand.yoxos.com/

Page 13: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 13

Workplace

2 Workbench Instances

RAP and RCP need different

targets

switching a target is time-

consuming because the complete

workspace is recompiled

Page 14: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 14

The Example Application

RCP Mail Demo

- created by using the new plug-in project wizard in the RCP workbench

- filed in a common projects folder

- created as Rich Client Application

- runs immediately

Page 15: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 15

Import to the RAP DevelopmentEnvironmentRAP Mail Demo

- import using the import project wizard

- after import 216 error markers

- step by step conversion to support both runtimes

Page 16: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 16

AgendaBasicsSetup

DependenciesExtensions

API DifferencesLift Off

API Differences IIMulti­User Environment

Page 17: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 17

Dependencies

The problem of different UI libraries

possible solutions:

package import

OSGi specification section 3.13.2

problems caused by split-packages

optional dependencies on both library versions

warnings caused by missing bundle references

UI abstraction layer

Page 18: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 18

Dependencies

The compatibility plug-in

location in projects folder

import into both workspaces

list of required bundles

org.eclipse.rap.ui

org.eclipse.ui

properties

‘Optional’

‘Reexport this dependency’

Page 19: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 19

Dependencies

RAP workspace after switching the UI dependencies

Page 20: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 20

AgendaBasicsSetup

DependenciesExtensions

API DifferencesLift Off

API Differences IIMulti­User Environment

Page 21: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 21

Extensions

The problem of different Extension-Points

not all RCP E-Ps are available in RAP

e.g. bindings, helpSupport …

additional RAP E-Ps for web specific requirements

e.g. entrypoint, phaselistener …

Page 22: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 22

Extensions

Fragment Solution

two fragments per plug-in one for RAP specifics

one for RCP specifics

at runtime, only the plug-in that fits the environment

will be installed

platform specific E-P contributions are moved into the corresponding fragment

bundle structure stays intact

Page 23: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 23

Extensions

Creation of the Fragment Projects

using the new project wizard fragment project

all fragments are filed in the projects folder

the following fragments are created compatibility.rap compatibility.rcp

maildemo.rap

maildemo.rcp

each workspace contains only therelevant fragments

Page 24: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 24

Extensions

Creation of the Fragment Projects

using the new project wizard fragment project

all fragments are filed in the projects folder

the following fragments are created compatibility.rap compatibility.rcp

maildemo.rap

maildemo.rcp

each workspace contains only therelevant fragments

Page 25: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 25

Extensions

RCP workspace after moving E-Ps into fragment.xml

Page 26: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 26

AgendaBasicsSetup

DependenciesExtensions

API DifferencesLift Off

API Differences IIMulti­User Environment

Page 27: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 27

API Differences

The problem of different APIs

not all RCP APIs are available in RAP

e.g. GC, MouseMove Events, FileDialog …

additional RAP APIs for web specific requirements

e.g. PhaseListener, ISessionStore …

Page 28: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 28

API Differences

The problem of different APIs

solution:

abstract type in host-bundle, that encapsulates the problem

type implementation in the fragment, that platform dependent, solves the problem

loading the platform specific implementation at runtime by means of reflection

Page 29: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 29

API Differences

Example ‘About’ Action

the last compile error in the RAP workspace is caused by the missing about action of the ActionFactory.

encapsulate the problem by using an ActionFactoryFacade type:

Page 30: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 30

API Differences

Example ‘About’ Action II

implementation of ActionFactoryFacade:

Page 31: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 31

API Differences

Example ‘About’ Action III

implementation of ImplemenationLoader:

Page 32: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 32

API Differences

Example ‘About’ Action IV

platform specific implementations:

RAP RCP

Page 33: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 33

AgendaBasicsSetup

DependenciesExtensions

API DifferencesLift Off

API Differences IIMulti­User Environment

Page 34: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 34

Lift Off

Start-up help

Page 35: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 35

Lift Off

Page 36: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 36

AgendaBasicsSetup

DependenciesExtensions

API DifferencesLift Off

API Differences IIMulti­User Environment

Page 37: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 37

API Differences

Resources in RAP are different from RCP

no public constructor

no dispose

shared between sessions

differences are resolved at JFace layer

Page 38: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 38

AgendaBasicsSetup

DependenciesExtensions

API DifferencesLift Off

API Differences IIMulti­User Environment

Page 39: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 39

Multi-User Environment

Singletons

classical singletons exist in application scope

in RAP, most of the time, session scope is desirable

Page 40: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 40

Multi-User Environment

Singletons II

implementation in the host bundle:

fragment implementation:

RAP RCP

Page 41: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 41

Multi-User Environment

Jobs

jobs can’t implicitly access session-singletons

Page 42: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 42

Multi-User Environment

Jobs II

implementations in the host bundle:

Page 43: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 43

Get RAP ­  http://eclipse.org/rap

Page 44: Single Sourcing

Single Sourcing                                            Copyright Innoopract – made available under the EPL 1.0 page: 44

More Information

http://www.eclipse.org/rap ­ RAP project page

http://wiki.eclipse.org/RAP ­ RAP project wiki

http://www.qooxdoo.org ­ qooxdoo js library

Questions?

  [email protected]