From cb4967e57dd8a327bffd21249db190bc2a12e70c Mon Sep 17 00:00:00 2001 From: rfeng Date: Wed, 24 Jun 2009 23:45:28 +0000 Subject: Add service properties from SCA Endpoint git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@788211 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/dosgi/discovery/AbstractDiscoveryService.java | 8 ++++---- .../sca/dosgi/discovery/DomainDiscoveryService.java | 2 +- .../sca/dosgi/discovery/EndpointPublication.java | 19 ++++++++++++++++++- 3 files changed, 23 insertions(+), 6 deletions(-) (limited to 'java/sca/modules') diff --git a/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/dosgi/discovery/AbstractDiscoveryService.java b/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/dosgi/discovery/AbstractDiscoveryService.java index 612e10e770..48a2777579 100644 --- a/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/dosgi/discovery/AbstractDiscoveryService.java +++ b/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/dosgi/discovery/AbstractDiscoveryService.java @@ -34,6 +34,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Logger; +import org.apache.tuscany.sca.assembly.Endpoint; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; @@ -314,10 +315,9 @@ public abstract class AbstractDiscoveryService implements Discovery { } } - protected void localServicePublished(ServiceReference ref) { - EndpointPublication publication = new EndpointPublication(ref); - Hashtable props = new Hashtable(); - ref.getBundle().getBundleContext().registerService(ServicePublication.class.getName(), publication, props); + protected void localServicePublished(ServiceReference ref, Endpoint endpoint) { + EndpointPublication publication = new EndpointPublication(ref, endpoint); + ref.getBundle().getBundleContext().registerService(ServicePublication.class.getName(), publication, publication.getProperties()); } } diff --git a/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/dosgi/discovery/DomainDiscoveryService.java b/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/dosgi/discovery/DomainDiscoveryService.java index 40094974ba..90305a9ae1 100644 --- a/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/dosgi/discovery/DomainDiscoveryService.java +++ b/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/dosgi/discovery/DomainDiscoveryService.java @@ -76,7 +76,7 @@ public class DomainDiscoveryService extends AbstractDiscoveryService implements // Ignore } if (ref != null) { - localServicePublished(ref); + localServicePublished(ref, endpoint); } } else { // Remote endpoints diff --git a/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/dosgi/discovery/EndpointPublication.java b/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/dosgi/discovery/EndpointPublication.java index 1a038ba41a..82080a2dc1 100644 --- a/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/dosgi/discovery/EndpointPublication.java +++ b/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/dosgi/discovery/EndpointPublication.java @@ -19,6 +19,12 @@ package org.apache.tuscany.sca.dosgi.discovery; +import java.util.Dictionary; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Map; + +import org.apache.tuscany.sca.assembly.Endpoint; import org.osgi.framework.ServiceReference; import org.osgi.service.discovery.ServicePublication; @@ -26,6 +32,7 @@ import org.osgi.service.discovery.ServicePublication; * Publication of an SCA endpoint */ public class EndpointPublication implements ServicePublication { + private Endpoint endpoint; private ServiceReference reference; /** @@ -33,13 +40,23 @@ public class EndpointPublication implements ServicePublication { * @param reference The OSGi service reference for the given endpoint. The SCA endpoint * is pointing to a local service in the OSGi service registry */ - public EndpointPublication(ServiceReference reference) { + public EndpointPublication(ServiceReference reference, Endpoint endpoint) { super(); this.reference = reference; + this.endpoint = endpoint; } public ServiceReference getReference() { return reference; } + public Dictionary getProperties() { + Dictionary props = new Hashtable(); + Map serviceProps = new HashMap(); + serviceProps.put(ENDPOINT_LOCATION, endpoint.getURI()); + props.put(SERVICE_PROPERTIES, serviceProps); + // TODO: Populate the properties from the Endpoint object + return props; + } + } -- cgit v1.2.3