You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Andrey Tarantsov <an...@gmail.com> on 2008/05/31 06:44:19 UTC
Javaflow & OSGi: success story
Hi,
I found that the topic of Javaflow + OSGi has been raised on commons-dev@jakarta.apache.org
mailing list in the past. I decided this might still be interesting
for someone, and that this is the most appropriate list for such info.
I don't know if any answers have been posted, so I wanted to share
that I successfully got it to work, based on the following three
resources:
1) article at http://wiki.eclipse.org/index.php/Adaptor_Hooks
2) article at http://www.eclemma.org/research/instrumentingosgi/index.html
3) Emma instrumentation hook sources at https://eclemma.svn.sourceforge.net/svnroot/eclemma/research/com.mountainminds.eclemma.osgihook/
I'm willing to share the sources with anyone interested. (Just too
lazy to publish them right now, after a full night of debugging.)
Here's the README.txt accompanying my sources:
Using Apache Commons Javaflow with OSGi
=======================================
Run-time code instrumentation required by Javaflow can be employed in
OSGi environment
by means of so-called Adaptor Hooks. Please see [1] for more
information on them.
Enabling Javaflow instrumentation
---------------------------------
To instrument plugin classes with Javaflow, add the following header
into the
bundle manifest file (META-INF/MANIFEST.MF): “JavaFlow-Enabled: true”.
Running with Javaflow
---------------------
Please refer to [1]. In short, for *development* mode:
1) Open “Plug-ins” view, find org.eclipse.osgi and choose “Import As >
Source Project”.
2) Make sure org.eclipse.osgi (from your workspace) and
com.yoursway.osgi.javaflow
are enabled in the launch configuration.
3) Make extra sure org.eclipse.osgi and com.yoursway.osgi.javaflow are
located
in the same file system directory (e.g. both in the workspace folder).
4) Add “-Dosgi.framework.extensions=com.yoursway.osgi.javaflow” to VM
arguments of
your launch configuration (found on Arguments tab).
For *production* (compiled & jared plugins) mode:
1) Compile com.yoursway.osgi.javaflow into a jar, and make sure the
jar includes
a version number (e.g. com.yoursway.osgi.javaflow_1.0.0.jar).
2) Put com.yoursway.osgi.javaflow_*.jar into eclipse/plugins folder
(i.e. into
exactly the same folder where org.eclipse.osgi_*.jar is located).
3) Add “osgi.framework.extensions=com.yoursway.osgi.javaflow” to
config.ini.
Failure to do any of these steps will cause Javaflow extension to be
silently
ignored. In case you find yourself debugging it, two places of
interest are:
- org.eclipse.equinox.launcher/
org.eclipse.equinox.launcher.Main.readFrameworkExtensions
(Reads extensions list from “osgi.framework.extensions” property and
sets up
the class path of the system bundle. The same property is read from
numerous other
location, but those locations do not affect anything loaded from the
extension.)
- org.eclipse.osgi/
org.eclipse.osgi.baseadaptor.HookRegistry.mergeFileHookConfigurators
(Actually reads the list of hook configurators from
hookconfigurators.properties.)
A few facts
-----------
1) To provide run-time instrumentation, you need adaptor hooks.
2) Adaptor hooks can only be registered in OSGi extension bundles [2]
3) OSGi extension bundles cannot require any other bundles
4) So you need to put Javaflow libraries into the extension bundle
itself.
5) To make Javaflow available to other plugins, they must import the
packages
rather than requiring the bundle (something you cannot do with
fragments).
6) Unfortunately, Eclipse PDE has some kind of problem importing the
packages
from com.yoursway.osgi.javaflow fragment — I could not get it to
compile.
7) So you have to put another copy of Javaflow into a regular plugin,
and
require it in a regular way. You end up with two copies of Javaflow,
one of
them is only used for instrumentation so it's not a problem.
8) Equinox launcher reads eclipse.properties to determine the
extension classpath
(in case you wonder why the file is needed).
References
----------
[1] http://wiki.eclipse.org/index.php/Adaptor_Hooks
[2] OSGi R4 Core Reference, Section 3.15 “Extension Bundles”
Andrey.
Re: Javaflow & OSGi: success story
Posted by Torsten Curdt <tc...@apache.org>.
> I'm not using Cocoon. I'm developing an Eclipse-based IDE.
Bah ...sorry - thought you posted on the cocoon user lists. The lack
of sleep :)
> BTW, Javaflow really needs compilation instructions on the site.
It uses maven ...what instructions do you need for that? :)
mvn install
> It did not compile with the latest version of Asm library.
Well, the default instrumentation uses BCEL anyway (at least still).
The problem always was that the ASM guys were never very quick in
getting their releases into the maven repositories. But it should be
not too hard to upgrade it to the latest release - if available.
> I personally got a compiled version with all prerequisites offered
> by Swing Continuations project (http://www.exploringexcellence.com/swingcontinuations/download.html
> ). That's Swing Continuations 0.9, but I don't know which version of
> Javaflow.
Bah! ...I didn't even know about that project. How come so many people
use javaflow but never tell.
I wish a few more of them would actually tell and help to grow a
community.
cheers
--
Torsten
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: Javaflow & OSGi: success story
Posted by Andrey Tarantsov <an...@gmail.com>.
Hi,
> Which version of cocoon have you been using?
I'm not using Cocoon. I'm developing an Eclipse-based IDE.
BTW, Javaflow really needs compilation instructions on the site. It
did not compile with the latest version of Asm library. I personally
got a compiled version with all prerequisites offered by Swing
Continuations project (http://www.exploringexcellence.com/swingcontinuations/download.html
). That's Swing Continuations 0.9, but I don't know which version of
Javaflow.
Andrey.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: Javaflow & OSGi: success story
Posted by Torsten Curdt <tc...@apache.org>.
Hey Andrey,
Thanks for the write up! Glad you got that working.
Which version of cocoon have you been using?
cheers
--
Torsten
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org