summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--java/sca/samples/dosgi-calculator-operations/pom.xml2
-rw-r--r--java/sca/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/CalculatorOSGiNodeTestCase.java7
-rw-r--r--java/sca/samples/dosgi-calculator/pom.xml10
-rw-r--r--java/sca/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRMIServer.java2
-rw-r--r--java/sca/samples/dosgi-calculator/src/main/resources/OSGI-INF/sca/bundle.componentType14
-rw-r--r--java/sca/samples/dosgi-calculator/src/main/resources/OSGI-INF/sca/bundle.composite19
-rw-r--r--java/sca/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java35
7 files changed, 67 insertions, 22 deletions
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 @@
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-node-impl-osgi</artifactId>
<version>2.0-SNAPSHOT</version>
- <scope>test</scope>
+ <scope>runtime</scope>
</dependency>
<dependency>
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 @@
<version>2.0-SNAPSHOT</version>
<type>pom</type>
</dependency>
-
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ <scope>runtime</scope>
+ </dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-node-launcher-equinox</artifactId>
@@ -48,7 +54,7 @@
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-node-impl-osgi</artifactId>
<version>2.0-SNAPSHOT</version>
- <scope>test</scope>
+ <scope>runtime</scope>
</dependency>
<dependency>
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.
-->
-<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1">
<!-- The service elment defines an SCA view of the OSGi service -->
- <service name="Calculator">
+ <service name="CalculatorService">
<!-- The interface will be mapped into the OSGi service class -->
<interface.java interface="calculator.dosgi.CalculatorService"/>
<!-- The list of OSGi properties -->
<t:osgi.property name="prop1">1</t:osgi.property>
<t:osgi.property name="prop2">ABC</t:osgi.property>
</service>
-
+
<!-- The reference elment defines an SCA proxy to a remote OSGi service -->
<reference name="addService">
<interface.java interface="calculator.dosgi.operations.AddService"/>
@@ -50,5 +50,5 @@
<t:osgi.property name="prop1">1</t:osgi.property>
<t:osgi.property name="prop2">ABC</t:osgi.property>
</reference>
-
+
</componentType>
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.
-->
-<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- targetNamespace="http://calculator.dosgi"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://calculator.dosgi"
name="CalculatorComposite">
<component name="CalculatorComponent">
<tuscany:implementation.osgi bundleSymbolicName="calculator.dosgi" bundleVersion="1.0.0" />
+ <service name="CalculatorService">
+ <binding.ws uri="http://localhost:8086/CalculatorService"/>
+ </service>
<reference name="addService">
<tuscany:binding.rmi uri="rmi://localhost:8085/AddService"/>
</reference>
@@ -37,8 +40,8 @@
<reference name="divideService">
<tuscany:binding.rmi uri="rmi://localhost:8085/DivideService"/>
</reference>
-
- <!--
+
+ <!--
<reference name="addService" target="OperationsComponent/AddService">
</reference>
<reference name="subtractService" target="OperationsComponent/SubtractService">
diff --git a/java/sca/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java b/java/sca/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java
index 213ee22436..d4bede0d98 100644
--- a/java/sca/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java
+++ b/java/sca/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java
@@ -21,6 +21,11 @@ package calculator.dosgi.test;
import static calculator.dosgi.test.OSGiTestUtils.bundleStatus;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URL;
+
import org.apache.tuscany.sca.node.equinox.launcher.EquinoxHost;
import org.junit.AfterClass;
import org.junit.Assert;
@@ -28,6 +33,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 org.osgi.framework.ServiceReference;
import calculator.dosgi.CalculatorService;
@@ -59,9 +65,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));
@@ -96,6 +104,29 @@ public class CalculatorOSGiNodeTestCase {
System.out.println("2.0 / 1.0 = " + calculator.divide(2.0, 1.0));
}
+ @Test
+ /**
+ * Test the Web service exposed by the Calculator
+ */
+ public void testWS() throws Exception {
+ URL url = new URL("http://localhost:8086/CalculatorService?wsdl");
+ InputStream is = url.openStream();
+ Reader reader = new InputStreamReader(is);
+ char[] content = new char[10240]; // 10k
+ int len = 0;
+ while (true) {
+ int size = reader.read(content, len, content.length - len);
+ if (size < 0) {
+ break;
+ }
+ len += size;
+ }
+ Assert.assertTrue(len > 0);
+ String str = new String(content, 0, len);
+ System.out.println(str);
+ Assert.assertTrue(str.indexOf("<wsdl:definitions") != -1);
+ }
+
/**
* @throws java.lang.Exception
*/