Monday, 19 July 2010

How do I add my own database to Java Shindig (Updated July 2011)

This post is a continuation of the previous post where we connected a database to Java Shindig. Now I will use my own database with shindig. In other words when a social request is executed, the data will be taken from my own social database.
To start with you have to have a working version of shindig-database connection as described in previous post.

1) Imagine I have a social MySQL database with only one table 'people' and three colums:
This will be my own social database that I want to connect to Shindig. (To make life easier you can just remove tables and redundant columns from shindig database (generated in previous post) and rename 'person' table to 'people' table). Add the following data into table: . 2) Now we have to tell shindig not to generate database every time it loads. Normally it should be possible to do through java/samples/src/main/resources/META-INF/persistence.xml but it seems Shindig's samples implementation doesn't take those properties from that file. So I had to change the following file: java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/eclipselink/

3) Now we have to change the file java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/ so that it takes needed for us data from the database. Read the explanations in comments.

4) Now recompile project and run jetty server
5) Now execute a social request in your browser. You should get back a json response (I had to reload page 3 times to get it) So, now you are ready to change, etc. files according to your own social database implementation! Concerning JPQL syntax I found the following useful: JPQL Language Reference

No comments:

Post a Comment