SlideShare una empresa de Scribd logo
1 de 21
Using OSGi in Nakamura Carl Hall [email_address] Hallway Technologies 15 June 2010
Overview ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],11th Sakai Conference - June 15-17, 2010
Starting Lineup ,[object Object],[object Object],[object Object],[object Object],11th Sakai Conference - June 15-17, 2010
Bundles   11th Sakai Conference - June 15-17, 2010
Bundle Life Cycle ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],11th Sakai Conference - June 15-17, 2010
Bundle Activation import   org.osgi.framework.BundleActivator ; import   org.osgi.framework.BundleContext ; public   class   Activator   implements  BundleActivator  { public   void  start ( BundleContext context )   { System . out . println ( "Starting: Hello World" ) ; } public   void  stop ( BundleContext context )   { System . out . println ( "Stopping: Goodbye Cruel World" ) ; } } Source: Wikipedia 11th Sakai Conference - June 15-17, 2010
Components   11th Sakai Conference - June 15-17, 2010
Types of Components ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],11th Sakai Conference - June 15-17, 2010
Service Example @Component @Service public class LdapAuthenticationPlugin implements AuthenticationPlugin {    @Property(value = &quot;o=sakai&quot;)    static final String LDAP_BASE_DN = &quot;sakai.auth.ldap.baseDn&quot;;    private String baseDn;    @Reference    private LdapConnectionManager connMgr;    @Activate    protected void activate(Map<?, ?> props) {      baseDn = OsgiUtil.toString(props.get(LDAP_BASE_DN), &quot;o=sakai&quot;);    } } 11th Sakai Conference - June 15-17, 2010
Component Execution @Activate protected void activate(ComponentContext ctx) {} protected void activate(BundleContext ctx) {} protected void activate(Map<?, ?> props) {} @Modified protected void modified(...) {} @Deactivate protected void deactivate(...) {} protected void deactivate(int reasonCode) {} 11th Sakai Conference - June 15-17, 2010
OSGi Services ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],11th Sakai Conference - June 15-17, 2010 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Dependency Injection   11th Sakai Conference - June 15-17, 2010
References ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],11th Sakai Conference - June 15-17, 2010
References public class GetAReference {    @Reference    ConnectionManager connMgr; } ----------------------------------------------------------------- @Component @Service public class LdapConnectionManager implements ConnectionManager { } @Component @Service public class JdbcConnectionManager implements ConnectionManager { } 11th Sakai Conference - June 15-17, 2010
Single Instance Reference // OPTIONAL_UNARY == &quot;0..1&quot; // MANDATORY_UNARY == &quot;1..1&quot; @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY,    policy = ReferencePolicy.STATIC) ConnectionManager connMgr; protected void bindConnMgr(ConnectionManager mgr) {    this.connMgr = mgr; } protected void unbindConnMgr(ConnectionManager mgr) {    this.connMgr = null; } 11th Sakai Conference - June 15-17, 2010
Multiple Instance Reference // OPTIONAL_MULTIPLE == &quot;0..n&quot; // MANDATORY_MULTIPLE == &quot;1..n&quot; @Reference(cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,    policy = ReferencePolicy.DYNAMIC,    referenceInterface = ConnectionManager.class,    bind = &quot;bindManager&quot;,    unbind = &quot;unbindManager&quot;) List<ConnectionManager> managers;  // be sure to instantiate this protected void bindManager(ConnectionManager mgr) {    managers.add(mgr); } protected void unbindManager(ConnectionManager mgr) {    managers.remove(mgr); } 11th Sakai Conference - June 15-17, 2010
Reference Target @Reference PooledConnectionManager connMgr;  //boo! @Reference(target = &quot;(type=pooled)&quot;) ConnectionManager connMgr;  //yay! ----------------------------------------------------------------- @Component @Service @Property(name = &quot;type&quot;, value = &quot;simple&quot;) public class SimpleCM implements ConnectionManager {} @Component @Service @Property(name = &quot;type&quot;, value = &quot;pooled&quot;) public class PooledCM implements ConnectionManager {} 11th Sakai Conference - June 15-17, 2010
Configuration   11th Sakai Conference - June 15-17, 2010
Felix Admin Console 11th Sakai Conference - June 15-17, 2010
New Service Configuration @Reference ConfigurationAdmin cfgAdmin; @Activate protected void activate() {    Configuration cfg =      cfgAdmin.createFactoryConfiguration(&quot;some.factory.pid&quot;);    Hashtable props = new Hashtable();    props.put(&quot;key1&quot;, &quot;val1&quot;);    props.put(&quot;key2&quot;, &quot;val2&quot;);    config.update(props); } 11th Sakai Conference - June 15-17, 2010
Configure A Reference @Reference ConnectionManager connMgr; ----------------------------------------------------------------- @Reference ConfigurationAdmin cfgAdmin; @Activate protected void activate() {    Configuration cfg =      cfgAdmin.createFactoryConfiguration(&quot;some.factory.pid&quot;);    Hashtable props = new Hashtable();    props.put(&quot;connMgr.target&quot;, &quot;(type=pooled)&quot;);    config.update(props); } 11th Sakai Conference - June 15-17, 2010

Más contenido relacionado

La actualidad más candente

Chapter 4.2
Chapter 4.2Chapter 4.2
Chapter 4.2
sotlsoc
 

La actualidad más candente (14)

Sagas Middleware Architecture
Sagas Middleware ArchitectureSagas Middleware Architecture
Sagas Middleware Architecture
 
Azure Durable Functions (2019-03-30)
Azure Durable Functions (2019-03-30) Azure Durable Functions (2019-03-30)
Azure Durable Functions (2019-03-30)
 
Serverless APIs, the Good, the Bad and the Ugly (2019-09-19)
Serverless APIs, the Good, the Bad and the Ugly (2019-09-19)Serverless APIs, the Good, the Bad and the Ugly (2019-09-19)
Serverless APIs, the Good, the Bad and the Ugly (2019-09-19)
 
Workshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 20: ReactJS Part II Flux Pattern & ReduxWorkshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 20: ReactJS Part II Flux Pattern & Redux
 
Azure Durable Functions
Azure Durable FunctionsAzure Durable Functions
Azure Durable Functions
 
Chapter 4.2
Chapter 4.2Chapter 4.2
Chapter 4.2
 
Developing JSR 286 Portlets
Developing JSR 286 PortletsDeveloping JSR 286 Portlets
Developing JSR 286 Portlets
 
Magento Imagine eCommerce Conference - February 2011 - Unit Testing with Magento
Magento Imagine eCommerce Conference - February 2011 - Unit Testing with MagentoMagento Imagine eCommerce Conference - February 2011 - Unit Testing with Magento
Magento Imagine eCommerce Conference - February 2011 - Unit Testing with Magento
 
CC111 Example
CC111 ExampleCC111 Example
CC111 Example
 
React + Redux. Best practices
React + Redux.  Best practicesReact + Redux.  Best practices
React + Redux. Best practices
 
Portlet Specification 3.0 Is Here!
Portlet Specification 3.0 Is Here! Portlet Specification 3.0 Is Here!
Portlet Specification 3.0 Is Here!
 
Java9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidadJava9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidad
 
Repetition is bad, repetition is bad.
Repetition is bad, repetition is bad.Repetition is bad, repetition is bad.
Repetition is bad, repetition is bad.
 
What is new in java 8 concurrency
What is new in java 8 concurrencyWhat is new in java 8 concurrency
What is new in java 8 concurrency
 

Destacado (8)

Why erlang
Why erlangWhy erlang
Why erlang
 
S3CA Samples
S3CA SamplesS3CA Samples
S3CA Samples
 
UX Programming: The Sakai 3 Approach
UX Programming: The Sakai 3 ApproachUX Programming: The Sakai 3 Approach
UX Programming: The Sakai 3 Approach
 
Man in the Mirror
Man in the MirrorMan in the Mirror
Man in the Mirror
 
Confidence Instantly
Confidence Instantly Confidence Instantly
Confidence Instantly
 
Mark Colthorpe Show
Mark Colthorpe ShowMark Colthorpe Show
Mark Colthorpe Show
 
þágufallssýki
þágufallssýki þágufallssýki
þágufallssýki
 
20 Points For Quality And Pi V2.3
20 Points For Quality And Pi V2.320 Points For Quality And Pi V2.3
20 Points For Quality And Pi V2.3
 

Similar a Using OSGi in Nakamura

Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)
Gunith Devasurendra
 
Declarative Services - Dependency Injection OSGi Style
Declarative Services - Dependency Injection OSGi StyleDeclarative Services - Dependency Injection OSGi Style
Declarative Services - Dependency Injection OSGi Style
Felix Meschberger
 

Similar a Using OSGi in Nakamura (20)

Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...
Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...
Pavlo Zhdanov "Java and Swift: How to Create Applications for Automotive Head...
 
dokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdf
dokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdfdokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdf
dokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdf
 
dokumen.tips_rediscovering-spring-with-spring-boot1.pdf
dokumen.tips_rediscovering-spring-with-spring-boot1.pdfdokumen.tips_rediscovering-spring-with-spring-boot1.pdf
dokumen.tips_rediscovering-spring-with-spring-boot1.pdf
 
Job Managment Portlet
Job Managment PortletJob Managment Portlet
Job Managment Portlet
 
Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)
 
Declarative Services Dependency Injection OSGi style
Declarative Services Dependency Injection OSGi styleDeclarative Services Dependency Injection OSGi style
Declarative Services Dependency Injection OSGi style
 
What's Coming in Spring 3.0
What's Coming in Spring 3.0What's Coming in Spring 3.0
What's Coming in Spring 3.0
 
MeasureCamp IX (London) - 10 JavaScript Concepts for web analysts
MeasureCamp IX (London) - 10 JavaScript Concepts for web analystsMeasureCamp IX (London) - 10 JavaScript Concepts for web analysts
MeasureCamp IX (London) - 10 JavaScript Concepts for web analysts
 
AngularJs-training
AngularJs-trainingAngularJs-training
AngularJs-training
 
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
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
Declarative Services - Dependency Injection OSGi Style
Declarative Services - Dependency Injection OSGi StyleDeclarative Services - Dependency Injection OSGi Style
Declarative Services - Dependency Injection OSGi Style
 
Declarative Services - Dependency Injection OSGi Style
Declarative Services - Dependency Injection OSGi StyleDeclarative Services - Dependency Injection OSGi Style
Declarative Services - Dependency Injection OSGi Style
 
OSGi Enterprise R6 specs are out! - David Bosschaert & Carsten Ziegeler
OSGi Enterprise R6 specs are out! - David Bosschaert & Carsten ZiegelerOSGi Enterprise R6 specs are out! - David Bosschaert & Carsten Ziegeler
OSGi Enterprise R6 specs are out! - David Bosschaert & Carsten Ziegeler
 
Struts 2 + Spring
Struts 2 + SpringStruts 2 + Spring
Struts 2 + Spring
 
Introducing Struts 2
Introducing Struts 2Introducing Struts 2
Introducing Struts 2
 
A gently introduction to AngularJS
A gently introduction to AngularJSA gently introduction to AngularJS
A gently introduction to AngularJS
 
May 2010 - RestEasy
May 2010 - RestEasyMay 2010 - RestEasy
May 2010 - RestEasy
 
RESTEasy
RESTEasyRESTEasy
RESTEasy
 
Amplify를 통해 클라우드 기반 모바일 앱 개발하기 - 박태성(IDEASAM) :: AWS Community Day 2020
Amplify를 통해 클라우드 기반 모바일 앱 개발하기 - 박태성(IDEASAM) :: AWS Community Day 2020Amplify를 통해 클라우드 기반 모바일 앱 개발하기 - 박태성(IDEASAM) :: AWS Community Day 2020
Amplify를 통해 클라우드 기반 모바일 앱 개발하기 - 박태성(IDEASAM) :: AWS Community Day 2020
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Último (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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)
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
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
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
[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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 
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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

Using OSGi in Nakamura

  • 1. Using OSGi in Nakamura Carl Hall [email_address] Hallway Technologies 15 June 2010
  • 2.
  • 3.
  • 4. Bundles   11th Sakai Conference - June 15-17, 2010
  • 5.
  • 6. Bundle Activation import org.osgi.framework.BundleActivator ; import org.osgi.framework.BundleContext ; public class Activator implements BundleActivator { public void start ( BundleContext context ) { System . out . println ( &quot;Starting: Hello World&quot; ) ; } public void stop ( BundleContext context ) { System . out . println ( &quot;Stopping: Goodbye Cruel World&quot; ) ; } } Source: Wikipedia 11th Sakai Conference - June 15-17, 2010
  • 7. Components   11th Sakai Conference - June 15-17, 2010
  • 8.
  • 9. Service Example @Component @Service public class LdapAuthenticationPlugin implements AuthenticationPlugin {    @Property(value = &quot;o=sakai&quot;)    static final String LDAP_BASE_DN = &quot;sakai.auth.ldap.baseDn&quot;;    private String baseDn;    @Reference    private LdapConnectionManager connMgr;    @Activate    protected void activate(Map<?, ?> props) {      baseDn = OsgiUtil.toString(props.get(LDAP_BASE_DN), &quot;o=sakai&quot;);    } } 11th Sakai Conference - June 15-17, 2010
  • 10. Component Execution @Activate protected void activate(ComponentContext ctx) {} protected void activate(BundleContext ctx) {} protected void activate(Map<?, ?> props) {} @Modified protected void modified(...) {} @Deactivate protected void deactivate(...) {} protected void deactivate(int reasonCode) {} 11th Sakai Conference - June 15-17, 2010
  • 11.
  • 12. Dependency Injection   11th Sakai Conference - June 15-17, 2010
  • 13.
  • 14. References public class GetAReference {    @Reference    ConnectionManager connMgr; } ----------------------------------------------------------------- @Component @Service public class LdapConnectionManager implements ConnectionManager { } @Component @Service public class JdbcConnectionManager implements ConnectionManager { } 11th Sakai Conference - June 15-17, 2010
  • 15. Single Instance Reference // OPTIONAL_UNARY == &quot;0..1&quot; // MANDATORY_UNARY == &quot;1..1&quot; @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY,    policy = ReferencePolicy.STATIC) ConnectionManager connMgr; protected void bindConnMgr(ConnectionManager mgr) {    this.connMgr = mgr; } protected void unbindConnMgr(ConnectionManager mgr) {    this.connMgr = null; } 11th Sakai Conference - June 15-17, 2010
  • 16. Multiple Instance Reference // OPTIONAL_MULTIPLE == &quot;0..n&quot; // MANDATORY_MULTIPLE == &quot;1..n&quot; @Reference(cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,    policy = ReferencePolicy.DYNAMIC,    referenceInterface = ConnectionManager.class,    bind = &quot;bindManager&quot;,    unbind = &quot;unbindManager&quot;) List<ConnectionManager> managers;  // be sure to instantiate this protected void bindManager(ConnectionManager mgr) {    managers.add(mgr); } protected void unbindManager(ConnectionManager mgr) {    managers.remove(mgr); } 11th Sakai Conference - June 15-17, 2010
  • 17. Reference Target @Reference PooledConnectionManager connMgr;  //boo! @Reference(target = &quot;(type=pooled)&quot;) ConnectionManager connMgr;  //yay! ----------------------------------------------------------------- @Component @Service @Property(name = &quot;type&quot;, value = &quot;simple&quot;) public class SimpleCM implements ConnectionManager {} @Component @Service @Property(name = &quot;type&quot;, value = &quot;pooled&quot;) public class PooledCM implements ConnectionManager {} 11th Sakai Conference - June 15-17, 2010
  • 18. Configuration   11th Sakai Conference - June 15-17, 2010
  • 19. Felix Admin Console 11th Sakai Conference - June 15-17, 2010
  • 20. New Service Configuration @Reference ConfigurationAdmin cfgAdmin; @Activate protected void activate() {    Configuration cfg =      cfgAdmin.createFactoryConfiguration(&quot;some.factory.pid&quot;);    Hashtable props = new Hashtable();    props.put(&quot;key1&quot;, &quot;val1&quot;);    props.put(&quot;key2&quot;, &quot;val2&quot;);    config.update(props); } 11th Sakai Conference - June 15-17, 2010
  • 21. Configure A Reference @Reference ConnectionManager connMgr; ----------------------------------------------------------------- @Reference ConfigurationAdmin cfgAdmin; @Activate protected void activate() {    Configuration cfg =      cfgAdmin.createFactoryConfiguration(&quot;some.factory.pid&quot;);    Hashtable props = new Hashtable();    props.put(&quot;connMgr.target&quot;, &quot;(type=pooled)&quot;);    config.update(props); } 11th Sakai Conference - June 15-17, 2010