You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2006/05/07 11:03:30 UTC

svn commit: r404744 - in /incubator/tuscany/java/sca/samples/helloworld: ./ src/main/java/helloworld/ src/main/java/org/apache/tuscany/samples/helloworld/ src/main/resources/ src/test/java/helloworld/ src/test/java/org/apache/tuscany/samples/helloworld/

Author: jsdelfino
Date: Sun May  7 02:03:28 2006
New Revision: 404744

URL: http://svn.apache.org/viewcvs?rev=404744&view=rev
Log:
Fix for TUSCANY-159 - simpler package names for the samples

Added:
    incubator/tuscany/java/sca/samples/helloworld/src/main/java/helloworld/
    incubator/tuscany/java/sca/samples/helloworld/src/main/java/helloworld/HelloWorldClient.java   (with props)
    incubator/tuscany/java/sca/samples/helloworld/src/main/java/helloworld/HelloWorldImpl.java   (with props)
    incubator/tuscany/java/sca/samples/helloworld/src/main/java/helloworld/HelloWorldService.java   (with props)
    incubator/tuscany/java/sca/samples/helloworld/src/test/java/helloworld/
    incubator/tuscany/java/sca/samples/helloworld/src/test/java/org/apache/tuscany/samples/helloworld/HelloWorldTestCase.java   (with props)
Removed:
    incubator/tuscany/java/sca/samples/helloworld/src/main/java/org/apache/tuscany/samples/helloworld/HelloWorldClient.java
    incubator/tuscany/java/sca/samples/helloworld/src/main/java/org/apache/tuscany/samples/helloworld/HelloWorldService.java
    incubator/tuscany/java/sca/samples/helloworld/src/main/java/org/apache/tuscany/samples/helloworld/HelloWorldServiceComponentImpl.java
    incubator/tuscany/java/sca/samples/helloworld/src/test/java/org/apache/tuscany/samples/helloworld/HelloWorldServiceComponentTestCase.java
Modified:
    incubator/tuscany/java/sca/samples/helloworld/pom.xml
    incubator/tuscany/java/sca/samples/helloworld/src/main/resources/sca.module

Modified: incubator/tuscany/java/sca/samples/helloworld/pom.xml
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/samples/helloworld/pom.xml?rev=404744&r1=404743&r2=404744&view=diff
==============================================================================
--- incubator/tuscany/java/sca/samples/helloworld/pom.xml (original)
+++ incubator/tuscany/java/sca/samples/helloworld/pom.xml Sun May  7 02:03:28 2006
@@ -38,7 +38,7 @@
             <groupId>org.apache.tuscany.sca.containers</groupId>
             <artifactId>tuscany-container-java</artifactId>
             <version>${pom.version}</version>
-            <scope>compile</scope>
+            <scope>runtime</scope>
         </dependency>
 
         <dependency>

Added: incubator/tuscany/java/sca/samples/helloworld/src/main/java/helloworld/HelloWorldClient.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/samples/helloworld/src/main/java/helloworld/HelloWorldClient.java?rev=404744&view=auto
==============================================================================
--- incubator/tuscany/java/sca/samples/helloworld/src/main/java/helloworld/HelloWorldClient.java (added)
+++ incubator/tuscany/java/sca/samples/helloworld/src/main/java/helloworld/HelloWorldClient.java Sun May  7 02:03:28 2006
@@ -0,0 +1,67 @@
+/**
+ *
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  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 helloworld;
+
+import java.util.logging.Level;
+import java.util.logging.LogManager;
+import java.util.Properties;
+
+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.
+ */
+public class HelloWorldClient {
+
+    public static final 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", null, 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("HelloWorldServiceComponent");
+        
+        // Invoke the HelloWorld service
+        String value = helloworldService.getGreetings("World");
+        
+        System.out.println(value);
+        System.out.flush();
+
+        // Disassociate the application module component
+        tuscany.stop();
+
+        // Shut down the runtime
+        tuscany.shutdown();
+    }
+}

Propchange: incubator/tuscany/java/sca/samples/helloworld/src/main/java/helloworld/HelloWorldClient.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/samples/helloworld/src/main/java/helloworld/HelloWorldClient.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/java/sca/samples/helloworld/src/main/java/helloworld/HelloWorldImpl.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/samples/helloworld/src/main/java/helloworld/HelloWorldImpl.java?rev=404744&view=auto
==============================================================================
--- incubator/tuscany/java/sca/samples/helloworld/src/main/java/helloworld/HelloWorldImpl.java (added)
+++ incubator/tuscany/java/sca/samples/helloworld/src/main/java/helloworld/HelloWorldImpl.java Sun May  7 02:03:28 2006
@@ -0,0 +1,31 @@
+/**
+ *
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  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 helloworld;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(HelloWorldService.class)
+public class HelloWorldImpl implements HelloWorldService {
+
+    public String getGreetings(String name) {
+        return "Hello " + name;
+    }
+
+}

Propchange: incubator/tuscany/java/sca/samples/helloworld/src/main/java/helloworld/HelloWorldImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/samples/helloworld/src/main/java/helloworld/HelloWorldImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/java/sca/samples/helloworld/src/main/java/helloworld/HelloWorldService.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/samples/helloworld/src/main/java/helloworld/HelloWorldService.java?rev=404744&view=auto
==============================================================================
--- incubator/tuscany/java/sca/samples/helloworld/src/main/java/helloworld/HelloWorldService.java (added)
+++ incubator/tuscany/java/sca/samples/helloworld/src/main/java/helloworld/HelloWorldService.java Sun May  7 02:03:28 2006
@@ -0,0 +1,26 @@
+/**
+ *
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  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 helloworld;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+public interface HelloWorldService {
+
+    public String getGreetings(String name);
+
+}

Propchange: incubator/tuscany/java/sca/samples/helloworld/src/main/java/helloworld/HelloWorldService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/samples/helloworld/src/main/java/helloworld/HelloWorldService.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Modified: incubator/tuscany/java/sca/samples/helloworld/src/main/resources/sca.module
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/samples/helloworld/src/main/resources/sca.module?rev=404744&r1=404743&r2=404744&view=diff
==============================================================================
--- incubator/tuscany/java/sca/samples/helloworld/src/main/resources/sca.module (original)
+++ incubator/tuscany/java/sca/samples/helloworld/src/main/resources/sca.module Sun May  7 02:03:28 2006
@@ -16,10 +16,10 @@
   limitations under the License.
  -->
 <module xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
-        name="sampleHelloworld">
+        name="helloworld">
 
     <component name="HelloWorldServiceComponent">
-        <implementation.java class="org.apache.tuscany.samples.helloworld.HelloWorldServiceComponentImpl"/>
+        <implementation.java class="helloworld.HelloWorldImpl"/>
     </component>
     
 </module>

Added: incubator/tuscany/java/sca/samples/helloworld/src/test/java/org/apache/tuscany/samples/helloworld/HelloWorldTestCase.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/samples/helloworld/src/test/java/org/apache/tuscany/samples/helloworld/HelloWorldTestCase.java?rev=404744&view=auto
==============================================================================
--- incubator/tuscany/java/sca/samples/helloworld/src/test/java/org/apache/tuscany/samples/helloworld/HelloWorldTestCase.java (added)
+++ incubator/tuscany/java/sca/samples/helloworld/src/test/java/org/apache/tuscany/samples/helloworld/HelloWorldTestCase.java Sun May  7 02:03:28 2006
@@ -0,0 +1,64 @@
+/**
+ *
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  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 org.apache.tuscany.samples.helloworld;
+
+import helloworld.HelloWorldService;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.client.TuscanyRuntime;
+import org.osoa.sca.CurrentModuleContext;
+import org.osoa.sca.ModuleContext;
+
+/**
+ * This shows how to test the HelloWorld service component.
+ */
+public class HelloWorldTestCase extends TestCase {
+    
+    private TuscanyRuntime tuscany;
+    
+    protected void setUp() throws Exception {
+        super.setUp();
+        
+        // Create a Tuscany runtime for the sample module component
+        tuscany = new TuscanyRuntime("HelloWorldModuleComponent", null);
+
+        // Start the Tuscany runtime and associate it with this thread
+        tuscany.start();
+    }
+    
+    public void testGeetings() throws Exception {
+
+        // Get the SCA module context.
+        ModuleContext moduleContext = CurrentModuleContext.getContext();
+
+        // Locate the HelloWorld service
+        HelloWorldService helloworldService = (HelloWorldService) moduleContext.locateService("HelloWorldServiceComponent");
+        
+        // Invoke the HelloWorld service
+        String value = helloworldService.getGreetings("World");
+        
+        assertEquals(value, "Hello World");
+    }
+    
+    protected void tearDown() throws Exception {
+        
+        // Stop the Tuscany runtime
+        tuscany.stop();
+        
+        super.tearDown();
+    }
+}

Propchange: incubator/tuscany/java/sca/samples/helloworld/src/test/java/org/apache/tuscany/samples/helloworld/HelloWorldTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/samples/helloworld/src/test/java/org/apache/tuscany/samples/helloworld/HelloWorldTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date