SlideShare une entreprise Scribd logo
1  sur  53
Télécharger pour lire hors ligne
Building complex and modular
RIAs with OSGi™ and Flex®

francois.fornaciari@zenika.com
www.zenika.com
Content
 Introduction
 OSGi™ and Flex® interactions
 Application modularization
 Demo
 Conclusion




                 Mix-IT 2011 - François Fornaciari
Bio
 Java EE / RIA consultant and trainer
   × Working on Flex projects at Manpower
 Board member of the OSGi™ Users’ Group
  France
 Over the last 4 years
  × Participation in the refactoring of the new
    version of JOnAS based on OSGi™




                  Mix-IT 2011 - François Fornaciari
What is Flex® (1/2)
 Framework for building RIA
  × Flash technology
  × Flash Player (VM)
  × Free Software Development Kit (SDK)
  × Strong integration with Java
  × Tooling
     × Flash Builder™ : IDE based on Eclipse
     × IntelliJ IDEA




                       Mix-IT 2011 - François Fornaciari
What is Flex® (2/2)
 MXML: XML-based language
 ActionScript: ECMAScript-compliant
  scripting
 Library of pre-built components
 Compiler: create SWFs from
  MXML/ActionScript files




                Mix-IT 2011 - François Fornaciari
MXML
 XML-based language
 Declarative way to build applications
   <s:Application
      xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:mx="library://ns.adobe.com/flex/mx">
     <s:Panel>
       <s:Label text="Label" />
       <s:Button label="Button" />
     </s:Panel>
   </s:Application>




                   Mix-IT 2011 - François Fornaciari
ActionScript
 Core of the Flex® Framework
 Familiar syntax
    package com.zenika.flex {
      public class MyClass interface MyInterface {
        public function MyClass() {

         }
         public function doSomething():String {

         }
        }
    }




                    Mix-IT 2011 - François Fornaciari
What is OSGi™
 OSGi™ framework specifications (4.2)
  × Core Specification
  × Compendium Specification
  × Enterprise Specification
 A module system and service platform for
 the Java programming language




               Mix-IT 2011 - François Fornaciari
OSGi™ Bundles
 Bundle
  × Deployment unit: JAR + MANIFEST
  × Functional unit (provides services)
 Application
  × Set of bundles
     × Dynamically deployed
     × Potentially shared between applications




                   Mix-IT 2011 - François Fornaciari
Bundle’s structure


  Provided                                       Required
                                    res
  services      classes                          services



 Exported                                        Imported
 packages           manifest
                                                 packages




             Mix-IT 2011 - François Fornaciari
MANIFEST file
 # Package(s) requis
 Import-Package: com.zenika.interface;version=1.1.0
 # Package(s) fournis
 Export-Package: com.zenika.service;version=2.0.0
 # Identifiant du bundle : unique pour la plate-forme
 Bundle-SymbolicName: com.zenika.example
 # Version du bundle
 Bundle-Version: 2.1.0
 # Nom du bundle
 Bundle-Name: Exemple
 # Nom de la classe Activator (l’équivalent du Main)
 Bundle-Activator: com.zenika.internal.Activator




                  Mix-IT 2011 - François Fornaciari
Bundle lifecycle




           Mix-IT 2011 - François Fornaciari
OSGi™ Services (1/2)
       Service Oriented Architecture

                  Service broker
   Lookup                                              Register
                      Specification


                        Binding
    Consumer                                       Provider




               Mix-IT 2011 - François Fornaciari
OSGi™ Services (2/2)
 Java™ Interface
   × Generally, the package is exported by a
     dedicated bundle
 One or many implementations
  × Packaged in a bundle
  × Generally not public: package not exported
 Identified by some properties
       Interface
                                                               Implementation class
       com.zenika.device.PrintService                       com.zenika.printer.laser.Driver
       (color=true)


                        Mix-IT 2011 - François Fornaciari
Purpose
 Presentation of the main design patterns for
  building complex and modular applications
  with OSGi™ and Flex®
 Two axes
  × Communication between Flex® and OSGi™
  × Application modularization




                 Mix-IT 2011 - François Fornaciari
General architecture

  Client (browser)                                                                  Server (Java)
                      Flex®                          HTTPService                     OSGi™ Framework
                                                     WebService
                                                     RemoteObject
    SWF Application




                                                     Producer
                      SWF Module

                                   SWF Module




                                                     Consumer




                                                                                      Bundle

                                                                                               Bundle

                                                                                                        Bundle
                                                Mix-IT 2011 - François Fornaciari
Handling remote calls
 HTTPService, WebService, Remote
 Objects, Consumer/Producer
  × Asynchronous calls
     × Result, Fault or Message handlers
  × Arguments and result types
     × Strongly typed or generic objects
     × XML format
  × Properties
     × URL, destination, endpoint, id, …



                    Mix-IT 2011 - François Fornaciari
Service call example
 private function callService():void {
   var service:MyService = new MyService(destination);
   service.addEventListener(ResultEvent.RESULT,
 onResult);
   service.addEventListener(FaultEvent.FAULT, onFault);
   service.send();
 }

 private function onResult(event:ResultEvent):void {
   var result:MyObject = event.result as MyObject;
   ...
 }

 private function onFault(event:FaultEvent):void {...}




                   Mix-IT 2011 - François Fornaciari
Accessing web services (1/2)
 “Non-OSGi™” services
 Flex consumer objects
  × HTTPService
     × Supported methods: GET | POST
     × HEAD | OPTIONS | PUT | TRACE | DELETE only
      through the server-based proxy service
  × WebService
     × Provides access to SOAP-based web services on
       local or remote servers



                  Mix-IT 2011 - François Fornaciari
Accessing web services (2/2)
 Expose OSGi™ services through the
 “Remote Services Specification”
  × Development of OSGi™ standard services
  × Service properties for defining
     × SOAP-based services
     × RESTful JAXRS-based endpoints
  × Implementation: Distributed OSGi™
     × Sub-project of Apache CXF




                 Mix-IT 2011 - François Fornaciari
Accessing OSGi™ services
 In a transparent way
 Two communication types
   × RemoteObject
     × Simple call to an existing OSGi™ service
     × Strongly-typed arguments and result or …
     × … generic objects
  × Producer/Consumer
     × Topic subscription




                   Mix-IT 2011 - François Fornaciari
AMF Protocol
 Action Message Format (v3)
  × Binary format used to serialize ActionScript
    objects
     × Optimized transferred data amount
  × Primarily used to exchange data between
    Adobe Flash applications and remote services
  × Specification since 2007
     × Supported by many server-side languages and
       technologies: Java™, .NET, PHP, …



                   Mix-IT 2011 - François Fornaciari
Integration frameworks
 Existing open source frameworks
  Name                    OSGi™ support        RemoteObject     OSGi™ EventAdmin
                                                                bridge

  AMF3 for OSGi™ (LGPL)   yes                  yes              yes
  GraniteDS (LGPL)        yes (prototype)      yes (unstable)   no
  Spring Flex (ASL)       yes (Virgo)          yes              no



 AMF3 for OSGi™ (Christopher Brind)
  × Robust, OSGi™ compliant and easy to use
         × Only 3 bundles to deploy


                          Mix-IT 2011 - François Fornaciari
AMF3 for OSGi™
 OSGi™ bundle description
  × uk.co.arum.osgi.amf3
     × Serialization-deserialization of AMF3 objects
  × uk.co.arum.osgi.amf3.http
     × Registers an HTTP servlet that is capable of reading
       and writing AMF3 objects
  × uk.co.arum.osgi.amf3.flex.remoting
     × Implements FlexRemoting over HTTP
     × Provides support for channel based messaging



                   Mix-IT 2011 - François Fornaciari
Apache Felix projects (1/2)
 Core of the server-side application
  × Framework
  × File Install
     × Directory based OSGi™ management agent
  × Used internally by AMF3 for OSGi ™
  × Declarative Service (SCR)
  × Event Admin Service
  × Log Service
  × HTTP Service (Jetty)

                  Mix-IT 2011 - François Fornaciari
Apache Felix projects (2/2)
 Application-specific projects
  × Event Admin Service
     × OSGi™ EventHandler receives messages from Flex
       Producers
     × Messages posted by the OSGi™ EventAdmin
       service are received by Flex Consumers
  × iPOJO
     × Used to declare OSGi™ components
     × Support of annotations
     × Extensible handlers


                  Mix-IT 2011 - François Fornaciari
Event Admin
 Based on the Publish-Subscribe pattern

                       postEvent
                        (topics)
                                                       EventAdmin
    Publisher
                                                        « service »



                EventHandler                                handleEvent
                 « service »                                  (topics)


                   Mix-IT 2011 - François Fornaciari
Publishing OSGi™ services
 Additional service property
  × AMF_SERVICE_NAME
       × Instantiated with the service class name

 @Component(name="MyService")
 @Provides
 public class MyServiceImpl implements MyService {

     @ServiceProperty(name="AMF_SERVICE_NAME")
     private String serviceName = MyService.class.getName();

     ...
 }




                      Mix-IT 2011 - François Fornaciari
Consuming OSGi™ services
 Flex RemoteObject
  × Endpoint: AMF3 servlet path
     × ex: http://localhost:8080/amf3osgi
  × Destination: OSGi™ service class name
  <s:RemoteObject id="myService"
                  endpoint="/amf3osgi"
                  destination="com.zenika.service.MyService">
     <s:method name="doSometing"
               result="onResult(event)"
               fault="onFault(event)" />
  </s:RemoteObject>




                      Mix-IT 2011 - François Fornaciari
Type-safe objects
 Method arguments and result




[RemoteClass(alias="com.zenika.systemmanager...SWFModule")]
[Bindable]
public class SWFModule



                     Mix-IT 2011 - François Fornaciari
Producer / Consumer (1/2)
 Bridge between Flex® events and
  EventAdmin service
 Elements attributes
  × Consumer: callback when a message is
    received
  × Consumer and producer: destination
     <s:Consumer message="onMessage(event)"
                 destination="events"
                 fault="onFault(event)" />
     <s:Producer destination="events"
                 fault="onFault(event)" />


                  Mix-IT 2011 - François Fornaciari
Producer / Consumer (2/2)
 Destination configuration
  × Set of channels used to send messages to a
    target destination
      × QoS: many channels for network failure tolerance

  var channelSet:ChannelSet = new ChannelSet();
  var channel:AMFChannel =
               new AMFChannel("events","/amf3osgi");
  channel.pollingInterval = 5000;
  channelSet.addChannel(channel);

  consumer.channelSet = channelSet;




                    Mix-IT 2011 - François Fornaciari
Sending messages (1/2)
 From OSGi™
  × PublishedObjectEvent (channelID, object)
  × Extends org.osgi.service.event.Event

    @Bind
    public void bindEventAdmin(EventAdmin eventAdmin) {
      this.eventAdmin = eventAdmin;
    }

    private void sendMessage() {
      eventAdmin.postEvent(
       new PublishedObjectEvent("events", object));
    }



                   Mix-IT 2011 - François Fornaciari
Sending messages (2/2)
 From Flex®
  × Sending AsyncMessage through the producer
     × Body: object to send

     var message:AsyncMessage = new AsyncMessage();
     message.body = messageObject;
     producer.send(message);




                   Mix-IT 2011 - François Fornaciari
Receiving message (1/2)
@Component(name="FlexEventHandler")
@Provides
public class FlexEventHandler implements EventHandler {
  @ServiceProperty(name="event.topics")
  private String eventTopics =
   ".../amf3/flex/remoting/events/PublishedObjectEvent";

    @ServiceProperty(name="event.filter")
    private String eventFilter = "(channel.id=events)";

    public void handleEvent(Event event) {
      if (event instanceof PublishedObjectEvent) { ...}
    }
}




                     Mix-IT 2011 - François Fornaciari
Receiving message (2/2)
 Start / cancel subscription
 Message: typed-object

 private function start():void {
    consumer.subscribe();
 }
 private function stop():void {
    consumer.unsubscribe();
 }
 private function onMessage(event:MessageEvent):void {
   var msg:MyMessage = event.message.body as MyMessage;
   ...
 }



                   Mix-IT 2011 - François Fornaciari
Some key elements
 We have seen how to:
  × Interact with different communication types
  × Standard web services
  × Remote Objects
  × Event-based messages
  × Expose OSGi™ services to Flex®
  × Handle events posted by the client-side or the
    backend


                  Mix-IT 2011 - François Fornaciari
Flex® modules
SWF Files
Loaded / unloaded at runtime
Better encapsulation
Separated developments
Compilation of one part of the application
Cached by the browser
Monitoring loading process
Cannot be run independently




                     Mix-IT 2011 - François Fornaciari
Main goal
 OSGi™ is the Java modularity
 Flex® supports modules


 How can we build a complete modular
 application?




                Mix-IT 2011 - François Fornaciari
Creating modules
 “Module” as root element
  <mx:Module
  xmlns:fx="http://ns.adobe.com/mxml/2009"
     xmlns:s="library://ns.adobe.com/flex/spark"
     xmlns:mx="library://ns.adobe.com/flex/mx"
     implements="...api.ModuleInterface"
     creationComplete="start()">
    <fx:Script>
      <![CDATA[
        public function start():void {...}
        public function stop():void {...}
      ]]>
    </fx:Script>
    <s:Label text="Label" />
  </mx:Module>


                   Mix-IT 2011 - François Fornaciari
Module lifecycle
 Start method is called when the module is
  loaded
 Stop method is called before unloading the
  module
  × Common interface between the application and
    the module
       package com.zenika.systemmanager.api {
         public interface ModuleInterface {
           function stop():void;
         }
       }


                 Mix-IT 2011 - François Fornaciari
Packaging
                                         Each bundle
                                             contains
  Application   Module
   Bundle       Bundle
                                              × Business logic
                                                    × OSGi™ services
   manifest     manifest
                                              × User interface
                                                    × SWF file
     JAVA        JAVA
    (OSGi™)     (OSGi™)

                                         Building tools like
      UI
    (SWF)
                  UI
                (SWF)
                                             Maven, Ant or
                                             Gradle can ease the
                                             packaging phase

                    Mix-IT 2011 - François Fornaciari
Application bundle
 User Interface skeleton
 Able to retrieve list of available modules
  × OSGi™ service for getting module URLs
 Flex® client notified when a module
  appears or disappears
  × Flex consumer is aware of events posted by
    the EventAdmin




                 Mix-IT 2011 - François Fornaciari
Technical view (1/4)
 At startup, registers bundle resources by
 using the HTTP Service
  × Main SWF, HTML files, …
 Gets registered modules and listens to
 bundle arrival / departure
  × Implementation of the extender pattern




                 Mix-IT 2011 - François Fornaciari
Technical view (2/4)
 Extender pattern
  × Use of a BundleTracker in order to be notified
    of bundles declaring Flex® modules
     × MANIFEST.MF :
        – SWF-Modules: [path]=[SWF name]
  × Register / unregister SWFs into path
     × Creation of a resource-aware context
  × Post event to notify Flex® client




                    Mix-IT 2011 - François Fornaciari
Technical view (3/4)
  var modules:ArrayCollection = event.result as
  ArrayCollection;

  for each(var module:SWFModule in modules) {
    var loader:ModuleLoader = new ModuleLoader(module.url);

      // Register event listeners
      loader.addEventListener(ModuleEvent.READY,
                              handleModuleReady);
      loader.addEventListener(ModuleEvent.ERROR,
                              handleModuleError);

      // Start the module loading
      loader.load();
  }




                       Mix-IT 2011 - François Fornaciari
Technical view (4/4)
 After bundle undeployment
  × Call the stop method
     × Stop properly on-going processes
     × Warning: OSGi™ services have already been
      unregistered
  × Unload associated modules
     × Free-up memory and resources




                     Mix-IT 2011 - François Fornaciari
Module bundle
 Autonomous module
  × Contains its own UI and logic
  × Good isolation
  × Flex® modules have to be based upon their
    own OSGi™ services
     × Avoid using unregistered services or managing
      service dynamicity on the client-side




                   Mix-IT 2011 - François Fornaciari
DEMO
Conclusion (1/2)
 Flex®
  × Development of rich interfaces
  × Native support of modules
     × Loading / unloading modules at runtime

 OSGi™
  × The Dynamic Module System for Java™
  × Service Oriented Architecture
     × Service availability to Flex®




                    Mix-IT 2011 - François Fornaciari
Conclusion (2/2)
 Seamless communications
  × Asynchronous remote calls
  × Notifications
 Integration
   × Application: set of autonomous bundles with
     their own interface and business logic




                  Mix-IT 2011 - François Fornaciari
References
 OSGi™ : www.osgi.org
 Apache Felix: felix.apache.org
 Adobe Flex® :
  www.adobe.com/fr/products/flex
 AMF3 for OSGi™ :
  www.arum.co.uk/amf3osgi.php




                Mix-IT 2011 - François Fornaciari
Questions




     francois.fornaciari@zenika.com
            www.zenika.com


            Mix-IT 2011 - François Fornaciari

Contenu connexe

Tendances

ServiceMix 4 -- Integrating OSGi with JBI
ServiceMix 4 -- Integrating OSGi with JBIServiceMix 4 -- Integrating OSGi with JBI
ServiceMix 4 -- Integrating OSGi with JBI
Gert Vanthienen
 
vlavrynovych - WebSockets Presentation
vlavrynovych - WebSockets Presentationvlavrynovych - WebSockets Presentation
vlavrynovych - WebSockets Presentation
Volodymyr Lavrynovych
 
Service-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMixService-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMix
Bruce Snyder
 
Comet web applications with Python, Django & Orbited
Comet web applications with Python, Django & OrbitedComet web applications with Python, Django & Orbited
Comet web applications with Python, Django & Orbited
PyCon Italia
 

Tendances (20)

HTML5 WebSocket Introduction
HTML5 WebSocket IntroductionHTML5 WebSocket Introduction
HTML5 WebSocket Introduction
 
An Introduction to Apache ServiceMix 4 - FUSE ESB
An Introduction to Apache ServiceMix 4 - FUSE ESBAn Introduction to Apache ServiceMix 4 - FUSE ESB
An Introduction to Apache ServiceMix 4 - FUSE ESB
 
ServiceMix 4 -- Integrating OSGi with JBI
ServiceMix 4 -- Integrating OSGi with JBIServiceMix 4 -- Integrating OSGi with JBI
ServiceMix 4 -- Integrating OSGi with JBI
 
Websocket protocol overview
Websocket protocol overviewWebsocket protocol overview
Websocket protocol overview
 
HTML5 Real-Time and Connectivity
HTML5 Real-Time and ConnectivityHTML5 Real-Time and Connectivity
HTML5 Real-Time and Connectivity
 
HTML5 Multimedia Accessibility
HTML5 Multimedia AccessibilityHTML5 Multimedia Accessibility
HTML5 Multimedia Accessibility
 
Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014
 
CouchDB Google
CouchDB GoogleCouchDB Google
CouchDB Google
 
WebSocket protocol
WebSocket protocolWebSocket protocol
WebSocket protocol
 
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
 
Building an HTML5 Video Player
Building an HTML5 Video PlayerBuilding an HTML5 Video Player
Building an HTML5 Video Player
 
Service Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixService Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMix
 
WordPress Plugins for n00bs
WordPress Plugins for n00bsWordPress Plugins for n00bs
WordPress Plugins for n00bs
 
vlavrynovych - WebSockets Presentation
vlavrynovych - WebSockets Presentationvlavrynovych - WebSockets Presentation
vlavrynovych - WebSockets Presentation
 
Service-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMixService-Oriented Integration With Apache ServiceMix
Service-Oriented Integration With Apache ServiceMix
 
Performance Improvements in Browsers
Performance Improvements in BrowsersPerformance Improvements in Browsers
Performance Improvements in Browsers
 
Advanced AV Foundation (CocoaConf, Aug '11)
Advanced AV Foundation (CocoaConf, Aug '11)Advanced AV Foundation (CocoaConf, Aug '11)
Advanced AV Foundation (CocoaConf, Aug '11)
 
HTML5와 모바일
HTML5와 모바일HTML5와 모바일
HTML5와 모바일
 
soft-shake.ch - Windows Phone 7 „Mango“ – what’s new for Developers?
soft-shake.ch - Windows Phone 7 „Mango“ – what’s new for Developers?soft-shake.ch - Windows Phone 7 „Mango“ – what’s new for Developers?
soft-shake.ch - Windows Phone 7 „Mango“ – what’s new for Developers?
 
Comet web applications with Python, Django & Orbited
Comet web applications with Python, Django & OrbitedComet web applications with Python, Django & Orbited
Comet web applications with Python, Django & Orbited
 

En vedette

Mix-IT (Apr 2011) - Intelligence Collective avec Apache Mahout
Mix-IT (Apr 2011) - Intelligence Collective avec Apache MahoutMix-IT (Apr 2011) - Intelligence Collective avec Apache Mahout
Mix-IT (Apr 2011) - Intelligence Collective avec Apache Mahout
Michaël Figuière
 
WSO2Con US 2013 - Rapidly Building Complex Applications with WSO2 App Factory
WSO2Con US 2013 - Rapidly Building Complex Applications with WSO2 App FactoryWSO2Con US 2013 - Rapidly Building Complex Applications with WSO2 App Factory
WSO2Con US 2013 - Rapidly Building Complex Applications with WSO2 App Factory
WSO2
 

En vedette (19)

HTML5... La révolution maintenant!
HTML5... La révolution maintenant!HTML5... La révolution maintenant!
HTML5... La révolution maintenant!
 
Sur la route de l'agilité @Mix-it Lyon 2011
Sur la route de l'agilité @Mix-it Lyon 2011Sur la route de l'agilité @Mix-it Lyon 2011
Sur la route de l'agilité @Mix-it Lyon 2011
 
Mix it 2011 - Clojure
Mix it 2011 - ClojureMix it 2011 - Clojure
Mix it 2011 - Clojure
 
Mix-IT (Apr 2011) - Intelligence Collective avec Apache Mahout
Mix-IT (Apr 2011) - Intelligence Collective avec Apache MahoutMix-IT (Apr 2011) - Intelligence Collective avec Apache Mahout
Mix-IT (Apr 2011) - Intelligence Collective avec Apache Mahout
 
mix-it 2011
mix-it 2011mix-it 2011
mix-it 2011
 
Agile Sans Frontières
Agile Sans FrontièresAgile Sans Frontières
Agile Sans Frontières
 
OUGF OSGi/Flex
OUGF OSGi/FlexOUGF OSGi/Flex
OUGF OSGi/Flex
 
Pre-Con Education: Building Advanced ITSM Workflows in CA Service Management
Pre-Con Education: Building Advanced ITSM Workflows in CA Service ManagementPre-Con Education: Building Advanced ITSM Workflows in CA Service Management
Pre-Con Education: Building Advanced ITSM Workflows in CA Service Management
 
WSO2Con US 2013 - Rapidly Building Complex Applications with WSO2 App Factory
WSO2Con US 2013 - Rapidly Building Complex Applications with WSO2 App FactoryWSO2Con US 2013 - Rapidly Building Complex Applications with WSO2 App Factory
WSO2Con US 2013 - Rapidly Building Complex Applications with WSO2 App Factory
 
Barile S., Polese F., Saviano M., Di Nauta P., Drawing boundaries in complex ...
Barile S., Polese F., Saviano M., Di Nauta P., Drawing boundaries in complex ...Barile S., Polese F., Saviano M., Di Nauta P., Drawing boundaries in complex ...
Barile S., Polese F., Saviano M., Di Nauta P., Drawing boundaries in complex ...
 
Fire Fighting systems - Advanced Services
Fire Fighting systems - Advanced ServicesFire Fighting systems - Advanced Services
Fire Fighting systems - Advanced Services
 
Intelligent Building (Dayabumi Complex)
Intelligent Building (Dayabumi Complex)Intelligent Building (Dayabumi Complex)
Intelligent Building (Dayabumi Complex)
 
Fire fighting passive system
Fire fighting passive systemFire fighting passive system
Fire fighting passive system
 
Topic 3 District Cooling System
Topic 3 District Cooling SystemTopic 3 District Cooling System
Topic 3 District Cooling System
 
Sewerage design
Sewerage designSewerage design
Sewerage design
 
MEP- Building services
MEP- Building servicesMEP- Building services
MEP- Building services
 
Introduction To Building Services
Introduction To Building ServicesIntroduction To Building Services
Introduction To Building Services
 
Curtain walls - Advanced structural systems
Curtain walls - Advanced structural systemsCurtain walls - Advanced structural systems
Curtain walls - Advanced structural systems
 
AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)
AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)
AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)
 

Similaire à Building complex and modular RIAs with OSGi and Flex

What's New Logrhythm 5.1 Data Sheet
What's New Logrhythm 5.1 Data SheetWhat's New Logrhythm 5.1 Data Sheet
What's New Logrhythm 5.1 Data Sheet
jordagro
 
Signotron Software India Projects
Signotron Software India ProjectsSignotron Software India Projects
Signotron Software India Projects
Rajat Kumar Saha
 
Orion context broker webminar 2013 06-19
Orion context broker webminar 2013 06-19Orion context broker webminar 2013 06-19
Orion context broker webminar 2013 06-19
Fermin Galan
 

Similaire à Building complex and modular RIAs with OSGi and Flex (20)

Switch to alfresco with wasaaiq [compatibility mode]
Switch to alfresco with wasaaiq [compatibility mode]Switch to alfresco with wasaaiq [compatibility mode]
Switch to alfresco with wasaaiq [compatibility mode]
 
Apache conna2010 os-gi_flex-fornaciari
Apache conna2010 os-gi_flex-fornaciariApache conna2010 os-gi_flex-fornaciari
Apache conna2010 os-gi_flex-fornaciari
 
Apache Flex - Enterprise ready GUI framework
Apache Flex - Enterprise ready GUI frameworkApache Flex - Enterprise ready GUI framework
Apache Flex - Enterprise ready GUI framework
 
Temenos- Fiorano T24 Integration
Temenos- Fiorano T24 IntegrationTemenos- Fiorano T24 Integration
Temenos- Fiorano T24 Integration
 
Flex and .NET Integration
Flex and .NET IntegrationFlex and .NET Integration
Flex and .NET Integration
 
Exploiting Firefox Extensions
Exploiting Firefox ExtensionsExploiting Firefox Extensions
Exploiting Firefox Extensions
 
OUGF - OSGi / Flex
OUGF - OSGi / FlexOUGF - OSGi / Flex
OUGF - OSGi / Flex
 
FusionInventory at LSM/RMLL 2012
FusionInventory at LSM/RMLL 2012FusionInventory at LSM/RMLL 2012
FusionInventory at LSM/RMLL 2012
 
What's New Logrhythm 5.1 Data Sheet
What's New Logrhythm 5.1 Data SheetWhat's New Logrhythm 5.1 Data Sheet
What's New Logrhythm 5.1 Data Sheet
 
Signotron Software India Projects
Signotron Software India ProjectsSignotron Software India Projects
Signotron Software India Projects
 
Developing RIAs... 10 reasons to use Adobe Flex
Developing RIAs... 10 reasons to use Adobe FlexDeveloping RIAs... 10 reasons to use Adobe Flex
Developing RIAs... 10 reasons to use Adobe Flex
 
Eclipse summit-2010
Eclipse summit-2010Eclipse summit-2010
Eclipse summit-2010
 
Import golang; struct microservice
Import golang; struct microserviceImport golang; struct microservice
Import golang; struct microservice
 
"Wie passen Serverless & Autonomous zusammen?"
"Wie passen Serverless & Autonomous zusammen?""Wie passen Serverless & Autonomous zusammen?"
"Wie passen Serverless & Autonomous zusammen?"
 
OpenStackDay - XIFI Federation
OpenStackDay - XIFI FederationOpenStackDay - XIFI Federation
OpenStackDay - XIFI Federation
 
FFmpeg - the universal multimedia toolkit
FFmpeg - the universal multimedia toolkitFFmpeg - the universal multimedia toolkit
FFmpeg - the universal multimedia toolkit
 
Use Cases for MXF Metadata and Simplified System Interaction
Use Cases for MXF Metadata and Simplified System InteractionUse Cases for MXF Metadata and Simplified System Interaction
Use Cases for MXF Metadata and Simplified System Interaction
 
TechEvent Servlerless Computing with Fn Project
TechEvent Servlerless Computing with Fn ProjectTechEvent Servlerless Computing with Fn Project
TechEvent Servlerless Computing with Fn Project
 
Serverless Computing with Fn Project
Serverless Computing with Fn ProjectServerless Computing with Fn Project
Serverless Computing with Fn Project
 
Orion context broker webminar 2013 06-19
Orion context broker webminar 2013 06-19Orion context broker webminar 2013 06-19
Orion context broker webminar 2013 06-19
 

Plus de CARA_Lyon (8)

Kanban un tour d'horizon
Kanban un tour d'horizonKanban un tour d'horizon
Kanban un tour d'horizon
 
Smartphone : et l'informatique devint mobile...
Smartphone : et l'informatique devint mobile...Smartphone : et l'informatique devint mobile...
Smartphone : et l'informatique devint mobile...
 
BDD (Behavior Driven Development) - Une voie vers l'agilité
BDD (Behavior Driven Development) - Une voie vers l'agilitéBDD (Behavior Driven Development) - Une voie vers l'agilité
BDD (Behavior Driven Development) - Une voie vers l'agilité
 
Test du futur avec Spock
Test du futur avec SpockTest du futur avec Spock
Test du futur avec Spock
 
Les outils de l'ergonome agile
Les outils de l'ergonome agileLes outils de l'ergonome agile
Les outils de l'ergonome agile
 
Fable du Product Owner et de la Maîtrise d'Ouvrage (MOA)
Fable du Product Owner et de la Maîtrise d'Ouvrage (MOA)Fable du Product Owner et de la Maîtrise d'Ouvrage (MOA)
Fable du Product Owner et de la Maîtrise d'Ouvrage (MOA)
 
HTML5... La révolution maintenant!
HTML5... La révolution maintenant!HTML5... La révolution maintenant!
HTML5... La révolution maintenant!
 
20110519 cara tests_agiles_grenoble_all
20110519 cara tests_agiles_grenoble_all20110519 cara tests_agiles_grenoble_all
20110519 cara tests_agiles_grenoble_all
 

Dernier

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

Building complex and modular RIAs with OSGi and Flex

  • 1. Building complex and modular RIAs with OSGi™ and Flex® francois.fornaciari@zenika.com www.zenika.com
  • 2. Content  Introduction  OSGi™ and Flex® interactions  Application modularization  Demo  Conclusion Mix-IT 2011 - François Fornaciari
  • 3. Bio  Java EE / RIA consultant and trainer × Working on Flex projects at Manpower  Board member of the OSGi™ Users’ Group France  Over the last 4 years × Participation in the refactoring of the new version of JOnAS based on OSGi™ Mix-IT 2011 - François Fornaciari
  • 4. What is Flex® (1/2)  Framework for building RIA × Flash technology × Flash Player (VM) × Free Software Development Kit (SDK) × Strong integration with Java × Tooling × Flash Builder™ : IDE based on Eclipse × IntelliJ IDEA Mix-IT 2011 - François Fornaciari
  • 5. What is Flex® (2/2)  MXML: XML-based language  ActionScript: ECMAScript-compliant scripting  Library of pre-built components  Compiler: create SWFs from MXML/ActionScript files Mix-IT 2011 - François Fornaciari
  • 6. MXML  XML-based language  Declarative way to build applications <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx"> <s:Panel> <s:Label text="Label" /> <s:Button label="Button" /> </s:Panel> </s:Application> Mix-IT 2011 - François Fornaciari
  • 7. ActionScript  Core of the Flex® Framework  Familiar syntax package com.zenika.flex { public class MyClass interface MyInterface { public function MyClass() { } public function doSomething():String { } } } Mix-IT 2011 - François Fornaciari
  • 8. What is OSGi™  OSGi™ framework specifications (4.2) × Core Specification × Compendium Specification × Enterprise Specification  A module system and service platform for the Java programming language Mix-IT 2011 - François Fornaciari
  • 9. OSGi™ Bundles  Bundle × Deployment unit: JAR + MANIFEST × Functional unit (provides services)  Application × Set of bundles × Dynamically deployed × Potentially shared between applications Mix-IT 2011 - François Fornaciari
  • 10. Bundle’s structure Provided Required res services classes services Exported Imported packages manifest packages Mix-IT 2011 - François Fornaciari
  • 11. MANIFEST file # Package(s) requis Import-Package: com.zenika.interface;version=1.1.0 # Package(s) fournis Export-Package: com.zenika.service;version=2.0.0 # Identifiant du bundle : unique pour la plate-forme Bundle-SymbolicName: com.zenika.example # Version du bundle Bundle-Version: 2.1.0 # Nom du bundle Bundle-Name: Exemple # Nom de la classe Activator (l’équivalent du Main) Bundle-Activator: com.zenika.internal.Activator Mix-IT 2011 - François Fornaciari
  • 12. Bundle lifecycle Mix-IT 2011 - François Fornaciari
  • 13. OSGi™ Services (1/2) Service Oriented Architecture Service broker Lookup Register Specification Binding Consumer Provider Mix-IT 2011 - François Fornaciari
  • 14. OSGi™ Services (2/2)  Java™ Interface × Generally, the package is exported by a dedicated bundle  One or many implementations × Packaged in a bundle × Generally not public: package not exported  Identified by some properties Interface Implementation class com.zenika.device.PrintService com.zenika.printer.laser.Driver (color=true) Mix-IT 2011 - François Fornaciari
  • 15. Purpose  Presentation of the main design patterns for building complex and modular applications with OSGi™ and Flex®  Two axes × Communication between Flex® and OSGi™ × Application modularization Mix-IT 2011 - François Fornaciari
  • 16. General architecture Client (browser) Server (Java) Flex® HTTPService OSGi™ Framework WebService RemoteObject SWF Application Producer SWF Module SWF Module Consumer Bundle Bundle Bundle Mix-IT 2011 - François Fornaciari
  • 17. Handling remote calls  HTTPService, WebService, Remote Objects, Consumer/Producer × Asynchronous calls × Result, Fault or Message handlers × Arguments and result types × Strongly typed or generic objects × XML format × Properties × URL, destination, endpoint, id, … Mix-IT 2011 - François Fornaciari
  • 18. Service call example private function callService():void { var service:MyService = new MyService(destination); service.addEventListener(ResultEvent.RESULT, onResult); service.addEventListener(FaultEvent.FAULT, onFault); service.send(); } private function onResult(event:ResultEvent):void { var result:MyObject = event.result as MyObject; ... } private function onFault(event:FaultEvent):void {...} Mix-IT 2011 - François Fornaciari
  • 19. Accessing web services (1/2)  “Non-OSGi™” services  Flex consumer objects × HTTPService × Supported methods: GET | POST × HEAD | OPTIONS | PUT | TRACE | DELETE only through the server-based proxy service × WebService × Provides access to SOAP-based web services on local or remote servers Mix-IT 2011 - François Fornaciari
  • 20. Accessing web services (2/2)  Expose OSGi™ services through the “Remote Services Specification” × Development of OSGi™ standard services × Service properties for defining × SOAP-based services × RESTful JAXRS-based endpoints × Implementation: Distributed OSGi™ × Sub-project of Apache CXF Mix-IT 2011 - François Fornaciari
  • 21. Accessing OSGi™ services  In a transparent way  Two communication types × RemoteObject × Simple call to an existing OSGi™ service × Strongly-typed arguments and result or … × … generic objects × Producer/Consumer × Topic subscription Mix-IT 2011 - François Fornaciari
  • 22. AMF Protocol  Action Message Format (v3) × Binary format used to serialize ActionScript objects × Optimized transferred data amount × Primarily used to exchange data between Adobe Flash applications and remote services × Specification since 2007 × Supported by many server-side languages and technologies: Java™, .NET, PHP, … Mix-IT 2011 - François Fornaciari
  • 23. Integration frameworks  Existing open source frameworks Name OSGi™ support RemoteObject OSGi™ EventAdmin bridge AMF3 for OSGi™ (LGPL) yes yes yes GraniteDS (LGPL) yes (prototype) yes (unstable) no Spring Flex (ASL) yes (Virgo) yes no  AMF3 for OSGi™ (Christopher Brind) × Robust, OSGi™ compliant and easy to use × Only 3 bundles to deploy Mix-IT 2011 - François Fornaciari
  • 24. AMF3 for OSGi™  OSGi™ bundle description × uk.co.arum.osgi.amf3 × Serialization-deserialization of AMF3 objects × uk.co.arum.osgi.amf3.http × Registers an HTTP servlet that is capable of reading and writing AMF3 objects × uk.co.arum.osgi.amf3.flex.remoting × Implements FlexRemoting over HTTP × Provides support for channel based messaging Mix-IT 2011 - François Fornaciari
  • 25. Apache Felix projects (1/2)  Core of the server-side application × Framework × File Install × Directory based OSGi™ management agent × Used internally by AMF3 for OSGi ™ × Declarative Service (SCR) × Event Admin Service × Log Service × HTTP Service (Jetty) Mix-IT 2011 - François Fornaciari
  • 26. Apache Felix projects (2/2)  Application-specific projects × Event Admin Service × OSGi™ EventHandler receives messages from Flex Producers × Messages posted by the OSGi™ EventAdmin service are received by Flex Consumers × iPOJO × Used to declare OSGi™ components × Support of annotations × Extensible handlers Mix-IT 2011 - François Fornaciari
  • 27. Event Admin  Based on the Publish-Subscribe pattern postEvent (topics) EventAdmin Publisher « service » EventHandler handleEvent « service » (topics) Mix-IT 2011 - François Fornaciari
  • 28. Publishing OSGi™ services  Additional service property × AMF_SERVICE_NAME × Instantiated with the service class name @Component(name="MyService") @Provides public class MyServiceImpl implements MyService { @ServiceProperty(name="AMF_SERVICE_NAME") private String serviceName = MyService.class.getName(); ... } Mix-IT 2011 - François Fornaciari
  • 29. Consuming OSGi™ services  Flex RemoteObject × Endpoint: AMF3 servlet path × ex: http://localhost:8080/amf3osgi × Destination: OSGi™ service class name <s:RemoteObject id="myService" endpoint="/amf3osgi" destination="com.zenika.service.MyService"> <s:method name="doSometing" result="onResult(event)" fault="onFault(event)" /> </s:RemoteObject> Mix-IT 2011 - François Fornaciari
  • 30. Type-safe objects  Method arguments and result [RemoteClass(alias="com.zenika.systemmanager...SWFModule")] [Bindable] public class SWFModule Mix-IT 2011 - François Fornaciari
  • 31. Producer / Consumer (1/2)  Bridge between Flex® events and EventAdmin service  Elements attributes × Consumer: callback when a message is received × Consumer and producer: destination <s:Consumer message="onMessage(event)" destination="events" fault="onFault(event)" /> <s:Producer destination="events" fault="onFault(event)" /> Mix-IT 2011 - François Fornaciari
  • 32. Producer / Consumer (2/2)  Destination configuration × Set of channels used to send messages to a target destination × QoS: many channels for network failure tolerance var channelSet:ChannelSet = new ChannelSet(); var channel:AMFChannel = new AMFChannel("events","/amf3osgi"); channel.pollingInterval = 5000; channelSet.addChannel(channel); consumer.channelSet = channelSet; Mix-IT 2011 - François Fornaciari
  • 33. Sending messages (1/2)  From OSGi™ × PublishedObjectEvent (channelID, object) × Extends org.osgi.service.event.Event @Bind public void bindEventAdmin(EventAdmin eventAdmin) { this.eventAdmin = eventAdmin; } private void sendMessage() { eventAdmin.postEvent( new PublishedObjectEvent("events", object)); } Mix-IT 2011 - François Fornaciari
  • 34. Sending messages (2/2)  From Flex® × Sending AsyncMessage through the producer × Body: object to send var message:AsyncMessage = new AsyncMessage(); message.body = messageObject; producer.send(message); Mix-IT 2011 - François Fornaciari
  • 35. Receiving message (1/2) @Component(name="FlexEventHandler") @Provides public class FlexEventHandler implements EventHandler { @ServiceProperty(name="event.topics") private String eventTopics = ".../amf3/flex/remoting/events/PublishedObjectEvent"; @ServiceProperty(name="event.filter") private String eventFilter = "(channel.id=events)"; public void handleEvent(Event event) { if (event instanceof PublishedObjectEvent) { ...} } } Mix-IT 2011 - François Fornaciari
  • 36. Receiving message (2/2)  Start / cancel subscription  Message: typed-object private function start():void { consumer.subscribe(); } private function stop():void { consumer.unsubscribe(); } private function onMessage(event:MessageEvent):void { var msg:MyMessage = event.message.body as MyMessage; ... } Mix-IT 2011 - François Fornaciari
  • 37. Some key elements  We have seen how to: × Interact with different communication types × Standard web services × Remote Objects × Event-based messages × Expose OSGi™ services to Flex® × Handle events posted by the client-side or the backend Mix-IT 2011 - François Fornaciari
  • 38. Flex® modules SWF Files Loaded / unloaded at runtime Better encapsulation Separated developments Compilation of one part of the application Cached by the browser Monitoring loading process Cannot be run independently Mix-IT 2011 - François Fornaciari
  • 39. Main goal  OSGi™ is the Java modularity  Flex® supports modules  How can we build a complete modular application? Mix-IT 2011 - François Fornaciari
  • 40. Creating modules  “Module” as root element <mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" implements="...api.ModuleInterface" creationComplete="start()"> <fx:Script> <![CDATA[ public function start():void {...} public function stop():void {...} ]]> </fx:Script> <s:Label text="Label" /> </mx:Module> Mix-IT 2011 - François Fornaciari
  • 41. Module lifecycle  Start method is called when the module is loaded  Stop method is called before unloading the module × Common interface between the application and the module package com.zenika.systemmanager.api { public interface ModuleInterface { function stop():void; } } Mix-IT 2011 - François Fornaciari
  • 42. Packaging  Each bundle contains Application Module Bundle Bundle × Business logic × OSGi™ services manifest manifest × User interface × SWF file JAVA JAVA (OSGi™) (OSGi™)  Building tools like UI (SWF) UI (SWF) Maven, Ant or Gradle can ease the packaging phase Mix-IT 2011 - François Fornaciari
  • 43. Application bundle  User Interface skeleton  Able to retrieve list of available modules × OSGi™ service for getting module URLs  Flex® client notified when a module appears or disappears × Flex consumer is aware of events posted by the EventAdmin Mix-IT 2011 - François Fornaciari
  • 44. Technical view (1/4)  At startup, registers bundle resources by using the HTTP Service × Main SWF, HTML files, …  Gets registered modules and listens to bundle arrival / departure × Implementation of the extender pattern Mix-IT 2011 - François Fornaciari
  • 45. Technical view (2/4)  Extender pattern × Use of a BundleTracker in order to be notified of bundles declaring Flex® modules × MANIFEST.MF : – SWF-Modules: [path]=[SWF name] × Register / unregister SWFs into path × Creation of a resource-aware context × Post event to notify Flex® client Mix-IT 2011 - François Fornaciari
  • 46. Technical view (3/4) var modules:ArrayCollection = event.result as ArrayCollection; for each(var module:SWFModule in modules) { var loader:ModuleLoader = new ModuleLoader(module.url); // Register event listeners loader.addEventListener(ModuleEvent.READY, handleModuleReady); loader.addEventListener(ModuleEvent.ERROR, handleModuleError); // Start the module loading loader.load(); } Mix-IT 2011 - François Fornaciari
  • 47. Technical view (4/4)  After bundle undeployment × Call the stop method × Stop properly on-going processes × Warning: OSGi™ services have already been unregistered × Unload associated modules × Free-up memory and resources Mix-IT 2011 - François Fornaciari
  • 48. Module bundle  Autonomous module × Contains its own UI and logic × Good isolation × Flex® modules have to be based upon their own OSGi™ services × Avoid using unregistered services or managing service dynamicity on the client-side Mix-IT 2011 - François Fornaciari
  • 49. DEMO
  • 50. Conclusion (1/2)  Flex® × Development of rich interfaces × Native support of modules × Loading / unloading modules at runtime  OSGi™ × The Dynamic Module System for Java™ × Service Oriented Architecture × Service availability to Flex® Mix-IT 2011 - François Fornaciari
  • 51. Conclusion (2/2)  Seamless communications × Asynchronous remote calls × Notifications  Integration × Application: set of autonomous bundles with their own interface and business logic Mix-IT 2011 - François Fornaciari
  • 52. References  OSGi™ : www.osgi.org  Apache Felix: felix.apache.org  Adobe Flex® : www.adobe.com/fr/products/flex  AMF3 for OSGi™ : www.arum.co.uk/amf3osgi.php Mix-IT 2011 - François Fornaciari
  • 53. Questions francois.fornaciari@zenika.com www.zenika.com Mix-IT 2011 - François Fornaciari