1

I'm wondering how to make a simple swing app aware of changes in Grails app. So if Grails updates a domain object, Swing becomes aware of it and updates it's display. Both app backed by the same DB.

I'm thinking Grails JMS (or Apache Camel) Plugin can expose changes taking place, but how does the Swing app discover them? I'd expect the implementation on Grails side would be straight forward but I'm completely lost as to the Swing side.

If it sounds vague, it's because this type of integration is a completely uncharted territory for me at this time. So much so that I have no code to post yet.

vector
  • 7,334
  • 8
  • 52
  • 80

1 Answers1

0

Well, if is the same database you can create a table that will have records when something changed and some method to update this table (triggers or updates in your grails app). Your Swing app will just check (you can use timers or Quartz jobs) the table and refresh the view when found something.

Something like:

grails_changes (i'm not concerned about better names here :) )
--------------------------
id
domain
id_record_domain
timestamp_changed
timestamp_updated_swing

The domain and id_recrod_domain makes your desktop application more flexible, you can have a specific view that will refresh only for one specific domain, for example.

The timestamp_update_swing is to know if the view already has been updated and when.

So the flow will be:

  • Record changed (created, modified, deleted) in grails app;
  • Register the change in grails_changes;
  • Swing app query the table, looking for new records without timestamp_updated_swing;
  • Swing app refresh's the view;
  • ... hm, that's a thought. I was thinking more along the lines of the swing app listening and getting pinged by the web-server. – vector Aug 24 '12 at 00:28