summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java22
-rw-r--r--sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/TopologyManagerImpl.java19
2 files changed, 36 insertions, 5 deletions
diff --git a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java
index c22506d560..d27a8708ee 100644
--- a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java
+++ b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java
@@ -26,6 +26,7 @@ import static org.osgi.framework.Constants.OBJECTCLASS;
import static org.osgi.framework.Constants.SERVICE_ID;
import java.io.IOException;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -59,6 +60,8 @@ import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.deployment.Deployer;
import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation;
import org.apache.tuscany.sca.implementation.osgi.OSGiImplementationFactory;
import org.apache.tuscany.sca.implementation.osgi.OSGiProperty;
@@ -94,7 +97,7 @@ public class EndpointIntrospector {
private ModelResolverExtensionPoint modelResolvers;
// private StAXArtifactProcessor<Composite> compositeProcessor;
private JavaInterfaceFactory javaInterfaceFactory;
- // private Deployer deployer;
+ private Deployer deployer;
private ServiceTracker discoveryTracker;
/**
@@ -134,7 +137,7 @@ public class EndpointIntrospector {
this.policyFactory = factories.getFactory(PolicyFactory.class);
this.implementationFactory = factories.getFactory(OSGiImplementationFactory.class);
this.javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
- // this.deployer = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(Deployer.class);
+ this.deployer = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(Deployer.class);
}
private Intent getIntent(String intent) {
@@ -263,6 +266,17 @@ public class EndpointIntrospector {
Contribution contribution = generateContribution(bundle, sid, remoteInterfaces, bindings, allIntents, osgiProps);
return contribution;
}
+
+ public Contribution loadContribution(Bundle bundle, Composite composite) {
+ try {
+ URL root = bundle.getEntry("/");
+ Contribution contribution = deployer.loadContribution(root.toURI(), root, deployer.createMonitor());
+ deployer.attachDeploymentComposite(contribution, composite, false);
+ return contribution;
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
/**
* Generate a contribution that contains the composite for the exported service
@@ -326,7 +340,7 @@ public class EndpointIntrospector {
}
// FIXME: Should we scan the owning bundle to create the SCA contribution?
- Contribution contribution = createContribution(bundle, id, composite);
+ Contribution contribution = loadContribution(bundle, composite);
return contribution;
}
@@ -419,7 +433,7 @@ public class EndpointIntrospector {
componentReference.getBindings().addAll(bindings);
}
- Contribution contribution = createContribution(bundle, id, composite);
+ Contribution contribution = loadContribution(bundle, composite);
return contribution;
}
diff --git a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/TopologyManagerImpl.java b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/TopologyManagerImpl.java
index 31f4f4c0b3..33faa77c84 100644
--- a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/TopologyManagerImpl.java
+++ b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/TopologyManagerImpl.java
@@ -195,7 +195,11 @@ public class TopologyManagerImpl implements ListenerHook, RemoteServiceAdminList
Collection<ListenerInfo> listenerInfos = (Collection<ListenerInfo>)listeners;
boolean changed = false;
for (ListenerInfo l : listenerInfos) {
- if (!l.isRemoved() && l.getBundleContext() != context) {
+ if (l.getBundleContext().getBundle().getBundleId() == 0L || l.getBundleContext() == context) {
+ // Ignore system and tuscany bundle
+ continue;
+ }
+ if (!l.isRemoved()) {
String key = l.getFilter();
if (key == null) {
// key = "";
@@ -357,6 +361,19 @@ public class TopologyManagerImpl implements ListenerHook, RemoteServiceAdminList
// Get a listener
ListenerInfo listener = listeners.iterator().next();
Bundle bundle = listener.getBundleContext().getBundle();
+ if (bundle.getBundleId() == 0L) {
+ // Skip system bundles
+ continue;
+ }
+ try {
+ Filter filter = listener.getBundleContext().createFilter(matchedFilter);
+ if (!filter.match(new Hashtable<String, Object>(endpoint.getProperties()))) {
+ continue;
+ }
+ } catch (InvalidSyntaxException ex) {
+ logger.log(Level.SEVERE, ex.getMessage(), ex);
+ continue;
+ }
Map<String, Object> props = new HashMap<String, Object>(endpoint.getProperties());
props.put(Bundle.class.getName(), bundle);