Question

in: Android Studio 0.4 
do: New Project, Generate AppEngine
result:

Classes DeviceInfo and DeviceInfoEndpoint in AppEngine tree

and

also Classes Deviceinfoendpoint (diff. spelling) and model/DeviceInfo (same spelling) in endpoints tree

Here's my best guess:

AppEngine/DeviceInfo is a Java Bean with get/set and some private properties (RegID, info strings)

AppEngine/DeviceInfoEndpoint is describing methods that will become the API on the Engine. provides methods like getDeviceInfo, insertDeviceInfo, removeDeviceInfo and manages persisting the collection of DeviceInfo entities

Endpoints/model/DeviceInfo extends com.google.api.client.json.GenericJson and implements what looks like, but is not the same as, AppEngine/DeviceInfo (properties for deviceInformation, deviceRegID, get/set methods) - why is this necessary if the Bean was already written?

Endpoints/Deviceinfoendpoint (spelled a little different, different caps) extends com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient and has lots of methods.

What are the responsibilities of these parts? Whats the difference between endpoint Classes in App-engine module and endpoint classes in Endpoints module?

A sort-of helpful video (relevant material around minute 38) http://www.youtube.com/watch?v=lmv1dTnhLH4&feature=youtu.be&t=37m4s although the behavior has changed since then.

An important class "Builder" is only available in the Endpoints/Deviceinfoendpoint, so that seems relevant.

Also wasn't finding a description of these results in Android web pages, if you know a like to a URL that's helpful I'll read it.

Was it helpful?

Solution

In the AppEngine Tree DeviceInfo is the persistence object, this JPA object is saved to the App Engine datastore. It is also the object used in serialization on the Server side.

Like you said, DeviceInfoEndpoint is the endpoint class which defines the methods you can use to interact with your Server. All the annotations help define how the endpoint will be exposed. (the spelling/capitalization of Deviceinfoendpoint on the client side is defined here with the @Api annotation).

Most of the code on the client side (all the client library code) is generated by an endpoints service which takes what is defined on the server side and provides an object model to interact with your endpoint. It may look like it's duplication because the service is duplicating the object model on the server side without actually exposing anything going on on the server side, just what the client needs to know.

Builder is just a service object that encapsulates everything you need to interact with your appengine server. It helps expose the endpoint to the user in a meaningful way.

Here's some info on endpoints client in Android : https://developers.google.com/appengine/docs/java/endpoints/consume_android

Here's some more general endpoints documentation : https://developers.google.com/appengine/docs/java/endpoints/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top