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 dm...@apache.org on 2006/06/22 19:47:49 UTC
svn commit: r416454 - in
/incubator/yoko/trunk/distribution/src/main/samples: orb/ orb/hello_world/
orb/hello_world/src/ orb/hello_world/src/corba/
orb/hello_world/src/corba/client/ orb/hello_world/src/corba/server/
orb/resources/ ws/hello_world/src/co...
Author: dmiddlem
Date: Thu Jun 22 12:47:48 2006
New Revision: 416454
URL: http://svn.apache.org/viewvc?rev=416454&view=rev
Log:
Adding a corba implementation of the yoko Hello World demo
Added:
incubator/yoko/trunk/distribution/src/main/samples/orb/
incubator/yoko/trunk/distribution/src/main/samples/orb/hello_world/
incubator/yoko/trunk/distribution/src/main/samples/orb/hello_world/build.xml
incubator/yoko/trunk/distribution/src/main/samples/orb/hello_world/src/
incubator/yoko/trunk/distribution/src/main/samples/orb/hello_world/src/corba/
incubator/yoko/trunk/distribution/src/main/samples/orb/hello_world/src/corba/client/
incubator/yoko/trunk/distribution/src/main/samples/orb/hello_world/src/corba/client/Client.java
incubator/yoko/trunk/distribution/src/main/samples/orb/hello_world/src/corba/server/
incubator/yoko/trunk/distribution/src/main/samples/orb/hello_world/src/corba/server/HelloWorldImpl.java
incubator/yoko/trunk/distribution/src/main/samples/orb/hello_world/src/corba/server/Server.java
incubator/yoko/trunk/distribution/src/main/samples/orb/resources/
incubator/yoko/trunk/distribution/src/main/samples/orb/resources/HelloWorld.idl
incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/corba/client/Client.java
incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/corba/server/HelloWorldImpl.java
incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/corba/server/Server.java
Added: incubator/yoko/trunk/distribution/src/main/samples/orb/hello_world/build.xml
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/distribution/src/main/samples/orb/hello_world/build.xml?rev=416454&view=auto
==============================================================================
--- incubator/yoko/trunk/distribution/src/main/samples/orb/hello_world/build.xml (added)
+++ incubator/yoko/trunk/distribution/src/main/samples/orb/hello_world/build.xml Thu Jun 22 12:47:48 2006
@@ -0,0 +1,67 @@
+<!--
+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="ORB 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="../../../../../.."/>
+
+ <target name="init">
+ <mkdir dir="build/src"/>
+ <mkdir dir="build/classes"/>
+ </target>
+
+ <target name="build" depends="init, generate.server.code, generate.client.code">
+ <javac destdir="${build.classes.dir}" debug="true">
+ <src path="${basedir}/src"/>
+ <src path="${build.src.dir}"/>
+ <classpath>
+ <path path="${yoko.home}/core/target/yoko-core-1.0-incubating-M1-SNAPSHOT.jar"/>
+ </classpath>
+ </javac>
+ </target>
+
+ <target name="generate.client.code">
+ <echo level="info" message="Generating client code using idlj..."/>
+ <exec executable="idlj" dir=".">
+ <arg line="-fall -td ${build.src.dir} -pkgPrefix HelloWorld corba.client ../resources/HelloWorld.idl"/>
+ </exec>
+ </target>
+
+ <target name="generate.server.code">
+ <echo level="info" message="Generating server code using idlj..."/>
+ <exec executable="idlj" dir=".">
+ <arg line="-fall -td ${build.src.dir} -pkgPrefix HelloWorld corba.server ../resources/HelloWorld.idl"/>
+ </exec>
+ </target>
+
+ <target name="clean">
+ <delete dir="${build.classes.dir}"/>
+ <delete dir="${build.src.dir}"/>
+ </target>
+</project>
Added: incubator/yoko/trunk/distribution/src/main/samples/orb/hello_world/src/corba/client/Client.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/distribution/src/main/samples/orb/hello_world/src/corba/client/Client.java?rev=416454&view=auto
==============================================================================
--- incubator/yoko/trunk/distribution/src/main/samples/orb/hello_world/src/corba/client/Client.java (added)
+++ incubator/yoko/trunk/distribution/src/main/samples/orb/hello_world/src/corba/client/Client.java Thu Jun 22 12:47:48 2006
@@ -0,0 +1,78 @@
+/**
+ * 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 corba.client;
+
+import java.util.Properties;
+
+import org.omg.CORBA.Object;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.UserException;
+
+public class Client {
+ static int run(ORB orb, String[] args) throws UserException {
+
+ // Get "hello" object
+ Object obj = orb.string_to_object("corbaloc::localhost:40000/hw");
+ if(obj == null) {
+ System.err.println("Client: Could not resolve target object");
+ return 1;
+ }
+
+ HelloWorld hello = HelloWorldHelper.narrow(obj);
+
+ // Test our narrowed "hello" object
+ System.out.println("Invoking greetMe...");
+ String result = hello.greetMe(new String());
+ System.out.println("greetMe.result = " + result);
+
+ return 0;
+ }
+
+ // Standalone program initialization
+ public static void main(String args[]) {
+ int status = 0;
+ ORB orb = null;
+
+ Properties props = System.getProperties();
+ props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
+ props.put("org.omg.CORBA.ORBSingletonClass",
+ "org.apache.yoko.orb.CORBA.ORBSingleton");
+ props.put("yoko.orb.id", "HelloWorld-Client");
+
+ try {
+ orb = ORB.init(args, props);
+ status = run(orb, args);
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ status = 1;
+ }
+
+ if(orb != null) {
+ try {
+ orb.destroy();
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ status = 1;
+ }
+ }
+
+ System.exit(status);
+ }
+}
Added: incubator/yoko/trunk/distribution/src/main/samples/orb/hello_world/src/corba/server/HelloWorldImpl.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/distribution/src/main/samples/orb/hello_world/src/corba/server/HelloWorldImpl.java?rev=416454&view=auto
==============================================================================
--- incubator/yoko/trunk/distribution/src/main/samples/orb/hello_world/src/corba/server/HelloWorldImpl.java (added)
+++ incubator/yoko/trunk/distribution/src/main/samples/orb/hello_world/src/corba/server/HelloWorldImpl.java Thu Jun 22 12:47:48 2006
@@ -0,0 +1,39 @@
+/**
+ * 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 corba.server;
+
+import org.omg.PortableServer.POA;
+
+public class HelloWorldImpl extends HelloWorldPOA {
+ // The servants default POA
+ private POA poa_;
+
+ HelloWorldImpl(POA poa) {
+ poa_ = poa;
+ }
+
+ public String greetMe(String inparameter) {
+ return new String("Hi " + inparameter);
+ }
+
+ public POA _default_POA() {
+ return poa_;
+ }
+}
Added: incubator/yoko/trunk/distribution/src/main/samples/orb/hello_world/src/corba/server/Server.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/distribution/src/main/samples/orb/hello_world/src/corba/server/Server.java?rev=416454&view=auto
==============================================================================
--- incubator/yoko/trunk/distribution/src/main/samples/orb/hello_world/src/corba/server/Server.java (added)
+++ incubator/yoko/trunk/distribution/src/main/samples/orb/hello_world/src/corba/server/Server.java Thu Jun 22 12:47:48 2006
@@ -0,0 +1,97 @@
+/**
+ * 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 corba.server;
+
+import java.util.Properties;
+
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.UserException;
+import org.omg.CORBA.ORBPackage.InvalidName;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.POAHelper;
+import org.omg.PortableServer.POAManager;
+
+import org.apache.yoko.orb.OB.BootManager;
+import org.apache.yoko.orb.OB.BootManagerHelper;
+import org.apache.yoko.orb.OB.BootManagerPackage.AlreadyExists;
+
+public class Server {
+ static int run(ORB orb, String[] args) throws UserException {
+ // Resolve Root POA
+ POA rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
+
+ // Get a reference to the POA manager
+ POAManager manager = rootPOA.the_POAManager();
+
+ // Create implementation object
+ HelloWorldImpl hwImpl = new HelloWorldImpl(rootPOA);
+ HelloWorld hello = hwImpl._this(orb);
+
+ // Add reference to the boot manager
+ try {
+ byte[] oid = ("hw").getBytes();
+ BootManager bootManager = BootManagerHelper.narrow(
+ orb.resolve_initial_references("BootManager"));
+ bootManager.add_binding(oid, hello);
+ } catch (InvalidName ex) {
+ throw new RuntimeException();
+ } catch (AlreadyExists ex) {
+ throw new RuntimeException();
+ }
+
+ // Run implementation
+ manager.activate();
+ orb.run();
+
+ return 0;
+ }
+
+ public static void main(String args[]) {
+ Properties props = System.getProperties();
+ props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
+ props.put("org.omg.CORBA.ORBSingletonClass",
+ "org.apache.yoko.orb.CORBA.ORBSingleton");
+ props.put("yoko.orb.id", "HelloWorld-Server");
+ // for this demo, start on localhost, port 40000
+ props.put("yoko.orb.oa.endpoint", "iiop --host localhost --port 40000");
+
+ int status = 0;
+ ORB orb = null;
+
+ try {
+ orb = ORB.init(args, props);
+ status = run(orb, args);
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ status = 1;
+ }
+
+ if(orb != null) {
+ try {
+ orb.destroy();
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ status = 1;
+ }
+ }
+
+ System.exit(status);
+ }
+}
Added: incubator/yoko/trunk/distribution/src/main/samples/orb/resources/HelloWorld.idl
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/distribution/src/main/samples/orb/resources/HelloWorld.idl?rev=416454&view=auto
==============================================================================
--- incubator/yoko/trunk/distribution/src/main/samples/orb/resources/HelloWorld.idl (added)
+++ incubator/yoko/trunk/distribution/src/main/samples/orb/resources/HelloWorld.idl Thu Jun 22 12:47:48 2006
@@ -0,0 +1,25 @@
+/*
+ * 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.
+*/
+
+interface HelloWorld {
+ string
+ greetMe(
+ in string return_message
+ );
+};
Added: incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/corba/client/Client.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/corba/client/Client.java?rev=416454&view=auto
==============================================================================
--- incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/corba/client/Client.java (added)
+++ incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/corba/client/Client.java Thu Jun 22 12:47:48 2006
@@ -0,0 +1,78 @@
+/**
+ * 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 corba.client;
+
+import java.util.Properties;
+
+import org.omg.CORBA.Object;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.UserException;
+
+public class Client {
+ static int run(ORB orb, String[] args) throws UserException {
+
+ // Get "hello" object
+ Object obj = orb.string_to_object("corbaloc::localhost:40000/hw");
+ if(obj == null) {
+ System.err.println("Client: Could not resolve target object");
+ return 1;
+ }
+
+ HelloWorld hello = HelloWorldHelper.narrow(obj);
+
+ // Test our narrowed "hello" object
+ System.out.println("Invoking greetMe...");
+ String result = hello.greetMe(new String());
+ System.out.println("greetMe.result = " + result);
+
+ return 0;
+ }
+
+ // Standalone program initialization
+ public static void main(String args[]) {
+ int status = 0;
+ ORB orb = null;
+
+ Properties props = System.getProperties();
+ props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
+ props.put("org.omg.CORBA.ORBSingletonClass",
+ "org.apache.yoko.orb.CORBA.ORBSingleton");
+ props.put("yoko.orb.id", "HelloWorld-Client");
+
+ try {
+ orb = ORB.init(args, props);
+ status = run(orb, args);
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ status = 1;
+ }
+
+ if(orb != null) {
+ try {
+ orb.destroy();
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ status = 1;
+ }
+ }
+
+ System.exit(status);
+ }
+}
Added: incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/corba/server/HelloWorldImpl.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/corba/server/HelloWorldImpl.java?rev=416454&view=auto
==============================================================================
--- incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/corba/server/HelloWorldImpl.java (added)
+++ incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/corba/server/HelloWorldImpl.java Thu Jun 22 12:47:48 2006
@@ -0,0 +1,39 @@
+/**
+ * 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 corba.server;
+
+import org.omg.PortableServer.POA;
+
+public class HelloWorldImpl extends HelloWorldPOA {
+ // The servants default POA
+ private POA poa_;
+
+ HelloWorldImpl(POA poa) {
+ poa_ = poa;
+ }
+
+ public String greetMe(String inparameter) {
+ return new String("Hi " + inparameter);
+ }
+
+ public POA _default_POA() {
+ return poa_;
+ }
+}
Added: incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/corba/server/Server.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/corba/server/Server.java?rev=416454&view=auto
==============================================================================
--- incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/corba/server/Server.java (added)
+++ incubator/yoko/trunk/distribution/src/main/samples/ws/hello_world/src/corba/server/Server.java Thu Jun 22 12:47:48 2006
@@ -0,0 +1,97 @@
+/**
+ * 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 corba.server;
+
+import java.util.Properties;
+
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.UserException;
+import org.omg.CORBA.ORBPackage.InvalidName;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.POAHelper;
+import org.omg.PortableServer.POAManager;
+
+import org.apache.yoko.orb.OB.BootManager;
+import org.apache.yoko.orb.OB.BootManagerHelper;
+import org.apache.yoko.orb.OB.BootManagerPackage.AlreadyExists;
+
+public class Server {
+ static int run(ORB orb, String[] args) throws UserException {
+ // Resolve Root POA
+ POA rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
+
+ // Get a reference to the POA manager
+ POAManager manager = rootPOA.the_POAManager();
+
+ // Create implementation object
+ HelloWorldImpl hwImpl = new HelloWorldImpl(rootPOA);
+ HelloWorld hello = hwImpl._this(orb);
+
+ // Add reference to the boot manager
+ try {
+ byte[] oid = ("hw").getBytes();
+ BootManager bootManager = BootManagerHelper.narrow(
+ orb.resolve_initial_references("BootManager"));
+ bootManager.add_binding(oid, hello);
+ } catch (InvalidName ex) {
+ throw new RuntimeException();
+ } catch (AlreadyExists ex) {
+ throw new RuntimeException();
+ }
+
+ // Run implementation
+ manager.activate();
+ orb.run();
+
+ return 0;
+ }
+
+ public static void main(String args[]) {
+ Properties props = System.getProperties();
+ props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
+ props.put("org.omg.CORBA.ORBSingletonClass",
+ "org.apache.yoko.orb.CORBA.ORBSingleton");
+ props.put("yoko.orb.id", "HelloWorld-Server");
+ // for this demo, start on localhost, port 40000
+ props.put("yoko.orb.oa.endpoint", "iiop --host localhost --port 40000");
+
+ int status = 0;
+ ORB orb = null;
+
+ try {
+ orb = ORB.init(args, props);
+ status = run(orb, args);
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ status = 1;
+ }
+
+ if(orb != null) {
+ try {
+ orb.destroy();
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ status = 1;
+ }
+ }
+
+ System.exit(status);
+ }
+}