1 /*------------------------------------------------------------------------------
 2 Name:      XmlBlasterCallback.java
 3 Project:   xmlBlaster.org
 4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
 5 ------------------------------------------------------------------------------*/
 6 package org.xmlBlaster.client.jmx;
 7 
 8 import java.rmi.RemoteException;
 9 import org.xmlBlaster.util.admin.extern.MethodInvocation;
10 
11 import org.xmlBlaster.util.admin.extern.XmlBlasterConnector;
12 import org.xmlBlaster.util.Global;
13 import java.util.logging.Logger;
14 import java.util.logging.Level;
15 
16 public class XmlBlasterCallback implements Callback{
17 
18   private int status = XmlBlasterConnector.UNKNOWN;
19   private static String ME = "XmlBlasterCallback";
20   private String ID = null;
21   private MethodInvocation mi = null;
22   private Global glob;
23    private static Logger log = Logger.getLogger(XmlBlasterCallback.class.getName());
24 
25   XmlBlasterCallback(String ID, MethodInvocation mi) {
26     status = XmlBlasterConnector.SENDING;
27 
28     this.ID = ID;
29     this.mi = mi;
30     this.glob = Global.instance();
31 
32   }
33 
34   protected void setMethodInvocation(MethodInvocation mi) {
35 
36     synchronized (this) {
37       if (log.isLoggable(Level.FINER)) this.log.finer("setMethodInvocation for " + mi.getMethodName());
38       this.mi = mi;
39       status = XmlBlasterConnector.FINISHED;
40       notifyAll();
41     }
42   }
43 
44   public int peek() {
45     return status;
46   }
47 
48   public Object get() throws RemoteException {
49     synchronized (this) {
50       if (log.isLoggable(Level.FINER)) this.log.finer("get");
51       while (status != XmlBlasterConnector.FINISHED) {
52         try {
53           wait();
54         }
55         catch (InterruptedException e) {}
56         }
57       }
58       return mi.getReturnValue();
59     }
60   }


syntax highlighted by Code2HTML, v. 0.9.1