apache aries · apache aries where web apps meet osgi by alasdair nottingham not@apache.org...
Post on 08-Jul-2020
2 Views
Preview:
TRANSCRIPT
Apache Aries Where Web Apps meet OSGi
by Alasdair Nottinghamnot@apache.orgSoftware Engineer, IBM
1Monday, 30 November 2009
What is OSGi?• The dynamic module system for Java
• Packages are the unit of modularity
• Collected together in bundles
• Connect using services
Services
Life Cycle
Module
Execution Environment
Security
Hardware / OS
Bundles
2Monday, 30 November 2009
Bundles
Bundle A Bundle BImport Export
3Monday, 30 November 2009
Class LoadingSystem loader
Extension loader
App 1 loader App 2 loader
WebApp1 loader Bundle A Bundle B
Bundle C1 Bundle C2
System loader
Extension loader
Import-Package:org.blah.util;
version=[1.0.2,2.0.0]
Export-Package:org.blah.util;version=1.5.0
Export-Package:org,blah.util;version=2.0.0
Traditional
OSGi
4Monday, 30 November 2009
Dynamics• Bundle life cycle
• Services
Bundle A
Bundle C
Bundle BRegisterUse
Listen
5Monday, 30 November 2009
Enterprise OSGi?• Java SE and EE technologies are not OSGi
aware
• OSGi Enterprise Expert Group (EEG) defining standards for integrating
JEE Glue OSGi
ApacheAries
JNDI
JPA
Servlet
6Monday, 30 November 2009
Apache Aries
• Recent Apache incubator project
• OSGi as an application model
• Blueprint container (standardised Spring DM)
• JNDI integration
• ...more to come
7Monday, 30 November 2009
Blueprint
8Monday, 30 November 2009
Hello World!
Hello World ServiceHello World Client
9Monday, 30 November 2009
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> <bean id="helloservice" class="org.apache.aries.blueprint.helloworldserver.HelloWorldServiceImpl" init-method="startUp"> </bean> <service ref="helloservice" interface="org.apache.aries.blueprint.helloworldapi.HelloWorldService" /></blueprint>
HW service bundle
public class HelloWorldServiceImpl implements HelloWorldService { public void hello() { System.out.println("======>>> A message from the server: Hello World!"); } public void startUp() { System.out.println("======>>> Starting HelloWorld Server"); }}
Hello World Service
10Monday, 30 November 2009
HW client bundle
public class HelloWorldClient {
private HelloWorldService helloWorldService = null;
public void setHelloWorldService(HelloWorldService hws) { helloWorldService = hws; }
public void startUp() { System.out.println("========>>>>Client HelloWorld: Execute hello() from Hello World service"); helloWorldService.hello(); System.out.println("========>>>>Client HelloWorld: ... done!"); }}
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> <reference id="helloservice" interface="org.apache.aries.blueprint.helloworldapi.HelloWorldService" />
<bean id="helloclient" class="org.apache.aries.blueprint.helloworldclient.HelloWorldClient" init-method="startUp"> <property name="helloWorldService" ref="helloservice" /> </bean></blueprint>
Hello World Client
11Monday, 30 November 2009
JNDI
• How to use JNDI in OSGi
• How to access the service registry from JNDI:
• osgi:service/<interface name>/<filter>
• osgi:serviceList/<interface name>/<filter>
12Monday, 30 November 2009
Web + JNDI + Blueprint
Blueprint BundleWeb Bundle
13Monday, 30 November 2009
Servlet
public class HelloWorldServlet extends HttpServlet {
@Resource(mappedName=”osgi:service/org.apache.aries.blueprint.helloworldapi.HelloWorldServlet”) private HelloWorldService helloWorldService = null;
public void doGet(HttpServletRequest request, HttpServletResponse response) { System.out.println("========>>>>Client HelloWorld: Execute hello() from Hello World service"); helloWorldService.hello(); System.out.println("========>>>>Client HelloWorld: ... done!"); }}
14Monday, 30 November 2009
Thanks for your attention!
• OSGi Alliance - http://www.osgi.org/
• OSGi Implementations
• http://www.eclipse.org/equinox/
• http://felix.apache.org/
• Apache Aries - http://incubator.apache.org/aries/
• Apache Aries Blog - http://blogs.apache.org/aries/
• Further reading
• http://www.ibm.com/developerworks/opensource/library/os-osgiblueprint/index.html
• OSGi in Action - http://neilbartlett.name/blog/osgibook/
15Monday, 30 November 2009
top related