EJB Schedule task with access to JSF Managed Beans

谁说我不能喝 提交于 2019-12-13 04:39:00

问题


I have a feeling I'm mixing EJB and JSF managed bean responsibilities, but what I want is a scheduled task EJB (@Singleton with @Schedule) that has access to my JSF application scoped beans.

Specifically, I have a JSF @ApplicationScoped bean that sends different e-mails depending on if it's in Development, Test, or Production. I want to schedule this to send e-mails every 24 hours. What's the best way to accomplish this?


回答1:


It's bad design to set the business layer (EJB) as dependent on the Presentation layer. The reverse (Web tier depending on Business tier) is the time tested best practice.

The EJB tier is to provide services to the web tier. Your use case seeks to make the web tier provide services to the EJB tier. And the need, IMO is too trivial to make such a compromise. I'd recommend instead that you externalize the desired config in a .properties file within a secure location in your application that both tiers have access to.



来源:https://stackoverflow.com/questions/15076409/ejb-schedule-task-with-access-to-jsf-managed-beans

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!