0





16

Advertisement

Assume that I have a cluster of embedded hazelcast instances. In runtime of each node, I have an instance of some bean, which keeps some state (let's say - some application-specific configuration parameters). I can guarantee that this state is constant, immutable and same on each node within the whole application lifetime.

Now, I need to use this bean within the Runnables executed over Hazelcast's IExecutorService. What I am looking for, is something like HazelcastInstanceAware interface, but for my bean - some contract which will take my bean instanse from the node, where the Runnable is supposed to be executed, and pass it to the Runnable prior to execution.

It is not possible and desired for me to serialize this bean over the cluster (I see no reason in it since I have exactly same bean state on each node). I don't use and don't intend to use any dependency frameworks for now, so Spring is not an option (I don't want to take dependency injection framework to only inject one bean).

Do I have any options?

Question author Skapral | Source

Advertisement


0


When creating your HazelcastInstance you can configure a com.hazelcast.core.ManagedContext instance (com.hazelcast.config.Config#setManagedContext) that will inject your own instances based on custom rules (like interface implementations or similar).

Answer author Noctarius