This app is written in Java and is developped using the GWT framework. It reposes on the MVP architecture (Model–View–Presenter) as described in the article Building MVP apps. This sample project provides:
- Sample code to use the LH API in Java.
- Sample code to build a MVP-based application (with AppController and history management).
This should be of interest for a wide range of prospective developers: Android native app, webapp and more generally multi-platform mobile HTML5 applications (see, e.g., PhoneGap).
The LH API is queried on the server side (hence the possible need for proxy setting–see next section). The client invokes the services via GWT RPCs.
The file Showcase-settings.xml (located in src\main\resources\lh\api\showcase) can be used to specify the required authentication information (obtained after successfully registering to the LH API).
Furthermore, if the server is behind a proxy, the parameters can be specified in this setting file as well.
Here an example:
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <settings> <authentication> <api> <key>client id</key> <secret>client secret</secret> <callback>http://example.com:8080</callback> </api> </authentication> <proxy> <http> <port>8080</port> <active>true</active> <user>username</user> <password>password</password> <host>proxy host</host> </http> </proxy> </settings>
Compiling and Testing
After cloning the repository, the following commands should be used:
mvn clean # can be omitted the first time mvn gwt:generateAsync mvn package
Then, the application can be launched locally in development mode with the command (see Compiling and Debugging for further details):
To open the project in Eclipse, the following command might prove useful:
This app is online at lh-api-showcase.appspot.com.