Storing Objects in the Registry
|MuleSoft recommends against deployments to Mule 3.8. Standard Support for this version ended on November 16, 2018, and Mule 3.8 will reach its End of Life on November 16, 2021, when Extended Support ends.|
If you need to store runtime data that is available across the application, you can store the data as objects in the Registry. You can get a handle to the Registry from anywhere that you have access to the MuleContext, as in most Mule entities. For example, you could store the object as follows:
muleContext.getRegistry().registerObject("foo", new MyFoo());
You could then update the object from somewhere else:
Foo foo = (Foo) muleContext.getRegistry().lookupObject("foo"); foo.setBarVal(25); // Replace the previous object muleContext.getRegistry().registerObject("foo", foo);
This approach is useful for storing an object that is needed by multiple components across your application.