-
-
Notifications
You must be signed in to change notification settings - Fork 872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow specification of the classloader for [de]serialisation #555
Comments
I will have a look, thanks for good documentation. On August 7, 2015 5:57:25 PM CEST, gravelld notifications@github.com wrote:
|
MapDB now allows to set custom global class loader and per-class class loader. There are new methods in This will set default Class Loader for all classes instantiated during deserialization: And this will set Class Loader for specific class: |
Thanks, that will be very easy for me to port to. |
See also #377 .
When MapDB [de]serialises objects, it needs to load the classes each object implements.
In a Java app running in a vanilla application container, using Class.forName is sufficient for this, because there is no class scope and all classes are known to all classes.
In an OSGi container, the scope is far more constrained. MapDB is deployed as its own "bundle" and using Class.forName will only work to load classes in the packages that the MapDB bundle has been pre-configured to know about.
This is a problem common with ORMs. The problem is more eloquently and authoritatively described in http://njbartlett.name/2010/08/30/osgi-readiness-loading-classes.html . Three solutions are suggested.
For my own use, I have hacked MapDB to have a
setClassloader
method onDBMaker
which is passed through to the serialisation layer. This is then used for loading classes, and it works well. However, whoever does this work for MapDB should consider which of the three options presented above makes most sense from MapDB's perspective.The text was updated successfully, but these errors were encountered: