OSGi in WebSphere : The Story so far

Similar documents
Using OSGi in Modular WebSphere Applications

WebSphere Application Server Support for OSGi Applications

Enterprise Development

OSGi Best Practices. Emily

Is OSGi Ready for the Enterprise?

Modular Java Applications with Spring, dm Server and OSGi

Hands-on Development of Web Applications with Java EE 6

Deccansoft Software Services. J2EE Syllabus

IBM WebSphere Application Server 8. Java EE 6 Feature Packs

WebSphere Application Server V8 New Features and a primer on WAS V8.5

J2EE - Version: 25. Developing Enterprise Applications with J2EE Enterprise Technologies

Oracle - Developing Applications for the Java EE 7 Platform Ed 1 (Training On Demand)

Leverage Rational Application Developer v8 to develop OSGi application and test with Websphere Application Server v8

Java EE 7 is ready What to do next? Peter Doschkinow Senior Java Architect

Developing Applications with Java EE 6 on WebLogic Server 12c

16562: Liberté, Égalité, Fraternité a Mini CICS and WebSphere Revolution

Java J Course Outline

Development of Advanced Applications with IBM WebSphere Application Server Liberty Profile IBM Redbooks Solution Guide

2017, IBM Corporation Liberty z/os Good Practices. WebSphere Liberty z/os Applications and Application Deployment

1 Markus Eisele, Insurance - Strategic IT-Architecture

IBM. IBM WebSphere Application Server Migration Toolkit. WebSphere Application Server. Version 9.0 Release

Oracle Corporation

Java Platform, Enterprise Edition 6 with Extensible GlassFish Application Server v3

Introduction. Enterprise Java Instructor: Please introduce yourself Name Experience in Java Enterprise Edition Goals you hope to achieve

From Development to Production with the IBM WebSphere Application Server Liberty Profile IBM Redbooks Solution Guide

Spring Framework 2.5: New and Notable. Ben Alex, Principal Software Engineer, SpringSource

Java EE 7: Back-End Server Application Development

Vision of J2EE. Why J2EE? Need for. J2EE Suite. J2EE Based Distributed Application Architecture Overview. Umair Javed 1

IBM WebSphere Application Server v6


J2EE Interview Questions

Java EE 5 Development for WebSphere Application Server V7

JavaEE.Next(): Java EE 7, 8, and Beyond

Java EE 6 - Update Harpreet Singh GlassFish Portfolio Product Manager

<Insert Picture Here> Productive JavaEE 5.0 Development

WebSphere Application Server What s new in WAS V7.0 for Developers

OSGi on the Server. Martin Lippert (it-agile GmbH)

Designing a Distributed System

J2EE Development. Course Detail: Audience. Duration. Course Abstract. Course Objectives. Course Topics. Class Format.

<Insert Picture Here> Exploring Java EE 6 The Programming Model Explained

Java- EE Web Application Development with Enterprise JavaBeans and Web Services

WebSphere Application Server - Overview

JBoss SOAP Web Services User Guide. Version: M5

User s Guide 12c (12.2.1)

Leverage Rational Application Developer v8 to develop Java EE6 application and test with WebSphere Application Server v8

Oracle Corporation

Overview p. 1 Server-side Component Architectures p. 3 The Need for a Server-Side Component Architecture p. 4 Server-Side Component Architecture

Architecting Java solutions for CICS

1Z Oracle. Java Enterprise Edition 5 Enterprise Architect Certified Master

IBM Web Enablement for IBM i, V6.1 gives you an IT-centric entry point to SOA

11-15 DECEMBER ANTWERP BELGIUM

7.1. RELEASE-NOTES-2.0-M1.TXT

EclipseLink. Solutions Guide for EclipseLink Release 2.6. June Beta Draft

Fast Track to EJB 3.0 and the JPA Using JBoss

IBM WebSphere Enterprise Service Bus V7.0, Integration Development Exam.

ISV Technical Executive Forum 2011

Techniques for Building J2EE Applications

CO Java EE 7: Back-End Server Application Development

<Insert Picture Here> Java Virtual Developer Day

EJB ENTERPRISE JAVA BEANS INTRODUCTION TO ENTERPRISE JAVA BEANS, JAVA'S SERVER SIDE COMPONENT TECHNOLOGY. EJB Enterprise Java

Migrating traditional Java EE applications to mobile

Oracle 10g: Build J2EE Applications

Java EE 6: Develop Web Applications with JSF

Apache TomEE Tomcat with a kick

Building the Enterprise

IBM EXAM - C IBM WebSphere Enterprise Service Bus V7.0, Integration Development. Buy Full Product.

Web Application Development Using JEE, Enterprise JavaBeans and JPA

Breaking Apart the Monolith with Modularity and Microservices CON3127

WebSphere Application Server - Overview

Copyright Oracle Corporation and VMware Inc, Enterprise Modules Project (Gemini) Proposal

Simplifying Migrations with the WebSphere Application Server Migration Toolkit

The Next Generation. Prabhat Jha Principal Engineer

index_ qxd 7/18/02 11:48 AM Page 259 Index

Leveraging Liberty IBM Integrated Web Application Server for i. Tim Rowe Architect Application Development

Exam Name: IBM Certified System Administrator - WebSphere Application Server Network Deployment V7.0

Web Application Development Using JEE, Enterprise JavaBeans and JPA

Liberate your components with OSGi services

What you need to know about CICS, Java and Liberty. Mark Cocker Senior Software Engineer, Java Hill Lead, IBM CICS Development

Enterprise Java Development using JPA, Hibernate and Spring. Srini Penchikala Detroit JUG Developer Day Conference November 14, 2009

Enterprise JavaBeans, Version 3 (EJB3) Programming

ORACLE DATA SHEET KEY FEATURES AND BENEFITS ORACLE WEBLOGIC SUITE

Java EE Application Assembly & Deployment Packaging Applications, Java EE modules. Model View Controller (MVC)2 Architecture & Packaging EJB Module

WAS V7 Application Development

SUN Sun Certified Enterprise Architect for J2EE 5. Download Full Version :

Programming Web Services in Java

Enterprise JavaBeans. Layer:01. Overview

Oracle Enterprise Pack for Eclipse

B. Assets are shared-by-copy by default; convert the library into *.jar and configure it as a shared library on the server runtime.

Component-Based Software Engineering. ECE493-Topic 5 Winter Lecture 26 Java Enterprise (Part D)

QUALITY SUPPORT FROM THE SOURCE.

Roadmap to Cloud with Cloud Application Foundation

WebSphere Application Server V8.0 Technical Overview

Data Management in Application Servers. Dean Jacobs BEA Systems

Rational Application Developer 7 Bootcamp

CMP 436/774. Introduction to Java Enterprise Edition. Java Enterprise Edition

INTRODUCTION TO COMPONENT DESIGN IN JAVA EE COMPONENT VS. OBJECT, JAVA EE JAVA EE DEMO. Tomas Cerny, Software Engineering, FEE, CTU in Prague,

Spring & Hibernate. Knowledge of database. And basic Knowledge of web application development. Module 1: Spring Basics

NetBeans IDE Field Guide

WebSphere Application Server v7.0

OSGi Application Development using GlassFish Server. Version 1.0

Transcription:

OSGi in WebSphere : The Story so far, IBM Hursley chris.wilkinson@uk.ibm.com

Disclaimer IBM s statements regarding its plans, directions, and intent are subject to change or withdrawal without notice at IBM s sole discretion. Information regarding potential future products is intended to outline our general product direction and it should not be relied on in making a purchasing decision. The information mentioned regarding potential future products is not a commitment, promise, or legal obligation to deliver any material, code or functionality. Information about potential future products may not be incorporated into any contract. The development, release, and timing of any future features or functionality described for our products remains at our sole discretion. 2

Agenda A Brief history of OSGi A Brief history of Enterprise OSGi Enterprise OSGi in WebSphere Application Server What s new in the WAS85 Beta? EJB Support Migrating to OSGi 3

A Brief history of OSGi... 4

A (very) brief history of programming In the beginning, there were bits... 0101011101001001010010010011011101101101101 0101011101001001010010010011011101101101101 5

A (very) brief history of programming Then came words... mov mov mov mov int int ah,9 ah,9 dx,offset dx,offset hello_message hello_message 21h 21h 6

A (very) brief history of programming... functions and libraries... #include <stdio.h> #include main() { <stdio.h> main()printf { ("Hello World!\n"); printf ("Hello World!\n"); } } 7

A (very) brief history of programming... objects... public class HelloWorldSayer { public class HelloWorldSayer { public void sayhello() { public void sayhello() { System.out.println("Hello, world!\n"); System.out.println("Hello, world!\n"); } } } } 8

A (very) brief history of programming... and then OSGi Import-Package : com.ibm.services.helloworldservice;version=8.0.0; Import-Package: :com.ibm.client.helloworldclient com.ibm.services.helloworldservice;version=8.0.0; Export-Package Export-Package : com.ibm.client.helloworldclient public class HelloWorldClient { publichelloworldservice class HelloWorldClient service{ = null; HelloWorldService service = null; } public void startup() { publicservice.hello(); void startup() { service.hello(); } } } 9

What was wrong with where we were? 10

What was wrong with where we were? A question of scale 11

Direct dependency Indirect (soft) dependency Optional dependencies Java EE Web technologies Web Container JNDI JAXP JAAS JMX JSF JSTL CDI & DI HTTP/SSL JASPIC StAX EJB JPA Debug JAXR Common Annotations JCA JDBC JACC JTA JMS WS Metadata Web Services JAXB JAX-WS JAX-RPC SAAJ JAX-RS JavaMail JAF IDL Management JSP Servlet RMI-IIOP Enterprise APIs in Java SE (Required for Java EE) 12

Direct dependency Indirect (soft) dependency Optional dependencies Java EE Web technologies Web Container Manage ment JPA JACC JTA Comm on Annota tions Debu g JMS WS Metadata Web Services JCA JAAS StAX JAXR JAX-WS JAXB JAXP EJB JNDI CDI & DI HTTP/SS JASPIC L JDBC JSTL JAX-RPC JAX-RS JavaMail JAF SAAJ IDL JSP JSF Servlet JMX RMI-IIOP Enterprise APIs in Java SE (Required for Java EE) HTTP Session Replication Connection Management Admin Console and scripting Logging and Tracing MBean Server Transport Channels Workload Management Thread management Classloading Persistence Providers DataSources HTTP Serving and routing Provisioning User Registries Messaging Engines High Availability Management Monitoring Event Mgmt Security Transaction Logging and Recovery Policy and SLA mgmt Configuration 13

Beyond Java EE Direct dependency Java EE Web technologies Indirect (soft) dependency Optional dependencies Batch Web Container Servlet JSP Telephony BPM CDI & DI Business Rules JSF JSTL WS Metadata HTTP/SSL JASPIC EJB JPA Management JAXR JACC JTA JMS JavaMail Web Services JAX-WS JAX-RPC JAX-RS SCA StAX Complex Event Processing Common Annotations Debug JCA SAAJ JAXB JAF IDL Dynamic Scripting JDBC JNDI JAXP JAAS JMX RMI-IIOP Enterprise APIs in Java SE (Required for Java EE) HTTP Session Replication Connection Management Admin Console and scripting Logging and Tracing MBean Server Transport Channels Workload Management Thread management Classloading Persistence Providers DataSources HTTP Serving and routing Provisioning User Registries Messaging Engines High Availability Management Monitoring Event Mgmt Security Transaction Logging and Recovery Policy and SLA mgmt Configuration 14

Requirements of Modular Programming Module Re-use Reduce development time Module Sharing Reduce Disk Footprint Reduce Memory Footprint Module Access Controlled access to specific contents Ease of Development Module Maintenance Loose-Coupling enables easy module updates Versioning policy 15

Java Modularity Limitations Unit of Modularity is a JAR No explicit dependency control between JARs Which packages does my JAR need? Which JARs use my packages? At the mercy of the Classpath! 16

Modular Programming with OSGi Introducing the OSGi Bundle Jar Bundle Package Package Class Class Class Class Class Class Package Package Class Class Class Class Class Class Package Package Class Class Class Class Class Class Manifest + OSGi Headers 17

OSGi : The Bundle Manifest What s in the manifest? Export-Package: What packages from this bundle are visible and reusable outside of the bundle? Import-Package: What packages from other bundles does this bundle depend upon? Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: MyService bundle Bundle-SymbolicName: com.sample.myservice Bundle-Version: 1.0.0 Bundle-Activator: com.sample.myservice.activator Import-Package: com.something.i.need;version="1.1.2" Export-Package: com.myservice.api;version="1.0.0" 18

Modular Programming with OSGi Bundles are installed to an embedded OSGi Framework JVM Provides 3 Layers OSGi Framework Module Lifecycle Bundle1 Bundle2 Bundle3 Services 19

OSGi : The Module Layer Class Loading Each bundle has its own loader No flat or monolithic classpath Class sharing and visibility decided by declarative dependencies, not by class loader hierarchies OSGi framework works out the dependencies including versions 20

S OSGi : The Service Layer Bundles are loosely coupled by communicating via Services. The OSGi framework provides a non-durable Service Registry Services are published to and discovered from this Service Registry. Services are the primary means of collaboration between bundles. Services are fully dynamic and typically have the same lifecycle as the bundle that provides them. 21

Modular Programming with OSGi Module Access JVM OSGi Framework Each bundle can be isolated by declaring exactly what is exported from within. Total control over access to bundle contents 22

Modular Programming with OSGi Module Re-Use JVM All dependencies are declared by the import header of the manifest Easy to reuse bundles in other scenarios. Services help to de-couple bundles OSGi Framework 23

Modular Programming with OSGi Module Sharing JVM The OSGi framework controls classloading to allow a single bundle instance to be shared amongst multiple applications. OSGi Framework 24

Modular Programming with OSGi Module Maintenance JVM The bundle manifest specifies a version. Dependencies requirements can specify a version range. Bundles with different versions can exist in the framework (We can have multiple versions of classes in use at same time in same JVM!) Using services provides plug points for extending and updating OSGi Framework 25

OSGi Origins : Modular Programming OSGi Java (SE) Applications Module Sharing Module Re-use Module Maintenance Module Access 26

OSGi Design Patterns Best Practices IBM DeveloperWorks article : http://www.ibm.com/developerworks/websphere/techjournal/1007_charters/1007_charters.html?ca=drs- 27

OSGi : An Open Standard OSGi is an open standard governed by the OSGi Alliance http://www.osgi.org OSGi has been used internally in WAS since V6.1 and in Eclipse since R3. The next step? OSGi for Enterprise Applications! 28

A Brief history of Enterprise OSGi... 29

OSGi Origins : Modular Programming in JEE? Same Java modularity issues exists inside each app. EAR1 JAR JAR JAR 30

OSGi Origins : Modular Programming in JEE? Same Java modularity issues exists inside each app. EAR1 JAR JAR JAR JAR JAR and extra modularity issues between application modules! EAR2 JAR 31

OSGi Origins : Modular Programming in JEE? Module Sharing Applications are isolated. Multiple copies of common JARs in each EBA Wasted Disk space! Wasted Memory! EAR1 JAR JAR JAR JAR JAR EAR2 Some help provided via WAS shared libraries but config is static and difficult to set up. JAR 32

OSGi Origins : Modular Programming in JEE? Module Maintenance EAR1 JAR JAR JAR JAR JAR Updating a JAR inside an EAR involves stopping entire application due to tight coupling of JARs. Large maintenance overheads. EAR2 JAR 33

OSGi Applications: Isolation versus Sharing OSGi v4.2 Framework Java EE App Server EAR 1 EAR 2 Module A Module A Module B Module G Module C Module C Isolation Sharing Which applications use module A? How many version of module C do I have deployed? Is module G being picked up from EAR 2 or the server runtime? Bundle B Bundle G Bundle C Everything shared Everything isolated 34 Bundle A Where are my applications? Did I intend application 1 to use application 2? How do I configure bundle A uniquely for each application? 34

Best of Both Worlds Java EE App Server EAR 1 EAR 2 Module A Module A Module B Module G Module C Module C WebSphere OSGi Applications Runtime OSGi App 2 OSGi App 1 Bundle B Bundle G Bundle A Bundle A Shared Bundle A Bundle B Bundle G Bundle C Bundle C Everything shared Everything isolated Single source for each binary Side-by-side version execution No accidental binding to server libraries Can share common services OSGi v4.2 Framework Bundle A Bundle C Isolated key application content Prevents accidental sharing Enables per-application configuration In-place update of running applications Dynamic extension of running applications 35 35

OSGi Application Bundle4 Bundle3 Isolated, cohesive collection of bundles Defined by application manifest Bundle2 OSGi Application Configuration by exception Bundle6 Deployed as.eba archive (zip file) Provisioning resolves application against archive contents and configured bundle repositories Transitive dependencies shared between applications Bundle1 shared Application Application Manifest Manifest Bundle1 Bundle3 Bundle4 Bundle6 Bundle2.eba 36

Enterprise OSGi : Also an Open Standard Enterprise OSGi an Open Standard OSGi Enterprise Expert Group (EEG) Apache Aries Using existing Java SE/EE specifications: JTA, JPA, JNDI, JMX, WebApps Includes SpringFramework-derived Blueprint Component Model for Dependency Injection Java EE is still the core enterprise application programming model Modular Programming benefits in a JEE App! 37

Enterprise OSGi in WebSphere Application Server 38

OSGi in WebSphere Application Server WebSphere Application Server V7 Feature Pack for OSGi Applications and Java Persistence API (JPA) 2.0 Available since May 2010 More downloads in a shorter period of time than any previous WAS v7 feature pack OSGi Feature enabled in core product for WebSphere Application Server v8. WebSphere Application Server v8.5 Beta 1 & 2 EJB Support 39

OSGi in the Application Server JEE Overview WAS Server Web Business Logic Persistence EAR Application WARs Servlets JSF JSP JARs JARs EJB SpringFramework JPA EntityBeans JNDI 40

OSGi in the Application Server OSGi with JEE WAS Server Web Business Logic Persistence EBA Application WABs Blueprint JSF Bundles Servlets POJO JNDI JPA EntityBeans Blueprint JSP Bundles Blueprint OSGi Service Registry 41

Bundle Repository Config in WAS 42

Application-centric Bundle Management 43

OSGi Service Registry and JNDI OSGi services are published to and looked up from OSGi service registry. Directly or from declarations in Blueprint XML Simplify integrating with existing JEE components: OSGi Services registered in the OSGi Service Registry are also available in JNDI via the osgi:service URL scheme Administered resources bound to JNDI are also published as services in the OSGi the Service Registry. The JNDI name is published as a service property called osgi.jndi.service.name 44

OSGi in the Application Server Lets look closer at Web Applications WAS Server Web Business Logic Persistence EBA Application WABs Blueprint JSF Bundles Servlets POJO JNDI JPA EntityBeans Blueprint JSP Bundles Blueprint OSGi Service Registry 45

Web Application Bundles (WABs) In-Built WAR to WAB convertor. No Java code changes; WAR modules -> WAB bundles 46

OSGi in the Application Server Lets look closer at Business Logic WAS Server Web Business Logic Persistence EBA Application WABs Bundles Servlets JSF POJO JNDI JPA EntityBeans Blueprint JSP Bundles Blueprint OSGi Service Registry 47

Blueprint Open Standard version of the SpringFramework Dependency Injection component. Configuration and Dependencies declared in Blueprint XML. In WAS, the Blueprint Container is a part of the Server runtime (SpringFramework is part of the application!) 48

Blueprint Components and Services dependencies injected publishes service A static assembly and configuration of components (POJOs) consumes service OSGI-INF/blueprint/ blueprint.xml Blueprint bundle Standardized Spring. Blueprint XML Extended for OSGi Services Simplifies unit test outside either Java EE or OSGi runtime 49

Exploiting Blueprint Components and Services e-commerce bundle <blueprint> <bean id= shop class= org.example.ecomm.shopimpl > <property name= billingservice ref= billingservice /> </bean> <reference id= billingservice interface= org.example.bill.billingservice /> </blueprint> public class ShopImpl { private BillingService billingservice; void setbillingservice(billingservice srv) { billingservice = srv; } e-commerce -injected service reference -service can change over time -can be temporarily absent without the bundle caring -managed by Blueprint container void process(order o) { billingservice.bill(o); } } 50

Exploiting Blueprint Components and Services Billing service bundle <blueprint> <service ref= service interface = org.example.bill.billingservice /> <bean id= service scope= prototype class= org.example.bill.impl.billingserviceimpl /> </blueprint> Billing public interface BillingService { void bill(order o); } 51

OSGi in the Application Server Lets look closer at Persistence Layer WAS Server Web Business Logic Persistence EBA Application WABs Bundles Servlets JSF POJO JNDI JPA EntityBeans Blueprint JSP Bundles Blueprint OSGi Service Registry 52

Blueprint Persistence and Transactions OpenJPA is default persistence provider in WebSphere Container managed JPA support integrated into Blueprint container: @PersistenceUnit or @PersistenceContext (managed) or <jpa:unit>, <jpa:context> bean property injection Familiar development experience for JPA developers Load-time enhancement of Entity classes Same container managed transaction attributes as EJBs: Required, RequiresNew, Mandatory, NotSupported, Supports, Never <blueprint> <bean id= shop class= org.example.ecomm.shopimpl > <jpa:context property="em" unitname="myunit"/> <tx:transaction method="*" value="required"/> </bean> </blueprint> 53

Further OSGi Support : SCA Integration Customer Component (POJO) Component JMS Warehouse Component (JEE) Application SCA Composite Bundle Bundle SCA Composite assembled from heterogeneous components including an OSGi Application component, and integrated through SCA services with configurable bindings (JMS, web services ). OSGi Bundles assembled in an OSGi Application and integrated through services in the OSGi service registry Application POJO POJO POJO Bundle POJOs assembled using a Blueprint context and scoped by an OSGi Bundle. 54

SCA integration: implementation.osgiapp Manifest-Version: 1.0 Manifest-Version: 1.0 Application-ManifestVersion: 1.0 Application-ManifestVersion: Application-Name: Aries Blog 1.0 Application-Name: Aries Blog Application-SymbolicName: com.ibm.ws.eba.example.blog.app Application-SymbolicName: com.ibm.ws.eba.example.blog.app Application-Version: 1.0 Application-Version: 1.0 Application-Content: Application-Content: com.ibm.ws.eba.example.blog.api;version="1.0.0", com.ibm.ws.eba.example.blog.api;version="1.0.0", com.ibm.ws.eba.example.blog.persistence;version="1.0.0", com.ibm.ws.eba.example.blog.persistence;version="1.0.0", com.ibm.ws.eba.example.blog.web;version="1.0.0", com.ibm.ws.eba.example.blog.web;version="1.0.0", com.ibm.ws.eba.example.blog;version="1.0.0" com.ibm.ws.eba.example.blog;version="1.0.0" Use-Bundle: com.ibm.json.java;version="[1.0.0,2.0.0)" Use-Bundle: com.ibm.json.java;version="[1.0.0,2.0.0)" Application-ExportService: Application-ExportService: com.ibm.ws.eba.example.blog.blog com.ibm.ws.eba.example.blog.blog Application-ImportService: Application-ImportService: com.ibm.ws.eba.example.blog.userauthorization com.ibm.ws.eba.example.blog.userauthorization BlogComponent api api persistence persistence web web blog blog <component name="com.ibm.ws.aries.example.blogcomponent"> <component name="com.ibm.ws.aries.example.blogcomponent"> <service name="bloggingservice"> <service name="bloggingservice"> <interface.java interface="com.ibm.ws.eba.example.blog.blog" /> <interface.java interface="com.ibm.ws.eba.example.blog.blog" /> <binding.ws <binding.ws port="http://www.blogging.org/blogservice#wsdl.endpoint(blogservice/blogservicesoap)" /> port="http://www.blogging.org/blogservice#wsdl.endpoint(blogservice/blogservicesoap)" /> </service> </service> <reference name="userauthorization"> <reference name="userauthorization"> <interface.java interface="com.ibm.ws.eba.example.blog.userauthorization" /> <interface.java interface="com.ibm.ws.eba.example.blog.userauthorization" /> </reference> </reference> <sfp:implementation.osgiapp applicationsymbolicname="com.ibm.ws.aries.example.blog.app" <sfp:implementation.osgiapp applicationsymbolicname="com.ibm.ws.aries.example.blog.app" applicationversion="1.0.0" /> applicationversion="1.0.0" /> </component> </component> 55

RAD v8 OSGi Application Development Support 56

What s new in the WAS8.5 Betas? 57

EJB Support! EJB Jar + OSGi Metadata = EJB Bundle Export-EJB: Opt-in header for EJB Bundles Existence: process bundle for EJBs Absence: do not process bundle for EJBs, even if it contains them Header value governs registration of EJBs as OSGi Services Excludes Stateful beans Best practice: only export EJBs to be shared outside bundle Example Meaning Export-EJB: Process all EJBs Export-EJB: BlogBiz, BlogPersistence Process all EJBs, register BlogBiz and BlogPersistence as Services if they exist Export-EJB: NONE RESERVED Export-EJB: ALL Process all EJBs and register all supported types as Services EJBs run in the same WAS EJB Container Uses OSGi for Classloading and Life-cycle 58 58

Example: Order Application using EJBs order.api order.web order.service Order Application EJB Bundle included like any other bundle. Use of EJB is an implementation detail. APPLICATION.MF Application-Name: Application-Name: Order Order processing processing application application Application-SymbolicName: Application-SymbolicName: com.acme.order.app com.acme.order.app Application-ManifestVersion: Application-ManifestVersion: 1.0 1.0 Application-Version: Application-Version: 1.0.0 1.0.0 Manifest-Version: Manifest-Version: 1.0 1.0 Application-Content: Application-Content: com.acme.order.service;version="[1.0, com.acme.order.service;version="[1.0, 1.1)", 1.1)", com.acme.order.api;version="[1.0, com.acme.order.api;version="[1.0, 1.1)", 1.1)", com.acme.order.web;version="[1.0, com.acme.order.web;version="[1.0, 1.1)" 1.1)" 59 59

Example: Order EJB Bundle OrderEJB implemented as normal local EJB EJB 3.x style only (2.x not supported) /** /** ** Local Local stateless stateless session session Order Order EJB EJB */ */ @Local @Local @Stateless @Stateless public public class class OrderEJB OrderEJB implements implements Order Order {{...... Best practices: Put interfaces and EJB implementations in separate bundles and separate packages Annotate @Local and/or @Remote on the EJB implementation classes* OrderEJB named in Export-EJB header so registered as an OSGi service under the Order interface Imports the packages it needs: Order API EJB }} @Override @Override public public String String process() process() {{...... return return "Order "Order Processed"; Processed"; }} Manifest-Version: Manifest-Version: 1.0 1.0 Bundle-ManifestVersion: Bundle-ManifestVersion: 22 Bundle-Name: Bundle-Name: Acme Acme order order processing processing service service Bundle-SymbolicName: Bundle-SymbolicName: com.acme.order.service com.acme.order.service Bundle-Version: Bundle-Version: 1.0.0 1.0.0 Export-EJB: Export-EJB: OrderEJB OrderEJB Import-Package: Import-Package: com.acme.order.api;version="[1.0.0,1.1.0)", com.acme.order.api;version="[1.0.0,1.1.0)", javax.ejb;version="3.1" javax.ejb;version="3.1" *annotations not processed outside the EJB bundle 60 60

Example: Order Web Front-end EJB 3.1 allows EJBs in a WAR (supported) but best practices suggest separating business logic from presentation logic Order EJB access: As EJB via injection or EJB JNDI lookup /** /** ** Order Order EJB EJB to to be be injected injected */ */ @EJB @EJB private private Order Order orderservice orderservice == null; null; orderservice orderservice == (Order) (Order) new new InitialContext().lookup("java:comp/env/com.acme.order.View/orderService"); InitialContext().lookup("java:comp/env/com.acme.order.View/orderService"); As an OSGi Service (helps decouple life-cycle for dynamic update) orderservice orderservice == (Order) (Order) new new InitialContext().lookup("osgi:service/com.acme.order.api.Order"); InitialContext().lookup("osgi:service/com.acme.order.api.Order"); orderservice orderservice == (Order) (Order) new new InitialContext().lookup("blueprint:comp/orderService"); InitialContext().lookup("blueprint:comp/orderService"); <blueprint <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" >> <reference <reference id="orderservice id="orderservice interface="com.acme.order.api.order"/> interface="com.acme.order.api.order"/> </blueprint> </blueprint> 61 61

EJB/Service Look-up Comparison Style Re-acquirable Re-injectable Damped Details @EJB No No No Use when simple, static injection is all that s required java:comp/env Yes No No Use for existing java:comp lookups osgi:service Yes Yes No Use when dynamic lifecycle required, but no damping blueprint:comp Yes Yes Yes Use when dynamic lifecycle and damping are required. Requires additional use of Blueprint 62 62

Tools: RAD 8.5 beta Initial EJB Bundle Project support OSGi Bundle Project + EJB Module Facet Familiar layout for EJB developers Uses PDE for build and validation 63 63

EJB Related Topics In-place Update EJB Bundles can participate in in-place updates. Use of Blueprint references and OSGi Service registry for EJB access recommended to take advantage of service damping and minimise update impact. Application Extension EJB Bundles can be included as extension content. Use of Blueprint references and OSGi Service registry for EJB access recommended to pick up extensions without application restart and to minimise impact of extensions on running application. Remoting @Remote EJBs exported to OSGi service registry treated like any other remote OSGi service and can be exported/bound using SCA. EJBs can look up SCA imported remote OSGi services through JNDI (using osgi:service or blueprint:comp schemes). Transactions & Security Work as for non-osgi Java EE EJBs 64 64

WAS8.5 Beta New Features : Blueprint Security Role based authorization Bean Security in XML Roles mapped to users at deploy time 65

WAS 8.5 Beta New Features : Java 7 Support Full Java 7 Support in WAS v8.5 Beta Includes OSGi support 66

Migrating to OSGi : Hints and Tips 67

Migration Approach 1 : The Big Bundle Put everything into one bundle Get it working Pick out libraries into individual bundles Keep it working! Pick out related content into separate bundles. Keep it working! Turn dependencies into service consumer/provider pairs Keep it working! 68

Migration Approach 2 : Service First Approach Identify logical relationships in the system Expose as services (POJO SR) Use the relationships to group content into similar JARs Turn into bundles (BND tools) 69

Migration Migration Tools : BND Tools Maven Plugin POJO SR Migration experience still in infancy Articles appearing : Conversion of Apache Tuscany to OSGi http://www.slideshare.net/luckbr1975/tuscany-applying-o-s-gi-after-the-fact Converting Large apps to OSGi http://download.oracle.com/javaone/javaone2008-ee.zip 70

Summary Modular Programming is not supported fully in : JAVA (SE) JAVA (EE) The Solution for JAVA (SE) applications OSGi The Solution for JAVA (EE) applications Enterprise OSGi Fully implemented in WASv7 and v8 EJB Support in the new v8.5 Beta Hints and Tips for Migration to OSGi 71

Useful Links OSGi Best Practices Developerworks Article http://www.ibm.com/developerworks/websphere/techjournal/1007_charters/1007_charters.html?ca=drs- Spring Application Migration http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.osgifep.multiplatform.doc/topics/ta_mig.html Resource Hub (articles, tutorials, redbooks, forums) http://www.ibm.com/software/websphere/osgi Team Blogs/Twitter/YouTube www.ianrobinson.blogspot.com www.devangelist.blogspot.com www.youtube.com/user/enterpriseosgi @sjmaple @notatibm @TimothyWard 72

Questions? 73

Copyright and Trademarks IBM Corporation 2012. All rights reserved. IBM, the IBM logo, ibm.com and the globe design are trademarks of International Business Machines Corporation, registered in many jurisdictions worldwide. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at www.ibm.com/legal/copytrade.shtml. Other company, product, or service names may be trademarks or service marks of others. 74