summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/node-impl-osgi/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/sca/modules/node-impl-osgi/src')
-rw-r--r--java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/AbstractOSGiServiceHandler.java7
-rw-r--r--java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointHelper.java24
-rw-r--r--java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiHelper.java10
-rw-r--r--java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java9
-rw-r--r--java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceImporter.java3
-rw-r--r--java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java5
-rw-r--r--java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java11
7 files changed, 61 insertions, 8 deletions
diff --git a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/AbstractOSGiServiceHandler.java b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/AbstractOSGiServiceHandler.java
index a043e33c32..7c9cf8ef6e 100644
--- a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/AbstractOSGiServiceHandler.java
+++ b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/AbstractOSGiServiceHandler.java
@@ -37,6 +37,7 @@ public class AbstractOSGiServiceHandler implements LifeCycleListener {
protected EndpointIntrospector introspector;
protected ServiceTracker discoveryTracker;
protected String domainRegistry;
+ protected String domainURI;
/**
* @param context
@@ -45,6 +46,8 @@ public class AbstractOSGiServiceHandler implements LifeCycleListener {
*/
protected AbstractOSGiServiceHandler(BundleContext context) {
this.context = context;
+ this.domainRegistry = context.getProperty("org.osgi.sca.domain.registry");
+ this.domainURI = context.getProperty("org.osgi.sca.domain.uri");
}
protected ExtensionPointRegistry getExtensionPointRegistry() {
@@ -87,4 +90,8 @@ public class AbstractOSGiServiceHandler implements LifeCycleListener {
this.domainRegistry = domainRegistry;
}
+ public void setDomainURI(String domainURI) {
+ this.domainURI = domainURI;
+ }
+
}
diff --git a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointHelper.java b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointHelper.java
index 8ac949ccc5..748f835859 100644
--- a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointHelper.java
+++ b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointHelper.java
@@ -26,6 +26,7 @@ import java.util.Map;
import java.util.UUID;
import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.implementation.osgi.OSGiProperty;
import org.apache.tuscany.sca.interfacedef.Interface;
import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
import org.apache.tuscany.sca.osgi.remoteserviceadmin.EndpointDescription;
@@ -54,11 +55,21 @@ public class EndpointHelper {
private static Map<String, Object> getProperties(BundleContext bundleContext, Endpoint endpoint) {
Map<String, Object> props = new HashMap<String, Object>();
- String uuid = getFrameworkUUID(bundleContext);
+ if (!endpoint.isRemote()) {
+ String uuid = getFrameworkUUID(bundleContext);
+ props.put(RemoteConstants.SERVICE_REMOTE_FRAMEWORK_UUID, uuid);
+ }
+
+ for (Object ext : endpoint.getService().getExtensions()) {
+ if (ext instanceof OSGiProperty) {
+ OSGiProperty prop = (OSGiProperty)ext;
+ props.put(prop.getName(), prop.getStringValue());
+ }
+ }
- props.put(RemoteConstants.SERVICE_REMOTE_FRAMEWORK_UUID, uuid);
+ props.put(RemoteConstants.SERVICE_REMOTE_ID, props.get(Constants.SERVICE_ID));
props.put(RemoteConstants.SERVICE_REMOTE_URI, endpoint.getURI());
- props.put(RemoteConstants.SERVICE_REMOTE_ID, String.valueOf(System.currentTimeMillis()));
+ // FIXME: [rfeng] How to pass in the remote service id from the endpoint XML
props.put(RemoteConstants.SERVICE_EXPORTED_CONFIGS, new String[] {"org.osgi.sca"});
props.put(Endpoint.class.getName(), endpoint);
List<String> interfaces = getInterfaces(endpoint);
@@ -67,7 +78,12 @@ public class EndpointHelper {
}
public synchronized static String getFrameworkUUID(BundleContext bundleContext) {
- String uuid = System.getProperty(FRAMEWORK_UUID);
+ String uuid = null;
+ if (bundleContext != null) {
+ uuid = bundleContext.getProperty(FRAMEWORK_UUID);
+ } else {
+ uuid = System.getProperty(FRAMEWORK_UUID);
+ }
if (uuid == null) {
uuid = UUID.randomUUID().toString();
}
diff --git a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiHelper.java b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiHelper.java
index d5a2b7aa95..52abef059c 100644
--- a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiHelper.java
+++ b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiHelper.java
@@ -26,6 +26,10 @@ import java.util.Collections;
import java.util.Enumeration;
import java.util.HashSet;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.osgi.OSGiImplementationFactory;
+import org.apache.tuscany.sca.implementation.osgi.OSGiProperty;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Filter;
@@ -131,5 +135,11 @@ public class OSGiHelper {
}
return files;
}
+
+ public static Collection<OSGiProperty> getOSGiProperties(ExtensionPointRegistry registry, ServiceReference reference) {
+ FactoryExtensionPoint factoryExtensionPoint = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ OSGiImplementationFactory implementationFactory= factoryExtensionPoint.getFactory(OSGiImplementationFactory.class);
+ return implementationFactory.createOSGiProperties(reference);
+ }
}
diff --git a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java
index 02603417cc..21950d9d59 100644
--- a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java
+++ b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java
@@ -70,14 +70,19 @@ public class OSGiServiceExporter extends AbstractOSGiServiceHandler implements S
if (domainRegistry != null) {
configuration.setDomainRegistryURI(domainRegistry);
}
+ if (domainURI != null) {
+ configuration.setDomainURI(domainURI);
+ }
configuration.setURI(contribution.getURI());
configuration.getExtensions().add(reference.getBundle());
+ Component component = contribution.getDeployables().get(0).getComponents().get(0);
+ ComponentService service = component.getServices().get(0);
+ service.getExtensions().addAll(OSGiHelper.getOSGiProperties(registry, reference));
+
// FIXME: Configure the domain and node URI
NodeImpl node = new NodeImpl(nodeFactory, configuration, Collections.singletonList(contribution));
node.start();
List<ExportRegistration> exportedServices = new ArrayList<ExportRegistration>();
- Component component = contribution.getDeployables().get(0).getComponents().get(0);
- ComponentService service = component.getServices().get(0);
for (Endpoint endpoint : service.getEndpoints()) {
EndpointDescription endpointDescription = createEndpointDescription(context, endpoint);
ExportRegistration exportRegistration =
diff --git a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceImporter.java b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceImporter.java
index 59a21ade06..c869ab8c14 100644
--- a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceImporter.java
+++ b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceImporter.java
@@ -61,6 +61,9 @@ public class OSGiServiceImporter extends AbstractOSGiServiceHandler {
if (domainRegistry != null) {
configuration.setDomainRegistryURI(domainRegistry);
}
+ if (domainURI != null) {
+ configuration.setDomainURI(domainURI);
+ }
configuration.setURI(contribution.getURI());
configuration.getExtensions().add(bundle);
// FIXME: Configure the domain and node URI
diff --git a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java
index bc2e3ce012..9da7b5f014 100644
--- a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java
+++ b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java
@@ -276,9 +276,14 @@ public class RemoteServiceAdminImpl implements RemoteServiceAdmin, ManagedServic
return;
}
String domainRegistry = (String)props.get("org.osgi.sca.domain.registry");
+ String domainURI = (String)props.get("org.osgi.sca.domain.uri");
if (domainRegistry != null) {
exporter.setDomainRegistry(domainRegistry);
importer.setDomainRegistry(domainRegistry);
}
+ if (domainURI != null) {
+ exporter.setDomainURI(domainURI);
+ importer.setDomainURI(domainURI);
+ }
}
}
diff --git a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java
index 2577a68808..bf70c98634 100644
--- a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java
+++ b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java
@@ -30,6 +30,7 @@ import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation;
import org.apache.tuscany.sca.osgi.remoteserviceadmin.EndpointDescription;
import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
import org.apache.tuscany.sca.runtime.EndpointListener;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
/**
@@ -56,8 +57,13 @@ public class DomainDiscoveryService extends AbstractDiscoveryService implements
return;
}
- OSGiImplementation osgiImpl = (OSGiImplementation)impl;
- BundleContext bundleContext = osgiImpl.getBundle().getBundleContext();
+ BundleContext bundleContext = null;
+ // Remote endpoint doesn't have a bundle
+ if (!endpoint.isRemote()) {
+ OSGiImplementation osgiImpl = (OSGiImplementation)impl;
+ Bundle bundle = osgiImpl.getBundle();
+ bundleContext = bundle != null ? bundle.getBundleContext() : null;
+ }
/*
if (!endpoint.isRemote()) {
@@ -114,4 +120,5 @@ public class DomainDiscoveryService extends AbstractDiscoveryService implements
props.put(SUPPORTED_PROTOCOLS, new String[] {"org.osgi.sca"});
return props;
}
+
}