Storing Objects in the Registry
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 ESB entities. For example, you could store the object as follows:
1 muleContext.getRegistry().registerObject("foo", new MyFoo());
You could then update the object from somewhere else:
1 2 3 4 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.