I'm wondering how I can dynamically annotate a set of EJB services with either Stateful or Stateless annotation. The reason behind is that the website I'm developing is using a Conversation scope of most of the backing beans. And so I use Stateful annotated services and extended PersistenceContext.
But I'm having a problem with jobs, job normally run on the background and so I don't really need a backing bean. So in this case I wanted my services to be Stateless. But I already annotated them with Stateful.
Any idea how to solve this issue? I have 2 solutions to this issue but I'm not really satisfied: 1.) Create a base service implementation, extend it with 2 other classes that will be annotated with Stateful and Stateless.
2.) Same as step 1 but this time the job and Stateless classes will be move to another project. And this project will use Alternative feature of JavaEE, in this way we are using Stateless services for the job project.