SlideShare a Scribd company logo
Balduran chang
2008/9/30
Balduran.cs96g@g2.nctu.edu.tw
EC719
(03)5712121#54819
 Bundle management portion
 GUI
 Bundle list
 un/install bundle
 Start/stop bundle
 Update/configre bundle
 EV bundle portion
 one trigger function to broadcast “Emergency event!”
 once receive EV message, response it and show
incoming message.
 Port number and message should be able to modify
 PPT slice
 Architectures
 System design
 Used module
 Source code
 Java code
 Jar file
 Knopflerfish
 http://www.knopflerfish.org/download.html
 Apache Felix
 http://felix.apache.org/site/downloads.cgi
 Equinox
 http://download.eclipse.org/equinox/
 Prosyst mBedded Server Equinox Edition
 http://dz.prosyst.com/oss/
 Install
 Use startinstall.bat
 Start framework
 C:mbs_equinoxbinv
msjdkserver.bat
 install
 uninstall
 start
 stop
 refresh
 update
 status
 ss
 services
 bundles
 bundle
 headers
 log
 gc
 sl
 exit
 init
 shutdown
 install file:../../../demo/bundles/httpdemo.jar
 start <bundle id>
 Check the bundle status is active
 Visit
http://<mbs_host>/images/imagination.jpg
 Stop <bundle id>
 Check the bundle status is resolved
 Uninstall <bundle id>
 JDK 1.6.07
 mBS Equinox edition 3.4
 Eclipse
 Configure build path…
 Add external JARs…
 bundles/org.eclipse.osgi.jar
 bundles/org.eclipse.osgi.services.jar
 bundles/org.eclipse.osgi.util.jar
1. Bundle implementation
2. Bundle activator
3. Compile and generate class file
4. Manifest.mf file
5. Generate bundle JAR file
6. Install and start bundle
HelloWorldThread.java
public class HelloWorldThread extends Thread {
private boolean running = true;
public HelloWorldThread() {}
public void run() {
while (running) {
System.out.println("Hello World!");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
System.out.println("ERROR: " + e);
}
}
}
public void stopThread() {
this.running = false;
}
}
Activator.java
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
public class Activator implements BundleActivator {
public static BundleContext bc = null;
private HelloWorldThread thread = null;
public void start(BundleContext bc) throws Exception {
System.out.println("Bundle starting...");
Activator.bc = bc;
this.thread = new HelloWorldThread();
this.thread.start();
}
public void stop(BundleContext bc) throws Exception {
System.out.println("Bundle stopping...");
this.thread.stopThread();
this.thread.join();
Activator.bc = null;
}
}
Manifest.mf
Manifest-Version: 1.0
Bundle-Name: first bundle
Bundle-SymbolicName: firstbundle
Bundle-Version: 1.0.0
Bundle-Description: first Demo Bundle
Bundle-Vendor: vendorABC
Bundle-Activator: demo.Activator
Bundle-Category: demo
Import-Package: org.osgi.framework
 Compile CMD
 javac -classpath .;../bundles/org.eclipse.osgi.jar; *.java
 Jar CMD
 jar cmf ./manifest firstbundle.jar *.class
Build.xml
<?xml version="1.0"?>
<project name="simplebundle" default="all">
<target name="all" depends="init,compile,jar" />
<target name="init">
<mkdir dir="./classes" />
<mkdir dir="./bin" />
</target>
<target name="compile">
<javac destdir="./classes" debug="on" srcdir="./src">
</javac>
</target>
<target name="jar">
<jar basedir="./classes" jarfile="./bin/simplebundle.jar" compress="true"
includes="**/*" manifest="./meta-inf/MANIFEST.MF" />
</target>
<target name="clean">
<delete dir="./classes" />
<delete dir="./bin" />
</target>
</project>
GetService.java
import org.osgi.framework.ServiceReference;
import org.osgi.framework.BundleException;
public class GetService implements BundleActivator {
ServiceReference timeRef = null;
TimeService timeService = null;
public void start(BundleContext bc) throws BundleException {
timeRef = bc.getServiceReference(TimeService.class.getName());
if (timeRef != null) {
timeService = (TimeService) bc.getService(timeRef);
}
if (timeService == null) {
return;
}
}
public void stop(BundleContext bc) throws BundleException {
if (timeRef != null) {
bc.ungetService(timeRef);
timeRef = null;
timeService = null;
}
}
}
public class PMPDemo implements BundleActivator {
static String SYSTEM = "com.prosyst.util.system.SystemService";
public void start(BundleContext bx) throws BundleException {
try {
ServiceReference sr =
bx.getServiceReference(PMPService.class.getName());
if(sr == null) throw new BundleException("Can't get
PMPService");
PMPService pmp = (PMPService)bx.getService(sr);
if(pmp == null) throw new BundleException("Can't get
PMPService");
Hashtable props = new Hashtable (20);
props.put("username", "admin");
props.put("password", "admin");
PMPConnection con = pmp.connect("socket://127.0.0.1:1449",
props);
RemoteObject rObject = con.getReference(SYSTEM, "");
String [] str = {Byte.TYPE.getName()};
RemoteMethod rMethod = rObject.getMethod("getProperties", str);
rMethod.changeReturnType(ExternalizableDictionary.class);
Dictionary obj = (ExternalizableDictionary)rMethod.invoke(new
Object[] {new Byte((byte) 3)}, true);
Enumeration enum = obj.keys();
while(enum.hasMoreElements()) {
Object tmp = enum.nextElement();
System.out.println(tmp + " " + obj.get(tmp));
}
}
catch (Exception e) {
System.out.println(e);
}
}
public void stop(BundleContext bx) {
}
}
 Bundle Management portion
 Use PMP (prosyst message protocol) to get a
connection to remote framework.
 1. request PMPService
 2. obtain PMPConnection
 3. call remote service method
 4.To make a service PMP-accessible, you should
additionally implement
the com.prosyst.util.io.Remoteinterface in the
service class.
public class example implements Remote {
public Class[] remoteInterfaces() {
}
}
Ref:
https://dz.prosyst.com/pdoc/mbs_equinox_3.4/um/framework/bundles/p
rosyst/rpc/pmp/pmpbundle.html
 See also:
 com.prosyst.util.parser
▪ Parser Service
▪ https://dz.prosyst.com/pdoc/mbs_prof_6.2/um/framew
ork/bundles/system/putil/putil_parser.html
 mConsole APIs
▪ https://dz.prosyst.com/pdoc/mbs_prof_6.2/um/framew
ork/admins/mConsole/mConsole_programmer.html
 EV bundle portion
 Java.net.DatagramSocket
▪ SO_BROADCAST
▪ setBroadcast(boolean on)
▪ getBroadcast()
 Java.net.DatagramPacket
▪ Use DatagramPacket(int port)
 https://dz.prosyst.com/pdoc/mbs_equinox_3.
4/um/index.html
 http://www.knopflerfish.org/tutorials.html

More Related Content

PDF
Algotitmo Moinho
PDF
[Spring Camp 2013] Java Configuration 없인 못살아!
PPTX
Apache Maven basics
PDF
Java Server Faces
PDF
#30.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
DOCX
Pom
PDF
Alfredo-PUMEX
PDF
ZF2 for the ZF1 Developer
Algotitmo Moinho
[Spring Camp 2013] Java Configuration 없인 못살아!
Apache Maven basics
Java Server Faces
#30.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
Pom
Alfredo-PUMEX
ZF2 for the ZF1 Developer

What's hot (19)

PDF
Jlook web ui framework
PDF
Using Perl Stored Procedures for MariaDB
PDF
mapserver_install_linux
PDF
Czym jest webpack i dlaczego chcesz go używać?
PDF
External Language Stored Procedures for MySQL
PDF
Lviv 2013 d7 vs d8
PDF
Architecting Large Enterprise Java Projects
PPTX
Spring Framework Petclinic sample application
PDF
Releasing Projects Using Maven
PPTX
Javascript Bundling and modularization
PDF
How to create a skeleton of a Java console application
ODP
Running ms sql stored procedures in mule
PPT
Plmce2015 java 101 - david bennett
PPTX
Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dep...
PDF
Instalar PENTAHO 5 en CentOS 6
PDF
Apache2 BootCamp : Getting Started With Apache
PDF
Perl Stored Procedures for MySQL (2009)
PDF
[Strukelj] Why will Java 7.0 be so cool
PPTX
Jmx capture
Jlook web ui framework
Using Perl Stored Procedures for MariaDB
mapserver_install_linux
Czym jest webpack i dlaczego chcesz go używać?
External Language Stored Procedures for MySQL
Lviv 2013 d7 vs d8
Architecting Large Enterprise Java Projects
Spring Framework Petclinic sample application
Releasing Projects Using Maven
Javascript Bundling and modularization
How to create a skeleton of a Java console application
Running ms sql stored procedures in mule
Plmce2015 java 101 - david bennett
Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dep...
Instalar PENTAHO 5 en CentOS 6
Apache2 BootCamp : Getting Started With Apache
Perl Stored Procedures for MySQL (2009)
[Strukelj] Why will Java 7.0 be so cool
Jmx capture
Ad

Similar to OSGi framework overview (20)

PPTX
Intro to OSGi and Eclipse Virgo
PDF
Eclipse_Building_Blocks
PDF
Bndtools and Maven: A Brave New World - N Bartlett & T Ward
PDF
Eclipse Concierge - an OSGi R5 framework for IoT applications
PDF
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
ODP
Java Tech & Tools | OSGi Best Practices | Emily Jiang
PDF
OSGi Community Event 2010 - OSGi Technical Update
PDF
JBoss AS 7 - YaJUG - nov. 2012
PDF
OSGi tech session
KEY
OSGi in 5 minutes
PDF
Tuscany : Applying OSGi After The Fact
PDF
Deploying Heterogeneous Artifacts to the Cloud with OSGi - Neil Bartlett
PDF
Managing Installations and Provisioning of OSGi Applications - Carsten Ziegeler
KEY
Is OSGi modularity always worth it?
PDF
soft-shake.ch - JBoss AS 7, la révolution
PDF
Easy-peasy OSGi Development with Bndtools - Neil Bartlett
ODP
OSGi Sticker Shock Eclipse Con 2010
PDF
Eclipse IDE, 2019.09, Java Development
PDF
Automate workflows with leading open-source BPM
PDF
OSGi bootcamp - part 1
Intro to OSGi and Eclipse Virgo
Eclipse_Building_Blocks
Bndtools and Maven: A Brave New World - N Bartlett & T Ward
Eclipse Concierge - an OSGi R5 framework for IoT applications
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
Java Tech & Tools | OSGi Best Practices | Emily Jiang
OSGi Community Event 2010 - OSGi Technical Update
JBoss AS 7 - YaJUG - nov. 2012
OSGi tech session
OSGi in 5 minutes
Tuscany : Applying OSGi After The Fact
Deploying Heterogeneous Artifacts to the Cloud with OSGi - Neil Bartlett
Managing Installations and Provisioning of OSGi Applications - Carsten Ziegeler
Is OSGi modularity always worth it?
soft-shake.ch - JBoss AS 7, la révolution
Easy-peasy OSGi Development with Bndtools - Neil Bartlett
OSGi Sticker Shock Eclipse Con 2010
Eclipse IDE, 2019.09, Java Development
Automate workflows with leading open-source BPM
OSGi bootcamp - part 1
Ad

Recently uploaded (20)

PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
top salesforce developer skills in 2025.pdf
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Digital Strategies for Manufacturing Companies
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
Introduction to Artificial Intelligence
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
medical staffing services at VALiNTRY
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
System and Network Administration Chapter 2
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
top salesforce developer skills in 2025.pdf
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Digital Strategies for Manufacturing Companies
Reimagine Home Health with the Power of Agentic AI​
Design an Analysis of Algorithms II-SECS-1021-03
Introduction to Artificial Intelligence
Operating system designcfffgfgggggggvggggggggg
medical staffing services at VALiNTRY
Upgrade and Innovation Strategies for SAP ERP Customers
How to Migrate SBCGlobal Email to Yahoo Easily
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
System and Network Administration Chapter 2
2025 Textile ERP Trends: SAP, Odoo & Oracle
How to Choose the Right IT Partner for Your Business in Malaysia
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...

OSGi framework overview

  • 2.  Bundle management portion  GUI  Bundle list  un/install bundle  Start/stop bundle  Update/configre bundle  EV bundle portion  one trigger function to broadcast “Emergency event!”  once receive EV message, response it and show incoming message.  Port number and message should be able to modify
  • 3.  PPT slice  Architectures  System design  Used module  Source code  Java code  Jar file
  • 4.  Knopflerfish  http://www.knopflerfish.org/download.html  Apache Felix  http://felix.apache.org/site/downloads.cgi  Equinox  http://download.eclipse.org/equinox/  Prosyst mBedded Server Equinox Edition  http://dz.prosyst.com/oss/
  • 5.  Install  Use startinstall.bat  Start framework  C:mbs_equinoxbinv msjdkserver.bat
  • 6.  install  uninstall  start  stop  refresh  update  status  ss  services  bundles  bundle  headers  log  gc  sl  exit  init  shutdown
  • 7.  install file:../../../demo/bundles/httpdemo.jar  start <bundle id>  Check the bundle status is active  Visit http://<mbs_host>/images/imagination.jpg
  • 8.  Stop <bundle id>  Check the bundle status is resolved  Uninstall <bundle id>
  • 9.  JDK 1.6.07  mBS Equinox edition 3.4  Eclipse  Configure build path…  Add external JARs…  bundles/org.eclipse.osgi.jar  bundles/org.eclipse.osgi.services.jar  bundles/org.eclipse.osgi.util.jar
  • 10. 1. Bundle implementation 2. Bundle activator 3. Compile and generate class file 4. Manifest.mf file 5. Generate bundle JAR file 6. Install and start bundle
  • 11. HelloWorldThread.java public class HelloWorldThread extends Thread { private boolean running = true; public HelloWorldThread() {} public void run() { while (running) { System.out.println("Hello World!"); try { Thread.sleep(5000); } catch (InterruptedException e) { System.out.println("ERROR: " + e); } } } public void stopThread() { this.running = false; } }
  • 12. Activator.java import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; public class Activator implements BundleActivator { public static BundleContext bc = null; private HelloWorldThread thread = null; public void start(BundleContext bc) throws Exception { System.out.println("Bundle starting..."); Activator.bc = bc; this.thread = new HelloWorldThread(); this.thread.start(); } public void stop(BundleContext bc) throws Exception { System.out.println("Bundle stopping..."); this.thread.stopThread(); this.thread.join(); Activator.bc = null; } }
  • 13. Manifest.mf Manifest-Version: 1.0 Bundle-Name: first bundle Bundle-SymbolicName: firstbundle Bundle-Version: 1.0.0 Bundle-Description: first Demo Bundle Bundle-Vendor: vendorABC Bundle-Activator: demo.Activator Bundle-Category: demo Import-Package: org.osgi.framework  Compile CMD  javac -classpath .;../bundles/org.eclipse.osgi.jar; *.java  Jar CMD  jar cmf ./manifest firstbundle.jar *.class
  • 14. Build.xml <?xml version="1.0"?> <project name="simplebundle" default="all"> <target name="all" depends="init,compile,jar" /> <target name="init"> <mkdir dir="./classes" /> <mkdir dir="./bin" /> </target> <target name="compile"> <javac destdir="./classes" debug="on" srcdir="./src"> </javac> </target> <target name="jar"> <jar basedir="./classes" jarfile="./bin/simplebundle.jar" compress="true" includes="**/*" manifest="./meta-inf/MANIFEST.MF" /> </target> <target name="clean"> <delete dir="./classes" /> <delete dir="./bin" /> </target> </project>
  • 15. GetService.java import org.osgi.framework.ServiceReference; import org.osgi.framework.BundleException; public class GetService implements BundleActivator { ServiceReference timeRef = null; TimeService timeService = null; public void start(BundleContext bc) throws BundleException { timeRef = bc.getServiceReference(TimeService.class.getName()); if (timeRef != null) { timeService = (TimeService) bc.getService(timeRef); } if (timeService == null) { return; } } public void stop(BundleContext bc) throws BundleException { if (timeRef != null) { bc.ungetService(timeRef); timeRef = null; timeService = null; } } }
  • 16. public class PMPDemo implements BundleActivator { static String SYSTEM = "com.prosyst.util.system.SystemService"; public void start(BundleContext bx) throws BundleException { try { ServiceReference sr = bx.getServiceReference(PMPService.class.getName()); if(sr == null) throw new BundleException("Can't get PMPService"); PMPService pmp = (PMPService)bx.getService(sr); if(pmp == null) throw new BundleException("Can't get PMPService"); Hashtable props = new Hashtable (20); props.put("username", "admin"); props.put("password", "admin"); PMPConnection con = pmp.connect("socket://127.0.0.1:1449", props); RemoteObject rObject = con.getReference(SYSTEM, "");
  • 17. String [] str = {Byte.TYPE.getName()}; RemoteMethod rMethod = rObject.getMethod("getProperties", str); rMethod.changeReturnType(ExternalizableDictionary.class); Dictionary obj = (ExternalizableDictionary)rMethod.invoke(new Object[] {new Byte((byte) 3)}, true); Enumeration enum = obj.keys(); while(enum.hasMoreElements()) { Object tmp = enum.nextElement(); System.out.println(tmp + " " + obj.get(tmp)); } } catch (Exception e) { System.out.println(e); } } public void stop(BundleContext bx) { } }
  • 18.  Bundle Management portion  Use PMP (prosyst message protocol) to get a connection to remote framework.  1. request PMPService  2. obtain PMPConnection  3. call remote service method
  • 19.  4.To make a service PMP-accessible, you should additionally implement the com.prosyst.util.io.Remoteinterface in the service class. public class example implements Remote { public Class[] remoteInterfaces() { } } Ref: https://dz.prosyst.com/pdoc/mbs_equinox_3.4/um/framework/bundles/p rosyst/rpc/pmp/pmpbundle.html
  • 20.  See also:  com.prosyst.util.parser ▪ Parser Service ▪ https://dz.prosyst.com/pdoc/mbs_prof_6.2/um/framew ork/bundles/system/putil/putil_parser.html  mConsole APIs ▪ https://dz.prosyst.com/pdoc/mbs_prof_6.2/um/framew ork/admins/mConsole/mConsole_programmer.html
  • 21.  EV bundle portion  Java.net.DatagramSocket ▪ SO_BROADCAST ▪ setBroadcast(boolean on) ▪ getBroadcast()  Java.net.DatagramPacket ▪ Use DatagramPacket(int port)