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/05 15:27:29 UTC
svn commit: r180086 [1/2] - in /webservices/axis/trunk/java/modules/samples:
./ script/ script/amazonQS/ script/googleSearch/ script/googleSpellcheck/
src/sample/amazon/amazonSimpleQueueService/
src/sample/amazon/amazonSimpleQueueService/util/
src/sample/amazon/common/conf/ src/sample/amazon/search/
src/sample/google/search/ src/sample/google/spellcheck/ xdocs/amazonQS/
xdocs/amazonSearch/ xdocs/googleSearch/ xdocs/googleSpellcheck/
Author: ajith
Date: Sun Jun 5 06:27:25 2005
New Revision: 180086
URL: http://svn.apache.org/viewcvs?rev=180086&view=rev
Log:
Checking on the samples and the documentation. the maven.xml is changed to copy the bat files onto the correct places. The documentation is up and running. Needs revision however!
Added:
webservices/axis/trunk/java/modules/samples/script/
webservices/axis/trunk/java/modules/samples/script/amazonQS/
webservices/axis/trunk/java/modules/samples/script/amazonQS/run.bat
webservices/axis/trunk/java/modules/samples/script/googleSearch/
webservices/axis/trunk/java/modules/samples/script/googleSearch/run.bat
webservices/axis/trunk/java/modules/samples/script/googleSpellcheck/
webservices/axis/trunk/java/modules/samples/script/googleSpellcheck/run.bat
webservices/axis/trunk/java/modules/samples/src/sample/amazon/common/conf/key.properties
webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/
webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/AsynchronousClient.java
webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/ClientCallbackHandler.java
webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/ClientUtil.java
webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/GUIHandler.java
webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/LinkFollower.java
webservices/axis/trunk/java/modules/samples/xdocs/amazonQS/AmazonSimpleWebService.html
webservices/axis/trunk/java/modules/samples/xdocs/amazonSearch/
webservices/axis/trunk/java/modules/samples/xdocs/amazonSearch/AmazonSearch.htm
webservices/axis/trunk/java/modules/samples/xdocs/googleSearch/GoogleSearchHelp.html
webservices/axis/trunk/java/modules/samples/xdocs/googleSearch/archi.JPG (with props)
webservices/axis/trunk/java/modules/samples/xdocs/googleSearch/sceenShot1.JPG (with props)
webservices/axis/trunk/java/modules/samples/xdocs/googleSearch/screenShot2.JPG (with props)
webservices/axis/trunk/java/modules/samples/xdocs/googleSearch/screenShot3.JPG (with props)
webservices/axis/trunk/java/modules/samples/xdocs/googleSpellcheck/Google1.jpg (with props)
webservices/axis/trunk/java/modules/samples/xdocs/googleSpellcheck/GoogleSpellCheck.html
webservices/axis/trunk/java/modules/samples/xdocs/googleSpellcheck/ModeMenu.JPG (with props)
webservices/axis/trunk/java/modules/samples/xdocs/googleSpellcheck/asyncScreen.JPG (with props)
webservices/axis/trunk/java/modules/samples/xdocs/googleSpellcheck/clearMenu.JPG (with props)
webservices/axis/trunk/java/modules/samples/xdocs/googleSpellcheck/helpMenu.JPG (with props)
webservices/axis/trunk/java/modules/samples/xdocs/googleSpellcheck/settingsMenu.JPG (with props)
webservices/axis/trunk/java/modules/samples/xdocs/googleSpellcheck/syncScreen.JPG (with props)
Removed:
webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/key.properties
Modified:
webservices/axis/trunk/java/modules/samples/maven.xml
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/RunGUICQ.java
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/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/spellcheck/AsyncPanel.java
webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/FormModel.java
webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/Observer.java
webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/SuggestionForm.java
webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/SyncPanel.java
Modified: webservices/axis/trunk/java/modules/samples/maven.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/maven.xml?rev=180086&r1=180085&r2=180086&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/maven.xml (original)
+++ webservices/axis/trunk/java/modules/samples/maven.xml Sun Jun 5 06:27:25 2005
@@ -6,9 +6,9 @@
xmlns:j="jelly:core"
xmlns:maven="jelly:maven"
xmlns:deploy="deploy"
- xmlns:ant="jelly:ant">
+ xmlns:ant="jelly:ant">
<j:set var="samples.dir" value="target/samples"/>
- <postGoal name="test:compile">
+ <postGoal name="test:compile">
<mkdir dir="target/test-resources/samples/modules"/>
<mkdir dir="target/test-resources/repository-client/modules"/>
<copy file="../addressing/target/addressing.mar"
@@ -18,108 +18,120 @@
<mkdir dir="target/echo"/>
<copy file="../core/target/echo/echo.aar"
tofile="target/echo/echo.aar"/>
- </postGoal>
-
- <postGoal name="test:test">
- <attainGoal name="create-samples"/>
- </postGoal>
-
- <goal name="create-samples">
- <mkdir dir="target/samples"/>
- <mkdir dir="${samples.dir}/userguide"/>
- <attainGoal name="userguide"/>
- <attainGoal name="amazonQS"/>
- <attainGoal name="googleSearch"/>
- <attainGoal name="googleSpellcheck"/>
- </goal>
- <goal name="userguide">
- <mkdir dir="target/samples"/>
- <mkdir dir="${samples.dir}/userguide"/>
- <mkdir dir="${samples.dir}/userguide/src"/>
- <ant:copy todir="${samples.dir}/userguide/src">
- <ant:fileset dir="src">
- <ant:include name="userguide/**"/>
- </ant:fileset>
- </ant:copy>
- <jar destfile="${samples.dir}/userguide/sample.jar">
- <fileset dir="target/classes">
- <include name="userguide/**"/>
- </fileset>
- </jar>
- <jar destfile="${samples.dir}/userguide/MyService.jar">
- <fileset dir="src/userguide/example1/">
- <include name="META-INF/**"/>
- </fileset>
- <fileset dir="target/classes">
- <include name="userguide/example1/**/*.class"/>
- </fileset>
- </jar>
- <jar destfile="${samples.dir}/userguide/MyServiceWithHandler.jar">
- <fileset dir="src/userguide/example1/">
- <include name="META-INF/**"/>
- </fileset>
- <fileset dir="target/classes">
- <include name="userguide/example2/**/*.class"/>
- </fileset>
- </jar>
-
- </goal>
-
- <goal name="amazonQS">
- <mkdir dir="${samples.dir}/amazonQS"/>
- <mkdir dir="${samples.dir}/amazonQS/src"/>
- <ant:copy todir="${samples.dir}/amazonQS/src">
- <ant:fileset dir="src">
- <ant:include name="sample/amazon/amazonSimpleQueueService/**"/>
- </ant:fileset>
- </ant:copy>
- <mkdir dir="${samples.dir}/amazonQS/docs"/>
- <ant:copy todir="${samples.dir}/amazonQS/docs">
- <ant:fileset dir="xdocs/amazonQS"/>
- </ant:copy>
- <jar destfile="${samples.dir}/amazonQS/amazonQS.jar">
- <fileset dir="target/classes">
- <include name="sample/amazon/amazonSimpleQueueService/**"/>
- </fileset>
- </jar>
- </goal>
-
- <goal name="googleSearch">
- <mkdir dir="${samples.dir}/googleSearch"/>
- <mkdir dir="${samples.dir}/googleSearch/src"/>
- <ant:copy todir="${samples.dir}/googleSearch/src">
- <ant:fileset dir="src">
- <ant:include name="sample/google/search/**"/>
- </ant:fileset>
- </ant:copy>
- <mkdir dir="${samples.dir}/googleSearch/docs"/>
- <ant:copy todir="${samples.dir}/googleSearch/docs">
- <ant:fileset dir="xdocs/googleSearch"/>
- </ant:copy>
- <jar destfile="${samples.dir}/googleSearch/googleSearch.jar">
- <fileset dir="target/classes">
- <include name="sample/google/search/**"/>
- </fileset>
- </jar>
- </goal>
- <goal name="googleSpellcheck">
- <mkdir dir="${samples.dir}/googleSpellcheck"/>
- <mkdir dir="${samples.dir}/googleSpellcheck/src"/>
- <ant:copy todir="${samples.dir}/googleSpellcheck/src">
- <ant:fileset dir="src">
- <ant:include name="sample/google/spellcheck/**"/>
- </ant:fileset>
- </ant:copy>
- <mkdir dir="${samples.dir}/googleSpellcheck/docs"/>
- <ant:copy todir="${samples.dir}/googleSpellcheck/docs">
- <ant:fileset dir="xdocs/googleSpellcheck"/>
- </ant:copy>
- <jar destfile="${samples.dir}/googleSpellcheck/googleSpellcheck.jar">
- <fileset dir="target/classes">
- <include name="sample/google/spellcheck/**"/>
- </fileset>
- </jar>
- </goal>
-
+ </postGoal>
+
+ <postGoal name="test:test">
+ <attainGoal name="create-samples"/>
+ </postGoal>
+
+ <goal name="create-samples">
+ <mkdir dir="target/samples"/>
+ <mkdir dir="${samples.dir}/userguide"/>
+ <attainGoal name="userguide"/>
+ <attainGoal name="amazonQS"/>
+ <attainGoal name="googleSearch"/>
+ <attainGoal name="googleSpellcheck"/>
+ </goal>
+ <goal name="userguide">
+ <mkdir dir="target/samples"/>
+ <mkdir dir="${samples.dir}/userguide"/>
+ <mkdir dir="${samples.dir}/userguide/src"/>
+ <ant:copy todir="${samples.dir}/userguide/src">
+ <ant:fileset dir="src">
+ <ant:include name="userguide/**"/>
+ </ant:fileset>
+ </ant:copy>
+ <jar destfile="${samples.dir}/userguide/sample.jar">
+ <fileset dir="target/classes">
+ <include name="userguide/**"/>
+ </fileset>
+ </jar>
+ <jar destfile="${samples.dir}/userguide/MyService.jar">
+ <fileset dir="src/userguide/example1/">
+ <include name="META-INF/**"/>
+ </fileset>
+ <fileset dir="target/classes">
+ <include name="userguide/example1/**/*.class"/>
+ </fileset>
+ </jar>
+ <jar destfile="${samples.dir}/userguide/MyServiceWithHandler.jar">
+ <fileset dir="src/userguide/example1/">
+ <include name="META-INF/**"/>
+ </fileset>
+ <fileset dir="target/classes">
+ <include name="userguide/example2/**/*.class"/>
+ </fileset>
+ </jar>
+
+ </goal>
+ <!-- ********************************************************************************************************-->
+ <goal name="amazonQS">
+ <mkdir dir="${samples.dir}/amazonQS"/>
+ <mkdir dir="${samples.dir}/amazonQS/src"/>
+ <ant:copy todir="${samples.dir}/amazonQS/src">
+ <ant:fileset dir="src">
+ <ant:include name="sample/amazon/amazonSimpleQueueService/**"/>
+ </ant:fileset>
+ </ant:copy>
+ <mkdir dir="${samples.dir}/amazonQS/docs"/>
+ <ant:copy todir="${samples.dir}/amazonQS/docs">
+ <ant:fileset dir="xdocs/amazonQS"/>
+ </ant:copy>
+ <ant:copy todir="${samples.dir}/amazonQS">
+ <ant:fileset dir="script/amazonQS"/>
+ </ant:copy>
+ <jar destfile="${samples.dir}/amazonQS/amazonQS.jar">
+ <fileset dir="target/classes">
+ <include name="sample/amazon/amazonSimpleQueueService/**"/>
+ </fileset>
+ </jar>
+ </goal>
+ <!-- ********************************************************************************************************-->
+ <goal name="googleSearch">
+ <mkdir dir="${samples.dir}/googleSearch"/>
+ <mkdir dir="${samples.dir}/googleSearch/src"/>
+ <ant:copy todir="${samples.dir}/googleSearch/src">
+ <ant:fileset dir="src">
+ <ant:include name="sample/google/search/**"/>
+ </ant:fileset>
+ </ant:copy>
+ <mkdir dir="${samples.dir}/googleSearch/docs"/>
+ <ant:copy todir="${samples.dir}/googleSearch/docs">
+ <ant:fileset dir="xdocs/googleSearch"/>
+ </ant:copy>
+ <ant:copy todir="${samples.dir}/googleSearch">
+ <ant:fileset dir="script/googleSearch"/>
+ </ant:copy>
+ <jar destfile="${samples.dir}/googleSearch/googleSearch.jar">
+ <fileset dir="target/classes">
+ <include name="sample/google/search/**"/>
+ <include name="sample/google/common/**"/>
+ </fileset>
+ </jar>
+ </goal>
+ <!-- ********************************************************************************************************-->
+ <goal name="googleSpellcheck">
+ <mkdir dir="${samples.dir}/googleSpellcheck"/>
+ <mkdir dir="${samples.dir}/googleSpellcheck/src"/>
+ <ant:copy todir="${samples.dir}/googleSpellcheck/src">
+ <ant:fileset dir="src">
+ <ant:include name="sample/google/spellcheck/**"/>
+ </ant:fileset>
+ </ant:copy>
+ <mkdir dir="${samples.dir}/googleSpellcheck/docs"/>
+ <ant:copy todir="${samples.dir}/googleSpellcheck/docs">
+ <ant:fileset dir="xdocs/googleSpellcheck"/>
+ </ant:copy>
+ <ant:copy todir="${samples.dir}/googleSpellcheck">
+ <ant:fileset dir="script/googleSpellcheck"/>
+ </ant:copy>
+ <jar destfile="${samples.dir}/googleSpellcheck/googleSpellcheck.jar">
+ <fileset dir="target/classes">
+ <include name="sample/google/spellcheck/**"/>
+ <include name="sample/google/common/**"/>
+ </fileset>
+ </jar>
+ </goal>
+
</project>
Added: webservices/axis/trunk/java/modules/samples/script/amazonQS/run.bat
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/script/amazonQS/run.bat?rev=180086&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/script/amazonQS/run.bat (added)
+++ webservices/axis/trunk/java/modules/samples/script/amazonQS/run.bat Sun Jun 5 06:27:25 2005
@@ -0,0 +1,27 @@
+@echo off
+rem ---------------------------------------------------------------------------
+rem Start script for running the Amazon Queuing service
+rem
+rem ---------------------------------------------------------------------------
+
+rem check the AXIS_HOME environment variable
+if not "%AXIS_HOME%" == "" goto gotHome
+echo The AXIS_HOME environment variable is not defined correctly
+echo This environment variable is needed to run this program
+pause
+exit
+
+:gotHome
+if EXIST "%AXIS_HOME%\lib\axis2-M2.jar" goto okHome
+echo The AXIS_HOME environment variable seems not to point to the correct location!
+echo This environment variable is needed to run this program
+pause
+exit
+
+:okHome
+rem get the classes for the simple axis server
+set AXIS2_CLASS_PATH="%AXIS_HOME%";"%AXIS_HOME%\lib\axis2-M2.jar";"%AXIS_HOME%\lib\axis-wsdl4j-1.2.jar";"%AXIS_HOME%\lib\commons-logging-1.0.3.jar";"%AXIS_HOME%\lib\log4j-1.2.8.jar";"%AXIS_HOME%\lib\stax-1.1.1-dev.jar";"%AXIS_HOME%\lib\stax-api-1.0.jar"
+set AXIS2_CLASS_PATH=%AXIS2_CLASS_PATH%;.\amazonQS.jar
+start javaw -cp %AXIS2_CLASS_PATH% sample.amazon.amazonSimpleQueueService.RunGUICQ
+start javaw -cp %AXIS2_CLASS_PATH% sample.amazon.amazonSimpleQueueService.RunGUIRQ
+:end
\ No newline at end of file
Added: webservices/axis/trunk/java/modules/samples/script/googleSearch/run.bat
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/script/googleSearch/run.bat?rev=180086&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/script/googleSearch/run.bat (added)
+++ webservices/axis/trunk/java/modules/samples/script/googleSearch/run.bat Sun Jun 5 06:27:25 2005
@@ -0,0 +1,27 @@
+@echo off
+rem ---------------------------------------------------------------------------
+rem Start script for running the Google Search tool
+rem
+rem ---------------------------------------------------------------------------
+
+rem check the AXIS_HOME environment variable
+if not "%AXIS_HOME%" == "" goto gotHome
+echo The AXIS_HOME environment variable is not defined correctly
+echo This environment variable is needed to run this program
+pause
+exit
+
+:gotHome
+if EXIST "%AXIS_HOME%\lib\axis2-M2.jar" goto okHome
+echo The AXIS_HOME environment variable seems not to point to the correct loaction!
+echo This environment variable is needed to run this program
+pause
+exit
+
+:okHome
+rem get the classes for the simple axis server
+set AXIS2_CLASS_PATH="%AXIS_HOME%";"%AXIS_HOME%\lib\axis2-M2.jar";"%AXIS_HOME%\lib\axis-wsdl4j-1.2.jar";"%AXIS_HOME%\lib\commons-logging-1.0.3.jar";"%AXIS_HOME%\lib\log4j-1.2.8.jar";"%AXIS_HOME%\lib\stax-1.1.1-dev.jar";"%AXIS_HOME%\lib\stax-api-1.0.jar"
+set AXIS2_CLASS_PATH=%AXIS2_CLASS_PATH%;.\googleSearch.jar
+javaw -cp %AXIS2_CLASS_PATH% sample.google.search.AsynchronousClient
+
+:end
\ No newline at end of file
Added: webservices/axis/trunk/java/modules/samples/script/googleSpellcheck/run.bat
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/script/googleSpellcheck/run.bat?rev=180086&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/script/googleSpellcheck/run.bat (added)
+++ webservices/axis/trunk/java/modules/samples/script/googleSpellcheck/run.bat Sun Jun 5 06:27:25 2005
@@ -0,0 +1,27 @@
+@echo off
+rem ---------------------------------------------------------------------------
+rem Start script for running the Google spell checker
+rem
+rem ---------------------------------------------------------------------------
+
+rem check the AXIS_HOME environment variable
+if not "%AXIS_HOME%" == "" goto gotHome
+echo The AXIS_HOME environment variable is not set!
+echo This environment variable is needed to run this program
+pause
+exit
+
+:gotHome
+if EXIST "%AXIS_HOME%\lib\axis2-M2.jar" goto okHome
+echo The AXIS_HOME environment variable seems not to point to the correct loaction!
+echo This environment variable is needed to run this program
+pause
+exit
+
+:okHome
+rem get the classes for the simple axis server
+set AXIS2_CLASS_PATH="%AXIS_HOME%";"%AXIS_HOME%\lib\axis2-M2.jar";"%AXIS_HOME%\lib\axis-wsdl4j-1.2.jar";"%AXIS_HOME%\lib\commons-logging-1.0.3.jar";"%AXIS_HOME%\lib\log4j-1.2.8.jar";"%AXIS_HOME%\lib\stax-1.1.1-dev.jar";"%AXIS_HOME%\lib\stax-api-1.0.jar"
+set AXIS2_CLASS_PATH=%AXIS2_CLASS_PATH%;.\googleSpellcheck.jar
+javaw -cp %AXIS2_CLASS_PATH% sample.google.spellcheck.SuggestionForm
+
+:end
\ No newline at end of file
Modified: 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=180086&r1=180085&r2=180086&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/AmazonSimpleQueueServiceIn.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/AmazonSimpleQueueServiceIn.java Sun Jun 5 06:27:25 2005
@@ -15,8 +15,15 @@
*/
package sample.amazon.amazonSimpleQueueService;
+import sample.amazon.amazonSimpleQueueService.util.QueueManager;
+
import javax.swing.*;
import java.awt.*;
+import java.awt.event.KeyEvent;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+import java.io.IOException;
/**
* GUI which handles the IN operations of the queue
@@ -24,10 +31,12 @@
*
*/
public class AmazonSimpleQueueServiceIn extends JFrame{
+ private static final String HELP_FILE_NAME = "/docs/AmazonSimpleWebService.html";
JTextField createQueue;
JTextField queueCode;
JTextField enqueue;
JTextArea resuts;
+
public AmazonSimpleQueueServiceIn(){
this.setBounds(200,200,450,500);
this.setTitle("Amazon Simple Queue WS - In");
@@ -65,7 +74,85 @@
this.add(resultpane,cons,0,6,2,2);
createQueue.addKeyListener(new ListenersIn(createQueue,queueCode,enqueue,resuts));
enqueue.addKeyListener(new ListenersIn(createQueue,queueCode,enqueue,resuts));
+
+ AddMenuItems();
+
+ }
+
+ private void AddMenuItems() {
+ //add the menus
+ JMenuBar menuBar = new JMenuBar();
+ JMenu settingsMenu = new JMenu("Settings");
+ settingsMenu.setMnemonic(KeyEvent.VK_S);
+ JMenuItem amazonKeyMenu = new JMenuItem("Set Amazon Key",KeyEvent.VK_G);
+ amazonKeyMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, ActionEvent.CTRL_MASK));
+ amazonKeyMenu.addActionListener(new ActionListener(){
+ public void actionPerformed(ActionEvent e) {
+ setKey();
+ }
+ });
+ settingsMenu.add(amazonKeyMenu);
+
+ JMenu helpMenu = new JMenu("Help");
+ JMenuItem mnuItemHelp = new JMenuItem("Show Help");
+ helpMenu.add(mnuItemHelp);
+
+ mnuItemHelp.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ showHelp();
+ }
+ });
+
+ menuBar.add(settingsMenu);
+ menuBar.add(helpMenu);
+ setJMenuBar(menuBar);
+ }
+
+ private void setKey(){
+ String key = JOptionPane.showInputDialog(this,"Set the Amazon Key",QueueManager.getKey());
+ if (key!=null && !key.trim().equals("")){
+ QueueManager.setKey(key);
+ }
}
+
+ /**
+ * method showHelp
+ */
+ private void showHelp() {
+
+ JFrame frame= new JFrame();
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ frame.setLocation(screenSize.width/5,
+ screenSize.height/5);
+ frame.setSize(screenSize.width/2,screenSize.height/2);
+
+ BorderLayout layout = new BorderLayout();
+
+ JScrollPane jsp ;
+ JEditorPane jep;
+
+ jep = new JEditorPane();
+ //jep.addHyperlinkListener(new LinkFollower());
+ jep.setEditable(false);
+ jep.setContentType("text/html");
+
+ jsp = new JScrollPane(jep);
+
+ Container contentPane = frame.getContentPane();
+ contentPane.setLayout(layout);
+ contentPane.add(jsp, BorderLayout.CENTER);
+ String helpDoc = System.getProperty("user.dir")+HELP_FILE_NAME;
+
+ try {
+ jep.setPage(new File(helpDoc).toURL());
+ } catch (IOException e) {
+ JOptionPane.showMessageDialog(this,"Help file not detected","Help file error",JOptionPane.ERROR_MESSAGE);
+ return;
+ }
+ frame.setVisible(true);
+ }
+
+
private void add(Component c, GridBagConstraints cons, int x, int y, int w, int h){
cons.gridx = x;
cons.gridy = y;
Modified: 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=180086&r1=180085&r2=180086&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/AmazonSimpleQueueServiceOut.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/AmazonSimpleQueueServiceOut.java Sun Jun 5 06:27:25 2005
@@ -15,8 +15,15 @@
*/
package sample.amazon.amazonSimpleQueueService;
+import sample.amazon.amazonSimpleQueueService.util.QueueManager;
+
import javax.swing.*;
import java.awt.*;
+import java.awt.event.KeyEvent;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+import java.io.IOException;
/**
* GUI class which handles the OUT operations of the queue
@@ -24,6 +31,7 @@
* @author Saminda Abeyruwan <sa...@opensource.lk>
*/
public class AmazonSimpleQueueServiceOut extends JFrame {
+ private static final String HELP_FILE_NAME = "/docs/AmazonSimpleWebService.html";
JTextField createQueue;
JTextField queueCode;
JTextField read;
@@ -84,6 +92,8 @@
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));
+
+ AddMenuItems();
}
private void add(Component c, GridBagConstraints cons, int x, int y, int w, int h) {
@@ -93,4 +103,78 @@
cons.gridwidth = w;
this.getContentPane().add(c, cons);
}
+
+ private void AddMenuItems() {
+ //add the menus
+ JMenuBar menuBar = new JMenuBar();
+ JMenu settingsMenu = new JMenu("Settings");
+ settingsMenu.setMnemonic(KeyEvent.VK_S);
+ JMenuItem amazonKeyMenu = new JMenuItem("Set Amazon Key",KeyEvent.VK_G);
+ amazonKeyMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, ActionEvent.CTRL_MASK));
+ amazonKeyMenu.addActionListener(new ActionListener(){
+ public void actionPerformed(ActionEvent e) {
+ setKey();
+ }
+ });
+ settingsMenu.add(amazonKeyMenu);
+
+ JMenu helpMenu = new JMenu("Help");
+ JMenuItem mnuItemHelp = new JMenuItem("Show Help");
+ helpMenu.add(mnuItemHelp);
+
+ mnuItemHelp.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ showHelp();
+ }
+ });
+
+ menuBar.add(settingsMenu);
+ menuBar.add(helpMenu);
+ setJMenuBar(menuBar);
+ }
+
+ private void setKey(){
+ String key = JOptionPane.showInputDialog(this,"Set the Amazon Key",QueueManager.getKey());
+ if (key!=null && !key.trim().equals("")){
+ QueueManager.setKey(key);
+ }
+ }
+
+ /**
+ * method showHelp
+ */
+ private void showHelp() {
+
+ JFrame frame= new JFrame();
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ frame.setLocation(screenSize.width/5,
+ screenSize.height/5);
+ frame.setSize(screenSize.width/2,screenSize.height/2);
+
+ BorderLayout layout = new BorderLayout();
+
+ JScrollPane jsp ;
+ JEditorPane jep;
+
+ jep = new JEditorPane();
+ //jep.addHyperlinkListener(new LinkFollower());
+ jep.setEditable(false);
+ jep.setContentType("text/html");
+
+ jsp = new JScrollPane(jep);
+
+ Container contentPane = frame.getContentPane();
+ contentPane.setLayout(layout);
+ contentPane.add(jsp, BorderLayout.CENTER);
+ String helpDoc = System.getProperty("user.dir")+HELP_FILE_NAME;
+
+ try {
+ jep.setPage(new File(helpDoc).toURL());
+ } catch (IOException e) {
+ JOptionPane.showMessageDialog(this,"Help file not detected","Help file error",JOptionPane.ERROR_MESSAGE);
+ return;
+ }
+ frame.setVisible(true);
+ }
+
}
Modified: 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=180086&r1=180085&r2=180086&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/RunGUICQ.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/RunGUICQ.java Sun Jun 5 06:27:25 2005
@@ -25,4 +25,5 @@
AmazonSimpleQueueServiceIn queue = new AmazonSimpleQueueServiceIn();
queue.show();
}
+
}
Modified: 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=180086&r1=180085&r2=180086&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/QueueManager.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/QueueManager.java Sun Jun 5 06:27:25 2005
@@ -4,28 +4,28 @@
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.
- *
- *
- */
+* 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 {
+ private static String key = null;
- protected String getKeyFromPropertyFile() {
+ static{
Class clazz = new Object().getClass();
- InputStream stream = clazz.getResourceAsStream("/sample/amazon/amazonSimpleQueueService/key.properties");
- String key = null;
+ InputStream stream = clazz.getResourceAsStream("/sample/amazon/common/conf/key.properties");
Properties properties = new Properties();
try {
properties.load(stream);
@@ -33,6 +33,14 @@
} catch (Exception e) {
e.printStackTrace();
}
+
+ }
+
+ public static String getKey() {
return key;
+ }
+
+ public synchronized static void setKey(String tkey){
+ key = tkey;
}
}
Modified: 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=180086&r1=180085&r2=180086&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableCreateQueue.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableCreateQueue.java Sun Jun 5 06:27:25 2005
@@ -49,14 +49,14 @@
public void run() {
if (this.createQueue.isEditable()) {
OMElement createQueueElement = CreateQueue.creatQueueElement(
- this.createQueue.getText(),getKeyFromPropertyFile());
+ this.createQueue.getText(),getKey());
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.queueCode.getText(),getKey());
this.axis2EngineRuns("Enqueue", enqueueElement, new SimpleQueueEnqueueCallbackHandler(
this.createQueue, this.queueCode, this.enqueue, this.result));
}
Modified: 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=180086&r1=180085&r2=180086&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableDeleteQueue.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableDeleteQueue.java Sun Jun 5 06:27:25 2005
@@ -48,7 +48,7 @@
}
public void run() {
- OMElement deleteQueueElement = DeleteQueue.deleteQueueElement(this.createQueue.getText(),getKeyFromPropertyFile());
+ OMElement deleteQueueElement = DeleteQueue.deleteQueueElement(this.createQueue.getText(),getKey());
this.axis2EngineRuns("DeleteQueue", deleteQueueElement,
new SimpleQueueDeleteQueueCallbackHandler(this.result, this.button));
}
Modified: 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=180086&r1=180085&r2=180086&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableListMyQueues.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableListMyQueues.java Sun Jun 5 06:27:25 2005
@@ -48,7 +48,7 @@
}
public void run() {
- OMElement listMyQueuesElement = ListMyQueues.queueListElement(getKeyFromPropertyFile());
+ OMElement listMyQueuesElement = ListMyQueues.queueListElement(getKey());
this.axis2EngineRuns("ListMyQueues", listMyQueuesElement,
new SimpleQueueListMyQueuesCallbackHandler(this.createQueue, this.queueCode,
this.read, this.result, this.button));
Modified: 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=180086&r1=180085&r2=180086&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableReadQueue.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableReadQueue.java Sun Jun 5 06:27:25 2005
@@ -46,7 +46,7 @@
}
public void run() {
- OMElement readQueueElement = Read.read(this.createQueue.getText(),getKeyFromPropertyFile());
+ OMElement readQueueElement = Read.read(this.createQueue.getText(),getKey());
this.axis2EngineRuns("Read", readQueueElement,
new SimpleQueueReadCallbackHandler(this.queueCode, this.result));
}
Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/common/conf/key.properties
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/common/conf/key.properties?rev=180086&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/common/conf/key.properties (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/common/conf/key.properties Sun Jun 5 06:27:25 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/search/AsynchronousClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/AsynchronousClient.java?rev=180086&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/AsynchronousClient.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/AsynchronousClient.java Sun Jun 5 06:27:25 2005
@@ -0,0 +1,179 @@
+/*
+ * 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 samples.amazon.search;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.io.IOException;
+import java.io.*;
+import java.util.*;
+
+import org.apache.axis.Constants;
+import org.apache.axis.description.OperationDescription;
+import org.apache.axis.context.MessageContext;
+import org.apache.axis.addressing.AddressingConstants;
+import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.clientapi.Call;
+import org.apache.axis.engine.AxisFault;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.XMLStreamException;
+
+/**
+ * This class implements main() method and sendMsg() methods,
+ * check the availability of License key
+ * Builds call objects and set it's properties,
+ * Also keep few important variables as static and protected those frequently need by other classes
+ *
+ * @auther Gayan Asanka (gayan@opensource.lk)
+ */
+
+public class AsynchronousClient {
+
+ /**
+ * Query parameter
+ */
+ protected static String search = "";
+
+ /**
+ * Query parameters sent with the last request
+ */
+ protected static String prevSearch = "";
+
+ /**
+ * License key
+ */
+ protected static String amazonkey;
+
+ /**
+ * 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) {
+ GUIHandler gui;
+ Thread linkThread, guiThread;
+ LinkFollower page;
+ File propertyFile;
+
+ page = new LinkFollower(); //this object used to build the linkfollower thread
+ LinkFollower.showURL = false;
+ gui = new GUIHandler();
+
+ /*check the license key, if it is not there, ask user to enter the key*/
+
+ prop = new Properties();
+ try {
+ String workingDir = System.getProperty("user.dir");
+ propertyFile = new File(workingDir + File.separator + "samples" + File.separator +
+ "key.properties");
+ propertyFile.createNewFile();
+ prop.load(new FileInputStream(propertyFile));
+ amazonkey = prop.getProperty("amazonKey");
+ System.out.println("key is " + amazonkey);
+ if (amazonkey == null) {
+ gui.setKey();
+ }
+ prop = null; //Useless from now onwards
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ gui.buildFrame(); //GUI is built and desplayed
+
+ linkThread = new Thread(page);
+ guiThread = new Thread(gui);
+
+ guiThread.start();
+ linkThread.start();
+ guiThread.run(); //To listen to the GUI and send messages
+ linkThread.run(); //To detect hyperLink actions and open Simple Web Browser
+ }
+
+ /**
+ * constructor
+ */
+ public AsynchronousClient() {
+
+ }
+
+ /**
+ * Method sendMsg()
+ * build the Call Object
+ * Set the URL : To use TCP monitor comment the line where url is hard coded
+ * and uncomment the following line
+ * Get built the messageContext
+ * Invoke the sending operation
+ *
+ * @throws AxisFault
+ */
+ public static void sendMsg() throws AxisFault {
+ search.trim();
+ prevSearch = search;
+ Call call = new Call();
+ URL url = null;
+ try {
+ url = new URL("http", "soap.amazon.com", "/onca/soap?Service=AlexaWebInfoService");
+
+ /** Uncomment the folowing to use TCP Monitor, and comment the above */
+
+ //url = new URL("http", "localhost",8080, "/onca/soap?Service=AlexaWebInfoService");
+
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ call.setTo(new EndpointReference(AddressingConstants.WSA_TO, url.toString()));
+ MessageContext requestContext = ClientUtil.getMessageContext();
+ try {
+ call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, false);
+
+ System.out.println("Sending the Async message ....");
+
+ XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter
+ (System.out);
+ requestContext.getEnvelope().serialize(writer);
+ writer.flush();
+
+ System.out.println();
+ QName opName = new QName("urn:GoogleSearch", "doGoogleSearch");
+ OperationDescription opdesc = new OperationDescription(opName);
+ call.invokeNonBlocking(opdesc, requestContext, new ClientCallbackHandler());
+ } catch (AxisFault e1) {
+ e1.printStackTrace();
+ } catch (XMLStreamException e) {
+ e.printStackTrace();
+ }
+ System.out.println("Message sent and the client thread is returned....");
+ }
+}
+
+
+
+
+
Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/ClientCallbackHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/ClientCallbackHandler.java?rev=180086&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/ClientCallbackHandler.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/ClientCallbackHandler.java Sun Jun 5 06:27:25 2005
@@ -0,0 +1,190 @@
+/*
+ * 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 samples.amazon.search;
+
+import org.apache.axis.clientapi.AsyncResult;
+import org.apache.axis.clientapi.Callback;
+import org.apache.axis.om.OMElement;
+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
+ *
+ * @auther 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 URLs read by soap
+ */
+ private String strURL = beginHTML;
+
+ /**
+ * Stores the response
+ */
+ private AsyncResult myResult;
+
+ /**
+ * method onComplete
+ *
+ * @param result
+ */
+ public void onComplete(AsyncResult result) {
+ System.out.println("Responce message received to the ClientCallbackHandler ...");
+ try {
+ XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
+ result.getResponseEnvelope().serialize(writer);
+ 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();
+ }
+ myResult = result;
+ extractDetails(myResult);
+ }
+
+ /**
+ * method extractDetails
+ *
+ * @param result
+ */
+ private void extractDetails(AsyncResult result) {
+ Iterator iterator0, iterator1, iterator2, iterator3, iterator4;
+ SOAPEnvelope resEnvilop;
+ OMElement body;
+ OMElement operation;
+ OMNode node;
+ OMElement elem;
+
+ resEnvilop = result.getResponseEnvelope();
+ body = resEnvilop.getBody();
+ operation = body.getFirstElement();
+
+ String opLocalName = operation.getLocalName();
+ if (opLocalName.equals("Fault")) {
+ System.out.println("A Fault message recieved, Check your Licence key");
+ strURL =
+ strURL +
+ "A Fault message recieved, Check your Licence key. Else you have reached the " +
+ "daily limit of 1000 requests";
+ } else {
+ System.out.println("this is opera: " + operation.getLocalName());
+ iterator0 = operation.getChildren();
+
+ while (iterator0.hasNext()) {
+ node = (OMNode) iterator0.next();
+ if (node.getType() == OMNode.ELEMENT_NODE) {
+ elem = (OMElement) node;
+ String str = elem.getLocalName();
+ System.out.println(str);
+ if (str.equals("SearchResult")) {
+ System.out.println("Got Search Results");
+ iterator1 = elem.getChildren();
+ while (iterator1.hasNext()) {
+ node = (OMNode) iterator1.next();
+ if (node.getType() == OMNode.ELEMENT_NODE) {
+ elem = (OMElement) node;
+ String str1 = elem.getLocalName();
+ System.out.println(str1);
+ if (str1.equals("Alexa")) {
+ System.out.println("Got Alexa");
+ elem = elem.getFirstElement(); //elem -> websearch
+ System.out.println("Should be WebSearch " +
+ elem.getLocalName());
+ 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 (str3.equals("Results")) {
+ System.out.println("Got Results");
+ iterator3 = elem.getChildren();
+ while (iterator3.hasNext()) {
+ node = (OMNode) iterator3.next();
+ if (node.getType() == OMNode.ELEMENT_NODE) {
+ elem = (OMElement) node;
+ String str4 = elem.getLocalName();
+ System.out.println(str4);
+ if (str4.equals("Result")) {
+ iterator4 = elem.getChildren();
+ while (iterator4.hasNext()) {
+ node = (OMNode) iterator4.next();
+ if (node.getType() ==
+ OMNode.ELEMENT_NODE) {
+ elem = (OMElement) node;
+ String str5 = elem.getLocalName();
+ System.out.println(str5);
+ if (str5.equals("NavigableUrl")) {
+ String txt = elem.getText();
+ strURL = strURL +
+ "<a href= " +
+ txt +
+ ">" +
+ txt +
+ "</a><br>";
+ System.out.println(strURL);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ System.out.println("Outside of loop");
+ GUIHandler.showResults(strURL + endHTML);
+ }
+
+ public void reportError(Exception e) {
+ System.out.println("Error occured after responce is received");
+ e.printStackTrace();
+ }
+}
\ No newline at end of file
Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/ClientUtil.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/ClientUtil.java?rev=180086&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/ClientUtil.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/ClientUtil.java Sun Jun 5 06:27:25 2005
@@ -0,0 +1,126 @@
+/*
+ * 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 samples.amazon.search;
+
+import org.apache.axis.om.OMNamespace;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMAbstractFactory;
+import org.apache.axis.deployment.DeploymentException;
+import org.apache.axis.context.MessageContext;
+import org.apache.axis.context.ConfigurationContextFactory;
+import org.apache.axis.context.ConfigurationContext;
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.soap.SOAPEnvelope;
+import org.apache.axis.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() {
+ 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.buildClientEngineContext("Search");
+ } catch (DeploymentException e) {
+ e.printStackTrace();
+ }
+ try {
+ msgContext = new MessageContext(configContext);
+ } catch (AxisFault axisFault) {
+ axisFault.printStackTrace();
+ }
+ msgContext.setEnvelope(reqEnv);
+ return msgContext;
+ }
+
+
+}
+
+
+
Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/GUIHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/GUIHandler.java?rev=180086&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/GUIHandler.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/GUIHandler.java Sun Jun 5 06:27:25 2005
@@ -0,0 +1,243 @@
+/*
+ * 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 samples.amazon.search;
+
+import org.apache.axis.engine.AxisFault;
+
+import javax.swing.*;
+import java.awt.event.KeyListener;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.ActionEvent;
+import java.awt.*;
+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) {
+ System.out.println("inside");
+ int event = e.getKeyChar();
+
+ if (event == KeyEvent.VK_SPACE || event == KeyEvent.VK_ENTER) {
+ AsynchronousClient.search = textBox.getText().trim();
+ AsynchronousClient.search.trim();
+ System.out.println(textBox.getText());
+ 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 {
+ System.out.println("come to the place");
+ 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.toString().trim();
+ if (AsynchronousClient.doSearch == true) {
+
+ try {
+ AsynchronousClient.doSearch = false;
+ AsynchronousClient.sendMsg();
+
+ } catch (AxisFault axisFault) {
+ axisFault.printStackTrace();
+ }
+ }
+ try {
+ Thread.sleep(50);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+}
\ No newline at end of file
Added: webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/LinkFollower.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/LinkFollower.java?rev=180086&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/LinkFollower.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/LinkFollower.java Sun Jun 5 06:27:25 2005
@@ -0,0 +1,144 @@
+/*
+ * 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 samples.amazon.search;
+
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkListener;
+import javax.swing.*;
+import java.io.IOException;
+import java.awt.*;
+
+/**
+ * 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 == false) {
+
+ /** Window is not built yet, so build it */
+
+ buildURLWindow();
+ }
+ try {
+ currentURL = evt.getURL().toString(); //set the URL
+ System.out.println("Going to " + currentURL);
+ showURL = true; // Flag is set, thread should open the URL
+ } catch (Exception e) {
+ System.out.println("ERROR: Trouble fetching url");
+ }
+ }
+ }
+
+ /**
+ * 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 == true) {
+ this.setPage();
+ showURL = false;
+ }
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+}
+
Modified: 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=180086&r1=180085&r2=180086&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/google/search/AsynchronousClient.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/google/search/AsynchronousClient.java Sun Jun 5 06:27:25 2005
@@ -8,17 +8,11 @@
import org.apache.axis.context.MessageContext;
import org.apache.axis.description.OperationDescription;
import org.apache.axis.engine.AxisFault;
+import sample.google.common.util.PropertyLoader;
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;
-
-import sample.google.common.util.PropertyLoader;
/*
* Copyright 2001-2004 The Apache Software Foundation.
@@ -42,63 +36,51 @@
/**
* Query parameter
*/
- protected static String search = "";
+ protected String search = "";
/**
* Query parameters sent with the last request
*/
- protected static String prevSearch = "";
+ protected String prevSearch = "";
/**
* Have to increase and set the start index when asking for more results
*/
- protected static int StartIndex = 0;
+ protected int StartIndex = 0;
/**
* License key
*/
- protected static String key;
-
- /** properties file to store the license key*/
- protected static Properties prop;
+ protected String key;
/** maximum results per page */
- protected static String maxResults = String.valueOf(2);
+ protected String maxResults = String.valueOf(2);
- /**when this is set, thread sends a new request */
- protected static boolean doSearch = false;
+ private GUIHandler gui;
public static void main(String[] args) {
+ new AsynchronousClient();
+ }
+ public AsynchronousClient() {
+
+ this.key = PropertyLoader.getGoogleKey();
LinkFollower page = new LinkFollower();
LinkFollower.showURL = false;
-
-
- GUIHandler gui = new GUIHandler();
- System.out.println(search);
- key = PropertyLoader.getGoogleKey();
-
+ gui = new GUIHandler(this);
gui.buildFrame();
- Thread linkThread = new Thread(page);
- Thread guiThread = new Thread(gui);
- guiThread.start();
+ Thread linkThread = new Thread(page);
linkThread.start();
- guiThread.run();
linkThread.run();
-
- }
-
- public AsynchronousClient() {
-
}
- public static void sendMsg() throws AxisFault {
+ public synchronized void sendMsg() throws AxisFault {
search.trim();
prevSearch = search;
@@ -106,28 +88,68 @@
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();
+ 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);
- call.invokeNonBlocking(opdesc, requestContext, new ClientCallbackHandler());
+ 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;
+ }
+
}
Modified: 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=180086&r1=180085&r2=180086&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/google/search/ClientCallbackHandler.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/google/search/ClientCallbackHandler.java Sun Jun 5 06:27:25 2005
@@ -19,14 +19,10 @@
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.SOAPBody;
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;
/**
@@ -64,11 +60,19 @@
*/
private String tempStr;
+
+ private GUIHandler handler;
+
+ public ClientCallbackHandler(GUIHandler handler) {
+ this.handler = handler;
+ }
+
/**
- * method onComplete
- *
- * @param result
- */
+ * method onComplete
+ *
+ * @param result
+ */
+
public void onComplete(AsyncResult result) {
AsyncResult myResult = result;
extractDetails(myResult);
@@ -85,13 +89,14 @@
private void extractDetails(AsyncResult result) {
Iterator iterator,iterator2;
OMNode node;
- OMElement body, operation, elem;
+ SOAPBody body;
+ OMElement operation, elem;
SOAPEnvelope resEnvelope;
-
+// /////////////////////////////////////////
// try {
// XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(
// System.out);
-// result.getResponseEnvelope().serialize(writer);
+// result.getResponseEnvelope().serializeWithCache(writer);
// //part.serialize(writer,false);
// writer.flush();
//
@@ -102,14 +107,11 @@
// //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");
+ if (body.hasFault()){
snippet =
snippet +
"A Fault message recieved, Check your Licence key. Else you have reached the" +
@@ -163,7 +165,7 @@
}
}
snippet = snippet + endHTML;
- GUIHandler.showResults(snippet);
+ this.handler.showResults(snippet);
}
public void reportError(Exception e) {
Modified: webservices/axis/trunk/java/modules/samples/src/sample/google/search/ClientUtil.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/google/search/ClientUtil.java?rev=180086&r1=180085&r2=180086&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/google/search/ClientUtil.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/google/search/ClientUtil.java Sun Jun 5 06:27:25 2005
@@ -16,14 +16,17 @@
package sample.google.search;
-import org.apache.axis.om.*;
-import org.apache.axis.soap.SOAPFactory;
-import org.apache.axis.soap.SOAPEnvelope;
-import org.apache.axis.context.ConfigurationContextFactory;
import org.apache.axis.context.ConfigurationContext;
+import org.apache.axis.context.ConfigurationContextFactory;
import org.apache.axis.context.MessageContext;
-import org.apache.axis.engine.AxisFault;
import org.apache.axis.deployment.DeploymentException;
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.om.OMAbstractFactory;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMFactory;
+import org.apache.axis.om.OMNamespace;
+import org.apache.axis.soap.SOAPEnvelope;
+import org.apache.axis.soap.SOAPFactory;
/**
* Builds the MessageContext as called by AsynchronousClient
@@ -35,17 +38,18 @@
public class ClientUtil {
/** Soap request is included to this and pass it to sendMsg() in AsynchronousClient */
- static MessageContext msgContext;
+ //static MessageContext msgContext;
/**
* method getMessageContext
* @return msgContext
*/
- public static MessageContext getMessageContext() throws DeploymentException {
+ public static MessageContext getMessageContext(AsynchronousClient asyncClient) throws DeploymentException {
OMNamespace defNs;
OMElement operation;
+ MessageContext msgContext = null;
- String str_ST_index = Integer.toString(AsynchronousClient.StartIndex);
+ String str_ST_index = Integer.toString(asyncClient.getStartIndex());
defNs = OMAbstractFactory.getSOAP11Factory().createOMNamespace("", "");
SOAPFactory omFactory = OMAbstractFactory.getSOAP11Factory();
@@ -70,10 +74,10 @@
operation.addChild(getOMElement(omFactory,defNs,"safeSearch","xsd:boolean","false"));
operation.addChild(getOMElement(omFactory,defNs,"restrict","xsd:string",""));
operation.addChild(getOMElement(omFactory,defNs,"filter","xsd:boolean","true"));
- operation.addChild(getOMElement(omFactory,defNs,"maxResults","xsd:int",AsynchronousClient.maxResults));
+ operation.addChild(getOMElement(omFactory,defNs,"maxResults","xsd:int",asyncClient.getMaxResults()));
operation.addChild(getOMElement(omFactory,defNs,"start","xsd:int",str_ST_index));
- operation.addChild(getOMElement(omFactory,defNs,"q","xsd:string",AsynchronousClient.search));
- operation.addChild(getOMElement(omFactory,defNs,"key","xsd:string",AsynchronousClient.key));
+ operation.addChild(getOMElement(omFactory,defNs,"q","xsd:string",asyncClient.getSearch()));
+ operation.addChild(getOMElement(omFactory,defNs,"key","xsd:string",asyncClient.getKey()));
ConfigurationContextFactory fac = new ConfigurationContextFactory();
ConfigurationContext configContext = fac.buildClientEngineContext("doGoogleSearch");