开发者

Different object of stateful session bean using SwingWorker in Java Swing

I have a have a custom progressbarpanel in Swing where I want to show the progress of a lengthy operation. So I created two swingworkers:

  1. One that does the actual lengthy operation in a bean managed stateful session bean (lengthyTask)
  2. One that asks the ssb for progress in a loop based on a flag (st开发者_如何学运维atusTask)

The ssb uses a boolean variable to flag if it is finished

My problem is that the ssb seams to be different objects in the event dispatch thread and the newly created threads even though the ssb is assigned to a final variable. When the statusTask ask for ssb.isDone(), it return false even though i know for sure that the lengthy task has completed without errors.

Psudo example:

final ProgressPanel p = new ProgressPanel();
final StatefulSessionBean ssb = getSSB();
p.print(ssb);
SwingWorker lengthyTask = new SwingWorker() { public void doInBackground(){p.print(ssb);} };
SwingWorker statusTask = new SwingWorker() {public void doInBackground(){p.print(ssb);} };
lengthyTask.execute();
statusTask.execute();

The code will print out different objects. By the way the swing app communicates with a JBoss 4.2.3 using EJB3, lookup is done with JNDI.

Has anyone had any similar experience or understands why the object is different in each thread? Thanks for any input!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜