SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

La actualidad más candente

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
 

La actualidad más candente (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
 

Similar a 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
 

Similar a 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
 

Más de 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
 

Más de 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
 

Último

Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 

Último (20)

Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 

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