| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
package org.apache.shindig.social.core.config; |
| 20 | |
|
| 21 | |
import org.apache.shindig.auth.AnonymousAuthenticationHandler; |
| 22 | |
import org.apache.shindig.auth.AuthenticationHandler; |
| 23 | |
import org.apache.shindig.common.servlet.ParameterFetcher; |
| 24 | |
import org.apache.shindig.social.core.oauth.AuthenticationHandlerProvider; |
| 25 | |
import org.apache.shindig.social.core.util.BeanJsonConverter; |
| 26 | |
import org.apache.shindig.social.core.util.BeanXStreamAtomConverter; |
| 27 | |
import org.apache.shindig.social.core.util.BeanXStreamConverter; |
| 28 | |
import org.apache.shindig.social.opensocial.service.BeanConverter; |
| 29 | |
import org.apache.shindig.social.opensocial.service.DataServiceServletFetcher; |
| 30 | |
import org.apache.shindig.social.opensocial.service.StandardHandlerDispatcher; |
| 31 | |
import org.apache.shindig.social.opensocial.service.HandlerDispatcher; |
| 32 | |
import org.apache.shindig.social.sample.service.SampleContainerHandler; |
| 33 | |
|
| 34 | |
import com.google.inject.AbstractModule; |
| 35 | |
import com.google.inject.Inject; |
| 36 | |
import com.google.inject.Provider; |
| 37 | |
import com.google.inject.TypeLiteral; |
| 38 | |
import com.google.inject.name.Names; |
| 39 | |
|
| 40 | |
import java.util.List; |
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | 2 | public class SocialApiGuiceModule extends AbstractModule { |
| 49 | |
|
| 50 | |
|
| 51 | |
@Override |
| 52 | |
protected void configure() { |
| 53 | 2 | bind(HandlerDispatcher.class).toProvider(HandlerDispatcherProvider.class); |
| 54 | |
|
| 55 | 2 | bind(ParameterFetcher.class).annotatedWith(Names.named("DataServiceServlet")) |
| 56 | |
.to(DataServiceServletFetcher.class); |
| 57 | |
|
| 58 | 2 | bind(String.class).annotatedWith(Names.named("shindig.canonical.json.db")) |
| 59 | |
.toInstance("sampledata/canonicaldb.json"); |
| 60 | |
|
| 61 | 2 | bind(Boolean.class) |
| 62 | |
.annotatedWith(Names.named(AnonymousAuthenticationHandler.ALLOW_UNAUTHENTICATED)) |
| 63 | |
.toInstance(Boolean.TRUE); |
| 64 | |
|
| 65 | 2 | bind(BeanConverter.class).annotatedWith(Names.named("shindig.bean.converter.xml")).to( |
| 66 | |
BeanXStreamConverter.class); |
| 67 | 2 | bind(BeanConverter.class).annotatedWith(Names.named("shindig.bean.converter.json")).to( |
| 68 | |
BeanJsonConverter.class); |
| 69 | 2 | bind(BeanConverter.class).annotatedWith(Names.named("shindig.bean.converter.atom")).to( |
| 70 | |
BeanXStreamAtomConverter.class); |
| 71 | |
|
| 72 | 2 | bind(new TypeLiteral<List<AuthenticationHandler>>(){}).toProvider( |
| 73 | |
AuthenticationHandlerProvider.class); |
| 74 | 2 | } |
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | 0 | static class HandlerDispatcherProvider implements Provider<HandlerDispatcher> { |
| 81 | |
private final HandlerDispatcher dispatcher; |
| 82 | |
|
| 83 | |
@Inject |
| 84 | |
public HandlerDispatcherProvider(StandardHandlerDispatcher dispatcher, |
| 85 | 0 | Provider<SampleContainerHandler> sampleHandler) { |
| 86 | 0 | dispatcher.addHandler("samplecontainer", sampleHandler); |
| 87 | 0 | this.dispatcher = dispatcher; |
| 88 | 0 | } |
| 89 | |
|
| 90 | |
public HandlerDispatcher get() { |
| 91 | 0 | return dispatcher; |
| 92 | |
} |
| 93 | |
} |
| 94 | |
} |