Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Calling third party jar method from OSGi Bundle
Calling third party jar method from OSGi Bundle [message #93061] Thu, 26 July 2007 11:40 Go to next message
Eclipse UserFriend
Originally posted by: michael2de.yahoo.com

Hi All

From my bundle installed in equinox, I want to call a method of third party jar (asm.jar). One way of doing this is to include this jar in the bundle but there is a restriction that we cannot include this jar in the bundle.

Is there a way to call this jar present outside on file system from inside the container.

Thanks,
MJ
Re: Calling third party jar method from OSGi Bundle [message #93076 is a reply to message #93061] Thu, 26 July 2007 13:28 Go to previous messageGo to next message
Danail Nachev is currently offline Danail NachevFriend
Messages: 36
Registered: July 2009
Member
Hi Michael,

I can think of three methods to do this:

1) create a new url classloader, pass the filesystem url and call the
jar entry point via reflection. Ugly:)
2) deploy the jar in the system classpath and export its packages via
framework extension. Then, you import them in your bundle and everything
is OK.
3) bundle-ize the third party library. I don't know what are the
restriction of the license of the library, so you need to figure out
whether this makes any sense. Perhaps, not:)

So, the best option you have is 2). How to do it:

http://dev.eclipse.org/mhonarc/lists/equinox-dev/msg02229.ht ml

However, this message is quite scarce, so if you need additional
assistance, drop a message.


Michael wrote:
> Hi All
>
> From my bundle installed in equinox, I want to call a method of third party jar (asm.jar). One way of doing this is to include this jar in the bundle but there is a restriction that we cannot include this jar in the bundle.
>
> Is there a way to call this jar present outside on file system from inside the container.
>
> Thanks,
> MJ
Re: Calling third party jar method from OSGi Bundle [message #93106 is a reply to message #93076] Thu, 26 July 2007 17:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alex_blewitt.yahoo.com

You can use the 'external' location, but that's not supported outside of Eclipse and in any case isn't a good thing.

What you could do is develop a placeholder bundle to be expanded on the filing system:

org.example.asm.placeholder_1.0.0/META-INF/MANIFEST.MF

Bundle-Name: org.example.asm.placeholder
Bundle-ClassPath: asm.jar
Export-Package: org.example.asm

Then, get your users to manually install/copy the 'asm.jar' into 'plugins/org.example.asm.placeholder_1.0.0/'

You can then use standard Import-Package to get the packages in. Then, if ASM ever gets bundleized, you will have a working dependency straight away.

Alex.
Re: Calling third party jar method from OSGi Bundle [message #93146 is a reply to message #93061] Fri, 27 July 2007 05:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: michael2de.yahoo.com

I tried the following but does not seem to be working :(

System.setProperty("osgi.clean", "true");
System.setProperty("osgi.frameworkClassPath",
".,D:\\asm.jar");
System.setProperty("osgi.framework.extensions",
"D:\\asm.jar");

Is there something i am missing?

Thanks,
MJ
Re: Calling third party jar method from OSGi Bundle [message #93160 is a reply to message #93146] Fri, 27 July 2007 06:49 Go to previous messageGo to next message
Danail Nachev is currently offline Danail NachevFriend
Messages: 36
Registered: July 2009
Member
The idea is to create an empty framework extension. It will contain only
a manifest with proper Export-Package header. You can install it as
normal via BundleContext.installBundle() or specify it in the
osgi.framework.extensions (the framework extension, not the asm.jar) in
config.ini.

The other step is to include asm.jar in the search path of the
classloader, loaded the org.eclipse.osgi bundle. Normally all you need
is to add the asm.jar to the VM classpath argument when launching.

On second thought, Alex Blewitt's proposal starts to look very easier
than this:)


Michael wrote:
> I tried the following but does not seem to be working :(
>
> System.setProperty("osgi.clean", "true");
> System.setProperty("osgi.frameworkClassPath",
> ".,D:\\asm.jar");
> System.setProperty("osgi.framework.extensions",
> "D:\\asm.jar");
>
> Is there something i am missing?
>
> Thanks,
> MJ
Re: Calling third party jar method from OSGi Bundle [message #93174 is a reply to message #93160] Fri, 27 July 2007 07:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alex_blewitt.yahoo.com

I thought so :-)

BTW you can't expect to do anything with setting osgi.* properties after the environment is up and running. They can only be set before startup, such as with -D and config.ini entries.

Alex.

PS I'm sure that the approach of placeholder bundle has been used in prior versions of Eclipse for bundling non-EPL functionality, but I can't remember what it was.
Re: Calling third party jar method from OSGi Bundle [message #106795 is a reply to message #93076] Tue, 25 March 2008 13:30 Go to previous message
Eclipse UserFriend
Originally posted by: manoshpadannayil.gmail.com

Hi Danail Nachev,
Will you please explain the steps of the option 2 (framework extension method) for accessing the classes in a third party jar from OSGI bundle.

thanks in advance,
ManoshP
Previous Topic:JSP compiler in Equinox and Tomcat 5
Next Topic:extension points vs osgi services
Goto Forum:
  


Current Time: Thu Mar 28 22:34:34 GMT 2024

Powered by FUDForum. Page generated in 0.02815 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top