我正在使用以下注释:
@ActivationConfigProperty(
propertyName = "connectionParameters",
propertyValue = "host=127.0.0.1;port=5445,host=127.0.0.1;port=6600"),
public class TestMDB implements MessageDrivenBean, MessageListener
我想提取每个 IP 地址和端口并将它们存储在文件 jmsendpoints.properties
中...然后动态加载它们。像这样:
@ActivationConfigProperty(
propertyName = "connectionParameters",
propertyValue = jmsEndpointsProperties.getConnectionParameters()),
public class TestMDB implements MessageDrivenBean, MessageListener
有办法吗?
最佳答案
否。注释处理器(您正在使用的基于注释的框架)需要实现一种处理占位符的方法。
例如,在 Spring
中实现了类似的技术。
@Value("#{systemProperties.dbName}")
在这里Spring
实现一种解析特定语法的方法,在本例中,它转换为类似于 System.getProperty("dbName");
关于java - 将动态参数传递给注释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12568385/