0

I got a GWT version of the java Pet Store working on my machine, and I'd like to implement an exteneral Java program that is on another machine, and just displays "On" or "off" - so when I turn off the java Pet Store on one machine, it will then switch from "On" to "Off" on the other machine.

How would I go about doing this? I've played with RMI a little, but it's quite cumbersome. Any tips or advice is appreciated.

Caffeinated
  • 11,982
  • 40
  • 122
  • 216

2 Answers2

1

If it's a web app, just use something like HttpClient to hit a known address; if you don't get a response, it's down.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
1

I'd create a program to check the running processes on the Pet Store machine to see if the application is still running and expose that capability to remote machines.

-Checking whether Pet Store is still running

-Executing the check remotely

It may be a bit overkill, but if you wanted, you could set up the remote check using web services. I personally like Axis2.

Community
  • 1
  • 1
Teddy Yueh
  • 664
  • 3
  • 6
  • 1
    I'm not sure what your comment means @_@. Is it that you feel like the approach I suggested is simple or that it is not simple? – Teddy Yueh Sep 14 '11 at 23:39
  • Not simple. All you have to do is connect to the app and see if you get anything back. – Dave Newton Sep 14 '11 at 23:40
  • "All you have to do is connect to the app" <-- This assumes you can do that, like in your answer you say "If it's a web app". We don't know that. Or at least I don't know that. Creating a method that contains code from the first link with the addition of matching the returned values with the desired process name and then using code from the second link to execute it remotely doesn't seem to be complicated to me, either, especially if it's mostly there already like it is now. And that puts no restrictions on what the application is. – Teddy Yueh Sep 15 '11 at 17:18
  • 1
    A non-web GWT app? GWT runs in a browser. If there's a GWT-based app, it's talking to an HTTP back end. If it's talking to an HTTP back end... – Dave Newton Sep 15 '11 at 18:28
  • 1
    I'm not familiar with GWT and just googled it."GWT runs in a browser." <-- I now agree with your answer completely. – Teddy Yueh Sep 15 '11 at 19:49
  • Hmm. Well, interesting approach to answering questions, I guess. – Dave Newton Sep 15 '11 at 19:53