I am using the following annotation:
@ActivationConfigProperty(
propertyName = "connectionParameters",
propertyValue = "host=127.0.0.1;port=5445,host=127.0.0.1;port=6600"),
public class TestMDB implements MessageDrivenBean, MessageListener
I would like to pull each of these IP addresses and ports and store them in a file jmsendpoints.properties
... then load them dynamically. Something like this:
@ActivationConfigProperty(
propertyName = "connectionParameters",
propertyValue = jmsEndpointsProperties.getConnectionParameters()),
public class TestMDB implements MessageDrivenBean, MessageListener
Is there a way to do that?
No. The annotation processor (the annotation-based framework you're using) needs to implement an approach to handling placeholders.
As an example, a similar technique is implemented in Spring
@Value("#{systemProperties.dbName}")
Here Spring
implements an approach to parsing that particular syntax, which in this case translates to something similar to System.getProperty("dbName");
Annotations are not designed to be modifiable at runtime, but you might be able to utilize a bytecode engineering library such as ASM in order to edit the annotation values dynamically.
Instead, I recommend creating an interface in which you could modify these values.
public interface Configurable {
public String getConnectionParameters();
}
public class TestMDB implements MessageDrivenBean, MessageListener, Configurable {
public String getConnectionParameters() {
return jmsEndpointsProperties.getConnectionParameters();
}
//...
}
You might wish to create a more key-value oriented interface, but that's the general concept of it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With