You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ri...@apache.org on 2006/08/15 21:50:18 UTC

svn commit: r431689 - in /incubator/tuscany/java/samples/sca/helloworldwsclientOM/src/main/java/helloworldOM: HelloWorldClient.java HelloWorldService.java HelloWorldServiceComponent.java

Author: rineholt
Date: Tue Aug 15 12:50:17 2006
New Revision: 431689

URL: http://svn.apache.org/viewvc?rev=431689&view=rev
Log:
 converstion to a raw OMElement 

Modified:
    incubator/tuscany/java/samples/sca/helloworldwsclientOM/src/main/java/helloworldOM/HelloWorldClient.java
    incubator/tuscany/java/samples/sca/helloworldwsclientOM/src/main/java/helloworldOM/HelloWorldService.java
    incubator/tuscany/java/samples/sca/helloworldwsclientOM/src/main/java/helloworldOM/HelloWorldServiceComponent.java

Modified: incubator/tuscany/java/samples/sca/helloworldwsclientOM/src/main/java/helloworldOM/HelloWorldClient.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sca/helloworldwsclientOM/src/main/java/helloworldOM/HelloWorldClient.java?rev=431689&r1=431688&r2=431689&view=diff
==============================================================================
--- incubator/tuscany/java/samples/sca/helloworldwsclientOM/src/main/java/helloworldOM/HelloWorldClient.java (original)
+++ incubator/tuscany/java/samples/sca/helloworldwsclientOM/src/main/java/helloworldOM/HelloWorldClient.java Tue Aug 15 12:50:17 2006
@@ -18,18 +18,15 @@
  */
 package helloworldOM;
 
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNode;
 import org.osoa.sca.CompositeContext;
 import org.osoa.sca.CurrentCompositeContext;
+import static java.lang.System.out;
 
 
-
-//import org.osoa.sca.CurrentModuleContext;
-//import org.osoa.sca.ModuleContext;
-//
-//import org.apache.tuscany.core.client.TuscanyRuntime;
-//import org.apache.tuscany.common.monitor.MonitorFactory;
-//import org.apache.tuscany.common.monitor.impl.JavaLoggingMonitorFactory;
-
 /**
  * This client program shows how to create an SCA runtime, start it,
  * locate the HelloWorld service and invoke it.
@@ -39,38 +36,43 @@
 
 public class HelloWorldClient {
    
+    private static final String TARGET_NAMESPACE = "http://helloworldOM";
 
     public  final static void main(String[] args) throws Exception {
         
-        // Setup Tuscany monitoring to use java.util.logging
-//        LogManager.getLogManager().readConfiguration(HelloWorldClient.class.getResourceAsStream("/logging.properties"));
-//        Properties levels = new Properties();
-//        MonitorFactory monitorFactory = new JavaLoggingMonitorFactory(levels, Level.FINEST, "MonitorMessages");
-
-        // Create a Tuscany runtime for the sample module component
-//        TuscanyRuntime tuscany = new TuscanyRuntime("HelloWorldModuleComponent", "http://helloworldOM", monitorFactory);
-
-        // Start the Tuscany runtime and associate it with this thread
-//        tuscany.start();
-
-        // Get the SCA module context.
-//        ModuleContext moduleContext = CurrentModuleContext.getContext();
-
-        // Locate the HelloWorld service
-//        HelloWorldService helloworldService = (HelloWorldService) moduleContext.locateService("HelloWorldService");
-        
         // Invoke the HelloWorld service
         CompositeContext compositeContext = CurrentCompositeContext.getContext();
         HelloWorldService helloWorldService= compositeContext.locateService(HelloWorldService.class, "HelloWorldServiceComponent");
-        String value = helloWorldService.getGreetings("World");
+        OMFactory fac= OMAbstractFactory.getOMFactory();
+        
+        //create operation
+        OMElement opE = fac.createOMElement("getGreetings", TARGET_NAMESPACE, "helloworld");
+        //create parm
+        OMElement parmE = fac.createOMElement("name", TARGET_NAMESPACE, "helloworld");
+        //and value.
+        opE.addChild(parmE);
+        StringBuilder sb= new StringBuilder(1000);
+        for(String s : args){
+            sb.append(s);
+        }
+        parmE.addChild(fac.createOMText(sb.toString()));
+        
+        OMElement value = helloWorldService.getGreetings(parmE);
+        printTRee(value);
         
-        System.out.println(value);
-        System.out.flush();
+        out.println(value);
+        out.flush();
 
-        // Disassociate the runtime from this thread
-//        tuscany.stop();
+    }
 
-        // Shut down the runtime
-//        tuscany.shutdown();
+    private static void printTRee(OMElement value) {
+
+      out.println(value);
+      for(OMNode n = value.getFirstOMChild(); n != null; n= n.getNextOMSibling()){
+          if(n instanceof OMElement) printTRee((OMElement) n);
+          else out.println(n);
+      }
+      out.flush();
+        
     }
 }

Modified: incubator/tuscany/java/samples/sca/helloworldwsclientOM/src/main/java/helloworldOM/HelloWorldService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sca/helloworldwsclientOM/src/main/java/helloworldOM/HelloWorldService.java?rev=431689&r1=431688&r2=431689&view=diff
==============================================================================
--- incubator/tuscany/java/samples/sca/helloworldwsclientOM/src/main/java/helloworldOM/HelloWorldService.java (original)
+++ incubator/tuscany/java/samples/sca/helloworldwsclientOM/src/main/java/helloworldOM/HelloWorldService.java Tue Aug 15 12:50:17 2006
@@ -18,12 +18,13 @@
  */
 package helloworldOM;
 
+import org.apache.axiom.om.OMElement;
 import org.osoa.sca.annotations.Service;
 
 
 @Service
 public interface HelloWorldService {
 
-    public String getGreetings(String name);
+    public OMElement getGreetings(OMElement parmE);
 
-}
+}
\ No newline at end of file

Modified: incubator/tuscany/java/samples/sca/helloworldwsclientOM/src/main/java/helloworldOM/HelloWorldServiceComponent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sca/helloworldwsclientOM/src/main/java/helloworldOM/HelloWorldServiceComponent.java?rev=431689&r1=431688&r2=431689&view=diff
==============================================================================
--- incubator/tuscany/java/samples/sca/helloworldwsclientOM/src/main/java/helloworldOM/HelloWorldServiceComponent.java (original)
+++ incubator/tuscany/java/samples/sca/helloworldwsclientOM/src/main/java/helloworldOM/HelloWorldServiceComponent.java Tue Aug 15 12:50:17 2006
@@ -18,6 +18,7 @@
  */
 package helloworldOM;
 
+import org.apache.axiom.om.OMElement;
 import org.osoa.sca.annotations.Scope;
 
 
@@ -31,17 +32,16 @@
 public class HelloWorldServiceComponent implements HelloWorldService {
    
     HelloWorldService helloWorldService;
+    
+    public void setHelloWorldService(HelloWorldService helloWorldService) {
+        
+        this.helloWorldService = helloWorldService;
+        
+    }
 
-    public String getGreetings(String name) {
+    public OMElement getGreetings(OMElement name) {
        
         return helloWorldService.getGreetings(name);
     }
 
-    public HelloWorldService getHelloWorldService() {
-        return helloWorldService;
-    }
-
-    public void setHelloWorldService(HelloWorldService helloWorldService) {
-        this.helloWorldService = helloWorldService;
-    }
 }



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