Author: jsdelfino
Date: Mon May 8 15:05:25 2006
New Revision: 405193
URL: http://svn.apache.org/viewcvs?rev=405193&view=rev
Log:
Calculator sample
Added:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/ (with props)
incubator/tuscany/sandbox/sebastien/java/samples/calculator/pom.xml (with
props)
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/AddService.java
(with props)
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/AddServiceImpl.java
(with props)
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/CalculatorClient.java
(with props)
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/CalculatorService.java
(with props)
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/CalculatorServiceImpl.java
(with props)
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/DivideService.java
(with props)
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/DivideServiceImpl.java
(with props)
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/MultiplyService.java
(with props)
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/MultiplyServiceImpl.java
(with props)
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/SubtractService.java
(with props)
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/SubtractServiceImpl.java
(with props)
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/resources/
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/resources/logging.properties
(with props)
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/resources/sca.module
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/test/
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/test/java/
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/test/java/calculator/
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/test/java/calculator/CalculatorTestCase.java
(with props)
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/test/resources/
Propchange: incubator/tuscany/sandbox/sebastien/java/samples/calculator/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon May 8 15:05:25 2006
@@ -0,0 +1,13 @@
+target
+*.iws
+*.ipr
+*.iml
+.project
+.classpath
+maven.log
+velocity.log*
+junit*.properties
+.settings
+.deployables
+.wtpmodules
+
Added: incubator/tuscany/sandbox/sebastien/java/samples/calculator/pom.xml
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/sebastien/java/samples/calculator/pom.xml?rev=405193&view=auto
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/samples/calculator/pom.xml (added)
+++ incubator/tuscany/sandbox/sebastien/java/samples/calculator/pom.xml Mon May
8 15:05:25 2006
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright (c) 2005-2006 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.
+ -->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca.samples</groupId>
+ <artifactId>tuscany-sca-samples</artifactId>
+ <version>SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>calculator</artifactId>
+ <packaging>jar</packaging>
+ <name>Tuscany Calculator Sample</name>
+ <description>A sample Calculator made of several SCA components wired
together.</description>
+ <version>SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.containers</groupId>
+ <artifactId>tuscany-container-java</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Propchange: incubator/tuscany/sandbox/sebastien/java/samples/calculator/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/samples/calculator/pom.xml
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/AddService.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/AddService.java?rev=405193&view=auto
==============================================================================
---
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/AddService.java
(added)
+++
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/AddService.java
Mon May 8 15:05:25 2006
@@ -0,0 +1,23 @@
+/**
+ *
+ * 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 calculator;
+
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
Propchange:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/AddService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/AddService.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/AddServiceImpl.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/AddServiceImpl.java?rev=405193&view=auto
==============================================================================
---
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/AddServiceImpl.java
(added)
+++
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/AddServiceImpl.java
Mon May 8 15:05:25 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 calculator;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ * An implementation of the Add service
+ */
[EMAIL PROTECTED](AddService.class)
+public class AddServiceImpl implements AddService {
+
+ public double add(double n1, double n2) {
+ return n1 + n2;
+ }
+
+}
Propchange:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/AddServiceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/AddServiceImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/CalculatorClient.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/CalculatorClient.java?rev=405193&view=auto
==============================================================================
---
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/CalculatorClient.java
(added)
+++
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/CalculatorClient.java
Mon May 8 15:05:25 2006
@@ -0,0 +1,68 @@
+/**
+ *
+ * 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 calculator;
+
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.LogManager;
+
+import org.apache.tuscany.common.monitor.MonitorFactory;
+import org.apache.tuscany.common.monitor.impl.JavaLoggingMonitorFactory;
+import org.apache.tuscany.core.client.TuscanyRuntime;
+import org.osoa.sca.CurrentModuleContext;
+import org.osoa.sca.ModuleContext;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * locate the HelloWorld service and invoke it.
+ */
+public class CalculatorClient {
+
+ public static final void main(String[] args) throws Exception {
+
+ // Setup Tuscany monitoring to use java.util.logging
+
LogManager.getLogManager().readConfiguration(CalculatorClient.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("CalculatorModuleComponent", "http://calculator",
monitorFactory);
+
+ // Start the Tuscany runtime and associate it with this thread
+ tuscany.start();
+
+ // Get the SCA module context.
+ ModuleContext moduleContext = CurrentModuleContext.getContext();
+
+ // Locate the Calculator service
+ CalculatorService calculatorService = (CalculatorService)
moduleContext.locateService("CalculatorServiceComponent");
+
+ // Calculate
+ System.out.println("3 + 2="+calculatorService.add(3, 2));
+ System.out.println("3 - 2="+calculatorService.subtract(3, 2));
+ System.out.println("3 * 2="+calculatorService.multiply(3, 2));
+ System.out.println("3 / 2="+calculatorService.divide(3, 2));
+
+ System.out.flush();
+
+ // Disassociate the application module component
+ tuscany.stop();
+
+ // Shut down the runtime
+ tuscany.shutdown();
+ }
+}
Propchange:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/CalculatorClient.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/CalculatorClient.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/CalculatorService.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/CalculatorService.java?rev=405193&view=auto
==============================================================================
---
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/CalculatorService.java
(added)
+++
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/CalculatorService.java
Mon May 8 15:05:25 2006
@@ -0,0 +1,33 @@
+/**
+ *
+ * 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 calculator;
+
+
+/**
+ * The Calculator service interface.
+ */
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
Propchange:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/CalculatorService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/CalculatorService.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/CalculatorServiceImpl.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/CalculatorServiceImpl.java?rev=405193&view=auto
==============================================================================
---
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/CalculatorServiceImpl.java
(added)
+++
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/CalculatorServiceImpl.java
Mon May 8 15:05:25 2006
@@ -0,0 +1,70 @@
+/**
+ *
+ * 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 calculator;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+
+/**
+ * An implementation of the Calculator service.
+ */
[EMAIL PROTECTED](CalculatorService.class)
+public class CalculatorServiceImpl implements CalculatorService {
+
+ private AddService addService;
+ private SubtractService subtractService;
+ private MultiplyService multiplyService;
+ private DivideService divideService;
+
+ @Reference
+ public void setAddService(AddService addService) {
+ this.addService = addService;
+ }
+
+ @Reference
+ public void setSubtractService(SubtractService subtractService) {
+ this.subtractService = subtractService;
+ }
+
+ @Reference
+ public void setDivideService(DivideService divideService) {
+ this.divideService = divideService;
+ }
+
+ @Reference
+ public void setMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = multiplyService;
+ }
+
+ public double add(double n1, double n2) {
+ return addService.add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return subtractService.subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return multiplyService.multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return divideService.divide(n1, n2);
+ }
+
+}
Propchange:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/CalculatorServiceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/CalculatorServiceImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/DivideService.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/DivideService.java?rev=405193&view=auto
==============================================================================
---
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/DivideService.java
(added)
+++
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/DivideService.java
Mon May 8 15:05:25 2006
@@ -0,0 +1,23 @@
+/**
+ *
+ * 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 calculator;
+
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
Propchange:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/DivideService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/DivideService.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/DivideServiceImpl.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/DivideServiceImpl.java?rev=405193&view=auto
==============================================================================
---
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/DivideServiceImpl.java
(added)
+++
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/DivideServiceImpl.java
Mon May 8 15:05:25 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 calculator;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ * An implementation of the Divide service.
+ */
[EMAIL PROTECTED](DivideService.class)
+public class DivideServiceImpl implements DivideService {
+
+ public double divide(double n1, double n2) {
+ return n1 / n2;
+ }
+
+}
Propchange:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/DivideServiceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/DivideServiceImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/MultiplyService.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/MultiplyService.java?rev=405193&view=auto
==============================================================================
---
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/MultiplyService.java
(added)
+++
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/MultiplyService.java
Mon May 8 15:05:25 2006
@@ -0,0 +1,23 @@
+/**
+ *
+ * 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 calculator;
+
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
Propchange:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/MultiplyService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/MultiplyService.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/MultiplyServiceImpl.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/MultiplyServiceImpl.java?rev=405193&view=auto
==============================================================================
---
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/MultiplyServiceImpl.java
(added)
+++
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/MultiplyServiceImpl.java
Mon May 8 15:05:25 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 calculator;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ * An implementation of the Multiply service.
+ */
[EMAIL PROTECTED](MultiplyService.class)
+public class MultiplyServiceImpl implements MultiplyService {
+
+ public double multiply(double n1, double n2) {
+ return n1 * n2;
+ }
+
+}
Propchange:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/MultiplyServiceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/MultiplyServiceImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/SubtractService.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/SubtractService.java?rev=405193&view=auto
==============================================================================
---
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/SubtractService.java
(added)
+++
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/SubtractService.java
Mon May 8 15:05:25 2006
@@ -0,0 +1,23 @@
+/**
+ *
+ * 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 calculator;
+
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
Propchange:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/SubtractService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/SubtractService.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/SubtractServiceImpl.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/SubtractServiceImpl.java?rev=405193&view=auto
==============================================================================
---
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/SubtractServiceImpl.java
(added)
+++
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/SubtractServiceImpl.java
Mon May 8 15:05:25 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 calculator;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ * An implementation of the subtract service.
+ */
[EMAIL PROTECTED](SubtractService.class)
+public class SubtractServiceImpl implements SubtractService {
+
+ public double subtract(double n1, double n2) {
+ return n1 - n2;
+ }
+
+}
Propchange:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/SubtractServiceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/java/calculator/SubtractServiceImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/resources/logging.properties
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/resources/logging.properties?rev=405193&view=auto
==============================================================================
---
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/resources/logging.properties
(added)
+++
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/resources/logging.properties
Mon May 8 15:05:25 2006
@@ -0,0 +1,27 @@
+# Copyright (c) 2006 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.
+#
+# $Rev$ $Date$
+#
+
+# Custom logging configuration for Tuscany samples
+# By default, only INFO level logging is enabled and ALL messages get sent to
the console
+# For more messages from the runtime, uncomment specific settings at the end
of this file
+handlers = java.util.logging.ConsoleHandler
+java.util.logging.ConsoleHandler.level = ALL
+java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
+.level=INFO
+
+# Uncomment the next setting to get all Tuscany messages (this will be a lot)
+#org.apache.tuscany.level=FINEST
\ No newline at end of file
Propchange:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/resources/logging.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/resources/logging.properties
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/resources/sca.module
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/resources/sca.module?rev=405193&view=auto
==============================================================================
---
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/resources/sca.module
(added)
+++
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/main/resources/sca.module
Mon May 8 15:05:25 2006
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 BEA Sytems Inc.
+ Copyright (c) 2005 International Business Machines
+
+ 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.
+ -->
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9"
xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+ name="calculator">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <references>
+ <v:addService>AddServiceComponent</v:addService>
+ <v:subtractService>SubtractServiceComponent</v:subtractService>
+ <v:multiplyService>MultiplyServiceComponent</v:multiplyService>
+ <v:divideService>DivideServiceComponent</v:divideService>
+ </references>
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</module>
Added:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/test/java/calculator/CalculatorTestCase.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/test/java/calculator/CalculatorTestCase.java?rev=405193&view=auto
==============================================================================
---
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/test/java/calculator/CalculatorTestCase.java
(added)
+++
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/test/java/calculator/CalculatorTestCase.java
Mon May 8 15:05:25 2006
@@ -0,0 +1,65 @@
+/**
+ *
+ * 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 calculator;
+
+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 CalculatorTestCase extends TestCase {
+
+ private TuscanyRuntime tuscany;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // Create a Tuscany runtime for the sample module component
+ tuscany = new TuscanyRuntime("CalculatorModuleComponent",
"http://calculator");
+
+ // Start the Tuscany runtime and associate it with this thread
+ tuscany.start();
+ }
+
+ public void testCalculator() throws Exception {
+
+ // Get the SCA module context.
+ ModuleContext moduleContext = CurrentModuleContext.getContext();
+
+ // Locate the Calculator service
+ CalculatorService calculatorService = (CalculatorService)
moduleContext.locateService("CalculatorServiceComponent");
+
+ // Calculate
+ assertEquals(calculatorService.add(3, 2), 5.0);
+ assertEquals(calculatorService.subtract(3, 2), 1.0);
+ assertEquals(calculatorService.multiply(3, 2), 6.0);
+ assertEquals(calculatorService.divide(3, 2), 1.5);
+
+ }
+
+ protected void tearDown() throws Exception {
+
+ // Stop the Tuscany runtime
+ tuscany.stop();
+
+ super.tearDown();
+ }
+}
Propchange:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/test/java/calculator/CalculatorTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/sandbox/sebastien/java/samples/calculator/src/test/java/calculator/CalculatorTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date