As explained in the XBee blog, I have been following the examples in the book Building Wireless Sensor Networks which culminates in a Pachube based system. However, as already explained in Xively – No Thanks!, Xively bought Pachube, and it is broken, so the whole project is dead, essentially. Enough has been written about this already.
Using GroveStreams instead is a great solution, but requires the re-writing of the Pachube Processing library, JPachube, to point to GroveStreams, instead of Pachube. This is how you achieve that.
NOTE: JPachube.jar is based on the EEML for Processing library.
See also BWSN Uploading to Xively.
Option drag it to a new folder to make a copy, as you don’t really need to destroy the original, plus you will want to keep it as a reference to compare against.
Open the .jar file, with 7-Zip, or Archive Utility on OS X, or something that handles zip files.
Delete all of the .class files, as you are going to recompile them later.
Now, the simple part – replace “Pachube” with “GroveStreams” where ever you see it. Before all, the parent directory should be renamed from JPachube to JGroveStreams, and the directory that it contains from “Pachube” to “GroveStreams”.
Then just three filenames,:
Now open every .java file, including those in the httpClient sub-directory, and replace EVERY instance of:
- “Pachube” with “GroveStreams”, and ;
- “pachube” with “grovestreams”
You do this everywhere… in URLs, class and method names, comments, everywhere.
Save all of the files.
Now, in a terminal, in the JGroveStream/GroveStream directory run
$ find . -name "*.java" > sources.txt
This makes a list of all of the .java files, including those in the sub-directory (you can check this by running “more sources.txt”. If you do not do this, you will had many compile errors. Next compile the lot:
$ javac @sources.txt
Now to make the .jar file. Change directory in the terminal to the JGroveStreams directory, and run the jar command on all files in the GroveStreams directory
$ jar cf JGroveStreams.jar GroveStreams/*
Now, there will be a JGroveStreams.jar directory, of exactly the same file structure as the original JPachube.jar file. You can check this, by creating a copy in a dummy folder and unzipping it and comparing it to the unzipped JPachube.jar directory:
NOTE: There is no need to make this .jar file executable, and so no entry point needs to be specified when creating the .jar file.
- Viewing contents of a .jar file
- javac option to compile all java files under a given directory recursively
- Java creating .jar file
Modifying the API calls
It is necessary to adjust the API calls, which were used to call Pachube, to match the GroveStreams calls. To do this it is necessary to see if, hopefully, there exists a one-for-one relationship for the various entities in each system, and then examine and compare the API references of each. This is no mean feat. For simplicity, one could just work through the JGRoveStreams library and modify the methods as required. Here are the developer resources:
- GroveStreams API references –
- Pachube API references –
Assuming, for the moment, that Grovestreams Component maps to Pachube’s Product, then considering each API in turn (Pachube vs GroveStreams), going down the GroveStreams’s Component Resource