diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2010-04-22 15:08:08 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2010-04-22 15:08:08 +0000 |
commit | 1a8b5e5f74351ca496c243a4949bc07d9f5177c0 (patch) | |
tree | ead6037cdd2ae022f1e33f8a3e72922cafa743cd /sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java | |
parent | 082884141610be91c2c615f9effb3da875c2d6c2 (diff) |
Add code to add the org.osgi.sca.config.xml property to the exported service. See page 450 of the OSGi 4.2 enterprise spec for an example of what the exported endpoint description should look like.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@936890 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java')
-rw-r--r-- | sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java index 4466c04563..081a3a60c0 100644 --- a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java +++ b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java @@ -35,10 +35,14 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; +import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.assembly.Component; import org.apache.tuscany.sca.assembly.ComponentService; import org.apache.tuscany.sca.assembly.Endpoint; import org.apache.tuscany.sca.contribution.Contribution; +import org.apache.tuscany.sca.implementation.osgi.OSGiProperty; +import org.apache.tuscany.sca.implementation.osgi.SCAConfig; +import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory; import org.apache.tuscany.sca.node.configuration.NodeConfiguration; import org.apache.tuscany.sca.node.impl.NodeImpl; import org.osgi.framework.BundleContext; @@ -102,6 +106,9 @@ public class OSGiServiceExporter extends AbstractOSGiServiceHandler implements S .getBundleContext()))); service.getExtensions().add(createOSGiProperty(registry, ENDPOINT_SERVICE_ID, reference .getProperty(SERVICE_ID))); + + // create the org.osgi.sca.config.xml property + service.getExtensions().add(createSCAConfigXMLProperty(reference, properties, service)); // FIXME: Configure the domain and node URI NodeImpl node = new NodeImpl(nodeFactory, configuration, Collections.singletonList(contribution)); @@ -140,4 +147,17 @@ public class OSGiServiceExporter extends AbstractOSGiServiceHandler implements S exportRegistration.close(); } } + + private OSGiProperty createSCAConfigXMLProperty(ServiceReference reference, Map<String, Object> props, ComponentService service){ + + // create the <sca-config> element + String scaConfigXMLString = introspector.instrospectSCAConfig(reference, props, service); + + // wrap the <sca-config> element in an <xml> element + String scaConfigXMLStringWithoutXMLHeader = scaConfigXMLString.substring(scaConfigXMLString.indexOf("><") + 1); + scaConfigXMLString = "<xml>" + scaConfigXMLStringWithoutXMLHeader + "</xml>"; + + // create and return the OSGI property + return createOSGiProperty(registry, "org.osgi.sca.config.xml", scaConfigXMLString); + } } |