axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dee...@apache.org
Subject svn commit: r470276 - in /webservices/axis2/branches/java/1_1/modules/samples/servicelifecycle: build.xml src/client/LibraryServiceClient.java
Date Thu, 02 Nov 2006 08:42:58 GMT
Author: deepal
Date: Thu Nov  2 00:42:57 2006
New Revision: 470276

URL: http://svn.apache.org/viewvc?view=rev&rev=470276
Log:
- making library client as an interactive client and you can just run the client using ant
run.client 

Modified:
    webservices/axis2/branches/java/1_1/modules/samples/servicelifecycle/build.xml
    webservices/axis2/branches/java/1_1/modules/samples/servicelifecycle/src/client/LibraryServiceClient.java

Modified: webservices/axis2/branches/java/1_1/modules/samples/servicelifecycle/build.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/samples/servicelifecycle/build.xml?view=diff&rev=470276&r1=470275&r2=470276
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/samples/servicelifecycle/build.xml (original)
+++ webservices/axis2/branches/java/1_1/modules/samples/servicelifecycle/build.xml Thu Nov
 2 00:42:57 2006
@@ -1,56 +1,77 @@
-<project basedir="." default="build" name="Library">
-
-    <property environment="env"/>
-    <property name="service-name" value="Library.aar"/>
-    <property name="dest.dir" value="target"/>
-
-    <property name="dest.dir.classes" value="${dest.dir}/classes"/>
-
-    <property name="dest.dir.lib" value="${dest.dir}/lib"/>
-    <property name="catalina-modules"
-              value="${env.CATALINA_HOME}/webapps/axis2/WEB-INF/services"/>
-
-    <path id="build.class.path">
-        <fileset dir="../../lib">
-            <include name="*.jar"/>
-        </fileset>
-    </path>
-
-    <target name="clean">
-        <delete dir="${dest.dir}"/>
-    </target>
-
-    <target name="prepare" depends="clean">
-
-        <mkdir dir="${dest.dir}"/>
-
-        <mkdir dir="${dest.dir.classes}"/>
-
-        <mkdir dir="${dest.dir.classes}/META-INF"/>
-
-    </target>
-
-    <target name="build" depends="prepare">
-
-        <mkdir dir="${dest.dir}"/>
-
-        <mkdir dir="${dest.dir.classes}"/>
-        <mkdir dir="${dest.dir.classes}/META-INF"/>
-
-        <copy file="src/META-INF/services.xml"
-              tofile="${dest.dir.classes}/META-INF/services.xml"
-              overwrite="true"/>
-
-        <javac debug="on" srcdir="src" destdir="${dest.dir.classes}" includes="sample/**">
-            <classpath refid="build.class.path"/>
-        </javac>
-
-        <jar basedir="${dest.dir.classes}"
-             destfile="${dest.dir}/${service-name}"/>
-
-    </target>
-    <target name="copy.to.tomcat" depends="build">
-        <copy file="${service-name}" todir="${catalina-modules}"/>
-    </target>
-
+<project basedir="." default="build" name="Library">
+
+    <property environment="env"/>
+    <property name="service-name" value="Library.aar"/>
+    <property name="dest.dir" value="target"/>
+
+    <property name="dest.dir.classes" value="${dest.dir}/classes"/>
+
+    <property name="dest.dir.lib" value="${dest.dir}/lib"/>
+    <property name="catalina-modules"
+              value="${env.CATALINA_HOME}/webapps/axis2/WEB-INF/services"/>
+
+    <path id="build.class.path">
+        <fileset dir="../../lib">
+            <include name="*.jar"/>
+        </fileset>
+    </path>
+
+    <target name="clean">
+        <delete dir="${dest.dir}"/>
+    </target>
+
+    <target name="prepare" depends="clean">
+
+        <mkdir dir="${dest.dir}"/>
+
+        <mkdir dir="${dest.dir.classes}"/>
+
+        <mkdir dir="${dest.dir.classes}/META-INF"/>
+
+    </target>
+
+    <target name="build" depends="prepare">
+
+        <mkdir dir="${dest.dir}"/>
+
+        <mkdir dir="${dest.dir.classes}"/>
+        <mkdir dir="${dest.dir.classes}/META-INF"/>
+
+        <copy file="src/META-INF/services.xml"
+              tofile="${dest.dir.classes}/META-INF/services.xml"
+              overwrite="true"/>
+
+        <javac debug="on" srcdir="src" destdir="${dest.dir.classes}" includes="sample/**">
+            <classpath refid="build.class.path"/>
+        </javac>
+
+        <jar basedir="${dest.dir.classes}"
+             destfile="${dest.dir}/${service-name}"/>
+
+    </target>
+
+    <target name="run.client" depends="prepare">
+        <mkdir dir="${dest.dir}"/>
+        <mkdir dir="${dest.dir.classes}"/>
+        <javac debug="on" srcdir="src" destdir="${dest.dir.classes}" includes="client/**">
+            <classpath>
+                <fileset dir="../../lib">
+                    <include name="*.jar"/>
+                </fileset>
+            </classpath>
+        </javac>
+
+        <java classname="client.LibraryServiceClient">
+            <classpath>
+                <pathelement location="${dest.dir.classes}"/>
+                <fileset dir="../../lib">
+                    <include name="*.jar"/>
+                </fileset>
+            </classpath>
+        </java>
+	</target>
+    <target name="copy.to.tomcat" depends="build">
+        <copy file="${dest.dir}/${service-name}" todir="${catalina-modules}"/>
+    </target>
+
 </project>

Modified: webservices/axis2/branches/java/1_1/modules/samples/servicelifecycle/src/client/LibraryServiceClient.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/samples/servicelifecycle/src/client/LibraryServiceClient.java?view=diff&rev=470276&r1=470275&r2=470276
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/samples/servicelifecycle/src/client/LibraryServiceClient.java
(original)
+++ webservices/axis2/branches/java/1_1/modules/samples/servicelifecycle/src/client/LibraryServiceClient.java
Thu Nov  2 00:42:57 2006
@@ -7,6 +7,7 @@
 import sample.servicelifecycle.bean.Book;
 
 import javax.xml.namespace.QName;
+import java.io.IOException;
 import java.util.ArrayList;
 
 /*
@@ -28,31 +29,153 @@
 */
 
 public class LibraryServiceClient {
+    private static final String USER_NAME = "-userName";
+    private static final String PASS_WORD = "-passWord";
+    private static final String ISBN = "-isbn";
+
     public static void main(String[] args) throws Exception {
-        String epr = "http://127.0.0.1:8000/axis2/services/Library";
+        LibraryServiceClient client = new LibraryServiceClient();
+        client.runClient();
+    }
+
+    public void runClient() throws Exception {
+        System.out.println("=====Welcome to Libraray client======");
+        System.out.println("                                     ");
+        System.out.println(" To list All books type 1");
+        System.out.println(" To list Available books type 2");
+        System.out.println(" To list Lend books type 3");
+        System.out.println(" To register  4  - -userName -passWord");
+        System.out.println(" To login     5 - -userName -passWord");
+        System.out.println(" To lend a book 6 - -isbn -userName   ");
+        System.out.println(" To return a book 7 - -isbn");
+        System.out.println("                                      ");
+        System.out.println("                                      ");
+        System.out.println("Enter service epr address :          ");
+        String epr = getInput();
         RPCServiceClient rpcClient = new RPCServiceClient();
         Options opts = new Options();
         opts.setTo(new EndpointReference(epr));
         rpcClient.setOptions(opts);
         LibraryServiceClient client = new LibraryServiceClient();
+        while (true) {
+            System.out.println("Type your command here : ");
+            String commandsParms = getInput();
+            if (commandsParms != null) {
+                String[] args = commandsParms.split(" ");
+                String firstarg = args[0];
+                int command = Integer.parseInt(firstarg);
+                switch (command) {
+                    case 1 : {
+                        client.listAllBook(rpcClient);
+                        break;
+                    }
+                    case 2 : {
+                        client.listAvailableBook(rpcClient);
+                        break;
+                    }
+                    case 3 : {
+                        client.listLendBook(rpcClient);
+                        break;
+                    }
+                    case 4 : {
+                        String usreName = null;
+                        String passWord = null;
+                        if (args.length < 5) {
+                            throw new Exception("No enough number of arguments");
+                        }
+                        if (USER_NAME.equals(args[1])) {
+                            usreName = args[2];
+                        } else if (USER_NAME.equals(args[3])) {
+                            usreName = args[4];
+                        }
+
+                        if (PASS_WORD.equals(args[1])) {
+                            passWord = args[2];
+                        } else if (PASS_WORD.equals(args[3])) {
+                            passWord = args[4];
+                        }
+                        client.register(usreName, passWord, rpcClient);
+                        break;
+                    }
+                    case 5 : {
+                        String usreName = null;
+                        String passWord = null;
+                        if (args.length < 5) {
+                            throw new Exception("No enough number of arguments");
+                        }
+                        if (USER_NAME.equals(args[1])) {
+                            usreName = args[2];
+                        } else if (USER_NAME.equals(args[3])) {
+                            usreName = args[4];
+                        }
+
+                        if (PASS_WORD.equals(args[1])) {
+                            passWord = args[2];
+                        } else if (PASS_WORD.equals(args[3])) {
+                            passWord = args[4];
+                        }
+                        client.login(usreName, passWord, rpcClient);
+                        break;
+                    }
+                    case 6 : {
+                        String isbn = null;
+                        String userName = null;
+                        if (args.length < 5) {
+                            throw new Exception("No enough number of arguments");
+                        }
+                        if (USER_NAME.equals(args[1])) {
+                            userName = args[2];
+                        } else if (USER_NAME.equals(args[3])) {
+                            userName = args[4];
+                        }
 
-        //TO list all the books
-        client.listAllBook(rpcClient);
-        //To register for the system
-        System.out.println(client.register("axis2", "abc", rpcClient));
-        //To login to the system
-        System.out.println(client.login("axis2", "abc", rpcClient));
-        //To lend a book
-        client.lendBook("1-56592-229-8", "axis2", rpcClient);
-        // to view the books in the lend section
-        client.listLendBook(rpcClient);
-        //list all the available books
-        client.listAvailableBook(rpcClient);
-        // returinging the book
-        client.returnBook("1-56592-229-8", rpcClient);
-        // view the lend list again
-        client.listLendBook(rpcClient);
+                        if (ISBN.equals(args[1])) {
+                            isbn = args[2];
+                        } else if (ISBN.equals(args[3])) {
+                            isbn = args[4];
+                        }
+                        client.lendBook(isbn, userName, rpcClient);
+                        break;
+                    }
+                    case 7 : {
+                        String isbn = null;
+                        if (args.length < 3) {
+                            throw new Exception("No enough number of arguments");
+                        }
+                        if (ISBN.equals(args[1])) {
+                            isbn = args[2];
+                        }
+                        client.returnBook(isbn, rpcClient);
+                        break;
+                    }
+                    case -1 : {
+                        System.exit(0);
+                    }
+                }
+            }
+        }
+
+        //  System.in.read()
+    }
+
+    //
+
+
+    private String getInput() {
+        try {
+            byte b [] = new byte [256];
+            int i = System.in.read(b);
+            String msg = "";
+            if (i != -1) {
+                msg = new String(b).substring(0, i - 1).trim();
+            }
+            return msg;
+        } catch (IOException e) {
+            System.err.println(" occurred while reading in command : " + e);
+            return null;
+        }
     }
+
 
     public void returnBook(String isbn, RPCServiceClient rpcClient) throws Exception {
         rpcClient.getOptions().setAction("urn:returnBook");



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message