• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
 

Hybrid Applications

on

  • 1,303 views

A presentation about how to create and combine Java EE and OSGi (aka hybrid application). Presentation held at Devcon12 2012 (Sweden, Karlskrona)

A presentation about how to create and combine Java EE and OSGi (aka hybrid application). Presentation held at Devcon12 2012 (Sweden, Karlskrona)

Statistics

Views

Total Views
1,303
Views on SlideShare
1,298
Embed Views
5

Actions

Likes
4
Downloads
0
Comments
0

2 Embeds 5

https://twitter.com 4
http://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Hybrid Applications Hybrid Applications Presentation Transcript

    • HYBRID APPLICATIONS - Combining the Power of Java EE and OSGiANDREAS ENBOHM (@enbohm)2012-09-13
    • 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 isused 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 Plain interface (not required)public interface PaymentService { public ProductReceipt pay(int productId);} EJB-annotation (convention over configuration)@Statelesspublic class PaymentEJB implements PaymentService { public ProductReceipt pay(int productId){ //implementation goes here }}
    • TDD and Java EE Unit test - POJO Integration test - embedded container - arquillian - pax exam
    • TDD and Java EEEJBContainer 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 andoffers standardized ways to manage the softwarelifecycle.” - 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! © 2012 Capgemini. All rights reserved. 31
    • Hybrid Applications“a hybrid application bundle is an OSGi bundle as wellas a Java EE module. Atruntime, it has both an OSGi bundle context and a JavaEE 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 ApplicationsHow to turn your JavaEE artifacts to OSGiServices?
    • Hybrid Applications Manifest.MF…Implementation-Title: hybridImplementation-Version: 1.3Bundle-ClassPath: WEB-INF/classes/Bundle-Name: hybridBundle-SymbolicName: com.acme.hybrid.service.implBundle-Version: 1.3.0Export-EJB: ALLWeb-ContextPath: /hybrid… WAB (web application bundle); OSGi Spec. 4.2
    • Hybrid Applications EJB artifacts + Manifest.MF = ’Declarative’ Service - Enterprise Application Bundle (EAB) - Web Application Bundle (WAB) Export-EJB: 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")); With CDI annotation: @Inject @OSGiService(dynamic=true) Hello hello; System.out.println(hello.sayHello("Duke"));
    • PROVE IT ! (Demo time) Asyncronous invocations Events Decorators Service update (hot deployment) REST service
    • Demo Overview HybridCommon (standard OSGi bundle containing domain objects) <uses> <uses> HybridClient OSGi Service HybridBackend(WAB exposes a service via Jax-RS) Registry (EJB as OSGi service, EAB) <discover> <publish>
    • 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
    • USEFUL LINKSwww.osgi.orgwww.glassfish.orghttp://www.oracle.com/technetwork/java/javaee/overview/index.htmlhttp://www.jboss.org/arquillian.htmlhttp://mreinhold.org/blog/late-for-the-train-qa | Sector, Alliance, Offering
    • Q&Ahttp://www.slideshare.net/enbohm Twitter: @enbohm © 2012 Capgemini. All rights reserved. 49
    • www.se.capgemini.comThe information contained in this presentation is proprietary. ©2012 Capgemini. All rights reserved