Dom Derrien did a great job earlier this year publishing his patch for Amazon FPS on Google’s App Engine. However, his project did not go live with FPS so few bugs remained unnoticed. Today I pushed my fixes to the cloned project on the GitHub project at http://github.com/radomirml/amazon-fps-gaej (If anyone is interested in what’s been changed, please check the project history.)
Beside fixing the library, I was free to make few more changes…
Bonus: Using the same FPS jar for production and Amazon’s Sandbox
Before using Amazon’s FPS library in your application, you need build a custom jar specify your Amazon AWS keys in the config.properties. The same configuration file also contains end-point URL’s to Amazon’s AWS and CBUI service. You can not change end-point URL’s during runtime so if you wanted to test your application with Amazon’s Sandbox, you would have to create a separate jar with URL’s to the Sandbox.
I did not like the idea of switching jar files as it appeared error-prone to me and did not fit with my release procedure for GAE application. So, I made few small changes to the FPS to support environment selection and here’s how to use it…
Creating FPS service
This does not differ much from the “regular” AmazonFPS service creation:
1 2 3 4 5 6 7 8 9 10
Obviously, in lines 5-6 I check if my application is running on the production server and switch to the sandbox environment if it does not. (This is possible with the official FPS library too but I’ve added a new property key for convenience.)
Creating CBUI Pipeline
Unfortunately, Amazon did not support runtime change of CBUI URL so I added a method setUsingSandbox(boolean) to the AmazonFPSCBUIPipeline that will change URL accordingly. Example use:
1 2 3 4 5
This update to the FPS is already included in the above GitHub project.
Disclaimer: I’m not responsible for any issue that may be a result of my changes to the library. :-)