summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/trunk/tutorials/travelsample/clients/currency-converter-rmi
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-1.x/trunk/tutorials/travelsample/clients/currency-converter-rmi')
-rw-r--r--sca-java-1.x/trunk/tutorials/travelsample/clients/currency-converter-rmi/build.xml36
-rw-r--r--sca-java-1.x/trunk/tutorials/travelsample/clients/currency-converter-rmi/pom.xml59
-rw-r--r--sca-java-1.x/trunk/tutorials/travelsample/clients/currency-converter-rmi/src/main/java/com/tuscanyscatours/currencyconverter/CurrencyConverter.java30
-rw-r--r--sca-java-1.x/trunk/tutorials/travelsample/clients/currency-converter-rmi/src/main/java/scatours/CurrencyConverterRMIClient.java36
4 files changed, 161 insertions, 0 deletions
diff --git a/sca-java-1.x/trunk/tutorials/travelsample/clients/currency-converter-rmi/build.xml b/sca-java-1.x/trunk/tutorials/travelsample/clients/currency-converter-rmi/build.xml
new file mode 100644
index 0000000000..2d9d3bc9d9
--- /dev/null
+++ b/sca-java-1.x/trunk/tutorials/travelsample/clients/currency-converter-rmi/build.xml
@@ -0,0 +1,36 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 name="scatours-client-currency-converter-rmi" default="compile">
+ <import file="../../antdefs.xml"/>
+
+ <!-- Before invoking the "run" target, the RMI implementation of the
+ currency converter service needs to be started in its own process. -->
+ <target name="run-service">
+ <ant dir="../../launchers/currency-converter-rmi" target="run"/>
+ </target>
+
+ <target name="run">
+ <java classname="scatours.CurrencyConverterRMIClient" fork="true">
+ <classpath>
+ <pathelement location="target/${ant.project.name}.jar"/>
+ </classpath>
+ </java>
+ </target>
+</project>
diff --git a/sca-java-1.x/trunk/tutorials/travelsample/clients/currency-converter-rmi/pom.xml b/sca-java-1.x/trunk/tutorials/travelsample/clients/currency-converter-rmi/pom.xml
new file mode 100644
index 0000000000..9b41782f82
--- /dev/null
+++ b/sca-java-1.x/trunk/tutorials/travelsample/clients/currency-converter-rmi/pom.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>scatours</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent><version>1.0-SNAPSHOT</version>
+ <artifactId>scatours-client-currency-converter-rmi</artifactId>
+ <name>Apache Tuscany SCA Tours Currency Converter RMI Client</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.2</version>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <classpathPrefix>../lib/</classpathPrefix>
+ <mainClass>scatours.CurrencyConverterRMIClient</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sca-java-1.x/trunk/tutorials/travelsample/clients/currency-converter-rmi/src/main/java/com/tuscanyscatours/currencyconverter/CurrencyConverter.java b/sca-java-1.x/trunk/tutorials/travelsample/clients/currency-converter-rmi/src/main/java/com/tuscanyscatours/currencyconverter/CurrencyConverter.java
new file mode 100644
index 0000000000..e12a95c964
--- /dev/null
+++ b/sca-java-1.x/trunk/tutorials/travelsample/clients/currency-converter-rmi/src/main/java/com/tuscanyscatours/currencyconverter/CurrencyConverter.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 com.tuscanyscatours.currencyconverter;
+
+/**
+ * The CurrencyConverter service interface
+ */
+public interface CurrencyConverter {
+
+ double getExchangeRate(String fromCurrencyCode, String toCurrencyCode);
+
+ double convert(String fromCurrencyCode, String toCurrencyCode, double amount);
+
+}
diff --git a/sca-java-1.x/trunk/tutorials/travelsample/clients/currency-converter-rmi/src/main/java/scatours/CurrencyConverterRMIClient.java b/sca-java-1.x/trunk/tutorials/travelsample/clients/currency-converter-rmi/src/main/java/scatours/CurrencyConverterRMIClient.java
new file mode 100644
index 0000000000..32e4fccfce
--- /dev/null
+++ b/sca-java-1.x/trunk/tutorials/travelsample/clients/currency-converter-rmi/src/main/java/scatours/CurrencyConverterRMIClient.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 scatours;
+
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+
+import com.tuscanyscatours.currencyconverter.CurrencyConverter;
+
+public class CurrencyConverterRMIClient {
+
+ public static void main(String[] args) throws Exception {
+ Registry registry = LocateRegistry.getRegistry("localhost", 8099);
+ String name = "CurrencyConverterRMI";
+ CurrencyConverter converter = (CurrencyConverter)registry.lookup(name);
+
+ System.out.println("USD -> GBP = " + converter.getExchangeRate("USD", "GBP"));
+ System.out.println("100 USD = " + converter.convert("USD", "GBP", 100.0) + "GBP");
+ }
+}