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 di...@apache.org on 2005/09/15 21:07:03 UTC
svn commit: r289289 [95/134] - in /webservices/axis2/trunk/java: ./ etc/
modules/addressing/ modules/addressing/src/META-INF/
modules/addressing/src/org/apache/axis2/handlers/addressing/
modules/addressing/test-resources/ modules/addressing/test/org/ap...
Modified: webservices/axis2/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueListMyQueuesCallbackHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueListMyQueuesCallbackHandler.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueListMyQueuesCallbackHandler.java (original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueListMyQueuesCallbackHandler.java Thu Sep 15 11:52:11 2005
@@ -1,96 +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.axis2.clientapi.AsyncResult;
-import org.apache.axis2.clientapi.Callback;
-import org.apache.axis2.om.OMElement;
-import org.apache.axis2.om.OMNode;
-import org.apache.axis2.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 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);
- }
-}
+/*
+* 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.axis2.clientapi.AsyncResult;
+import org.apache.axis2.clientapi.Callback;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMNode;
+import org.apache.axis2.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 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);
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueListMyQueuesCallbackHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueReadCallbackHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueReadCallbackHandler.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueReadCallbackHandler.java (original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueReadCallbackHandler.java Thu Sep 15 11:52:11 2005
@@ -1,75 +1,75 @@
-/*
-* 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.axis2.clientapi.AsyncResult;
-import org.apache.axis2.clientapi.Callback;
-import org.apache.axis2.om.OMElement;
-import org.apache.axis2.om.OMNode;
-import org.apache.axis2.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");
- }
-}
+/*
+* 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.axis2.clientapi.AsyncResult;
+import org.apache.axis2.clientapi.Callback;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMNode;
+import org.apache.axis2.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");
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueReadCallbackHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: webservices/axis2/trunk/java/modules/samples/src/sample/amazon/search/AsynchronousClient.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: webservices/axis2/trunk/java/modules/samples/src/sample/amazon/search/ClientCallbackHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/samples/src/sample/amazon/search/ClientUtil.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/src/sample/amazon/search/ClientUtil.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/amazon/search/ClientUtil.java (original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/amazon/search/ClientUtil.java Thu Sep 15 11:52:11 2005
@@ -1,138 +1,138 @@
-/*
- * 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.amazon.search;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.deployment.DeploymentException;
-import org.apache.axis2.om.OMAbstractFactory;
-import org.apache.axis2.om.OMElement;
-import org.apache.axis2.om.OMNamespace;
-import org.apache.axis2.soap.SOAPEnvelope;
-import org.apache.axis2.soap.SOAPFactory;
-
-/**
- * Builds the MessageContext as called by AsynchronousClient
- * First build the request soap envilope
- * then build a messageContext and soap envelope is attached to it
- *
- * @auther Gayan Asanka (gayan@opensource.lk)
- */
-public class ClientUtil {
-
- /**
- * Soap request is included to this and pass it to sendMsg() in AsynchronousClient
- */
- private static MessageContext msgContext;
-
- /**
- * method getMessageContext
- *
- * @return msgContext
- */
- public static MessageContext getMessageContext() throws AxisFault {
- OMNamespace namespace, nulNS;
- OMElement operation, value1, value2;
- OMElement subValue1, subValue2, subValue3, subValue4, subValue5;
-
- SOAPFactory omFactory = OMAbstractFactory.getSOAP11Factory();
- SOAPEnvelope reqEnv = omFactory.getDefaultEnvelope();
- namespace = reqEnv.declareNamespace(
- "http://schemas.xmlsoap.org/soap/envelope/",
- "SOAP-ENV");
- namespace = reqEnv.declareNamespace(
- "http://schemas.xmlsoap.org/soap/encoding/",
- "SOAP-ENC");
- namespace =
- reqEnv.declareNamespace(
- "http://www.w3.org/1999/XMLSchema-instance/", "xsi");
- namespace =
- reqEnv.declareNamespace("http://www.w3.org/2001/XMLSchema",
- "xsd");
- namespace = reqEnv.declareNamespace(
- "http://schemas.xmlsoap.org/wsdl/soap/",
- "soap");
- namespace = reqEnv.declareNamespace("http://schemas.xmlsoap.org/wsdl/",
- "wsdl");
- namespace = reqEnv.declareNamespace(
- "http://webservices.amazon.com/AWSAlexa/2005-02-01",
- "tns");
-
- nulNS = omFactory.createOMNamespace("", "");
-
- operation =
- omFactory.createOMElement("Search",
- "http://webservices.amazon.com/AWSAlexa/2005-02-01",
- "ns1");
- reqEnv.getBody().addChild(operation);
- operation.addAttribute("encordingStyle",
- "http://schemas.xmlsoap.org/soap/encoding/",
- null);
-
-
- value1 = omFactory.createOMElement("SubscriptionId", nulNS);
- value1.addChild(omFactory.createText(AsynchronousClient.amazonkey));
- //this is a valid sample key :- "0Y6WJGPB6TW8AVAHGFR2"));
-
- value2 = omFactory.createOMElement("Request", nulNS);
-
- subValue1 = omFactory.createOMElement("ResponseGroup", nulNS);
- subValue1.addChild(omFactory.createText("Web"));
-
- subValue2 = omFactory.createOMElement("Query", nulNS);
- subValue2.addChild(omFactory.createText(AsynchronousClient.search));
-
- subValue3 = omFactory.createOMElement("Count", nulNS);
- subValue3.addChild(omFactory.createText(AsynchronousClient.maxResults));
-
- subValue4 = omFactory.createOMElement("IgnoreWords", nulNS);
- subValue4.addChild(omFactory.createText("90"));
-
- subValue5 = omFactory.createOMElement("AdultFilter", nulNS);
- subValue5.addChild(omFactory.createText("yes"));
-
- value2.addChild(subValue5);
- value2.addChild(subValue4);
- value2.addChild(subValue3);
- value2.addChild(subValue2);
- value2.addChild(subValue1);
- operation.addChild(value2);
- operation.addChild(value1);
-
- ConfigurationContextFactory fac = new ConfigurationContextFactory();
- ConfigurationContext configContext = null;
- try {
- configContext = fac.buildClientConfigurationContext("Search");
- } catch (DeploymentException e) {
- e.printStackTrace();
- }
- try {
- msgContext = new MessageContext(configContext);
- } catch (AxisFault axisFault) {
- axisFault.printStackTrace();
- }
- msgContext.setEnvelope(reqEnv);
- return msgContext;
- }
-
-
-}
-
-
-
+/*
+ * 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.amazon.search;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.deployment.DeploymentException;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMNamespace;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.axis2.soap.SOAPFactory;
+
+/**
+ * Builds the MessageContext as called by AsynchronousClient
+ * First build the request soap envilope
+ * then build a messageContext and soap envelope is attached to it
+ *
+ * @auther Gayan Asanka (gayan@opensource.lk)
+ */
+public class ClientUtil {
+
+ /**
+ * Soap request is included to this and pass it to sendMsg() in AsynchronousClient
+ */
+ private static MessageContext msgContext;
+
+ /**
+ * method getMessageContext
+ *
+ * @return msgContext
+ */
+ public static MessageContext getMessageContext() throws AxisFault {
+ OMNamespace namespace, nulNS;
+ OMElement operation, value1, value2;
+ OMElement subValue1, subValue2, subValue3, subValue4, subValue5;
+
+ SOAPFactory omFactory = OMAbstractFactory.getSOAP11Factory();
+ SOAPEnvelope reqEnv = omFactory.getDefaultEnvelope();
+ namespace = reqEnv.declareNamespace(
+ "http://schemas.xmlsoap.org/soap/envelope/",
+ "SOAP-ENV");
+ namespace = reqEnv.declareNamespace(
+ "http://schemas.xmlsoap.org/soap/encoding/",
+ "SOAP-ENC");
+ namespace =
+ reqEnv.declareNamespace(
+ "http://www.w3.org/1999/XMLSchema-instance/", "xsi");
+ namespace =
+ reqEnv.declareNamespace("http://www.w3.org/2001/XMLSchema",
+ "xsd");
+ namespace = reqEnv.declareNamespace(
+ "http://schemas.xmlsoap.org/wsdl/soap/",
+ "soap");
+ namespace = reqEnv.declareNamespace("http://schemas.xmlsoap.org/wsdl/",
+ "wsdl");
+ namespace = reqEnv.declareNamespace(
+ "http://webservices.amazon.com/AWSAlexa/2005-02-01",
+ "tns");
+
+ nulNS = omFactory.createOMNamespace("", "");
+
+ operation =
+ omFactory.createOMElement("Search",
+ "http://webservices.amazon.com/AWSAlexa/2005-02-01",
+ "ns1");
+ reqEnv.getBody().addChild(operation);
+ operation.addAttribute("encordingStyle",
+ "http://schemas.xmlsoap.org/soap/encoding/",
+ null);
+
+
+ value1 = omFactory.createOMElement("SubscriptionId", nulNS);
+ value1.addChild(omFactory.createText(AsynchronousClient.amazonkey));
+ //this is a valid sample key :- "0Y6WJGPB6TW8AVAHGFR2"));
+
+ value2 = omFactory.createOMElement("Request", nulNS);
+
+ subValue1 = omFactory.createOMElement("ResponseGroup", nulNS);
+ subValue1.addChild(omFactory.createText("Web"));
+
+ subValue2 = omFactory.createOMElement("Query", nulNS);
+ subValue2.addChild(omFactory.createText(AsynchronousClient.search));
+
+ subValue3 = omFactory.createOMElement("Count", nulNS);
+ subValue3.addChild(omFactory.createText(AsynchronousClient.maxResults));
+
+ subValue4 = omFactory.createOMElement("IgnoreWords", nulNS);
+ subValue4.addChild(omFactory.createText("90"));
+
+ subValue5 = omFactory.createOMElement("AdultFilter", nulNS);
+ subValue5.addChild(omFactory.createText("yes"));
+
+ value2.addChild(subValue5);
+ value2.addChild(subValue4);
+ value2.addChild(subValue3);
+ value2.addChild(subValue2);
+ value2.addChild(subValue1);
+ operation.addChild(value2);
+ operation.addChild(value1);
+
+ ConfigurationContextFactory fac = new ConfigurationContextFactory();
+ ConfigurationContext configContext = null;
+ try {
+ configContext = fac.buildClientConfigurationContext("Search");
+ } catch (DeploymentException e) {
+ e.printStackTrace();
+ }
+ try {
+ msgContext = new MessageContext(configContext);
+ } catch (AxisFault axisFault) {
+ axisFault.printStackTrace();
+ }
+ msgContext.setEnvelope(reqEnv);
+ return msgContext;
+ }
+
+
+}
+
+
+
Propchange: webservices/axis2/trunk/java/modules/samples/src/sample/amazon/search/ClientUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/samples/src/sample/amazon/search/GUIHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/src/sample/amazon/search/GUIHandler.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/amazon/search/GUIHandler.java (original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/amazon/search/GUIHandler.java Thu Sep 15 11:52:11 2005
@@ -1,248 +1,248 @@
-/*
- * 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.amazon.search;
-
-import org.apache.axis2.AxisFault;
-
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.io.*;
-
-/**
- * Build and desplay the GUI
- * implements both KeyListner and ActionListner
- * KeyListner is used to detect space or Enter key at textField
- * ActionListner is used for menu cammands
- * Thread is run to isolate the GUI from internal actions
- *
- * @auther Gayan Asanka (gayan@opensource.lk)
- */
-public class GUIHandler implements KeyListener, ActionListener, Runnable {
-
- /**
- * Results are desplayed here
- */
- private static JEditorPane text;
-
- /**
- * Query parameters typed here
- */
- private static JTextField textBox;
-
- /**
- * Menu command to set the key
- */
- private static JMenuItem mnuKey;
-
- /**
- * menu commant to set the maximum results per page
- */
- private static JMenuItem mnuMaxResults;
-
- /**
- * Build the GUI using awt and swing components
- */
- public void buildFrame() {
- JFrame frame;
- SpringLayout layout;
- JMenuBar menuBar;
- JMenu setMenu;
- Spring hSpring, wSpring, xSpring, ySpring;
-
- frame = new JFrame("Amazon Web Search");
- layout = new SpringLayout();
- Container pane = frame.getContentPane();
- pane.setLayout(layout);
-
- menuBar = new JMenuBar();
- frame.setJMenuBar(menuBar);
- setMenu = new JMenu("Set"); // Create Set menu
- menuBar.add(setMenu);
- setMenu.addActionListener(this);
-
- mnuKey = new JMenuItem("Key");
- mnuMaxResults = new JMenuItem("Results per Page");
-
- setMenu.add(mnuKey);
- setMenu.add(mnuMaxResults);
-
- mnuKey.addActionListener(this);
- mnuMaxResults.addActionListener(this);
-
- Toolkit theKit = frame.getToolkit(); // Get the window toolkit
- Dimension wndSize = theKit.getScreenSize(); // Get screen size
- // Set the position to screen center and appropriate size
- frame.setBounds(wndSize.width / 6, wndSize.height / 10, // Position
- wndSize.width * 3 / 5, wndSize.height * 3 / 4); // Size
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-
- text = new JEditorPane();
- text.setEditable(false);
- text.setContentType("text/html");
- text.addHyperlinkListener(new LinkFollower());
-
- JScrollPane scroll = new JScrollPane(text, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
- JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
- pane.add(scroll);
-
- textBox = new JTextField();
- textBox.addKeyListener(this);
- pane.add(textBox);
-
- SpringLayout.Constraints textBoxConstraints = layout.getConstraints(
- textBox);
- xSpring = Spring.constant(0); // Spring well use for X
- ySpring = Spring.constant(0); // Spring well use for Y
- wSpring = Spring.constant(frame.getBounds().width); // Spring well use for width
- hSpring = Spring.constant(30); // Strut well use for height
- textBoxConstraints.setWidth(wSpring); // Set component width constraint
- textBoxConstraints.setHeight(hSpring);
- textBoxConstraints.setX(xSpring); // Set the WEST edge constraint
- textBoxConstraints.setY(ySpring);
-
- SpringLayout.Constraints scrollConstraints = layout.getConstraints(
- scroll);
- xSpring = Spring.constant(0); // Spring well use for X
- ySpring = Spring.constant(30); // Spring well use for Y
- wSpring = Spring.constant(frame.getBounds().width); // Spring well use for width
- hSpring = Spring.constant(500); // Strut well use for height
- scrollConstraints.setWidth(wSpring); // Set component width constraint
- scrollConstraints.setHeight(hSpring);
- scrollConstraints.setX(xSpring); // Set the WEST edge constraint
- scrollConstraints.setY(ySpring); // Set the NORTH edge constraint
-
- frame.setVisible(true);
- }
-
- /**
- * method showResults
- * desplay results by ClientCallbackHandler
- *
- * @param results
- */
- protected static void showResults(String results) {
- text.setText(results);
- }
-
- /**
- * method setKey
- * Get the key from user via an inputDialog and
- * store it in the properties file
- */
- protected void setKey() {
- AsynchronousClient.amazonkey =
- JOptionPane.showInputDialog(null, "Enter the license Key");
- if (AsynchronousClient.amazonkey == null) {
- setKey();
- }
- OutputStream propOut;
- try {
- String workingDir = System.getProperty("user.dir");
- File propertyFile = new File(workingDir + File.separator +
- "samples" +
- File.separator +
- "/key.properties");
- propOut = new FileOutputStream(propertyFile);
-
- AsynchronousClient.prop.setProperty("amazonKey",
- AsynchronousClient.amazonkey);
- AsynchronousClient.prop.store(propOut, "License Key");
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * method keyTyped
- * fires when user typing in TextField textBox
- * act when detects space and Enter key only
- *
- * @param e
- */
- public void keyTyped(KeyEvent e) {
- int event = e.getKeyChar();
-
- if (event == KeyEvent.VK_SPACE || event == KeyEvent.VK_ENTER) {
- AsynchronousClient.search = textBox.getText().trim();
- AsynchronousClient.search.trim();
- if (!AsynchronousClient.prevSearch.equals(
- AsynchronousClient.search)) {
- AsynchronousClient.doSearch = true;
- }
- }
- }
-
- public void keyPressed(KeyEvent e) {
- }
-
- public void keyReleased(KeyEvent s) {
- }
-
- /**
- * method actionPerformed
- * Detects menu click events
- *
- * @param e
- */
- public void actionPerformed(ActionEvent e) {
- if (e.getSource() == mnuMaxResults) {
- do {
- AsynchronousClient.maxResults =
- JOptionPane.showInputDialog(null,
- "Enter the number of maximum results per page (Maximum allowed is 1000)");
- //JOptionPane.get
-
- } while (Integer.parseInt(AsynchronousClient.maxResults) > 1000 ||
- Integer.parseInt(AsynchronousClient.maxResults) < 0);
- }
- if (e.getSource() == mnuKey) {
- setKey();
- }
- }
-
- /**
- * method run
- * check the flag doSearch
- * if it's set, call sendMsg method
- */
- public void run() {
- while (true) {
- AsynchronousClient.search.trim();
- if (AsynchronousClient.doSearch) {
-
- try {
- AsynchronousClient.doSearch = false;
- AsynchronousClient.sendMsg();
-
- } catch (AxisFault axisFault) {
- axisFault.printStackTrace();
- }
- }
- try {
- Thread.sleep(50);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
+/*
+ * 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.amazon.search;
+
+import org.apache.axis2.AxisFault;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.io.*;
+
+/**
+ * Build and desplay the GUI
+ * implements both KeyListner and ActionListner
+ * KeyListner is used to detect space or Enter key at textField
+ * ActionListner is used for menu cammands
+ * Thread is run to isolate the GUI from internal actions
+ *
+ * @auther Gayan Asanka (gayan@opensource.lk)
+ */
+public class GUIHandler implements KeyListener, ActionListener, Runnable {
+
+ /**
+ * Results are desplayed here
+ */
+ private static JEditorPane text;
+
+ /**
+ * Query parameters typed here
+ */
+ private static JTextField textBox;
+
+ /**
+ * Menu command to set the key
+ */
+ private static JMenuItem mnuKey;
+
+ /**
+ * menu commant to set the maximum results per page
+ */
+ private static JMenuItem mnuMaxResults;
+
+ /**
+ * Build the GUI using awt and swing components
+ */
+ public void buildFrame() {
+ JFrame frame;
+ SpringLayout layout;
+ JMenuBar menuBar;
+ JMenu setMenu;
+ Spring hSpring, wSpring, xSpring, ySpring;
+
+ frame = new JFrame("Amazon Web Search");
+ layout = new SpringLayout();
+ Container pane = frame.getContentPane();
+ pane.setLayout(layout);
+
+ menuBar = new JMenuBar();
+ frame.setJMenuBar(menuBar);
+ setMenu = new JMenu("Set"); // Create Set menu
+ menuBar.add(setMenu);
+ setMenu.addActionListener(this);
+
+ mnuKey = new JMenuItem("Key");
+ mnuMaxResults = new JMenuItem("Results per Page");
+
+ setMenu.add(mnuKey);
+ setMenu.add(mnuMaxResults);
+
+ mnuKey.addActionListener(this);
+ mnuMaxResults.addActionListener(this);
+
+ Toolkit theKit = frame.getToolkit(); // Get the window toolkit
+ Dimension wndSize = theKit.getScreenSize(); // Get screen size
+ // Set the position to screen center and appropriate size
+ frame.setBounds(wndSize.width / 6, wndSize.height / 10, // Position
+ wndSize.width * 3 / 5, wndSize.height * 3 / 4); // Size
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ text = new JEditorPane();
+ text.setEditable(false);
+ text.setContentType("text/html");
+ text.addHyperlinkListener(new LinkFollower());
+
+ JScrollPane scroll = new JScrollPane(text, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+ pane.add(scroll);
+
+ textBox = new JTextField();
+ textBox.addKeyListener(this);
+ pane.add(textBox);
+
+ SpringLayout.Constraints textBoxConstraints = layout.getConstraints(
+ textBox);
+ xSpring = Spring.constant(0); // Spring well use for X
+ ySpring = Spring.constant(0); // Spring well use for Y
+ wSpring = Spring.constant(frame.getBounds().width); // Spring well use for width
+ hSpring = Spring.constant(30); // Strut well use for height
+ textBoxConstraints.setWidth(wSpring); // Set component width constraint
+ textBoxConstraints.setHeight(hSpring);
+ textBoxConstraints.setX(xSpring); // Set the WEST edge constraint
+ textBoxConstraints.setY(ySpring);
+
+ SpringLayout.Constraints scrollConstraints = layout.getConstraints(
+ scroll);
+ xSpring = Spring.constant(0); // Spring well use for X
+ ySpring = Spring.constant(30); // Spring well use for Y
+ wSpring = Spring.constant(frame.getBounds().width); // Spring well use for width
+ hSpring = Spring.constant(500); // Strut well use for height
+ scrollConstraints.setWidth(wSpring); // Set component width constraint
+ scrollConstraints.setHeight(hSpring);
+ scrollConstraints.setX(xSpring); // Set the WEST edge constraint
+ scrollConstraints.setY(ySpring); // Set the NORTH edge constraint
+
+ frame.setVisible(true);
+ }
+
+ /**
+ * method showResults
+ * desplay results by ClientCallbackHandler
+ *
+ * @param results
+ */
+ protected static void showResults(String results) {
+ text.setText(results);
+ }
+
+ /**
+ * method setKey
+ * Get the key from user via an inputDialog and
+ * store it in the properties file
+ */
+ protected void setKey() {
+ AsynchronousClient.amazonkey =
+ JOptionPane.showInputDialog(null, "Enter the license Key");
+ if (AsynchronousClient.amazonkey == null) {
+ setKey();
+ }
+ OutputStream propOut;
+ try {
+ String workingDir = System.getProperty("user.dir");
+ File propertyFile = new File(workingDir + File.separator +
+ "samples" +
+ File.separator +
+ "/key.properties");
+ propOut = new FileOutputStream(propertyFile);
+
+ AsynchronousClient.prop.setProperty("amazonKey",
+ AsynchronousClient.amazonkey);
+ AsynchronousClient.prop.store(propOut, "License Key");
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * method keyTyped
+ * fires when user typing in TextField textBox
+ * act when detects space and Enter key only
+ *
+ * @param e
+ */
+ public void keyTyped(KeyEvent e) {
+ int event = e.getKeyChar();
+
+ if (event == KeyEvent.VK_SPACE || event == KeyEvent.VK_ENTER) {
+ AsynchronousClient.search = textBox.getText().trim();
+ AsynchronousClient.search.trim();
+ if (!AsynchronousClient.prevSearch.equals(
+ AsynchronousClient.search)) {
+ AsynchronousClient.doSearch = true;
+ }
+ }
+ }
+
+ public void keyPressed(KeyEvent e) {
+ }
+
+ public void keyReleased(KeyEvent s) {
+ }
+
+ /**
+ * method actionPerformed
+ * Detects menu click events
+ *
+ * @param e
+ */
+ public void actionPerformed(ActionEvent e) {
+ if (e.getSource() == mnuMaxResults) {
+ do {
+ AsynchronousClient.maxResults =
+ JOptionPane.showInputDialog(null,
+ "Enter the number of maximum results per page (Maximum allowed is 1000)");
+ //JOptionPane.get
+
+ } while (Integer.parseInt(AsynchronousClient.maxResults) > 1000 ||
+ Integer.parseInt(AsynchronousClient.maxResults) < 0);
+ }
+ if (e.getSource() == mnuKey) {
+ setKey();
+ }
+ }
+
+ /**
+ * method run
+ * check the flag doSearch
+ * if it's set, call sendMsg method
+ */
+ public void run() {
+ while (true) {
+ AsynchronousClient.search.trim();
+ if (AsynchronousClient.doSearch) {
+
+ try {
+ AsynchronousClient.doSearch = false;
+ AsynchronousClient.sendMsg();
+
+ } catch (AxisFault axisFault) {
+ axisFault.printStackTrace();
+ }
+ }
+ try {
+ Thread.sleep(50);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
}
Propchange: webservices/axis2/trunk/java/modules/samples/src/sample/amazon/search/GUIHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/samples/src/sample/amazon/search/LinkFollower.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/src/sample/amazon/search/LinkFollower.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/amazon/search/LinkFollower.java (original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/amazon/search/LinkFollower.java Thu Sep 15 11:52:11 2005
@@ -1,143 +1,143 @@
-/*
- * 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.amazon.search;
-
-import javax.swing.*;
-import javax.swing.event.HyperlinkEvent;
-import javax.swing.event.HyperlinkListener;
-import java.awt.*;
-import java.io.IOException;
-
-/**
- * class LinkFollower
- * Listen to HyperLink actions and Open Simple web browser to open URLs
- *
- * @auther Gayan Asanka (gayan@opensource.lk)
- */
-class LinkFollower implements HyperlinkListener, Runnable {
-
- /**
- * Flag to used by the thread, If set, thread opens a URL in the Simple Web Browser
- */
- protected static boolean showURL = false;
-
- /**
- * Used as the root of the Simple web Browser, only one instance is needed
- */
- private static JFrame f;
-
- /**
- * Used for the Simple web Browser, only one instance is needed
- */
- private static JPanel contentPane;
- private static JEditorPane jep;
- private static JScrollPane scrollPane;
-
- /**
- * Flag to prevent duplicating Building of the Simple web browser Window
- */
- private static boolean builded = false;
-
- /**
- * Keep the URL of the last Hyperlink click event
- */
- private static String currentURL;
-
- /**
- * Constructor
- */
- public LinkFollower() {
-
- }
-
- /**
- * method hyperlinkUpdate
- * The action is to show the page of the URL the user clicked on.
- *
- * @param evt the event. We only care when its type is ACTIVATED.
- */
- public void hyperlinkUpdate(HyperlinkEvent evt) {
- if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
- if (!builded) {
-
- /** Window is not built yet, so build it */
-
- buildURLWindow();
- }
- try {
- currentURL = evt.getURL().toString(); //set the URL
- showURL = true; // Flag is set, thread should open the URL
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- /**
- * method setPage
- * Open the URL in the simple web browser window by replacing the previous one
- */
- protected void setPage() {
- jep.setEditable(false);
- jep.addHyperlinkListener(new LinkFollower());
- f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
-
- contentPane.setLayout(new BorderLayout());
- contentPane.setPreferredSize(new Dimension(400, 100));
- contentPane.add(scrollPane, BorderLayout.CENTER);
-
- f.pack();
- f.setSize(640, 360);
- f.setVisible(true);
- try {
- jep.setPage(currentURL);
- } catch (IOException e) {
- System.err.println(e);
- }
- }
-
- /**
- * method buildURLWindow
- * Build the Simple Web Broser but not displayed
- */
- private void buildURLWindow() {
- builded = true;
- jep = new JEditorPane();
- f = new JFrame("Simple Web Browser");
- contentPane = (JPanel) f.getContentPane();
- scrollPane = new JScrollPane(jep);
- }
-
- /**
- * method run
- * check the showURL flag and if set, open the url in simple Web Browser
- */
- public void run() {
- while (true) {
- if (showURL) {
- this.setPage();
- showURL = false;
- }
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
-}
-
+/*
+ * 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.amazon.search;
+
+import javax.swing.*;
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkListener;
+import java.awt.*;
+import java.io.IOException;
+
+/**
+ * class LinkFollower
+ * Listen to HyperLink actions and Open Simple web browser to open URLs
+ *
+ * @auther Gayan Asanka (gayan@opensource.lk)
+ */
+class LinkFollower implements HyperlinkListener, Runnable {
+
+ /**
+ * Flag to used by the thread, If set, thread opens a URL in the Simple Web Browser
+ */
+ protected static boolean showURL = false;
+
+ /**
+ * Used as the root of the Simple web Browser, only one instance is needed
+ */
+ private static JFrame f;
+
+ /**
+ * Used for the Simple web Browser, only one instance is needed
+ */
+ private static JPanel contentPane;
+ private static JEditorPane jep;
+ private static JScrollPane scrollPane;
+
+ /**
+ * Flag to prevent duplicating Building of the Simple web browser Window
+ */
+ private static boolean builded = false;
+
+ /**
+ * Keep the URL of the last Hyperlink click event
+ */
+ private static String currentURL;
+
+ /**
+ * Constructor
+ */
+ public LinkFollower() {
+
+ }
+
+ /**
+ * method hyperlinkUpdate
+ * The action is to show the page of the URL the user clicked on.
+ *
+ * @param evt the event. We only care when its type is ACTIVATED.
+ */
+ public void hyperlinkUpdate(HyperlinkEvent evt) {
+ if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
+ if (!builded) {
+
+ /** Window is not built yet, so build it */
+
+ buildURLWindow();
+ }
+ try {
+ currentURL = evt.getURL().toString(); //set the URL
+ showURL = true; // Flag is set, thread should open the URL
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * method setPage
+ * Open the URL in the simple web browser window by replacing the previous one
+ */
+ protected void setPage() {
+ jep.setEditable(false);
+ jep.addHyperlinkListener(new LinkFollower());
+ f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+
+ contentPane.setLayout(new BorderLayout());
+ contentPane.setPreferredSize(new Dimension(400, 100));
+ contentPane.add(scrollPane, BorderLayout.CENTER);
+
+ f.pack();
+ f.setSize(640, 360);
+ f.setVisible(true);
+ try {
+ jep.setPage(currentURL);
+ } catch (IOException e) {
+ System.err.println(e);
+ }
+ }
+
+ /**
+ * method buildURLWindow
+ * Build the Simple Web Broser but not displayed
+ */
+ private void buildURLWindow() {
+ builded = true;
+ jep = new JEditorPane();
+ f = new JFrame("Simple Web Browser");
+ contentPane = (JPanel) f.getContentPane();
+ scrollPane = new JScrollPane(jep);
+ }
+
+ /**
+ * method run
+ * check the showURL flag and if set, open the url in simple Web Browser
+ */
+ public void run() {
+ while (true) {
+ if (showURL) {
+ this.setPage();
+ showURL = false;
+ }
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+}
+
Propchange: webservices/axis2/trunk/java/modules/samples/src/sample/amazon/search/LinkFollower.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/samples/src/sample/axisversion/META-INF/service.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/src/sample/axisversion/META-INF/service.xml?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/axisversion/META-INF/service.xml (original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/axisversion/META-INF/service.xml Thu Sep 15 11:52:11 2005
@@ -1,8 +1,8 @@
-<service name="Version">
- <description>
- This servics is to get the running Axis version
- </description>
- <parameter name="ServiceClass" locked="false">sample.axisversion.Version</parameter>
- <operation name="getVersion">
- </operation>
+<service name="Version">
+ <description>
+ This servics is to get the running Axis version
+ </description>
+ <parameter name="ServiceClass" locked="false">sample.axisversion.Version</parameter>
+ <operation name="getVersion">
+ </operation>
</service>
Propchange: webservices/axis2/trunk/java/modules/samples/src/sample/axisversion/META-INF/service.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/samples/src/sample/axisversion/Version.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/src/sample/axisversion/Version.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/axisversion/Version.java (original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/axisversion/Version.java Thu Sep 15 11:52:11 2005
@@ -1,42 +1,42 @@
-package sample.axisversion;
-
-import org.apache.axis2.om.OMAbstractFactory;
-import org.apache.axis2.om.OMElement;
-import org.apache.axis2.om.OMFactory;
-import org.apache.axis2.om.OMNamespace;
-
-/*
- * 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.
- *
- *
- */
-
-/**
- * Author : Deepal Jayasinghe
- * Date: Jun 7, 2005
- * Time: 1:19:11 PM
- */
-public class Version {
-
- public OMElement getVersion() {
- OMFactory fac = OMAbstractFactory.getOMFactory();
- OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
- OMElement version = fac.createOMElement("Version", omNs);
- version.addChild(
- fac.createText(version,
- "Hello I am Axis2 versionning service , My version is Axis2 0.91 !! "));
- return version;
- }
-}
+package sample.axisversion;
+
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMFactory;
+import org.apache.axis2.om.OMNamespace;
+
+/*
+ * 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.
+ *
+ *
+ */
+
+/**
+ * Author : Deepal Jayasinghe
+ * Date: Jun 7, 2005
+ * Time: 1:19:11 PM
+ */
+public class Version {
+
+ public OMElement getVersion() {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
+ OMElement version = fac.createOMElement("Version", omNs);
+ version.addChild(
+ fac.createText(version,
+ "Hello I am Axis2 versionning service , My version is Axis2 0.91 !! "));
+ return version;
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/samples/src/sample/axisversion/Version.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/samples/src/sample/google/common/util/PropertyLoader.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/src/sample/google/common/util/PropertyLoader.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/google/common/util/PropertyLoader.java (original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/google/common/util/PropertyLoader.java Thu Sep 15 11:52:11 2005
@@ -1,65 +1,65 @@
-package sample.google.common.util;
-
-import java.io.IOException;
-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 PropertyLoader {
-
- private static String googleKey;
- private static String googleEndpointURL;
- private static String googleEndpointServiceName;
-
- static {
- try {
- Properties prop = new Properties();
- Class clazz = Object.class;
- InputStream stream = clazz.getResourceAsStream(
- "/sample/google/common/conf/key.properties");
- prop.load(stream);
-
- googleKey = prop.getProperty("google.key");
- googleEndpointURL = prop.getProperty("google.url");
- googleEndpointServiceName = prop.getProperty("google.name");
-
- } catch (IOException e) {
- System.exit(0);
- }
-
- }
-
- public static String getGoogleKey() {
- return googleKey;
- }
-
- public static String getGoogleEndpointURL() {
- return googleEndpointURL;
- }
-
- public static String getGoogleEndpointServiceName() {
- return googleEndpointServiceName;
- }
-
- public static void setGoogleKey(String googleKey) {
- PropertyLoader.googleKey = googleKey;
- }
-
-}
+package sample.google.common.util;
+
+import java.io.IOException;
+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 PropertyLoader {
+
+ private static String googleKey;
+ private static String googleEndpointURL;
+ private static String googleEndpointServiceName;
+
+ static {
+ try {
+ Properties prop = new Properties();
+ Class clazz = Object.class;
+ InputStream stream = clazz.getResourceAsStream(
+ "/sample/google/common/conf/key.properties");
+ prop.load(stream);
+
+ googleKey = prop.getProperty("google.key");
+ googleEndpointURL = prop.getProperty("google.url");
+ googleEndpointServiceName = prop.getProperty("google.name");
+
+ } catch (IOException e) {
+ System.exit(0);
+ }
+
+ }
+
+ public static String getGoogleKey() {
+ return googleKey;
+ }
+
+ public static String getGoogleEndpointURL() {
+ return googleEndpointURL;
+ }
+
+ public static String getGoogleEndpointServiceName() {
+ return googleEndpointServiceName;
+ }
+
+ public static void setGoogleKey(String googleKey) {
+ PropertyLoader.googleKey = googleKey;
+ }
+
+}
Propchange: webservices/axis2/trunk/java/modules/samples/src/sample/google/common/util/PropertyLoader.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/samples/src/sample/google/search/AsynchronousClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/src/sample/google/search/AsynchronousClient.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/google/search/AsynchronousClient.java (original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/google/search/AsynchronousClient.java Thu Sep 15 11:52:11 2005
@@ -1,157 +1,157 @@
-package sample.google.search;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.clientapi.Call;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.OperationDescription;
-import sample.google.common.util.PropertyLoader;
-import javax.xml.namespace.QName;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-/*
-* 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 String search = "";
-
- /**
- * Query parameters sent with the last request
- */
- protected String prevSearch = "";
-
- /**
- * Have to increase and set the start index when asking for more results
- */
- protected int StartIndex = 0;
-
- /**
- * License key
- */
- protected String key;
-
- /**
- * maximum results per page
- */
- protected String maxResults = String.valueOf(10);
-
-
- private GUIHandler gui;
-
-
- public static void main(String[] args) {
- new AsynchronousClient();
- }
-
- public AsynchronousClient() {
-
- this.key = PropertyLoader.getGoogleKey();
- LinkFollower page = new LinkFollower();
- LinkFollower.showURL = false;
- gui = new GUIHandler(this);
- gui.buildFrame();
-
- Thread linkThread = new Thread(page);
- linkThread.start();
- linkThread.run();
- }
-
-
- public synchronized 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://127.0.0.1:8080/axis2/services/axisversion/viewVersion");
- } catch (MalformedURLException e) {
- e.printStackTrace();
- System.exit(0);
- }
-
- call.setTo(
- new EndpointReference(url.toString()));
-
- MessageContext requestContext = ClientUtil.getMessageContext(this);
- try {
- call.setTransportInfo(Constants.TRANSPORT_HTTP,
- Constants.TRANSPORT_HTTP,
- false);
- QName opName = new QName("urn:GoogleSearch", "doGoogleSearch");
- OperationDescription opdesc = new OperationDescription(opName);
- // OperationDescription opdesc = new OperationDescription(new QName("viewVersion"));
- call.invokeNonBlocking(opdesc,
- requestContext,
- new ClientCallbackHandler(this.gui));
-
- } catch (AxisFault e1) {
- e1.printStackTrace();
- }
- }
-
- public String getSearch() {
- return search;
- }
-
- public String getPrevSearch() {
- return prevSearch;
- }
-
- public int getStartIndex() {
- return StartIndex;
- }
-
- public String getKey() {
- return key;
- }
-
- public String getMaxResults() {
- return maxResults;
- }
-
-
- public void setSearch(String search) {
- this.search = search;
- }
-
- public void setPrevSearch(String prevSearch) {
- this.prevSearch = prevSearch;
- }
-
- public void setStartIndex(int startIndex) {
- StartIndex = startIndex;
- }
-
- public void setKey(String key) {
- this.key = key;
- }
-
- public void setMaxResults(String maxResults) {
- this.maxResults = maxResults;
- }
-
-
-}
-
-
-
+package sample.google.search;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.clientapi.Call;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.OperationDescription;
+import sample.google.common.util.PropertyLoader;
+import javax.xml.namespace.QName;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/*
+* 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 String search = "";
+
+ /**
+ * Query parameters sent with the last request
+ */
+ protected String prevSearch = "";
+
+ /**
+ * Have to increase and set the start index when asking for more results
+ */
+ protected int StartIndex = 0;
+
+ /**
+ * License key
+ */
+ protected String key;
+
+ /**
+ * maximum results per page
+ */
+ protected String maxResults = String.valueOf(10);
+
+
+ private GUIHandler gui;
+
+
+ public static void main(String[] args) {
+ new AsynchronousClient();
+ }
+
+ public AsynchronousClient() {
+
+ this.key = PropertyLoader.getGoogleKey();
+ LinkFollower page = new LinkFollower();
+ LinkFollower.showURL = false;
+ gui = new GUIHandler(this);
+ gui.buildFrame();
+
+ Thread linkThread = new Thread(page);
+ linkThread.start();
+ linkThread.run();
+ }
+
+
+ public synchronized 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://127.0.0.1:8080/axis2/services/axisversion/viewVersion");
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ System.exit(0);
+ }
+
+ call.setTo(
+ new EndpointReference(url.toString()));
+
+ MessageContext requestContext = ClientUtil.getMessageContext(this);
+ try {
+ call.setTransportInfo(Constants.TRANSPORT_HTTP,
+ Constants.TRANSPORT_HTTP,
+ false);
+ QName opName = new QName("urn:GoogleSearch", "doGoogleSearch");
+ OperationDescription opdesc = new OperationDescription(opName);
+ // OperationDescription opdesc = new OperationDescription(new QName("viewVersion"));
+ call.invokeNonBlocking(opdesc,
+ requestContext,
+ new ClientCallbackHandler(this.gui));
+
+ } catch (AxisFault e1) {
+ e1.printStackTrace();
+ }
+ }
+
+ public String getSearch() {
+ return search;
+ }
+
+ public String getPrevSearch() {
+ return prevSearch;
+ }
+
+ public int getStartIndex() {
+ return StartIndex;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public String getMaxResults() {
+ return maxResults;
+ }
+
+
+ public void setSearch(String search) {
+ this.search = search;
+ }
+
+ public void setPrevSearch(String prevSearch) {
+ this.prevSearch = prevSearch;
+ }
+
+ public void setStartIndex(int startIndex) {
+ StartIndex = startIndex;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public void setMaxResults(String maxResults) {
+ this.maxResults = maxResults;
+ }
+
+
+}
+
+
+
Propchange: webservices/axis2/trunk/java/modules/samples/src/sample/google/search/AsynchronousClient.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/samples/src/sample/google/search/ClientCallbackHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/src/sample/google/search/ClientCallbackHandler.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/google/search/ClientCallbackHandler.java (original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/google/search/ClientCallbackHandler.java Thu Sep 15 11:52:11 2005
@@ -1,178 +1,178 @@
-/*
- * 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.axis2.clientapi.AsyncResult;
-import org.apache.axis2.clientapi.Callback;
-import org.apache.axis2.om.OMElement;
-import org.apache.axis2.om.OMNode;
-import org.apache.axis2.soap.SOAPBody;
-import org.apache.axis2.soap.SOAPEnvelope;
-
-import java.util.Iterator;
-
-/**
- * This class implements the onComplete method extended by call back
- * receives 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;
-
-
- private GUIHandler handler;
-
- public ClientCallbackHandler(GUIHandler handler) {
- this.handler = handler;
- }
-
- /**
- * method onComplete
- *
- * @param result
- */
-
- public void onComplete(AsyncResult result) {
- extractDetails(result);
- }
-
- /**
- * 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;
- SOAPBody body;
- OMElement operation, elem;
- SOAPEnvelope resEnvelope;
-// /////////////////////////////////////////
-// try {
-// XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(
-// System.out);
-// result.getResponseEnvelope().serializeWithCache(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();
- if (body.hasFault()) {
- snippet =
- snippet +
- "A Fault message received, 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();
- 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;
- this.handler.showResults(snippet);
- }
-
- public void reportError(Exception e) {
- e.printStackTrace();
- }
+/*
+ * 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.axis2.clientapi.AsyncResult;
+import org.apache.axis2.clientapi.Callback;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMNode;
+import org.apache.axis2.soap.SOAPBody;
+import org.apache.axis2.soap.SOAPEnvelope;
+
+import java.util.Iterator;
+
+/**
+ * This class implements the onComplete method extended by call back
+ * receives 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;
+
+
+ private GUIHandler handler;
+
+ public ClientCallbackHandler(GUIHandler handler) {
+ this.handler = handler;
+ }
+
+ /**
+ * method onComplete
+ *
+ * @param result
+ */
+
+ public void onComplete(AsyncResult result) {
+ extractDetails(result);
+ }
+
+ /**
+ * 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;
+ SOAPBody body;
+ OMElement operation, elem;
+ SOAPEnvelope resEnvelope;
+// /////////////////////////////////////////
+// try {
+// XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(
+// System.out);
+// result.getResponseEnvelope().serializeWithCache(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();
+ if (body.hasFault()) {
+ snippet =
+ snippet +
+ "A Fault message received, 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();
+ 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;
+ this.handler.showResults(snippet);
+ }
+
+ public void reportError(Exception e) {
+ e.printStackTrace();
+ }
}
Propchange: webservices/axis2/trunk/java/modules/samples/src/sample/google/search/ClientCallbackHandler.java
------------------------------------------------------------------------------
svn:eol-style = native