SlideShare a Scribd company logo
1 of 44
Download to read offline
Building complex and modular RIAs with
                         OSGi and Flex



                 francois.fornaciari@zenika.com




www.zenika.com
Agenda



•    Introduction
•    Flex and OSGi interactions
•    Application modularization
•    Demo
•    Conclusion




    www.zenika.com
What is Flex (1/2)



• Framework for building RIA
  •   Flash technology
  •   Free Software Development Kit (SDK)
  •   Flash Player (VM)
  •   Strong integration with Java
  •   Tooling
       •   Flash Builder : IDE based on Eclipse
       •   IntelliJ IDEA




 www.zenika.com
What is Flex (2/2)



•    MXML: XML-based language
•    ActionScript: ECMAScript-compliant scripting
•    Library of pre-built components
•    Compiler: create SWFs from MXML/ActionScript




    www.zenika.com
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>




 www.zenika.com
ActionScript



• Core of the Flex Framework
• ECMAScript-compliant scripting
• Familiar syntax
        package com.zenika.flex {
          public class MyClass interface MyInterface {
            public function MyClass() {

                    }
                    public function doSomething():String {

                }
            }
        }




 www.zenika.com
What is OSGi (1/3)



• A module system and service platform for the Java
  programming language
• OSGi framework specifications
  • Core Specification
  • Compendium Specification
  • Enterprise Specification




 www.zenika.com
What is OSGi (2/3)



• Service Oriented Architecture

                         Service
                         broker
      Lookup                                     Register
                        Specification


                         Binding
         Consumer                            Provider


 www.zenika.com
What is OSGi (3/3)



• Bundle
  • Deployment unit: JAR + MANIFEST
  • Functional unit (provides services)
• Application
  • Set of bundles
       •   Dynamically deployed
       •   Potentially shared between applications




 www.zenika.com
Purpose



• Presentation of the main design patterns for building
  complex and modular applications with Flex and OSGi
• Two axes
  • Communication between Flex and OSGi
  • Application modularization




 www.zenika.com
General architecture




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

                       SWF Module

                                    SWF Module




                                                 Consumer




                                                                     Bundle

                                                                              Bundle

                                                                                       Bundle
www.zenika.com
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, …




 www.zenika.com
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 {...}




www.zenika.com
Communications (1/2)



• Accessing “non-OSGi services”
  • 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 remote servers
            •     ex: exposed through D-OSGi




 www.zenika.com
Communications (2/2)



• 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
                   • Unsafe access to properties and methods
                   • Introspection API
       •   Producer/Consumer
           •      Topic subscription




 www.zenika.com
AMF Protocol (1/2)



• 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, …




 www.zenika.com
Integration frameworks



• Existing open source frameworks
 Name                    OSGi support      RemoteObject     Producer / Consumer

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


• AMF3 for OSGi (Christopher Brind)
   • Easy to use
        •   Only 3 bundles to deploy
   • Robust



 www.zenika.com
AMF3 for OSGi



• OSGi bundles 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




 www.zenika.com
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)




 www.zenika.com
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




 www.zenika.com
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();

     ...
 }




 www.zenika.com
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">
   <mx:method name="doSometing"
              result="onResult(event)"
              fault="onFault(event)" />
</s:RemoteObject>




 www.zenika.com
Type-safe objects



• Method arguments and result




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




  www.zenika.com
Producer / Consumer (1/2)



• Bridge between Flex events and EventAdmin service
• Elements attributes
  • Consumer: callback when a message is received
  • Consumer and producer: destination

     <mx:Consumer message="onMessage(event)"
                  destination="events"
                  fault="onFault(event)" />
     <mx:Producer destination="events"
                  fault="onFault(event)" />




 www.zenika.com
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;




 www.zenika.com
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));
 }




 www.zenika.com
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);




 www.zenika.com
Receiving message (1/2)


 public class FlexEventHandler implements EventHandler {
   @ServiceProperty(name="event.topics")
   private String eventTopics =
    ".../amf3/flex/remoting/events/PublishedObjectEvent";

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


All Flex messages
are received by
this handler



 www.zenika.com
Receiving message (2/2)


  • Message: typed-object
  • Start / cancel subscription

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;
  ...
}




www.zenika.com
Some key elements



• We have seen how to:
  • Expose OSGi services to Flex
  • Interact with different service types
       •   Remote Objects
       •   Event-based messages
       •   Standard web services
  • Define strongly-typed objects
  • Handle events posted by the backend




 www.zenika.com
Flex modulary



• Flex modules
  • SWF files that can be loaded and unloaded at runtime by an
    application
  • Cannot be run independently
  • Applications can share modules
  • No need to load all modules at startup




 www.zenika.com
Benefits



• Split Flex application into several pieces
   • Smaller initial download size of the SWF
   • Shorter load time
   • Better encapsulation
• Load required modules only
• Unload modules at runtime
   • Free up memory and resources




 www.zenika.com
Main goal



• OSGi is the Java modularity
• Flex supports modules

• How can we build a complete modular application?




 www.zenika.com
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>



 www.zenika.com
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;
           }
         }




 www.zenika.com
Packaging


                            • Each bundle contains
                              • Business logic
                                 • OSGi services
     Application   Module
       bundle      bundle     • User interface
                                 • SWF file

         JAVA       JAVA    • Build may be done with
        (OSGi)     (OSGi)     Maven

          UI         UI
        (SWF)      (SWF)



www.zenika.com
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




 www.zenika.com
Technical view (1/3)



• Registers bundle resources into the HTTP Service
   • Main SWF, HTML files, …
• Listens to bundle arrival / departure
   • Implementation of the extender pattern
       •   Use of a BundeTracker for being notified of bundles declaring
           Flex modules
            •     MANIFEST.MF : SWF-Modules: [path]=[SWF name]
       •   Register/unregister SWFs into declared path
       •   Post event to notify Flex client




 www.zenika.com
Technical view (2/3)


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();
}




www.zenika.com
Technical view (3/3)



• 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




 www.zenika.com
Module bundle



• Autonomous module
  • Contains its own UI and logic
  • Good isolation
  • Flex modules can easily be based upon OSGi services




 www.zenika.com
Démo

                 DEMO




www.zenika.com
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




 www.zenika.com
Conclusion (2/2)



• Seamless communications
  • Asynchronous remote calls
  • Notifications
• Integration
  • Application: set of autonomous bundles with their own
    interface and business logic




 www.zenika.com

More Related Content

What's hot

Mike Taulty DevDays 2010 Silverlight 4 - What's New Part 1
Mike Taulty DevDays 2010 Silverlight 4 - What's New Part 1Mike Taulty DevDays 2010 Silverlight 4 - What's New Part 1
Mike Taulty DevDays 2010 Silverlight 4 - What's New Part 1
ukdpe
 
Dot net Online Training | .Net Training and Placement online
Dot net Online Training | .Net Training and Placement onlineDot net Online Training | .Net Training and Placement online
Dot net Online Training | .Net Training and Placement online
Garuda Trainings
 
The History and Status of Web Crypto API (2012)
The History and Status of Web Crypto API (2012)The History and Status of Web Crypto API (2012)
The History and Status of Web Crypto API (2012)
Channy Yun
 
Polyakov how i will break your enterprise. esb security and more
Polyakov   how i will break your enterprise. esb security and morePolyakov   how i will break your enterprise. esb security and more
Polyakov how i will break your enterprise. esb security and more
DefconRussia
 

What's hot (19)

Mike Taulty DevDays 2010 Silverlight 4 - What's New Part 1
Mike Taulty DevDays 2010 Silverlight 4 - What's New Part 1Mike Taulty DevDays 2010 Silverlight 4 - What's New Part 1
Mike Taulty DevDays 2010 Silverlight 4 - What's New Part 1
 
10 Tricks and Tips for WCF
10 Tricks and Tips for WCF10 Tricks and Tips for WCF
10 Tricks and Tips for WCF
 
Dot net Online Training | .Net Training and Placement online
Dot net Online Training | .Net Training and Placement onlineDot net Online Training | .Net Training and Placement online
Dot net Online Training | .Net Training and Placement online
 
Enjoying the Move from WCF to the Web API
Enjoying the Move from WCF to the Web APIEnjoying the Move from WCF to the Web API
Enjoying the Move from WCF to the Web API
 
Web services soap
Web services soapWeb services soap
Web services soap
 
Java Web Services [3/5]: WSDL, WADL and UDDI
Java Web Services [3/5]: WSDL, WADL and UDDIJava Web Services [3/5]: WSDL, WADL and UDDI
Java Web Services [3/5]: WSDL, WADL and UDDI
 
WebServices
WebServicesWebServices
WebServices
 
Web services
Web servicesWeb services
Web services
 
WCF for begineers
WCF  for begineersWCF  for begineers
WCF for begineers
 
The History and Status of Web Crypto API (2012)
The History and Status of Web Crypto API (2012)The History and Status of Web Crypto API (2012)
The History and Status of Web Crypto API (2012)
 
WCF
WCFWCF
WCF
 
WCF tutorial
WCF tutorialWCF tutorial
WCF tutorial
 
Design-Time Properties in Custom Pipeline Components
Design-Time Properties in Custom Pipeline ComponentsDesign-Time Properties in Custom Pipeline Components
Design-Time Properties in Custom Pipeline Components
 
Web services wsdl
Web services wsdlWeb services wsdl
Web services wsdl
 
Polyakov how i will break your enterprise. esb security and more
Polyakov   how i will break your enterprise. esb security and morePolyakov   how i will break your enterprise. esb security and more
Polyakov how i will break your enterprise. esb security and more
 
Web Services
Web ServicesWeb Services
Web Services
 
Windows Communication Foundation (WCF)
Windows Communication Foundation (WCF)Windows Communication Foundation (WCF)
Windows Communication Foundation (WCF)
 
Introduction to WCF
Introduction to WCFIntroduction to WCF
Introduction to WCF
 
Net framework
Net frameworkNet framework
Net framework
 

Viewers also liked

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
 

Viewers also liked (13)

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
 
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
 
Building complex and modular RIAs with OSGi and Flex
Building complex and modular RIAs with OSGi and FlexBuilding complex and modular RIAs with OSGi and Flex
Building complex and modular RIAs with OSGi and Flex
 
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)
 

Similar to OUGF OSGi/Flex

AMF Flash and .NET
AMF Flash and .NETAMF Flash and .NET
AMF Flash and .NET
Yaniv Uriel
 
Technical Specification Overview - OSGi World Congress 2002 Workshop Intro - ...
Technical Specification Overview - OSGi World Congress 2002 Workshop Intro - ...Technical Specification Overview - OSGi World Congress 2002 Workshop Intro - ...
Technical Specification Overview - OSGi World Congress 2002 Workshop Intro - ...
mfrancis
 
HTML5 Programming
HTML5 ProgrammingHTML5 Programming
HTML5 Programming
hotrannam
 
OSGi In Anger - Tara Simpson
OSGi In Anger - Tara SimpsonOSGi In Anger - Tara Simpson
OSGi In Anger - Tara Simpson
mfrancis
 
SkyeCORE - Rev Up Your OSGi Services!
SkyeCORE - Rev Up Your OSGi Services!SkyeCORE - Rev Up Your OSGi Services!
SkyeCORE - Rev Up Your OSGi Services!
Wayne Williams
 

Similar to OUGF OSGi/Flex (20)

Apache conna2010 os-gi_flex-fornaciari
Apache conna2010 os-gi_flex-fornaciariApache conna2010 os-gi_flex-fornaciari
Apache conna2010 os-gi_flex-fornaciari
 
AMF Flash and .NET
AMF Flash and .NETAMF Flash and .NET
AMF Flash and .NET
 
Technical Specification Overview - OSGi World Congress 2002 Workshop Intro - ...
Technical Specification Overview - OSGi World Congress 2002 Workshop Intro - ...Technical Specification Overview - OSGi World Congress 2002 Workshop Intro - ...
Technical Specification Overview - OSGi World Congress 2002 Workshop Intro - ...
 
IBM BP Session - Multiple CLoud Paks and Cloud Paks Foundational Services.pptx
IBM BP Session - Multiple CLoud Paks and Cloud Paks Foundational Services.pptxIBM BP Session - Multiple CLoud Paks and Cloud Paks Foundational Services.pptx
IBM BP Session - Multiple CLoud Paks and Cloud Paks Foundational Services.pptx
 
SOAP Service in Mule Esb
SOAP Service in Mule EsbSOAP Service in Mule Esb
SOAP Service in Mule Esb
 
uMobile Development Strategies
uMobile Development StrategiesuMobile Development Strategies
uMobile Development Strategies
 
Distributing OSGi
Distributing OSGiDistributing OSGi
Distributing OSGi
 
Java onebrazil hk2
Java onebrazil hk2Java onebrazil hk2
Java onebrazil hk2
 
Html5 Application Security
Html5 Application SecurityHtml5 Application Security
Html5 Application Security
 
HTML5 Programming
HTML5 ProgrammingHTML5 Programming
HTML5 Programming
 
Flex alfresco
Flex   alfrescoFlex   alfresco
Flex alfresco
 
Convertigo Mobile Application Development platform for Enterprises
Convertigo Mobile Application Development platform for EnterprisesConvertigo Mobile Application Development platform for Enterprises
Convertigo Mobile Application Development platform for Enterprises
 
OSGi In Anger - Tara Simpson
OSGi In Anger - Tara SimpsonOSGi In Anger - Tara Simpson
OSGi In Anger - Tara Simpson
 
Collector Web Services
Collector Web ServicesCollector Web Services
Collector Web Services
 
SUGCON EU 2023 - Secure Composable SaaS.pptx
SUGCON EU 2023 - Secure Composable SaaS.pptxSUGCON EU 2023 - Secure Composable SaaS.pptx
SUGCON EU 2023 - Secure Composable SaaS.pptx
 
OSGi Cloud Ecosystems
OSGi Cloud EcosystemsOSGi Cloud Ecosystems
OSGi Cloud Ecosystems
 
SkyeCORE - Rev Up Your OSGi Services!
SkyeCORE - Rev Up Your OSGi Services!SkyeCORE - Rev Up Your OSGi Services!
SkyeCORE - Rev Up Your OSGi Services!
 
OSGi on Google Android using Apache Felix
OSGi on Google Android using Apache FelixOSGi on Google Android using Apache Felix
OSGi on Google Android using Apache Felix
 
Phonegap 2.x
Phonegap 2.xPhonegap 2.x
Phonegap 2.x
 
Enterprise service bus part 2
Enterprise service bus part 2Enterprise service bus part 2
Enterprise service bus part 2
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
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
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
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
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

OUGF OSGi/Flex

  • 1. Building complex and modular RIAs with OSGi and Flex francois.fornaciari@zenika.com www.zenika.com
  • 2. Agenda • Introduction • Flex and OSGi interactions • Application modularization • Demo • Conclusion www.zenika.com
  • 3. What is Flex (1/2) • Framework for building RIA • Flash technology • Free Software Development Kit (SDK) • Flash Player (VM) • Strong integration with Java • Tooling • Flash Builder : IDE based on Eclipse • IntelliJ IDEA www.zenika.com
  • 4. What is Flex (2/2) • MXML: XML-based language • ActionScript: ECMAScript-compliant scripting • Library of pre-built components • Compiler: create SWFs from MXML/ActionScript www.zenika.com
  • 5. 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> www.zenika.com
  • 6. ActionScript • Core of the Flex Framework • ECMAScript-compliant scripting • Familiar syntax package com.zenika.flex { public class MyClass interface MyInterface { public function MyClass() { } public function doSomething():String { } } } www.zenika.com
  • 7. What is OSGi (1/3) • A module system and service platform for the Java programming language • OSGi framework specifications • Core Specification • Compendium Specification • Enterprise Specification www.zenika.com
  • 8. What is OSGi (2/3) • Service Oriented Architecture Service broker Lookup Register Specification Binding Consumer Provider www.zenika.com
  • 9. What is OSGi (3/3) • Bundle • Deployment unit: JAR + MANIFEST • Functional unit (provides services) • Application • Set of bundles • Dynamically deployed • Potentially shared between applications www.zenika.com
  • 10. Purpose • Presentation of the main design patterns for building complex and modular applications with Flex and OSGi • Two axes • Communication between Flex and OSGi • Application modularization www.zenika.com
  • 11. General architecture Client (browser) Server (Java) Flex HTTPService OSGi Framework WebService RemoteObject Producer SWF Application SWF Module SWF Module Consumer Bundle Bundle Bundle www.zenika.com
  • 12. 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, … www.zenika.com
  • 13. 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 {...} www.zenika.com
  • 14. Communications (1/2) • Accessing “non-OSGi services” • 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 remote servers • ex: exposed through D-OSGi www.zenika.com
  • 15. Communications (2/2) • 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 • Unsafe access to properties and methods • Introspection API • Producer/Consumer • Topic subscription www.zenika.com
  • 16. AMF Protocol (1/2) • 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, … www.zenika.com
  • 17. Integration frameworks • Existing open source frameworks Name OSGi support RemoteObject Producer / Consumer AMF3 for OSGi (LGPL) yes yes yes GraniteDS (LGPL) yes (prototype) yes (unstable) no Spring Flex (ASL) yes (Virgo) yes yes • AMF3 for OSGi (Christopher Brind) • Easy to use • Only 3 bundles to deploy • Robust www.zenika.com
  • 18. AMF3 for OSGi • OSGi bundles 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 www.zenika.com
  • 19. 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) www.zenika.com
  • 20. 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 www.zenika.com
  • 21. 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(); ... } www.zenika.com
  • 22. 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"> <mx:method name="doSometing" result="onResult(event)" fault="onFault(event)" /> </s:RemoteObject> www.zenika.com
  • 23. Type-safe objects • Method arguments and result [RemoteClass(alias="com.zenika.systemmanager...SWFModule")] [Bindable] public class SWFModule www.zenika.com
  • 24. Producer / Consumer (1/2) • Bridge between Flex events and EventAdmin service • Elements attributes • Consumer: callback when a message is received • Consumer and producer: destination <mx:Consumer message="onMessage(event)" destination="events" fault="onFault(event)" /> <mx:Producer destination="events" fault="onFault(event)" /> www.zenika.com
  • 25. 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; www.zenika.com
  • 26. 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)); } www.zenika.com
  • 27. 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); www.zenika.com
  • 28. Receiving message (1/2) public class FlexEventHandler implements EventHandler { @ServiceProperty(name="event.topics") private String eventTopics = ".../amf3/flex/remoting/events/PublishedObjectEvent"; public void handleEvent(Event event) { if (event instanceof PublishedObjectEvent) { ...} } } All Flex messages are received by this handler www.zenika.com
  • 29. Receiving message (2/2) • Message: typed-object • Start / cancel subscription 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; ... } www.zenika.com
  • 30. Some key elements • We have seen how to: • Expose OSGi services to Flex • Interact with different service types • Remote Objects • Event-based messages • Standard web services • Define strongly-typed objects • Handle events posted by the backend www.zenika.com
  • 31. Flex modulary • Flex modules • SWF files that can be loaded and unloaded at runtime by an application • Cannot be run independently • Applications can share modules • No need to load all modules at startup www.zenika.com
  • 32. Benefits • Split Flex application into several pieces • Smaller initial download size of the SWF • Shorter load time • Better encapsulation • Load required modules only • Unload modules at runtime • Free up memory and resources www.zenika.com
  • 33. Main goal • OSGi is the Java modularity • Flex supports modules • How can we build a complete modular application? www.zenika.com
  • 34. 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> www.zenika.com
  • 35. 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; } } www.zenika.com
  • 36. Packaging • Each bundle contains • Business logic • OSGi services Application Module bundle bundle • User interface • SWF file JAVA JAVA • Build may be done with (OSGi) (OSGi) Maven UI UI (SWF) (SWF) www.zenika.com
  • 37. 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 www.zenika.com
  • 38. Technical view (1/3) • Registers bundle resources into the HTTP Service • Main SWF, HTML files, … • Listens to bundle arrival / departure • Implementation of the extender pattern • Use of a BundeTracker for being notified of bundles declaring Flex modules • MANIFEST.MF : SWF-Modules: [path]=[SWF name] • Register/unregister SWFs into declared path • Post event to notify Flex client www.zenika.com
  • 39. Technical view (2/3) 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(); } www.zenika.com
  • 40. Technical view (3/3) • 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 www.zenika.com
  • 41. Module bundle • Autonomous module • Contains its own UI and logic • Good isolation • Flex modules can easily be based upon OSGi services www.zenika.com
  • 42. Démo DEMO www.zenika.com
  • 43. 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 www.zenika.com
  • 44. Conclusion (2/2) • Seamless communications • Asynchronous remote calls • Notifications • Integration • Application: set of autonomous bundles with their own interface and business logic www.zenika.com