Shindig Spring Example
Skip to end of metadata
Go to start of metadata

Shindig Spring Example

Example Overview

MockPersonSpi

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

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

ApplicationContextFactory acts as a holder to Spring's ApplicationContext, thus providing a static getter method to the context.

application-context.xml

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.

web.xml

To have this example running within a servlet container it's necessary to add GuiceModule into the web.xml file.

Example Source Code

Labels
  • No labels