至少从 JBoss AS 5.1 开始,您可以使用 AOP 来配置 @ActivationConfigProperties。我通过查看 jboss在此处提供的示例发现了这一点。如果您不希望系统属性中的整个容器都可以使用您的用户名和密码,或者如果您像我一样,并且从不(我重复一遍,从不)想要部署其中包含用户名/密码的工件,这将非常有用。无论如何,这是jist...
像这样注释 mdb...
...
@MessageDriven
@AspectDomain("TestMDBean")
public class TestMDBean implements MessageListener {
...
然后将 ${whatever}-aop.xml 添加到具有如下内部结构的部署目录。我把原来的评论留在那里,以防 Jaikiran 确实做出了提到的改变......
注意:注释只能在一行上。
<?xml version="1.0" encoding="UTF-8"?>
<aop xmlns="urn:jboss:aop-beans:1.0">
<!-- TODO: Jaikiran - These interceptor declarations need not be here since they
are already declared through the ejb3-interceptors-aop.xml. Duplicating them leads to
deployment errors. However, if this custom-ejb3-interceptors-aop.xml needs to be
independent, then we must find a better way of declaring these. Right now, commenting these
out, can be looked at later. -->
<!--
<interceptor class="org.jboss.ejb3.AllowedOperationsInterceptor" scope="PER_VM"/>
<interceptor class="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor" scope="PER_VM"/>
<interceptor factory="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory" scope="PER_CLASS"/>
<interceptor class="org.jboss.ejb3.stateless.StatelessInstanceInterceptor" scope="PER_VM"/>
<interceptor factory="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory" scope="PER_CLASS_JOINPOINT"/>
<interceptor factory="org.jboss.aspects.tx.TxInterceptorFactory" scope="PER_CLASS_JOINPOINT"/>
-->
<domain name="TestMDBean" extends="Message Driven Bean" inheritBindings="true">
<annotation expr="!class(@org.jboss.ejb3.annotation.DefaultActivationSpecs)">
@org.jboss.ejb3.annotation.DefaultActivationSpecs (value={@javax.ejb.ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"), @javax.ejb.ActivationConfigProperty(propertyName="destination", propertyValue="queue/MyQueue"), @javax.ejb.ActivationConfigProperty(propertyName="user", propertyValue="testusr"), @javax.ejb.ActivationConfigProperty(propertyName="password", propertyValue="testpwd")})
</annotation>
</domain>
</aop>