Shindig: A Local Development Environment
OpenSocial applications live within an OpenSocial Container that maintains the application state and information about the users and the social network they compose. Other popular containers include orkut, hi5, or MySpace. For OpenSocial application development, you can either run your code within sandboxed environments, which many containers provide, or use a container running on your local machine specifically for development purposes. (The OpenSocial "Getting Started" tutorial
lists available containers on the web and the development features they support, in case you prefer that option.) The local environment option is preferable because it gives you unconstrained possibilities to test different scenarios, such as manipulating the list of friends, altering your activities stream, or impersonating different users.
In this article, you will set up a local development environment using Apache Shindig as your container. Shindig is an open source container that provides the reference implementation for the OpenSocial APIs. Therefore, you are assured that whatever application you create on your local environment will work on existing containers on the web. Once the application is finished, you may then deploy it on the web and include it in public directories (such as the orkut application gallery), so that users can include it within their personal pages and profiles and start spreading the word!
Start by downloading the Shinding container from the project website. Since no packaged version yet exists, you have to download the source code and build it from scratch. The following instructions guide you through the process, assuming that you have a Java Development Kit (JDK), Subversion, and Maven2 installed on your system (as described on the Shindig website):
svn co http://svn.apache.org/repos/asf/incubator/shindig/trunk/
Once the build finishes, you will have a WAR file suitable for deployment in a J2EE application server such as Apache Tomcat. Supposing that you have a working installation of Tomcat in your ~/tomcat folder (if you don't, you can download it from the web and unpack it in your local disk by following this link), start up Tomcat using the following command:
Once started, access the Tomcat deployment manager at http://localhost:8080/manager/html and deploy the Shindig container. If you followed the instructions above, the WAR file will be located in ~/shindig/java/server/target/shindig.war. To work properly, the Shindig container must be deployed under the root context path, so be sure to un-deploy any application that may already be deployed under the same path before deploying Shindig. If everything goes accordingly, you should be able to access the URL http://localhost:8080/gadgets/files/samplecontainer/samplecontainer.html and see something similar to Figure 3.
|Figure 3. The Shindig Container Initial Page: The Shindig OpenSocial container allows you to deploy and test your applications.|
The page displayed in Figure 3 is the Shindig OpenSocial container. It allows you to deploy and test your applications, as well as control the application state: changing the number and kind of friends, application data, and activities, or switching the user accessing the application. You can change the application state by providing a properly formatted XML file to the Shindig container (more on this later).