appstart

App Engine Java Modules Boilerplate Template

32
5
Java

Appstart

Appstart is an opinionated Java boilerplate template for rapid development of multi-module Google App Engine applications based on Google Guice, a lightweight dependency injection framework.
Appstart uses the App Engine Maven plugin, it has a parent pom and 3 maven projects. 2 of the projects (appstart-front and appstart-backend) are App Engine modules.

App Engine multi-module applications are organized as an unpacked Java Enterprise Archive (EAR) directory structure. This project contains the following directories:

  • appstart-ear contains the EAR deployment descriptors application.xml and appengine-application.xml
  • appstart-frontend is configured to use a frontend instance <instance-class>F1</instance-class> and
  • appstart-backend is configured to use a backend instance <instance-class>B2</instance-class>.
  • The third project appstart-common is a common code project shared between the appstart-frontend and appstart-backend modules handy when you are developing multiple modules with shared code.

Appstart encourages the Single Page Application (SPA) pattern by providing backend services as APIs that can be invoked from any frontend, be it Web or Mobile. The philosophy of Appstart is to enable you to spend less or no time writing boilerplate code and more time focusing on your business logic.

Demo

A live demo is available here https://appstart-web.appspot.com/.

Explore the Cloud Endpoint API for Appstart here.

Overall Architecture

Alt text

Key Technologies/Libraries

The following key technologies/libraries are used by Appstart. You can either use some or all of these technologies depending on your needs:

App Engine Services

  • cron.xml for a cron job that run every midnight on the backend module and archives any old todos. This must be included with the default module (appstart-frontend) rather than any other modules as mentioned here.
  • Cloud Endpoints is configured on the default module (appstart-frontend).

Backend Technologies

  • Google Guice: App Engine friendly, lightweight dependency injection framework.
  • Objectify: Convenient data access API for the App Engine datastore.
  • Cloud Endpoints: App Engine REST/RPC API to simplify clients (Android, iOS, etc…) access.
  • Jersey & Jersey Guice integration: Jersey framework is an implementation of the JAX-RS (JSR 311 & JSR 339) to provide RESTful Web services in Java.
  • Lombok: A framework for boilerplate code generation such as getter, setter, constructors, equalTo, hashCode, etc… Saving you time to focus on your business logic. Note: for the code to compile in your IDE and not to show compile errors, you need to install Lombok in your IDE as explained here.
  • Google Guava, Google Gson and Apache Commons Lang: Useful Java libraries that plays well with App Engine.
  • App Engine Unit Testing Libraries & jMockit: Creating unit tests using the App Engine local unit testing libraries. Mocking is achieved using the jMockit mocking library.

Frontend Technologies

  • AngularJS TodoMVC: Frontend page uses the TodoMVC AngularJS as an example. You can integrate your own frontend technology with Appstart.

Usage:

You need to change the following values with your own:

To run or deploy the application (all modules):

    git clone https://github.com/omerio/appstart.git
    cd appstart
    mvn install
    cd appstart-ear
    #to test it locally:
    mvn appengine:devserver
    #or to deploy it:
    mvn appengine:update

To deploy or run individual modules:

    cd appstart-frontend
    #to test it locally:
    mvn appengine:devserver
    #or to deploy it:
    mvn appengine:update

Local URLs:

TODO:

  • Create documentations.
  • Add sample unit tests that uses the App Engine local unit testing libraries.
  • Create Cloud Endpoints frontend code to authenticate a user and refresh the OAuth token once it expires.
  • Provide an option on the frontend to use either the JAX-RS REST or Cloud Endpoints.
  • Create a Maven archetype to easily scaffold projects.

Contributing:

Contributions are welcome and encouraged, simply fork the project make your changes and submit a pull request.

License

Open Source (Apache License 2.0)