You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by aj...@apache.org on 2005/06/03 10:12:50 UTC

svn commit: r179743 [1/2] - in /webservices/axis/trunk/java/modules/samples/src/sample: ./ amazon/ amazon/amazonSimpleQueueService/ amazon/amazonSimpleQueueService/util/ google/ google/search/

Author: ajith
Date: Fri Jun  3 01:12:48 2005
New Revision: 179743

URL: http://svn.apache.org/viewcvs?rev=179743&view=rev
Log:
Adding the samples, the google search and the amazon queue

Added:
    webservices/axis/trunk/java/modules/samples/src/sample/
    webservices/axis/trunk/java/modules/samples/src/sample/amazon/
    webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/
    webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/AmazonSimpleQueueServiceIn.java
    webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/AmazonSimpleQueueServiceOut.java
    webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/CreateQueue.java
    webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/DeleteQueue.java
    webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/Enqueue.java
    webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListMyQueues.java
    webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListenersIn.java
    webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListenersOut.java
    webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/Read.java
    webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/RunGUICQ.java
    webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/RunGUIRQ.java
    webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/key.properties
    webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/
    webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/QueueManager.java
    webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableCreateQueue.java
    webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableDeleteQueue.java
    webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableListMyQueues.java
    webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableReadQueue.java
    webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueCreateQueueCallbackHandler.java
    webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueDeleteQueueCallbackHandler.java
    webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueEnqueueCallbackHandler.java
    webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueListMyQueuesCallbackHandler.java
    webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueReadCallbackHandler.java
    webservices/axis/trunk/java/modules/samples/src/sample/google/
    webservices/axis/trunk/java/modules/samples/src/sample/google/search/
    webservices/axis/trunk/java/modules/samples/src/sample/google/search/AsynchronousClient.java
    webservices/axis/trunk/java/modules/samples/src/sample/google/search/ClientCallbackHandler.java
    webservices/axis/trunk/java/modules/samples/src/sample/google/search/ClientUtil.java
    webservices/axis/trunk/java/modules/samples/src/sample/google/search/GUIHandler.java
    webservices/axis/trunk/java/modules/samples/src/sample/google/search/LinkFollower.java
    webservices/axis/trunk/java/modules/samples/src/sample/google/search/key.properties

Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/AmazonSimpleQueueServiceIn.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/AmazonSimpleQueueServiceIn.java?rev=179743&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/AmazonSimpleQueueServiceIn.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/AmazonSimpleQueueServiceIn.java Fri Jun  3 01:12:48 2005
@@ -0,0 +1,77 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package sample.amazon.amazonSimpleQueueService;
+
+import javax.swing.*;
+import java.awt.*;
+
+/**
+ * GUI which handles the IN operations of the queue
+ * @author Saminda Abeyruwan <sa...@opensource.lk>
+ *
+ */
+public class AmazonSimpleQueueServiceIn extends JFrame{
+    JTextField createQueue;
+    JTextField queueCode;
+    JTextField enqueue;
+    JTextArea resuts;
+    public AmazonSimpleQueueServiceIn(){
+        this.setBounds(200,200,450,500);
+        this.setTitle("Amazon Simple Queue WS - In");
+        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        this.guiInit();
+    }
+    private void guiInit(){
+        getContentPane().setLayout(new GridBagLayout());
+        GridBagConstraints cons = new GridBagConstraints();
+        cons.fill = GridBagConstraints.BOTH;
+        JLabel lable1 = new JLabel("Create Queue");
+        cons.insets = new Insets(5,5,5,5);
+        this.add(lable1,cons,0,0,1,1);
+        JLabel lable2 = new JLabel("Queue Code");
+        this.add(lable2, cons, 1,0,1,1);
+        cons.weightx = 100;
+        createQueue = new JTextField("Test Queue LSF2");
+        this.add(createQueue,cons,0,1,1,1);
+        queueCode = new JTextField();
+        queueCode.setEditable(false);
+        this.add(queueCode,cons,1,1,1,1);
+        JLabel lable3 = new JLabel("Enqueue");
+        this.add(lable3,cons,0,2,1,1);
+        enqueue = new JTextField();
+        enqueue.setEditable(false);
+        this.add(enqueue,cons,0,3,2,1);
+        JLabel label4 = new JLabel("Results");
+        this.add(label4,cons,0,5,1,1);
+        cons.weighty = 100;
+        resuts = new JTextArea();
+        resuts.setEditable(false);
+        resuts.setLineWrap(true);
+        resuts.setWrapStyleWord(true);
+        JScrollPane resultpane = new JScrollPane(resuts);
+        this.add(resultpane,cons,0,6,2,2);
+        createQueue.addKeyListener(new ListenersIn(createQueue,queueCode,enqueue,resuts));
+        enqueue.addKeyListener(new ListenersIn(createQueue,queueCode,enqueue,resuts));
+    }
+    private void add(Component c, GridBagConstraints cons, int x, int y, int w, int h){
+        cons.gridx = x;
+        cons.gridy = y;
+        cons.gridheight = h;
+        cons.gridwidth = w;
+        this.getContentPane().add(c,cons);
+    }
+
+}

Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/AmazonSimpleQueueServiceOut.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/AmazonSimpleQueueServiceOut.java?rev=179743&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/AmazonSimpleQueueServiceOut.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/AmazonSimpleQueueServiceOut.java Fri Jun  3 01:12:48 2005
@@ -0,0 +1,96 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package sample.amazon.amazonSimpleQueueService;
+
+import javax.swing.*;
+import java.awt.*;
+
+/**
+ * GUI class which handles the OUT operations of the queue
+ *
+ * @author Saminda Abeyruwan <sa...@opensource.lk>
+ */
+public class AmazonSimpleQueueServiceOut extends JFrame {
+    JTextField createQueue;
+    JTextField queueCode;
+    JTextField read;
+    JTextArea resuts;
+    JButton loadButton;
+    JButton deleteButton;
+
+    public AmazonSimpleQueueServiceOut() {
+        this.setBounds(200, 200, 450, 500);
+        this.setTitle("Amazon Simple Queue WS - Out");
+        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        this.guiInit();
+    }
+
+    private void guiInit() {
+        getContentPane().setLayout(new GridBagLayout());
+        GridBagConstraints cons = new GridBagConstraints();
+        cons.fill = GridBagConstraints.BOTH;
+        cons.insets = new Insets(5, 5, 5, 5);
+        cons.weightx = 100;
+        JLabel label0 = new JLabel("Enter Queue Name");
+        this.add(label0, cons, 0, 0, 1, 1);
+        JLabel lable1 = new JLabel("Queue Code");
+        this.add(lable1, cons, 1, 0, 1, 1);
+        createQueue = new JTextField();
+        createQueue.setEditable(false);
+        this.add(createQueue, cons, 0, 1, 1, 1);
+        queueCode = new JTextField();
+        queueCode.setEditable(false);
+        this.add(queueCode, cons, 1, 1, 1, 1);
+        JLabel lable2 = new JLabel("Read");
+        this.add(lable2, cons, 0, 2, 1, 1);
+        read = new JTextField();
+        read.setEditable(false);
+        this.add(read, cons, 0, 3, 2, 1);
+        JLabel label3 = new JLabel("Results");
+        this.add(label3, cons, 0, 4, 1, 1);
+        resuts = new JTextArea();
+        resuts.setEditable(false);
+        JScrollPane resultPane = new JScrollPane(resuts);
+        cons.weighty = 100;
+        this.add(resultPane, cons, 0, 5, 2, 1);
+        JPanel buttonPannel = new JPanel();
+        loadButton = new JButton("Load Queue");
+        loadButton.setActionCommand("1");
+        deleteButton = new JButton("Delete Queue");
+        deleteButton.setActionCommand("2");
+        buttonPannel.add(loadButton);
+        buttonPannel.add(deleteButton);
+        cons.weightx = 0;
+        cons.weighty = 0;
+        this.add(buttonPannel, cons, 0, 6, 2, 1);
+        this.createQueue.addKeyListener(new ListenersOut(this.createQueue, this.queueCode,
+                this.read, this.resuts, this.loadButton, this.deleteButton));
+        this.loadButton.addActionListener(new ListenersOut(this.createQueue, this.queueCode,
+                this.read, this.resuts, this.loadButton, this.deleteButton));
+        this.resuts.addMouseMotionListener(new ListenersOut(this.createQueue, this.queueCode,
+                this.read, this.resuts, this.loadButton, this.deleteButton));
+        this.deleteButton.addActionListener(new ListenersOut(this.createQueue, this.queueCode,
+                this.read, this.resuts, this.loadButton, this.deleteButton));
+    }
+
+    private void add(Component c, GridBagConstraints cons, int x, int y, int w, int h) {
+        cons.gridx = x;
+        cons.gridy = y;
+        cons.gridheight = h;
+        cons.gridwidth = w;
+        this.getContentPane().add(c, cons);
+    }
+}

Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/CreateQueue.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/CreateQueue.java?rev=179743&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/CreateQueue.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/CreateQueue.java Fri Jun  3 01:12:48 2005
@@ -0,0 +1,45 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package sample.amazon.amazonSimpleQueueService;
+
+import org.apache.axis.om.*;
+import org.apache.axis.soap.SOAPFactory;
+
+/**
+ * This will create the OMElement needed to be used in invokeNonBlocking() method
+ *
+ * @author Saminda Abeyruwan <sa...@opensource.lk>
+ */
+public class CreateQueue {
+    public static OMElement creatQueueElement(String createQueueElement, String key) {
+        SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+        OMNamespace opN = factory.createOMNamespace(
+                "http://webservices.amazon.com/AWSSimpleQueueService/2005-01-01", "nsQ");
+        OMElement createQueue = factory.createOMElement("CreateQueue", opN);
+        OMElement subID = factory.createOMElement("SubscriptionId", opN);
+        OMElement request = factory.createOMElement("Request", opN);
+        OMElement queueName = factory.createOMElement("QueueName", opN);
+        OMElement readLockTimeOutSeconds = factory.createOMElement("ReadLockTimeoutSeconds", opN);
+        request.addChild(queueName);
+        request.addChild(readLockTimeOutSeconds);
+        subID.addChild(factory.createText(key));
+        queueName.addChild(factory.createText(createQueueElement));
+        readLockTimeOutSeconds.addChild(factory.createText("10"));
+        createQueue.addChild(subID);
+        createQueue.addChild(request);
+        return createQueue;
+    }
+}

Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/DeleteQueue.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/DeleteQueue.java?rev=179743&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/DeleteQueue.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/DeleteQueue.java Fri Jun  3 01:12:48 2005
@@ -0,0 +1,47 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package sample.amazon.amazonSimpleQueueService;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMAbstractFactory;
+import org.apache.axis.om.OMNamespace;
+import org.apache.axis.soap.SOAPFactory;
+
+/**
+ * This will create the OMElement needed to be used in invokeNonBlocking() method
+ *
+ * @author Saminda Abeyruwan <sa...@opensource.lk>
+ */
+public class DeleteQueue {
+    public static OMElement deleteQueueElement(String deleteQueueName, String key) {
+        SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+        OMNamespace opN = factory.createOMNamespace(
+                "http://webservices.amazon.com/AWSSimpleQueueService/2005-01-01", "nsQ");
+        OMElement enque = factory.createOMElement("DeleteQueue", opN);
+        OMElement subID = factory.createOMElement("SubscriptionId", opN);
+        OMElement request = factory.createOMElement("Request", opN);
+        OMElement queueName = factory.createOMElement("QueueName", opN);
+        //OMElement queueID = factory.createOMElement("QueueId",opN);
+        request.addChild(queueName);
+        //request.addChild(queueID);
+        subID.addChild(factory.createText(key));
+        queueName.addChild(factory.createText(deleteQueueName));
+        //queueID.addChild(factory.createText(queueIden));
+        enque.addChild(subID);
+        enque.addChild(request);
+        return enque;
+    }
+}

Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/Enqueue.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/Enqueue.java?rev=179743&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/Enqueue.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/Enqueue.java Fri Jun  3 01:12:48 2005
@@ -0,0 +1,50 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package sample.amazon.amazonSimpleQueueService;
+
+import org.apache.axis.om.*;
+import org.apache.axis.soap.SOAPFactory;
+
+/**
+ * This will create the OMElement needed to be used in invokeNonBlocking() method
+ *
+ * @author Saminda Abeyruwan <sa...@opensource.lk>
+ */
+public class Enqueue {
+    public static OMElement enqueueElement(String queueEntyBody, String queueIden, String key) {
+        SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+        OMNamespace opN = factory.createOMNamespace(
+                "http://webservices.amazon.com/AWSSimpleQueueService/2005-01-01", "nsQ");
+        OMElement enque = factory.createOMElement("Enqueue", opN);
+        OMElement subID = factory.createOMElement("SubscriptionId", opN);
+        OMElement request = factory.createOMElement("Request", opN);
+        //OMElement queueName = factory.createOMElement("QueueName",opN);
+        OMElement queueID = factory.createOMElement("QueueId", opN);
+        OMElement queueEntryBodies = factory.createOMElement("QueueEntryBodies", opN);
+        OMElement queueEntryBody1 = factory.createOMElement("QueueEntryBody", opN);
+        queueEntryBodies.addChild(queueEntryBody1);
+        //request.addChild(queueName);
+        request.addChild(queueID);
+        request.addChild(queueEntryBodies);
+        subID.addChild(factory.createText(key));
+        //queueName.addChild(factory.createText("Test Queue LSF "));
+        queueID.addChild(factory.createText(queueIden));
+        queueEntryBody1.addChild(factory.createText(queueEntyBody));
+        enque.addChild(subID);
+        enque.addChild(request);
+        return enque;
+    }
+}

Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListMyQueues.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListMyQueues.java?rev=179743&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListMyQueues.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListMyQueues.java Fri Jun  3 01:12:48 2005
@@ -0,0 +1,40 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package sample.amazon.amazonSimpleQueueService;
+
+import org.apache.axis.om.*;
+import org.apache.axis.soap.SOAPFactory;
+
+/**
+ * This will create the OMElement needed to be used in invokeNonBlocking() method
+ *
+ * @author Saminda Abeyruwan <sa...@opensource.lk>
+ */
+public class ListMyQueues {
+    public static OMElement queueListElement(String key) {
+        SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+        OMNamespace opN = factory.createOMNamespace(
+                "http://webservices.amazon.com/AWSSimpleQueueService/2005-01-01",
+                "nsQ");
+        OMElement listMyQueues = factory.createOMElement("ListMyQueues", opN);
+        OMElement subID = factory.createOMElement("SubscriptionId", opN);
+        OMElement request = factory.createOMElement("Request", opN);
+        subID.addChild(factory.createText(key));
+        listMyQueues.addChild(subID);
+        listMyQueues.addChild(request);
+        return listMyQueues;
+    }
+}

Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListenersIn.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListenersIn.java?rev=179743&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListenersIn.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListenersIn.java Fri Jun  3 01:12:48 2005
@@ -0,0 +1,62 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package sample.amazon.amazonSimpleQueueService;
+
+import sample.amazon.amazonSimpleQueueService.util.RunnableCreateQueue;
+import sample.amazon.amazonSimpleQueueService.util.RunnableCreateQueue;
+
+import javax.swing.*;
+import java.awt.event.KeyListener;
+import java.awt.event.KeyEvent;
+
+/**
+ * Listeners for relevent Components in the IN operation
+ *
+ * @author Saminda Abeyruwan <sa...@opensource.lk>
+ */
+public class ListenersIn implements KeyListener {
+    JTextField createQueue;
+    JTextArea result;
+    JTextField queueCode;
+    JTextField enqueue;
+    RunnableCreateQueue runnable;
+
+    public ListenersIn(JTextField createQueue, JTextField queueCode, JTextField enqueue,
+                       JTextArea result) {
+        this.queueCode = queueCode;
+        this.createQueue = createQueue;
+        this.enqueue = enqueue;
+        this.result = result;
+    }
+
+    public void keyPressed(KeyEvent e) {
+        if (e.getKeyCode() == KeyEvent.VK_ENTER) {
+            runnable =
+                    new RunnableCreateQueue(this.createQueue, this.queueCode, this.enqueue,
+                            this.result);
+            Thread tread = new Thread(runnable);
+            tread.start();
+        }
+    }
+
+    public void keyReleased(KeyEvent e) {
+
+    }
+
+    public void keyTyped(KeyEvent e) {
+
+    }
+}

Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListenersOut.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListenersOut.java?rev=179743&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListenersOut.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListenersOut.java Fri Jun  3 01:12:48 2005
@@ -0,0 +1,97 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package sample.amazon.amazonSimpleQueueService;
+
+import sample.amazon.amazonSimpleQueueService.util.RunnableListMyQueues;
+import sample.amazon.amazonSimpleQueueService.util.RunnableReadQueue;
+import sample.amazon.amazonSimpleQueueService.util.RunnableDeleteQueue;
+import sample.amazon.amazonSimpleQueueService.util.RunnableListMyQueues;
+import sample.amazon.amazonSimpleQueueService.util.RunnableReadQueue;
+
+import javax.swing.*;
+import java.awt.event.*;
+
+/**
+ * This will create the OMElement needed to be used in invokeNonBlocking() method
+ *
+ * @author Saminda Abeyruwan <sa...@opensource.lk>
+ */
+public class ListenersOut implements KeyListener, ActionListener, MouseMotionListener {
+    JTextField createQueue;
+    JTextArea result;
+    JTextField queueCode;
+    JTextField read;
+    JButton buttonLoad;
+    JButton buttonDelete;
+    Runnable runableCodeListMyQueues;
+    Runnable runnableCodeDequeue;
+
+    public ListenersOut(JTextField createQueue, JTextField queueCode, JTextField read,
+                        JTextArea result, JButton buttonLoad, JButton buttonDelete) {
+        this.queueCode = queueCode;
+        this.createQueue = createQueue;
+        this.read = read;
+        this.result = result;
+        this.buttonLoad = buttonLoad;
+        this.buttonDelete = buttonDelete;
+    }
+
+    public void keyPressed(KeyEvent e) {
+        if (e.getKeyCode() == KeyEvent.VK_ENTER) {
+            this.result.setText("");
+            this.createQueue.setEditable(false);
+            this.runableCodeListMyQueues = new RunnableReadQueue(this.createQueue,
+                    this.queueCode, this.read, this.result);
+            Thread thread = new Thread(this.runableCodeListMyQueues);
+            thread.start();
+        }
+    }
+
+    public void keyReleased(KeyEvent e) {
+        //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public void keyTyped(KeyEvent e) {
+        //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public void actionPerformed(ActionEvent e) {
+        if (e.getActionCommand().equals("1")) {
+            this.runableCodeListMyQueues = new RunnableListMyQueues(this.createQueue, this.queueCode, this.read,
+                    this.result, this.buttonLoad);
+            Thread thread1 = new Thread(this.runableCodeListMyQueues);
+            thread1.start();
+            this.createQueue.setEditable(true);
+            this.buttonLoad.setText("Running..");
+        }
+        if (e.getActionCommand().equals("2")) {
+            this.buttonDelete.setText("Running");
+            this.runnableCodeDequeue = new RunnableDeleteQueue(this.createQueue, this.queueCode, this.read,
+                    this.result, this.buttonDelete);
+            Thread thread2 = new Thread(this.runnableCodeDequeue);
+            thread2.start();
+        }
+    }
+
+    public void mouseDragged(MouseEvent e) {
+        String selectedText = this.result.getSelectedText();
+        this.createQueue.setText(selectedText);
+    }
+
+    public void mouseMoved(MouseEvent e) {
+        //To change body of implemented methods use File | Settings | File Templates.
+    }
+}

Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/Read.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/Read.java?rev=179743&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/Read.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/Read.java Fri Jun  3 01:12:48 2005
@@ -0,0 +1,49 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package sample.amazon.amazonSimpleQueueService;
+
+import org.apache.axis.om.*;
+import org.apache.axis.soap.SOAPFactory;
+
+/**
+ * This will create the OMElement needed to be used in invokeNonBlocking() method
+ * Reading from a give queue is done according to queue name. QueueId can also used.  
+ *
+ * @author Saminda Abeyruwan <sa...@opensource.lk>
+ */
+public class Read {
+    public static OMElement read(String requiredQueueName,String key) {
+        SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+        OMNamespace opN = factory.createOMNamespace(
+                "http://webservices.amazon.com/AWSSimpleQueueService/2005-01-01", "nsQ");
+        OMElement read = factory.createOMElement("Read", opN);
+        OMElement subID = factory.createOMElement("SubscriptionId", opN);
+        OMElement request = factory.createOMElement("Request", opN);
+        OMElement queueName = factory.createOMElement("QueueName", opN);
+        //OMElement queueID = factory.createOMElement("QueueId",opN);
+        OMElement readCount = factory.createOMElement("ReadCount", opN);
+        request.addChild(queueName);
+        //request.addChild(queueID);
+        request.addChild(readCount);
+        subID.addChild(factory.createText(key));
+        queueName.addChild(factory.createText(requiredQueueName));
+        //queueID.addChild(factory.createText(queueIden));
+        readCount.addChild(factory.createText("25"));
+        read.addChild(subID);
+        read.addChild(request);
+        return read;
+    }
+}

Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/RunGUICQ.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/RunGUICQ.java?rev=179743&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/RunGUICQ.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/RunGUICQ.java Fri Jun  3 01:12:48 2005
@@ -0,0 +1,28 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package sample.amazon.amazonSimpleQueueService;
+
+import sample.amazon.amazonSimpleQueueService.AmazonSimpleQueueServiceIn;
+
+/**
+ * @author Saminda Abeyruwan <sa...@opensource.lk>
+ */
+public class RunGUICQ {
+    public static void main(String[] args) {
+        AmazonSimpleQueueServiceIn queue = new AmazonSimpleQueueServiceIn();
+        queue.show();
+    }
+}

Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/RunGUIRQ.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/RunGUIRQ.java?rev=179743&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/RunGUIRQ.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/RunGUIRQ.java Fri Jun  3 01:12:48 2005
@@ -0,0 +1,28 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package sample.amazon.amazonSimpleQueueService;
+
+import sample.amazon.amazonSimpleQueueService.AmazonSimpleQueueServiceOut;
+
+/**
+ * @author Saminda Abeyruwan <sa...@opensource.lk>
+ */
+public class RunGUIRQ {
+    public static void main(String[] args) {
+        AmazonSimpleQueueServiceOut frame = new AmazonSimpleQueueServiceOut();
+        frame.show();
+    }
+}

Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/key.properties
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/key.properties?rev=179743&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/key.properties (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/key.properties Fri Jun  3 01:12:48 2005
@@ -0,0 +1,4 @@
+# This is the subcription Id for the Amazon Simple Queue Web Service
+# When a user need to run the sample through a new subcription Id 
+# simply changed this value of the key/value pair. 
+key=0HPJJ4GJDSG2TZ2C8X02
\ No newline at end of file

Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/QueueManager.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/QueueManager.java?rev=179743&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/QueueManager.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/QueueManager.java Fri Jun  3 01:12:48 2005
@@ -0,0 +1,47 @@
+package sample.amazon.amazonSimpleQueueService.util;
+
+import java.io.InputStream;
+import java.util.Properties;
+
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * 
+ */
+public class QueueManager {
+
+    protected String getKeyFromPropertyFile() {
+
+
+
+        Class clazz = new Object().getClass();
+        InputStream stream = clazz.getResourceAsStream("/sample/amazon/amazonSimpleQueueService/key.properties");
+        String key = null;
+
+//        String userDir = System.getProperty("user.dir");
+
+//        String keyPathName = userDir + File.separator + "modules" + File.separator + "sample"
+//                + File.separator
+//                + "properties";
+        Properties properties = new Properties();
+        try {
+            properties.load(stream);
+            key = properties.getProperty("key");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return key;
+    }
+}

Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableCreateQueue.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableCreateQueue.java?rev=179743&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableCreateQueue.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableCreateQueue.java Fri Jun  3 01:12:48 2005
@@ -0,0 +1,89 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package sample.amazon.amazonSimpleQueueService.util;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.clientapi.Call;
+import org.apache.axis.clientapi.Callback;
+import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.addressing.AddressingConstants;
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.Constants;
+
+import javax.swing.*;
+
+import sample.amazon.amazonSimpleQueueService.CreateQueue;
+import sample.amazon.amazonSimpleQueueService.Enqueue;
+import sample.amazon.amazonSimpleQueueService.CreateQueue;
+
+import java.io.File;
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * This will create the Excutable code which runs seperately of GUI interations
+ *
+ * @author Saminda Abeyruwan <sa...@opensource.lk>
+ */
+public class RunnableCreateQueue extends QueueManager implements Runnable {
+    JTextField createQueue;
+    JTextArea result;
+    JTextField queueCode;
+    JTextField enqueue;
+
+    public RunnableCreateQueue(JTextField createQueue, JTextField queueCode, JTextField enqueue,
+                               JTextArea result) {
+        this.createQueue = createQueue;
+        this.queueCode = queueCode;
+        this.enqueue = enqueue;
+        this.result = result;
+    }
+
+    public void run() {
+        if (this.createQueue.isEditable()) {
+            OMElement createQueueElement = CreateQueue.creatQueueElement(
+                    this.createQueue.getText(),getKeyFromPropertyFile());
+            this.axis2EngineRuns("CreateQueue", createQueueElement,
+                    new SimpleQueueCreateQueueCallbackHandler(this.createQueue, this.queueCode,
+                            this.enqueue, this.result));
+        }
+        if (this.enqueue.isEditable()) {
+            OMElement enqueueElement = Enqueue.enqueueElement(this.enqueue.getText(),
+                    this.queueCode.getText(),getKeyFromPropertyFile());
+            this.axis2EngineRuns("Enqueue", enqueueElement, new SimpleQueueEnqueueCallbackHandler(
+                    this.createQueue, this.queueCode, this.enqueue, this.result));
+        }
+    }
+
+    private void axis2EngineRuns(String operation, OMElement element,
+                                 Callback specificCallbackObject) {
+        //endpoint uri is hard coded....
+        String url = "http://webservices.amazon.com/onca/soap?Service=AWSSimpleQueueService";
+        try {
+            Call call = new Call();
+            call.setTo(new EndpointReference(AddressingConstants.WSA_TO, url));
+            call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, false);
+            call.invokeNonBlocking(operation, element, specificCallbackObject);
+        } catch (AxisFault axisFault) {
+            axisFault.printStackTrace();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+}

Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableDeleteQueue.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableDeleteQueue.java?rev=179743&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableDeleteQueue.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableDeleteQueue.java Fri Jun  3 01:12:48 2005
@@ -0,0 +1,79 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package sample.amazon.amazonSimpleQueueService.util;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.clientapi.Callback;
+import org.apache.axis.clientapi.Call;
+import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.addressing.AddressingConstants;
+import org.apache.axis.Constants;
+import org.apache.axis.engine.AxisFault;
+
+import javax.swing.*;
+
+import sample.amazon.amazonSimpleQueueService.DeleteQueue;
+import sample.amazon.amazonSimpleQueueService.DeleteQueue;
+
+import java.io.File;
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.util.Properties;
+
+/**
+ * This will create the Excutable code which runs seperately of GUI interations
+ *
+ * @author Saminda Abeyruwan <sa...@opensource.lk>
+ */
+public class RunnableDeleteQueue extends QueueManager implements Runnable {
+    JTextField createQueue;
+    JTextArea result;
+    JTextField queueCode;
+    JTextField read;
+    JButton button;
+
+    public RunnableDeleteQueue(JTextField createQueue, JTextField queueCode, JTextField read,
+                               JTextArea result, JButton button) {
+        this.createQueue = createQueue;
+        this.queueCode = queueCode;
+        this.read = read;
+        this.result = result;
+        this.button = button;
+    }
+
+    public void run() {
+        OMElement deleteQueueElement = DeleteQueue.deleteQueueElement(this.createQueue.getText(),getKeyFromPropertyFile());
+        this.axis2EngineRuns("DeleteQueue", deleteQueueElement,
+                new SimpleQueueDeleteQueueCallbackHandler(this.result, this.button));
+    }
+
+    private void axis2EngineRuns(String operation, OMElement element,
+                                 Callback specificCallbackObject) {
+        //endpoint uri is hard coded....
+        String url = "http://webservices.amazon.com/onca/soap?Service=AWSSimpleQueueService";
+        try {
+            Call call = new Call();
+            call.setTo(new EndpointReference(AddressingConstants.WSA_TO, url));
+            call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, false);
+            call.invokeNonBlocking(operation, element, specificCallbackObject);
+        } catch (AxisFault axisFault) {
+            axisFault.printStackTrace();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+  
+}

Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableListMyQueues.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableListMyQueues.java?rev=179743&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableListMyQueues.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableListMyQueues.java Fri Jun  3 01:12:48 2005
@@ -0,0 +1,79 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package sample.amazon.amazonSimpleQueueService.util;
+
+import javax.swing.*;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.clientapi.Callback;
+import org.apache.axis.clientapi.Call;
+import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.addressing.AddressingConstants;
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.Constants;
+import sample.amazon.amazonSimpleQueueService.ListMyQueues;
+import sample.amazon.amazonSimpleQueueService.ListMyQueues;
+
+import java.io.File;
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.util.Properties;
+
+/**
+ * This will create the Excutable code which runs seperately of GUI interations
+ *
+ * @author Saminda Abeyruwan <sa...@opensource.lk>
+ */
+public class RunnableListMyQueues extends QueueManager implements Runnable {
+    JTextField createQueue;
+    JTextArea result;
+    JTextField queueCode;
+    JTextField read;
+    JButton button;
+
+    public RunnableListMyQueues(JTextField createQueue, JTextField queueCode, JTextField read,
+                                JTextArea result, JButton button) {
+        this.createQueue = createQueue;
+        this.queueCode = queueCode;
+        this.read = read;
+        this.result = result;
+        this.button = button;
+    }
+
+    public void run() {
+        OMElement listMyQueuesElement = ListMyQueues.queueListElement(getKeyFromPropertyFile());
+        this.axis2EngineRuns("ListMyQueues", listMyQueuesElement,
+                new SimpleQueueListMyQueuesCallbackHandler(this.createQueue, this.queueCode,
+                        this.read, this.result, this.button));
+    }
+
+    private void axis2EngineRuns(String operation, OMElement element,
+                                 Callback specificCallbackObject) {
+        //endpoint uri is hard coded....
+        String url = "http://webservices.amazon.com/onca/soap?Service=AWSSimpleQueueService";
+        try {
+            Call call = new Call();
+            call.setTo(new EndpointReference(AddressingConstants.WSA_TO, url));
+            call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, false);
+            call.invokeNonBlocking(operation, element, specificCallbackObject);
+        } catch (AxisFault axisFault) {
+            axisFault.printStackTrace();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+  
+}

Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableReadQueue.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableReadQueue.java?rev=179743&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableReadQueue.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableReadQueue.java Fri Jun  3 01:12:48 2005
@@ -0,0 +1,76 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package sample.amazon.amazonSimpleQueueService.util;
+
+import javax.swing.*;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.clientapi.Callback;
+import org.apache.axis.clientapi.Call;
+import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.addressing.AddressingConstants;
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.Constants;
+import sample.amazon.amazonSimpleQueueService.Read;
+import sample.amazon.amazonSimpleQueueService.Read;
+
+import java.io.File;
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.util.Properties;
+
+/**
+ * This will create the Excutable code which runs seperately of GUI interations
+ *
+ * @author Saminda Abeyruwan <sa...@opensource.lk>
+ */
+public class RunnableReadQueue extends QueueManager implements Runnable {
+    JTextField createQueue;
+    JTextArea result;
+    JTextField queueCode;
+    JTextField read;
+
+    public RunnableReadQueue(JTextField createQueue, JTextField queueCode, JTextField read,
+                             JTextArea result) {
+        this.createQueue = createQueue;
+        this.queueCode = queueCode;
+        this.read = read;
+        this.result = result;
+    }
+
+    public void run() {
+        OMElement readQueueElement = Read.read(this.createQueue.getText(),getKeyFromPropertyFile());
+        this.axis2EngineRuns("Read", readQueueElement,
+                new SimpleQueueReadCallbackHandler(this.queueCode, this.result));
+    }
+
+    private void axis2EngineRuns(String operation, OMElement element,
+                                 Callback specificCallbackObject) {
+        //endpoint uri is hard coded....
+        String url = "http://webservices.amazon.com/onca/soap?Service=AWSSimpleQueueService";
+        try {
+            Call call = new Call();
+            call.setTo(new EndpointReference(AddressingConstants.WSA_TO, url));
+            call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, false);
+            call.invokeNonBlocking(operation, element, specificCallbackObject);
+        } catch (AxisFault axisFault) {
+            axisFault.printStackTrace();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+   
+}

Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueCreateQueueCallbackHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueCreateQueueCallbackHandler.java?rev=179743&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueCreateQueueCallbackHandler.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueCreateQueueCallbackHandler.java Fri Jun  3 01:12:48 2005
@@ -0,0 +1,101 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package sample.amazon.amazonSimpleQueueService.util;
+
+import org.apache.axis.clientapi.Callback;
+import org.apache.axis.clientapi.AsyncResult;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMNode;
+import org.apache.axis.soap.SOAPBody;
+
+import javax.swing.*;
+import java.util.Iterator;
+/**
+ * Callback class which deals with the outcome of the operation
+ *
+ * @author Saminda Abeyruwan <sa...@opensource.lk>
+ */
+public class SimpleQueueCreateQueueCallbackHandler extends Callback {
+    private static String returnString = "";
+    private JTextField createQueue;
+    private JTextArea result;
+    private JTextField queueCode;
+    private JTextField enqueue;
+
+    public SimpleQueueCreateQueueCallbackHandler() {
+    }//defaultConstructor
+
+    public SimpleQueueCreateQueueCallbackHandler(JTextField createQueue, JTextField queueCode,
+                                                 JTextField enqueue, JTextArea result) {
+        super();
+        this.createQueue = createQueue;
+        this.queueCode = queueCode;
+        this.enqueue = enqueue;
+        this.result = result;
+    }
+
+    public void onComplete(AsyncResult result) {
+        SOAPBody body = result.getResponseEnvelope().getBody();
+        getResults(body);
+    }
+
+    public void reportError(Exception e) {
+
+    }
+
+    private boolean getResults(OMElement element) {
+        Iterator iterator = element.getChildren();
+        while (iterator.hasNext()) {
+            OMNode omNode = (OMNode) iterator.next();
+            if (omNode.getType() == OMNode.ELEMENT_NODE) {
+                OMElement omElement = (OMElement) omNode;
+                if ((omElement.getLocalName().equals("Status"))
+                        || (omElement.getLocalName().equals("QueueId"))) {
+                    this.getText(omElement);
+                } else {
+                    getResults(omElement);
+                }
+            }
+        }
+        return false;
+    }
+
+    public static String getReturnString() {
+        return returnString;
+    }
+
+    private void getText(OMElement element) {
+        if (element.getLocalName().equals("Status")) {
+            this.result.setText(element.getText() + ".......");
+            if (element.getText().equals("Success")) {
+                this.enqueue.setEditable(true);
+                returnString = returnString + "Successfully Added the new Queue.." +
+                        "[" + this.createQueue.getText() + "]" + "\n";
+                this.result.setText(returnString);
+            }
+            if (element.getText().equals("Warnings")) {
+                this.enqueue.setEditable(true);
+                this.createQueue.setEditable(false);
+                returnString = returnString + "Enque the existing queue.." +
+                        "[" + this.createQueue.getText() + "]" + "..Allow Enquring data";
+                this.result.setText(returnString);
+            }
+        }
+        if (element.getLocalName().equals("QueueId")) {
+            this.queueCode.setText(element.getText());
+        }
+    }
+}
\ No newline at end of file

Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueDeleteQueueCallbackHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueDeleteQueueCallbackHandler.java?rev=179743&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueDeleteQueueCallbackHandler.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueDeleteQueueCallbackHandler.java Fri Jun  3 01:12:48 2005
@@ -0,0 +1,72 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package sample.amazon.amazonSimpleQueueService.util;
+
+import org.apache.axis.clientapi.AsyncResult;
+import org.apache.axis.clientapi.Callback;
+import org.apache.axis.soap.SOAPBody;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMNode;
+
+import javax.swing.*;
+import java.util.Iterator;
+/**
+ * Callback class which deals with the outcome of the operation
+ * @author Saminda Abeyruwan <sa...@opensource.lk>
+ *
+ */
+public class SimpleQueueDeleteQueueCallbackHandler extends Callback {
+    private String returnString = "";
+    JTextArea results;
+    JButton button;
+    public SimpleQueueDeleteQueueCallbackHandler(){}//defalut handler
+    public SimpleQueueDeleteQueueCallbackHandler(JTextArea results,JButton button){
+        super();
+        this.results = results;
+        this.button = button;
+    }
+    public void onComplete(AsyncResult result) {
+        SOAPBody body = result.getResponseEnvelope().getBody();
+        this.getQueueDeleteStatus(body);
+        this.button.setText("Delete Queue");
+    }
+    public void reportError(Exception e) {
+
+    }
+    private void getQueueDeleteStatus(OMElement element) {
+        Iterator iterator = element.getChildren();
+        while (iterator.hasNext()) {
+            OMNode omNode = (OMNode) iterator.next();
+            if (omNode.getType() == OMNode.ELEMENT_NODE) {
+                OMElement omElement = (OMElement) omNode;
+                if (omElement.getLocalName().equals("Status")) {
+                    this.readTheQueue(omElement);
+                }else{
+                    getQueueDeleteStatus(omElement);
+                }
+            }
+        }
+    }
+    private void readTheQueue(OMElement element) {
+        if (element.getText().equals("Errors")) {
+            returnString += "Queue can't be deleted, it has to be dequeued first" + "\n";
+        }
+        else{
+           returnString += "Queue is deleted" + "\n";
+        }
+        this.results.setText(returnString + "\n");
+    }
+}

Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueEnqueueCallbackHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueEnqueueCallbackHandler.java?rev=179743&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueEnqueueCallbackHandler.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueEnqueueCallbackHandler.java Fri Jun  3 01:12:48 2005
@@ -0,0 +1,94 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package sample.amazon.amazonSimpleQueueService.util;
+
+import org.apache.axis.clientapi.Callback;
+import org.apache.axis.clientapi.AsyncResult;
+import org.apache.axis.soap.SOAPBody;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMNode;
+
+import javax.swing.*;
+import java.util.Iterator;
+
+/**
+ * Callback class which deals with the outcome of the operation
+ *
+ * @author Saminda Abeyruwan <sa...@opensource.lk>
+ */
+public class SimpleQueueEnqueueCallbackHandler extends Callback {
+    private static String returnString = "";
+    private JTextField createQueue;
+    private JTextArea result;
+    private JTextField queueCode;
+    private JTextField enqueue;
+
+    public SimpleQueueEnqueueCallbackHandler() {
+    }//defaultConstructor
+
+    public SimpleQueueEnqueueCallbackHandler(JTextField createQueue, JTextField queueCode,
+                                             JTextField enqueue, JTextArea result) {
+        super();
+        this.createQueue = createQueue;
+        this.queueCode = queueCode;
+        this.enqueue = enqueue;
+        this.result = result;
+    }
+
+    public void onComplete(AsyncResult result) {
+        SOAPBody body = result.getResponseEnvelope().getBody();
+        getResults(body);
+    }
+
+    public void reportError(Exception e) {
+
+    }
+
+    private boolean getResults(OMElement element) {
+        Iterator iterator = element.getChildren();
+        while (iterator.hasNext()) {
+            OMNode omNode = (OMNode) iterator.next();
+            if (omNode.getType() == OMNode.ELEMENT_NODE) {
+                OMElement omElement = (OMElement) omNode;
+                if (omElement.getLocalName().equals("Status")) {
+                    this.getText(omElement);
+                } else {
+                    getResults(omElement);
+                }
+            }
+        }
+        return false;
+    }
+
+    public static String getReturnString() {
+        return returnString;
+    }
+
+    private void getText(OMElement element) {
+        if (element.getLocalName().equals("Status")) {
+            this.result.setText(element.getText() + ".......");
+            if (element.getText().equals("Success")) {
+                returnString = returnString + "Successfully Enqueued.." +
+                        "[" + this.enqueue.getText() + "]" + "..Queue.." + "["
+                        + this.createQueue.getText()
+                        + "]"
+                        + "\n";
+                this.result.setText(returnString);
+                this.enqueue.setText("");
+            }
+        }
+    }
+}

Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueListMyQueuesCallbackHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueListMyQueuesCallbackHandler.java?rev=179743&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueListMyQueuesCallbackHandler.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueListMyQueuesCallbackHandler.java Fri Jun  3 01:12:48 2005
@@ -0,0 +1,96 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package sample.amazon.amazonSimpleQueueService.util;
+
+import org.apache.axis.clientapi.AsyncResult;
+import org.apache.axis.clientapi.Callback;
+import org.apache.axis.soap.SOAPBody;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMNode;
+
+import javax.swing.*;
+import java.util.Iterator;
+
+/**
+ * Callback class which deals with the outcome of the operation
+ *
+ * @author Saminda Abeyruwan <sa...@opensource.lk>
+ */
+public class SimpleQueueListMyQueuesCallbackHandler extends Callback {
+    private String returnString = "Listing Available Queues......\n";
+    private JTextField createQueue;
+    private JTextArea result;
+    private JTextField queueCode;
+    private JTextField read;
+    private JButton button;
+
+    public SimpleQueueListMyQueuesCallbackHandler() {
+    }//defaultConstructor
+
+    public SimpleQueueListMyQueuesCallbackHandler(JTextField createQueue, JTextField queueCode,
+                                                  JTextField read, JTextArea result,
+                                                  JButton button) {
+        super();
+        this.createQueue = createQueue;
+        this.queueCode = queueCode;
+        this.read = read;
+        this.result = result;
+        this.button = button;
+    }
+
+    public void onComplete(AsyncResult result) {
+        SOAPBody body = result.getResponseEnvelope().getBody();
+        getResults(body);
+        this.button.setText("Load Queue");
+    }
+
+    public void reportError(Exception e) {
+
+    }
+
+    private boolean getResults(OMElement element) {
+        Iterator iterator = element.getChildren();
+        while (iterator.hasNext()) {
+            OMNode omNode = (OMNode) iterator.next();
+            if (omNode.getType() == OMNode.ELEMENT_NODE) {
+                OMElement omElement = (OMElement) omNode;
+                if ((omElement.getLocalName().equals("QueueId"))
+                        || (omElement.getLocalName().equals("QueueName"))) {
+
+                    if (omElement.getLocalName().equals("QueueId")) {
+                        this.getText(omElement);
+                    }
+                    if (omElement.getLocalName().equals("QueueName")) {
+                        this.getText(omElement);
+                    }
+
+                } else {
+                    getResults(omElement);
+                }
+            }
+        }
+        return false;
+    }
+
+    public String getReturnString() {
+        return this.returnString;
+    }
+
+    private void getText(OMElement element) {
+        returnString = returnString + element.getText() + "\n";
+        this.result.setText(returnString);
+    }
+}

Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueReadCallbackHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueReadCallbackHandler.java?rev=179743&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueReadCallbackHandler.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueReadCallbackHandler.java Fri Jun  3 01:12:48 2005
@@ -0,0 +1,65 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package sample.amazon.amazonSimpleQueueService.util;
+
+import org.apache.axis.clientapi.Callback;
+import org.apache.axis.clientapi.AsyncResult;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMNode;
+import org.apache.axis.soap.SOAPBody;
+import javax.swing.*;
+import java.util.Iterator;
+/**
+ * Callback class which deals with the outcome of the operation
+ * @author Saminda Abeyruwan <sa...@opensource.lk>
+ *
+ */
+public class SimpleQueueReadCallbackHandler extends Callback {
+    private String returnString = "";
+    JTextField queueCode;
+    JTextArea results;
+    public SimpleQueueReadCallbackHandler(){}//defalut handler
+    public SimpleQueueReadCallbackHandler(JTextField queueCode, JTextArea results){
+        super();
+        this.queueCode = queueCode;
+        this.results = results;
+    }
+    public void onComplete(AsyncResult result) {
+        SOAPBody body = result.getResponseEnvelope().getBody();
+        this.getQueueEntryBody(body);
+    }
+    public void reportError(Exception e) {
+
+    }
+    private void getQueueEntryBody(OMElement element) {
+        Iterator iterator = element.getChildren();
+        while (iterator.hasNext()) {
+            OMNode omNode = (OMNode) iterator.next();
+            if (omNode.getType() == OMNode.ELEMENT_NODE) {
+                OMElement omElement = (OMElement) omNode;
+                if (omElement.getLocalName().equals("QueueEntryBody")) {
+                    this.readTheQueue(omElement);
+                }else{
+                    getQueueEntryBody(omElement);
+                }
+            }
+        }
+    }
+    private void readTheQueue(OMElement element) {
+        returnString = returnString + element.getText() + "\n";
+        this.results.setText(returnString + "\n");
+    }
+}

Added: webservices/axis/trunk/java/modules/samples/src/sample/google/search/AsynchronousClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/google/search/AsynchronousClient.java?rev=179743&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/google/search/AsynchronousClient.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/google/search/AsynchronousClient.java Fri Jun  3 01:12:48 2005
@@ -0,0 +1,148 @@
+
+package sample.google.search;
+
+import org.apache.axis.Constants;
+import org.apache.axis.addressing.AddressingConstants;
+import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.clientapi.Call;
+import org.apache.axis.context.MessageContext;
+import org.apache.axis.description.OperationDescription;
+import org.apache.axis.engine.AxisFault;
+
+import javax.xml.namespace.QName;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Properties;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+public class AsynchronousClient {
+
+    /**
+         * Query parameter
+         */
+        protected static String search = "";
+
+        /**
+         * Query parameters sent with the last request
+         */
+        protected static String prevSearch = "";
+
+        /**
+         * Have to increase and set the start index when asking for more results
+         */
+        protected static int StartIndex = 0;
+
+        /**
+         * License key
+         */
+        protected static String key;
+
+        /** properties file to store the license key*/
+        protected static Properties prop;
+
+         /** maximum results per page */
+        protected static String maxResults = String.valueOf(2);
+
+        /**when this is set, thread sends a new request */
+        protected static boolean doSearch = false;
+
+
+
+
+
+    public static void main(String[] args) {
+
+        LinkFollower page = new LinkFollower();
+        LinkFollower.showURL = false;
+
+
+        GUIHandler gui = new GUIHandler();
+        System.out.println(search);
+        prop = new Properties();
+
+        Class clazz = new Object().getClass();
+        InputStream stream = clazz.getResourceAsStream("/sample/google/search/key.properties");
+
+
+
+
+        try {
+            prop.load(stream);
+            key = prop.getProperty("Key");
+            if (key==null) {
+                gui.setKey();
+            }
+        } catch (IOException e) {
+           e.printStackTrace();
+        }
+
+        gui.buildFrame();
+        Thread linkThread = new Thread(page);
+        Thread guiThread = new Thread(gui);
+
+        guiThread.start();
+        linkThread.start();
+        guiThread.run();
+        linkThread.run();
+
+    }
+
+    public AsynchronousClient() {
+
+    }
+
+
+    public static void sendMsg() throws AxisFault {
+
+        search.trim();
+        prevSearch = search;
+        Call call = new Call();
+        URL url = null;
+        try {
+            url = new URL("http", "api.google.com", "/search/beta2");
+            //url = new URL("http", "localhost",8080, "/search/beta2");
+        } catch (MalformedURLException e) {
+
+            e.printStackTrace();
+            System.exit(0);
+        }
+
+        call.setTo(new EndpointReference(AddressingConstants.WSA_TO, url.toString()));
+
+
+        MessageContext requestContext = ClientUtil.getMessageContext();
+        try {
+            call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, false);
+            QName opName = new QName("urn:GoogleSearch", "doGoogleSearch");
+            OperationDescription opdesc = new OperationDescription(opName);
+            call.invokeNonBlocking(opdesc, requestContext, new ClientCallbackHandler());
+        } catch (AxisFault e1) {
+            e1.printStackTrace();
+        }
+    }
+
+
+}
+
+
+

Added: webservices/axis/trunk/java/modules/samples/src/sample/google/search/ClientCallbackHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/google/search/ClientCallbackHandler.java?rev=179743&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/google/search/ClientCallbackHandler.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/google/search/ClientCallbackHandler.java Fri Jun  3 01:12:48 2005
@@ -0,0 +1,175 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package sample.google.search;
+
+
+import org.apache.axis.clientapi.AsyncResult;
+import org.apache.axis.clientapi.Callback;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMNamespace;
+import org.apache.axis.om.OMNode;
+import org.apache.axis.soap.SOAPEnvelope;
+
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.util.Iterator;
+
+/**
+ * This class implements the onComplete method extended by call back
+ * recieves the Response
+ * process the soap with OM to extract the data
+ * Find the <NavigationURL> element and get the text from it
+ *
+ * @author Gayan Asanka  (gayan@opensource.lk)
+ */
+public class ClientCallbackHandler extends Callback {
+
+    /**
+     * HTML Header to desplay snippet text
+     */
+    private String beginHTML = "<HTML><HEAD><TITLE>Wow</TITLE></HEAD><BODY>";
+
+    /**
+     * HTML footer
+     */
+    private String endHTML = "</BODY></HTML>";
+
+    /**
+     * Store the texts read by NavigationURL of soap
+     */
+    private String snippet = beginHTML;
+
+    /**
+     * Store the URLs read by snippet element of soap
+     */
+    private String strURL;
+
+    /**
+     * Store texts temperaly
+     */
+    private String tempStr;
+
+    /**
+     * method onComplete
+     *
+     * @param result
+     */
+    public void onComplete(AsyncResult result) {
+        //System.out.println("Responce message received to the ClientCallbackHandler ...");
+        AsyncResult myResult = result;
+        extractDetails(myResult);
+    }
+
+    /**
+     * method extractDetails
+     * Go through the children of soap
+     * stores requres information in variables
+     * Call to desplay the results
+     *
+     * @param result
+     */
+    private void extractDetails(AsyncResult result) {
+        Iterator iterator,iterator2;
+        OMNode node;
+        OMElement body, operation, elem;
+        SOAPEnvelope resEnvelope;
+
+        try {
+            XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(
+                    System.out);
+            result.getResponseEnvelope().serialize(writer);
+            //part.serialize(writer,false);
+            writer.flush();
+
+        } catch (XMLStreamException e) {
+           // System.out.println("Error occured after responce is received");
+            e.printStackTrace();
+        } catch (FactoryConfigurationError e) {
+            //System.out.println("Error occured after responce is received");
+            e.printStackTrace();
+        }
+        resEnvelope = result.getResponseEnvelope();
+        body = resEnvelope.getBody();
+        operation = body.getFirstElement();
+
+        String opLocalName = operation.getLocalName();
+        if (opLocalName.equals("Fault")) {
+            //System.out.println("A Fault message recieved, Check your Licence key");
+            snippet =
+                    snippet +
+                    "A Fault message recieved, Check your Licence key. Else you have reached the" +
+                    " daily limit of 1000 requests";
+        } else {
+            OMElement part = operation.getFirstElement();
+
+            iterator = part.getChildren();
+            while (iterator.hasNext()) {
+                node = (OMNode) iterator.next();
+                if (node.getType() == OMNode.ELEMENT_NODE) {
+                    elem = (OMElement) node;
+                    String str = elem.getLocalName();
+                    //System.out.println(str);
+                    if (str.equals("resultElements")) {
+                        //System.out.println("Got the Result Elements");
+                        Iterator iterator0 = elem.getChildren();
+                        while (iterator0.hasNext()) {
+                            node = (OMNode) iterator0.next();
+                            if (node.getType() == OMNode.ELEMENT_NODE) {
+                                elem = (OMElement) node;
+                                if (elem.getLocalName().equals("item")) {
+                                    iterator2 = elem.getChildren();
+                                    while (iterator2.hasNext()) {
+                                        node = (OMNode) iterator2.next();
+                                        if (node.getType() == OMNode.ELEMENT_NODE) {
+                                            elem = (OMElement) node;
+                                            String str3 = elem.getLocalName();
+                                            System.out.println(str3);
+                                            if (elem.getLocalName().equals("snippet")) {
+                                                //System.out.println("Got the snippet");
+                                                tempStr = elem.getText();
+
+                                                //System.out.println(tempStr);
+                                                snippet = snippet + tempStr;
+                                            }
+
+                                            if (elem.getLocalName().equals("URL")) {
+                                                //System.out.println("Got the URL");
+                                                strURL = elem.getText();
+                                            }
+                                        }
+                                    }
+                                }
+                                snippet = snippet + "<br> URL:-<a href=" + strURL + ">" + strURL +
+                                        "</a\n\n> <br><br>";
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        snippet = snippet + endHTML;
+        //System.out.println(snippet);
+
+        GUIHandler.showResults(snippet);
+    }
+
+    public void reportError(Exception e) {
+        //System.out.println("Error occured after responce is received3");
+        e.printStackTrace();
+    }
+}
\ No newline at end of file