SlideShare ist ein Scribd-Unternehmen logo
1 von 50
ANDREAS ENBOHM (@enbohm)
2012-09-13
HYBRID APPLICATIONS
- Combining the Power of Java EE and OSGi
About Me
Agenda
 Introduction
 Java EE
 OSGi + Java EE
 Demo
- Java EE + OSGi
- Glassfish V3
 Future<?>
Why This Presenation?
Homer Simpson Programming Model:
”Let some else do it!”
Java EE
Java EE
”The industri standard for enterprise computing. JEE is
used for mission-critical, large-scale, multi-tiered,
scalable, reliable, and secure applications”
Java EE
 A set of API
- JTA, JPA, JSF, EJB, JMS, JCA, Servlet, CDI, JAX-WS, JAX-RS…
 Application Servers
- Oracle AS, IBM Websphere, Apache Geronimo, JBoss, Glassfish, JOnAS,
TomEE, Resin…
 Used within
- Finance
- Telecom
- Manufacturing
- …
Ewok* EJB Appreciation
*Ewoks from motion picture ”Star Wars Return of the Jedi”
”EJB/J2EE IS HEAVYWEIGHT”
”EJB/J2EE IS HEAVYWEIGHT”
 EJB != heavyweight
- acctually its considered ultra-lean
- please tell if anyone know any other tech!
 One jar file (java-ee-6.jar, 967 kB)
 One single annotation
- @Stateless
 Glassfish (55/200MB)
- restart in ~3 seconds
- hot deployment
- full OSGi support
Why Java EE
 Hyper productive
- time-to-market
 Maximize focus on Business functionality
- Inversion of control (DI)
- Decorators
- Aspects
- Schedulers
- Events
- Asyncronous calls
- …
 Helps you with a lot of non-functional requirements
Why Java EE
 Thread-safe
- every thread gets it own bean instance
 Transaction management
- transaction are automatically started, commited or rollbacked
 Pooling of Session beans
- prevent DDOS attacks
- scale up/down
 Distributed components
- runs in a multi-tier architecture
- failover, scalability
Why Java EE
 Deployment
- very few (if any) xzy.xml deployment desc.
- runs on several app servers and/or clouds
 Elastic
Why Java EE
 Ultra-lean
- what more can be removed?
EJB Component
public interface PaymentService {
public ProductReceipt pay(int productId);
}
@Stateless
public class PaymentEJB implements PaymentService {
public ProductReceipt pay(int productId){
//implementation goes here
}
}
EJB-annotation (convention over configuration)
Plain interface (not
required)
TDD and Java EE
 Unit test
- POJO
 Integration test
- embedded container
- arquillian
- pax exam
TDD and Java EE
EJBContainer container = EJBContainer.createEJBContainer();
Context ctx = container.getContext();
PaymentService service = (PaymentService) ctx
.lookup("java:global/classes/PaymentEJB");
Assert.assertNotNull(service);
Areas Not Covered by Java EE
 Java lacks (real) modularity
- known problem since day 1
- many app servers builds on OSGi
- may change when Project Jigsaw is release (2013)
 Service tracking
 Criteria-based service selection
 ”Jar-hell”
- NoSuchMethodException
- Classpath / Dependencies
Areas Not Covered by Java EE
 Well defined life-cycle of components
 Multiple instances of a service/component
 Hot-swapping* of components
* debug mode doesn’t count
Hello OSGi!
“OSGi technology provides a service-oriented,
component-based environment for developers and
offers standardized ways to manage the software
lifecycle.” - Wikipedia
Hello OSGi!
Simply put, a modularity layer for the Java platform
Why OSGi
 Separation of concerns (i.e modularization)
 Key concepts
- Cohesion
- Coupling
 Containers
- Apache Felix
- Knopflerfish
- Equinox
Why OSGi
 But how about OO in Java?
- OO is all about high cohesion and low coupling, right?
 Java has a limited modularization
- no transitive dependencies
- public (keyword) is ’too public’
- error prone class path
- low-level modularization (packages)
OSGi Layers
 OSGi Layered Architecture
 Module
- packaging and sharing
of code
 Life Cycle
- module management
 Service
- interaction between
modules
OSGi Module Layer
 Bundle
–a unit of modularity in OSGi
 Package as a JAR (classes + MANIFEST.MF with OSGi metadata)
 Versionable
 Clear dependency declaration
 Clear dependency resolution rules
OSGi Metadata
 Manifest.MF
Manifest-Version: 1.0
Built-By: aenbohm
Bundle-ManifestVersion: 2
Bundle-Name: hybridCommon
Bundle-SymbolicName: hybridCommon
Bundle-Version: 1.0.0
Export-Package: com.acme.hybrid.devcon.entity;version="1.0.0"
Import-Package: javax.persistence,javax.xml.bind.annotation
OSGi Life Cycle Layer
 Life Cycle
OSGi Service Layer
 Services registry
- register
- unregister
 Service is a POJI
- focus on the contract/interface
- reduce coupling
 Service discovery
- LDAP filter based queries
Best of Both Worlds
 How about combining JEE & OSGi?
- productivity
- reusable bundles with visible dependencies
- version control of components
- automatic transaction handling
- ..
Hello Hybrid Application!
31
© 2012 Capgemini. All rights reserved.
Hybrid Applications
“a hybrid application bundle is an OSGi bundle as well
as a Java EE module. At
runtime, it has both an OSGi bundle context and a Java
EE context.”
Hybrid Applications
 Allows you to develop managed, transactional OSGi services with little
knowledge of OSGi
 Makes your EJB:s available as OSGi services with little effort
- bundles can use Java EE services like JTA, JPA, etc
 Supports Stateless and Singleton EJBs
Hybrid Applications
How to turn your Java
EE artifacts to OSGi
Services?
Hybrid Applications
…
Implementation-Title: hybrid
Implementation-Version: 1.3
Bundle-ClassPath: WEB-INF/classes/
Bundle-Name: hybrid
Bundle-SymbolicName: com.acme.hybrid.service.impl
Bundle-Version: 1.3.0
Export-EJB: ALL
Web-ContextPath: /hybrid
…
Manifest.MF
WAB (web application bundle); OSGi Spec. 4.2
Hybrid Applications
 EJB artifacts + Manifest.MF = ’Declarative’ Service
- Enterprise Application Bundle (EAB)
- Web Application Bundle (WAB)
 ExportEJB: List of EJBs to be exported as OSGi services.
- Values: NONE, ALL or fully qualified name
Hybrid Applications
 In VM SOA
- service-oriented design
- domain-driven design
 Different support for hybrid apps
- JBoss
- Glassfish
- IBM Websphere
- Geronimo
 This makes hybrid apps less portable!
- RFP 152 ”EJB Integration”
- RFP 146 ”OSGi/CDI Integration”
Glassfish + OSGi
 OSGi R4, version 4.2 compliant
- Uses Apache Felix as OSGi runtime
 Jave EE / OSGi services in Glassfish
- JTA
- JPA
- JMS
- HTTP Service
- Event Admin
- Config Admin
- …
Glassfish + OSGi
 Type safe injection with CDI Extension
ServiceTracker tracker =
new ServiceTracker(context, Hello.class.getName(), null);
tracker.open();
Hello hello = (Hello) tracker.getService();
System.out.println(hello.sayHello("Duke"));
@Inject @OSGiService(dynamic=true)
Hello hello;
System.out.println(hello.sayHello("Duke"));
With CDI annotation:
PROVE IT ! (Demo time)
 Asyncronous invocations
 Events
 Decorators
 Service update (hot deployment)
 REST service
Demo Overview
HybridCommon
(standard OSGi bundle containing
domain objects)
HybridClient
(WAB exposes a service via Jax-RS)
HybridBackend
(EJB as OSGi service, EAB)
<uses>
<uses>
OSGi Service
Registry
<publish>
<discover>
CONS JEE + OSGi
 ”With great power comes great complexity”
- combining OSGi + JEE
- two different component models
- developers need to know both models
- not all app server have (full) hybrid support
- different containers with different characteristics
 Technology overlap of Java EE and OSGi
- events, security, monitoring…
 Declarative Services, iPojo, Blueprint, ServiceTracker…
FUTURE<JavaEE&OSGi>
Project Jigsaw
FUTURE<JavaEE&OSGi>
 Project Jigsaw
- monolitic JVM
- will address both compile & runtime (Maven + OSGi)
- no service register nor life cycle handling
- (probably) not until Java 9
FUTURE<JavaEE&OSGi>
OSGi + Maven?
FUTURE<JavaEE&OSGi>
 OSGi
- CDI integration
- EJB incorporation
- more app servers will support hybrid
apps
 Jigsaw and OSGi will definitely co-exist
- Project Penrose
SUMMARY
 Features in Java EE and OSGi
- productivity and modularity
 How to combine them
- WAB/EAB
 Demonstrated a hybrid application
- using Glassfish + Apache Felix
| Sector, Alliance, Offering
USEFUL LINKS
www.osgi.org
www.glassfish.org
http://www.oracle.com/technetwork/java/javaee/overvie
w/index.html
http://www.jboss.org/arquillian.html
http://mreinhold.org/blog/late-for-the-train-qa
Q & A
49
© 2012 Capgemini. All rights reserved.
http://www.slideshare.net/enbohm
Twitter: @enbohm
www.se.capgemini.com
The informationcontained in this presentation is proprietary. ©2012 Capgemini. All rights reserved

Weitere ähnliche Inhalte

Was ist angesagt?

Open Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVMOpen Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVMTom Lee
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyNick Sieger
 
Using Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBUsing Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBHiro Asari
 
Camel and JBoss
Camel and JBossCamel and JBoss
Camel and JBossJBug Italy
 
Faster & Greater Messaging System HornetQ zzz
Faster & Greater Messaging System HornetQ zzzFaster & Greater Messaging System HornetQ zzz
Faster & Greater Messaging System HornetQ zzzJBug Italy
 
Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Anton Arhipov
 
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e RubyTorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e RubyBruno Oliveira
 
Cracking JWT tokens: a tale of magic, Node.JS and parallel computing
Cracking JWT tokens: a tale of magic, Node.JS and parallel computingCracking JWT tokens: a tale of magic, Node.JS and parallel computing
Cracking JWT tokens: a tale of magic, Node.JS and parallel computingLuciano Mammino
 
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Nayden Gochev
 
K is for Kotlin
K is for KotlinK is for Kotlin
K is for KotlinTechMagic
 
TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011bobmcwhirter
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014Nayden Gochev
 
JRuby in Java Projects
JRuby in Java ProjectsJRuby in Java Projects
JRuby in Java Projectsjazzman1980
 
SoftwareUniversity seminar fast REST Api with Spring
SoftwareUniversity seminar fast REST Api with SpringSoftwareUniversity seminar fast REST Api with Spring
SoftwareUniversity seminar fast REST Api with SpringNayden Gochev
 
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time APIModern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time APIGanesh Samarthyam
 
Rapid Network Application Development with Apache MINA
Rapid Network Application Development with Apache MINARapid Network Application Development with Apache MINA
Rapid Network Application Development with Apache MINAtrustinlee
 

Was ist angesagt? (19)

Open Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVMOpen Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVM
 
Kotlin - Better Java
Kotlin - Better JavaKotlin - Better Java
Kotlin - Better Java
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRuby
 
Using Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBUsing Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRB
 
Camel and JBoss
Camel and JBossCamel and JBoss
Camel and JBoss
 
Seeking Clojure
Seeking ClojureSeeking Clojure
Seeking Clojure
 
Faster & Greater Messaging System HornetQ zzz
Faster & Greater Messaging System HornetQ zzzFaster & Greater Messaging System HornetQ zzz
Faster & Greater Messaging System HornetQ zzz
 
Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012
 
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e RubyTorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
 
Cracking JWT tokens: a tale of magic, Node.JS and parallel computing
Cracking JWT tokens: a tale of magic, Node.JS and parallel computingCracking JWT tokens: a tale of magic, Node.JS and parallel computing
Cracking JWT tokens: a tale of magic, Node.JS and parallel computing
 
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
 
K is for Kotlin
K is for KotlinK is for Kotlin
K is for Kotlin
 
TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014
 
JRuby in Java Projects
JRuby in Java ProjectsJRuby in Java Projects
JRuby in Java Projects
 
SoftwareUniversity seminar fast REST Api with Spring
SoftwareUniversity seminar fast REST Api with SpringSoftwareUniversity seminar fast REST Api with Spring
SoftwareUniversity seminar fast REST Api with Spring
 
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time APIModern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
 
Rapid Network Application Development with Apache MINA
Rapid Network Application Development with Apache MINARapid Network Application Development with Apache MINA
Rapid Network Application Development with Apache MINA
 
Invoke dynamics
Invoke dynamicsInvoke dynamics
Invoke dynamics
 

Ähnlich wie Hybrid Applications

OSGi and Java EE in GlassFish - Tech Days 2010 India
OSGi and Java EE in GlassFish - Tech Days 2010 IndiaOSGi and Java EE in GlassFish - Tech Days 2010 India
OSGi and Java EE in GlassFish - Tech Days 2010 IndiaArun Gupta
 
OSGi Community Event 2010 - Enterprise OSGi in WebSphere and Apache Aries
OSGi Community Event 2010 - Enterprise OSGi in WebSphere and Apache AriesOSGi Community Event 2010 - Enterprise OSGi in WebSphere and Apache Aries
OSGi Community Event 2010 - Enterprise OSGi in WebSphere and Apache Ariesmfrancis
 
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...OpenBlend society
 
OSGi DevCon 2009 Review
OSGi DevCon 2009 ReviewOSGi DevCon 2009 Review
OSGi DevCon 2009 Reviewnjbartlett
 
GlassFish OSGi Server
GlassFish OSGi ServerGlassFish OSGi Server
GlassFish OSGi ServerArtur Alves
 
The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012
The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012
The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012Arun Gupta
 
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010JUG Lausanne
 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Enginecatherinewall
 
Easing offline web application development with GWT
Easing offline web application development with GWTEasing offline web application development with GWT
Easing offline web application development with GWTArnaud Tournier
 
OSGi and Java EE: A Hybrid Approach to Enterprise Java Application Development
OSGi and Java EE: A Hybrid Approach to Enterprise Java Application DevelopmentOSGi and Java EE: A Hybrid Approach to Enterprise Java Application Development
OSGi and Java EE: A Hybrid Approach to Enterprise Java Application DevelopmentSanjeeb Sahoo
 
Java EE7
Java EE7Java EE7
Java EE7Jay Lee
 
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...Jesse Gallagher
 
Playframework + Twitter Bootstrap
Playframework + Twitter BootstrapPlayframework + Twitter Bootstrap
Playframework + Twitter BootstrapKevingo Tsai
 
Java EE | Modular EJBs for Enterprise OSGi | Tim Ward
Java EE | Modular EJBs for Enterprise OSGi | Tim WardJava EE | Modular EJBs for Enterprise OSGi | Tim Ward
Java EE | Modular EJBs for Enterprise OSGi | Tim WardJAX London
 

Ähnlich wie Hybrid Applications (20)

OSGi and Java EE in GlassFish - Tech Days 2010 India
OSGi and Java EE in GlassFish - Tech Days 2010 IndiaOSGi and Java EE in GlassFish - Tech Days 2010 India
OSGi and Java EE in GlassFish - Tech Days 2010 India
 
OSGi Community Event 2010 - Enterprise OSGi in WebSphere and Apache Aries
OSGi Community Event 2010 - Enterprise OSGi in WebSphere and Apache AriesOSGi Community Event 2010 - Enterprise OSGi in WebSphere and Apache Aries
OSGi Community Event 2010 - Enterprise OSGi in WebSphere and Apache Aries
 
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
 
OSGi DevCon 2009 Review
OSGi DevCon 2009 ReviewOSGi DevCon 2009 Review
OSGi DevCon 2009 Review
 
GlassFish OSGi Server
GlassFish OSGi ServerGlassFish OSGi Server
GlassFish OSGi Server
 
The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012
The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012
The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012
 
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010
 
GlassFish and JavaEE, Today and Future
GlassFish and JavaEE, Today and FutureGlassFish and JavaEE, Today and Future
GlassFish and JavaEE, Today and Future
 
Glass Fishv3 March2010
Glass Fishv3 March2010Glass Fishv3 March2010
Glass Fishv3 March2010
 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Engine
 
Easing offline web application development with GWT
Easing offline web application development with GWTEasing offline web application development with GWT
Easing offline web application development with GWT
 
OSGi and Java EE: A Hybrid Approach to Enterprise Java Application Development
OSGi and Java EE: A Hybrid Approach to Enterprise Java Application DevelopmentOSGi and Java EE: A Hybrid Approach to Enterprise Java Application Development
OSGi and Java EE: A Hybrid Approach to Enterprise Java Application Development
 
Java ee7 1hour
Java ee7 1hourJava ee7 1hour
Java ee7 1hour
 
Java EE7
Java EE7Java EE7
Java EE7
 
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
 
Polyglot OSGi
Polyglot OSGiPolyglot OSGi
Polyglot OSGi
 
GlassFish v3 : En Route Java EE 6
GlassFish v3 : En Route Java EE 6GlassFish v3 : En Route Java EE 6
GlassFish v3 : En Route Java EE 6
 
Playframework + Twitter Bootstrap
Playframework + Twitter BootstrapPlayframework + Twitter Bootstrap
Playframework + Twitter Bootstrap
 
Java EE | Modular EJBs for Enterprise OSGi | Tim Ward
Java EE | Modular EJBs for Enterprise OSGi | Tim WardJava EE | Modular EJBs for Enterprise OSGi | Tim Ward
Java EE | Modular EJBs for Enterprise OSGi | Tim Ward
 
JBoss AS7 OSDC 2011
JBoss AS7 OSDC 2011JBoss AS7 OSDC 2011
JBoss AS7 OSDC 2011
 

Mehr von Andreas Enbohm

BDD Short Introduction
BDD Short IntroductionBDD Short Introduction
BDD Short IntroductionAndreas Enbohm
 
Behavior-driven Development and Lambdaj
Behavior-driven Development and LambdajBehavior-driven Development and Lambdaj
Behavior-driven Development and LambdajAndreas Enbohm
 
Software Craftsmanship
Software CraftsmanshipSoftware Craftsmanship
Software CraftsmanshipAndreas Enbohm
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design PrinciplesAndreas Enbohm
 
Java Extension Methods
Java Extension MethodsJava Extension Methods
Java Extension MethodsAndreas Enbohm
 
Project Lambda - Closures after all?
Project Lambda - Closures after all?Project Lambda - Closures after all?
Project Lambda - Closures after all?Andreas Enbohm
 

Mehr von Andreas Enbohm (7)

BDD Short Introduction
BDD Short IntroductionBDD Short Introduction
BDD Short Introduction
 
Behavior-driven Development and Lambdaj
Behavior-driven Development and LambdajBehavior-driven Development and Lambdaj
Behavior-driven Development and Lambdaj
 
Software Craftsmanship
Software CraftsmanshipSoftware Craftsmanship
Software Craftsmanship
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
Java Extension Methods
Java Extension MethodsJava Extension Methods
Java Extension Methods
 
Project Lambda - Closures after all?
Project Lambda - Closures after all?Project Lambda - Closures after all?
Project Lambda - Closures after all?
 
Fest
FestFest
Fest
 

Kürzlich hochgeladen

Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 

Kürzlich hochgeladen (20)

Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 

Hybrid Applications

  • 1. ANDREAS ENBOHM (@enbohm) 2012-09-13 HYBRID APPLICATIONS - Combining the Power of Java EE and OSGi
  • 3. Agenda  Introduction  Java EE  OSGi + Java EE  Demo - Java EE + OSGi - Glassfish V3  Future<?>
  • 4. Why This Presenation? Homer Simpson Programming Model: ”Let some else do it!”
  • 6.
  • 7. Java EE ”The industri standard for enterprise computing. JEE is used for mission-critical, large-scale, multi-tiered, scalable, reliable, and secure applications”
  • 8. Java EE  A set of API - JTA, JPA, JSF, EJB, JMS, JCA, Servlet, CDI, JAX-WS, JAX-RS…  Application Servers - Oracle AS, IBM Websphere, Apache Geronimo, JBoss, Glassfish, JOnAS, TomEE, Resin…  Used within - Finance - Telecom - Manufacturing - …
  • 9. Ewok* EJB Appreciation *Ewoks from motion picture ”Star Wars Return of the Jedi”
  • 11. ”EJB/J2EE IS HEAVYWEIGHT”  EJB != heavyweight - acctually its considered ultra-lean - please tell if anyone know any other tech!  One jar file (java-ee-6.jar, 967 kB)  One single annotation - @Stateless  Glassfish (55/200MB) - restart in ~3 seconds - hot deployment - full OSGi support
  • 12. Why Java EE  Hyper productive - time-to-market  Maximize focus on Business functionality - Inversion of control (DI) - Decorators - Aspects - Schedulers - Events - Asyncronous calls - …  Helps you with a lot of non-functional requirements
  • 13. Why Java EE  Thread-safe - every thread gets it own bean instance  Transaction management - transaction are automatically started, commited or rollbacked  Pooling of Session beans - prevent DDOS attacks - scale up/down  Distributed components - runs in a multi-tier architecture - failover, scalability
  • 14. Why Java EE  Deployment - very few (if any) xzy.xml deployment desc. - runs on several app servers and/or clouds  Elastic
  • 15. Why Java EE  Ultra-lean - what more can be removed?
  • 16. EJB Component public interface PaymentService { public ProductReceipt pay(int productId); } @Stateless public class PaymentEJB implements PaymentService { public ProductReceipt pay(int productId){ //implementation goes here } } EJB-annotation (convention over configuration) Plain interface (not required)
  • 17. TDD and Java EE  Unit test - POJO  Integration test - embedded container - arquillian - pax exam
  • 18. TDD and Java EE EJBContainer container = EJBContainer.createEJBContainer(); Context ctx = container.getContext(); PaymentService service = (PaymentService) ctx .lookup("java:global/classes/PaymentEJB"); Assert.assertNotNull(service);
  • 19. Areas Not Covered by Java EE  Java lacks (real) modularity - known problem since day 1 - many app servers builds on OSGi - may change when Project Jigsaw is release (2013)  Service tracking  Criteria-based service selection  ”Jar-hell” - NoSuchMethodException - Classpath / Dependencies
  • 20. Areas Not Covered by Java EE  Well defined life-cycle of components  Multiple instances of a service/component  Hot-swapping* of components * debug mode doesn’t count
  • 21. Hello OSGi! “OSGi technology provides a service-oriented, component-based environment for developers and offers standardized ways to manage the software lifecycle.” - Wikipedia
  • 22. Hello OSGi! Simply put, a modularity layer for the Java platform
  • 23. Why OSGi  Separation of concerns (i.e modularization)  Key concepts - Cohesion - Coupling  Containers - Apache Felix - Knopflerfish - Equinox
  • 24. Why OSGi  But how about OO in Java? - OO is all about high cohesion and low coupling, right?  Java has a limited modularization - no transitive dependencies - public (keyword) is ’too public’ - error prone class path - low-level modularization (packages)
  • 25. OSGi Layers  OSGi Layered Architecture  Module - packaging and sharing of code  Life Cycle - module management  Service - interaction between modules
  • 26. OSGi Module Layer  Bundle –a unit of modularity in OSGi  Package as a JAR (classes + MANIFEST.MF with OSGi metadata)  Versionable  Clear dependency declaration  Clear dependency resolution rules
  • 27. OSGi Metadata  Manifest.MF Manifest-Version: 1.0 Built-By: aenbohm Bundle-ManifestVersion: 2 Bundle-Name: hybridCommon Bundle-SymbolicName: hybridCommon Bundle-Version: 1.0.0 Export-Package: com.acme.hybrid.devcon.entity;version="1.0.0" Import-Package: javax.persistence,javax.xml.bind.annotation
  • 28. OSGi Life Cycle Layer  Life Cycle
  • 29. OSGi Service Layer  Services registry - register - unregister  Service is a POJI - focus on the contract/interface - reduce coupling  Service discovery - LDAP filter based queries
  • 30. Best of Both Worlds  How about combining JEE & OSGi? - productivity - reusable bundles with visible dependencies - version control of components - automatic transaction handling - ..
  • 31. Hello Hybrid Application! 31 © 2012 Capgemini. All rights reserved.
  • 32. Hybrid Applications “a hybrid application bundle is an OSGi bundle as well as a Java EE module. At runtime, it has both an OSGi bundle context and a Java EE context.”
  • 33. Hybrid Applications  Allows you to develop managed, transactional OSGi services with little knowledge of OSGi  Makes your EJB:s available as OSGi services with little effort - bundles can use Java EE services like JTA, JPA, etc  Supports Stateless and Singleton EJBs
  • 34. Hybrid Applications How to turn your Java EE artifacts to OSGi Services?
  • 35. Hybrid Applications … Implementation-Title: hybrid Implementation-Version: 1.3 Bundle-ClassPath: WEB-INF/classes/ Bundle-Name: hybrid Bundle-SymbolicName: com.acme.hybrid.service.impl Bundle-Version: 1.3.0 Export-EJB: ALL Web-ContextPath: /hybrid … Manifest.MF WAB (web application bundle); OSGi Spec. 4.2
  • 36. Hybrid Applications  EJB artifacts + Manifest.MF = ’Declarative’ Service - Enterprise Application Bundle (EAB) - Web Application Bundle (WAB)  ExportEJB: List of EJBs to be exported as OSGi services. - Values: NONE, ALL or fully qualified name
  • 37. Hybrid Applications  In VM SOA - service-oriented design - domain-driven design  Different support for hybrid apps - JBoss - Glassfish - IBM Websphere - Geronimo  This makes hybrid apps less portable! - RFP 152 ”EJB Integration” - RFP 146 ”OSGi/CDI Integration”
  • 38. Glassfish + OSGi  OSGi R4, version 4.2 compliant - Uses Apache Felix as OSGi runtime  Jave EE / OSGi services in Glassfish - JTA - JPA - JMS - HTTP Service - Event Admin - Config Admin - …
  • 39. Glassfish + OSGi  Type safe injection with CDI Extension ServiceTracker tracker = new ServiceTracker(context, Hello.class.getName(), null); tracker.open(); Hello hello = (Hello) tracker.getService(); System.out.println(hello.sayHello("Duke")); @Inject @OSGiService(dynamic=true) Hello hello; System.out.println(hello.sayHello("Duke")); With CDI annotation:
  • 40. PROVE IT ! (Demo time)  Asyncronous invocations  Events  Decorators  Service update (hot deployment)  REST service
  • 41. Demo Overview HybridCommon (standard OSGi bundle containing domain objects) HybridClient (WAB exposes a service via Jax-RS) HybridBackend (EJB as OSGi service, EAB) <uses> <uses> OSGi Service Registry <publish> <discover>
  • 42. CONS JEE + OSGi  ”With great power comes great complexity” - combining OSGi + JEE - two different component models - developers need to know both models - not all app server have (full) hybrid support - different containers with different characteristics  Technology overlap of Java EE and OSGi - events, security, monitoring…  Declarative Services, iPojo, Blueprint, ServiceTracker…
  • 44. FUTURE<JavaEE&OSGi>  Project Jigsaw - monolitic JVM - will address both compile & runtime (Maven + OSGi) - no service register nor life cycle handling - (probably) not until Java 9
  • 46. FUTURE<JavaEE&OSGi>  OSGi - CDI integration - EJB incorporation - more app servers will support hybrid apps  Jigsaw and OSGi will definitely co-exist - Project Penrose
  • 47. SUMMARY  Features in Java EE and OSGi - productivity and modularity  How to combine them - WAB/EAB  Demonstrated a hybrid application - using Glassfish + Apache Felix
  • 48. | Sector, Alliance, Offering USEFUL LINKS www.osgi.org www.glassfish.org http://www.oracle.com/technetwork/java/javaee/overvie w/index.html http://www.jboss.org/arquillian.html http://mreinhold.org/blog/late-for-the-train-qa
  • 49. Q & A 49 © 2012 Capgemini. All rights reserved. http://www.slideshare.net/enbohm Twitter: @enbohm
  • 50. www.se.capgemini.com The informationcontained in this presentation is proprietary. ©2012 Capgemini. All rights reserved