I'm in the process of creating a persistence.jar that different
projects can use. The jar will mainly consist of service objects that
call daos. For example UserService will have getUser which calls a
userDao.getUser  method.

I'm not so sure though that I want the external users of the jar to be
required to use Guice to bootstrap it with Guice.createInjector
(module).

I don't really mind, if at the very end point that the user's deal
with, I code typical singletons, but I still want the daos injected by
Guice.

So for example...

public class AssociateService extends BaseService {
        private static final AssociateService instance = new AssociateService
();
        private AssociateService() {}
        public static AssociateService getInstance() {
           return instance;
        }

        AssociateDAO associateDAO;

        @Inject
        public setAssociateDAO(AssociateDAO associateDAO) {
                this.associateDAO = associateDAO;
        }

        public Associate findByDmzID(String dmzID) throws Exception  {
                 return associateDAO.findByDmzID(dmzID);
        }
        //..
}

public abstract BaseService {
        static {
                //COULD I JUST BOOTSTRAP HERE? which will make sure that  call
                //to AssociateService.getInstance() will properly have the
AssociateDAO injected?
               Guice.createInjector(module)
        }
}


I'm just not sure the above would work out ok?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to