Upload
mfrancis
View
517
Download
0
Tags:
Embed Size (px)
DESCRIPTION
OSGi Community Event 2013 (http://www.osgi.org/CommunityEvent2013/Schedule) ABSTRACT 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 capabilities, standards coverage, tools support, and available implementations, and will show working examples of each, all in an effort to help OSGi users find a path to a component model best suited to their particular task. SPEAKER BIO Graham Charters is a Senior Technical Staff Member in the IBM WebSphere Application Server development organization. He is responsible for the OSGi Applications feature of the Application Server and a committer and PMC member of the Apache Aries OSGi programming model project. He is also the IBM technical lead in the OSGi Alliance Enterprise Expert Group.
Citation preview
© 2013 IBM Corporation
DS, BP, EJB, CDI, WTF!? Graham Charters, IBM
OSGi DevCon US 2013
1
© 2013 IBM Corporation
Agenda
Background
Criteria
Component models
How to choose
2
© 2013 IBM Corporation
Why?
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!!
© 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
© 2013 IBM Corporation
Non-technical criteria
Open Standards
Open Source implementations
Choice of implementations
Availability of tools
Existing assets
Existing skills
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)
8
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
Now with
added demos!
© 2013 IBM Corporation
The demo
9
Time Service
Component Servlet Service
Http Service
Http Service Whiteboard
alias=/xyz
© 2013 IBM Corporation
Declarative Services
10
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 Schema extensibility
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 ) { ... } }
© 2013 IBM Corporation
Blueprint
11
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>
© 2013 IBM Corporation
Enterprise JavaBeans
12
Criterion EJB
Inspiration Version 1.0 - 15 years old
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() { … } … }
© 2013 IBM Corporation
Contexts and Dependency Injection
13
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 @Component public class DiscountCalculatorImpl implements DiscountCalculator { @Inject @Service StaticLogger logger; public double dicount() {...} ... }
© 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
14
No one component model to rule them all