For completeness, Here is the patch, cut and paste, but I would be
happy to wait...
sorry for the long post.
<PATCH>
Index: java/gadgets/conf/opensocial.properties
===================================================================
Property changes on: java/gadgets/conf/opensocial.properties
___________________________________________________________________
Name: svn:eol-style
+ native
Index:
java/gadgets/src/main/java/org/apache/shindig/social/opensocial/OpenSocialDataHandler.java
===================================================================
---
java/gadgets/src/main/java/org/apache/shindig/social/opensocial/OpenSocialDataHandler.java
(revision 644317)
+++
java/gadgets/src/main/java/org/apache/shindig/social/opensocial/OpenSocialDataHandler.java
(working copy)
@@ -17,26 +17,24 @@
*/
package org.apache.shindig.social.opensocial;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
import org.apache.shindig.social.GadgetDataHandler;
import org.apache.shindig.social.RequestItem;
import org.apache.shindig.social.ResponseError;
import org.apache.shindig.social.ResponseItem;
import org.apache.shindig.social.opensocial.model.Activity;
import org.apache.shindig.social.opensocial.model.IdSpec;
-import org.apache.shindig.social.samplecontainer.BasicActivitiesService;
-import org.apache.shindig.social.samplecontainer.BasicDataService;
-import org.apache.shindig.social.samplecontainer.BasicPeopleService;
-
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+import com.google.inject.Inject;
/**
* Servlet for serving the data required for opensocial.
@@ -47,10 +45,20 @@
= 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();
+ */
+ @Inject
+ private PeopleService peopleHandler;
+
+ @Inject
+ private DataService dataHandler;
+
+ @Inject
+ private ActivitiesService activitiesHandler;
public enum OpenSocialDataType {
FETCH_PEOPLE,
Index:
java/gadgets/src/main/java/org/apache/shindig/social/opensocial/DeafultServiceModule.java
===================================================================
---
java/gadgets/src/main/java/org/apache/shindig/social/opensocial/DeafultServiceModule.java
(revision 0)
+++
java/gadgets/src/main/java/org/apache/shindig/social/opensocial/DeafultServiceModule.java
(revision 0)
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+package org.apache.shindig.social.opensocial;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.Properties;
+
+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.util.ResourceLoader;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.CreationException;
+import com.google.inject.Scopes;
+import com.google.inject.name.Names;
+import com.google.inject.spi.Message;
+
+/**
+ * @author ieb
+ */
+public class DeafultServiceModule extends AbstractModule
+{
+ private final Properties properties;
+
+ private final static String DEFAULT_PROPERTIES =
"opensocial.properties";
+
+ public DeafultServiceModule(Properties properties)
+ {
+ this.properties = properties;
+ }
+
+ /**
+ * Creates module with standard properties.
+ */
+ public DeafultServiceModule()
+ {
+ Properties properties = null;
+ try
+ {
+ InputStream is =
ResourceLoader.openResource(DEFAULT_PROPERTIES);
+ properties = new Properties();
+ properties.load(is);
+ }
+ catch (IOException e)
+ {
+
+ throw new CreationException(Arrays.asList(new Message(
+ "Unable to load properties: "
+ DEFAULT_PROPERTIES)));
+ }
+ this.properties = properties;
+ }
+
+ /** [EMAIL PROTECTED] */
+ @Override
+ public void configure()
+ {
+ Names.bindProperties(this.binder(), properties);
+
+ /* bind in the default services */
+
bind(ActivitiesService.class).to(BasicActivitiesService.class).in(
+ Scopes.SINGLETON);
+
bind(PeopleService.class).to(BasicPeopleService.class).in(Scopes.SINGLETON);
+
bind(DataService.class).to(BasicDataService.class).in(Scopes.SINGLETON);
+ }
+
+}
Property changes on:
java/gadgets/src/main/java/org/apache/shindig/social/opensocial/DeafultServiceModule.java
___________________________________________________________________
Name: svn:keywords
+ Date Revision Author HeadURL Id
Name: svn:eol-style
+ native
Index: java/gadgets/src/main/webapp/WEB-INF/web.xml
===================================================================
--- java/gadgets/src/main/webapp/WEB-INF/web.xml (revision 644317)
+++ java/gadgets/src/main/webapp/WEB-INF/web.xml (working copy)
@@ -26,7 +26,7 @@
<!-- If you have your own Guice module(s), put them here as a
colon-separated list. -->
<context-param>
<param-name>guice-modules</param-name>
- <param-value>org.apache.shindig.gadgets.http.HttpGuiceModule</param-value>
+
<param-value>org.apache.shindig.gadgets.http.HttpGuiceModule:org.apache.shindig.social.opensocial.DeafultServiceModule</param-value>
</context-param>
<listener>
</PATCH>
On 04/04/2008, Cassie <[EMAIL PROTECTED]> wrote:
> Ian - your patch didn't come through.
>
> I am working on this as we speak and hope to have something checked in
> in just a couple hours (before my flight to london). If your patch
> works Ian - I'll gladly use it!
>
>
> - Cassie
>
>
>
> On Fri, Apr 4, 2008 at 12:03 PM, Ian Boston <[EMAIL PROTECTED]> wrote:
> > This is what I did to make my service injectable (I have my own
> > version of the DefaultServiceModule), patch attached. One cavet, its
> > the first time I have used Guice, so I expect its wrong, but if not
> > please feel free to use (in apache jira I would have ticked the ASF
> > license checkbox).
> >
> > Ian
> > (btw, I will not be in the slightest offended if you ignore the patch
> > :), I am only experimenting )
> >
> >
> >
> >
> >
> >
> > On 04/04/2008, Kevin Brown <[EMAIL PROTECTED]> wrote:
> > > On Fri, Apr 4, 2008 at 12:58 AM, Ian Boston <[EMAIL PROTECTED]>
> > > wrote:
> > >
> > >
> > > > Would, longer term the intention be to define the services in a Guice
> > > > Module that was referenced in the web.xml ?
> > >
> > >
> > >
> > > This would be the case today, but someone needs to wire up guice
> injection
> > > in the social parts. The gadget renderer is thoroughly covered, but I
> only
> > > did the most basic stuff to make the social data stuff work correctly.
> Since
> > > that code is more subject to change than the renderer at the moment I
> > > thought it best to leave it up to people who are actually actively
> working
> > > with that code.
> > >
> > > --
> > >
> > > ~Kevin
> > >
> >
>