Shindig Spring Example
MockPersonSpi is a mock implementation of PersonService, returning mock responses to the getPerson and getPeople methods. Obviously, in a real world scenario this should be a real implementation of PersonService, but the mock serves our purposes well for this example.
GuiceModule is the Guice configuration module that binds any custom shindig bindings, and in this scenario the only customization needed is to bind MockPersonSpi to the PersonService interface. To bind an instance of MockPersonSpi, GuiceModule will use ApplicationContextFactory to get Spring's ApplicationContext, and in turn use ApplicationContext to get the MockPersonSpi bean instance. Since GuiceModule extends SocialApiGuiceModule, it calls super.configure() so that the default social bindings are therefore also configured.
ApplicationContextFactory acts as a holder to Spring's ApplicationContext, thus providing a static getter method to the context.
The application-context.xml Spring configuration file is where Spring beans are defined, and in this instance a bean definition has been included for MockPersonSpi.
To have this example running within a servlet container it's necessary to add GuiceModule into the web.xml file.
Example Source Code
- Check-out from svn (https://svn.apache.org/repos/asf/shindig/sandbox/trunk/shindig-spring-example/) and look at the README to get started.