Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

DS, BP, EJB, CDI, WTF!? - Graham Charters

588 vues

Publié le

OSGi DevCon 2013

There are a number component models available to OSGi developers; Declarative Services (DS), Blueprint (BP), Enterprise JavaBeans (EJB), Contexts and Dependency Injection (CDI). Some have their roots in Java EE, some in open source projects such as the Spring Framework, others are standards at the OSGi Alliance, and some have DNA from all three. As is often the case where there are options available, there's rarely a one-size-fits-all. The 'right' choice may depend on the type of project you're working on, the existing assets, tools and skills at your disposal, and the runtime you're looking to deploy to. This talk will provide a brief overview of the four component models listed, describe their scope of capabilities, standards coverage, tools support, and available implementations in an efforts to help OSGi users find a path to a component model best suited to their particular task.

Publié dans : Technologie
  • Soyez le premier à commenter

  • Soyez le premier à aimer ceci

DS, BP, EJB, CDI, WTF!? - Graham Charters

  1. 1. © 2013 IBM Corporation DS, BP, EJB, CDI, WTF!? Graham Charters, IBM OSGi DevCon US 2013 1
  2. 2. © 2013 IBM Corporation Agenda  Background  Criteria  Component models  How to choose 2
  3. 3. © 2013 IBM Corporation Why? 4
  4. 4. © 2013 IBM Corporation Approach  Provide some criteria to consider when making a component model choice  Explain a little bit about the technologies  Describe how each rates against the criteria  Reasons aren’t always technical  We probably won’t always agree 5 My beans are dynamic and use annotations. Your beans smell!!
  5. 5. © 2013 IBM Corporation Technical Criteria  Extra-bean definition (e.g. XML-based declarative model)  Intra-bean definition (e.g. bean annotation- based declarative model)  Extensibility  Enterprise Qualities of Service  Quality of Integration with OSGi 6
  6. 6. © 2013 IBM Corporation Non-technical criteria  Open Standards  Open Source implementations  Choice of implementations  Availability of tools  Existing assets  Existing skills 7
  7. 7. © 2013 IBM Corporation The technologies: DS, BP, EJB, CDI, WTF  Declaratives Services (DS)  Blueprint (not commonly known as BP)  Enterprise JavaBeans (EJB)  Contexts and Dependency Injection (CDI)  World Taekwondo Federation (WTF) There are a number of other component models, but I’ve focused on the ones I heard discussed most often. They’re also all based on open standards 8
  8. 8. © 2013 IBM Corporation Declarative Services 9 Criterion DS Inspiration Popularity if DI frameworks, but designed for OSGi Approach Extra-bean definition (XML-based declarative model) Build-time intra-bean definition (annotations compiled to XML) Extensibility No Enterprise QoS No OSGi Integration Designed by OSGi for OSGi. Includes Configuration Admin Open Standards OSGi Alliance Implementations Eclipse Equinox & Apache Felix Tools BND & BNDTools <component name=“DiscountCalculator“ …> <implementation class="com.acme.utils.impl.DiscountCalculatorImpl"/> <service> <provide interface="com.acme.utils.DiscountCalculator"/> </service> <reference name=“log" interface="org.osgi.service.log.LogService" bind="setLog" unbind="unsetLog" updated=“updateLog" /> </component> @Component public class DiscountCalculatorImpl implements DiscountCalculator { private Logger logger; @Reference(policy=DYNAMIC, policyOption=GREEDY, cardinality=MANDATORY) void setLog( LogService log) { ... } void unsetLog( LogService log) { ... } void updatedLog( Map<String,?> ref ) { ... } }
  9. 9. © 2013 IBM Corporation Blueprint 10 Criterion Blueprint Inspiration Spring & Spring DM (standardized by SpringSource) Approach Extra-bean definition (XML-based declarative model, includes bean-to- bean wiring) Intra-bean definition (Annotations – Apache Aries Open Source only) Extensibility Through XML namespaces – no runtime standard Enterprise QoS Transactions and Persistence (Apache Aries), Security (WebSphere Application Server), Bus (CXF), Camel, etc… OSGi Integration Some life-cycle compromises Config Admin (open source) Open Standards OSGi Alliance Updates in pipeline Implementations Eclipse Gemini & Apache Aries Tools WebSphere Developer Tools (no charge), Rational Application Developer <?xml version="1.0" encoding="UTF-8"?> <blueprint …> <service id="DiscountCalculatorBeanService" ref="DiscountCalculatorBean" interface="com.acme.utils.DiscountCalculator" /> <bean id="DiscountCalculatorBean" class="com.acme.utils.impl.DiscountCalculatorImpl"> <property name="logger" ref="loggerService" /> </bean> <reference id="loggerService" interface="com.acme.utils.Logger" /> </blueprint>
  10. 10. © 2013 IBM Corporation Enterprise JavaBeans 11 Criterion EJB Inspiration Version 1.0 - 15 years old this week! Approach Inheritance & XML bindings (pre-3.0). Intra-bean definition (bean annotation- based declarative model) (3.0 or later) Extensibility Nothing formal (defer to CDI) Enterprise QoS Transaction, Security, Remoting, Persistence, Messaging OSGi Integration Core capabilities (proprietary) Open Standards JCP, OSGi specification in progress Implementations All JavaEE App Servers support EJB. OSGi integration in WebSphere Application Server, GlassFish, Apache Aries, Apache OpenEJB Tools WebSphere Developer Tools (no charge), Rational Application Developer, Eclipse WTP @Stateless @Local(DiscountCalculator.class) public class DiscountCalculatorImpl implements DiscountCalculator { @Resource(lookup="osgi:service/Logger") private Logger logger; public double discount() { … } … }
  11. 11. © 2013 IBM Corporation Contexts and Dependency Injection 12 Criterion CDI Inspiration JBoss Seam, Google Guice & Spring Approach Intra-bean definition (annotation-based life-cycle and DI model), Extra-bean opt-in beans.xml with additional config (e.g. extensibility) Extensibility Interceptors, Decorators & Portable Extensions Enterprise QoS None. Leverage CDI in other component models (e.g. EJB) OSGi Integration Core capabilities (Open Source) Open Standards JCP, OSGi Alliance in progress Implementations Weld-OSGi, Pax-CDI, Fighterfish Tools EE Vendors tools @Named @RequestScoped @OSGiComponent public class DiscountCalculatorImpl implements DiscountCalculator { @Inject @OSGiService StaticLogger logger; public double dicount() {...} ... }
  12. 12. © 2013 IBM Corporation Some questions to ask when choosing  What existing skills does my team have? – Choose the closest match (e.g. Spring? Consider Blueprint)  What existing assets do I have available? – Choose the closest match  Do I need Enterprise capabilities? – If “yes”, consider Blueprint or EJB, if “no”, consider DS  Do I want something based on a standard? – If “yes”, familarize yourself with the scope and direction of existing standards  Do I need something based on open source? – Apache Felix, Eclipse Equinox, Apache Karaf, Eclipse Gemini, Apache Aries, Eclipse Virgo, ….the list goes on…..  What are the capabilities of my target runtime? – If a component model isn’t supported, there’s little point choosing it  What are the capabilities of my tool chain? – If a component model isn’t supported, you’re asking for pain  What if I use more than one component model? – Leverage OSGi services as the common integration point 13 No one component model to rule them all