我的架構飛:
GlassFish應用服務器版3.1.2.2(5)
Java EE 6的
的Eclipse IDE
如何修改JNDI自定義資源的屬性值上
我創建了一個EJB計時器,它打印日誌消息:
@Startup
@Singleton
public class ProgrammaticalTimerEJB {
private final Logger log = Logger.getLogger(getClass().getName());
@Resource(name = "properties/mailconfig")
private Properties mailProperties;
@Resource
private TimerService timerService;
@PostConstruct
public void createProgrammaticalTimer() {
log.log(Level.INFO, "ProgrammaticalTimerEJB initialized");
ScheduleExpression everyTenSeconds = new ScheduleExpression().second("*/10").minute("*").hour("*");
timerService.createCalendarTimer(everyTenSeconds, new TimerConfig("passed message " + new Date(), false));
}
@Timeout
public void handleTimer(final Timer timer) {
log.info(new Date().toGMTString() + " Programmatical: " + mailProperties.getProperty("to"));
}
}
該類注入我的自定義JNDI資源:
@Resource(name = "properties/mailconfig")
private Properties mailProperties;
Eclipse控制檯:
INFO: 2 Aug 2013 10:55:40 GMT Programmatical: [email protected]
INFO: 2 Aug 2013 10:55:50 GMT Programmatical: [email protected]
INFO: 2 Aug 2013 10:56:00 GMT Programmatical: [email protected]
Glassfish的設置
asadmin> get server.resources.custom-resource.properties/mailconfig.property
server.resources.custom-resource.properties/[email protected]
Command get executed successfully.
asadmin>
現在我想改變在應用程序運行時該屬性值。 通過Adminconsole或asadmin的編輯它不工作。 這是可能的,或者是有一個其他/更好soulution?
提前