You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by Brian Eaton <be...@google.com> on 2008/03/28 21:04:07 UTC

oauth dependency injection

There are a couple of patterns I could use to give OAuthFetcher a
reference to a persistent data store.  They all seem to work equally
well.  Let me know if you've got a preference.

Option 1: CrossServletState (superseded by Guice real soon now...)
- CrossServletState gets a reference to a single GadgetTokenStore object
- CrossServletState provides a factory method to create OAuthFetcher
objects, passing in the GadgetTokenStore
- subclasses of CrossServletState implement their own factory methods
that pass in the token store.

Option 2: OAuthFetcher subclasses provide persistence
- OAuthFetcher gets a protected method getGadgetTokenStore that
returns a reference to a single GadgetTokenStore object
- subclasses of OAuthFetcher return their own GadgetTokenStore
implementatino instead.

Cheers,
Brian

Re: oauth dependency injection

Posted by Kevin Brown <et...@google.com>.
On Fri, Mar 28, 2008 at 1:04 PM, Brian Eaton <be...@google.com> wrote:

> There are a couple of patterns I could use to give OAuthFetcher a
> reference to a persistent data store.  They all seem to work equally
> well.  Let me know if you've got a preference.
>
> Option 1: CrossServletState (superseded by Guice real soon now...)
> - CrossServletState gets a reference to a single GadgetTokenStore object
> - CrossServletState provides a factory method to create OAuthFetcher
> objects, passing in the GadgetTokenStore
> - subclasses of CrossServletState implement their own factory methods
> that pass in the token store.
>
> Option 2: OAuthFetcher subclasses provide persistence
> - OAuthFetcher gets a protected method getGadgetTokenStore that
> returns a reference to a single GadgetTokenStore object
> - subclasses of OAuthFetcher return their own GadgetTokenStore
> implementatino instead.
>
> Cheers,
> Brian
>

The right model is probably to have guice create the persistence store and
have that injected into whatever creates the OAuthFetcher (either the
ProxyHandler itself, or some new factory). That's what I've done with all
the other things that were formerly a part of CrossServletState.


-- 
~Kevin