Stateless (Flyweight) and current user

Adam Young ayoung at redhat.com
Thu Apr 1 16:54:15 UTC 2010


Regarding this:


  // FIXME Why is this in here?
         if (username != null) {
             this.owner = ownerCurator.lookupByName(username);
             if (owner == null) {
                 owner = ownerCurator.create(new Owner(username));
             }
         }


I think I can answer that question.  All of the other objects injected 
into the ConsumerResource are globally named objects.  Username comes 
from the request, and is resolvable from there.  To get the right  
owner, you bascially have to do the lookup specified in the constructor.

If I understand Guice correctly, we need to register a means of doing 
this lookup that would look something like this:

class OwnerFactory{
     public OwnerFactory(User u, OwnerCurator curator){
     }

     Owner fetch(){
         curator.findByUser(u);
     }
}






More information about the candlepin mailing list