views:

195

answers:

3

I believe any programmer who has been dealing with database requests in a gui application has run into some or all of the following problems:

  • Your GUI freezes because you call database layer from within the event dispatch thread
  • When you have multiple windows/panels/jframes where user can start a db request your performance degrades because you don't have any control about the threads your user creates
  • User may be able to lock down the application and even the database because he calls any action many times before the first action has been finished

What I'd like to know about: are there any frameworks that handle the requirements of handling an ordered set of long running actions (including but not limited to database calls, i.e. calculations) outside the event dispatch thread?

Note: I know of SwingWorker ;-)

+1  A: 

I doubt you will find something specific for database requests. You can try to reuse existing generic task scheduling libraries. An example is the Eclipse jobs API. This does not depend on the IDE.

See http://www.eclipse.org/articles/Article-Concurrency/jobs-api.html

Tom
That has been my impression at the time too. We've developed a kind of queue where you could add SwingWorker instances that would execute in scheduled order.
dhiller
+1  A: 

Such a thing should be found in Netbeans for example. See RequestProcessor. But in simpler cases this is not required. Last time I need something like thread scheduling and control I simply used new concurrency packages included in J5 (I used J6). With its ExecutorFactory-ies you can simply achieve basic control over tasks. You can also use some queues. This PDF can help. The PDF is written in Slovak language but the Single/Multiple task workers are there written in Java ;)

Rastislav Komara
+1  A: 

Naked Objects facilitate a clean domain model and they also have a GUI 2 DB mapping layer -- http://www.nakedobjects.org/home/index.shtml

anjanb