0 votes
asked in MicroStream for Java by (160 points)
Hi there,

first of all: great product and thanks a lot for presenting it at the JUG Augsburg.

As I already suggested at the meeting: I t would be great if your libraries had proper OSGi Metadata in their Manifest files.

As I couldn't wait to try it out in our setup I already repackaged your "all" jar and made a testdrive with it within an OSGi Environment. At least your hello world application works like a charm :)

All you would need to do is to add either the bnd maven/gradle plugin or the apache-felix maven-bundle-plugin to your build and it will generate all the needed OSGi Metadata for you. As long as you are not doing any nasty classloading/serviceloader stuff within your library, this would make microstream usable in every OSGi runtime.

If you need any support regarding OSGi I will gladly help you out.

 

Keep up your great work!

 

Kind regards.

Thomas

1 Answer

0 votes
answered by (160 points)
edited by
First finding: Of course you are doing some sort of classloading internally (my bad, sorry ;) ) so your manifest file would need a Header like

DynamicImport-Package: *

in order to find the class files it needs in an OSGi environment.

Either this or I could use my own classloader.

I will further test it and if I find something, I will post my findings here :)
commented by (3.4k points)
Hello Thomas,

many thanks for your post and your offer to give us some support regarding OSGi.
We already created an internal issue to add proper OSGi support to Microstream. Unfortunately, I cannot estimate when it will be available.

 

Regarding the class loading:

Microstream needs access to all classes that have been stored to recreate the persisted objects. This is done on startup if an existing storage has been found or during lazy-loading. By default, Microstream uses the standard Java classloader but you can provide a custom class loader quit easily.
see https://manual.docs.microstream.one/data-store/customizing/custom-class-loader

please let us know If you have any suggestions or questions.

 

Best regards
Harald
commented by (160 points)

Hi Harald,

thanks for the link. This would indeed be a possibility to use microstream in OSGi. 

However, I think the simpler approach would be to add the above mentioned header to your manifest. At least for all my test this worked perfectly.

 

All I did was to repackage your "all" artifact and generate the manifest via maven-bundle-plugin.

Don't know if this helps you, but here is the needed maven plugin configuration for this:

<plugin>
 <groupId>org.apache.felix</groupId>
 <artifactId>maven-bundle-plugin</artifactId>
 <version>4.2.1</version>
 <extensions>true</extensions>
  <dependencies>
   <dependency>
    <groupId>biz.aQute.bnd</groupId>
    <artifactId>biz.aQute.bndlib</artifactId>
    <version>5.0.0</version>
   </dependency>
  </dependencies>
  <configuration>
   <instructions>
    <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
    <Bundle-Version>${project.version}</Bundle-Version>
    <Export-Package>
      one.microstream*;-split-package:=merge-first
    </Export-Package>
    <Import-Package>*</Import-Package>
    <DynamicImport-Package>*</DynamicImport-Package>
   </instructions>
  </configuration>
</plugin>

The module's packaging would need to be "bundle" instead of jar, but there's virtually no difference between those two aside from the additional information in the manifest.

 

Kind regards,

Thomas

 

Notes: Every question must be a separate forum post. Headline: Formulate your question shortly and precisely. Thank you!
Powered by Question2Answer
...