Author: rfeng
Date: Fri Aug 8 11:45:38 2008
New Revision: 684046
URL: http://svn.apache.org/viewvc?rev=684046&view=rev
Log:
Use ServiceDiscovery in node2-api to find SCANode2Factory subclasses
Added:
tuscany/java/sca/modules/node2-impl/src/main/resources/META-INF/
tuscany/java/sca/modules/node2-impl/src/main/resources/META-INF/services/
tuscany/java/sca/modules/node2-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.SCANode2Factory
Modified:
tuscany/java/sca/modules/extensibility-osgi/src/main/java/org/apache/tuscany/sca/extensibility/osgi/OSGiServiceDiscoveryActivator.java
tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java
tuscany/java/sca/modules/node2-api/src/main/java/org/apache/tuscany/sca/node/SCANode2Factory.java
tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
tuscany/java/sca/modules/node2-launcher-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/launcher/LauncherBundleActivator.java
tuscany/java/sca/modules/node2-launcher-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/launcher/NodeLauncherUtil.java
tuscany/java/sca/modules/node2-launcher-osgi/src/test/java/org/apache/tuscany/sca/node/osgi/launcher/NodeLauncherTestCase.java
tuscany/java/sca/modules/pom.xml
Modified:
tuscany/java/sca/modules/extensibility-osgi/src/main/java/org/apache/tuscany/sca/extensibility/osgi/OSGiServiceDiscoveryActivator.java
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/extensibility-osgi/src/main/java/org/apache/tuscany/sca/extensibility/osgi/OSGiServiceDiscoveryActivator.java?rev=684046&r1=684045&r2=684046&view=diff
==============================================================================
---
tuscany/java/sca/modules/extensibility-osgi/src/main/java/org/apache/tuscany/sca/extensibility/osgi/OSGiServiceDiscoveryActivator.java
(original)
+++
tuscany/java/sca/modules/extensibility-osgi/src/main/java/org/apache/tuscany/sca/extensibility/osgi/OSGiServiceDiscoveryActivator.java
Fri Aug 8 11:45:38 2008
@@ -27,13 +27,18 @@
* The Bundle Activator that creates the OSGi-based service discoverer
*/
public class OSGiServiceDiscoveryActivator implements BundleActivator {
+ private static BundleContext bundleContext;
public void start(BundleContext context) throws Exception {
- OSGiServiceDiscoverer discoverer = new OSGiServiceDiscoverer(context);
- ServiceDiscovery.setServiceDiscoverer(discoverer);
+ if (bundleContext == null) {
+ bundleContext = context;
+ OSGiServiceDiscoverer discoverer = new
OSGiServiceDiscoverer(bundleContext);
+ ServiceDiscovery.setServiceDiscoverer(discoverer);
+ }
}
- public void stop(BundleContext arg0) throws Exception {
+ public void stop(BundleContext context) throws Exception {
+ bundleContext = null;
// ServiceDiscovery.setServiceDiscoverer(discoverer);
}
Modified:
tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java?rev=684046&r1=684045&r2=684046&view=diff
==============================================================================
---
tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java
(original)
+++
tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java
Fri Aug 8 11:45:38 2008
@@ -20,8 +20,11 @@
package org.apache.tuscany.sca.extensibility;
import java.io.IOException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.HashSet;
import java.util.Set;
+import java.util.logging.Level;
import java.util.logging.Logger;
/**
@@ -49,21 +52,21 @@
public static ServiceDiscovery getInstance() {
return instance;
}
-
+
public static ServiceDiscoverer getServiceDiscoverer() {
if (discoverer == null) {
discoverer = new ClasspathServiceDiscover();
}
return discoverer;
}
-
+
public static void setServiceDiscoverer(ServiceDiscoverer sd) {
if (discoverer != null) {
throw new IllegalStateException("The ServiceDiscoverer cannot be
reset");
}
discoverer = sd;
}
-
+
/**
* Register a ClassLoader with this discovery mechanism. Tuscany extension
* ClassLoaders are registered here.
@@ -73,7 +76,7 @@
public synchronized void registerClassLoader(ClassLoader classLoader) {
registeredClassLoaders.add(classLoader);
}
-
+
/**
* Unregister a ClassLoader with this discovery mechanism.
*
@@ -115,9 +118,22 @@
* @throws IOException
* @throws ClassNotFoundException
*/
- public Class<?> loadFirstServiceClass(Class<?> serviceInterface) throws
IOException, ClassNotFoundException {
+ public Class<?> loadFirstServiceClass(final Class<?> serviceInterface)
throws IOException, ClassNotFoundException {
+ // Try System property first
+ String className = AccessController.doPrivileged(new
PrivilegedAction<String>() {
+ public String run() {
+ return System.getProperty(serviceInterface.getName());
+ }
+ });
+ if (className != null) {
+ try {
+ return Class.forName(className, false,
Thread.currentThread().getContextClassLoader());
+ } catch (ClassNotFoundException e) {
+ logger.log(Level.WARNING, e.getMessage(), e);
+ }
+ }
Set<ServiceDeclaration> services =
getServiceDiscoverer().discover(serviceInterface.getName(), true);
- if(services.isEmpty()) {
+ if (services.isEmpty()) {
return null;
}
return services.iterator().next().loadClass();
Modified:
tuscany/java/sca/modules/node2-api/src/main/java/org/apache/tuscany/sca/node/SCANode2Factory.java
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node2-api/src/main/java/org/apache/tuscany/sca/node/SCANode2Factory.java?rev=684046&r1=684045&r2=684046&view=diff
==============================================================================
---
tuscany/java/sca/modules/node2-api/src/main/java/org/apache/tuscany/sca/node/SCANode2Factory.java
(original)
+++
tuscany/java/sca/modules/node2-api/src/main/java/org/apache/tuscany/sca/node/SCANode2Factory.java
Fri Aug 8 11:45:38 2008
@@ -19,8 +19,10 @@
package org.apache.tuscany.sca.node;
-import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import org.osoa.sca.CallableReference;
+import org.osoa.sca.ServiceReference;
import org.osoa.sca.ServiceRuntimeException;
/**
@@ -30,8 +32,85 @@
* @version $Rev$ $Date$
*/
public abstract class SCANode2Factory {
-
-
+
+ public static class NodeProxy implements SCANode2, SCAClient {
+ private Object node;
+
+ private NodeProxy(Object node) {
+ super();
+ this.node = node;
+ }
+
+ public static <T> T createProxy(Class<T> type, Object node) {
+ try {
+ return
type.getDeclaredConstructor(Object.class).newInstance(node);
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public <B, R extends CallableReference<B>> R cast(B target) throws
IllegalArgumentException {
+ try {
+ return (R)node.getClass().getMethod("cast",
Object.class).invoke(node, target);
+ } catch (Throwable e) {
+ handleException(e);
+ return null;
+ }
+ }
+
+ public <B> B getService(Class<B> businessInterface, String
serviceName) {
+ try {
+ return (B)node.getClass().getMethod("getService", Class.class,
String.class).invoke(node,
+
businessInterface,
+
serviceName);
+ } catch (Throwable e) {
+ handleException(e);
+ return null;
+ }
+ }
+
+ public <B> ServiceReference<B> getServiceReference(Class<B>
businessInterface, String serviceName) {
+ try {
+ return
(ServiceReference<B>)node.getClass().getMethod("getServiceReference",
Class.class, String.class)
+ .invoke(node, businessInterface, serviceName);
+ } catch (Throwable e) {
+ handleException(e);
+ return null;
+ }
+ }
+
+ public void start() {
+ try {
+ node.getClass().getMethod("start").invoke(node);
+ } catch (Throwable e) {
+ handleException(e);
+ }
+ }
+
+ public void stop() {
+ try {
+ node.getClass().getMethod("stop").invoke(node);
+ } catch (Throwable e) {
+ handleException(e);
+ }
+ }
+
+ private static void handleException(Throwable ex) {
+ if (ex instanceof InvocationTargetException) {
+ ex = ((InvocationTargetException)ex).getTargetException();
+ }
+ if (ex instanceof RuntimeException) {
+ throw (RuntimeException)ex;
+ }
+ if (ex instanceof Error) {
+ throw (Error)ex;
+ } else {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ }
+
/**
* Returns a new SCA node factory instance.
*
@@ -39,30 +118,35 @@
*/
public static SCANode2Factory newInstance() {
SCANode2Factory scaNodeFactory = null;
-
+
try {
final ClassLoader classLoader =
Thread.currentThread().getContextClassLoader();
- String className =
"org.apache.tuscany.sca.node.impl.NodeFactoryImpl";
-
+ // Use reflection APIs to call ServiceDiscovery to avoid hard
dependency to tuscany-extensibility
+ try {
+ Class<?> discoveryClass =
+
Class.forName("org.apache.tuscany.sca.extensibility.ServiceDiscovery", true,
classLoader);
+ Object instance =
discoveryClass.getMethod("getInstance").invoke(null);
+ Class<?> factoryImplClass =
+
(Class<?>)discoveryClass.getMethod("loadFirstServiceClass", Class.class)
+ .invoke(instance, SCANode2Factory.class);
+ if (factoryImplClass != null) {
+ scaNodeFactory =
(SCANode2Factory)factoryImplClass.newInstance();
+ return scaNodeFactory;
+ }
+ } catch (ClassNotFoundException e) {
+ // Ignore
+ }
+
+ // Fail back to default impl
+ String className =
"org.apache.tuscany.sca.node.impl.NodeFactoryImpl";
+
Class<?> cls = Class.forName(className, true, classLoader);
-
- Constructor<?> constructor = null;
-
- try {
- constructor = cls.getConstructor();
- } catch (NoSuchMethodException e) {
- // ignore
- }
-
- if (constructor != null) {
- scaNodeFactory = (SCANode2Factory)constructor.newInstance();
- }
-
+ scaNodeFactory = (SCANode2Factory)cls.newInstance();
return scaNodeFactory;
} catch (Exception e) {
throw new ServiceRuntimeException(e);
- }
+ }
}
/**
@@ -79,7 +163,7 @@
* @return A newly created SCA node
*/
public abstract SCANode2 createSCANodeFromClassLoader(String compositeURI,
ClassLoader classLoader);
-
+
/**
* Creates a new SCA node from the configuration URL
*
@@ -110,23 +194,8 @@
* @param contributions the URI of the contributions that provides the
composites and related artifacts
* @return a new SCA node.
*/
- public abstract SCANode2 createSCANode(String compositeURI, String
compositeContent, SCAContribution... contributions);
-
- /**
- * Creates and starts a new SCA node from a single composite with the
- * contribution being the folder that contains the composite.
- *
- * This method provides the equivalent of doing:
- * <code>
- * File compositeFile = new File(compositeURI);
- * File compositeFolder = compositeFile.getParentFile();
- * SCAContribution contribution = new
SCAContribution(compositeFolder.getName(), compositeFolder.toURL().toString());
- * SCANode2 node =
SCANode2Factory.newInstance().createSCANode(compositeFile.getName(),
contribution);
- * node.start();
- * </code>
- *
- * @param compositeURI the URI of the composite to use
- * @return a new and started SCA node
- */
- public abstract SCANode2 createSCANode(String compositeURI);
+ public abstract SCANode2 createSCANode(String compositeURI,
+ String compositeContent,
+ SCAContribution... contributions);
+
}
Modified:
tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java?rev=684046&r1=684045&r2=684046&view=diff
==============================================================================
---
tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
(original)
+++
tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
Fri Aug 8 11:45:38 2008
@@ -19,13 +19,9 @@
package org.apache.tuscany.sca.node.impl;
-import java.io.File;
-import java.net.MalformedURLException;
-
import org.apache.tuscany.sca.node.SCAContribution;
import org.apache.tuscany.sca.node.SCANode2;
import org.apache.tuscany.sca.node.SCANode2Factory;
-import org.osoa.sca.ServiceRuntimeException;
/**
* Default implementation of an SCA node factory.
@@ -56,26 +52,4 @@
return new NodeImpl(compositeURI, compositeContent, contributions);
}
- @Override
- public SCANode2 createSCANode(String compositeURI) {
- try {
-
- File compositeFile = new File(compositeURI);
- if (!compositeFile.exists()) {
- throw new IllegalArgumentException("composite not found: " +
compositeURI);
- }
-
- File compositeFolder = compositeFile.getParentFile();
- SCAContribution contribution = new
SCAContribution(compositeFolder.getName(), compositeFolder.toURL().toString());
-
- SCANode2 node = createSCANode(compositeFile.getName(),
contribution);
-
- node.start();
-
- return node;
-
- } catch (MalformedURLException e) {
- throw new ServiceRuntimeException(e);
- }
- }
}
Added:
tuscany/java/sca/modules/node2-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.SCANode2Factory
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node2-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.SCANode2Factory?rev=684046&view=auto
==============================================================================
---
tuscany/java/sca/modules/node2-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.SCANode2Factory
(added)
+++
tuscany/java/sca/modules/node2-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.SCANode2Factory
Fri Aug 8 11:45:38 2008
@@ -0,0 +1,17 @@
+# 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.
+org.apache.tuscany.sca.node.impl.NodeFactoryImpl
\ No newline at end of file
Modified:
tuscany/java/sca/modules/node2-launcher-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/launcher/LauncherBundleActivator.java
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node2-launcher-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/launcher/LauncherBundleActivator.java?rev=684046&r1=684045&r2=684046&view=diff
==============================================================================
---
tuscany/java/sca/modules/node2-launcher-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/launcher/LauncherBundleActivator.java
(original)
+++
tuscany/java/sca/modules/node2-launcher-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/launcher/LauncherBundleActivator.java
Fri Aug 8 11:45:38 2008
@@ -3,7 +3,6 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -41,6 +40,8 @@
private BundleContext bundleContext;
private List<Bundle> tuscanyBundles = new ArrayList<Bundle>();
+
+ private List<URL> jarFiles = new ArrayList<URL>();
public static String toString(Bundle b, boolean verbose) {
StringBuffer sb = new StringBuffer();
@@ -103,7 +104,9 @@
for (Bundle bundle : tuscanyBundles) {
try {
- logger.info("Uninstalling bundle: " + toString(bundle, false));
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Uninstalling bundle: " + toString(bundle,
false));
+ }
bundle.uninstall();
} catch (Exception e) {
logger.log(Level.SEVERE, e.getMessage(), e);
@@ -132,7 +135,7 @@
continue;
}
try {
- Bundle bundle = createAndInstallBundle(bundleContext,
file);
+ Bundle bundle = createAndInstallBundle(bundleContext, url);
} catch (Exception e) {
logger.log(Level.SEVERE, e.getMessage(), e);
}
@@ -177,8 +180,10 @@
return null;
}
- public Bundle createAndInstallBundle(BundleContext bundleContext, File
bundleFile) throws Exception {
- logger.info("Installing bundle: " + bundleFile);
+ public Bundle createAndInstallBundle(BundleContext bundleContext, URL
bundleFile) throws Exception {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Installing bundle: " + bundleFile);
+ }
long start = System.currentTimeMillis();
Manifest manifest = readManifest(bundleFile);
@@ -192,11 +197,13 @@
String version = manifest.getMainAttributes().getValue(BUNDLE_VERSION);
Bundle bundle = findBundle(bundleContext, symbolicName, version);
if (bundle != null) {
- logger.info("Bundle is already installed: " + symbolicName);
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Bundle is already installed: " + symbolicName);
+ }
return bundle;
}
- String bundleLocation = bundleFile.toURI().toString();
+ String bundleLocation = bundleFile.toString();
InputStream inStream = null;
if (!isOSGiBundle) {
// We need to repackage the bundle
@@ -215,12 +222,14 @@
inStream = new ByteArrayInputStream(out.toByteArray());
} else {
// The file itself is already a bundle
- inStream = new FileInputStream(bundleFile);
+ inStream = bundleFile.openStream();
}
try {
bundle = bundleContext.installBundle(bundleLocation, inStream);
- logger.info("Bundle installed in " + (System.currentTimeMillis() -
start) + " ms: " + bundleLocation);
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Bundle installed in " +
(System.currentTimeMillis() - start) + " ms: " + bundleLocation);
+ }
tuscanyBundles.add(bundle);
return bundle;
} finally {
@@ -245,12 +254,19 @@
}
return null;
}
+
+ private String getFileName(URL url) {
+ String name = url.getPath();
+ int index = name.lastIndexOf('/');
+ return name.substring(index+1);
+ }
- private void addFileToJar(File file, JarOutputStream jarOut) throws
IOException {
- JarEntry ze = new JarEntry(file.getName());
+ private void addFileToJar(URL file, JarOutputStream jarOut) throws
IOException {
+ JarEntry ze = new JarEntry(getFileName(file));
jarOut.putNextEntry(ze);
- FileInputStream inStream = new FileInputStream(file);
+ InputStream inStream = file.openStream();
copy(inStream, jarOut);
+ inStream.close();
}
private void copy(InputStream in, OutputStream out) throws IOException {
@@ -261,8 +277,8 @@
}
}
- private void copyJar(File file, JarOutputStream jarOut) throws IOException
{
- JarInputStream jarIn = new JarInputStream(new FileInputStream(file));
+ private void copyJar(URL in, JarOutputStream jarOut) throws IOException {
+ JarInputStream jarIn = new JarInputStream(in.openStream());
ZipEntry ze;
while ((ze = jarIn.getNextEntry()) != null) {
// Skip the MANIFEST.MF
@@ -274,11 +290,8 @@
jarIn.close();
}
- private Manifest readManifest(File jarFile) throws IOException {
- if (!jarFile.exists()) {
- return null;
- }
- JarInputStream jar = new JarInputStream(new FileInputStream(jarFile));
+ private Manifest readManifest(URL jarFile) throws IOException {
+ JarInputStream jar = new JarInputStream(jarFile.openStream());
// Read the Manifest from the jar file
Manifest manifest = jar.getManifest();
jar.close();
@@ -290,25 +303,23 @@
return manifest;
}
- private Manifest updateBundleManifest(File jarFile, Manifest manifest)
throws Exception {
-
- if (!jarFile.exists()) {
- return null;
- }
+ private Manifest updateBundleManifest(URL jarFile, Manifest manifest)
throws Exception {
// Check if we have an associated .mf file
- String name = jarFile.getName();
+ String name = jarFile.toString();
int index = name.lastIndexOf('.');
if (index != -1) {
- File mf = new File(jarFile.getParentFile(), name.substring(0,
index) + ".mf");
- if (mf.isFile()) {
- FileInputStream is = new FileInputStream(mf);
- manifest.read(is);
- is.close();
+ URL mf = new URL(name.substring(0, index) + ".mf");
+ try {
+ InputStream in = mf.openStream();
+ manifest.read(in);
+ in.close();
+ } catch(IOException e) {
+ // Ignore
}
}
- String jarFileName = jarFile.getName();
+ String jarFileName = getFileName(jarFile);
boolean isImmutableJar = false;
for (String immutableJar : immutableJars) {
if (jarFileName.startsWith(immutableJar)) {
@@ -319,7 +330,7 @@
Attributes attributes = manifest.getMainAttributes();
if (attributes.getValue(BUNDLE_SYMBOLICNAME) == null) {
- String bundleSymbolicName = jarFile.getName();
+ String bundleSymbolicName = jarFileName;
if (bundleSymbolicName.endsWith(".jar")) {
bundleSymbolicName = bundleSymbolicName.substring(0,
bundleSymbolicName.length() - 4);
}
@@ -341,7 +352,7 @@
attributes.putValue(BUNDLE_CLASSPATH, ".," + jarFileName);
}
- JarInputStream jar = new JarInputStream(new FileInputStream(jarFile));
+ JarInputStream jar = new JarInputStream(jarFile.openStream());
HashSet<String> packages = getPackagesInJar(jarFileName, jar);
jar.close();
String version = getJarVersion(jarFileName);
Modified:
tuscany/java/sca/modules/node2-launcher-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/launcher/NodeLauncherUtil.java
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node2-launcher-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/launcher/NodeLauncherUtil.java?rev=684046&r1=684045&r2=684046&view=diff
==============================================================================
---
tuscany/java/sca/modules/node2-launcher-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/launcher/NodeLauncherUtil.java
(original)
+++
tuscany/java/sca/modules/node2-launcher-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/launcher/NodeLauncherUtil.java
Fri Aug 8 11:45:38 2008
@@ -101,6 +101,13 @@
}
Object node =
bootstrapClass.getMethod("getNode").invoke(bootstrap);
+ try {
+ Class<?> type =
Class.forName("org.apache.tuscany.sca.node.SCANode2Factory");
+ type = type.getDeclaredClasses()[0];
+ return type.getMethod("createProxy", Class.class,
Object.class).invoke(null, type, node);
+ } catch (ClassNotFoundException e) {
+ // Ignore
+ }
return node;
} catch (Exception e) {
@@ -165,13 +172,13 @@
Thread.currentThread().setContextClassLoader(tccl);
}
}
-
+
static OSGiHost startOSGi() {
OSGiHost host = new FelixOSGiHost();
host.start();
return host;
}
-
+
static void stopOSGi(OSGiHost host) {
host.stop();
}
Modified:
tuscany/java/sca/modules/node2-launcher-osgi/src/test/java/org/apache/tuscany/sca/node/osgi/launcher/NodeLauncherTestCase.java
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node2-launcher-osgi/src/test/java/org/apache/tuscany/sca/node/osgi/launcher/NodeLauncherTestCase.java?rev=684046&r1=684045&r2=684046&view=diff
==============================================================================
---
tuscany/java/sca/modules/node2-launcher-osgi/src/test/java/org/apache/tuscany/sca/node/osgi/launcher/NodeLauncherTestCase.java
(original)
+++
tuscany/java/sca/modules/node2-launcher-osgi/src/test/java/org/apache/tuscany/sca/node/osgi/launcher/NodeLauncherTestCase.java
Fri Aug 8 11:45:38 2008
@@ -21,10 +21,11 @@
import hello.HelloWorld;
-import java.lang.reflect.Method;
-
+import org.apache.tuscany.sca.node.SCAClient;
+import org.apache.tuscany.sca.node.SCANode2;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
/**
@@ -50,19 +51,17 @@
@Test
public void testLaunch() throws Exception {
NodeLauncher launcher = NodeLauncher.newInstance();
- Object node =
launcher.createNodeFromClassLoader("HelloWorld.composite",
getClass().getClassLoader());
- Method start = node.getClass().getMethod("start");
- start.invoke(node);
+ SCANode2 node =
launcher.createNodeFromClassLoader("HelloWorld.composite",
getClass().getClassLoader());
+ node.start();
- Method getService = node.getClass().getMethod("getService",
Class.class, String.class);
- HelloWorld hw = (HelloWorld)getService.invoke(node, HelloWorld.class,
"HelloWorld");
+ HelloWorld hw = ((SCAClient)node).getService(HelloWorld.class,
"HelloWorld");
hw.hello("OSGi");
- Method stop = node.getClass().getMethod("stop");
- stop.invoke(node);
+ node.stop();
}
-
+
@Test
+ @Ignore("contribution-osgi issue")
public void testLaunchDomain() throws Exception {
DomainManagerLauncher.main(new String[] {});
}
Modified: tuscany/java/sca/modules/pom.xml
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/modules/pom.xml?rev=684046&r1=684045&r2=684046&view=diff
==============================================================================
--- tuscany/java/sca/modules/pom.xml (original)
+++ tuscany/java/sca/modules/pom.xml Fri Aug 8 11:45:38 2008
@@ -151,9 +151,7 @@
<module>node2-api</module>
<module>node2-impl</module>
<module>node2-launcher</module>
- <!--
<module>node2-launcher-osgi</module>
- -->
<module>node2-launcher-webapp</module>
<module>node-manager</module>
<module>osgi-runtime</module>
@@ -174,6 +172,7 @@
<module>workspace-xml</module>
<module>xsd</module>
<module>xsd-xml</module>
+ <module>tracing-aspectj</module>
</modules>
</profile>