我的架构飞:
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?
提前