ryan1234
ryan1234

Reputation: 7275

How to access Spring configuration properties in Java class

If I have my own transformer and I'm doing work in a Java class, how can I access the Spring configuration properties?

In the flow XML I would type something like ${activemq_server}, but in Java I'm not sure how to get that value.

I'm digging through the MuleMessage and all the objects that come with it (Context, Configuration, etc.), but I haven't found them yet.

In the past I've injected them into message properties, but that feels so sloppy.

Upvotes: 2

Views: 988

Answers (1)

David Dossot
David Dossot

Reputation: 33413

IMO injecting properties in Spring beans is probably the cleanest.

Alternatively, you can use util:properties to load the properties file in a bean and then have the context:property-placeholder use this bean for placeholder resolution. This gives you the possibility to either inject or use MEL to lookup this bean (like #[app.registry.myProperties.propertyName].

Upvotes: 2

Related Questions