• Save
What's new in the OSGi 4.2 Enterprise Release
Upcoming SlideShare
Loading in...5
×
 

What's new in the OSGi 4.2 Enterprise Release

on

  • 6,057 views

 

Statistics

Views

Total Views
6,057
Views on SlideShare
5,832
Embed Views
225

Actions

Likes
2
Downloads
0
Comments
0

11 Embeds 225

http://osgithoughts.blogspot.com 161
http://www.slideshare.net 38
http://osgithoughts.blogspot.de 10
http://static.slidesharecdn.com 5
http://osgithoughts.blogspot.co.uk 3
http://osgithoughts.blogspot.in 2
http://osgithoughts.blogspot.com.br 2
http://www.blogger.com 1
http://planet.jboss.org 1
http://khaliline.blogspot.com 1
http://osgithoughts.blogspot.com.es 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

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

What's new in the OSGi 4.2 Enterprise Release What's new in the OSGi 4.2 Enterprise Release Presentation Transcript

  • What's new in the OSGi 4.2 Enterprise Specification David Bosschaert, 2010
  • History ● EEG formed early 2007 ● Work areas identified and work started ● Work areas: ● Distributed Services ● Developer Support / Spring DM ● JEE – related specifications ● Remote Services & Blueprint specs part of 4.2 core/compendium release summer 2009 ● Culmination of the work done in 4.2 Enterprise Release, Q1 2010
  • 4.2 Enterprise Specification Component Models Naming, Management ● Blueprint ● JNDI ● Declarative Services ● JMX Distributed Services Database Access ● Remote Services ● JDBC ● Remote Services Admin ● JPA ● SCA Configuration Type ● JTA Web Applications Supporting Technologies ● Http Service Spec ● Events, Config Admin, User ● Web Container Spec Admin, Trackers, ...
  • Blueprint Blueprint makes developing for OSGi easier. ● Create Blueprint Components ● Based on ideas from Spring Dynamic Modules ● Blueprint Component ≈ Spring DM Bean ● Inversion of Control ● Dependency on other components or OSGi Services ● Register components as Services
  • Blueprint example Bundle component.xml MyComponent.java <blueprint xmlns="..."> package org.example.test; <reference id="logSvc" interface="org.osgi.service.log.LogService"/> import org.osgi.service.log.LogService; <bean id="myComponent" public class MyComponent implements MyInterface class="org.example.test.MyComponent" { init-method="started"> private LogService logService; <property name="dbURL" private String dbURL; value="jdbc:foo://bar"/> <property name="logService" public String getDbURL() { ref="logSvc"/> return dbURL; </bean> } <service ref="myComponent" public void setDbURL(String url) { interface="org.example.test.MyInterface"/> dbURL = url; </blueprint> } public void setLogService(LogService log) { logService = log; Blueprint manifest header: } Bundle-Blueprint: OSGI-INF/blueprint/*.xml public void started() { logService.log(LogService.LOG_INFO, "MyComponent started. DB URL: " + dbURL); } }
  • Distributed OSGi Distributed OSGi (RFC 119) split up into three specs: ● Remote Services spec released in 4.2 Compendium Summer 2009 API to expose and consume remote OSGi Services (service properties) ● Remote Services Admin spec new in the Enterprise Release Standardizes the APIs of internal Remote Services components, allowing mix & match of sub-components (like Discovery) ● SCA Configuration spec If you want to use SCA metadata for configuration
  • Remote Services (in brief) Export a service remotely: Import a remote service: ● Add an extra service property ● With Discovery public class Activator implements BundleActivator { private ServiceRegistration reg; automatic public void start(BundleContext bc) { Dictionary props = new Hashtable(); ● With static props.put("service.exported.interfaces", "*"); <endpoint-description> files // optionally, configure some details // for example props.put("service.exported.configs", ● All client-side proxies "org.apache.cxf.ws"); props.put("org.apache.cxf.ws.address", services have "http://localhost:9090/greeter"); service.imported reg = bc.registerService( GreeterService.class.getName(), new GreeterServiceImpl(), props); property set. // Greeter Service now accessible // over network } …
  • Remote Service Admin Standardizes the API of components under the hood ● Distribution Provider, Topology Manager, Discovery VM1 creates remote invocation Distribution Topology remote Discovery Distribution Topology service Discovery network Provider Provider instructs Manager Manager metadata Component Component X listens D D T T DP DP creates X' X' a service by some listens bundle Service Service Client Client Bundle Bundle VM2
  • Web Applications Deploy your webapps straight into an OSGi Framework Supports .WAR and .WAB files ● Deploy them just like any other bundle ● .WAB primary deployment format – Is a proper bundle, with BSN, package Imports & Exports, etc... – Required Manifest header: Web-ContextPath: /myServlet ● .WARs are turned into a .WAB via a URL handler, e.g. webbundle:file:///mywebapp.war?Web-ContextPath=/myServlet
  • Web Applications (2) Support for interaction with OSGi Framework ● Access to Bundle Context from within a Servlet BundleContext bc = (BundleContext) servletContext.getAttribute("osgi-bundlecontext"); ● Servlet Context registered in OSGi Service Registry – For every successfully started Web Application
  • JPA Proper database persistence for OSGi ● Don't use static Persistence class to create an EntityManager ● Look up EntityManagerFactory or EntityManagerFactoryBuilder in the Service Registry ● A bundle defining Persistence Units declares this using the OSGi/JPA header: Meta-Persistence: OSGI-INF/people-persistence.xml ● Look up Filter filter: (osgi.unit.name=People) interface: javax.persistence.EntityManagerFactory
  • JPA (2) Small example: EntityManagerFactory emf = … // from OSGi Service Registry // From here everything is familiar EntityManager em = emf.createEntityManager(); em.getTransaction().begin(); Person person = new Person(); person.setName("David"); em.persist(person); em.getTransaction().commit(); …
  • JNDI Access to OSGi from JNDI clients ● Look up OSGi Services and BundleContext through JNDI osgi: scheme osgi:service/javax.sql.DataSource osgi:service/my_service (if service sets the osgi.jndi.service.name property) osgi:servicelist/javax.sql.DataSource osgi:framework/bundleContext Access to JNDI for OSGi Bundles ● Look up JNDI in OSGi Service Registry – JNDIContextManager Service provides access JNDI Initial Context – Service registry preferred over calling new InitialContext()
  • JTA Provides OSGi services in the registry: ● javax.transaction.UserTransaction ● javax.transaction.TransactionManager ● javax.transaction.TransactionSynchronizationRegistry Supports XA Resources.
  • JDBC Database Drivers registered in the OSGi Service Registry as DataSourceFactory objects ● With APIs to create – javax.sql.DataSource – javax.sql.ConnectionPoolDataSource – javax.sql.XADataSource – java.sql.Driver
  • JMX ● JMX access to the OSGi Framework ● Framework Control (Bundle lifecycle) ● Bundle information ● Service information ● Services supported ● Package Admin ● Configuration Admin ● Permission Admin ● Initial Provisioning ● User Admin
  • Examples? ● Apache Aries Trader ● Leverages – Blueprint – Web – JPA / JDBC – JTA – JNDI http://incubator.apache.org/aries/ariestrader.html ● Besides that lots of more isolated examples can be found in the various implementing projects.
  • Future EEG work Besides refinements to current specs... ● Subsystems & Applications ● OBR ● Async communications ● JMS ● Message Driven Components ● Asynchronous Services ● ...
  • Questions?