You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by Cassie <do...@google.com> on 2008/04/09 13:53:37 UTC

Re: svn commit: r645947 - in /incubator/shindig/trunk/java/gadgets/src/main: java/org/apache/shindig/gadgets/ java/org/apache/shindig/social/ java/org/apache/shindig/social/opensocial/ webapp/WEB-INF/

What we should really do is split the social and gadgets servers into
two. One server/url path for all gadgets stuff, one server/url path
for the social data and restful api stuff. When we do that we can fix
all of the dependecies between the two. Right now though, the social
code is dependant on a lot of the gadgets code, and there is only one
server.. so everyone was pulling it in anyway.

Let's fix the root problem.

I don't have any time to code it up right at the moment because I'm in
Amsterdam at ApacheCon, but perhaps someone out there can make a
patch? The social code isn't moving very much at the moment, so no one
has to worry about breaking too many in progress changes. Perhaps you
have some time Kevin?

- Cassie



On Wed, Apr 9, 2008 at 9:10 AM, Kevin Brown <et...@google.com> wrote:
> That's what I was asking for as well. It is definitely the intent that
>  DefaultGuiceModule be used primarily for injected things that will almost
>  never need to be changed between implementations. I also have a preference
>  for keeping the bindings as close to the package that they're declared in as
>  well.
>
>  I'm not sure about not being able to re-bind though. If that's true, then
>  you're right and making it a separate module is indeed the only clean way to
>  make this work. If someone were to be using Guice by pulling in release jars
>  (say, from maven), they'd have no choice but to re-implement all of
>  HttpGuiceModule & DefaultGuiceModule by hand, even if they're only trying to
>  provide custom opensocial data handlers.
>
>
>
>  On Wed, Apr 9, 2008 at 1:03 AM, Ian Boston <ie...@tfd.co.uk> wrote:
>
>  > Can we have one module that has just the services in it please.....
>  >
>  > as I understand it Guice 1.0 doesnt have re-bind capabilities, so if the
>  > services are in a core module, then an implementor, will have to replicate
>  > the implementation of the opensocial core module, rather than just creating
>  > a module to define the service bindings.
>  >
>  > (all said as a Guice beginner :) )
>  > Ian
>  >
>  >
>  >
>  > Ian
>  >
>  >
>  >
>  >
>  > On 8 Apr 2008, at 18:21, Kevin Brown wrote:
>  >
>  > > You should be providing a separate guice module for social stuff. It
>  > > doesn't
>  > > make sense to be creating all these social bindings for people who
>  > > aren't
>  > > using the social stuff at all yet (and it really doesn't make sense for
>  > > shindig.gadgets to be referencing stuff in shindig.social).
>  > >
>  > > The module loader already allows multiple modules to be converted to a
>  > > single injector; just add yours separated with a colon.
>  > >
>  > > On Tue, Apr 8, 2008 at 7:42 AM, <do...@apache.org> wrote:
>  > >
>  > >  Author: doll
>  > > > Date: Tue Apr  8 07:42:54 2008
>  > > > New Revision: 645947
>  > > >
>  > > > URL: http://svn.apache.org/viewvc?rev=645947&view=rev
>  > > > Log:
>  > > > The social data classes now use guice to get all of their
>  > > > dependencies.
>  > > >
>  > > > Modified:
>  > > >
>  > > >
>  > > >  incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/DefaultGuiceModule.java
>  > > >
>  > > >
>  > > >  incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/social/GadgetDataServlet.java
>  > > >
>  > > >
>  > > >  incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/social/opensocial/OpenSocialDataHandler.java
>  > > >   incubator/shindig/trunk/java/gadgets/src/main/webapp/WEB-INF/web.xml
>  > > >
>  > > > Modified:
>  > > >
>  > > > incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/DefaultGuiceModule.java
>  > > > URL:
>  > > > http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/
>  > > > src/main/java/org/apache/shindig/gadgets/DefaultGuiceModule.java?rev=645947&r1=645946&r2=645947&view=diff
>  > > >
>  > > >
>  > > > ==============================================================================
>  > > > ---
>  > > >
>  > > > incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/DefaultGuiceModule.java
>  > > > (original)
>  > > > +++
>  > > >
>  > > > incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/DefaultGuiceModule.java
>  > > > Tue Apr  8 07:42:54 2008
>  > > > @@ -18,18 +18,31 @@
>  > > >  */
>  > > >  package org.apache.shindig.gadgets;
>  > > >
>  > > > -import org.apache.shindig.gadgets.oauth.OAuthFetcherFactory;
>  > > > -import org.apache.shindig.util.ResourceLoader;
>  > > > -
>  > > >  import com.google.inject.AbstractModule;
>  > > >  import com.google.inject.CreationException;
>  > > > +import com.google.inject.Inject;
>  > > > +import com.google.inject.Provider;
>  > > >  import com.google.inject.Scopes;
>  > > > +import com.google.inject.TypeLiteral;
>  > > >  import com.google.inject.name.Names;
>  > > >  import com.google.inject.spi.Message;
>  > > > +import org.apache.shindig.gadgets.oauth.OAuthFetcherFactory;
>  > > > +import org.apache.shindig.social.GadgetDataHandler;
>  > > > +import org.apache.shindig.social.opensocial.ActivitiesService;
>  > > > +import org.apache.shindig.social.opensocial.DataService;
>  > > > +import org.apache.shindig.social.opensocial.OpenSocialDataHandler;
>  > > > +import org.apache.shindig.social.opensocial.PeopleService;
>  > > > +import
>  > > > org.apache.shindig.social.samplecontainer.BasicActivitiesService;
>  > > > +import org.apache.shindig.social.samplecontainer.BasicDataService;
>  > > > +import org.apache.shindig.social.samplecontainer.BasicPeopleService;
>  > > > +import
>  > > > org.apache.shindig.social.samplecontainer.StateFileDataHandler;
>  > > > +import org.apache.shindig.util.ResourceLoader;
>  > > >
>  > > >  import java.io.IOException;
>  > > >  import java.io.InputStream;
>  > > > +import java.util.ArrayList;
>  > > >  import java.util.Arrays;
>  > > > +import java.util.List;
>  > > >  import java.util.Properties;
>  > > >  import java.util.concurrent.Executor;
>  > > >  import java.util.concurrent.Executors;
>  > > > @@ -64,6 +77,15 @@
>  > > >    bind(SyndicatorConfig.class).in(Scopes.SINGLETON);
>  > > >    bind(GadgetFeatureRegistry.class).in(Scopes.SINGLETON);
>  > > >    bind(GadgetServer.class).in(Scopes.SINGLETON);
>  > > > +
>  > > > +    // Social guice
>  > > > +    bind(PeopleService.class).to(BasicPeopleService.class);
>  > > > +    bind(DataService.class).to(BasicDataService.class);
>  > > > +    bind(ActivitiesService.class).to(BasicActivitiesService.class);
>  > > > +
>  > > > +    bind(new TypeLiteral<List<GadgetDataHandler>>() {})
>  > > > +        .toProvider(GadgetDataHandlersProvider.class);
>  > > > +
>  > > >  }
>  > > >
>  > > >  public DefaultGuiceModule(Properties properties) {
>  > > > @@ -84,5 +106,22 @@
>  > > >          new Message("Unable to load properties: " +
>  > > > DEFAULT_PROPERTIES)));
>  > > >    }
>  > > >    this.properties = properties;
>  > > > +  }
>  > > > +
>  > > > +  public static class GadgetDataHandlersProvider
>  > > > +      implements Provider<List<GadgetDataHandler>> {
>  > > > +    List<GadgetDataHandler> handlers;
>  > > > +
>  > > > +    @Inject
>  > > > +    public GadgetDataHandlersProvider(OpenSocialDataHandler
>  > > > +        openSocialDataHandler, StateFileDataHandler stateFileHandler)
>  > > > {
>  > > > +      handlers = new ArrayList<GadgetDataHandler>();
>  > > > +      handlers.add(openSocialDataHandler);
>  > > > +      handlers.add(stateFileHandler);
>  > > > +    }
>  > > > +
>  > > > +    public List<GadgetDataHandler> get() {
>  > > > +      return handlers;
>  > > > +    }
>  > > >  }
>  > > >  }
>  > > >
>  > > > Modified:
>  > > >
>  > > > incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/social/GadgetDataServlet.java
>  > > > URL:
>  > > > http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/
>  > > > src/main/java/org/apache/shindig/social/GadgetDataServlet.java?rev=645947&r1=645946&r2=645947&view=diff
>  > > >
>  > > >
>  > > > ==============================================================================
>  > > > ---
>  > > >
>  > > > incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/social/GadgetDataServlet.java
>  > > > (original)
>  > > > +++
>  > > >
>  > > > incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/social/GadgetDataServlet.java
>  > > > Tue Apr  8 07:42:54 2008
>  > > > @@ -17,30 +17,23 @@
>  > > >  */
>  > > >  package org.apache.shindig.social;
>  > > >
>  > > > +import com.google.inject.Inject;
>  > > >  import org.apache.shindig.gadgets.GadgetException;
>  > > >  import org.apache.shindig.gadgets.GadgetToken;
>  > > >  import org.apache.shindig.gadgets.GadgetTokenDecoder;
>  > > >  import org.apache.shindig.gadgets.http.InjectedServlet;
>  > > > -import org.apache.shindig.social.opensocial.OpenSocialDataHandler;
>  > > > -import
>  > > > org.apache.shindig.social.samplecontainer.StateFileDataHandler;
>  > > > -
>  > > > -import com.google.inject.Inject;
>  > > > -
>  > > >  import org.json.JSONArray;
>  > > >  import org.json.JSONException;
>  > > >  import org.json.JSONObject;
>  > > >
>  > > > +import javax.servlet.http.HttpServletRequest;
>  > > > +import javax.servlet.http.HttpServletResponse;
>  > > >  import java.io.IOException;
>  > > >  import java.io.PrintWriter;
>  > > >  import java.util.ArrayList;
>  > > >  import java.util.List;
>  > > >  import java.util.logging.Logger;
>  > > >
>  > > > -import javax.servlet.ServletConfig;
>  > > > -import javax.servlet.ServletException;
>  > > > -import javax.servlet.http.HttpServletRequest;
>  > > > -import javax.servlet.http.HttpServletResponse;
>  > > > -
>  > > >  /**
>  > > >  * Servlet for handling gadget requests for data. The request accepts
>  > > > one
>  > > > json
>  > > >  * parameter of the format:
>  > > > @@ -61,37 +54,17 @@
>  > > >  private static final Logger logger
>  > > >      = Logger.getLogger("org.apache.shindig.social");
>  > > >
>  > > > -  // TODO: get through injection
>  > > > -  private static final List<GadgetDataHandler> handlers
>  > > > -      = new ArrayList<GadgetDataHandler>();
>  > > > -
>  > > > -
>  > > > +  private List<GadgetDataHandler> handlers;
>  > > >  private GadgetTokenDecoder gadgetTokenDecoder;
>  > > >
>  > > >  @Inject
>  > > > -  public void setGadgetTokenDecoder(GadgetTokenDecoder
>  > > > gadgetTokenDecoder) {
>  > > > -   this.gadgetTokenDecoder = gadgetTokenDecoder;
>  > > > +  public void setGadgetDataHandlers(List<GadgetDataHandler> handlers)
>  > > > {
>  > > > +    this.handlers = handlers;
>  > > >  }
>  > > >
>  > > > -  @Override
>  > > > -  public void init(ServletConfig config) throws ServletException {
>  > > > -    super.init(config);
>  > > > -
>  > > > -    String handlerNames = config.getInitParameter("handlers");
>  > > > -    if (handlerNames == null) {
>  > > > -      handlers.add(new OpenSocialDataHandler());
>  > > > -      handlers.add(new StateFileDataHandler());
>  > > > -    } else {
>  > > > -      for (String handlerName : handlerNames.split(",")) {
>  > > > -        try {
>  > > > -          GadgetDataHandler handler
>  > > > -              = (GadgetDataHandler)
>  > > > (Class.forName(handlerName)).newInstance();
>  > > > -          handlers.add(handler);
>  > > > -        } catch (Exception ex) {
>  > > > -          throw new ServletException(ex);
>  > > > -        }
>  > > > -      }
>  > > > -    }
>  > > > +  @Inject
>  > > > +  public void setGadgetTokenDecoder(GadgetTokenDecoder
>  > > > gadgetTokenDecoder) {
>  > > > +    this.gadgetTokenDecoder = gadgetTokenDecoder;
>  > > >  }
>  > > >
>  > > >  @Override
>  > > >
>  > > > Modified:
>  > > >
>  > > > incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/social/opensocial/OpenSocialDataHandler.java
>  > > > URL:
>  > > > http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/
>  > > > src/main/java/org/apache/shindig/social/opensocial/OpenSocialDataHandler.java?rev=645947&r1=645946&r2=645947&view=diff
>  > > >
>  > > >
>  > > > ==============================================================================
>  > > > ---
>  > > >
>  > > > incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/social/opensocial/OpenSocialDataHandler.java
>  > > > (original)
>  > > > +++
>  > > >
>  > > > incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/social/opensocial/OpenSocialDataHandler.java
>  > > > Tue Apr  8 07:42:54 2008
>  > > > @@ -38,6 +38,8 @@
>  > > >  import java.util.logging.Level;
>  > > >  import java.util.logging.Logger;
>  > > >
>  > > > +import com.google.inject.Inject;
>  > > > +
>  > > >  /**
>  > > >  * Servlet for serving the data required for opensocial.
>  > > >  * This will expand to be more sophisticated as time goes on.
>  > > > @@ -46,11 +48,17 @@
>  > > >  private static final Logger logger
>  > > >      = Logger.getLogger("org.apache.shindig.social");
>  > > >
>  > > > -  // TODO: get through injection
>  > > > -  private static PeopleService peopleHandler = new
>  > > > BasicPeopleService();
>  > > > -  private static DataService dataHandler = new BasicDataService();
>  > > > -  private static ActivitiesService activitiesHandler
>  > > > -      = new BasicActivitiesService();
>  > > > +  private PeopleService peopleHandler;
>  > > > +  private DataService dataHandler;
>  > > > +  private ActivitiesService activitiesHandler;
>  > > > +
>  > > > +  @Inject
>  > > > +  public OpenSocialDataHandler(PeopleService peopleHandler,
>  > > > +      DataService dataHandler, ActivitiesService activitiesHandler) {
>  > > > +    this.peopleHandler = peopleHandler;
>  > > > +    this.dataHandler = dataHandler;
>  > > > +    this.activitiesHandler = activitiesHandler;
>  > > > +  }
>  > > >
>  > > >  public enum OpenSocialDataType {
>  > > >    FETCH_PEOPLE,
>  > > >
>  > > > Modified:
>  > > > incubator/shindig/trunk/java/gadgets/src/main/webapp/WEB-INF/web.xml
>  > > > URL:
>  > > > http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/
>  > > > src/main/webapp/WEB-INF/web.xml?rev=645947&r1=645946&r2=645947&view=diff
>  > > >
>  > > >
>  > > > ==============================================================================
>  > > > ---
>  > > > incubator/shindig/trunk/java/gadgets/src/main/webapp/WEB-INF/web.xml
>  > > > (original)
>  > > > +++
>  > > > incubator/shindig/trunk/java/gadgets/src/main/webapp/WEB-INF/web.xml
>  > > > Tue Apr  8 07:42:54 2008
>  > > > @@ -63,13 +63,6 @@
>  > > >    <servlet-class>
>  > > >      org.apache.shindig.social.GadgetDataServlet
>  > > >    </servlet-class>
>  > > > -<!--
>  > > > -    <init-param>
>  > > > -      Add your custom classes that handle opensocial requests here
>  > > > -      <param-name>handlers</param-name>
>  > > > -      <parame-value>com.muysite.OpenSocialDataHandler</param-value>
>  > > > -    </init-param>
>  > > > --->
>  > > >  </servlet>
>  > > >
>  > > >  <!-- javascript serving -->
>  > > >
>  > > >
>  > > >
>  > > >
>  > >
>  > > --
>  > > ~Kevin
>  > >
>  >
>  >
>
>
>  --
>  ~Kevin
>

Re: svn commit: r645947 - in /incubator/shindig/trunk/java/gadgets/src/main: java/org/apache/shindig/gadgets/ java/org/apache/shindig/social/ java/org/apache/shindig/social/opensocial/ webapp/WEB-INF/

Posted by Kevin Brown <et...@google.com>.
You don't have to split the dependencies here to facilitate allowing
injection of just the opensocial bits. In the long run, very few people will
ever have to change the classes used by the gadget renderer, but almost
everyone will have to swap in a different implementation of the data
handlers. A separate module is a simple solution for this.

I agree that in the long term we need to do the 3 component breakup that
we've discussed, but that's a separate issue.

On Wed, Apr 9, 2008 at 4:53 AM, Cassie <do...@google.com> wrote:

> What we should really do is split the social and gadgets servers into
> two. One server/url path for all gadgets stuff, one server/url path
> for the social data and restful api stuff. When we do that we can fix
> all of the dependecies between the two. Right now though, the social
> code is dependant on a lot of the gadgets code, and there is only one
> server.. so everyone was pulling it in anyway.
>
> Let's fix the root problem.
>
> I don't have any time to code it up right at the moment because I'm in
> Amsterdam at ApacheCon, but perhaps someone out there can make a
> patch? The social code isn't moving very much at the moment, so no one
> has to worry about breaking too many in progress changes. Perhaps you
> have some time Kevin?
>
> - Cassie
>
>
>
> On Wed, Apr 9, 2008 at 9:10 AM, Kevin Brown <et...@google.com> wrote:
> > That's what I was asking for as well. It is definitely the intent that
> >  DefaultGuiceModule be used primarily for injected things that will
> almost
> >  never need to be changed between implementations. I also have a
> preference
> >  for keeping the bindings as close to the package that they're declared
> in as
> >  well.
> >
> >  I'm not sure about not being able to re-bind though. If that's true,
> then
> >  you're right and making it a separate module is indeed the only clean
> way to
> >  make this work. If someone were to be using Guice by pulling in release
> jars
> >  (say, from maven), they'd have no choice but to re-implement all of
> >  HttpGuiceModule & DefaultGuiceModule by hand, even if they're only
> trying to
> >  provide custom opensocial data handlers.
> >
> >
> >
> >  On Wed, Apr 9, 2008 at 1:03 AM, Ian Boston <ie...@tfd.co.uk> wrote:
> >
> >  > Can we have one module that has just the services in it please.....
> >  >
> >  > as I understand it Guice 1.0 doesnt have re-bind capabilities, so if
> the
> >  > services are in a core module, then an implementor, will have to
> replicate
> >  > the implementation of the opensocial core module, rather than just
> creating
> >  > a module to define the service bindings.
> >  >
> >  > (all said as a Guice beginner :) )
> >  > Ian
> >  >
> >  >
> >  >
> >  > Ian
> >  >
> >  >
> >  >
> >  >
> >  > On 8 Apr 2008, at 18:21, Kevin Brown wrote:
> >  >
> >  > > You should be providing a separate guice module for social stuff.
> It
> >  > > doesn't
> >  > > make sense to be creating all these social bindings for people who
> >  > > aren't
> >  > > using the social stuff at all yet (and it really doesn't make sense
> for
> >  > > shindig.gadgets to be referencing stuff in shindig.social).
> >  > >
> >  > > The module loader already allows multiple modules to be converted
> to a
> >  > > single injector; just add yours separated with a colon.
> >  > >
> >  > > On Tue, Apr 8, 2008 at 7:42 AM, <do...@apache.org> wrote:
> >  > >
> >  > >  Author: doll
> >  > > > Date: Tue Apr  8 07:42:54 2008
> >  > > > New Revision: 645947
> >  > > >
> >  > > > URL: http://svn.apache.org/viewvc?rev=645947&view=rev
> >  > > > Log:
> >  > > > The social data classes now use guice to get all of their
> >  > > > dependencies.
> >  > > >
> >  > > > Modified:
> >  > > >
> >  > > >
> >  > > >
>  incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/DefaultGuiceModule.java
> >  > > >
> >  > > >
> >  > > >
>  incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/social/GadgetDataServlet.java
> >  > > >
> >  > > >
> >  > > >
>  incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/social/opensocial/OpenSocialDataHandler.java
> >  > > >
> incubator/shindig/trunk/java/gadgets/src/main/webapp/WEB-INF/web.xml
> >  > > >
> >  > > > Modified:
> >  > > >
> >  > > >
> incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/DefaultGuiceModule.java
> >  > > > URL:
> >  > > >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/
> >  > > >
> src/main/java/org/apache/shindig/gadgets/DefaultGuiceModule.java?rev=645947&r1=645946&r2=645947&view=diff
> >  > > >
> >  > > >
> >  > > >
> ==============================================================================
> >  > > > ---
> >  > > >
> >  > > >
> incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/DefaultGuiceModule.java
> >  > > > (original)
> >  > > > +++
> >  > > >
> >  > > >
> incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/DefaultGuiceModule.java
> >  > > > Tue Apr  8 07:42:54 2008
> >  > > > @@ -18,18 +18,31 @@
> >  > > >  */
> >  > > >  package org.apache.shindig.gadgets;
> >  > > >
> >  > > > -import org.apache.shindig.gadgets.oauth.OAuthFetcherFactory;
> >  > > > -import org.apache.shindig.util.ResourceLoader;
> >  > > > -
> >  > > >  import com.google.inject.AbstractModule;
> >  > > >  import com.google.inject.CreationException;
> >  > > > +import com.google.inject.Inject;
> >  > > > +import com.google.inject.Provider;
> >  > > >  import com.google.inject.Scopes;
> >  > > > +import com.google.inject.TypeLiteral;
> >  > > >  import com.google.inject.name.Names;
> >  > > >  import com.google.inject.spi.Message;
> >  > > > +import org.apache.shindig.gadgets.oauth.OAuthFetcherFactory;
> >  > > > +import org.apache.shindig.social.GadgetDataHandler;
> >  > > > +import org.apache.shindig.social.opensocial.ActivitiesService;
> >  > > > +import org.apache.shindig.social.opensocial.DataService;
> >  > > > +import
> org.apache.shindig.social.opensocial.OpenSocialDataHandler;
> >  > > > +import org.apache.shindig.social.opensocial.PeopleService;
> >  > > > +import
> >  > > > org.apache.shindig.social.samplecontainer.BasicActivitiesService;
> >  > > > +import
> org.apache.shindig.social.samplecontainer.BasicDataService;
> >  > > > +import
> org.apache.shindig.social.samplecontainer.BasicPeopleService;
> >  > > > +import
> >  > > > org.apache.shindig.social.samplecontainer.StateFileDataHandler;
> >  > > > +import org.apache.shindig.util.ResourceLoader;
> >  > > >
> >  > > >  import java.io.IOException;
> >  > > >  import java.io.InputStream;
> >  > > > +import java.util.ArrayList;
> >  > > >  import java.util.Arrays;
> >  > > > +import java.util.List;
> >  > > >  import java.util.Properties;
> >  > > >  import java.util.concurrent.Executor;
> >  > > >  import java.util.concurrent.Executors;
> >  > > > @@ -64,6 +77,15 @@
> >  > > >    bind(SyndicatorConfig.class).in(Scopes.SINGLETON);
> >  > > >    bind(GadgetFeatureRegistry.class).in(Scopes.SINGLETON);
> >  > > >    bind(GadgetServer.class).in(Scopes.SINGLETON);
> >  > > > +
> >  > > > +    // Social guice
> >  > > > +    bind(PeopleService.class).to(BasicPeopleService.class);
> >  > > > +    bind(DataService.class).to(BasicDataService.class);
> >  > > > +
>  bind(ActivitiesService.class).to(BasicActivitiesService.class);
> >  > > > +
> >  > > > +    bind(new TypeLiteral<List<GadgetDataHandler>>() {})
> >  > > > +        .toProvider(GadgetDataHandlersProvider.class);
> >  > > > +
> >  > > >  }
> >  > > >
> >  > > >  public DefaultGuiceModule(Properties properties) {
> >  > > > @@ -84,5 +106,22 @@
> >  > > >          new Message("Unable to load properties: " +
> >  > > > DEFAULT_PROPERTIES)));
> >  > > >    }
> >  > > >    this.properties = properties;
> >  > > > +  }
> >  > > > +
> >  > > > +  public static class GadgetDataHandlersProvider
> >  > > > +      implements Provider<List<GadgetDataHandler>> {
> >  > > > +    List<GadgetDataHandler> handlers;
> >  > > > +
> >  > > > +    @Inject
> >  > > > +    public GadgetDataHandlersProvider(OpenSocialDataHandler
> >  > > > +        openSocialDataHandler, StateFileDataHandler
> stateFileHandler)
> >  > > > {
> >  > > > +      handlers = new ArrayList<GadgetDataHandler>();
> >  > > > +      handlers.add(openSocialDataHandler);
> >  > > > +      handlers.add(stateFileHandler);
> >  > > > +    }
> >  > > > +
> >  > > > +    public List<GadgetDataHandler> get() {
> >  > > > +      return handlers;
> >  > > > +    }
> >  > > >  }
> >  > > >  }
> >  > > >
> >  > > > Modified:
> >  > > >
> >  > > >
> incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/social/GadgetDataServlet.java
> >  > > > URL:
> >  > > >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/
> >  > > >
> src/main/java/org/apache/shindig/social/GadgetDataServlet.java?rev=645947&r1=645946&r2=645947&view=diff
> >  > > >
> >  > > >
> >  > > >
> ==============================================================================
> >  > > > ---
> >  > > >
> >  > > >
> incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/social/GadgetDataServlet.java
> >  > > > (original)
> >  > > > +++
> >  > > >
> >  > > >
> incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/social/GadgetDataServlet.java
> >  > > > Tue Apr  8 07:42:54 2008
> >  > > > @@ -17,30 +17,23 @@
> >  > > >  */
> >  > > >  package org.apache.shindig.social;
> >  > > >
> >  > > > +import com.google.inject.Inject;
> >  > > >  import org.apache.shindig.gadgets.GadgetException;
> >  > > >  import org.apache.shindig.gadgets.GadgetToken;
> >  > > >  import org.apache.shindig.gadgets.GadgetTokenDecoder;
> >  > > >  import org.apache.shindig.gadgets.http.InjectedServlet;
> >  > > > -import
> org.apache.shindig.social.opensocial.OpenSocialDataHandler;
> >  > > > -import
> >  > > > org.apache.shindig.social.samplecontainer.StateFileDataHandler;
> >  > > > -
> >  > > > -import com.google.inject.Inject;
> >  > > > -
> >  > > >  import org.json.JSONArray;
> >  > > >  import org.json.JSONException;
> >  > > >  import org.json.JSONObject;
> >  > > >
> >  > > > +import javax.servlet.http.HttpServletRequest;
> >  > > > +import javax.servlet.http.HttpServletResponse;
> >  > > >  import java.io.IOException;
> >  > > >  import java.io.PrintWriter;
> >  > > >  import java.util.ArrayList;
> >  > > >  import java.util.List;
> >  > > >  import java.util.logging.Logger;
> >  > > >
> >  > > > -import javax.servlet.ServletConfig;
> >  > > > -import javax.servlet.ServletException;
> >  > > > -import javax.servlet.http.HttpServletRequest;
> >  > > > -import javax.servlet.http.HttpServletResponse;
> >  > > > -
> >  > > >  /**
> >  > > >  * Servlet for handling gadget requests for data. The request
> accepts
> >  > > > one
> >  > > > json
> >  > > >  * parameter of the format:
> >  > > > @@ -61,37 +54,17 @@
> >  > > >  private static final Logger logger
> >  > > >      = Logger.getLogger("org.apache.shindig.social");
> >  > > >
> >  > > > -  // TODO: get through injection
> >  > > > -  private static final List<GadgetDataHandler> handlers
> >  > > > -      = new ArrayList<GadgetDataHandler>();
> >  > > > -
> >  > > > -
> >  > > > +  private List<GadgetDataHandler> handlers;
> >  > > >  private GadgetTokenDecoder gadgetTokenDecoder;
> >  > > >
> >  > > >  @Inject
> >  > > > -  public void setGadgetTokenDecoder(GadgetTokenDecoder
> >  > > > gadgetTokenDecoder) {
> >  > > > -   this.gadgetTokenDecoder = gadgetTokenDecoder;
> >  > > > +  public void setGadgetDataHandlers(List<GadgetDataHandler>
> handlers)
> >  > > > {
> >  > > > +    this.handlers = handlers;
> >  > > >  }
> >  > > >
> >  > > > -  @Override
> >  > > > -  public void init(ServletConfig config) throws ServletException
> {
> >  > > > -    super.init(config);
> >  > > > -
> >  > > > -    String handlerNames = config.getInitParameter("handlers");
> >  > > > -    if (handlerNames == null) {
> >  > > > -      handlers.add(new OpenSocialDataHandler());
> >  > > > -      handlers.add(new StateFileDataHandler());
> >  > > > -    } else {
> >  > > > -      for (String handlerName : handlerNames.split(",")) {
> >  > > > -        try {
> >  > > > -          GadgetDataHandler handler
> >  > > > -              = (GadgetDataHandler)
> >  > > > (Class.forName(handlerName)).newInstance();
> >  > > > -          handlers.add(handler);
> >  > > > -        } catch (Exception ex) {
> >  > > > -          throw new ServletException(ex);
> >  > > > -        }
> >  > > > -      }
> >  > > > -    }
> >  > > > +  @Inject
> >  > > > +  public void setGadgetTokenDecoder(GadgetTokenDecoder
> >  > > > gadgetTokenDecoder) {
> >  > > > +    this.gadgetTokenDecoder = gadgetTokenDecoder;
> >  > > >  }
> >  > > >
> >  > > >  @Override
> >  > > >
> >  > > > Modified:
> >  > > >
> >  > > >
> incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/social/opensocial/OpenSocialDataHandler.java
> >  > > > URL:
> >  > > >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/
> >  > > >
> src/main/java/org/apache/shindig/social/opensocial/OpenSocialDataHandler.java?rev=645947&r1=645946&r2=645947&view=diff
> >  > > >
> >  > > >
> >  > > >
> ==============================================================================
> >  > > > ---
> >  > > >
> >  > > >
> incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/social/opensocial/OpenSocialDataHandler.java
> >  > > > (original)
> >  > > > +++
> >  > > >
> >  > > >
> incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/social/opensocial/OpenSocialDataHandler.java
> >  > > > Tue Apr  8 07:42:54 2008
> >  > > > @@ -38,6 +38,8 @@
> >  > > >  import java.util.logging.Level;
> >  > > >  import java.util.logging.Logger;
> >  > > >
> >  > > > +import com.google.inject.Inject;
> >  > > > +
> >  > > >  /**
> >  > > >  * Servlet for serving the data required for opensocial.
> >  > > >  * This will expand to be more sophisticated as time goes on.
> >  > > > @@ -46,11 +48,17 @@
> >  > > >  private static final Logger logger
> >  > > >      = Logger.getLogger("org.apache.shindig.social");
> >  > > >
> >  > > > -  // TODO: get through injection
> >  > > > -  private static PeopleService peopleHandler = new
> >  > > > BasicPeopleService();
> >  > > > -  private static DataService dataHandler = new
> BasicDataService();
> >  > > > -  private static ActivitiesService activitiesHandler
> >  > > > -      = new BasicActivitiesService();
> >  > > > +  private PeopleService peopleHandler;
> >  > > > +  private DataService dataHandler;
> >  > > > +  private ActivitiesService activitiesHandler;
> >  > > > +
> >  > > > +  @Inject
> >  > > > +  public OpenSocialDataHandler(PeopleService peopleHandler,
> >  > > > +      DataService dataHandler, ActivitiesService
> activitiesHandler) {
> >  > > > +    this.peopleHandler = peopleHandler;
> >  > > > +    this.dataHandler = dataHandler;
> >  > > > +    this.activitiesHandler = activitiesHandler;
> >  > > > +  }
> >  > > >
> >  > > >  public enum OpenSocialDataType {
> >  > > >    FETCH_PEOPLE,
> >  > > >
> >  > > > Modified:
> >  > > >
> incubator/shindig/trunk/java/gadgets/src/main/webapp/WEB-INF/web.xml
> >  > > > URL:
> >  > > >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/
> >  > > >
> src/main/webapp/WEB-INF/web.xml?rev=645947&r1=645946&r2=645947&view=diff
> >  > > >
> >  > > >
> >  > > >
> ==============================================================================
> >  > > > ---
> >  > > >
> incubator/shindig/trunk/java/gadgets/src/main/webapp/WEB-INF/web.xml
> >  > > > (original)
> >  > > > +++
> >  > > >
> incubator/shindig/trunk/java/gadgets/src/main/webapp/WEB-INF/web.xml
> >  > > > Tue Apr  8 07:42:54 2008
> >  > > > @@ -63,13 +63,6 @@
> >  > > >    <servlet-class>
> >  > > >      org.apache.shindig.social.GadgetDataServlet
> >  > > >    </servlet-class>
> >  > > > -<!--
> >  > > > -    <init-param>
> >  > > > -      Add your custom classes that handle opensocial requests
> here
> >  > > > -      <param-name>handlers</param-name>
> >  > > > -
>  <parame-value>com.muysite.OpenSocialDataHandler</param-value>
> >  > > > -    </init-param>
> >  > > > --->
> >  > > >  </servlet>
> >  > > >
> >  > > >  <!-- javascript serving -->
> >  > > >
> >  > > >
> >  > > >
> >  > > >
> >  > >
> >  > > --
> >  > > ~Kevin
> >  > >
> >  >
> >  >
> >
> >
> >  --
> >  ~Kevin
> >
>



-- 
~Kevin