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 2 Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
modularity and promote library bloat. The Solution! Harness the flexibility of the OSGi Web Container standard, Spring, Spring-DM, and the SpringSource dm Server™. Overview 3 Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
OSGi Web Container SpringSource dm Server™ Demos Q&A 4 Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
format Static content Dynamic content WEB-INF WEB-INF/classes WEB-INF/lib All-in-one deployment model EAR Container shared libraries 6 Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
HelloMessage Service layer: HelloService, HelloServiceImpl Presentation layer: Controllers: HelloController Views: JSP + JSTL Introduction to Demos 7 Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
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 10 Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
Service Registry allows other bundles to consume services Services come and go at runtime … transparently when using Spring-DM 11 Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
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 12 Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
your bundle. Export-Package: com.xyz.bar Export-Package: com.xyz.bar;version="1.0.5" Import-Package: com.xyz.foo Import-Package: com.xyz.foo;version="1.0.3" 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)" >= 1.0.3; e.g., 1.0.3, 1.0.3.GA, 1.0.4, 2.0, etc. 13 Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
= (Bar) bundleContext.getService(ref); ... bundleContext.ungetService(ref); // bar should no longer be used here Complex… Potential resource leaks! 15 Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
Felix IDEs Eclipse PDE SpringSource Tool Suite Build support: BND Bundlor 16 Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
merged ..and an ApplicationContext is created one per Bundle Spring-DM manages the ApplicationContext lifecycle OSGi manages the Bundle lifecycle 18 Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
id="dataSource" interface="javax.sql.DataSource" /> </beans> Also supports filters, listeners, collections (lists and sets), etc. Contrast with programmatic API 19 Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
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 Spring-DM: Service Registry 20 Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
Using JPA or Hibernate in OSGi Seamless Web support Notion of an application Enter: OSGi Web Container SpringSource dm Server 21 Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
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 23 Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
WAR Goals: Libraries: eradicate library bloat Services: OSGi Service Registry Results: decrease overall footprint 24 Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
OSGi bundle and installed into the Servlet Container All standard WAR contracts are honored Easy on-ramp for web applications in OSGi Standard Java EE WAR 25 Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
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 Shared Libraries WAR 26 Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
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. Shared Services WAR 28 Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
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]" 32 Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
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 33 Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
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 35 Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
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 36 Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.
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 39 Copyright 2008-2009 Sam Brannen and SpringSource. Copying, publishing or distributing without express written permission is prohibited.