During a project, I have some issues about what pattern would be the best to use. The case is that I have a singleton startup bean that loads some configs from files. My target is to consume some messages from a queue using the beans(no message driven beans cause of AMQP, I know there is a JMS client but it doesn't work in our case). After startup, I need one (stateless?) bean to start(how? inject it in the singleton??) and run the consume runnable that in each delivery runs some code that needs to persist entities. So that means that it has to be a bean in order to inject the persistence context? My questions are is there a way to inject-use persistencecontext em through a non-ejb class avoiding passing it through reference(I checked it and this worked passing it all way the flow till the class that persisting the entities) from the singleton, or it has to be an ejb 100%? Also is it a feasible and good pattern to inject the singleton into the stateless ejbs in order to pull global configurations in postconstruct? Currently there is an implementation of the current system using only a singleton startup bean and the rest are all non-ejb classes, passing container objects through singleton references. A change now in the way we persist force to use an injected entitymanager. Any suggestions-ideas?
Aucun commentaire:
Enregistrer un commentaire