diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-13 01:42:27 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-13 01:42:27 +0000 |
commit | 3c7c4a749baafcf375f4785a7668d3a25c9063e3 (patch) | |
tree | a66b8b031c5dc6c7744f44b44b6bcd371bd0b8df /sca-java-1.x/trunk/samples/calculator-android/src/calculator | |
parent | eb03ff672236cddf65533f39b83ddd5e2984a2bb (diff) |
Moving 1.x trunk
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835700 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-1.x/trunk/samples/calculator-android/src/calculator')
31 files changed, 474 insertions, 0 deletions
diff --git a/sca-java-1.x/trunk/samples/calculator-android/src/calculator/AddService.class b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/AddService.class Binary files differnew file mode 100644 index 0000000000..8a5ed25f9f --- /dev/null +++ b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/AddService.class diff --git a/sca-java-1.x/trunk/samples/calculator-android/src/calculator/AddService.java b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/AddService.java new file mode 100644 index 0000000000..21c6789632 --- /dev/null +++ b/sca-java-1.x/trunk/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/sca-java-1.x/trunk/samples/calculator-android/src/calculator/AddServiceImpl.class b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/AddServiceImpl.class Binary files differnew file mode 100644 index 0000000000..c6fd83f6a1 --- /dev/null +++ b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/AddServiceImpl.class diff --git a/sca-java-1.x/trunk/samples/calculator-android/src/calculator/AddServiceImpl.java b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..6181a1c651 --- /dev/null +++ b/sca-java-1.x/trunk/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/sca-java-1.x/trunk/samples/calculator-android/src/calculator/CalculatorBuilder.class b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/CalculatorBuilder.class Binary files differnew file mode 100644 index 0000000000..b4466a3017 --- /dev/null +++ b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/CalculatorBuilder.class diff --git a/sca-java-1.x/trunk/samples/calculator-android/src/calculator/CalculatorClient.class b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/CalculatorClient.class Binary files differnew file mode 100644 index 0000000000..aaf9e9710f --- /dev/null +++ b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/CalculatorClient.class diff --git a/sca-java-1.x/trunk/samples/calculator-android/src/calculator/CalculatorClient.java b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/CalculatorClient.java new file mode 100644 index 0000000000..3b977259e8 --- /dev/null +++ b/sca-java-1.x/trunk/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/sca-java-1.x/trunk/samples/calculator-android/src/calculator/CalculatorService.class b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/CalculatorService.class Binary files differnew file mode 100644 index 0000000000..c3cc2911e9 --- /dev/null +++ b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/CalculatorService.class diff --git a/sca-java-1.x/trunk/samples/calculator-android/src/calculator/CalculatorService.java b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/CalculatorService.java new file mode 100644 index 0000000000..862d7b892d --- /dev/null +++ b/sca-java-1.x/trunk/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/sca-java-1.x/trunk/samples/calculator-android/src/calculator/CalculatorServiceImpl.class b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/CalculatorServiceImpl.class Binary files differnew file mode 100644 index 0000000000..8e0f206119 --- /dev/null +++ b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/CalculatorServiceImpl.class diff --git a/sca-java-1.x/trunk/samples/calculator-android/src/calculator/CalculatorServiceImpl.java b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..2c88b5319e --- /dev/null +++ b/sca-java-1.x/trunk/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/sca-java-1.x/trunk/samples/calculator-android/src/calculator/DivideService.class b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/DivideService.class Binary files differnew file mode 100644 index 0000000000..8f056b16b6 --- /dev/null +++ b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/DivideService.class diff --git a/sca-java-1.x/trunk/samples/calculator-android/src/calculator/DivideService.java b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/DivideService.java new file mode 100644 index 0000000000..8f544632dc --- /dev/null +++ b/sca-java-1.x/trunk/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/sca-java-1.x/trunk/samples/calculator-android/src/calculator/DivideServiceImpl.class b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/DivideServiceImpl.class Binary files differnew file mode 100644 index 0000000000..09cae06d9c --- /dev/null +++ b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/DivideServiceImpl.class diff --git a/sca-java-1.x/trunk/samples/calculator-android/src/calculator/DivideServiceImpl.java b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..5dfae77222 --- /dev/null +++ b/sca-java-1.x/trunk/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/sca-java-1.x/trunk/samples/calculator-android/src/calculator/MultiplyService.class b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/MultiplyService.class Binary files differnew file mode 100644 index 0000000000..6542db7083 --- /dev/null +++ b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/MultiplyService.class diff --git a/sca-java-1.x/trunk/samples/calculator-android/src/calculator/MultiplyService.java b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/MultiplyService.java new file mode 100644 index 0000000000..f7f4ee77b5 --- /dev/null +++ b/sca-java-1.x/trunk/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/sca-java-1.x/trunk/samples/calculator-android/src/calculator/MultiplyServiceImpl.class b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/MultiplyServiceImpl.class Binary files differnew file mode 100644 index 0000000000..0e69e7ad2d --- /dev/null +++ b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/MultiplyServiceImpl.class diff --git a/sca-java-1.x/trunk/samples/calculator-android/src/calculator/MultiplyServiceImpl.java b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..3142f86a58 --- /dev/null +++ b/sca-java-1.x/trunk/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/sca-java-1.x/trunk/samples/calculator-android/src/calculator/SubtractService.class b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/SubtractService.class Binary files differnew file mode 100644 index 0000000000..84c741e301 --- /dev/null +++ b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/SubtractService.class diff --git a/sca-java-1.x/trunk/samples/calculator-android/src/calculator/SubtractService.java b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/SubtractService.java new file mode 100644 index 0000000000..2349febb0f --- /dev/null +++ b/sca-java-1.x/trunk/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/sca-java-1.x/trunk/samples/calculator-android/src/calculator/SubtractServiceImpl.class b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/SubtractServiceImpl.class Binary files differnew file mode 100644 index 0000000000..7b1aeab811 --- /dev/null +++ b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/SubtractServiceImpl.class diff --git a/sca-java-1.x/trunk/samples/calculator-android/src/calculator/SubtractServiceImpl.java b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..ec55f4f07d --- /dev/null +++ b/sca-java-1.x/trunk/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/sca-java-1.x/trunk/samples/calculator-android/src/calculator/android/CalculatorClient.class b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/android/CalculatorClient.class Binary files differnew file mode 100644 index 0000000000..20b588f972 --- /dev/null +++ b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/android/CalculatorClient.class diff --git a/sca-java-1.x/trunk/samples/calculator-android/src/calculator/android/CalculatorClient.java b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/android/CalculatorClient.java new file mode 100644 index 0000000000..9e5c782447 --- /dev/null +++ b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/android/CalculatorClient.java @@ -0,0 +1,233 @@ +package calculator.android; + +import java.io.FileDescriptor; +import java.net.InetAddress; +import java.net.URL; +import java.security.Permission; + +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 { + System.setSecurityManager(new SecurityManager() { + @Override + public void checkPermission(Permission permission) { + + } + + @Override + public void checkAccept(String host, int port) { + + } + + @Override + public void checkAccess(Thread thread) { + // TODO Auto-generated method stub + + } + @Override + public void checkAccess(ThreadGroup group) { + + } + + @Override + public void checkAwtEventQueueAccess() { + // TODO Auto-generated method stub + + } + @Override + public void checkConnect(String host, int port) { + + } + @Override + public void checkConnect(String host, int port, Object context) { + + } + @Override + public void checkCreateClassLoader() { + // TODO Auto-generated method stub + + } + @Override + public void checkDelete(String file) { + + } + @Override + public void checkExec(String cmd) { + // TODO Auto-generated method stub + + } + @Override + public void checkExit(int status) { + + } + @Override + public void checkLink(String libName) { + // TODO Auto-generated method stub + + } + @Override + public void checkListen(int port) { + // TODO Auto-generated method stub + + } + @Override + public void checkMemberAccess(Class<?> cls, int type) { + // TODO Auto-generated method stub + + } + @Override + public void checkMulticast(InetAddress maddr) { + // TODO Auto-generated method stub + + } + @Override + public void checkMulticast(InetAddress maddr, byte ttl) { + // TODO Auto-generated method stub + + } + @Override + public void checkPackageAccess(String packageName) { + // TODO Auto-generated method stub + + } + @Override + public void checkPackageDefinition(String packageName) { + // TODO Auto-generated method stub + + } + @Override + public void checkPermission(Permission permission, + Object context) { + // TODO Auto-generated method stub + + } + @Override + public void checkPrintJobAccess() { + // TODO Auto-generated method stub + + } + @Override + public void checkPropertiesAccess() { + // TODO Auto-generated method stub + + } + @Override + public void checkPropertyAccess(String key) { + // TODO Auto-generated method stub + + } + @Override + public void checkRead(FileDescriptor fd) { + // TODO Auto-generated method stub + + } + @Override + public void checkRead(String file) { + // TODO Auto-generated method stub + + } + @Override + public void checkRead(String file, Object context) { + // TODO Auto-generated method stub + + } + @Override + public void checkSecurityAccess(String target) { + // TODO Auto-generated method stub + + } + @Override + public void checkSetFactory() { + // TODO Auto-generated method stub + + } + @Override + public void checkSystemClipboardAccess() { + // TODO Auto-generated method stub + + } + + @Override + public void checkWrite(FileDescriptor fd) { + // TODO Auto-generated method stub + + } + @Override + public void checkWrite(String file) { + // TODO Auto-generated method stub + + } + + }); + + Thread.currentThread().setContextClassLoader(getClassLoader()); + + 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/sca-java-1.x/trunk/samples/calculator-android/src/calculator/android/R$attr.class b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/android/R$attr.class Binary files differnew file mode 100644 index 0000000000..4d7e121ddc --- /dev/null +++ b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/android/R$attr.class diff --git a/sca-java-1.x/trunk/samples/calculator-android/src/calculator/android/R$drawable.class b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/android/R$drawable.class Binary files differnew file mode 100644 index 0000000000..842aa47958 --- /dev/null +++ b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/android/R$drawable.class diff --git a/sca-java-1.x/trunk/samples/calculator-android/src/calculator/android/R$layout.class b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/android/R$layout.class Binary files differnew file mode 100644 index 0000000000..2b7eadeac8 --- /dev/null +++ b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/android/R$layout.class diff --git a/sca-java-1.x/trunk/samples/calculator-android/src/calculator/android/R$string.class b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/android/R$string.class Binary files differnew file mode 100644 index 0000000000..fd104e6c86 --- /dev/null +++ b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/android/R$string.class diff --git a/sca-java-1.x/trunk/samples/calculator-android/src/calculator/android/R.class b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/android/R.class Binary files differnew file mode 100644 index 0000000000..7bca04a8a4 --- /dev/null +++ b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/android/R.class diff --git a/sca-java-1.x/trunk/samples/calculator-android/src/calculator/android/R.java b/sca-java-1.x/trunk/samples/calculator-android/src/calculator/android/R.java new file mode 100644 index 0000000000..a338c98c3a --- /dev/null +++ b/sca-java-1.x/trunk/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; + } +} |