File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Direction needed to connect the desktop app to the cloud Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Direction needed to connect the desktop app to the cloud" Watch "Direction needed to connect the desktop app to the cloud" New topic
Author

Direction needed to connect the desktop app to the cloud

Dan Foster
Greenhorn

Joined: May 02, 2013
Posts: 23
I have a Java desktop application which stores data into a SQLite db every 10 mins which is stored locally in the user's system. I have a cloud interface to visualize this data which uses PHP and MySQL.

I need to fetch data from the local db of the users. I don't know how to go forward with this. What technologies to use so that the local data in the user's system is not exposed to the web but is somehow made available to the cloud interface to visualize it.

Can you please tell me what technologies to go with and the whole process of data interchange? I am a bit confused with this.
Carles Gasques
Ranch Hand

Joined: Apr 19, 2013
Posts: 199
    
    1
Just guessing,
but you could replicate the client local data to the cloud every X minutes with a client task?

For example a rest/ws/json call from the client to a rest/ws/json php service in the server.

Best regards
Dan Foster
Greenhorn

Joined: May 02, 2013
Posts: 23
im not sure how to do this. So what you are saying is that the data stored in the local machine would be pushed to the cloud every X minutes ?
This is what i want but im not sure how to do this? what technologies ?
surlac surlacovich
Ranch Hand

Joined: Mar 12, 2013
Posts: 296

Nice idea Carles. Very similar to mobile device with floating Internet connection. It saves all the data to local DB, and when connection is available sends a bunch of messages to the server.

Dan Foster wrote:how to do this? what technologies ?

You need to call OS specific scheduling service (Task on Win32, Cron on Unix), or use Java scheduling framework which will make the call under the hood.
For example: Quartz.
Dan Foster
Greenhorn

Joined: May 02, 2013
Posts: 23
So here is what i understand. Please correct me if this is wrong -

Components -
1) My desktop application runs every X minutes and inserts the data into the db.
2) Cloud app which would visualize this data every X minutes.

Every time data is inserted into db, a servlet(since desktop app is in Java) runs and sends a json string to the cloud app. Now the cloud app parses this string and gets data to visualize
or
Every time data is inserted into db, a servlet(since desktop app is in Java) runs and saves the data in the cloud app db. Now the cloud app reads its own db and visualizes.

Carles Gasques
Ranch Hand

Joined: Apr 19, 2013
Posts: 199
    
    1
Hi Dan,

What about

1. Every X insertions in your client desktop db (SQL Lite) or T time, your client app sends a json string, with this data new data,
to a json service in the server via Apache HttpClient or Jersey API.
2. Your json service in the server implemented with php, parses the data and insert this new data to the mysql db.
3. Visualize the data in your mysql through some php page in your server



Dan Foster
Greenhorn

Joined: May 02, 2013
Posts: 23
Ya, this looks good. Thanks Carles.

So in order to implement this -
1) I will have to make a JSON string using the Jersey API.
2) JSON service in the cloud app using PHP which parses the JSON string and stores in the mysql db.

Does this mean i have to write a web service of some kind?
Don't I have to write some servlets or just using the Jersey API will suffice ? Can you suggest some good tutorial or book where the process would be explained well ?
surlac surlacovich
Ranch Hand

Joined: Mar 12, 2013
Posts: 296

Dan Foster wrote:
1) I will have to make a JSON string using the Jersey API.

You could also employ JAXB to bind JSON to Java objects.
Dan Foster
Greenhorn

Joined: May 02, 2013
Posts: 23
Now i am sending the JSON string using POST via HTTPURLConnection. But how to accept that JSON string using PHP ?
surlac surlacovich
Ranch Hand

Joined: Mar 12, 2013
Posts: 296

Dan Foster wrote:...how to accept that JSON string using PHP ?

You need to read the string from HTTP request on PHP side and parse it with some library. However that is not java related question.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Direction needed to connect the desktop app to the cloud