summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2008-12-17 19:51:24 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2008-12-17 19:51:24 +0000
commit432dd8fb555ad9d6dde1b5d220e7a0fe2de51904 (patch)
treeffdc231e6c6413aaed515297a9f5834087d4d31b
parent31cc3f73bea03fb0d8403ed7b5c7adda6c7c9c9a (diff)
[Work in progress] An Android version of the calculator sample application
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@727494 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/.classpath24
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/.project39
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/.settings/org.eclipse.jdt.core.prefs5
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/AndroidManifest.xml15
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/META-INF/MANIFEST.MF2
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/res/drawable/icon.pngbin0 -> 3180 bytes
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/res/layout/main.xml12
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/res/values/strings.xml5
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/AddService.classbin0 -> 134 bytes
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/AddService.java11
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/AddServiceImpl.classbin0 -> 1019 bytes
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/AddServiceImpl.java18
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorBuilder.classbin0 -> 2314 bytes
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorClient.classbin0 -> 461 bytes
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorClient.java30
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorService.classbin0 -> 203 bytes
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorService.java18
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorServiceImpl.classbin0 -> 1682 bytes
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorServiceImpl.java54
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/DivideService.classbin0 -> 143 bytes
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/DivideService.java11
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/DivideServiceImpl.classbin0 -> 1037 bytes
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/DivideServiceImpl.java18
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/MultiplyService.classbin0 -> 149 bytes
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/MultiplyService.java11
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/MultiplyServiceImpl.classbin0 -> 1050 bytes
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/MultiplyServiceImpl.java18
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/SubtractService.classbin0 -> 149 bytes
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/SubtractService.java11
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/SubtractServiceImpl.classbin0 -> 1050 bytes
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/SubtractServiceImpl.java18
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/android/CalculatorClient.classbin0 -> 920 bytes
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/android/CalculatorClient.java77
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/android/R$attr.classbin0 -> 340 bytes
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/android/R$drawable.classbin0 -> 400 bytes
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/android/R$layout.classbin0 -> 394 bytes
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/android/R$string.classbin0 -> 427 bytes
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/android/R.classbin0 -> 489 bytes
-rw-r--r--branches/sca-java-1.x/samples/calculator-android/src/calculator/android/R.java23
39 files changed, 420 insertions, 0 deletions
diff --git a/branches/sca-java-1.x/samples/calculator-android/.classpath b/branches/sca-java-1.x/samples/calculator-android/.classpath
new file mode 100644
index 0000000000..f5ff047152
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/.classpath
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/tuscany-assembly"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/tuscany-assembly-xml"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/tuscany-assembly-xsd"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/tuscany-definitions"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/tuscany-definitions-xml"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/tuscany-extensibility"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/tuscany-implementation-java"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/tuscany-implementation-java-runtime"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/tuscany-implementation-java-xml"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/tuscany-interface"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/tuscany-interface-java"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/tuscany-interface-java-xml"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/tuscany-monitor"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/tuscany-policy"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/tuscany-sca-api"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/tuscany-contribution"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/tuscany-contribution-impl"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/tuscany-host-android"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/branches/sca-java-1.x/samples/calculator-android/.project b/branches/sca-java-1.x/samples/calculator-android/.project
new file mode 100644
index 0000000000..b0a16117c8
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/.project
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>calculator-android</name>
+ <comment></comment>
+ <projects>
+ <project>tuscany-assembly</project>
+ <project>tuscany-definitions</project>
+ <project>tuscany-extensibility</project>
+ <project>tuscany-interface</project>
+ <project>tuscany-monitor</project>
+ <project>tuscany-policy</project>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/branches/sca-java-1.x/samples/calculator-android/.settings/org.eclipse.jdt.core.prefs b/branches/sca-java-1.x/samples/calculator-android/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000000..4077c7b7f0
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,5 @@
+#Mon Nov 24 19:53:10 PST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/branches/sca-java-1.x/samples/calculator-android/AndroidManifest.xml b/branches/sca-java-1.x/samples/calculator-android/AndroidManifest.xml
new file mode 100644
index 0000000000..ad6daf347e
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/AndroidManifest.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="calculator.android"
+ android:versionCode="1"
+ android:versionName="1.0.0">
+ <application android:icon="@drawable/icon" android:label="@string/app_name">
+ <activity android:name=".CalculatorClient"
+ android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest> \ No newline at end of file
diff --git a/branches/sca-java-1.x/samples/calculator-android/META-INF/MANIFEST.MF b/branches/sca-java-1.x/samples/calculator-android/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..58630c02ef
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/META-INF/MANIFEST.MF
@@ -0,0 +1,2 @@
+Manifest-Version: 1.0
+
diff --git a/branches/sca-java-1.x/samples/calculator-android/res/drawable/icon.png b/branches/sca-java-1.x/samples/calculator-android/res/drawable/icon.png
new file mode 100644
index 0000000000..75024841d3
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/res/drawable/icon.png
Binary files differ
diff --git a/branches/sca-java-1.x/samples/calculator-android/res/layout/main.xml b/branches/sca-java-1.x/samples/calculator-android/res/layout/main.xml
new file mode 100644
index 0000000000..3a5f117d3c
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/res/layout/main.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ >
+<TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/hello"
+ />
+</LinearLayout>
diff --git a/branches/sca-java-1.x/samples/calculator-android/res/values/strings.xml b/branches/sca-java-1.x/samples/calculator-android/res/values/strings.xml
new file mode 100644
index 0000000000..71052e74b8
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/res/values/strings.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="hello">Hello World, CalculatorClient</string>
+ <string name="app_name">Calculator</string>
+</resources>
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/AddService.class b/branches/sca-java-1.x/samples/calculator-android/src/calculator/AddService.class
new file mode 100644
index 0000000000..8a5ed25f9f
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/AddService.class
Binary files differ
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/AddService.java b/branches/sca-java-1.x/samples/calculator-android/src/calculator/AddService.java
new file mode 100644
index 0000000000..21c6789632
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/AddService.java
@@ -0,0 +1,11 @@
+package calculator;
+
+
+/**
+ * The Add service interface
+ */
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/AddServiceImpl.class b/branches/sca-java-1.x/samples/calculator-android/src/calculator/AddServiceImpl.class
new file mode 100644
index 0000000000..c6fd83f6a1
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/AddServiceImpl.class
Binary files differ
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/AddServiceImpl.java b/branches/sca-java-1.x/samples/calculator-android/src/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..6181a1c651
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/AddServiceImpl.java
@@ -0,0 +1,18 @@
+package calculator;
+
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the Add service
+ */
+public class AddServiceImpl implements AddService {
+
+ public double add(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Adding " + n1 + " and " + n2);
+ return n1 + n2;
+ }
+
+}
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorBuilder.class b/branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorBuilder.class
new file mode 100644
index 0000000000..b4466a3017
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorBuilder.class
Binary files differ
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorClient.class b/branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorClient.class
new file mode 100644
index 0000000000..aaf9e9710f
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorClient.class
Binary files differ
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorClient.java b/branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorClient.java
new file mode 100644
index 0000000000..3b977259e8
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorClient.java
@@ -0,0 +1,30 @@
+package calculator;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+public class CalculatorClient {
+ public static void main(String[] args) throws Exception {
+
+
+ SCADomain scaDomain = SCADomain.newInstance("Calculator.composite");
+
+ CalculatorService calculatorService =
+ scaDomain.getService(CalculatorService.class, "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));
+
+ scaDomain.close();
+
+ }
+
+}
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorService.class b/branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorService.class
new file mode 100644
index 0000000000..c3cc2911e9
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorService.class
Binary files differ
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorService.java b/branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorService.java
new file mode 100644
index 0000000000..862d7b892d
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorService.java
@@ -0,0 +1,18 @@
+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);
+
+}
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorServiceImpl.class b/branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorServiceImpl.class
new file mode 100644
index 0000000000..8e0f206119
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorServiceImpl.class
Binary files differ
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorServiceImpl.java b/branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..2c88b5319e
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/CalculatorServiceImpl.java
@@ -0,0 +1,54 @@
+package calculator;
+
+
+//import org.osoa.sca.annotations.Reference;
+
+
+/**
+ * An implementation of the Calculator service.
+ */
+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);
+ }
+
+}
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/DivideService.class b/branches/sca-java-1.x/samples/calculator-android/src/calculator/DivideService.class
new file mode 100644
index 0000000000..8f056b16b6
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/DivideService.class
Binary files differ
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/DivideService.java b/branches/sca-java-1.x/samples/calculator-android/src/calculator/DivideService.java
new file mode 100644
index 0000000000..8f544632dc
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/DivideService.java
@@ -0,0 +1,11 @@
+package calculator;
+
+
+/**
+ * The divide service interface
+ */
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/DivideServiceImpl.class b/branches/sca-java-1.x/samples/calculator-android/src/calculator/DivideServiceImpl.class
new file mode 100644
index 0000000000..09cae06d9c
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/DivideServiceImpl.class
Binary files differ
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/DivideServiceImpl.java b/branches/sca-java-1.x/samples/calculator-android/src/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..5dfae77222
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/DivideServiceImpl.java
@@ -0,0 +1,18 @@
+package calculator;
+
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the Divide service.
+ */
+public class DivideServiceImpl implements DivideService {
+
+ public double divide(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Dividing " + n1 + " with " + n2);
+ return n1 / n2;
+ }
+
+}
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/MultiplyService.class b/branches/sca-java-1.x/samples/calculator-android/src/calculator/MultiplyService.class
new file mode 100644
index 0000000000..6542db7083
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/MultiplyService.class
Binary files differ
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/MultiplyService.java b/branches/sca-java-1.x/samples/calculator-android/src/calculator/MultiplyService.java
new file mode 100644
index 0000000000..f7f4ee77b5
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/MultiplyService.java
@@ -0,0 +1,11 @@
+package calculator;
+
+
+/**
+ * The interface for the multiply service
+ */
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/MultiplyServiceImpl.class b/branches/sca-java-1.x/samples/calculator-android/src/calculator/MultiplyServiceImpl.class
new file mode 100644
index 0000000000..0e69e7ad2d
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/MultiplyServiceImpl.class
Binary files differ
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/MultiplyServiceImpl.java b/branches/sca-java-1.x/samples/calculator-android/src/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..3142f86a58
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/MultiplyServiceImpl.java
@@ -0,0 +1,18 @@
+package calculator;
+
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the Multiply service.
+ */
+public class MultiplyServiceImpl implements MultiplyService {
+
+ public double multiply(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Multiplying " + n1 + " with " + n2);
+ return n1 * n2;
+ }
+
+}
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/SubtractService.class b/branches/sca-java-1.x/samples/calculator-android/src/calculator/SubtractService.class
new file mode 100644
index 0000000000..84c741e301
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/SubtractService.class
Binary files differ
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/SubtractService.java b/branches/sca-java-1.x/samples/calculator-android/src/calculator/SubtractService.java
new file mode 100644
index 0000000000..2349febb0f
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/SubtractService.java
@@ -0,0 +1,11 @@
+package calculator;
+
+
+/**
+ * The interface for the multiply service
+ */
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/SubtractServiceImpl.class b/branches/sca-java-1.x/samples/calculator-android/src/calculator/SubtractServiceImpl.class
new file mode 100644
index 0000000000..7b1aeab811
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/SubtractServiceImpl.class
Binary files differ
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/SubtractServiceImpl.java b/branches/sca-java-1.x/samples/calculator-android/src/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..ec55f4f07d
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/SubtractServiceImpl.java
@@ -0,0 +1,18 @@
+package calculator;
+
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the subtract service.
+ */
+public class SubtractServiceImpl implements SubtractService {
+
+ public double subtract(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Subtracting " + n1 + " from " + n2);
+ return n1 - n2;
+ }
+
+}
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/android/CalculatorClient.class b/branches/sca-java-1.x/samples/calculator-android/src/calculator/android/CalculatorClient.class
new file mode 100644
index 0000000000..20b588f972
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/android/CalculatorClient.class
Binary files differ
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/android/CalculatorClient.java b/branches/sca-java-1.x/samples/calculator-android/src/calculator/android/CalculatorClient.java
new file mode 100644
index 0000000000..2bc8b3eb1d
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/android/CalculatorClient.java
@@ -0,0 +1,77 @@
+package calculator.android;
+
+import java.net.URL;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.service.ContributionService;
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.apache.tuscany.sca.host.embedded.impl.EmbeddedSCADomain;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.widget.TextView;
+import calculator.CalculatorService;
+
+public class CalculatorClient extends Activity {
+ private EmbeddedSCADomain domain;
+ private CalculatorService calculatorService;
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ String calculationResult = "Error !";
+ try {
+
+ SCADomain scaDomain = SCADomain.newInstance("Calculator.composite");
+
+ CalculatorService calculatorService =
+ scaDomain.getService(CalculatorService.class, "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));
+
+ scaDomain.close();
+
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+
+
+
+ TextView tv = new TextView(this);
+ tv.setText("3 + 2 =" + calculationResult);
+ setContentView(tv);
+
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+
+ try {
+ //scaDomain.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onContentChanged() {
+ super.onContentChanged();
+ /*
+ // 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));
+ */
+
+ }
+
+
+} \ No newline at end of file
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/android/R$attr.class b/branches/sca-java-1.x/samples/calculator-android/src/calculator/android/R$attr.class
new file mode 100644
index 0000000000..4d7e121ddc
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/android/R$attr.class
Binary files differ
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/android/R$drawable.class b/branches/sca-java-1.x/samples/calculator-android/src/calculator/android/R$drawable.class
new file mode 100644
index 0000000000..842aa47958
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/android/R$drawable.class
Binary files differ
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/android/R$layout.class b/branches/sca-java-1.x/samples/calculator-android/src/calculator/android/R$layout.class
new file mode 100644
index 0000000000..2b7eadeac8
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/android/R$layout.class
Binary files differ
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/android/R$string.class b/branches/sca-java-1.x/samples/calculator-android/src/calculator/android/R$string.class
new file mode 100644
index 0000000000..fd104e6c86
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/android/R$string.class
Binary files differ
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/android/R.class b/branches/sca-java-1.x/samples/calculator-android/src/calculator/android/R.class
new file mode 100644
index 0000000000..7bca04a8a4
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/android/R.class
Binary files differ
diff --git a/branches/sca-java-1.x/samples/calculator-android/src/calculator/android/R.java b/branches/sca-java-1.x/samples/calculator-android/src/calculator/android/R.java
new file mode 100644
index 0000000000..a338c98c3a
--- /dev/null
+++ b/branches/sca-java-1.x/samples/calculator-android/src/calculator/android/R.java
@@ -0,0 +1,23 @@
+/* AUTO-GENERATED FILE. DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found. It
+ * should not be modified by hand.
+ */
+
+package calculator.android;
+
+public final class R {
+ public static final class attr {
+ }
+ public static final class drawable {
+ public static final int icon=0x7f020000;
+ }
+ public static final class layout {
+ public static final int main=0x7f030000;
+ }
+ public static final class string {
+ public static final int app_name=0x7f040001;
+ public static final int hello=0x7f040000;
+ }
+}