SlideShare una empresa de Scribd logo
1 de 25
peaberry Stuart McCulloch
Today's menu Origin of peaberry OSGi-fying Guice Service providers Service registry abstraction Blending services & extensions Future ideas
Origin Began as lab project at community site new annotations @Inject @OSGiService("(Currency=GBP)") StockQuote quote; patched Guice to support service “auto-binding” @OSGiService(...) StockQuote quote; // magically added for you bind(StockQuote.class)...
Simplification Auto-binding introduced too much magic @Inject @OSGiService("(Currency=GBP)") StockQuote quote; NO new annotations service bindings now explicit, just like pure Guice  aim to be a true extension to Guice – no patches! so...
Squeezing Guice into a bundle Guice now has OSGi metadata thanks to Guice's type-safety meant no major classloading issues ... but AOP proxies initially didn't work in OSGi AOP proxies need to see client types AOP support types BND internal &
Bridge class loader Don't want to expose AOP internals (repackaged CGLIB) parent parent com.google.inject.internal.* loadClass loadClass so load proxy classes using “bridge” class loaders
Bridge class loader (2) No dependency on OSGi ! – only used when needed of bridge classloaders allows re-use ... as well as eager unloading of proxy classes BUT cannot apply bridging to  package-private  types as not visible from other classloaders weak cache
Why peaberry? Guice can now be used in OSGi – so what's missing? no support for dynamic OSGi services! each injector uses immutable set of explicit bindings so ... new  Injector  on every service change? or ...  Provider<T>  that returns dynamic proxies? :( :)
Service Provider @Inject StockQuote quote; quote.price(“JAVA”); get unget price injector get K P K P K P P Service Registry p r o x y p r o x y
Service binding Fluent API helps you get the right service  Provider<T> bind( iterable( A.class ) ).toProvider( service( A.class ).multiple() ); @Inject A bestService; @Inject Iterable<A> allServices; // each element is a proxy import static org.ops4j.peaberry.Peaberry.service; import static org.ops4j.peaberry.util.TypeLiterals.iterable; * bind( A.class ).toProvider( service( A.class ).single() );
Service binding (2) So is that it? s:
Service binding (2) So is that it? ... no, you can also service( A.class ).filter( /* apply a filter */ )... service( A.class ).in( /* query a specific registry */ )... service( A.class ).out( /* watch for service changes */ )... service( A.class ).decoratedWith( /* apply decoration */ )... each stage of the builder creates an immutable copy which means you can share and re-use builders
Service Registry public   interface  ServiceRegistry { <T> Iterable<Import<T>> lookup(Class<T> clazz, AttributeFilter filter); <T>  void  watch(Class<T> clazz, AttributeFilter filter, ServiceWatcher<?  super  T> watcher); } public   interface  AttributeFilter { boolean  matches(Map<String, ?> attributes); } Pluggable API – integrate all kinds of service registries simple, allows lazines s z z z , no dependency on OSGi service filters not just limited to LDAP strings but we do provide an LDAP adapter (among others)
Import public   interface  Import<T> { T get();  // may throw unchecked ServiceUnavailableException Map <String, ?> attributes(); void  unget(); boolean  available(); } Tracking service use is very important ! public   interface  ImportDecorator<S> { <T  extends  S> Import<T> decorate(Import<T> service); } can easily apply deco to change dynamic behaviour (e.g. sticky services) ation to imported services
Concurrent Import public   synchronized  T get() { count ++; if  ( null  ==  service ) { final  Iterator<Import<T>> i =  services .iterator(); if  (i.hasNext()) { service  = i.next(); instance  =  service .get(); } } return   instance ; } public   synchronized   void  unget() { if  (0 == -- count  &&  null  !=  service ) { final  Import<T> temp =  service ; instance  =  null ; service  =  null ; temp.unget(); } } Single services wrap iterables to look like single imports avoids thread-locals, provides basic service affinity
Export What's the opposite of a imported service? hint
Export public   interface  Export<T> { void  put(T instance); void  attributes(Map<String, ?> attributes); void  unput(); } Can alter/remove exported instance, update attributes public   interface  ServiceWatcher<S> { <T  extends  S> Export<T> add(Import<T> service); } watchers can receive imports and (re-)export them but wait, isn't a registry a bit like a watcher?
Service Registry (revisited) public   interface  ServiceRegistry extends  ServiceWatcher<Object> {  // etc... public   interface  Export<T> extends  Import<T> {  // etc... which leads to interesting possibilities ... Yes, and exports are also related to imports // like pushing services from one registry to another for (Import<A> i : extensionRegistry.lookup(A.class, null)) { serviceRegistry.add(i); } but you  don't  have to use the raw API  to export
Service binding (revisited) Exported service handles can be injected bind( export( A.class ) ).toProvider( service( (A)null ).export() ); @Inject Export<A> exportedService; import static org.ops4j.peaberry.Peaberry.service; import static org.ops4j.peaberry.util.TypeLiterals.export; * bind( export( A.class ) ).toProvider( service( aImpl ).export() ); otherwise published when export handle is created can defer publishing a service by passing in null
Eclipse extensions Eclipse has its own registry for plug-in this is like another service registry, but less dynamic extensions so ... how can we map the service class to an instance? take inspiration from Eclipse Riena, use bean mapping ! unless its a compatible executable extension OR  we're looking up  IconfigurationElement  class
Mapping extensions Use  @MapName,   @MapContent  from peaberry or Riena Same approach as Riena for mapping bean types But use  @ExtensionBean  to configure point id @ExtensionBean(&quot;examples.menu.items&quot;) public interface Item { String getLabel(); @MapName(&quot;label&quot;) String toString(); @MapContent String getContent(); }
Injecting extensions <extension point=&quot;org.eclipse.ui.views&quot;> <view name=&quot;Message&quot; allowMultiple=&quot;true&quot; icon=&quot;icons/sample2.gif&quot; class=&quot;example.ViewImpl&quot; id=&quot;example.view&quot; /> </extension> <extension point=&quot;org.eclipse.ui.views&quot;> <view name=&quot;Message&quot; allowMultiple=&quot;true&quot; icon=&quot;icons/sample2.gif&quot; class=&quot; org.ops4j.peaberry.eclipse.GuiceExtensionFactory : example.ViewImpl&quot; id=&quot;example.view&quot; /> </extension> <extension point=&quot;org.ops4j.peaberry.eclipse.modules&quot;> <module class=&quot;example.ViewModule&quot; /> </extension> GuiceExtensionFactory, similar approach as Spring becomes
Blending services and extensions binder.install(osgiModule(context, eclipseRegistry())); peaberry 1.1-rc2 lets you combine registries Clients can continue to use the same injection points @Inject StockQuote quote; YOU can choose where the service comes from or even whether to use a dynamic service at all ! service proxies will then query both OSGi and
Summary Guice can now be used in OSGi peaberry adds  dynamic   services to Guice model easy to switch between services and non-services can mix'n'match coming soon: lifecycles, configuration support ... like OSGi services and Eclipse extensions different service registries
Questions?

Más contenido relacionado

La actualidad más candente

Full-Stack Reactive with Spring WebFlux + Angular - JConf Colombia 2019
Full-Stack Reactive with Spring WebFlux + Angular - JConf Colombia 2019Full-Stack Reactive with Spring WebFlux + Angular - JConf Colombia 2019
Full-Stack Reactive with Spring WebFlux + Angular - JConf Colombia 2019Loiane Groner
 
Protocol in Swift
Protocol in SwiftProtocol in Swift
Protocol in SwiftYusuke Kita
 
Functional Javascript
Functional JavascriptFunctional Javascript
Functional Javascriptguest4d57e6
 
Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018
Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018
Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018Loiane Groner
 
Computer notes - Reference Variables –II
Computer notes  - Reference Variables –IIComputer notes  - Reference Variables –II
Computer notes - Reference Variables –IIecomputernotes
 
Full-Stack Reativo com Spring WebFlux + Angular - Devs Java Girl
Full-Stack Reativo com Spring WebFlux + Angular - Devs Java GirlFull-Stack Reativo com Spring WebFlux + Angular - Devs Java Girl
Full-Stack Reativo com Spring WebFlux + Angular - Devs Java GirlLoiane Groner
 
computer notes - Data Structures - 18
computer notes - Data Structures - 18computer notes - Data Structures - 18
computer notes - Data Structures - 18ecomputernotes
 
Functional Reactive Endpoints using Spring 5
Functional Reactive Endpoints using Spring 5Functional Reactive Endpoints using Spring 5
Functional Reactive Endpoints using Spring 5Rory Preddy
 
Gerenciamento de estado no Angular com NgRx
Gerenciamento de estado no Angular com NgRxGerenciamento de estado no Angular com NgRx
Gerenciamento de estado no Angular com NgRxLoiane Groner
 
06. operator overloading
06. operator overloading06. operator overloading
06. operator overloadingHaresh Jaiswal
 
JavaScript Functions
JavaScript FunctionsJavaScript Functions
JavaScript FunctionsColin DeCarlo
 
Inline and lambda function
Inline and lambda functionInline and lambda function
Inline and lambda functionJawad Khan
 
The Ring programming language version 1.5.2 book - Part 79 of 181
The Ring programming language version 1.5.2 book - Part 79 of 181The Ring programming language version 1.5.2 book - Part 79 of 181
The Ring programming language version 1.5.2 book - Part 79 of 181Mahmoud Samir Fayed
 
Commit University - Exploring Angular 2
Commit University - Exploring Angular 2Commit University - Exploring Angular 2
Commit University - Exploring Angular 2Commit University
 
Mobile Fest 2018. Кирилл Розов. Insert Koin
Mobile Fest 2018. Кирилл Розов. Insert KoinMobile Fest 2018. Кирилл Розов. Insert Koin
Mobile Fest 2018. Кирилл Розов. Insert KoinMobileFest2018
 
Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Eliran Eliassy
 

La actualidad más candente (20)

Full-Stack Reactive with Spring WebFlux + Angular - JConf Colombia 2019
Full-Stack Reactive with Spring WebFlux + Angular - JConf Colombia 2019Full-Stack Reactive with Spring WebFlux + Angular - JConf Colombia 2019
Full-Stack Reactive with Spring WebFlux + Angular - JConf Colombia 2019
 
Protocol in Swift
Protocol in SwiftProtocol in Swift
Protocol in Swift
 
Ngrx meta reducers
Ngrx meta reducersNgrx meta reducers
Ngrx meta reducers
 
Functional Javascript
Functional JavascriptFunctional Javascript
Functional Javascript
 
Angular2 + rxjs
Angular2 + rxjsAngular2 + rxjs
Angular2 + rxjs
 
Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018
Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018
Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018
 
Computer notes - Reference Variables –II
Computer notes  - Reference Variables –IIComputer notes  - Reference Variables –II
Computer notes - Reference Variables –II
 
Full-Stack Reativo com Spring WebFlux + Angular - Devs Java Girl
Full-Stack Reativo com Spring WebFlux + Angular - Devs Java GirlFull-Stack Reativo com Spring WebFlux + Angular - Devs Java Girl
Full-Stack Reativo com Spring WebFlux + Angular - Devs Java Girl
 
computer notes - Data Structures - 18
computer notes - Data Structures - 18computer notes - Data Structures - 18
computer notes - Data Structures - 18
 
Functional Reactive Endpoints using Spring 5
Functional Reactive Endpoints using Spring 5Functional Reactive Endpoints using Spring 5
Functional Reactive Endpoints using Spring 5
 
Gerenciamento de estado no Angular com NgRx
Gerenciamento de estado no Angular com NgRxGerenciamento de estado no Angular com NgRx
Gerenciamento de estado no Angular com NgRx
 
06. operator overloading
06. operator overloading06. operator overloading
06. operator overloading
 
JavaScript Functions
JavaScript FunctionsJavaScript Functions
JavaScript Functions
 
Inline and lambda function
Inline and lambda functionInline and lambda function
Inline and lambda function
 
The Ring programming language version 1.5.2 book - Part 79 of 181
The Ring programming language version 1.5.2 book - Part 79 of 181The Ring programming language version 1.5.2 book - Part 79 of 181
The Ring programming language version 1.5.2 book - Part 79 of 181
 
Lecture5
Lecture5Lecture5
Lecture5
 
Capstone ms2
Capstone ms2Capstone ms2
Capstone ms2
 
Commit University - Exploring Angular 2
Commit University - Exploring Angular 2Commit University - Exploring Angular 2
Commit University - Exploring Angular 2
 
Mobile Fest 2018. Кирилл Розов. Insert Koin
Mobile Fest 2018. Кирилл Розов. Insert KoinMobile Fest 2018. Кирилл Розов. Insert Koin
Mobile Fest 2018. Кирилл Розов. Insert Koin
 
Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics
 

Similar a Peaberry - Blending Services And Extensions

The Web on OSGi: Here's How
The Web on OSGi: Here's HowThe Web on OSGi: Here's How
The Web on OSGi: Here's Howmrdon
 
Wcf data services
Wcf data servicesWcf data services
Wcf data servicesEyal Vardi
 
Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy codeShriKant Vashishtha
 
Category theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) DataCategory theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) Datagreenwop
 
Interoperable Web Services with JAX-WS
Interoperable Web Services with JAX-WSInteroperable Web Services with JAX-WS
Interoperable Web Services with JAX-WSCarol McDonald
 
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-publicJavazone 2010-lift-framework-public
Javazone 2010-lift-framework-publicTimothy Perrett
 
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...Roel Hartman
 
AngularJS - Services
AngularJS - ServicesAngularJS - Services
AngularJS - ServicesNir Kaufman
 
JSP diana y yo
JSP diana y yoJSP diana y yo
JSP diana y yomichael
 
Angular resolver tutorial
Angular resolver tutorialAngular resolver tutorial
Angular resolver tutorialKaty Slemon
 
The battle of Protractor and Cypress - RunIT Conference 2019
The battle of Protractor and Cypress - RunIT Conference 2019The battle of Protractor and Cypress - RunIT Conference 2019
The battle of Protractor and Cypress - RunIT Conference 2019Ludmila Nesvitiy
 
Introduction to Everit Component Registry - B Zsoldos
Introduction to Everit Component Registry - B ZsoldosIntroduction to Everit Component Registry - B Zsoldos
Introduction to Everit Component Registry - B Zsoldosmfrancis
 
OpenSocial Intro
OpenSocial IntroOpenSocial Intro
OpenSocial IntroPamela Fox
 
Building real-time collaborative apps with Ajax.org Platform
Building real-time collaborative apps with Ajax.org PlatformBuilding real-time collaborative apps with Ajax.org Platform
Building real-time collaborative apps with Ajax.org PlatformJaveline B.V.
 

Similar a Peaberry - Blending Services And Extensions (20)

The Web on OSGi: Here's How
The Web on OSGi: Here's HowThe Web on OSGi: Here's How
The Web on OSGi: Here's How
 
Wcf data services
Wcf data servicesWcf data services
Wcf data services
 
Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy code
 
Intro to RX
Intro to RXIntro to RX
Intro to RX
 
Category theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) DataCategory theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) Data
 
GWT
GWTGWT
GWT
 
Gooogle Web Toolkit
Gooogle Web ToolkitGooogle Web Toolkit
Gooogle Web Toolkit
 
Interoperable Web Services with JAX-WS
Interoperable Web Services with JAX-WSInteroperable Web Services with JAX-WS
Interoperable Web Services with JAX-WS
 
Qt Workshop
Qt WorkshopQt Workshop
Qt Workshop
 
WCF - In a Week
WCF - In a WeekWCF - In a Week
WCF - In a Week
 
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-publicJavazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
 
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
 
AngularJS - Services
AngularJS - ServicesAngularJS - Services
AngularJS - Services
 
JSP diana y yo
JSP diana y yoJSP diana y yo
JSP diana y yo
 
Angular resolver tutorial
Angular resolver tutorialAngular resolver tutorial
Angular resolver tutorial
 
The battle of Protractor and Cypress - RunIT Conference 2019
The battle of Protractor and Cypress - RunIT Conference 2019The battle of Protractor and Cypress - RunIT Conference 2019
The battle of Protractor and Cypress - RunIT Conference 2019
 
Introduction to Everit Component Registry - B Zsoldos
Introduction to Everit Component Registry - B ZsoldosIntroduction to Everit Component Registry - B Zsoldos
Introduction to Everit Component Registry - B Zsoldos
 
OpenSocial Intro
OpenSocial IntroOpenSocial Intro
OpenSocial Intro
 
Building real-time collaborative apps with Ajax.org Platform
Building real-time collaborative apps with Ajax.org PlatformBuilding real-time collaborative apps with Ajax.org Platform
Building real-time collaborative apps with Ajax.org Platform
 
Google Web Toolkit
Google Web ToolkitGoogle Web Toolkit
Google Web Toolkit
 

Último

Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Paige Cruz
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxjbellis
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxFIDO Alliance
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityVictorSzoltysek
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctBrainSell Technologies
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxMasterG
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxFIDO Alliance
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....rightmanforbloodline
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsLeah Henrickson
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTopCSSGallery
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfalexjohnson7307
 
CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)Wonjun Hwang
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightSafe Software
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfdanishmna97
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data SciencePaolo Missier
 
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...SOFTTECHHUB
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهMohamed Sweelam
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxMarkSteadman7
 

Último (20)

Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development Companies
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdf
 
CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهله
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 

Peaberry - Blending Services And Extensions

  • 2. Today's menu Origin of peaberry OSGi-fying Guice Service providers Service registry abstraction Blending services & extensions Future ideas
  • 3. Origin Began as lab project at community site new annotations @Inject @OSGiService(&quot;(Currency=GBP)&quot;) StockQuote quote; patched Guice to support service “auto-binding” @OSGiService(...) StockQuote quote; // magically added for you bind(StockQuote.class)...
  • 4. Simplification Auto-binding introduced too much magic @Inject @OSGiService(&quot;(Currency=GBP)&quot;) StockQuote quote; NO new annotations service bindings now explicit, just like pure Guice aim to be a true extension to Guice – no patches! so...
  • 5. Squeezing Guice into a bundle Guice now has OSGi metadata thanks to Guice's type-safety meant no major classloading issues ... but AOP proxies initially didn't work in OSGi AOP proxies need to see client types AOP support types BND internal &
  • 6. Bridge class loader Don't want to expose AOP internals (repackaged CGLIB) parent parent com.google.inject.internal.* loadClass loadClass so load proxy classes using “bridge” class loaders
  • 7. Bridge class loader (2) No dependency on OSGi ! – only used when needed of bridge classloaders allows re-use ... as well as eager unloading of proxy classes BUT cannot apply bridging to package-private types as not visible from other classloaders weak cache
  • 8. Why peaberry? Guice can now be used in OSGi – so what's missing? no support for dynamic OSGi services! each injector uses immutable set of explicit bindings so ... new Injector on every service change? or ... Provider<T> that returns dynamic proxies? :( :)
  • 9. Service Provider @Inject StockQuote quote; quote.price(“JAVA”); get unget price injector get K P K P K P P Service Registry p r o x y p r o x y
  • 10. Service binding Fluent API helps you get the right service Provider<T> bind( iterable( A.class ) ).toProvider( service( A.class ).multiple() ); @Inject A bestService; @Inject Iterable<A> allServices; // each element is a proxy import static org.ops4j.peaberry.Peaberry.service; import static org.ops4j.peaberry.util.TypeLiterals.iterable; * bind( A.class ).toProvider( service( A.class ).single() );
  • 11. Service binding (2) So is that it? s:
  • 12. Service binding (2) So is that it? ... no, you can also service( A.class ).filter( /* apply a filter */ )... service( A.class ).in( /* query a specific registry */ )... service( A.class ).out( /* watch for service changes */ )... service( A.class ).decoratedWith( /* apply decoration */ )... each stage of the builder creates an immutable copy which means you can share and re-use builders
  • 13. Service Registry public interface ServiceRegistry { <T> Iterable<Import<T>> lookup(Class<T> clazz, AttributeFilter filter); <T> void watch(Class<T> clazz, AttributeFilter filter, ServiceWatcher<? super T> watcher); } public interface AttributeFilter { boolean matches(Map<String, ?> attributes); } Pluggable API – integrate all kinds of service registries simple, allows lazines s z z z , no dependency on OSGi service filters not just limited to LDAP strings but we do provide an LDAP adapter (among others)
  • 14. Import public interface Import<T> { T get(); // may throw unchecked ServiceUnavailableException Map <String, ?> attributes(); void unget(); boolean available(); } Tracking service use is very important ! public interface ImportDecorator<S> { <T extends S> Import<T> decorate(Import<T> service); } can easily apply deco to change dynamic behaviour (e.g. sticky services) ation to imported services
  • 15. Concurrent Import public synchronized T get() { count ++; if ( null == service ) { final Iterator<Import<T>> i = services .iterator(); if (i.hasNext()) { service = i.next(); instance = service .get(); } } return instance ; } public synchronized void unget() { if (0 == -- count && null != service ) { final Import<T> temp = service ; instance = null ; service = null ; temp.unget(); } } Single services wrap iterables to look like single imports avoids thread-locals, provides basic service affinity
  • 16. Export What's the opposite of a imported service? hint
  • 17. Export public interface Export<T> { void put(T instance); void attributes(Map<String, ?> attributes); void unput(); } Can alter/remove exported instance, update attributes public interface ServiceWatcher<S> { <T extends S> Export<T> add(Import<T> service); } watchers can receive imports and (re-)export them but wait, isn't a registry a bit like a watcher?
  • 18. Service Registry (revisited) public interface ServiceRegistry extends ServiceWatcher<Object> { // etc... public interface Export<T> extends Import<T> { // etc... which leads to interesting possibilities ... Yes, and exports are also related to imports // like pushing services from one registry to another for (Import<A> i : extensionRegistry.lookup(A.class, null)) { serviceRegistry.add(i); } but you don't have to use the raw API to export
  • 19. Service binding (revisited) Exported service handles can be injected bind( export( A.class ) ).toProvider( service( (A)null ).export() ); @Inject Export<A> exportedService; import static org.ops4j.peaberry.Peaberry.service; import static org.ops4j.peaberry.util.TypeLiterals.export; * bind( export( A.class ) ).toProvider( service( aImpl ).export() ); otherwise published when export handle is created can defer publishing a service by passing in null
  • 20. Eclipse extensions Eclipse has its own registry for plug-in this is like another service registry, but less dynamic extensions so ... how can we map the service class to an instance? take inspiration from Eclipse Riena, use bean mapping ! unless its a compatible executable extension OR we're looking up IconfigurationElement class
  • 21. Mapping extensions Use @MapName, @MapContent from peaberry or Riena Same approach as Riena for mapping bean types But use @ExtensionBean to configure point id @ExtensionBean(&quot;examples.menu.items&quot;) public interface Item { String getLabel(); @MapName(&quot;label&quot;) String toString(); @MapContent String getContent(); }
  • 22. Injecting extensions <extension point=&quot;org.eclipse.ui.views&quot;> <view name=&quot;Message&quot; allowMultiple=&quot;true&quot; icon=&quot;icons/sample2.gif&quot; class=&quot;example.ViewImpl&quot; id=&quot;example.view&quot; /> </extension> <extension point=&quot;org.eclipse.ui.views&quot;> <view name=&quot;Message&quot; allowMultiple=&quot;true&quot; icon=&quot;icons/sample2.gif&quot; class=&quot; org.ops4j.peaberry.eclipse.GuiceExtensionFactory : example.ViewImpl&quot; id=&quot;example.view&quot; /> </extension> <extension point=&quot;org.ops4j.peaberry.eclipse.modules&quot;> <module class=&quot;example.ViewModule&quot; /> </extension> GuiceExtensionFactory, similar approach as Spring becomes
  • 23. Blending services and extensions binder.install(osgiModule(context, eclipseRegistry())); peaberry 1.1-rc2 lets you combine registries Clients can continue to use the same injection points @Inject StockQuote quote; YOU can choose where the service comes from or even whether to use a dynamic service at all ! service proxies will then query both OSGi and
  • 24. Summary Guice can now be used in OSGi peaberry adds dynamic services to Guice model easy to switch between services and non-services can mix'n'match coming soon: lifecycles, configuration support ... like OSGi services and Eclipse extensions different service registries