SlideShare a Scribd company logo
June 10-11, 2008 Berlin, Germany
Everything can be a bundle –
Making OSGi bundles of Java legacy code
Erik Wistrand
wistrand@makewave.com
Gunnar Ekolin
ekolin@makewave.com
2
•! Lots of Java code has been written taking stuff for
granted
•! Just one classloader
•! System.exit() is OK to call
•! A file system is present
•! A static main() method is used for start-up
•! ...
...this leads to classloading problems, premature
exit of the entire framework and various internal
bugs
What's the problem?
3
The Knopflerfish OSGi framework contains code
that can
•! Start jar files with only a static main method
•! Automatically import/export packages
•! Patch code that uses “bad” methods regarding
classloading etc.
What can be done?
4
Installing a non-bundle JAR-file
•! The Auto-Manifest feature of Knopflerfish makes
it possible to take any jar file and install it as if it
where bundle
•! All contained packages will be exported
•! Dynamic-Import: * used to get access to shared
packages.
5
Auto-Manifest - Configuration
The file automanifest.props
1.match.filter=(location=*hello_world-app*)!
1.export.filter=(pkg=*)!
1.export.file.filter=(file=*.class)!
1.header.DynamicImport-Package=*
1.header.Import-Package=[remove]
1.header.Export-Package=[autoexport]
6
Auto-Manifest - Launch
java
-Dorg.knopflerfish.framework.automanifest=true
-Dorg.knopflerfish.framework.automanifest.config=
file:automanifest.props
-Dorg.knopflerfish.framework.debug.automanifest=
true
-jar framework.jar
7
Demo: Hello World
•! Install the Hello World application
hello_world-app-1.0.0.jar
•! The demos are available for download from
http://www.knopflerfish.org/demos/knopflerfish-osgi-berlin-2008.zip
8
Main-Class as Activator - Launch
java
-Dorg.knopflerfish.framework.automanifest=true
-Dorg.knopflerfish.framework.automanifest.config=
file:automanifest.props
-Dorg.knopflerfish.framework.debug.automanifest=
true
-Dorg.knopflerfish.framework.main.class.activation=
file:jars/hello_world-app/hello_world-app-1.0.0.jar
-jar framework.jar
9
System.exit()!
•! An application normally calls System.exit(0)
to terminate.
•! This will kill the entire OSGi framework.
•! Common workaround:
•! Modify the application source to be OSGi aware and
recompile.
•! Impractical.
•! License issues.
•! Source may not be available.
10
SinceallbundleclassesareloadedviatheOSGiframework,theframeworkcanmodify
th
e
byte-code on the fly to use the correct classloader:
1. Load original byte code.
2. Find occurrences of “wrong” method calls.
3. Replace with call to “right” method.
4. Use the modified class.
(5. Profit!)!
A new approach – automatic byte code
modification
11
BundleClassLoader
The Knopflerfish implementation
Bundle Patched BundleASM
patches.props
12
•! Uses the ASM byte-code manipulation library.
•! A configuration file can specify which bundles/
classes should be modified.
•! Bundles are automatically modified as they are
loaded.
Yes, this is a poor man's aspect oriented
framework.
btw, LDAP filters are the best thing since sliced
bread. Yes, they are!
The Knopflerfish implementation
13
Default set of patches
•! java.lang.ClassLoader.getSystemClassLoader()!
•! Returns the bundle classloader.
•! java.lang.System.exit(int)!
•! Calls BundleContext.stop(), disabled by default.
•! java.lang.Class.forName(String)!
•! First tries the default classloader, then the bundle's classloader.
•! java.lang.Class.forName(String,boolean,ClassLoader)!
•
F
irst tries the specified classloader, then the bundle's classloader.
14
Patching - Launch
java
-Dorg.knopflerfish.framework.patch=true
-Dkf.patch.systemExitWrapper=true
-cp framework.jar:asm-3.1.jar
org.knopflerfish.framework.Main
15
Demo: Hello World
•! Start the Hello World application and stop it by
closing the window.
•! Same thing again with default bundle patching
enabled.
•! The demos are available for download from
http://www.knopflerfish.org/demos/knopflerfish-osgi-berlin-2008.zip
16
Classloading problems
•! Old, non-OSGi-aware libraries can easily be
wrapped as an OSGi bundle.
•! Sounds easy, just create a manifest file and export/
import the necessary stuff,
...but they may still run into classloading problems.
ClassNotFoundException:
Cannot find com.acme.ICustomer
17
Why ClassNotFoundException
•! For the OSGi import/export mechanism to work,
the bundle must use the Bundle classloader.
•! However, many libraries uses the system
classloader or the thread's classloader
•! Works great in standalone apps
•! Does not work at all in typical OSGi settings
18
package mypackage;
class Foo {
System classloader
Bundle classloader
mypackage.Foo.class
mypackage.Bar.class
Class c = ...getContextClassLoader().loadClass(“mypackage.Bar”);
Class c = Foo.class.getClassloader().loadClass(“mypackage.Bar”);
OSGi framework
Fails!
ok!
19
•! Modifying the library source to be OSGi-aware
and recompile
•! Impractical
•! License issues
•! Wrapping each library call in code that sets the
thread's context class loader
•! Tricky to find all cases
•! Boilerplate code is a Bad Thing
•! Put all classes on the system class path!
•! Really just hurts
Common workarounds to fix classloading
20
Demo – run jEdit as a bundle
jEdit bundle
Knopflerfish OSGi + ASM
jEdit 4.2 std distribution
Std OSGi bundles
Wrapper methods
JVM
21
Let's patch all library calls to
Class.forName(String name,
boolean init,
ClassLoader cl)!
Example patch
22
public static
Class forName3Wrapper(String name,
boolean initialize,
ClassLoader cl,
long bid,
Object context)
throws ClassNotFoundException
{
// use bundle classloader instead
return ...
}
First, write the wrapper method
23
•!Find the string signature of the method to be patched
java/lang/Class.forName(Ljava/lang/
String;ZLjava/lang/ClassLoader;)Ljava/
lang/Class;
•!Find the string signature or the static wrapper
method that should replace the above call
org/knopflerfish/framework/
ClassPatcherWrappers.forName3Wrapper
Next, find signature strings
24
patch.1.from= java/lang/Class.
forName(Ljava/lang/String;ZLjava/lang/ClassLoader;)
Ljava/lang/Class;
p
at
ch.1.to= org/knopflerfish/framework/ClassPatcherWrappers.
forName3Wrapper
patch.1.static=true
patch.1.active=true
# Optional LDAP-filter with keys: classname, methodname, methoddesc,
# methodaccess, bid, location and all manifest headers.
patches.filter=(&(!(classname=org.knopflerfish.*))
(!(classname=org.osgi.*))(location=*))!
Create configuration file
25
Specify Configuration File
•! A global (default) patch configuration file can be
specified as the value of the (system) property:
org.knopflerfish.framework.patch.configurl
•! Each bundle can specify a bundle specific
patch configuration file via the manifest
header:
Bundle-ClassPatcher-Config:!/patches.props
26
java 
-Dorg.knopflerfish.framework.patch=true 
-Dorg.knopflerfish.framework.patch.configurl=
file:patches.props 
-cp framework.jar:asm-3.1.jar 
org.knopflerfish.framework.Main
...and launch
27
Upcoming changes
•! Today the patching engine is part of the
framework.
•! It will be moved out to a separate bundle using
an API similar to
java.lang.instrumentation.ClassFileTransformer
June 10-11, 2008 Berlin, Germany
Q&A
Gunnar Ekolin
ekolin@makewave.com
June 10-11, 2008 Berlin, Germany
Everything can be a bundle –
Making OSGi bundles of Java legacy code
Erik Wistrand
wistrand@makewave.com
Gunnar Ekolin
ekolin@makewave.com

More Related Content

PDF
Beyond JVM - YOW! Sydney 2013
PDF
JVM for Dummies - OSCON 2011
PDF
Burp Plugin Development for Java n00bs - 44CON 2012
KEY
JavaOne 2011 - JVM Bytecode for Dummies
PPTX
Mastering java bytecode with ASM - GeeCON 2012
PDF
Clojure in real life 17.10.2014
PPTX
GOTO Night with Charles Nutter Slides
PDF
Beyond JVM - YOW Melbourne 2013
Beyond JVM - YOW! Sydney 2013
JVM for Dummies - OSCON 2011
Burp Plugin Development for Java n00bs - 44CON 2012
JavaOne 2011 - JVM Bytecode for Dummies
Mastering java bytecode with ASM - GeeCON 2012
Clojure in real life 17.10.2014
GOTO Night with Charles Nutter Slides
Beyond JVM - YOW Melbourne 2013

What's hot (20)

PDF
mjprof: Monadic approach for JVM profiling
PPTX
Thread dump troubleshooting
PDF
Asynchronous I/O in Python 3
KEY
Mashups with Drupal and QueryPath
PDF
Oscon Java Testing on the Fast Lane
PDF
Dist::Zilla - A very brief introduction
PPTX
Attack on the Core
PDF
Connecting the Worlds of Java and Ruby with JRuby
PPTX
Ahead-Of-Time Compilation of Java Applications
PDF
Using Java from Ruby with JRuby IRB
PDF
Java Deserialization Vulnerabilities - The Forgotten Bug Class
PDF
Resting on your laurels will get you powned
PPTX
Why Doesn't Java Has Instant Turnaround - Con-FESS 2012
PDF
Beyond JVM - YOW! Brisbane 2013
PPTX
BSides Edinburgh 2017 - TR-06FAIL and other CPE Configuration Disasters
PPTX
Power of linked list
PDF
Invokedynamic in 45 Minutes
KEY
Lock? We don't need no stinkin' locks!
PPTX
JRuby in Java Projects
PDF
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)
mjprof: Monadic approach for JVM profiling
Thread dump troubleshooting
Asynchronous I/O in Python 3
Mashups with Drupal and QueryPath
Oscon Java Testing on the Fast Lane
Dist::Zilla - A very brief introduction
Attack on the Core
Connecting the Worlds of Java and Ruby with JRuby
Ahead-Of-Time Compilation of Java Applications
Using Java from Ruby with JRuby IRB
Java Deserialization Vulnerabilities - The Forgotten Bug Class
Resting on your laurels will get you powned
Why Doesn't Java Has Instant Turnaround - Con-FESS 2012
Beyond JVM - YOW! Brisbane 2013
BSides Edinburgh 2017 - TR-06FAIL and other CPE Configuration Disasters
Power of linked list
Invokedynamic in 45 Minutes
Lock? We don't need no stinkin' locks!
JRuby in Java Projects
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)
Ad

Similar to Everything can be a bundle - making OSGi bundles of Java legacy code - Gunnar Ekolin, Makewave (19)

PDF
Everything can be a bundle — automatically repairing pre-OSGi code - Erik Wis...
PDF
OSGi bootcamp - part 1
PPTX
Introduction to OSGi
PPTX
NetBeans Plugin Development: JRebel Experience Report
PDF
Delving Deeper Into OSGI Modularity
ODP
OSGi-friendly bytecode weaving – enhance your classes, not your dependency gr...
PDF
OSGi framework overview
PDF
OSGI Modularity
PDF
Intro To OSGi
PDF
Create *real* modular Java applications - a brief introduction -
PDF
Understanding ClassLoaders
PPTX
OSGi Training for Carbon Developers
PDF
How to Make Your Code OSGi Friendly Without Depending on OSGi - Neil Bartlett
PDF
Third party libraries and OSGi - a complicated relationship
PDF
Will it blend? Java agents and OSGi
PDF
Bytecode Weaving in OSGi – Enhance Your Classes, Not Your Dependency graph! ...
PDF
How Class Data Sharing Can Speed up Your Jakarta EE Application Startup
PPT
Sviluppo di architetture orientate ai servizi con EclipseSOA
PPT
OSGi & Blueprint
Everything can be a bundle — automatically repairing pre-OSGi code - Erik Wis...
OSGi bootcamp - part 1
Introduction to OSGi
NetBeans Plugin Development: JRebel Experience Report
Delving Deeper Into OSGI Modularity
OSGi-friendly bytecode weaving – enhance your classes, not your dependency gr...
OSGi framework overview
OSGI Modularity
Intro To OSGi
Create *real* modular Java applications - a brief introduction -
Understanding ClassLoaders
OSGi Training for Carbon Developers
How to Make Your Code OSGi Friendly Without Depending on OSGi - Neil Bartlett
Third party libraries and OSGi - a complicated relationship
Will it blend? Java agents and OSGi
Bytecode Weaving in OSGi – Enhance Your Classes, Not Your Dependency graph! ...
How Class Data Sharing Can Speed up Your Jakarta EE Application Startup
Sviluppo di architetture orientate ai servizi con EclipseSOA
OSGi & Blueprint
Ad

More from mfrancis (20)

PDF
Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...
PDF
OSGi and Java 9+ - BJ Hargrave (IBM)
PDF
Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)
PDF
OSGi for the data centre - Connecting OSGi to Kubernetes - Frank Lyaruu
PDF
Remote Management and Monitoring of Distributed OSGi Applications - Tim Verbe...
PDF
OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...
PDF
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...
PDF
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
PDF
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
PDF
OSGi CDI Integration Specification - Ray Augé (Liferay)
PDF
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
PDF
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
PDF
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
PDF
Popular patterns revisited on OSGi - Christian Schneider (Adobe)
PDF
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
PDF
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
PDF
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
PDF
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
PDF
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
PDF
How to connect your OSGi application - Dirk Fauth (Bosch)
Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...
OSGi and Java 9+ - BJ Hargrave (IBM)
Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)
OSGi for the data centre - Connecting OSGi to Kubernetes - Frank Lyaruu
Remote Management and Monitoring of Distributed OSGi Applications - Tim Verbe...
OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
OSGi CDI Integration Specification - Ray Augé (Liferay)
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
Popular patterns revisited on OSGi - Christian Schneider (Adobe)
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
How to connect your OSGi application - Dirk Fauth (Bosch)

Recently uploaded (20)

PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
A Presentation on Artificial Intelligence
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Approach and Philosophy of On baking technology
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Encapsulation theory and applications.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Cloud computing and distributed systems.
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Chapter 3 Spatial Domain Image Processing.pdf
Big Data Technologies - Introduction.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
A Presentation on Artificial Intelligence
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Spectral efficient network and resource selection model in 5G networks
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Approach and Philosophy of On baking technology
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Empathic Computing: Creating Shared Understanding
Encapsulation theory and applications.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Cloud computing and distributed systems.
Building Integrated photovoltaic BIPV_UPV.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Unlocking AI with Model Context Protocol (MCP)
Digital-Transformation-Roadmap-for-Companies.pptx
MYSQL Presentation for SQL database connectivity
20250228 LYD VKU AI Blended-Learning.pptx

Everything can be a bundle - making OSGi bundles of Java legacy code - Gunnar Ekolin, Makewave

  • 1. June 10-11, 2008 Berlin, Germany Everything can be a bundle – Making OSGi bundles of Java legacy code Erik Wistrand wistrand@makewave.com Gunnar Ekolin ekolin@makewave.com
  • 2. 2 •! Lots of Java code has been written taking stuff for granted •! Just one classloader •! System.exit() is OK to call •! A file system is present •! A static main() method is used for start-up •! ... ...this leads to classloading problems, premature exit of the entire framework and various internal bugs What's the problem?
  • 3. 3 The Knopflerfish OSGi framework contains code that can •! Start jar files with only a static main method •! Automatically import/export packages •! Patch code that uses “bad” methods regarding classloading etc. What can be done?
  • 4. 4 Installing a non-bundle JAR-file •! The Auto-Manifest feature of Knopflerfish makes it possible to take any jar file and install it as if it where bundle •! All contained packages will be exported •! Dynamic-Import: * used to get access to shared packages.
  • 5. 5 Auto-Manifest - Configuration The file automanifest.props 1.match.filter=(location=*hello_world-app*)! 1.export.filter=(pkg=*)! 1.export.file.filter=(file=*.class)! 1.header.DynamicImport-Package=* 1.header.Import-Package=[remove] 1.header.Export-Package=[autoexport]
  • 7. 7 Demo: Hello World •! Install the Hello World application hello_world-app-1.0.0.jar •! The demos are available for download from http://www.knopflerfish.org/demos/knopflerfish-osgi-berlin-2008.zip
  • 8. 8 Main-Class as Activator - Launch java -Dorg.knopflerfish.framework.automanifest=true -Dorg.knopflerfish.framework.automanifest.config= file:automanifest.props -Dorg.knopflerfish.framework.debug.automanifest= true -Dorg.knopflerfish.framework.main.class.activation= file:jars/hello_world-app/hello_world-app-1.0.0.jar -jar framework.jar
  • 9. 9 System.exit()! •! An application normally calls System.exit(0) to terminate. •! This will kill the entire OSGi framework. •! Common workaround: •! Modify the application source to be OSGi aware and recompile. •! Impractical. •! License issues. •! Source may not be available.
  • 10. 10 SinceallbundleclassesareloadedviatheOSGiframework,theframeworkcanmodify th e byte-code on the fly to use the correct classloader: 1. Load original byte code. 2. Find occurrences of “wrong” method calls. 3. Replace with call to “right” method. 4. Use the modified class. (5. Profit!)! A new approach – automatic byte code modification
  • 12. 12 •! Uses the ASM byte-code manipulation library. •! A configuration file can specify which bundles/ classes should be modified. •! Bundles are automatically modified as they are loaded. Yes, this is a poor man's aspect oriented framework. btw, LDAP filters are the best thing since sliced bread. Yes, they are! The Knopflerfish implementation
  • 13. 13 Default set of patches •! java.lang.ClassLoader.getSystemClassLoader()! •! Returns the bundle classloader. •! java.lang.System.exit(int)! •! Calls BundleContext.stop(), disabled by default. •! java.lang.Class.forName(String)! •! First tries the default classloader, then the bundle's classloader. •! java.lang.Class.forName(String,boolean,ClassLoader)! • F irst tries the specified classloader, then the bundle's classloader.
  • 15. 15 Demo: Hello World •! Start the Hello World application and stop it by closing the window. •! Same thing again with default bundle patching enabled. •! The demos are available for download from http://www.knopflerfish.org/demos/knopflerfish-osgi-berlin-2008.zip
  • 16. 16 Classloading problems •! Old, non-OSGi-aware libraries can easily be wrapped as an OSGi bundle. •! Sounds easy, just create a manifest file and export/ import the necessary stuff, ...but they may still run into classloading problems. ClassNotFoundException: Cannot find com.acme.ICustomer
  • 17. 17 Why ClassNotFoundException •! For the OSGi import/export mechanism to work, the bundle must use the Bundle classloader. •! However, many libraries uses the system classloader or the thread's classloader •! Works great in standalone apps •! Does not work at all in typical OSGi settings
  • 18. 18 package mypackage; class Foo { System classloader Bundle classloader mypackage.Foo.class mypackage.Bar.class Class c = ...getContextClassLoader().loadClass(“mypackage.Bar”); Class c = Foo.class.getClassloader().loadClass(“mypackage.Bar”); OSGi framework Fails! ok!
  • 19. 19 •! Modifying the library source to be OSGi-aware and recompile •! Impractical •! License issues •! Wrapping each library call in code that sets the thread's context class loader •! Tricky to find all cases •! Boilerplate code is a Bad Thing •! Put all classes on the system class path! •! Really just hurts Common workarounds to fix classloading
  • 20. 20 Demo – run jEdit as a bundle jEdit bundle Knopflerfish OSGi + ASM jEdit 4.2 std distribution Std OSGi bundles Wrapper methods JVM
  • 21. 21 Let's patch all library calls to Class.forName(String name, boolean init, ClassLoader cl)! Example patch
  • 22. 22 public static Class forName3Wrapper(String name, boolean initialize, ClassLoader cl, long bid, Object context) throws ClassNotFoundException { // use bundle classloader instead return ... } First, write the wrapper method
  • 23. 23 •!Find the string signature of the method to be patched java/lang/Class.forName(Ljava/lang/ String;ZLjava/lang/ClassLoader;)Ljava/ lang/Class; •!Find the string signature or the static wrapper method that should replace the above call org/knopflerfish/framework/ ClassPatcherWrappers.forName3Wrapper Next, find signature strings
  • 24. 24 patch.1.from= java/lang/Class. forName(Ljava/lang/String;ZLjava/lang/ClassLoader;) Ljava/lang/Class; p at ch.1.to= org/knopflerfish/framework/ClassPatcherWrappers. forName3Wrapper patch.1.static=true patch.1.active=true # Optional LDAP-filter with keys: classname, methodname, methoddesc, # methodaccess, bid, location and all manifest headers. patches.filter=(&(!(classname=org.knopflerfish.*)) (!(classname=org.osgi.*))(location=*))! Create configuration file
  • 25. 25 Specify Configuration File •! A global (default) patch configuration file can be specified as the value of the (system) property: org.knopflerfish.framework.patch.configurl •! Each bundle can specify a bundle specific patch configuration file via the manifest header: Bundle-ClassPatcher-Config:!/patches.props
  • 26. 26 java -Dorg.knopflerfish.framework.patch=true -Dorg.knopflerfish.framework.patch.configurl= file:patches.props -cp framework.jar:asm-3.1.jar org.knopflerfish.framework.Main ...and launch
  • 27. 27 Upcoming changes •! Today the patching engine is part of the framework. •! It will be moved out to a separate bundle using an API similar to java.lang.instrumentation.ClassFileTransformer
  • 28. June 10-11, 2008 Berlin, Germany Q&A Gunnar Ekolin ekolin@makewave.com
  • 29. June 10-11, 2008 Berlin, Germany Everything can be a bundle – Making OSGi bundles of Java legacy code Erik Wistrand wistrand@makewave.com Gunnar Ekolin ekolin@makewave.com