camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henryk Konsek <>
Subject Shared static members in components
Date Mon, 11 Feb 2013 20:20:33 GMT

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.


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

Do you see any drawbacks of this approach?

Henryk Konsek

View raw message