From 15cb80cb8e53910e05f6d6f6d8ed4536eb335eba Mon Sep 17 00:00:00 2001 From: rfeng Date: Mon, 16 Mar 2009 23:17:35 +0000 Subject: Add missing composites and use SCA-Composite header git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@755037 13f79535-47bb-0310-9956-ffa450edef68 --- java/sca/modules/implementation-osgi-runtime/pom.xml | 7 +++++++ .../calculator/dosgi/test/CalculatorOSGiNodeTestCase.java | 3 ++- .../test/resources/calculator/dosgi/META-INF/MANIFEST.MF | 1 + .../calculator/dosgi/operations/META-INF/MANIFEST.MF | 1 + .../calculator/dosgi/operations/operations.composite | 8 -------- .../apache/tuscany/sca/node/osgi/impl/NodeActivator.java | 1 + .../org/apache/tuscany/sca/node/osgi/impl/NodeImpl.java | 5 ++++- .../org/apache/tuscany/sca/node/osgi/impl/NodeManager.java | 13 ++++++++++--- 8 files changed, 26 insertions(+), 13 deletions(-) (limited to 'java') diff --git a/java/sca/modules/implementation-osgi-runtime/pom.xml b/java/sca/modules/implementation-osgi-runtime/pom.xml index b7ac27f7e0..91ee8e3e24 100644 --- a/java/sca/modules/implementation-osgi-runtime/pom.xml +++ b/java/sca/modules/implementation-osgi-runtime/pom.xml @@ -154,6 +154,13 @@ test + + org.apache.tuscany.sca + tuscany-extensibility-equinox + 2.0-SNAPSHOT + test + + junit junit diff --git a/java/sca/modules/implementation-osgi-runtime/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java b/java/sca/modules/implementation-osgi-runtime/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java index 1dee0b1ae7..04341bcd3f 100644 --- a/java/sca/modules/implementation-osgi-runtime/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java +++ b/java/sca/modules/implementation-osgi-runtime/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java @@ -102,7 +102,8 @@ public class CalculatorOSGiNodeTestCase { new String[] {"OSGI-INF/add-component.xml", "OSGI-INF/subtract-component.xml", "OSGI-INF/multiply-component.xml", - "OSGI-INF/divide-component.xml"}, + "OSGI-INF/divide-component.xml", + "calculator/dosgi/operations/operations.composite"}, OperationsActivator.class, AddService.class, AddServiceImpl.class, diff --git a/java/sca/modules/implementation-osgi-runtime/src/test/resources/calculator/dosgi/META-INF/MANIFEST.MF b/java/sca/modules/implementation-osgi-runtime/src/test/resources/calculator/dosgi/META-INF/MANIFEST.MF index f0f640541f..5973372d7c 100644 --- a/java/sca/modules/implementation-osgi-runtime/src/test/resources/calculator/dosgi/META-INF/MANIFEST.MF +++ b/java/sca/modules/implementation-osgi-runtime/src/test/resources/calculator/dosgi/META-INF/MANIFEST.MF @@ -16,3 +16,4 @@ Eclipse-LazyStart: true Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt Bundle-DocURL: http://www.apache.org/ Service-Component: OSGI-INF/calculator-component.xml +SCA-Composite: calculator/dosgi/calculator.composite diff --git a/java/sca/modules/implementation-osgi-runtime/src/test/resources/calculator/dosgi/operations/META-INF/MANIFEST.MF b/java/sca/modules/implementation-osgi-runtime/src/test/resources/calculator/dosgi/operations/META-INF/MANIFEST.MF index 2dbead0b88..d353e7edb6 100644 --- a/java/sca/modules/implementation-osgi-runtime/src/test/resources/calculator/dosgi/operations/META-INF/MANIFEST.MF +++ b/java/sca/modules/implementation-osgi-runtime/src/test/resources/calculator/dosgi/operations/META-INF/MANIFEST.MF @@ -17,3 +17,4 @@ Service-Component: OSGI-INF/add-component.xml, OSGI-INF/subtract-component.xml, OSGI-INF/multiply-component.xml, OSGI-INF/divide-component.xml +SCA-Composite: calculator/dosgi/operations/operations.composite diff --git a/java/sca/modules/implementation-osgi-runtime/src/test/resources/calculator/dosgi/operations/operations.composite b/java/sca/modules/implementation-osgi-runtime/src/test/resources/calculator/dosgi/operations/operations.composite index 14c2b6a4e4..964be5643e 100644 --- a/java/sca/modules/implementation-osgi-runtime/src/test/resources/calculator/dosgi/operations/operations.composite +++ b/java/sca/modules/implementation-osgi-runtime/src/test/resources/calculator/dosgi/operations/operations.composite @@ -25,14 +25,6 @@ - - - - - - - - diff --git a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeActivator.java b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeActivator.java index 42ae9d89f3..a67a7c0a45 100644 --- a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeActivator.java +++ b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeActivator.java @@ -75,6 +75,7 @@ public class NodeActivator implements BundleActivator, SynchronousBundleListener public void bundleChanged(BundleEvent event) { if (event.getType() == BundleEvent.STARTING) { if (isSCABundle(event.getBundle())) { + bundleContext.removeBundleListener(this); init(); } } diff --git a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeImpl.java b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeImpl.java index 8ecb8b968d..2b74720a53 100644 --- a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeImpl.java +++ b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeImpl.java @@ -147,7 +147,10 @@ public class NodeImpl implements Node, Client { modelFactories.getFactory(NodeImplementationFactory.class); ConfiguredNodeImplementation configuration = nodeImplementationFactory.createConfiguredNodeImplementation(); - String compositeURI = "OSGI-INF/sca/bundle.composite"; + String compositeURI = (String)bundle.getHeaders().get("SCA-Composite"); + if (compositeURI == null) { + compositeURI = "OSGI-INF/sca/bundle.composite"; + } if (compositeURI != null) { Composite composite = assemblyFactory.createComposite(); composite.setURI(compositeURI); diff --git a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java index 68575b6c74..0dccdd95e9 100644 --- a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java +++ b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java @@ -23,6 +23,8 @@ import java.util.Dictionary; import java.util.Enumeration; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import java.util.logging.Level; +import java.util.logging.Logger; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; @@ -35,6 +37,7 @@ import org.osgi.framework.SynchronousBundleListener; * Managing the mapping between OSGi bundles and SCA implementation.osgi */ public class NodeManager implements SynchronousBundleListener, ServiceListener { + private static final Logger logger = Logger.getLogger(NodeManager.class.getName()); private BundleContext bundleContext; private Map nodes = new ConcurrentHashMap(); @@ -84,9 +87,13 @@ public class NodeManager implements SynchronousBundleListener, ServiceListener { if (!isSCABundle(bundle)) { return; } - NodeImpl node = new NodeImpl(bundle); - nodes.put(bundle, node); - node.start(); + try { + NodeImpl node = new NodeImpl(bundle); + nodes.put(bundle, node); + node.start(); + } catch (Throwable e) { + logger.log(Level.SEVERE, e.getMessage(), e); + } } private void bundleStopping(Bundle bundle) { -- cgit v1.2.3