0

Do you guys know if there is some way to change the MANISFEST.MF settings programmaticaly at time to load a plugin? It would be perfect for me if I could do that on Activator start method.

For example:

I have a plugin1 that have a dependency on its MANIFEST.MF to plugin2 (Require-Bundle: plugin2;bundle-version="1.0.0")> The change a wanna do is to set reexport such dependency before (visibility:=reexport) load plugin1.

Any suggestion

Thanks in advance

Raphael Moita

BJ Hargrave
  • 9,324
  • 1
  • 19
  • 27

1 Answers1

2

You cannot change the manifest. The manifest contains declarative information need to resolve the bundle and supply it a class loader with visibility to the necessary types. Your activator class is loaded by that class loader. How can you expect a class loaded the class loader to change the definition of the classes visible to the class loader?

Why don't you just modify the manifest before installing the bundle?

BJ Hargrave
  • 9,324
  • 1
  • 19
  • 27
  • We have a framework that provides a custom Activator to the team's plugins. This custom Activator provides some extra features to the developers and now also is doing some changes (injection code) on the plugins code at time to load that. In order to get it working it needs to have some dependencies reexported cause after injection it is being compiled again and I'm getting a ClassDefFoundError. As the code being injected is a legacy, and I can ask to the teams to change it manually, I'm looking for a way to do that at time to loading/install the bundle. – VeryNiceArgumentException Oct 24 '12 at 10:15
  • Have you looked at the [weaving hooks](http://www.osgi.org/javadoc/r4v43/core/index.html?org/osgi/framework/hooks/weaving/package-summary.html)? While you don't need to actually weave the code, you can [add dynamic import package clauses](http://www.osgi.org/javadoc/r4v43/core/org/osgi/framework/hooks/weaving/WovenClass.html#getDynamicImports%28%29) at runtime. – BJ Hargrave Oct 24 '12 at 12:20
  • It's not a matter of importing a package, it's a case of class visibility. That's why I wanna reexport a specific depedency. – VeryNiceArgumentException Oct 24 '12 at 17:02
  • OK, then you will need to update the bundle with a modified version having it's manifest changed as you require. – BJ Hargrave Oct 24 '12 at 21:42
  • If could do that I wouldn't be looking for a way to do that in runtime ;) ... but thanks anyway! – VeryNiceArgumentException Oct 25 '12 at 11:00