That is the typical case like in jpa where you have a generic service
that needs to create objects from a packages it can not know at compile
time.
The typical solution for this is to give B the classloader of C. So
currently you might have a deserialize method like:
Object object = unmarshal(InputStream is);
So the idea is to change this to
Object object = unmarshal(InputStream is, Classloader classloader);
So C can give B his classloader and B can use this to create objects
only C knows but not B. Another way is to give B a kind of context that
is configured with a list of the
classes from A. C can initialize this context so B does not have to load
these classes at all.
Christian
Am 24.04.2012 15:53, schrieb Hervé BARRAULT:
Hi,
I have a case where i can't see how to cleanly list the imported
packages without using DynamicImport-Package.
Example :
I have a bundle A where there is the whole dto.
I have a bundle B which defines a "container" library (basically a
container can support any Serializable and provides
serialization/deserialization tools).
I have a bundle C which use a container (from B) and add in this
container some object from the dto (from A)
In the bundle C, I instantiate the classes from the bundle B and A.
When i put "object from A" into "container from B" in "my code from C"
it is working without problem.
When i try to get "object from A" from "container from B" in "my code
from C" i get a ClassNotFoundException for the object in A.
My Bundle B has no specific import (i think this library shall be
"agnostic").
My bundle C import packages from A and B.
For Information, in B library we are using genericity which is perhaps
a problem for imports.
Where am I missing something ?
Regards
Hervé
--
Christian Schneider
http://www.liquid-reality.de
Open Source Architect
Talend Application Integration Division http://www.talend.com