0

I'm working on an eclipse-based application, composed by several plug-ins. One of these plugins performs a computationally-intensive task, hence I want to provide a "native" implementation for some platforms I support. What is the best way to do it?

I was thinking about a base plugin (which provides the default implementation) extended with some fragments (to provide platform-specific implementations). However, how can the base plugin be aware of the available fragments?

Matteo
  • 1,367
  • 7
  • 25

2 Answers2

2

You could write a class in your main plugin similar to LocalFileNatives from org.eclipse.core.filesystem. It loads a library that implements its set of native methods. It then provides a facade to the system that uses the native implementation if it is available but has some default functionality for platforms where there are no native implementations.

Then each platform fragment simply provides the appropriate native DLL or .so

There are other options for having the fragment supply a service, that can be retrieved by the host plugin.

Paul Webster
  • 10,614
  • 1
  • 25
  • 32
0

Eclipse plugin's are written in Java. So what you need to do is retrieve OS info.

If you scroll to the bottom of this page, you'll see a code that does this.

karlphillip
  • 92,053
  • 36
  • 243
  • 426
  • Yeah, Eclipse plugins' are written in java, this is why I want to use JNI and write some native code to speed-up computationally-intensive tasks. Moreover, I was planning to specify the `Eclipse-PlatformFilter:` to ensure that each platform only loads the correct fragment. However, I am not able to make the "base" plugin aware of the fragments (and use them to perform the computationally-intensive task). – Matteo Jun 16 '11 at 16:39
  • Check the link I suggested above and let us know if that is what you are looking for. – karlphillip Jun 16 '11 at 16:41
  • I do not want to detect the platform within a single plugin. Instead, I would like to use the eclipse facilities to load the correct fragment. This way, if I want to support a new platform, I only have to release a new fragment (and all the other users are not affected by this change). – Matteo Jun 16 '11 at 16:45