传递动态参数注释? [英] Passing dynamic parameters to an annotation?
问题描述
我用下面的注释:
@ActivationConfigProperty(
propertyName的=connectionParameters
为PropertyValue =主机= 127.0.0.1,端口= 5445,主机= 127.0.0.1,端口= 6600),
公共类TestMDB实现消息驱动Bean,消息监听
我想拉这些IP地址和端口,并将它们存储在一个文件中 jmsendpoints.properties
...然后动态地加载它们。事情是这样的:
@ActivationConfigProperty(
propertyName的=connectionParameters
的PropertyValue = jmsEndpointsProperties.getConnectionParameters()),
公共类TestMDB实现消息驱动Bean,消息监听
有没有办法做到这一点?
否注解处理器(您正在使用基于注解的框架)需要实现一个方法来处理占位符。
作为一个例子,一个类似的技术在<一个实施href=\"http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/\"><$c$c>Spring$c$c>
@Value(#{systemProperties.dbName})
下面<一个href=\"http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/ex$p$pssions.html\"><$c$c>Spring$c$c>实现了一个方法的解析</ em>的特定语法,在这种情况下,转换为类似的东西,以 I am using the following annotation: I would like to pull each of these IP addresses and ports and store them in a file 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 Here 这篇关于传递动态参数注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! System.getProperty(DBNAME);
对>@ActivationConfigProperty(
propertyName = "connectionParameters",
propertyValue = "host=127.0.0.1;port=5445,host=127.0.0.1;port=6600"),
public class TestMDB implements MessageDrivenBean, MessageListener
jmsendpoints.properties
... then load them dynamically. Something like this:@ActivationConfigProperty(
propertyName = "connectionParameters",
propertyValue = jmsEndpointsProperties.getConnectionParameters()),
public class TestMDB implements MessageDrivenBean, MessageListener
Spring
@Value("#{systemProperties.dbName}")
Spring
implements an approach to parsing that particular syntax, which in this case translates to something similar to System.getProperty("dbName");