Hi,
I would like to have your opinion about sharing static members in the
Camel components.
Imagine the following scenario.
I want to create a Camel component that would be deployed on
ServiceMix. I want my component to cache some state and share it
between the ServiceMix bundles. For example I would like to share a
cache between bundles.
Let's assume that I cannot use OSGI service registry for some reason.
I decided then to implement my component to contain a shared static state.
class MyComponent extends DefaultComponent {
private static final Map<String,String> sharedCache = ...;
...
}
I also created Karaf feature for my component.
Then I created bundles with routes making use of my component.
from("my-component://...").to(...);
My assumption would be as follows then - if I install my component as
a feature in ServiceMix, then the other bundles using it will share
the static cache MyComponent#sharedCache (because it will be always
loaded by the same class loader associated with the bundle from
feature).
Do you see any drawbacks of this approach?
--
Henryk Konsek
http://henryk-konsek.blogspot.com