SlideShare a Scribd company logo
1 of 40
Download to read offline
Modular Web Applications
       with OSGi
eJUG Seminar              Sam Brannen
Linz, Austria       Software Consultant
17 September 2009
Speaker Profile
          Software Consultant
          Spring Framework Core Developer
          Previous SpringSource dm Server™ developer: OSGi-
                   enabled Web deployment models, Tomcat integration,
                   Test Framework

          Java developer with 10+ years' experience
          Regular speaker at conferences on Spring, dm Server,
                   Java, OSGi, and testing

          Co-author of Spring in a Nutshell; chief technical
                   reviewer for Spring Recipes

Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          2
Overview
    The Challenge?
    Monolithic WAR deployments hinder both
    development and runtime modularity and promote
    library bloat.

    The Solution!
    Harness the flexibility of the OSGi Web Container
    standard, Spring, Spring-DM, and the SpringSource
    dm Server™.




Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          3
Agenda
          Status Quo
          OSGi
          Spring DM
          OSGi Web Container
          SpringSource dm Server™
          Demos
          Q&A



Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          4
Status Quo




Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          5
Standard Java EE WAR
          Java Servlet 2.5
          WAR format
                           Static content
                           Dynamic content
                           WEB-INF
                           WEB-INF/classes
                           WEB-INF/lib

          All-in-one deployment model
          EAR
          Container shared libraries

Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          6
Introduction to Demos
     Spring MVC 2.5 based "Hello World" web application
     Domain model: HelloMessage
     Service layer: HelloService, HelloServiceImpl
     Presentation layer:
                Controllers: HelloController
                Views: JSP + JSTL




Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          7
DEMO

            Standard WAR




Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          8
OSGi




Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          9
It's a module system
     Partition a system into a number of modules –
             “bundles”
     Dynamic: bundles can be installed, started, stopped,
             uninstalled and updated ... at runtime!
     Strict visibility rules
     Resolution process satisfies dependencies of a
             module
     Versioning
        Packages & Services
        Deploy multiple versions of a module
Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          10
It's even service-oriented
          Bundles can publish services… dynamically!


          Service Registry allows other bundles to consume
                   services


          Services come and go at runtime
                     … transparently when using Spring-DM




Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          11
OSGi Bundle
          The fundamental unit of deployment and
                   modularity in OSGi
          Just a JAR file
                     with additional entries in META-INF/MANIFEST.MF
          Common manifest headers:
                           Bundle-SymbolicName
                           Bundle-Version
                           Bundle-Name
                           Bundle-ManifestVersion
                           Export-Package
                           Import-Package


Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          12
Export & Import Packages
   Declare package-level visibility and dependencies of
   your bundle.

   Export-Package: com.xyz.bar
   Export-Package: com.xyz.bar;version="1.0.5"
   Import-Package: com.xyz.foo
                                      >= 1.0.3; e.g.,
   Import-Package:                    1.0.3, 1.0.3.GA,
     com.xyz.foo;version="1.0.3"      1.0.4, 2.0, etc.
   Import-Package:
     com.xyz.foo;version="[1.0.3,1.0.3]"
   Import-Package:
     com.xyz.foo;version="[1.0.3,1.1.0)",
     com.xyz.bar;version="[1.0.3,2.0.0)"
Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          13
Publish a Service

              ServiceRegistration reg =
                bundleContext.registerService(
                 Bar.class.getName(), myBarService);
              ...
              reg.unregister();




Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          14
Consume a Service
   ServiceReference ref =

             bundleContext.getServiceReference(
              Bar.class.getName());
             Bar bar = (Bar)
               bundleContext.getService(ref);
             ...
             bundleContext.ungetService(ref);
             // bar should no longer be used here

                             Complex… Potential resource leaks!
Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          15
Implementations & Tools
          OSGi implementations:
                     Equinox
                     Knopflerfish
                     Felix
          IDEs
                     Eclipse PDE
                     SpringSource Tool Suite

          Build support:
                     BND
                     Bundlor


Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          16
Spring DM




Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          17
Spring-DM: App. Context
          Configuration files in /META-INF/spring
          Automatically merged
          ..and an ApplicationContext is created
                     one per Bundle



          Spring-DM manages the ApplicationContext lifecycle
          OSGi manages the Bundle lifecycle




Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          18
Spring-DM: Service Registry
                                                                                                                                          Contrast with programmatic
 <beans ...>                                                                                                                                          API
            <osgi:service ref="customerDAO"

                      interface="dao.CustomerDAO" />

            <osgi:reference id="dataSource"

                      interface="javax.sql.DataSource" />

 </beans>

 Also supports filters, listeners, collections (lists and sets), etc.


Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                                                   19
Spring-DM: Service Registry
          Dynamic services handled automatically
                     Instances and collections are proxied
                     Method calls are buffered
                     Configurable timeouts
          Purely declarative
                     Application code is typically decoupled from OSGi
          Spring’s POJO programming model
          Testable, out-of-container




Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          20
Out-of-scope for Spring-DM
          Easy import of bundles and libraries
          Using JPA or Hibernate in OSGi
          Seamless Web support
          Notion of an application


          Enter:
                     OSGi Web Container
                     SpringSource dm Server



Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          21
OSGi Web Container




Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          22
Web Bundle
          RFC 66: OSGi Web Container specification
          Reference implementation by SpringSource
          Web Bundle = web application in OSGi
          Multiple supported formats
                     Standard WAR
                     Shared Libraries WAR
                     Shared Services WAR
          Context path defined via query parameter or in
                   manifest:
                     Web-ContextPath: /my-web-app

Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          23
OSGi Web Migration Path
  Status quo: everything in a
       monolithic WAR


  Goals:
            Libraries: eradicate library bloat
            Services: OSGi Service Registry


  Results: decrease overall
       footprint




Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          24
Standard Java EE WAR
     Supported as is
     The WAR file is transformed into an OSGi bundle and
         installed into the Servlet Container

     All standard WAR contracts are honored
     Easy on-ramp for web applications in OSGi




Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          25
Shared Libraries WAR
     Eradicate the library bloat of monolithic Java EE WARs
     Declare dependencies via OSGi manifest headers
              •  Import-Package & Require-Bundle
              •  Import-Library & Import-Bundle  Import-Package

     Reduce application deployment footprint
     SpringSource Enterprise Bundle Repository: central
         source for OSGi bundles




Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          26
DEMO

            Shared Libraries WAR




Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          27
Shared Services WAR
     Share services between bundles and web applications
     Spring-DM simplifies usage of the OSGi Service Registry
                Publish services via <osgi:service … />
                Consume them via <osgi:reference … />

    • ServerOsgiBundleXmlWebApplicationContext: use as
         contextClass property for ContextLoaderListener and
         DispatcherServlet
     Program to interfaces and decouple web artifacts from the
         domain model, services, infrastructure, etc.




Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          28
DEMO

            Shared Services WAR




Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          29
SpringSource dm Server™




Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          30
dm Server Architecture
 Built on Equinox
 Modular architecture
    Subsystems
    Bundles
 Small footprint
 Modular profiles
 Bundle repository
 Library provisioning
 Serviceability
    FFDC
    Logging
    Tracing
  Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                            31
Import: Library & Bundle
          Plain OSGi + …
          Import-Library and Import-Bundle
                     Library imports  bundle imports
                     Bundle imports  package imports
                     OSGi runtime semantics remain the same


        Import-Library: org.springframework.spring;
          version="[2.5.6,3.0)"

        Import-Bundle: com.springsource.org.hibernate;
          version="[3.2.6.ga,3.2.6.ga]"


Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          32
PAR
  Packaging format for all
   modules in an app.
  JAR with Application-*
   manifest headers
  Single unit: deploy, refresh,
   undeploy
  Application boundaries
     Scoping of types / services
     DataSource does not leak out of
      the application
     Hibernate can change domain
      objects


 Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                           33
DEMO

            PAR




Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          34
Plan
          Conceptually similar to the PAR format:
                     Defines all modules within an application
                     Single configuration for deployment, etc.
                     Application boundaries
                              Scoping of types / services

          Differences:
                           Plan = XML file with „.plan“ extension
                           Application modules are referenced within XML
                           Modules are installed stand-alone in the repository
                           Control deployment order of modules
                           Share modules between plans
                           Configure scoping and atomicity


Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          35
Slices
          Slice = mechanism for extending a host web bundle
                     Goes beyond mere code
                     Slices can provide code and content to a host
                     Slices can use content and services from a host
          Analogous to OSGi fragments, slices attach to a host
                   web bundle:
                     Slice-Host: hello.war.host;version="[1.0,2.0)”
                     Slice-ContextPath: /de
          Host interacts with slices via slices tag library
          Slices provide configuration properties to host


Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          36
DEMO

            Slices




Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          37
Closing




Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          38
Further Resources
          OSGi:
                      http://osgi.org
                 Spring Framework:
                      http://springframework.org
                 Spring-DM:
                      http://springframework.org/osgi
                 SpringSource dm Server:
                      http://springframework.org/dmserver
                 SpringSource Team Blog:
                      http://blog.springsource.com
                 German Getting Started:
                      http://www.dpunkt.de/buecher/3231.html



Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          39
Q&A

        Sam Brannen

        sam [at] sambrannen [dot] com

        http://SamBrannen.com

        http://twitter.com/sam_brannen

Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
                                                                                                                                          40

More Related Content

Viewers also liked

Константин Маркович: "Creating modular application using Spring Boot "
Константин Маркович: "Creating modular application using Spring Boot "Константин Маркович: "Creating modular application using Spring Boot "
Константин Маркович: "Creating modular application using Spring Boot "Anna Shymchenko
 
Apache Karaf - Building OSGi applications on Apache Karaf - T Frank & A Grzesik
Apache Karaf - Building OSGi applications on Apache Karaf - T Frank & A GrzesikApache Karaf - Building OSGi applications on Apache Karaf - T Frank & A Grzesik
Apache Karaf - Building OSGi applications on Apache Karaf - T Frank & A Grzesikmfrancis
 
Service oriented web development with OSGi
Service oriented web development with OSGiService oriented web development with OSGi
Service oriented web development with OSGiCarsten Ziegeler
 
OSGi & Java EE in GlassFish - Best of both worlds
OSGi & Java EE in GlassFish - Best of both worldsOSGi & Java EE in GlassFish - Best of both worlds
OSGi & Java EE in GlassFish - Best of both worldsArun Gupta
 

Viewers also liked (6)

OSGi with the Spring Framework
OSGi with the Spring FrameworkOSGi with the Spring Framework
OSGi with the Spring Framework
 
Константин Маркович: "Creating modular application using Spring Boot "
Константин Маркович: "Creating modular application using Spring Boot "Константин Маркович: "Creating modular application using Spring Boot "
Константин Маркович: "Creating modular application using Spring Boot "
 
Apache Karaf - Building OSGi applications on Apache Karaf - T Frank & A Grzesik
Apache Karaf - Building OSGi applications on Apache Karaf - T Frank & A GrzesikApache Karaf - Building OSGi applications on Apache Karaf - T Frank & A Grzesik
Apache Karaf - Building OSGi applications on Apache Karaf - T Frank & A Grzesik
 
Service oriented web development with OSGi
Service oriented web development with OSGiService oriented web development with OSGi
Service oriented web development with OSGi
 
OSGi & Java EE in GlassFish - Best of both worlds
OSGi & Java EE in GlassFish - Best of both worldsOSGi & Java EE in GlassFish - Best of both worlds
OSGi & Java EE in GlassFish - Best of both worlds
 
IYRE forward into 2012
IYRE forward into 2012IYRE forward into 2012
IYRE forward into 2012
 

Similar to Modular Web Applications with OSGi

Enterprise Applications With OSGi and SpringSource dm Server
Enterprise Applications With OSGi and SpringSource dm ServerEnterprise Applications With OSGi and SpringSource dm Server
Enterprise Applications With OSGi and SpringSource dm ServerSam Brannen
 
What's New in Spring 3.0
What's New in Spring 3.0What's New in Spring 3.0
What's New in Spring 3.0Sam Brannen
 
Server Day 2009: Spring dm Server by Alef Arendsen
Server Day 2009: Spring dm Server by Alef ArendsenServer Day 2009: Spring dm Server by Alef Arendsen
Server Day 2009: Spring dm Server by Alef ArendsenJUG Genova
 
Integration and Batch Processing on Cloud Foundry
Integration and Batch Processing on Cloud FoundryIntegration and Batch Processing on Cloud Foundry
Integration and Batch Processing on Cloud FoundryJoshua Long
 
Spring integration integration, but not only...
Spring integration integration, but not only...Spring integration integration, but not only...
Spring integration integration, but not only...Artem Bilan
 
Philly Spring UG Roo Overview
Philly Spring UG Roo OverviewPhilly Spring UG Roo Overview
Philly Spring UG Roo Overviewkrimple
 
SDLC for Pivotal Platform powered by Spring Initializr and Concourse
SDLC for Pivotal Platform powered by Spring Initializr and ConcourseSDLC for Pivotal Platform powered by Spring Initializr and Concourse
SDLC for Pivotal Platform powered by Spring Initializr and ConcourseVMware Tanzu
 
LiMo Foundation BONDI SDK
LiMo Foundation BONDI SDKLiMo Foundation BONDI SDK
LiMo Foundation BONDI SDKmattswan
 
Towards Semantic Virtual Worlds
Towards Semantic Virtual WorldsTowards Semantic Virtual Worlds
Towards Semantic Virtual WorldsDavid Burden
 
OSGi Cloud Workshop - March 2010
OSGi Cloud Workshop - March 2010OSGi Cloud Workshop - March 2010
OSGi Cloud Workshop - March 2010mfrancis
 
(Oleg zhurakousky)spring integration-scala-intro
(Oleg zhurakousky)spring integration-scala-intro(Oleg zhurakousky)spring integration-scala-intro
(Oleg zhurakousky)spring integration-scala-introSkills Matter Talks
 
Jeremy Spring Source Blaze Ds
Jeremy Spring Source Blaze DsJeremy Spring Source Blaze Ds
Jeremy Spring Source Blaze DsSkills Matter
 
Hive solutions cloudviews 2010 presentation
Hive solutions cloudviews 2010 presentationHive solutions cloudviews 2010 presentation
Hive solutions cloudviews 2010 presentationEuroCloud
 
colony framework & omni platform
colony framework & omni platformcolony framework & omni platform
colony framework & omni platformHive Solutions
 

Similar to Modular Web Applications with OSGi (20)

Enterprise Applications With OSGi and SpringSource dm Server
Enterprise Applications With OSGi and SpringSource dm ServerEnterprise Applications With OSGi and SpringSource dm Server
Enterprise Applications With OSGi and SpringSource dm Server
 
What's New in Spring 3.0
What's New in Spring 3.0What's New in Spring 3.0
What's New in Spring 3.0
 
Zembly
ZemblyZembly
Zembly
 
Server Day 2009: Spring dm Server by Alef Arendsen
Server Day 2009: Spring dm Server by Alef ArendsenServer Day 2009: Spring dm Server by Alef Arendsen
Server Day 2009: Spring dm Server by Alef Arendsen
 
Integration and Batch Processing on Cloud Foundry
Integration and Batch Processing on Cloud FoundryIntegration and Batch Processing on Cloud Foundry
Integration and Batch Processing on Cloud Foundry
 
Spring integration integration, but not only...
Spring integration integration, but not only...Spring integration integration, but not only...
Spring integration integration, but not only...
 
Flash And Dom
Flash And DomFlash And Dom
Flash And Dom
 
Lo nuevo en Spring 3.0
Lo nuevo  en Spring 3.0Lo nuevo  en Spring 3.0
Lo nuevo en Spring 3.0
 
CloudFront Partner Webinar
CloudFront Partner WebinarCloudFront Partner Webinar
CloudFront Partner Webinar
 
Philly Spring UG Roo Overview
Philly Spring UG Roo OverviewPhilly Spring UG Roo Overview
Philly Spring UG Roo Overview
 
SDLC for Pivotal Platform powered by Spring Initializr and Concourse
SDLC for Pivotal Platform powered by Spring Initializr and ConcourseSDLC for Pivotal Platform powered by Spring Initializr and Concourse
SDLC for Pivotal Platform powered by Spring Initializr and Concourse
 
LiMo Foundation BONDI SDK
LiMo Foundation BONDI SDKLiMo Foundation BONDI SDK
LiMo Foundation BONDI SDK
 
Towards Semantic Virtual Worlds
Towards Semantic Virtual WorldsTowards Semantic Virtual Worlds
Towards Semantic Virtual Worlds
 
OSGi Cloud Workshop - March 2010
OSGi Cloud Workshop - March 2010OSGi Cloud Workshop - March 2010
OSGi Cloud Workshop - March 2010
 
(Oleg zhurakousky)spring integration-scala-intro
(Oleg zhurakousky)spring integration-scala-intro(Oleg zhurakousky)spring integration-scala-intro
(Oleg zhurakousky)spring integration-scala-intro
 
Jeremy Spring Source Blaze Ds
Jeremy Spring Source Blaze DsJeremy Spring Source Blaze Ds
Jeremy Spring Source Blaze Ds
 
Amazon CloudFront 101
Amazon CloudFront 101Amazon CloudFront 101
Amazon CloudFront 101
 
Hive solutions cloudviews 2010 presentation
Hive solutions cloudviews 2010 presentationHive solutions cloudviews 2010 presentation
Hive solutions cloudviews 2010 presentation
 
colony framework & omni platform
colony framework & omni platformcolony framework & omni platform
colony framework & omni platform
 
Windows Azure Essentials
Windows Azure EssentialsWindows Azure Essentials
Windows Azure Essentials
 

More from Sam Brannen

Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023
Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023
Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023Sam Brannen
 
Testing with JUnit 5 and Spring - Spring I/O 2022
Testing with JUnit 5 and Spring - Spring I/O 2022Testing with JUnit 5 and Spring - Spring I/O 2022
Testing with JUnit 5 and Spring - Spring I/O 2022Sam Brannen
 
JUnit 5 - Evolution and Innovation - SpringOne Platform 2019
JUnit 5 - Evolution and Innovation - SpringOne Platform 2019JUnit 5 - Evolution and Innovation - SpringOne Platform 2019
JUnit 5 - Evolution and Innovation - SpringOne Platform 2019Sam Brannen
 
JUnit 5: What's New and What's Coming - Spring I/O 2019
JUnit 5: What's New and What's Coming - Spring I/O 2019JUnit 5: What's New and What's Coming - Spring I/O 2019
JUnit 5: What's New and What's Coming - Spring I/O 2019Sam Brannen
 
JUnit 5 - New Opportunities for Testing on the JVM
JUnit 5 - New Opportunities for Testing on the JVMJUnit 5 - New Opportunities for Testing on the JVM
JUnit 5 - New Opportunities for Testing on the JVMSam Brannen
 
Get the Most out of Testing with Spring 4.2
Get the Most out of Testing with Spring 4.2Get the Most out of Testing with Spring 4.2
Get the Most out of Testing with Spring 4.2Sam Brannen
 
JUnit 5 - from Lambda to Alpha and beyond
JUnit 5 - from Lambda to Alpha and beyondJUnit 5 - from Lambda to Alpha and beyond
JUnit 5 - from Lambda to Alpha and beyondSam Brannen
 
Testing with Spring: An Introduction
Testing with Spring: An IntroductionTesting with Spring: An Introduction
Testing with Spring: An IntroductionSam Brannen
 
Testing with Spring 4.x
Testing with Spring 4.xTesting with Spring 4.x
Testing with Spring 4.xSam Brannen
 
Spring Framework 4.1
Spring Framework 4.1Spring Framework 4.1
Spring Framework 4.1Sam Brannen
 
Testing Spring MVC and REST Web Applications
Testing Spring MVC and REST Web ApplicationsTesting Spring MVC and REST Web Applications
Testing Spring MVC and REST Web ApplicationsSam Brannen
 
Composable Software Architecture with Spring
Composable Software Architecture with SpringComposable Software Architecture with Spring
Composable Software Architecture with SpringSam Brannen
 
Testing Web Apps with Spring Framework 3.2
Testing Web Apps with Spring Framework 3.2Testing Web Apps with Spring Framework 3.2
Testing Web Apps with Spring Framework 3.2Sam Brannen
 
Spring Framework 4.0 to 4.1
Spring Framework 4.0 to 4.1Spring Framework 4.0 to 4.1
Spring Framework 4.0 to 4.1Sam Brannen
 
Spring Framework 4.0 - The Next Generation - Soft-Shake 2013
Spring Framework 4.0 - The Next Generation - Soft-Shake 2013Spring Framework 4.0 - The Next Generation - Soft-Shake 2013
Spring Framework 4.0 - The Next Generation - Soft-Shake 2013Sam Brannen
 
Spring Framework 3.2 - What's New
Spring Framework 3.2 - What's NewSpring Framework 3.2 - What's New
Spring Framework 3.2 - What's NewSam Brannen
 
Spring 3.1 and MVC Testing Support - 4Developers
Spring 3.1 and MVC Testing Support - 4DevelopersSpring 3.1 and MVC Testing Support - 4Developers
Spring 3.1 and MVC Testing Support - 4DevelopersSam Brannen
 
Effective out-of-container Integration Testing - 4Developers
Effective out-of-container Integration Testing - 4DevelopersEffective out-of-container Integration Testing - 4Developers
Effective out-of-container Integration Testing - 4DevelopersSam Brannen
 
Spring 3.1 to 3.2 in a Nutshell - SDC2012
Spring 3.1 to 3.2 in a Nutshell - SDC2012Spring 3.1 to 3.2 in a Nutshell - SDC2012
Spring 3.1 to 3.2 in a Nutshell - SDC2012Sam Brannen
 
Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012
Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012
Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012Sam Brannen
 

More from Sam Brannen (20)

Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023
Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023
Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023
 
Testing with JUnit 5 and Spring - Spring I/O 2022
Testing with JUnit 5 and Spring - Spring I/O 2022Testing with JUnit 5 and Spring - Spring I/O 2022
Testing with JUnit 5 and Spring - Spring I/O 2022
 
JUnit 5 - Evolution and Innovation - SpringOne Platform 2019
JUnit 5 - Evolution and Innovation - SpringOne Platform 2019JUnit 5 - Evolution and Innovation - SpringOne Platform 2019
JUnit 5 - Evolution and Innovation - SpringOne Platform 2019
 
JUnit 5: What's New and What's Coming - Spring I/O 2019
JUnit 5: What's New and What's Coming - Spring I/O 2019JUnit 5: What's New and What's Coming - Spring I/O 2019
JUnit 5: What's New and What's Coming - Spring I/O 2019
 
JUnit 5 - New Opportunities for Testing on the JVM
JUnit 5 - New Opportunities for Testing on the JVMJUnit 5 - New Opportunities for Testing on the JVM
JUnit 5 - New Opportunities for Testing on the JVM
 
Get the Most out of Testing with Spring 4.2
Get the Most out of Testing with Spring 4.2Get the Most out of Testing with Spring 4.2
Get the Most out of Testing with Spring 4.2
 
JUnit 5 - from Lambda to Alpha and beyond
JUnit 5 - from Lambda to Alpha and beyondJUnit 5 - from Lambda to Alpha and beyond
JUnit 5 - from Lambda to Alpha and beyond
 
Testing with Spring: An Introduction
Testing with Spring: An IntroductionTesting with Spring: An Introduction
Testing with Spring: An Introduction
 
Testing with Spring 4.x
Testing with Spring 4.xTesting with Spring 4.x
Testing with Spring 4.x
 
Spring Framework 4.1
Spring Framework 4.1Spring Framework 4.1
Spring Framework 4.1
 
Testing Spring MVC and REST Web Applications
Testing Spring MVC and REST Web ApplicationsTesting Spring MVC and REST Web Applications
Testing Spring MVC and REST Web Applications
 
Composable Software Architecture with Spring
Composable Software Architecture with SpringComposable Software Architecture with Spring
Composable Software Architecture with Spring
 
Testing Web Apps with Spring Framework 3.2
Testing Web Apps with Spring Framework 3.2Testing Web Apps with Spring Framework 3.2
Testing Web Apps with Spring Framework 3.2
 
Spring Framework 4.0 to 4.1
Spring Framework 4.0 to 4.1Spring Framework 4.0 to 4.1
Spring Framework 4.0 to 4.1
 
Spring Framework 4.0 - The Next Generation - Soft-Shake 2013
Spring Framework 4.0 - The Next Generation - Soft-Shake 2013Spring Framework 4.0 - The Next Generation - Soft-Shake 2013
Spring Framework 4.0 - The Next Generation - Soft-Shake 2013
 
Spring Framework 3.2 - What's New
Spring Framework 3.2 - What's NewSpring Framework 3.2 - What's New
Spring Framework 3.2 - What's New
 
Spring 3.1 and MVC Testing Support - 4Developers
Spring 3.1 and MVC Testing Support - 4DevelopersSpring 3.1 and MVC Testing Support - 4Developers
Spring 3.1 and MVC Testing Support - 4Developers
 
Effective out-of-container Integration Testing - 4Developers
Effective out-of-container Integration Testing - 4DevelopersEffective out-of-container Integration Testing - 4Developers
Effective out-of-container Integration Testing - 4Developers
 
Spring 3.1 to 3.2 in a Nutshell - SDC2012
Spring 3.1 to 3.2 in a Nutshell - SDC2012Spring 3.1 to 3.2 in a Nutshell - SDC2012
Spring 3.1 to 3.2 in a Nutshell - SDC2012
 
Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012
Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012
Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012
 

Recently uploaded

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 

Recently uploaded (20)

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 

Modular Web Applications with OSGi

  • 1. Modular Web Applications with OSGi eJUG Seminar Sam Brannen Linz, Austria Software Consultant 17 September 2009
  • 2. Speaker Profile   Software Consultant   Spring Framework Core Developer   Previous SpringSource dm Server™ developer: OSGi- enabled Web deployment models, Tomcat integration, Test Framework   Java developer with 10+ years' experience   Regular speaker at conferences on Spring, dm Server, Java, OSGi, and testing   Co-author of Spring in a Nutshell; chief technical reviewer for Spring Recipes Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 2
  • 3. Overview The Challenge? Monolithic WAR deployments hinder both development and runtime modularity and promote library bloat. The Solution! Harness the flexibility of the OSGi Web Container standard, Spring, Spring-DM, and the SpringSource dm Server™. Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 3
  • 4. Agenda   Status Quo   OSGi   Spring DM   OSGi Web Container   SpringSource dm Server™   Demos   Q&A Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 4
  • 5. Status Quo Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 5
  • 6. Standard Java EE WAR   Java Servlet 2.5   WAR format   Static content   Dynamic content   WEB-INF   WEB-INF/classes   WEB-INF/lib   All-in-one deployment model   EAR   Container shared libraries Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 6
  • 7. Introduction to Demos  Spring MVC 2.5 based "Hello World" web application  Domain model: HelloMessage  Service layer: HelloService, HelloServiceImpl  Presentation layer:   Controllers: HelloController   Views: JSP + JSTL Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 7
  • 8. DEMO Standard WAR Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 8
  • 9. OSGi Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 9
  • 10. It's a module system   Partition a system into a number of modules – “bundles”   Dynamic: bundles can be installed, started, stopped, uninstalled and updated ... at runtime!   Strict visibility rules   Resolution process satisfies dependencies of a module   Versioning   Packages & Services   Deploy multiple versions of a module Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 10
  • 11. It's even service-oriented   Bundles can publish services… dynamically!   Service Registry allows other bundles to consume services   Services come and go at runtime   … transparently when using Spring-DM Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 11
  • 12. OSGi Bundle   The fundamental unit of deployment and modularity in OSGi   Just a JAR file   with additional entries in META-INF/MANIFEST.MF   Common manifest headers:   Bundle-SymbolicName   Bundle-Version   Bundle-Name   Bundle-ManifestVersion   Export-Package   Import-Package Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 12
  • 13. Export & Import Packages Declare package-level visibility and dependencies of your bundle. Export-Package: com.xyz.bar Export-Package: com.xyz.bar;version="1.0.5" Import-Package: com.xyz.foo >= 1.0.3; e.g., Import-Package: 1.0.3, 1.0.3.GA, com.xyz.foo;version="1.0.3" 1.0.4, 2.0, etc. Import-Package: com.xyz.foo;version="[1.0.3,1.0.3]" Import-Package: com.xyz.foo;version="[1.0.3,1.1.0)", com.xyz.bar;version="[1.0.3,2.0.0)" Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 13
  • 14. Publish a Service ServiceRegistration reg = bundleContext.registerService( Bar.class.getName(), myBarService); ... reg.unregister(); Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 14
  • 15. Consume a Service ServiceReference ref = bundleContext.getServiceReference( Bar.class.getName()); Bar bar = (Bar) bundleContext.getService(ref); ... bundleContext.ungetService(ref); // bar should no longer be used here Complex… Potential resource leaks! Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 15
  • 16. Implementations & Tools   OSGi implementations:   Equinox   Knopflerfish   Felix   IDEs   Eclipse PDE   SpringSource Tool Suite   Build support:   BND   Bundlor Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 16
  • 17. Spring DM Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 17
  • 18. Spring-DM: App. Context   Configuration files in /META-INF/spring   Automatically merged   ..and an ApplicationContext is created   one per Bundle   Spring-DM manages the ApplicationContext lifecycle   OSGi manages the Bundle lifecycle Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 18
  • 19. Spring-DM: Service Registry Contrast with programmatic <beans ...> API <osgi:service ref="customerDAO" interface="dao.CustomerDAO" /> <osgi:reference id="dataSource" interface="javax.sql.DataSource" /> </beans> Also supports filters, listeners, collections (lists and sets), etc. Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 19
  • 20. Spring-DM: Service Registry   Dynamic services handled automatically   Instances and collections are proxied   Method calls are buffered   Configurable timeouts   Purely declarative   Application code is typically decoupled from OSGi   Spring’s POJO programming model   Testable, out-of-container Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 20
  • 21. Out-of-scope for Spring-DM   Easy import of bundles and libraries   Using JPA or Hibernate in OSGi   Seamless Web support   Notion of an application   Enter:   OSGi Web Container   SpringSource dm Server Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 21
  • 22. OSGi Web Container Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 22
  • 23. Web Bundle   RFC 66: OSGi Web Container specification   Reference implementation by SpringSource   Web Bundle = web application in OSGi   Multiple supported formats   Standard WAR   Shared Libraries WAR   Shared Services WAR   Context path defined via query parameter or in manifest:   Web-ContextPath: /my-web-app Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 23
  • 24. OSGi Web Migration Path   Status quo: everything in a monolithic WAR   Goals:   Libraries: eradicate library bloat   Services: OSGi Service Registry   Results: decrease overall footprint Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 24
  • 25. Standard Java EE WAR  Supported as is  The WAR file is transformed into an OSGi bundle and installed into the Servlet Container  All standard WAR contracts are honored  Easy on-ramp for web applications in OSGi Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 25
  • 26. Shared Libraries WAR  Eradicate the library bloat of monolithic Java EE WARs  Declare dependencies via OSGi manifest headers •  Import-Package & Require-Bundle •  Import-Library & Import-Bundle Import-Package  Reduce application deployment footprint  SpringSource Enterprise Bundle Repository: central source for OSGi bundles Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 26
  • 27. DEMO Shared Libraries WAR Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 27
  • 28. Shared Services WAR  Share services between bundles and web applications  Spring-DM simplifies usage of the OSGi Service Registry   Publish services via <osgi:service … />   Consume them via <osgi:reference … /> • ServerOsgiBundleXmlWebApplicationContext: use as contextClass property for ContextLoaderListener and DispatcherServlet  Program to interfaces and decouple web artifacts from the domain model, services, infrastructure, etc. Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 28
  • 29. DEMO Shared Services WAR Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 29
  • 30. SpringSource dm Server™ Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 30
  • 31. dm Server Architecture  Built on Equinox  Modular architecture  Subsystems  Bundles  Small footprint  Modular profiles  Bundle repository  Library provisioning  Serviceability  FFDC  Logging  Tracing Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 31
  • 32. Import: Library & Bundle   Plain OSGi + …   Import-Library and Import-Bundle   Library imports  bundle imports   Bundle imports  package imports   OSGi runtime semantics remain the same Import-Library: org.springframework.spring; version="[2.5.6,3.0)" Import-Bundle: com.springsource.org.hibernate; version="[3.2.6.ga,3.2.6.ga]" Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 32
  • 33. PAR   Packaging format for all modules in an app.   JAR with Application-* manifest headers   Single unit: deploy, refresh, undeploy   Application boundaries   Scoping of types / services   DataSource does not leak out of the application   Hibernate can change domain objects Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 33
  • 34. DEMO PAR Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 34
  • 35. Plan   Conceptually similar to the PAR format:   Defines all modules within an application   Single configuration for deployment, etc.   Application boundaries   Scoping of types / services   Differences:   Plan = XML file with „.plan“ extension   Application modules are referenced within XML   Modules are installed stand-alone in the repository   Control deployment order of modules   Share modules between plans   Configure scoping and atomicity Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 35
  • 36. Slices   Slice = mechanism for extending a host web bundle   Goes beyond mere code   Slices can provide code and content to a host   Slices can use content and services from a host   Analogous to OSGi fragments, slices attach to a host web bundle:   Slice-Host: hello.war.host;version="[1.0,2.0)”   Slice-ContextPath: /de   Host interacts with slices via slices tag library   Slices provide configuration properties to host Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 36
  • 37. DEMO Slices Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 37
  • 38. Closing Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 38
  • 39. Further Resources   OSGi: http://osgi.org   Spring Framework: http://springframework.org   Spring-DM: http://springframework.org/osgi   SpringSource dm Server: http://springframework.org/dmserver   SpringSource Team Blog: http://blog.springsource.com   German Getting Started: http://www.dpunkt.de/buecher/3231.html Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 39
  • 40. Q&A Sam Brannen sam [at] sambrannen [dot] com http://SamBrannen.com http://twitter.com/sam_brannen Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited. 40