You are viewing a plain text version of this content. The canonical link for it is here.
Posted to yoko-commits@incubator.apache.org by br...@apache.org on 2006/06/22 15:21:51 UTC

svn commit: r416396 - in /incubator/yoko/trunk: distribution/src/main/samples/ws/hello_world/ distribution/src/main/samples/ws/hello_world/corba/ distribution/src/main/samples/ws/hello_world/src/ distribution/src/main/samples/ws/hello_world/src/corba/ ...

Author: bravi
Date: Thu Jun 22 08:21:50 2006
New Revision: 416396

URL: http://svn.apache.org/viewvc?rev=416396&view=rev
Log:
Updated the hello_world sample.
JIRA: http://issues.apache.org/jira/browse/YOKO-54

Added:
    incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/build.xml   (with props)
    incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/
    incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/corba/
    incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/corba/client/
    incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/corba/server/
    incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/yoko/
    incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/yoko/client/
    incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/yoko/client/Client.java   (with props)
    incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/yoko/server/
    incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/yoko/server/HelloWorldImpl.java   (with props)
    incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/yoko/server/Server.java   (with props)
Removed:
    incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/corba/
    incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/yoko/
Modified:
    incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/README.txt
    incubator/yoko/trunk/distribution/src/main/samples/ws/resources/HelloWorld.wsdl
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaBinding.java

Modified: incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/README.txt
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/README.txt?rev=416396&r1=416395&r2=416396&view=diff
==============================================================================
--- incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/README.txt (original)
+++ incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/README.txt Thu Jun 22 08:21:50 2006
@@ -12,5 +12,75 @@
 javac, and java to build and run the demos, you must set the
 environment by running the script.
 
+Building and running the demo using ant
+---------------------------------------
 
+From the samples/ws/hello_world directory, the ant build script
+can be used to build and run the demo.
+
+Using either UNIX or Windows:
+
+  ant generate.corba.wsdl
+
+This will add a corba binding to the HelloWorld.wsdl & generate a 
+HelloWorld-corba.wsdl. Add a corba service to this wsdl before proceeding.
+
+<wsdl:service name="HelloWorldCORBAService">
+  <wsdl:port name="HelloWorldCORBAPort" binding="tns:HelloWorldCORBABinding">
+     <corba:address location="corbaloc::localhost:40000/hw" />
+  </wsdl:port>
+</wsdl:service>
+
+Please make sure that the address location you specify for the service & in the
+Server(yoko/server/Server.java) class matches.
+
+Then run,
+
+   ant build
+
+This will use the wsdl2java utility in celtix to generate the server & client code.
+    
+
+To remove the code generated from the WSDL file and the .class
+files, run:
+
+  ant clean
+
+
+
+Running the demo
+-----------------
+
+From the samples/ws/hello_world directory run the commands, entered on a
+single command line:
+
+For UNIX (must use forward slashes):
+    java -Djava.endorsed.dirs=<yoko-install-dir>/lib 
+        -Dceltix.config.file=file:/<yoko-install-dir>/samples/ws/hello_world/etc/corba_bus_config.xml
+        -classpath $CLASSPATH:build/classes yoko.server.Server &
+
+    java -Djava.endorsed.dirs=<yoko-install-dir>/lib 
+        -Dceltix.config.file=file:/<yoko-install-dir>/samples/ws/hello_world/etc/corba_bus_config.xml 
+        -classpath $CLASSPATH:build/classes yoko.client.Client <Name>
+
+The server process starts in the background.  After running the client,
+use the kill command to terminate the server process.
+
+For Windows (may use either forward or back slashes):
+  start 
+    java -Djava.endorsed.dirs=<yoko-install-dir>\lib 
+        -Dceltix.config.file=file:/<yoko-install-dir>\samples\ws\hello_world\etc\corba_bus_config.xml
+        -classpath %CLASSPATH%;build\classes yoko.server.Server
+
+    java -Djava.endorsed.dirs=<yoko-install-dir>\lib
+        -Dceltix.config.file=file:/<yoko-install-dir>\samples\ws\hello_world\etc\corba_bus_config.xml
+        -classpath %CLASSPATH%;build\classes yoko.client.Client <Name>
+
+A new command windows opens for the server process.  After running the
+client, terminate the server process by issuing Ctrl-C in its command window.
+
+To remove the code generated from the WSDL file and the .class
+files, either delete the build directory and its contents or run:
+
+  ant clean
 

Added: incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/build.xml
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/build.xml?rev=416396&view=auto
==============================================================================
--- incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/build.xml (added)
+++ incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/build.xml Thu Jun 22 08:21:50 2006
@@ -0,0 +1,113 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+-->
+<project name="hello world demo" default="build" basedir=".">
+
+    <property environment="env"/>
+    <property name="build.dir" location ="${basedir}/build"/>
+    <property name="build.src.dir" location ="${basedir}/build/src"/>
+    <property name="build.classes.dir" location ="${build.dir}/classes"/>
+
+    <!-- Determine yoko.home, either from the environment variable YOKO_HOME
+       - or using ../..
+       -->
+    <condition property="yoko.home" value="${env.YOKO_HOME}">
+        <isset property="env.YOKO_HOME"/>
+    </condition>
+    <property name="yoko.home" location="../../.."/>
+
+    <path id="yoko.classpath">
+        <pathelement location="${build.classes.dir}"/>
+        <pathelement location="${yoko.home}/lib/yoko.jar"/>
+    </path>
+
+    <target name="build" depends="generate.server.code, generate.client.code">
+        <javac destdir="${build.classes.dir}" debug="true">
+            <src path="${basedir}/src"/>
+            <src path="${build.src.dir}"/>
+            <classpath>
+                <path refid="yoko.classpath"/>
+                <pathelement path="${thirdparty.classpath}"/>
+            </classpath>
+        </javac>
+    </target>
+
+    <target name="generate.corba.wsdl">
+        <echo level="info" message="Generating corba binding using wsdltoidl..."/>
+        <wsdl2corba file="../resources/HelloWorld.wsdl" />
+    </target>
+
+    <target name="generate.server.code">
+        <echo level="info" message="Generating server code using wsdl2java..."/>
+        <wsdl2java file="HelloWorld-corba.wsdl" package="yoko.server" extraArgs="-server" />
+    </target>
+
+    <target name="generate.client.code">
+        <echo level="info" message="Generating client code using wsdl2java..."/>
+        <wsdl2java file="HelloWorld-corba.wsdl" package="yoko.client" extraArgs="-client" />
+    </target>
+
+    <target name="clean">
+        <delete dir="${build.classes.dir}"/>
+        <delete dir="${build.src.dir}"/>
+    </target>
+
+    <!-- move this to a common place, once we have more demos that use this -->
+    <macrodef name="wsdl2corba">
+        <attribute name="file"/>
+        <attribute name="extraArgs" default=""/>
+        <sequential>
+            <java failonerror="true" classname="org.apache.yoko.tools.WSDLToIDL" fork="yes">
+                <classpath>
+                    <path refid="yoko.classpath" />
+                </classpath>
+                <arg value="@{extraArgs}"/>
+                <arg value="-d"/>
+                <arg value="${basedir}"/>
+                <arg value="-corba"/>
+                <arg value="@{file}"/>
+            </java>
+        </sequential>
+    </macrodef>
+
+
+    <macrodef name="wsdl2java">
+        <attribute name="srcdestdir" default="${build.src.dir}"/>
+        <attribute name="destdir" default="${build.classes.dir}"/>
+        <attribute name="file"/>
+        <attribute name="bindingfile" default=""/>
+        <attribute name="package" default="NOT_SPECIFIED"/>
+        <attribute name="extraArgs" default=""/>
+        <sequential>
+            <mkdir dir="@{srcdestdir}"/>
+            <mkdir dir="@{destdir}"/>
+            <java failonerror="true" classname="org.objectweb.celtix.tools.WSDLToJava" fork="yes">
+                <classpath>
+                    <path refid="yoko.classpath" />
+                </classpath>
+                <arg line="-p"/>
+                <arg line="@{package}"/>
+                <arg value="@{extraArgs}"/>
+                <arg value="-d"/>
+                <arg value="@{srcdestdir}"/>
+                <arg value="@{file}"/>
+            </java>
+        </sequential>
+    </macrodef>
+</project>
\ No newline at end of file

Propchange: incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/build.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/build.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/build.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/yoko/client/Client.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/yoko/client/Client.java?rev=416396&view=auto
==============================================================================
--- incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/yoko/client/Client.java (added)
+++ incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/yoko/client/Client.java Thu Jun 22 08:21:50 2006
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 yoko.client;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import javax.xml.namespace.QName;
+
+public final class Client {
+
+    private static final QName SERVICE_NAME = new QName("http://schemas.apache.org/yoko/idl/HelloWorld", "HelloWorldCORBAService");
+
+    private Client() {
+    }
+
+    public static void main(String args[]) throws Exception {
+        if (args.length == 1) {
+            System.err.println("Please pass the greetMe argument.");
+            System.exit(1);
+        }
+        URL wsdlUrl = new URL("file:./HelloWorld-corba.wsdl");
+    
+        HelloWorldCORBAService ss = new HelloWorldCORBAService(wsdlUrl, SERVICE_NAME);
+        HelloWorld port = ss.getHelloWorldCORBAPort();  
+        
+
+        System.out.println("Invoking greetMe... ");
+        java.lang.String _greetMe_outparameter = port.greetMe(args[0]);
+        System.out.println("greetMe.result=" + _greetMe_outparameter);
+                
+        
+        System.exit(0);
+    }
+
+}

Propchange: incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/yoko/client/Client.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/yoko/client/Client.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/yoko/server/HelloWorldImpl.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/yoko/server/HelloWorldImpl.java?rev=416396&view=auto
==============================================================================
--- incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/yoko/server/HelloWorldImpl.java (added)
+++ incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/yoko/server/HelloWorldImpl.java Thu Jun 22 08:21:50 2006
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 yoko.server;
+
+import java.util.logging.Logger;
+import javax.jws.WebMethod;
+import javax.jws.WebResult;
+
+@javax.jws.WebService(name = "HelloWorld", serviceName = "HelloWorldCORBAService", 
+                      targetNamespace = "http://schemas.apache.org/yoko/idl/HelloWorld", 
+                      wsdlLocation = "file:./HelloWorld-corba.wsdl")
+                      
+public class HelloWorldImpl implements HelloWorld {
+
+    private static final Logger LOG = 
+        Logger.getLogger(HelloWorldImpl.class.getPackage().getName());
+
+    /* (non-Javadoc)
+     * @see yoko.server.HelloWorld#greetMe(java.lang.String  inparameter )*
+     */
+    public java.lang.String greetMe(
+        java.lang.String inparameter
+    )
+    { 
+       LOG.info("Executing operation greetMe");
+       return new java.lang.String("Hi " + inparameter);
+    }
+
+}

Propchange: incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/yoko/server/HelloWorldImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/yoko/server/HelloWorldImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/yoko/server/Server.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/yoko/server/Server.java?rev=416396&view=auto
==============================================================================
--- incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/yoko/server/Server.java (added)
+++ incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/yoko/server/Server.java Thu Jun 22 08:21:50 2006
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 yoko.server;
+
+import javax.xml.ws.Endpoint;
+
+public class Server {
+
+    protected Server() throws Exception {
+        System.out.println("Starting Server");
+
+        Object implementor = new HelloWorldImpl();
+        String address = "corbaloc::localhost:40000/hw";
+        Endpoint.publish(address, implementor);
+    }
+
+    public static void main(String args[]) throws Exception {
+        new Server();
+        System.out.println("Server ready...");
+
+        Thread.sleep(5 * 60 * 1000);
+        System.out.println("Server exiting");
+        System.exit(0);
+    }
+}

Propchange: incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/yoko/server/Server.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/yoko/server/Server.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/yoko/trunk/distribution/src/main/samples/ws/resources/HelloWorld.wsdl
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/distribution/src/main/samples/ws/resources/HelloWorld.wsdl?rev=416396&r1=416395&r2=416396&view=diff
==============================================================================
--- incubator/yoko/trunk/distribution/src/main/samples/ws/resources/HelloWorld.wsdl (original)
+++ incubator/yoko/trunk/distribution/src/main/samples/ws/resources/HelloWorld.wsdl Thu Jun 22 08:21:50 2006
@@ -46,9 +46,4 @@
       <wsdl:output name="greetMeResponse" message="tns:greetMeResponse"/>
     </wsdl:operation>
   </wsdl:portType>
-  <wsdl:service name="HelloWorldCORBAService">
-    <wsdl:port name="HelloWorldCORBAPort" binding="tns:HelloWorldCORBABinding">
-        <corba:address location="corbaloc:localhost:40000/hw"/>
-    </wsdl:port>
-  </wsdl:service>
 </wsdl:definitions>

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaBinding.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaBinding.java?rev=416396&r1=416395&r2=416396&view=diff
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaBinding.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaBinding.java Thu Jun 22 08:21:50 2006
@@ -176,7 +176,7 @@
                 if (portTypes.size() > 1) {
                     throwMultiplePortTypeException(portTypes);
                 } else {
-                    portType = (PortType) portTypes.keySet().iterator().next();
+                    portType = (PortType) portTypes.values().iterator().next();
                     interfaceNames.add(portType.getQName().getLocalPart());
                 }
                 intfs = new ArrayList<PortType>();