I have a fairly standard architecture for my application. I'm using SFSB/SLSB
Seam components with IN/OUT injection. These methods call the EntityManager
(e.g., find()) to interact with the database.
| @Name("seam.editor")
| @Stateful
| public class SeamEditor implements ISeamEditor{
| @In EntityManager em;
|
| @Out DomainModelObject dmo;
| public String executeAction(){
| dmo = em.find(DomainModelObject.class, new Long(9));
| dmo.performSomeAction();
| }
| }
|
Deep in the object graph returned by the the EntityManager, a domain model
object sometimes needs to call a service to obtain another resource. Right
now, these services are static method calls.
| @Entity
| public class DeepDomainObject{
|
| private long id;
|
| public String calculateSomething(){
| ..snip...
|
| String resut = DAService.getSomeInformationFromAnotherService();
|
| ..snip...
| }
|
| }
|
The domain object is created by the EntityManager (using Jboss 4.0.x) via lazy
loading using (or eager fetching). So there isn't any DI injection from Seam
of the EJB (3) container. And I'm pretty sure I don't want it to come from the
container as we want to run unit tests outside the container (which will not
hit the db).
We've now run into the unit testing issue that we want to mock out the static
method call. We're exploring different options (Factory creation) and
different DI mechanisms.
What have others done? Does anyone have experience with Guice in this type of
situation?
Thanks in advance,
Chris....
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4113898#4113898
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4113898
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user