summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/node-launcher-equinox
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-09-09 22:24:55 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-09-09 22:24:55 +0000
commit8c7f53c15bf5b2dc64d96e1bee8b1f8cc632d48a (patch)
tree7ea9c24be52993fc36a414df4a52b1e1c35c985e /java/sca/modules/node-launcher-equinox
parenta1bc5c955317ac6ba27cf44d4575dcdd0ffb654a (diff)
Use bundle.getResources to discover services
Run the test case within OSGi git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@693637 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/node-launcher-equinox')
-rw-r--r--java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java5
-rw-r--r--java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java1
-rw-r--r--java/sca/modules/node-launcher-equinox/src/test/java/hello/HelloWorldClient.java50
-rw-r--r--java/sca/modules/node-launcher-equinox/src/test/java/hello/HelloWorldImpl.java2
-rw-r--r--java/sca/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java7
-rw-r--r--java/sca/modules/node-launcher-equinox/src/test/resources/HelloWorld.composite8
6 files changed, 62 insertions, 11 deletions
diff --git a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java
index 2a6e24f6e0..06bc1907b4 100644
--- a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java
+++ b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java
@@ -100,7 +100,7 @@ public class EquinoxHost {
props.put("osgi.contextClassLoaderParent", "boot");
// Set the extension bundle
- props.put("osgi.framework.extensions", "org.apache.tuscany.sca.extensibility.equinox");
+ props.put("osgi.framework.extensions", "org.apache.tuscany.sca.node.launcher.equinox");
// Set startup properties
props.put(EclipseStarter.PROP_CLEAN, "true");
@@ -205,6 +205,9 @@ public class EquinoxHost {
* @throws IOException
*/
private static String getBundleName(File file) throws IOException {
+ if (!file.exists()) {
+ return null;
+ }
String bundleName = null;
if (file.isDirectory()) {
File mf = new File(file, "META-INF/MANIFEST.MF");
diff --git a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java
index 07da404d12..b422651244 100644
--- a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java
+++ b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java
@@ -250,6 +250,7 @@ final class NodeLauncherUtil {
if (!entry.isDirectory() && entryName != null
&& entryName.length() > 0
&& !entryName.startsWith(".")
+ && entryName.endsWith(".class") // Exclude resources from Export-Package
&& entryName.lastIndexOf("/") > 0) {
String pkg = entryName.substring(0, entryName.lastIndexOf("/")).replace('/', '.') + version;
packages.add(pkg);
diff --git a/java/sca/modules/node-launcher-equinox/src/test/java/hello/HelloWorldClient.java b/java/sca/modules/node-launcher-equinox/src/test/java/hello/HelloWorldClient.java
new file mode 100644
index 0000000000..11e008619c
--- /dev/null
+++ b/java/sca/modules/node-launcher-equinox/src/test/java/hello/HelloWorldClient.java
@@ -0,0 +1,50 @@
+/*
+ * 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 hello;
+
+import org.osoa.sca.annotations.EagerInit;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+@Scope("COMPOSITE")
+@EagerInit
+public class HelloWorldClient {
+
+ private HelloWorld hw;
+
+ @Reference
+ public void setHelloWorld(HelloWorld hw) {
+ this.hw = hw;
+ }
+
+ @Init
+ public void hello() {
+ // Say hello
+ System.out.println("Contribution ClassLoader: " + getClass().getClassLoader());
+ System.out.println("SCA API ClassLoader: " + Reference.class.getClassLoader());
+ System.out.println(hw.hello("Equinox"));
+ }
+
+}
diff --git a/java/sca/modules/node-launcher-equinox/src/test/java/hello/HelloWorldImpl.java b/java/sca/modules/node-launcher-equinox/src/test/java/hello/HelloWorldImpl.java
index c9a7560b12..e51d3c79d9 100644
--- a/java/sca/modules/node-launcher-equinox/src/test/java/hello/HelloWorldImpl.java
+++ b/java/sca/modules/node-launcher-equinox/src/test/java/hello/HelloWorldImpl.java
@@ -24,7 +24,7 @@ package hello;
*/
public class HelloWorldImpl implements HelloWorld {
public String hello(String name) {
- System.out.println("Hello: " + name);
+ System.out.println("Name: " + name);
return "Hello, " + name;
}
}
diff --git a/java/sca/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java b/java/sca/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java
index 569b82cf4c..b16045a103 100644
--- a/java/sca/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java
+++ b/java/sca/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java
@@ -19,9 +19,6 @@
package org.apache.tuscany.sca.node.equinox.launcher;
-import hello.HelloWorld;
-
-import org.apache.tuscany.sca.node.SCAClient;
import org.apache.tuscany.sca.node.SCANode;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -55,10 +52,6 @@ public class NodeLauncherTestCase {
public void testLaunch() throws Exception {
SCANode node = launcher.createNodeFromClassLoader("HelloWorld.composite", getClass().getClassLoader());
node.start();
-
- HelloWorld hw = ((SCAClient)node).getService(HelloWorld.class, "HelloWorld");
- hw.hello("OSGi");
-
node.stop();
}
diff --git a/java/sca/modules/node-launcher-equinox/src/test/resources/HelloWorld.composite b/java/sca/modules/node-launcher-equinox/src/test/resources/HelloWorld.composite
index 9e3299d691..0608e70ca5 100644
--- a/java/sca/modules/node-launcher-equinox/src/test/resources/HelloWorld.composite
+++ b/java/sca/modules/node-launcher-equinox/src/test/resources/HelloWorld.composite
@@ -22,9 +22,13 @@
targetNamespace="http://sample/composite"
xmlns:sc="http://sample/composite"
name="HelloWorld">
-
+
<component name="HelloWorld">
- <implementation.java class="hello.HelloWorldImpl"/>
+ <implementation.java class="hello.HelloWorldImpl" />
+ </component>
+ <component name="HelloWorldClient">
+ <implementation.java class="hello.HelloWorldClient" />
+ <reference name="helloWorld" target="HelloWorld"></reference>
</component>
</composite>