1 16 package sample.amazon.amazonSimpleQueueService.util; 17 18 import org.apache.axis2.clientapi.AsyncResult; 19 import org.apache.axis2.clientapi.Callback; 20 import org.apache.axis2.om.OMElement; 21 import org.apache.axis2.om.OMNode; 22 import org.apache.axis2.soap.SOAPBody; 23 24 import javax.swing.*; 25 import java.util.Iterator ; 26 27 32 public class SimpleQueueListMyQueuesCallbackHandler extends Callback { 33 private String returnString = "Listing Available Queues......\n"; 34 private JTextField createQueue; 35 private JTextArea result; 36 private JTextField queueCode; 37 private JTextField read; 38 private JButton button; 39 40 public SimpleQueueListMyQueuesCallbackHandler() { 41 } 43 public SimpleQueueListMyQueuesCallbackHandler(JTextField createQueue, JTextField queueCode, 44 JTextField read, JTextArea result, 45 JButton button) { 46 super(); 47 this.createQueue = createQueue; 48 this.queueCode = queueCode; 49 this.read = read; 50 this.result = result; 51 this.button = button; 52 } 53 54 public void onComplete(AsyncResult result) { 55 SOAPBody body = result.getResponseEnvelope().getBody(); 56 getResults(body); 57 this.button.setText("Load Queue"); 58 } 59 60 public void reportError(Exception e) { 61 62 } 63 64 private boolean getResults(OMElement element) { 65 Iterator iterator = element.getChildren(); 66 while (iterator.hasNext()) { 67 OMNode omNode = (OMNode) iterator.next(); 68 if (omNode.getType() == OMNode.ELEMENT_NODE) { 69 OMElement omElement = (OMElement) omNode; 70 if ((omElement.getLocalName().equals("QueueId")) 71 || (omElement.getLocalName().equals("QueueName"))) { 72 73 if (omElement.getLocalName().equals("QueueId")) { 74 this.getText(omElement); 75 } 76 if (omElement.getLocalName().equals("QueueName")) { 77 this.getText(omElement); 78 } 79 80 } else { 81 getResults(omElement); 82 } 83 } 84 } 85 return false; 86 } 87 88 public String getReturnString() { 89 return this.returnString; 90 } 91 92 private void getText(OMElement element) { 93 returnString = returnString + element.getText() + "\n"; 94 this.result.setText(returnString); 95 } 96 } 97 | Popular Tags |