summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/implementation-osgi-runtime/src
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-03-23 19:05:06 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-03-23 19:05:06 +0000
commit7065b6c6e734a5c48b8f2c6b4f373c3e62cf3b36 (patch)
treef009da18aa14291fe6d26a0b4d449d6610444f7d /java/sca/modules/implementation-osgi-runtime/src
parent8d53ca67aa02c88e9732bb69e03368e4545c942e (diff)
Start to align with the OSGi property names defined by RFC 119
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@757502 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/implementation-osgi-runtime/src')
-rw-r--r--java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiDistributionProvider.java99
-rw-r--r--java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java11
2 files changed, 106 insertions, 4 deletions
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
new file mode 100644
index 0000000000..ff30730c78
--- /dev/null
+++ b/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiDistributionProvider.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.tuscany.sca.implementation.osgi.runtime;
+
+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.
+ */
+public interface OSGiDistributionProvider {
+
+ /**
+ * Service Registration property for the name of the Distribution Provider
+ * product.
+ */
+ static final String PROP_KEY_PRODUCT_NAME = "osgi.remote.distribution.product";
+
+ /**
+ * Service Registration property for the version of the Distribution
+ * Provider product.
+ */
+ static final String PROP_KEY_PRODUCT_VERSION = "osgi.remote.distribution.product.version";
+
+ /**
+ * Service Registration property for the Distribution Provider product
+ * vendor name.
+ */
+ static final String PROP_KEY_VENDOR_NAME = "osgi.remote.distribution.vendor";
+
+ /**
+ * Service Registration property that lists the intents supported by this
+ * DistributionProvider. Value of this property is of type
+ * Collection (<? extends String>).
+ */
+ static final String PROP_KEY_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<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<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 service.intents=”transactionality” is set.
+ * However, these intents are *not* 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);
+
+}
diff --git a/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java b/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java
index 5e592ee97a..ddcd49a235 100644
--- a/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java
+++ b/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java
@@ -72,9 +72,12 @@ public class OSGiImplementationProvider implements ImplementationProvider {
JavaInterface javaInterface = (JavaInterface)interfaceContract.getInterface();
final Class<?> interfaceClass = javaInterface.getJavaClass();
- final Hashtable<String, Object> targetProperties = getOSGiProperties(reference);
- targetProperties.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
- targetProperties.put("sca.reference", component.getURI() + "#reference(" + ref.getName() + ")");
+ final Hashtable<String, Object> osgiProps = getOSGiProperties(reference);
+ osgiProps.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
+ osgiProps.put("sca.reference", component.getURI() + "#reference(" + ref.getName() + ")");
+ osgiProps.put(OSGiProperty.OSGI_REMOTE, "true");
+ osgiProps.put(OSGiProperty.OSGI_REMOTE_CONFIGURATION_TYPE, "sca");
+ osgiProps.put(OSGiProperty.OSGI_REMOTE_INTERFACES, interfaceClass.getName());
ProxyFactory proxyService = proxyFactoryExtensionPoint.getInterfaceProxyFactory();
if (!interfaceClass.isInterface()) {
@@ -87,7 +90,7 @@ public class OSGiImplementationProvider implements ImplementationProvider {
public ServiceRegistration run() {
return osgiBundle.getBundleContext().registerService(interfaceClass.getName(),
proxy,
- targetProperties);
+ osgiProps);
}
});
}