From 3ef97e3558b10b558afaaac3942b60993faa7441 Mon Sep 17 00:00:00 2001 From: rfeng Date: Tue, 7 Apr 2009 21:08:52 +0000 Subject: Expose the CalculatorService as a web service git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@762966 13f79535-47bb-0310-9956-ffa450edef68 --- .../samples/dosgi-calculator-operations/pom.xml | 2 +- .../test/CalculatorOSGiNodeTestCase.java | 7 +++-- java/sca/samples/dosgi-calculator/pom.xml | 10 +++++-- .../java/calculator/rmi/OperationsRMIServer.java | 2 ++ .../resources/OSGI-INF/sca/bundle.componentType | 14 ++++----- .../main/resources/OSGI-INF/sca/bundle.composite | 19 +++++++----- .../dosgi/test/CalculatorOSGiNodeTestCase.java | 35 ++++++++++++++++++++-- 7 files changed, 67 insertions(+), 22 deletions(-) (limited to 'java/sca') diff --git a/java/sca/samples/dosgi-calculator-operations/pom.xml b/java/sca/samples/dosgi-calculator-operations/pom.xml index 945b9bbb6d..fd08e25e72 100644 --- a/java/sca/samples/dosgi-calculator-operations/pom.xml +++ b/java/sca/samples/dosgi-calculator-operations/pom.xml @@ -48,7 +48,7 @@ org.apache.tuscany.sca tuscany-node-impl-osgi 2.0-SNAPSHOT - test + runtime diff --git a/java/sca/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/CalculatorOSGiNodeTestCase.java b/java/sca/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/CalculatorOSGiNodeTestCase.java index cedba02b47..fbda1990fa 100644 --- a/java/sca/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/CalculatorOSGiNodeTestCase.java +++ b/java/sca/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/CalculatorOSGiNodeTestCase.java @@ -34,6 +34,7 @@ import org.junit.BeforeClass; import org.junit.Test; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; +import org.osgi.framework.Constants; import calculator.dosgi.operations.AddService; @@ -66,9 +67,11 @@ public class CalculatorOSGiNodeTestCase { if (b.getSymbolicName().equals("org.eclipse.equinox.ds") || b.getSymbolicName() .startsWith("org.apache.tuscany.sca.")) { try { - b.start(); + if (b.getHeaders().get(Constants.FRAGMENT_HOST) == null) { + // Start the non-fragment bundle + b.start(); + } } catch (Exception e) { - System.out.println(bundleStatus(b, false)); e.printStackTrace(); } System.out.println(bundleStatus(b, false)); diff --git a/java/sca/samples/dosgi-calculator/pom.xml b/java/sca/samples/dosgi-calculator/pom.xml index 4f2b390588..2033338434 100644 --- a/java/sca/samples/dosgi-calculator/pom.xml +++ b/java/sca/samples/dosgi-calculator/pom.xml @@ -36,7 +36,13 @@ 2.0-SNAPSHOT pom - + + org.apache.tuscany.sca + tuscany-feature-webservice + 2.0-SNAPSHOT + pom + runtime + org.apache.tuscany.sca tuscany-node-launcher-equinox @@ -48,7 +54,7 @@ org.apache.tuscany.sca tuscany-node-impl-osgi 2.0-SNAPSHOT - test + runtime diff --git a/java/sca/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRMIServer.java b/java/sca/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRMIServer.java index 1cfc438fca..1a3e36f571 100644 --- a/java/sca/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRMIServer.java +++ b/java/sca/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRMIServer.java @@ -58,12 +58,14 @@ public class OperationsRMIServer implements OperationsRemote, Serializable { Thread thread = new Thread() { public void run() { try { + System.out.println("Starting the RMI server for calculator operations..."); Remote stub = UnicastRemoteObject.exportObject(OperationsRMIServer.this); registry = LocateRegistry.createRegistry(8085); registry.bind("AddService", stub); registry.bind("SubtractService", stub); registry.bind("MultiplyService", stub); registry.bind("DivideService", stub); + System.out.println("RMI server for calculator operations is now started."); } catch (Exception e) { e.printStackTrace(); } diff --git a/java/sca/samples/dosgi-calculator/src/main/resources/OSGI-INF/sca/bundle.componentType b/java/sca/samples/dosgi-calculator/src/main/resources/OSGI-INF/sca/bundle.componentType index 7860094626..92b0ac7bf9 100644 --- a/java/sca/samples/dosgi-calculator/src/main/resources/OSGI-INF/sca/bundle.componentType +++ b/java/sca/samples/dosgi-calculator/src/main/resources/OSGI-INF/sca/bundle.componentType @@ -7,28 +7,28 @@ * 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. + * under the License. --> - - + 1 ABC - + @@ -50,5 +50,5 @@ 1 ABC - + diff --git a/java/sca/samples/dosgi-calculator/src/main/resources/OSGI-INF/sca/bundle.composite b/java/sca/samples/dosgi-calculator/src/main/resources/OSGI-INF/sca/bundle.composite index 3c77086c45..7109300293 100644 --- a/java/sca/samples/dosgi-calculator/src/main/resources/OSGI-INF/sca/bundle.composite +++ b/java/sca/samples/dosgi-calculator/src/main/resources/OSGI-INF/sca/bundle.composite @@ -7,24 +7,27 @@ * 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. + * under the License. --> - + + + @@ -37,8 +40,8 @@ - -