简体   繁体   中英

How do I connect my Desktop Java Application to an Existing GAE Datastore?

Currently I have a very basic desktop Java application in Eclipse that is meant to add entities to an existing project's datastore on Google App Engine. I have it all setup right now but since I am new to working with Google App Engine, I have no clue on how to get the application to send the Entities into the datastore of my existing project.

I tried looking this up online but most of what I found was for making java web apps. My goal is to have the application running as its own application, not through a browser.

So, what do I have to do to make the application connect to my GAE datastore? Is there some code I need to type, or perhaps some xml file I need to have within the project? I am just using the Java Eclipse plugin for Google App Engine.

Thanks for the help!

Based on the language of your question, I think you really need a big-picture sort of answer, rather than any specific code. Therefore:

You have a desktop application. This runs on some desktop computer.

You have a Google App Engine application with its data store. This runs in Google's data centers.

These are not the same computer. Therefore, they must communicate over the network in some fashion — that is the missing piece you're looking for.

Since GAE is designed around doing web applications, I recommend you think of this as a “web service” situation — that is, your desktop application makes HTTP requests to your GAE application. (The situation is simplified over the general case because you are writing both the client and the server.)

I recommend you read about designing simple web services and do whatever seems to fit your application.


One important warning: Unless your GAE application only ever has one user , you must not simply write a bridge that gives access to the data store over HTTP, because then anyone can make arbitrary changes to other people's data. As it is said for multiplayer game design: don't trust the client — that is, only accept network requests that make sense according to the rules of your application, and do not expect the client to enforce those rules. This is because anyone can make requests to your GAE application using something other than your desktop application , so you must assume you could receive arbitrary requests. This is the fundamental nature of the Internet.

For example, in the simple case of a multi-user application whose users do not interact with each other using the application, this means that every request that, say, updates a record, should only update a record which belongs to the logged-in user , not one of any other user.

For anyone that gets this problem in the future, I got an answer to it. I just tried experimenting around with the project settings and found it. So as it turns out, after you have installed the GAE Eclipse Plugin, you can just right click your project folder in the Package Explorer , go the Google sub menu, then click on App Engine Settings... .

From there, you need to check the Use Google App Engine checkbox, then in the deployment section, just fill in your project's Application ID . Your project's application ID can be found under the Application Settings tab of your project's online Google app engine dashboard. It is listed there as your Application Identifier .

Turns out that for me, I will need to find a different solution as you cannot integrate GAE with a desktop application that uses the Java Swing library. Bummer :/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM