Skip to content
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

MapAttributeConfig cannot be loaded in an OSGi environment #8482

Closed
chuspb opened this issue Jun 30, 2016 · 4 comments

Comments

Projects
None yet
2 participants
@chuspb
Copy link

commented Jun 30, 2016

Hi,

Problem:
I am using Hazelcast 3.6. When I try to use a MapAttributeConfig in an OSGi environment I find that MapContainer receives name, mapconfig and mapServiceContext:

public MapContainer(final String name, final MapConfig mapConfig, final MapServiceContext mapServiceContext);

Then, inside it, the extractors are created like:

this.extractors = new Extractors(mapConfig.getMapAttributeConfigs());

And Extractors uses ExtractorHelpers, which uses Class.forName to load the ValueExtractor described in each MapAttributeConfig.

Then, I can not load extractors from different bundles, even if I add the bundle classloader to the Hz instance Config classloader.

Solutions:

Option A: Pass com.hazelcast.config.Config from MapServiceContextImpl to MapContainer constructor, and then pass it to Extractors constructors. Then try lo load de class using the Config classloader, like:
config.getClassLoader().loadClass("com.MyValueExtractor").
If it does not work, then try to load it as you do now with
instantiateExtractors(mapAttributeConfigs).

Option B: Let the MapAttributeConfig have a ValueExtractor instance, so Extractors class just search into MapAttributeConfig for them. The idea is to allow that a bundle can provide a ValueExtractor dinamically.

I think both options can live together.

What do you think? It could be possible? Thanks.

@chuspb

This comment has been minimized.

Copy link
Author

commented Jul 4, 2016

I have made an approach #8491.

May be you can review it?

Thanks

@tombujok

This comment has been minimized.

Copy link
Contributor

commented Jul 4, 2016

@chuspb Thx for the fix. I had to change some minor details, thus I submitted a new PR, but I set you as the author so that it's your commit: #8493
Plz check if that's fine for you.

@chuspb

This comment has been minimized.

Copy link
Author

commented Jul 4, 2016

It is more completed with your changes. Thanks so much!

@tombujok

This comment has been minimized.

Copy link
Contributor

commented Jul 4, 2016

@chuspb Thx, BTW, did you make any tests that the bundle-class-loader will be propagated to Config.classLoader? or do you have to do it manually?
It would be great to have a sample to show that behavior in the samples code-base, sth similar to:
https://github.com/hazelcast/hazelcast-code-samples/blob/master/osgi/src/main/java/com/hazelcast/osgi/examples/OSGiSample.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.