diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-03-23 19:05:06 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-03-23 19:05:06 +0000 |
commit | 7065b6c6e734a5c48b8f2c6b4f373c3e62cf3b36 (patch) | |
tree | f009da18aa14291fe6d26a0b4d449d6610444f7d /java/sca/modules/implementation-osgi/src | |
parent | 8d53ca67aa02c88e9732bb69e03368e4545c942e (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/src')
7 files changed, 55 insertions, 71 deletions
diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java index 8509e866ef..26b588a099 100644 --- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java +++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java @@ -28,6 +28,21 @@ public interface OSGiProperty { String NAME = "name"; QName PROPERTY_QNAME = new QName(OSGiImplementation.SCA11_TUSCANY_NS, "osgi.property"); + /** + * Standard OSGi property names + */ + String OSGI_REMOTE = "osgi.remote"; + String SERVICE_INTENTS = "service.intents"; + String OSGI_REMOTE_INTERFACES = "osgi.remote.interfaces"; + String OSGI_REMOTE_INTENTS = "osgi.remote.requires.intents"; + String OSGI_REMOTE_CONFIGURATION_TYPE = "osgi.remote.configuration.type"; + String SCA_BINDINGS = "osgi.remote.configuration.sca.bindings"; + String SCA_REFERENCE = "osgi.remote.configuration.sca.reference"; + String SCA_SERVICE = "osgi.remote.configuration.sca.service"; + String SCA_REFERENCE_BINDING = "osgi.remote.configuration.sca.reference.binding"; + String SCA_SERVICE_BINDING = "osgi.remote.configuration.sca.service.binding"; + String OSGI_REMOTE_CONFIGURATION_TYPE_SCA = "sca"; + String getValue(); void setValue(String value); diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescription.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescription.java index 832e26a48f..119d7ed657 100644 --- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescription.java +++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescription.java @@ -22,12 +22,19 @@ package org.apache.tuscany.sca.implementation.osgi; import java.util.List; import java.util.Map; - /** * The OSGi RFC 119 description of a remote OSGi service */ public interface ServiceDescription { + /** + * Get a list of interfaces + * @return + */ List<String> getInterfaces(); + /** + * Get a list of properties + * @return + */ Map<String, Object> getProperties(); } diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.java index 36968615c0..35866938d6 100644 --- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.java +++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.java @@ -23,7 +23,6 @@ import java.util.List; import javax.xml.namespace.QName; - /** * OSGi RFC 119 service descriptions */ @@ -34,9 +33,4 @@ public interface ServiceDescriptions extends List<ServiceDescription> { QName SERVICE_DESCRIPTIONS_QNAME = new QName(OSGI_SD_NS, "service-descriptions"); QName SERVICE_DESCRIPTION_QNAME = new QName(OSGI_SD_NS, "service-description"); String REMOTE_SERVICE_HEADER = "Remote-Service"; - String PROP_SERVICE_INTENTS = "service.intents"; - String PROP_REQUIRES_INTENTS = "osgi.remote.requires.intents"; - String PROP_CONFIGURATION_TYPE = "osgi.remote.configuration.type"; - String CONFIGURATION_TYPE_SCA = "sca"; - String PROP_CONFIGURATION_SCA_BINDINGS = "osgi.remote.configuration.sca.bindings"; } diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java index d9641def69..41deef131f 100644 --- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java +++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java @@ -18,14 +18,11 @@ */ package org.apache.tuscany.sca.implementation.osgi.impl; -import java.util.Hashtable; -import java.util.List; - -import org.apache.tuscany.sca.assembly.ComponentProperty; import org.apache.tuscany.sca.assembly.impl.ImplementationImpl; import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation; import org.osgi.framework.Bundle; +import org.osgi.framework.Constants; /** * OSGi implementation @@ -40,41 +37,20 @@ public class OSGiImplementationImpl extends ImplementationImpl implements OSGiIm private String bundleVersion; private Bundle osgiBundle; - private Hashtable<String, List<ComponentProperty>> referenceProperties; - private Hashtable<String, List<ComponentProperty>> serviceProperties; - - private Hashtable<String, List<ComponentProperty>> referenceCallbackProperties; - private Hashtable<String, List<ComponentProperty>> serviceCallbackProperties; - private FactoryExtensionPoint modelFactories; - protected OSGiImplementationImpl(FactoryExtensionPoint modelFactories) { this.modelFactories = modelFactories; } - public OSGiImplementationImpl(FactoryExtensionPoint modelFactories, - String bundleSymbolicName, - String bundleVersion, - Hashtable<String, List<ComponentProperty>> refProperties, - Hashtable<String, List<ComponentProperty>> serviceProperties) { + public OSGiImplementationImpl(FactoryExtensionPoint modelFactories, String bundleSymbolicName, String bundleVersion) { super(); this.bundleSymbolicName = bundleSymbolicName; this.bundleVersion = bundleVersion; - this.referenceProperties = refProperties; - this.serviceProperties = serviceProperties; this.modelFactories = modelFactories; } - public void setCallbackProperties(Hashtable<String, List<ComponentProperty>> refCallbackProperties, - Hashtable<String, List<ComponentProperty>> serviceCallbackProperties) { - - this.referenceCallbackProperties = refCallbackProperties; - this.serviceCallbackProperties = serviceCallbackProperties; - - } - public String getBundleSymbolicName() { return bundleSymbolicName; } @@ -87,22 +63,6 @@ public class OSGiImplementationImpl extends ImplementationImpl implements OSGiIm return modelFactories; } - public List<ComponentProperty> getReferenceProperties(String referenceName) { - return referenceProperties.get(referenceName); - } - - public List<ComponentProperty> getServiceProperties(String serviceName) { - return serviceProperties.get(serviceName); - } - - public List<ComponentProperty> getReferenceCallbackProperties(String referenceName) { - return referenceCallbackProperties.get(referenceName); - } - - public List<ComponentProperty> getServiceCallbackProperties(String serviceName) { - return serviceCallbackProperties.get(serviceName); - } - /** * Since OSGi implementation annotations may not be processed until much later, leave it to * the OSGi invoker to decide whether pass-by-reference is allowed. @@ -118,6 +78,10 @@ public class OSGiImplementationImpl extends ImplementationImpl implements OSGiIm public void setBundle(Bundle osgiBundle) { this.osgiBundle = osgiBundle; + if (osgiBundle != null) { + this.bundleSymbolicName = osgiBundle.getSymbolicName(); + this.bundleVersion = (String)osgiBundle.getHeaders().get(Constants.BUNDLE_VERSION); + } } private boolean areEqual(Object obj1, Object obj2) { @@ -138,14 +102,6 @@ public class OSGiImplementationImpl extends ImplementationImpl implements OSGiIm return false; if (!areEqual(bundleVersion, impl.bundleVersion)) return false; - if (!areEqual(serviceProperties, impl.serviceProperties)) - return false; - if (!areEqual(serviceCallbackProperties, impl.serviceCallbackProperties)) - return false; - if (!areEqual(referenceProperties, impl.referenceProperties)) - return false; - if (!areEqual(referenceCallbackProperties, impl.referenceCallbackProperties)) - return false; return super.equals(obj); } diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java index eeacdb9702..b990cf5980 100644 --- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java +++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java @@ -30,13 +30,13 @@ import org.apache.tuscany.sca.implementation.osgi.ServiceDescription; * The OSGi RFC 119 description of a remote OSGi service */ public class ServiceDescriptionImpl implements ServiceDescription { + private List<String> interfaces = new ArrayList<String>(); + private Map<String, Object> properties = new HashMap<String, Object>(); + protected ServiceDescriptionImpl() { super(); } - private List<String> interfaces = new ArrayList<String>(); - private Map<String, Object> properties = new HashMap<String, Object>(); - public List<String> getInterfaces() { return interfaces; } @@ -46,6 +46,6 @@ public class ServiceDescriptionImpl implements ServiceDescription { } public String toString() { - return "service-description: interfaces=" + interfaces + "properties=" + properties; + return "service-description: interfaces=" + interfaces + " properties=" + properties; } -}
\ No newline at end of file +} diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java index 0a0efd1ec1..57d360ca29 100644 --- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java +++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java @@ -45,6 +45,7 @@ import org.apache.tuscany.sca.contribution.resolver.ModelResolver; import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation; import org.apache.tuscany.sca.implementation.osgi.OSGiImplementationFactory; +import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory; import org.apache.tuscany.sca.interfacedef.Interface; import org.apache.tuscany.sca.interfacedef.java.JavaInterface; import org.apache.tuscany.sca.monitor.Monitor; @@ -65,13 +66,13 @@ import org.osgi.framework.Version; */ public class OSGiImplementationProcessor implements StAXArtifactProcessor<OSGiImplementation> { private AssemblyFactory assemblyFactory; - // private FactoryExtensionPoint modelFactories; + private ServiceDescriptionsFactory serviceDescriptionsFactory; private OSGiImplementationFactory osgiImplementationFactory; private Monitor monitor; public OSGiImplementationProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) { this.monitor = monitor; - // this.modelFactories = modelFactories; + this.serviceDescriptionsFactory = modelFactories.getFactory(ServiceDescriptionsFactory.class); this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class); this.osgiImplementationFactory = modelFactories.getFactory(OSGiImplementationFactory.class); } @@ -171,8 +172,15 @@ public class OSGiImplementationProcessor implements StAXArtifactProcessor<OSGiIm error("MissingComponentTypeFile", impl, componentType.getURI()); //throw new ContributionResolveException("missing .componentType side file " + ctURI); return; + } else { + mergeFromComponentType(impl, componentType, resolver); } + // FIXME: How to find the RFC 119 service descriptions in the contribution and + // derive the SCA component type from them? + } + + private void mergeFromComponentType(OSGiImplementation impl, ComponentType componentType, ModelResolver resolver) { List<Service> services = componentType.getServices(); for (Service service : services) { Interface interfaze = service.getInterfaceContract().getInterface(); @@ -211,7 +219,6 @@ public class OSGiImplementationProcessor implements StAXArtifactProcessor<OSGiIm impl.getProperties().add(property); } impl.setConstrainingType(componentType.getConstrainingType()); - } private Class<?> getJavaClass(ModelResolver resolver, String className) { diff --git a/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java b/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java index 7a4ae3e6de..436143ad6c 100644 --- a/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java +++ b/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java @@ -38,13 +38,18 @@ import org.junit.Test; */ public class ServiceDescriptionsTestCase { private static final String xml = - "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<service-descriptions xmlns=\"http://www.osgi.org/xmlns/sd/v1.0.0\">" + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + "<service-descriptions xmlns=\"http://www.osgi.org/xmlns/sd/v1.0.0\" " + +"xmlns:sca=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\">" + "<service-description>" - + "<provide interface=\"com.iona.soa.pojo.hello.HelloService\"/>" - + "<property name=\"service.intents\">SOAP HTTP</property>" - + "<property name=\"osgi.remote.configuration.type\">pojo</property>" - + "<property name=\"osgi.remote.configuration.pojo.address\">" - + "http://localhost:9000/hello" + + "<provide interface=\"calculator.operations.AddService\"/>" + + "<property name=\"service.intents\">sca:SOAP sca:HTTP</property>" + + "<property name=\"osgi.remote.configuration.type\">sca</property>" + + "<property name=\"osgi.remote.configuration.sca.componentType\">" + + "OSGI-INF/sca/bundle.componentType" + + "</property>" + + "<property name=\"osgi.remote.configuration.sca.reference\">" + + "addService" + "</property>" + "</service-description>" + "<service-description>" |