SlideShare a Scribd company logo
1 of 58
Download to read offline
ScalaModules
   Scala and OSGi
OSGi Services


• The key to modularity
• Arguably, the key to OOP itself?
Dr Alan Kay
Dr Alan Kay

“Dude I
invented
friggin’ OOP.
Have you
heard of it?”
Dr Alan Kay

“OOP to me means only
messaging, local
retention and protection
and hiding of state-
process, and extreme
late-binding of all things.”
Late Binding with
         Services

• Services answer the question:where do I
  get an implementation of this interface?
• The registry decentralises the architecture.
Consuming Services
Harder than Expected!
Why...?
Slippery
Dynamics

• A service can come and go
• At any time
• On any thread
• Yes... even while you’re using it
Result


• Service usage code can be
 very complex
Service Consumption
        in Java
Consuming a Service

public void consumeService(BundleContext context) {
   ServiceReference ref = context.getServiceReference(Greeting.class.getName());
   Greeting greeting = (Greeting) context.getService(ref);
   System.out.println(greeting.getMessage());
}
Consuming a Service

public void consumeService(BundleContext context) {
   ServiceReference ref = context.getServiceReference(Greeting.class.getName());
   Greeting greeting = (Greeting) context.getService(ref);
   System.out.println(greeting.getMessage());
}




             WRONG
Consuming a Service

public void consumeService(BundleContext context) {
   ServiceReference ref = context.getServiceReference(Greeting.class.getName());
   if(ref != null) {
      Greeting greeting = (Greeting) context.getService(ref);
      System.out.println(greeting.getMessage());
   }
}
Consuming a Service

public void consumeService(BundleContext context) {
   ServiceReference ref = context.getServiceReference(Greeting.class.getName());
   if(ref != null) {
      Greeting greeting = (Greeting) context.getService(ref);
      System.out.println(greeting.getMessage());
   }
}




             WRONG
Consuming a Service

    public void consumeService(BundleContext context) {
       ServiceReference ref = context.getServiceReference(Greeting.class.getName());
       if(ref != null) {
          Greeting greeting = (Greeting) context.getService(ref);
          if(greeting != null) {
         	 System.out.println(greeting.getMessage());
          }
       }
    }
Consuming a Service

    public void consumeService(BundleContext context) {
       ServiceReference ref = context.getServiceReference(Greeting.class.getName());
       if(ref != null) {
          Greeting greeting = (Greeting) context.getService(ref);
          if(greeting != null) {
         	 System.out.println(greeting.getMessage());
          }
       }
    }
	




                 WRONG
Consuming a Service
public void consumeService(BundleContext context) {
   ServiceReference ref = context.getServiceReference(Greeting.class.getName());
   if(ref != null) {
      Greeting greeting = (Greeting) context.getService(ref);
      if(greeting != null) {
     	 System.out.println(greeting.getMessage());
      }
      context.ungetService(ref);
   }
}
Consuming a Service
public void consumeService(BundleContext context) {
   ServiceReference ref = context.getServiceReference(Greeting.class.getName());
   if(ref != null) {
      Greeting greeting = (Greeting) context.getService(ref);
      if(greeting != null) {
     	 System.out.println(greeting.getMessage());
      }
      context.ungetService(ref);
   }
}




             WRONG
Consuming a Service
public void consumeService(BundleContext context) {
   ServiceReference ref = context.getServiceReference(Greeting.class.getName());
   if(ref != null) {
      try {
         Greeting greeting = (Greeting) context.getService(ref);
         if(greeting != null) {
     	     System.out.println(greeting.getMessage());
         }
      } finally {
     	 context.ungetService(ref);
      }
   }
}
Consuming a Service
public void consumeService(BundleContext context) {
   ServiceReference ref = context.getServiceReference(Greeting.class.getName());
   if(ref != null) {
      try {
         Greeting greeting = (Greeting) context.getService(ref);
         if(greeting != null) {
     	     System.out.println(greeting.getMessage());
         }
      } finally {
     	 context.ungetService(ref);
      }
   }
}




NOT TYPE SAFE
Consuming a Service
public void consumeService(BundleContext context) {
   ServiceReference ref = context.getServiceReference(Greeting.class.getName());
   if(ref != null) {
      try {
         Greeting greeting = (Greeting) context.getService(ref);
         if(greeting != null) {
     	     System.out.println(greeting.getMessage());
         }
      } finally {
     	 context.ungetService(ref);
      }
   }
}




NOT TYPE SAFE
An Answer:
Stop Writing Code!
Declarative Services
              (DS)
@Reference
public void setGreeting(Greeting greeting) {
   this.greeting = greeting;
}

public void consumeService() {
   System.out.println(greeting.getMessage());
}
Blueprint
   public void setGreeting(Greeting greeting) {
      this.greeting = greeting;
   }

   public void consumeService() {
      System.out.println(greeting.getMessage());
   }


<blueprint>

   <reference id="greeting" interface="org.example.Greeting"/>

   <bean id="foo" class="com.foo.Foo"/>
      <property name="greeting" ref="greeting"/>
   </bean>

</blueprint>
Problem

• These frameworks provide abstractions
• Abstraction hide detail
• Sometimes we need the detail
Example: Cardinality?
                  Service



                  Service

      Component

                  Service



                  Service
Single
            Service



            Service

Component

            Service



            Service
Multiple
            Service



            Service

Component

            Service



            Service
???
  Component         Service



  Component         Service



  Component         Service



  Component         Service




Not supported by DS
Declarative
I    Services
       (and Blueprint)
Declarative
I    Services
       (and Blueprint)
The “80%” Solution
              “Normal” Users
The “80%” Solution
              “Normal” Users
              DS support
The “80%” Solution
              “Normal” Users
              DS support
The “80%” Solution
              “Normal” Users
              DS support
              “Power” Users
The “80%” Solution
              “Normal” Users
              DS support
              “Power” Users
The “80%” Solution
              “Normal” Users
              DS support
              “Power” Users
              Easy in Java
The “80%” Solution
              “Normal” Users
              DS support
              “Power” Users
              Easy in Java
The “80%” Solution
              “Normal” Users
              DS support
              “Power” Users
              Easy in Java
              Easy in Scala
The “80%” Solution
              “Normal” Users
              DS support
              “Power” Users
              Easy in Java
              Easy in Scala
Java
ServiceTracker tracker = new ServiceTracker(context, Greeting.class.getName(),
                                            new ServiceTrackerCustomizer() {

      public Object addingService(ServiceReference reference) {
         Greeting greeting = (Greeting) context.getService(reference);	
         ServiceRegistration reg = context.registerService(IFoo.class.getName(),
                                                           new Foo(greeting), null);
         return reg;
      }

      public void modifiedService(ServiceReference reference, Object service) {
      }

      public void removedService(ServiceReference reference, Object service) {
         ServiceRegistration reg = (ServiceRegistration) service;
         reg.unregister();
      }
});
Java
ServiceTracker tracker = new ServiceTracker(context, Greeting.class.getName(),
                                            new ServiceTrackerCustomizer() {

      public Object addingService(ServiceReference reference) {
         Greeting greeting = (Greeting) context.getService(reference);	
         ServiceRegistration reg = context.registerService(IFoo.class.getName(),
                                                           new Foo(greeting), null);
         return reg;
      }

      public void modifiedService(ServiceReference reference, Object service) {
      }

      public void removedService(ServiceReference reference, Object service) {
         ServiceRegistration reg = (ServiceRegistration) service;
         reg.unregister();
      }
});



                                                               Type Safety???
What is ScalaModules?
NOT Another Module
  System (phew!)
“A Scala internal DSL to ease
    OSGi development”
• Now:
 • Services
• Future:
 • Extender Pattern?
 • Resources?
An Eclipse Project!
Examples
Java
ServiceTracker tracker = new ServiceTracker(context, Greeting.class.getName(),
                                            new ServiceTrackerCustomizer() {

      public Object addingService(ServiceReference reference) {
         Greeting greeting = (Greeting) context.getService(reference);	
         ServiceRegistration reg = context.registerService(IFoo.class.getName(),
                                                           new Foo(greeting), null);
         return reg;
      }

      public void modifiedService(ServiceReference reference, Object service) {
      }

      public void removedService(ServiceReference reference, Object service) {
         ServiceRegistration reg = (ServiceRegistration) service;
         reg.unregister();
      }
});
ScalaModules


val greetingTrack = context track classOf[Greeting] on {
   case Adding(greeting) => context createService (classOf[IFoo],
                                                   new Foo(greeting))
   case Removed(_, reg) => reg unregister
}
Plan
• Started moving the code & docs to Eclipse
• 19 March: M1
• 7 May: M2
• 28 May: RC1
• 11 June: RC2
• 23 June: ScalaModules 2.0 Release &
  Graduation
Get Involved

http://www.eclipse.org/forums/
      eclipse.scalamodules

More Related Content

Viewers also liked

Oop lecture1-chapter1(review of java)
Oop lecture1-chapter1(review of java)Oop lecture1-chapter1(review of java)
Oop lecture1-chapter1(review of java)Dastan Kamaran
 
Oscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheimOscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheimSkills Matter
 
Scala e xchange 2013 haoyi li on metascala a tiny diy jvm
Scala e xchange 2013 haoyi li on metascala a tiny diy jvmScala e xchange 2013 haoyi li on metascala a tiny diy jvm
Scala e xchange 2013 haoyi li on metascala a tiny diy jvmSkills Matter
 
5 things cucumber is bad at by Richard Lawrence
5 things cucumber is bad at by Richard Lawrence5 things cucumber is bad at by Richard Lawrence
5 things cucumber is bad at by Richard LawrenceSkills Matter
 
Patterns for slick database applications
Patterns for slick database applicationsPatterns for slick database applications
Patterns for slick database applicationsSkills Matter
 
enhanced er diagram
enhanced er diagramenhanced er diagram
enhanced er diagramCHANDRA BHUSHAN
 

Viewers also liked (6)

Oop lecture1-chapter1(review of java)
Oop lecture1-chapter1(review of java)Oop lecture1-chapter1(review of java)
Oop lecture1-chapter1(review of java)
 
Oscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheimOscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheim
 
Scala e xchange 2013 haoyi li on metascala a tiny diy jvm
Scala e xchange 2013 haoyi li on metascala a tiny diy jvmScala e xchange 2013 haoyi li on metascala a tiny diy jvm
Scala e xchange 2013 haoyi li on metascala a tiny diy jvm
 
5 things cucumber is bad at by Richard Lawrence
5 things cucumber is bad at by Richard Lawrence5 things cucumber is bad at by Richard Lawrence
5 things cucumber is bad at by Richard Lawrence
 
Patterns for slick database applications
Patterns for slick database applicationsPatterns for slick database applications
Patterns for slick database applications
 
enhanced er diagram
enhanced er diagramenhanced er diagram
enhanced er diagram
 

Similar to Scala modules

OSGi DevCon 09 - OSGi on Scala
OSGi DevCon 09 - OSGi on ScalaOSGi DevCon 09 - OSGi on Scala
OSGi DevCon 09 - OSGi on ScalaHeiko Seeberger
 
JAX 09 - OSGi on Scala
JAX 09 - OSGi on ScalaJAX 09 - OSGi on Scala
JAX 09 - OSGi on ScalaHeiko Seeberger
 
ASP.Net 5 and C# 6
ASP.Net 5 and C# 6ASP.Net 5 and C# 6
ASP.Net 5 and C# 6Andy Butland
 
Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...
Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...
Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...Oracle Developers
 
Angular.js Primer in Aalto University
Angular.js Primer in Aalto UniversityAngular.js Primer in Aalto University
Angular.js Primer in Aalto UniversitySC5.io
 
How to perform debounce in react
How to perform debounce in reactHow to perform debounce in react
How to perform debounce in reactBOSC Tech Labs
 
Julio Capote, Twitter
Julio Capote, TwitterJulio Capote, Twitter
Julio Capote, TwitterOntico
 
Getting the most out of Java [Nordic Coding-2010]
Getting the most out of Java [Nordic Coding-2010]Getting the most out of Java [Nordic Coding-2010]
Getting the most out of Java [Nordic Coding-2010]Sven Efftinge
 
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition! Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition! Michel Schudel
 
Sapphire Gimlets
Sapphire GimletsSapphire Gimlets
Sapphire GimletsRobert Cooper
 
ngMess: AngularJS Dependency Injection
ngMess: AngularJS Dependency InjectionngMess: AngularJS Dependency Injection
ngMess: AngularJS Dependency InjectionDzmitry Ivashutsin
 
Mobicents JSLEE progress and roadmap - Mobicents Summit 2011
Mobicents JSLEE progress and roadmap - Mobicents Summit 2011Mobicents JSLEE progress and roadmap - Mobicents Summit 2011
Mobicents JSLEE progress and roadmap - Mobicents Summit 2011telestax
 
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09Daniel Bryant
 
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
 Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbsAWS Chicago
 
Field injection, type safe configuration, and more new goodies in Declarative...
Field injection, type safe configuration, and more new goodies in Declarative...Field injection, type safe configuration, and more new goodies in Declarative...
Field injection, type safe configuration, and more new goodies in Declarative...bjhargrave
 
apidays LIVE Australia - Building distributed systems on the shoulders of gia...
apidays LIVE Australia - Building distributed systems on the shoulders of gia...apidays LIVE Australia - Building distributed systems on the shoulders of gia...
apidays LIVE Australia - Building distributed systems on the shoulders of gia...apidays
 
Java Configuration Deep Dive with Spring
Java Configuration Deep Dive with SpringJava Configuration Deep Dive with Spring
Java Configuration Deep Dive with SpringJoshua Long
 
Ambari Views - Overview
Ambari Views - OverviewAmbari Views - Overview
Ambari Views - OverviewHortonworks
 
Introduction to OSGi - Part-2
Introduction to OSGi - Part-2Introduction to OSGi - Part-2
Introduction to OSGi - Part-2kshanth2101
 

Similar to Scala modules (20)

OSGi DevCon 09 - OSGi on Scala
OSGi DevCon 09 - OSGi on ScalaOSGi DevCon 09 - OSGi on Scala
OSGi DevCon 09 - OSGi on Scala
 
JAX 09 - OSGi on Scala
JAX 09 - OSGi on ScalaJAX 09 - OSGi on Scala
JAX 09 - OSGi on Scala
 
ASP.Net 5 and C# 6
ASP.Net 5 and C# 6ASP.Net 5 and C# 6
ASP.Net 5 and C# 6
 
Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...
Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...
Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...
 
Angular.js Primer in Aalto University
Angular.js Primer in Aalto UniversityAngular.js Primer in Aalto University
Angular.js Primer in Aalto University
 
How to perform debounce in react
How to perform debounce in reactHow to perform debounce in react
How to perform debounce in react
 
Julio Capote, Twitter
Julio Capote, TwitterJulio Capote, Twitter
Julio Capote, Twitter
 
Getting the most out of Java [Nordic Coding-2010]
Getting the most out of Java [Nordic Coding-2010]Getting the most out of Java [Nordic Coding-2010]
Getting the most out of Java [Nordic Coding-2010]
 
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition! Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
 
Guice gin
Guice ginGuice gin
Guice gin
 
Sapphire Gimlets
Sapphire GimletsSapphire Gimlets
Sapphire Gimlets
 
ngMess: AngularJS Dependency Injection
ngMess: AngularJS Dependency InjectionngMess: AngularJS Dependency Injection
ngMess: AngularJS Dependency Injection
 
Mobicents JSLEE progress and roadmap - Mobicents Summit 2011
Mobicents JSLEE progress and roadmap - Mobicents Summit 2011Mobicents JSLEE progress and roadmap - Mobicents Summit 2011
Mobicents JSLEE progress and roadmap - Mobicents Summit 2011
 
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
 
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
 Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
 
Field injection, type safe configuration, and more new goodies in Declarative...
Field injection, type safe configuration, and more new goodies in Declarative...Field injection, type safe configuration, and more new goodies in Declarative...
Field injection, type safe configuration, and more new goodies in Declarative...
 
apidays LIVE Australia - Building distributed systems on the shoulders of gia...
apidays LIVE Australia - Building distributed systems on the shoulders of gia...apidays LIVE Australia - Building distributed systems on the shoulders of gia...
apidays LIVE Australia - Building distributed systems on the shoulders of gia...
 
Java Configuration Deep Dive with Spring
Java Configuration Deep Dive with SpringJava Configuration Deep Dive with Spring
Java Configuration Deep Dive with Spring
 
Ambari Views - Overview
Ambari Views - OverviewAmbari Views - Overview
Ambari Views - Overview
 
Introduction to OSGi - Part-2
Introduction to OSGi - Part-2Introduction to OSGi - Part-2
Introduction to OSGi - Part-2
 

More from Skills Matter

Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...Skills Matter
 
Cukeup nyc ian dees on elixir, erlang, and cucumberl
Cukeup nyc ian dees on elixir, erlang, and cucumberlCukeup nyc ian dees on elixir, erlang, and cucumberl
Cukeup nyc ian dees on elixir, erlang, and cucumberlSkills Matter
 
Cukeup nyc peter bell on getting started with cucumber.js
Cukeup nyc peter bell on getting started with cucumber.jsCukeup nyc peter bell on getting started with cucumber.js
Cukeup nyc peter bell on getting started with cucumber.jsSkills Matter
 
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...Skills Matter
 
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...Skills Matter
 
Progressive f# tutorials nyc don syme on keynote f# in the open source world
Progressive f# tutorials nyc don syme on keynote f# in the open source worldProgressive f# tutorials nyc don syme on keynote f# in the open source world
Progressive f# tutorials nyc don syme on keynote f# in the open source worldSkills Matter
 
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...Skills Matter
 
Dmitry mozorov on code quotations code as-data for f#
Dmitry mozorov on code quotations code as-data for f#Dmitry mozorov on code quotations code as-data for f#
Dmitry mozorov on code quotations code as-data for f#Skills Matter
 
A poet's guide_to_acceptance_testing
A poet's guide_to_acceptance_testingA poet's guide_to_acceptance_testing
A poet's guide_to_acceptance_testingSkills Matter
 
Russ miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-diveRuss miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-diveSkills Matter
 
Serendipity-neo4j
Serendipity-neo4jSerendipity-neo4j
Serendipity-neo4jSkills Matter
 
Simon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSimon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSkills Matter
 
Lug presentation
Lug presentationLug presentation
Lug presentationSkills Matter
 
I went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_tI went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_tSkills Matter
 
Bootstrapping a-devops-matter
Bootstrapping a-devops-matterBootstrapping a-devops-matter
Bootstrapping a-devops-matterSkills Matter
 
Personal kanban-workshop
Personal kanban-workshopPersonal kanban-workshop
Personal kanban-workshopSkills Matter
 
Agilex retrospectives
Agilex retrospectivesAgilex retrospectives
Agilex retrospectivesSkills Matter
 

More from Skills Matter (20)

Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
 
Cukeup nyc ian dees on elixir, erlang, and cucumberl
Cukeup nyc ian dees on elixir, erlang, and cucumberlCukeup nyc ian dees on elixir, erlang, and cucumberl
Cukeup nyc ian dees on elixir, erlang, and cucumberl
 
Cukeup nyc peter bell on getting started with cucumber.js
Cukeup nyc peter bell on getting started with cucumber.jsCukeup nyc peter bell on getting started with cucumber.js
Cukeup nyc peter bell on getting started with cucumber.js
 
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
 
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
 
Progressive f# tutorials nyc don syme on keynote f# in the open source world
Progressive f# tutorials nyc don syme on keynote f# in the open source worldProgressive f# tutorials nyc don syme on keynote f# in the open source world
Progressive f# tutorials nyc don syme on keynote f# in the open source world
 
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
 
Dmitry mozorov on code quotations code as-data for f#
Dmitry mozorov on code quotations code as-data for f#Dmitry mozorov on code quotations code as-data for f#
Dmitry mozorov on code quotations code as-data for f#
 
A poet's guide_to_acceptance_testing
A poet's guide_to_acceptance_testingA poet's guide_to_acceptance_testing
A poet's guide_to_acceptance_testing
 
Russ miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-diveRuss miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-dive
 
Serendipity-neo4j
Serendipity-neo4jSerendipity-neo4j
Serendipity-neo4j
 
Simon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSimon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelism
 
Plug 20110217
Plug   20110217Plug   20110217
Plug 20110217
 
Lug presentation
Lug presentationLug presentation
Lug presentation
 
I went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_tI went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_t
 
Plug saiku
Plug   saikuPlug   saiku
Plug saiku
 
Huguk lily
Huguk lilyHuguk lily
Huguk lily
 
Bootstrapping a-devops-matter
Bootstrapping a-devops-matterBootstrapping a-devops-matter
Bootstrapping a-devops-matter
 
Personal kanban-workshop
Personal kanban-workshopPersonal kanban-workshop
Personal kanban-workshop
 
Agilex retrospectives
Agilex retrospectivesAgilex retrospectives
Agilex retrospectives
 

Recently uploaded

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
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...Igalia
 
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 MenDelhi Call girls
 
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 SolutionsEnterprise Knowledge
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
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 WorkerThousandEyes
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
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 Servicegiselly40
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Recently uploaded (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
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...
 
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
 
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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
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
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

Scala modules

  • 1. ScalaModules Scala and OSGi
  • 2. OSGi Services • The key to modularity • Arguably, the key to OOP itself?
  • 4. Dr Alan Kay “Dude I invented friggin’ OOP. Have you heard of it?”
  • 5. Dr Alan Kay “OOP to me means only messaging, local retention and protection and hiding of state- process, and extreme late-binding of all things.”
  • 6. Late Binding with Services • Services answer the question:where do I get an implementation of this interface? • The registry decentralises the architecture.
  • 10.
  • 12. Dynamics • A service can come and go • At any time • On any thread • Yes... even while you’re using it
  • 13. Result • Service usage code can be very complex
  • 15. Consuming a Service public void consumeService(BundleContext context) { ServiceReference ref = context.getServiceReference(Greeting.class.getName()); Greeting greeting = (Greeting) context.getService(ref); System.out.println(greeting.getMessage()); }
  • 16. Consuming a Service public void consumeService(BundleContext context) { ServiceReference ref = context.getServiceReference(Greeting.class.getName()); Greeting greeting = (Greeting) context.getService(ref); System.out.println(greeting.getMessage()); } WRONG
  • 17. Consuming a Service public void consumeService(BundleContext context) { ServiceReference ref = context.getServiceReference(Greeting.class.getName()); if(ref != null) { Greeting greeting = (Greeting) context.getService(ref); System.out.println(greeting.getMessage()); } }
  • 18. Consuming a Service public void consumeService(BundleContext context) { ServiceReference ref = context.getServiceReference(Greeting.class.getName()); if(ref != null) { Greeting greeting = (Greeting) context.getService(ref); System.out.println(greeting.getMessage()); } } WRONG
  • 19. Consuming a Service public void consumeService(BundleContext context) { ServiceReference ref = context.getServiceReference(Greeting.class.getName()); if(ref != null) { Greeting greeting = (Greeting) context.getService(ref); if(greeting != null) { System.out.println(greeting.getMessage()); } } }
  • 20. Consuming a Service public void consumeService(BundleContext context) { ServiceReference ref = context.getServiceReference(Greeting.class.getName()); if(ref != null) { Greeting greeting = (Greeting) context.getService(ref); if(greeting != null) { System.out.println(greeting.getMessage()); } } } WRONG
  • 21. Consuming a Service public void consumeService(BundleContext context) { ServiceReference ref = context.getServiceReference(Greeting.class.getName()); if(ref != null) { Greeting greeting = (Greeting) context.getService(ref); if(greeting != null) { System.out.println(greeting.getMessage()); } context.ungetService(ref); } }
  • 22. Consuming a Service public void consumeService(BundleContext context) { ServiceReference ref = context.getServiceReference(Greeting.class.getName()); if(ref != null) { Greeting greeting = (Greeting) context.getService(ref); if(greeting != null) { System.out.println(greeting.getMessage()); } context.ungetService(ref); } } WRONG
  • 23. Consuming a Service public void consumeService(BundleContext context) { ServiceReference ref = context.getServiceReference(Greeting.class.getName()); if(ref != null) { try { Greeting greeting = (Greeting) context.getService(ref); if(greeting != null) { System.out.println(greeting.getMessage()); } } finally { context.ungetService(ref); } } }
  • 24. Consuming a Service public void consumeService(BundleContext context) { ServiceReference ref = context.getServiceReference(Greeting.class.getName()); if(ref != null) { try { Greeting greeting = (Greeting) context.getService(ref); if(greeting != null) { System.out.println(greeting.getMessage()); } } finally { context.ungetService(ref); } } } NOT TYPE SAFE
  • 25. Consuming a Service public void consumeService(BundleContext context) { ServiceReference ref = context.getServiceReference(Greeting.class.getName()); if(ref != null) { try { Greeting greeting = (Greeting) context.getService(ref); if(greeting != null) { System.out.println(greeting.getMessage()); } } finally { context.ungetService(ref); } } } NOT TYPE SAFE
  • 27. Declarative Services (DS) @Reference public void setGreeting(Greeting greeting) { this.greeting = greeting; } public void consumeService() { System.out.println(greeting.getMessage()); }
  • 28. Blueprint public void setGreeting(Greeting greeting) { this.greeting = greeting; } public void consumeService() { System.out.println(greeting.getMessage()); } <blueprint> <reference id="greeting" interface="org.example.Greeting"/> <bean id="foo" class="com.foo.Foo"/> <property name="greeting" ref="greeting"/> </bean> </blueprint>
  • 29. Problem • These frameworks provide abstractions • Abstraction hide detail • Sometimes we need the detail
  • 30. Example: Cardinality? Service Service Component Service Service
  • 31. Single Service Service Component Service Service
  • 32. Multiple Service Service Component Service Service
  • 33. ??? Component Service Component Service Component Service Component Service Not supported by DS
  • 34. Declarative I Services (and Blueprint)
  • 35. Declarative I Services (and Blueprint)
  • 36. The “80%” Solution “Normal” Users
  • 37. The “80%” Solution “Normal” Users DS support
  • 38. The “80%” Solution “Normal” Users DS support
  • 39. The “80%” Solution “Normal” Users DS support “Power” Users
  • 40. The “80%” Solution “Normal” Users DS support “Power” Users
  • 41. The “80%” Solution “Normal” Users DS support “Power” Users Easy in Java
  • 42. The “80%” Solution “Normal” Users DS support “Power” Users Easy in Java
  • 43. The “80%” Solution “Normal” Users DS support “Power” Users Easy in Java Easy in Scala
  • 44. The “80%” Solution “Normal” Users DS support “Power” Users Easy in Java Easy in Scala
  • 45. Java ServiceTracker tracker = new ServiceTracker(context, Greeting.class.getName(), new ServiceTrackerCustomizer() { public Object addingService(ServiceReference reference) { Greeting greeting = (Greeting) context.getService(reference); ServiceRegistration reg = context.registerService(IFoo.class.getName(), new Foo(greeting), null); return reg; } public void modifiedService(ServiceReference reference, Object service) { } public void removedService(ServiceReference reference, Object service) { ServiceRegistration reg = (ServiceRegistration) service; reg.unregister(); } });
  • 46. Java ServiceTracker tracker = new ServiceTracker(context, Greeting.class.getName(), new ServiceTrackerCustomizer() { public Object addingService(ServiceReference reference) { Greeting greeting = (Greeting) context.getService(reference); ServiceRegistration reg = context.registerService(IFoo.class.getName(), new Foo(greeting), null); return reg; } public void modifiedService(ServiceReference reference, Object service) { } public void removedService(ServiceReference reference, Object service) { ServiceRegistration reg = (ServiceRegistration) service; reg.unregister(); } }); Type Safety???
  • 48. NOT Another Module System (phew!)
  • 49.
  • 50.
  • 51. “A Scala internal DSL to ease OSGi development”
  • 52. • Now: • Services • Future: • Extender Pattern? • Resources?
  • 55. Java ServiceTracker tracker = new ServiceTracker(context, Greeting.class.getName(), new ServiceTrackerCustomizer() { public Object addingService(ServiceReference reference) { Greeting greeting = (Greeting) context.getService(reference); ServiceRegistration reg = context.registerService(IFoo.class.getName(), new Foo(greeting), null); return reg; } public void modifiedService(ServiceReference reference, Object service) { } public void removedService(ServiceReference reference, Object service) { ServiceRegistration reg = (ServiceRegistration) service; reg.unregister(); } });
  • 56. ScalaModules val greetingTrack = context track classOf[Greeting] on { case Adding(greeting) => context createService (classOf[IFoo], new Foo(greeting)) case Removed(_, reg) => reg unregister }
  • 57. Plan • Started moving the code & docs to Eclipse • 19 March: M1 • 7 May: M2 • 28 May: RC1 • 11 June: RC2 • 23 June: ScalaModules 2.0 Release & Graduation