diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-07-17 18:51:33 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-07-17 18:51:33 +0000 |
commit | 9b4b350ea62fda310cba5c80ce618c0db138cc22 (patch) | |
tree | 9479ba31984d81cb778f96fd8f803f4681d780bd /java/sca/modules | |
parent | e34f5408ced780f4a587269aa17327b8dea45590 (diff) |
Remove the need of the DistributionProvider interface
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@795192 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules')
4 files changed, 47 insertions, 136 deletions
diff --git a/java/sca/modules/implementation-osgi-runtime/META-INF/MANIFEST.MF b/java/sca/modules/implementation-osgi-runtime/META-INF/MANIFEST.MF index f0704ad240..f1bac6e4eb 100644 --- a/java/sca/modules/implementation-osgi-runtime/META-INF/MANIFEST.MF +++ b/java/sca/modules/implementation-osgi-runtime/META-INF/MANIFEST.MF @@ -28,4 +28,3 @@ Import-Package: org.apache.tuscany.sca.assembly;version="2.0.0", org.osgi.util.tracker;version="1.3.3"
Bundle-DocURL: http://www.apache.org/
Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6 -Export-Package: org.osgi.service.distribution;version="1.0"
diff --git a/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiDistributionProvider.java b/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiDistributionProvider.java index b471d645dc..8b1001b85d 100644 --- a/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiDistributionProvider.java +++ b/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiDistributionProvider.java @@ -19,47 +19,68 @@ package org.apache.tuscany.sca.implementation.osgi.runtime; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; import java.util.Dictionary; import java.util.Hashtable; -import java.util.Map; import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.service.distribution.DistributionProvider; +import org.osgi.framework.Constants; /** - * OSGi distribution provider + * OSGi distribution provider for remote services */ -public class OSGiDistributionProvider implements DistributionProvider { +public class OSGiDistributionProvider { + /** + * Registered by the distribution provider on one of its services to indicate the + * supported configuration types. + */ + public static final String REMOTE_CONFIGS_SUPPORTED = "remote.configs.supported"; // String+ + + /** + * Registered by the distribution provider on one of its services to indicate the vocabulary + * of implemented intents. + */ + public static final String REMOTE_INTENTS_SUPPORTED = "remote.intents.supported"; // String+ + + /** + * Service Registration property for the name of the Distribution Provider + * product. + * <p> + * The value of this property is of type String. + */ + static final String PRODUCT_NAME = "osgi.remote.distribution.product"; + + /** + * Service Registration property for the version of the Distribution + * Provider product. + * <p> + * The value of this property is of type String. + */ + static final String PRODUCT_VERSION = "osgi.remote.distribution.product.version"; + + /** + * Service Registration property for the Distribution Provider product + * vendor name. + * <p> + * The value of this property is of type String. + */ + static final String VENDOR_NAME = "osgi.remote.distribution.vendor"; + private BundleContext bundleContext; - private Collection<ServiceReference> exposedServices = new ArrayList<ServiceReference>(); - private Collection<ServiceReference> remoteServices = new ArrayList<ServiceReference>(); public OSGiDistributionProvider(BundleContext bundleContext) { super(); this.bundleContext = bundleContext; } - public Map<String, String> getExposedProperties(ServiceReference sr) { - return Collections.emptyMap(); - } - - public Collection<ServiceReference> getExposedServices() { - return exposedServices; - } - - public Collection<ServiceReference> getRemoteServices() { - return remoteServices; - } - public Dictionary<String, Object> getProperties() { + Dictionary headers = bundleContext.getBundle().getHeaders(); Hashtable<String, Object> props = new Hashtable<String, Object>(); props.put(PRODUCT_NAME, "Apache Tuscany SCA"); - props.put(PRODUCT_VERSION, "2.0.0"); - props.put(VENDOR_NAME, "Apache Software Foundation"); + props.put(PRODUCT_VERSION, headers.get(Constants.BUNDLE_VERSION)); + props.put(VENDOR_NAME, headers.get(Constants.BUNDLE_VENDOR)); + props.put(REMOTE_CONFIGS_SUPPORTED, new String[] {"sca"}); + // FIXME: We need to populate the list of intents from the SCA definitions + props.put(REMOTE_INTENTS_SUPPORTED, new String[] {}); return props; } } diff --git a/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationRuntimeActivator.java b/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationRuntimeActivator.java index ee8e9ade72..8bbfc19323 100644 --- a/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationRuntimeActivator.java +++ b/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationRuntimeActivator.java @@ -22,29 +22,22 @@ package org.apache.tuscany.sca.implementation.osgi.runtime; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; -import org.osgi.service.distribution.DistributionProvider; /** * Bundle activator to receive the BundleContext */ public class OSGiImplementationRuntimeActivator implements BundleActivator { private static BundleContext bundleContext; -// private DiscoveryActivator discoveryActivator; private ServiceRegistration distributionProvider; public void start(BundleContext context) throws Exception { bundleContext = context; -// discoveryActivator = new DiscoveryActivator(); -// discoveryActivator.start(context); OSGiDistributionProvider provider = new OSGiDistributionProvider(bundleContext); - distributionProvider = bundleContext.registerService(DistributionProvider.class.getName(), provider, provider.getProperties()); + distributionProvider = + bundleContext.registerService(OSGiDistributionProvider.class.getName(), provider, provider.getProperties()); } public void stop(BundleContext context) throws Exception { -// if (discoveryActivator != null) { -// discoveryActivator.stop(context); -// } -// discoveryActivator = null; if (distributionProvider != null) { distributionProvider.unregister(); } diff --git a/java/sca/modules/implementation-osgi-runtime/src/main/java/org/osgi/service/distribution/DistributionProvider.java b/java/sca/modules/implementation-osgi-runtime/src/main/java/org/osgi/service/distribution/DistributionProvider.java deleted file mode 100644 index 43783e5e53..0000000000 --- a/java/sca/modules/implementation-osgi-runtime/src/main/java/org/osgi/service/distribution/DistributionProvider.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) OSGi Alliance (2000, 2008). All Rights Reserved. - * - * Licensed 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. - */ -package org.osgi.service.distribution; - -import java.util.Collection; -import java.util.Map; - -import org.osgi.framework.ServiceReference; - -/** - * Every Distribution Provider registers exactly one Service in the - * ServiceRegistry implementing this interface. The service is registered with - * extra properties identified at the beginning of this interface to denote the - * Distribution Provider product name, version, vendor and supported intents. - * - * @ThreadSafe - * @version $Revision$ - */ -public interface DistributionProvider { - /** - * Service Registration property for the name of the Distribution Provider - * product. - * <p> - * The value of this property is of type String. - */ - static final String PRODUCT_NAME = "osgi.remote.distribution.product"; - - /** - * Service Registration property for the version of the Distribution - * Provider product. - * <p> - * The value of this property is of type String. - */ - static final String PRODUCT_VERSION = "osgi.remote.distribution.product.version"; - - /** - * Service Registration property for the Distribution Provider product - * vendor name. - * <p> - * The value of this property is of type String. - */ - static final String VENDOR_NAME = "osgi.remote.distribution.vendor"; - - /** - * Service Registration property that lists the intents supported by this - * DistributionProvider. - * <p> - * The value of this property is of type String, String[] or Collection of - * String. - */ - static final String SUPPORTED_INTENTS = "osgi.remote.distribition.supported_intents"; - - /** - * @return ServiceReferences of services registered in the local Service - * Registry that are proxies to remote services. If no proxies are - * registered, then an empty collection is returned. - */ - Collection /*<? extends ServiceReference>*/getRemoteServices(); - - /** - * @return ServiceReferences of local services that are exposed remotely - * using this DisitributionProvider. Note that certain services may be - * exposed and without being published to a discovery service. This - * API returns all the exposed services. If no services are exposed an - * empty collection is returned. - */ - Collection /*<? extends ServiceReference>*/getExposedServices(); - - /** - * Provides access to extra properties set by the DistributionProvider on - * endpoints, as they will appear on client side proxies given an exposed - * ServiceReference. These properties are not always available on the - * server-side ServiceReference of the exposed service but will be on the - * remote client side proxy to this service. This API provides access to - * these extra properties from the exposing side. E.g. a service is exposed - * remotely, the distribution software is configured to add transactionality - * to the remote service. Because of this, on the client-side proxy the - * property serviceosgi.intents="transactionality" is set. However, these - * intents are <i>not</i> always set on the original ServiceRegistration on - * the server-side since on the server side the service object is a local - * pojo which doesn't provide transactionality by itself. This QoS is added - * by the distribution. This API provides access to these extra properties - * from the server-side. - * - * @param sr A ServiceReference of an exposed service. - * @return The map of extra properties. - */ - Map /*<String, String>*/getExposedProperties(ServiceReference sr); -} |