Hear from Salesforce leaders on how to create and deploy Agentforce agents.
Contact Us 1-800-596-4880

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 entities. For example, you could store the object as follows:

muleContext.getRegistry().registerObject("foo", new MyFoo());
java

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);
java

This approach is useful for storing an object that is needed by multiple components across your application.