我試圖在我們的EJB3應用程序中使用this method來接收郵件。總之,這意味着與以下注釋創建一個MDB:對MDB註釋的可配置值
@MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "mailServer", propertyValue = "imap.company.com"),
@ActivationConfigProperty(propertyName = "mailFolder", propertyValue = "INBOX"),
@ActivationConfigProperty(propertyName = "storeProtocol", propertyValue = "imap"),
@ActivationConfigProperty(propertyName = "debug", propertyValue = "false"),
@ActivationConfigProperty(propertyName = "userName", propertyValue = "username"),
@ActivationConfigProperty(propertyName = "password", propertyValue = "pass") })
@ResourceAdapter("mail-ra.rar")
@Name("mailMessageBean")
public class MailMessageBean implements MailListener {
public void onMessage(final Message msg) {
...snip...
}
}
我有這個工作,但情況不太理想:主機名,用戶名和密碼是硬編碼。在編譯之前使用ant和build.properties替換這些值的時候,我不知道如何將它們外化。
這將是使用MBean的理想選擇,但我不知道如何從MBean獲取值到MDB配置。
我該怎麼做?
對於JBoss,你還需要啓用`<規格描述符屬性替換>` – eis 2014-01-09 14:06:38
對於GlassFish你在domain.xml文件中添加此或使用create-JVM選項的asadmin命令工具。 – 2014-05-12 08:28:49