You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2010/01/09 19:00:26 UTC
svn commit: r897502 [1/2] - in /tuscany/sca-java-2.x/trunk:
distribution/all/manifests/ features/ features/osgi/
modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/
modules/implementation-osgi/src/main/java/org/apache/...
Author: rfeng
Date: Sat Jan 9 18:00:24 2010
New Revision: 897502
URL: http://svn.apache.org/viewvc?rev=897502&view=rev
Log:
Update to the latest version of OSGi enterprise draft specs
Added:
tuscany/sca-java-2.x/trunk/features/osgi/
tuscany/sca-java-2.x/trunk/features/osgi/pom.xml (with props)
Removed:
tuscany/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/deployment/
Modified:
tuscany/sca-java-2.x/trunk/distribution/all/manifests/axiom-api-1.2.7.MF
tuscany/sca-java-2.x/trunk/features/pom.xml
tuscany/sca-java-2.x/trunk/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.java
tuscany/sca-java-2.x/trunk/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java
tuscany/sca-java-2.x/trunk/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java
tuscany/sca-java-2.x/trunk/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
tuscany/sca-java-2.x/trunk/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java
tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointHelper.java
tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java
tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ExportRegistrationImpl.java
tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ImportRegistrationImpl.java
tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java
tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java
tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java
tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/LocalDiscoveryService.java
tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointDescription.java
tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointPermission.java
tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/RemoteConstants.java
tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/test/resources/calculator/dosgi/OSGI-INF/remote-service/calculator-service-descriptions.xml
tuscany/sca-java-2.x/trunk/samples/dosgi-dynamic-calculator/OSGI-INF/remote-service/calculator-service-descriptions.xml
Modified: tuscany/sca-java-2.x/trunk/distribution/all/manifests/axiom-api-1.2.7.MF
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/distribution/all/manifests/axiom-api-1.2.7.MF?rev=897502&r1=897501&r2=897502&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/distribution/all/manifests/axiom-api-1.2.7.MF (original)
+++ tuscany/sca-java-2.x/trunk/distribution/all/manifests/axiom-api-1.2.7.MF Sat Jan 9 18:00:24 2010
@@ -3,7 +3,6 @@
Bundle-Name: Axiom API
Bundle-SymbolicName: org.apache.ws.commons.axiom.axiom-api
Bundle-Version: 1.2.7
-Bundle-ClassPath: axiom-api-1.2.7.jar
Bundle-Vendor: Apache Software Foundation
Export-Package: org.apache.axiom.attachments,
org.apache.axiom.attachments.impl,
Added: tuscany/sca-java-2.x/trunk/features/osgi/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/features/osgi/pom.xml?rev=897502&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/features/osgi/pom.xml (added)
+++ tuscany/sca-java-2.x/trunk/features/osgi/pom.xml Sat Jan 9 18:00:24 2010
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-feature-osgi</artifactId>
+ <name>Apache Tuscany SCA OSGi Remote Services Feature</name>
+ <packaging>pom</packaging>
+
+ <dependencies>
+
+ <!-- Core distribution -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Bindings -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rmi-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- WebService -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Hosts -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-rmi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Implementations -->
+
+ <!-- OSGi Remote Services -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-osgi-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-osgi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl-osgi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.osgi</groupId>
+ <artifactId>services</artifactId>
+ <version>3.2.0-v20090520-1800</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint-tribes</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Policies -->
+<!--
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-transaction</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+-->
+ </dependencies>
+
+
+</project>
Propchange: tuscany/sca-java-2.x/trunk/features/osgi/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/sca-java-2.x/trunk/features/osgi/pom.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: tuscany/sca-java-2.x/trunk/features/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/features/pom.xml?rev=897502&r1=897501&r2=897502&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/features/pom.xml (original)
+++ tuscany/sca-java-2.x/trunk/features/pom.xml Sat Jan 9 18:00:24 2010
@@ -35,6 +35,7 @@
<module>api</module>
<module>core</module>
<module>ejava</module>
+ <module>osgi</module>
<module>process</module>
<module>webservice</module>
<module>web20</module>
Modified: tuscany/sca-java-2.x/trunk/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.java?rev=897502&r1=897501&r2=897502&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.java Sat Jan 9 18:00:24 2010
@@ -29,8 +29,10 @@
public interface ServiceDescriptions extends List<ServiceDescription> {
String REMOTE_SERVICE_FOLDER = "OSGI-INF/remote-service";
- String OSGI_SD_NS = "http://www.osgi.org/xmlns/sd/v1.0.0";
- QName SERVICE_DESCRIPTIONS_QNAME = new QName(OSGI_SD_NS, "service-descriptions");
- QName SERVICE_DESCRIPTION_QNAME = new QName(OSGI_SD_NS, "service-description");
+ String OSGI_SD_NS = "http://www.osgi.org/xmlns/rsa/v1.0.0";
+ QName SERVICE_DESCRIPTIONS_QNAME = new QName(OSGI_SD_NS, "endpoint-descriptions");
+ QName SERVICE_DESCRIPTION_QNAME = new QName(OSGI_SD_NS, "endpoint-description");
+ QName PROPERTY_QNAME = new QName(OSGI_SD_NS, "property");
+ QName XML_QNAME = new QName(OSGI_SD_NS, "xml");
String REMOTE_SERVICE_HEADER = "Remote-Service";
}
Modified: tuscany/sca-java-2.x/trunk/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java?rev=897502&r1=897501&r2=897502&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java Sat Jan 9 18:00:24 2010
@@ -19,18 +19,18 @@
package org.apache.tuscany.sca.implementation.osgi.impl;
-import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.tuscany.sca.implementation.osgi.ServiceDescription;
+import org.osgi.framework.Constants;
/**
* 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() {
@@ -38,7 +38,7 @@
}
public List<String> getInterfaces() {
- return interfaces;
+ return Arrays.asList((String[])properties.get(Constants.OBJECTCLASS));
}
public Map<String, Object> getProperties() {
@@ -46,6 +46,6 @@
}
public String toString() {
- return "service-description: interfaces=" + interfaces + " properties=" + properties;
+ return "service-description: " + properties;
}
}
Modified: tuscany/sca-java-2.x/trunk/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java?rev=897502&r1=897501&r2=897502&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java Sat Jan 9 18:00:24 2010
@@ -19,6 +19,9 @@
package org.apache.tuscany.sca.implementation.osgi.xml;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
import java.util.StringTokenizer;
import javax.xml.namespace.QName;
@@ -39,98 +42,118 @@
import org.apache.tuscany.sca.implementation.osgi.ServiceDescription;
import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions;
import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory;
+import org.osgi.framework.Constants;
/*
<?xml version="1.0" encoding="UTF-8"?>
-<service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
- <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
+<endpoint-descriptions xmlns="http://www.osgi.org/xmlns/rsa/v1.0.0">
+ <endpoint-description>
+ <property name="service.intents">
+ <list>
+ <value>SOAP</value>
+ <value>HTTP</value>
+ </list>
</property>
- </service-description>
- <service-description>
- <provide interface="com.iona.soa.pojo.hello.GreeterService"/>
- <property name="service.intents">SOAP HTTP</property>
- <property name="osgi.remote.configuration.type">pojo</property>
- <property name="osgi.remote.configuration.pojo.address">
- http://localhost:9005/greeter
+ <property name="endpoint.id" value="http://ws.acme.com:9000/hello"/>
+ <property name="objectClass" value="com.acme.Foo"/>
+ <property name="endpoint.package.version.com.acme" value="4.2"/>
+ <property name="service.imported.configs" value="com.acme"/>
+ <property name="com.acme.ws.xml">
+ <xml>
+ <config xmlns="http://acme.com/defs">
+ <port>1029</port>
+ <host>www.acme.com</host>
+ </config>
+ </xml>
</property>
- </service-description>
-</service-descriptions>
+ </endpoint-description>
+</endpoint-descriptions>
*/
public class ServiceDescriptionsProcessor extends BaseStAXArtifactProcessor implements
StAXArtifactProcessor<ServiceDescriptions> {
private ServiceDescriptionsFactory factory;
private StAXArtifactProcessor processor;
-
- public ServiceDescriptionsProcessor(ExtensionPointRegistry registry,
- StAXArtifactProcessor processor) {
+ public ServiceDescriptionsProcessor(ExtensionPointRegistry registry, StAXArtifactProcessor processor) {
this.processor = processor;
FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
this.factory = modelFactories.getFactory(ServiceDescriptionsFactory.class);
}
- public ServiceDescriptions read(XMLStreamReader reader, ProcessorContext context) throws XMLStreamException, ContributionReadException {
+ public ServiceDescriptions read(XMLStreamReader reader, ProcessorContext context) throws XMLStreamException,
+ ContributionReadException {
int event = reader.getEventType();
- ServiceDescriptions sds = factory.createServiceDescriptions();
+ ServiceDescriptions sds = null;
ServiceDescription sd = null;
+ String propertyName = null;
+ String propertyType = "String";
+ Object propertyValue = null;
+ String propertyLiteral = null;
+ boolean xml = false;
+ boolean multiValued = false;
while (true) {
switch (event) {
case XMLStreamConstants.START_ELEMENT:
QName name = reader.getName();
- if (ServiceDescriptions.SERVICE_DESCRIPTION_QNAME.equals(name)) {
+ if (ServiceDescriptions.SERVICE_DESCRIPTIONS_QNAME.equals(name)) {
+ sds = factory.createServiceDescriptions();
+ } else if (ServiceDescriptions.SERVICE_DESCRIPTION_QNAME.equals(name)) {
sd = factory.createServiceDescription();
sds.add(sd);
- } else if ("provide".equals(name.getLocalPart())) {
- String interfaceName = reader.getAttributeValue(null, "interface");
- if (interfaceName != null) {
- sd.getInterfaces().add(interfaceName);
- }
} else if ("property".equals(name.getLocalPart())) {
- String propName = reader.getAttributeValue(null, "name");
- String propValue = reader.getAttributeValue(null, "value");
- String propType = reader.getAttributeValue(null, "type");
- if (propType == null) {
- propType = "String";
- }
- if (propValue == null) {
- propValue = reader.getElementText();
- }
- if (propValue != null) {
- propValue = propValue.trim();
- }
- Object prop = propValue;
- if ("Integer".equals(propType)) {
- prop = Integer.valueOf(propValue);
- } else if ("Long".equals(propType)) {
- prop = Long.valueOf(propValue);
- } else if ("Float".equals(propType)) {
- prop = Float.valueOf(propValue);
- } else if ("Double".equals(propType)) {
- prop = Double.valueOf(propValue);
- } else if ("Short".equals(propType)) {
- prop = Short.valueOf(propValue);
- } else if ("Character".equals(propType)) {
- prop = propValue.charAt(0);
- } else if ("Byte".equals(propType)) {
- prop = Byte.valueOf(propValue);
- } else if ("Boolean".equals(propType)) {
- prop = Boolean.valueOf(propValue);
- }
- if (propName.endsWith(".intents")) {
- prop = toQNames(reader, propValue);
+ multiValued = false;
+ propertyName = reader.getAttributeValue(null, "name");
+ propertyType = reader.getAttributeValue(null, "value-type");
+ if (propertyType == null) {
+ propertyType = "String";
+ }
+ propertyLiteral = reader.getAttributeValue(null, "value");
+ // if (propertyLiteral == null) {
+ // propertyLiteral = reader.getElementText();
+ // }
+ if (propertyLiteral != null) {
+ propertyLiteral = propertyLiteral.trim();
+ propertyValue = getPropertyValue(reader, propertyName, propertyLiteral, propertyType);
+ }
+ } else if ("list".equals(name.getLocalPart())) {
+ if (propertyValue != null) {
+ throw new IllegalArgumentException("@value and <list> are both present");
+ }
+ propertyValue = new ArrayList<Object>();
+ multiValued = true;
+ } else if ("array".equals(name.getLocalPart())) {
+ if (propertyValue != null) {
+ throw new IllegalArgumentException("@value and <array> are both present");
+ }
+ propertyValue = new ArrayList<Object>();
+ multiValued = true;
+ } else if ("set".equals(name.getLocalPart())) {
+ if (propertyValue != null) {
+ throw new IllegalArgumentException("@value and <set> are both present");
+ }
+ propertyValue = new HashSet<Object>();
+ multiValued = true;
+ } else if ("xml".equals(name.getLocalPart())) {
+ xml = true;
+ } else if ("value".equals(name.getLocalPart())) {
+ propertyLiteral = reader.getElementText();
+ if (propertyLiteral != null) {
+ propertyLiteral = propertyLiteral.trim();
+ Object value = getPropertyValue(reader, propertyName, propertyLiteral, propertyType);
+ if (multiValued && (propertyValue instanceof Collection)) {
+ ((Collection)propertyValue).add(value);
+ } else if (propertyValue == null) {
+ propertyValue = value;
+ }
}
- sd.getProperties().put(propName, prop);
} else {
- name = reader.getName();
- if (!ServiceDescriptions.SERVICE_DESCRIPTIONS_QNAME.equals(name)) {
- Object ext = processor.read(reader, context);
- if (sd != null) {
- sd.getProperties().put(name.toString(), ext);
+ // FIXME: [rfeng] The rsa spec says the XML should be saved as String
+ Object value = processor.read(reader, context);
+ if (xml) {
+ if (multiValued && (propertyValue instanceof Collection)) {
+ ((Collection)propertyValue).add(value);
+ } else if (propertyValue == null) {
+ propertyValue = value;
}
}
}
@@ -140,8 +163,20 @@
if (ServiceDescriptions.SERVICE_DESCRIPTION_QNAME.equals(name)) {
// Reset the sd
sd = null;
- }
- if (ServiceDescriptions.SERVICE_DESCRIPTIONS_QNAME.equals(name)) {
+ } else if (ServiceDescriptions.PROPERTY_QNAME.equals(name)) {
+ if (sd != null && propertyName != null) {
+ if (propertyValue == null) {
+ throw new IllegalArgumentException("No value is defined for " + propertyName);
+ }
+ sd.getProperties().put(propertyName, propertyValue);
+ }
+ propertyName = null;
+ propertyType = "String";
+ propertyValue = null;
+ multiValued = false;
+ } else if (ServiceDescriptions.XML_QNAME.equals(name)) {
+ xml = false;
+ } else if (ServiceDescriptions.SERVICE_DESCRIPTIONS_QNAME.equals(name)) {
return sds;
}
break;
@@ -154,6 +189,35 @@
}
}
+ private Object getPropertyValue(XMLStreamReader reader, String propertyName, String propertyLiteral, String propType) {
+ Object propertyValue = null;
+ propertyValue = propertyLiteral;
+ if ("Integer".equals(propType) || "int".equals(propType)) {
+ propertyValue = Integer.valueOf(propertyLiteral);
+ } else if ("Long".equals(propType) || "long".equals(propType)) {
+ propertyValue = Long.valueOf(propertyLiteral);
+ } else if ("Float".equals(propType) || "float".equals(propType)) {
+ propertyValue = Float.valueOf(propertyLiteral);
+ } else if ("Double".equals(propType) || "double".equals(propType)) {
+ propertyValue = Double.valueOf(propertyLiteral);
+ } else if ("Short".equals(propType) || "short".equals(propType)) {
+ propertyValue = Short.valueOf(propertyLiteral);
+ } else if ("Character".equals(propType) || "char".equals(propType)) {
+ propertyValue = propertyLiteral.charAt(0);
+ } else if ("Byte".equals(propType) || "byte".equals(propType)) {
+ propertyValue = Byte.valueOf(propertyLiteral);
+ } else if ("Boolean".equals(propType) || "boolean".equals(propType)) {
+ propertyValue = Boolean.valueOf(propertyLiteral);
+ }
+ if (propertyName.endsWith(".intents")) {
+ propertyValue = toQNames(reader, propertyLiteral);
+ }
+ if (Constants.OBJECTCLASS.equals(propertyName)) {
+ return propertyLiteral.split("( |\t|\n|\r|\f)+");
+ }
+ return propertyValue;
+ }
+
/**
* Convert ns1:e1 ns2:e2 to {http://ns1}e1 {http://ns2}e2
* @param reader
@@ -176,8 +240,8 @@
return ServiceDescriptions.SERVICE_DESCRIPTIONS_QNAME;
}
- public void write(ServiceDescriptions model, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
- XMLStreamException {
+ public void write(ServiceDescriptions model, XMLStreamWriter writer, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
// TODO: To be implemented
}
@@ -185,7 +249,7 @@
return ServiceDescriptions.class;
}
- public void resolve(ServiceDescriptions model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
- // TODO: To be implemented
+ public void resolve(ServiceDescriptions model, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
}
}
Modified: tuscany/sca-java-2.x/trunk/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor?rev=897502&r1=897501&r2=897502&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor (original)
+++ tuscany/sca-java-2.x/trunk/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor Sat Jan 9 18:00:24 2010
@@ -17,6 +17,6 @@
# Implementation class for the artifact processor extension
org.apache.tuscany.sca.implementation.osgi.xml.OSGiImplementationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#implementation.osgi,model=org.apache.tuscany.sca.implementation.osgi.OSGiImplementation
-org.apache.tuscany.sca.implementation.osgi.xml.ServiceDescriptionsProcessor;qname=http://www.osgi.org/xmlns/sd/v1.0.0#service-descriptions,model=org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions
+org.apache.tuscany.sca.implementation.osgi.xml.ServiceDescriptionsProcessor;qname=http://www.osgi.org/xmlns/rsa/v1.0.0#endpoint-descriptions,model=org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions
org.apache.tuscany.sca.implementation.osgi.xml.OSGiPropertyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#osgi.property,model=org.apache.tuscany.sca.implementation.osgi.OSGiProperty
org.apache.tuscany.sca.implementation.osgi.xml.SCAConfigProcessor;qname=http://www.osgi.org/xmlns/scact/v1.0.0#sca-config,model=org.apache.tuscany.sca.implementation.osgi.SCAConfig
Modified: tuscany/sca-java-2.x/trunk/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java?rev=897502&r1=897501&r2=897502&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java Sat Jan 9 18:00:24 2010
@@ -41,32 +41,34 @@
*/
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\"?>" + "<endpoint-descriptions xmlns=\"http://www.osgi.org/xmlns/rsa/v1.0.0\" "
+ "xmlns:sca=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\">"
- + "<service-description>"
- + "<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"
+ + "<endpoint-description>"
+ + "<property name=\"objectClass\" value=\"calculator.operations.AddService\"/>"
+ + "<property name=\"service.intents\" value=\"sca:SOAP sca:HTTP\"/>"
+ + "<property name=\"service.imported.configs\" value=\"org.osgi.sca\"/>"
+ + "</endpoint-description>"
+ + "<endpoint-description>"
+ + "<property name=\"service.intents\">"
+ + " <list>"
+ + " <value>SOAP</value>"
+ + " <value>HTTP</value>"
+ + " </list>"
+ "</property>"
- + "<property name=\"osgi.remote.configuration.sca.reference\">"
- + "addService"
- + "</property>"
- + "</service-description>"
- + "<service-description>"
- + "<provide interface=\"calculator.operations.SubtractService\"/>"
- + "<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\">"
- + "subtractService"
- + "</property>"
- + "</service-description>"
- + "</service-descriptions>";
+ + "<property name=\"endpoint.id\" value=\"http://ws.acme.com:9000/hello\"/>"
+ + "<property name=\"objectClass\" value=\"com.acme.Foo\"/>"
+ + "<property name=\"endpoint.package.version.com.acme\" value=\"4.2\"/>"
+ + "<property name=\"service.imported.configs\" value=\"com.acme\"/>"
+ + "<property name=\"com.acme.ws.xml\">"
+ + "<xml>"
+ + " <config xmlns=\"http://acme.com/defs\">"
+ + " <port>1029</port>"
+ + " <host>www.acme.com</host>"
+ + " </config>"
+ + " </xml>"
+ + " </property>"
+ + "</endpoint-description>"
+ + "</endpoint-descriptions>";
private static ServiceDescriptionsProcessor processor;
private static XMLStreamReader reader;
Modified: tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointHelper.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointHelper.java?rev=897502&r1=897501&r2=897502&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointHelper.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointHelper.java Sat Jan 9 18:00:24 2010
@@ -67,11 +67,11 @@
String serviceID = (String)props.get(Constants.SERVICE_ID);
if (serviceID != null) {
- props.put(RemoteConstants.ENDPOINT_ID, Long.parseLong(serviceID));
+ props.put(RemoteConstants.ENDPOINT_SERVICE_ID, Long.parseLong(serviceID));
}
- props.put(RemoteConstants.ENDPOINT_URI, endpoint.getURI());
+ props.put(RemoteConstants.ENDPOINT_ID, endpoint.getURI());
// FIXME: [rfeng] How to pass in the remote service id from the endpoint XML
- props.put(RemoteConstants.SERVICE_EXPORTED_CONFIGS, new String[] {"org.osgi.sca"});
+ props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, new String[] {"org.osgi.sca"});
props.put(Endpoint.class.getName(), endpoint);
List<String> interfaces = getInterfaces(endpoint);
props.put(Constants.OBJECTCLASS, interfaces.toArray(new String[interfaces.size()]));
Modified: tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java?rev=897502&r1=897501&r2=897502&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java Sat Jan 9 18:00:24 2010
@@ -425,10 +425,13 @@
JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
Class<?> interfaceClass = bundle.loadClass(intf);
JavaInterface javaInterface = javaInterfaceFactory.createJavaInterface(interfaceClass);
+ // [rfeng] For OSGi, the interfaces should be marked as remote
+ javaInterface.setRemotable(true);
interfaceContract.setInterface(javaInterface);
if (javaInterface.getCallbackClass() != null) {
- interfaceContract.setCallbackInterface(javaInterfaceFactory.createJavaInterface(javaInterface
- .getCallbackClass()));
+ JavaInterface callbackInterface = javaInterfaceFactory.createJavaInterface(javaInterface.getCallbackClass());
+ callbackInterface.setRemotable(true);
+ interfaceContract.setCallbackInterface(callbackInterface);
}
return interfaceContract;
}
Modified: tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ExportRegistrationImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ExportRegistrationImpl.java?rev=897502&r1=897501&r2=897502&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ExportRegistrationImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ExportRegistrationImpl.java Sat Jan 9 18:00:24 2010
@@ -30,10 +30,8 @@
*/
public class ExportRegistrationImpl implements ExportRegistration {
private Node node;
- private ServiceReference exportedService;
- private EndpointDescription endpointDescription;
- private Throwable exception;
private ExportReference exportReference;
+ private Throwable exception;
/**
* @param exportedService
@@ -46,8 +44,7 @@
Throwable exception) {
super();
this.node = node;
- this.exportedService = exportedService;
- this.endpointDescription = endpointDescription;
+ this.exportReference = new ExportReferenceImpl(exportedService, endpointDescription);
this.exception = exception;
}
@@ -68,16 +65,15 @@
node = null;
}
exception = null;
- endpointDescription = null;
- exportedService = null;
+ exportReference = new ExportReferenceImpl(null, null);
}
public ServiceReference getExportedService() {
- return exportedService;
+ return exportReference.getExportedService();
}
public EndpointDescription getEndpointDescription() {
- return endpointDescription;
+ return exportReference.getExportedEndpoint();
}
public Throwable getException() {
@@ -89,8 +85,7 @@
}
public ExportReference getExportReference() throws IllegalStateException {
- // TODO Auto-generated method stub
- return null;
+ return exportReference;
}
}
Modified: tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ImportRegistrationImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ImportRegistrationImpl.java?rev=897502&r1=897501&r2=897502&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ImportRegistrationImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ImportRegistrationImpl.java Sat Jan 9 18:00:24 2010
@@ -67,7 +67,7 @@
node = null;
}
exception = null;
- importReference = null;
+ importReference = new ImportReferenceImpl(null, null);
}
public Throwable getException() {
Modified: tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java?rev=897502&r1=897501&r2=897502&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java Sat Jan 9 18:00:24 2010
@@ -25,7 +25,7 @@
import static org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.OSGiHelper.getOSGiProperties;
import static org.osgi.framework.Constants.SERVICE_ID;
import static org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_FRAMEWORK_UUID;
-import static org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID;
+import static org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_SERVICE_ID;
import java.util.ArrayList;
import java.util.Collections;
@@ -88,7 +88,7 @@
ENDPOINT_FRAMEWORK_UUID,
getFrameworkUUID(reference.getBundle()
.getBundleContext())));
- service.getExtensions().add(createOSGiProperty(registry, ENDPOINT_ID, reference
+ service.getExtensions().add(createOSGiProperty(registry, ENDPOINT_SERVICE_ID, reference
.getProperty(SERVICE_ID)));
// FIXME: Configure the domain and node URI
Modified: tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java?rev=897502&r1=897501&r2=897502&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java Sat Jan 9 18:00:24 2010
@@ -41,6 +41,7 @@
import org.osgi.service.remoteserviceadmin.ExportRegistration;
import org.osgi.service.remoteserviceadmin.ImportReference;
import org.osgi.service.remoteserviceadmin.ImportRegistration;
+import org.osgi.service.remoteserviceadmin.RemoteConstants;
import org.osgi.service.remoteserviceadmin.RemoteServiceAdmin;
import org.osgi.service.remoteserviceadmin.RemoteServiceAdminEvent;
import org.osgi.service.remoteserviceadmin.RemoteServiceAdminListener;
@@ -70,8 +71,15 @@
this.importer = new OSGiServiceImporter(context);
exporter.start();
importer.start();
- registration = context.registerService(RemoteServiceAdmin.class.getName(), this, null);
Hashtable<String, Object> props = new Hashtable<String, Object>();
+ props.put(RemoteConstants.REMOTE_CONFIGS_SUPPORTED, new String[] {"org.osgi.sca"});
+ // FIXME: We should ask SCA domain for the supported intents
+ props.put(RemoteConstants.REMOTE_INTENTS_SUPPORTED, new String[] {});
+ // FIXME: We should ask SCA domain for the supported binding types
+ props.put("org.osgi.sca.binding.types", new String[] {});
+ registration = context.registerService(RemoteServiceAdmin.class.getName(), this, props);
+
+ props = new Hashtable<String, Object>();
props.put(Constants.SERVICE_PID, RemoteServiceAdminImpl.class.getName());
managedService = context.registerService(ManagedService.class.getName(), this, props);
listeners = new ServiceTracker(this.context, RemoteServiceAdminListener.class.getName(), null);
@@ -213,17 +221,17 @@
props.put("bundle-symbolicname", rsaBundle.getSymbolicName());
props.put("bundle-version", rsaBundle.getHeaders().get(Constants.BUNDLE_VERSION));
props.put("cause", rsaEvent.getException());
- props.put("import.reference", rsaEvent.getImportReference());
- props.put("export.reference", rsaEvent.getExportReference());
+ props.put("import.registration", rsaEvent.getImportReference());
+ props.put("export.registration", rsaEvent.getExportReference());
EndpointDescription ep = null;
if (rsaEvent.getImportReference() != null) {
ep = rsaEvent.getImportReference().getImportedEndpoint();
} else {
ep = rsaEvent.getExportReference().getExportedEndpoint();
}
- props.put("service.remote.id", ep.getRemoteServiceID());
- props.put("service.remote.uuid", ep.getRemoteFrameworkUUID());
- props.put("service.remote.uri", ep.getRemoteURI());
+ props.put("endpoint.service.id", ep.getRemoteServiceID());
+ props.put("endpoint.framework.uuid", ep.getRemoteFrameworkUUID());
+ props.put("endpoint.id", ep.getRemoteID());
props.put("objectClass", ep.getInterfaces());
props.put("service.imported.configs", ep.getConfigurationTypes());
props.put("timestamp", new Long(System.currentTimeMillis()));
Modified: tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java?rev=897502&r1=897501&r2=897502&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java Sat Jan 9 18:00:24 2010
@@ -25,10 +25,13 @@
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.core.LifeCycleListener;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
import org.apache.tuscany.sca.runtime.EndpointListener;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.service.remoteserviceadmin.EndpointDescription;
@@ -38,6 +41,7 @@
*/
public class DomainDiscoveryService extends AbstractDiscoveryService implements EndpointListener {
private DomainRegistryFactory domainRegistryFactory;
+ private EndpointRegistry endpointRegistry;
public DomainDiscoveryService(BundleContext context) {
super(context);
@@ -49,6 +53,18 @@
this.domainRegistryFactory =
registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(DomainRegistryFactory.class);
domainRegistryFactory.addListener(this);
+ // The following code forced the start() of the domain registry in absense of services
+ String domainRegistry = context.getProperty("org.osgi.sca.domain.registry");
+ if (domainRegistry == null) {
+ domainRegistry = NodeConfiguration.DEFAULT_DOMAIN_REGISTRY_URI;
+ }
+ String domainURI = context.getProperty("org.osgi.sca.domain.uri");
+ if (domainURI == null) {
+ domainURI = NodeConfiguration.DEFAULT_DOMAIN_URI;
+ }
+ if (domainRegistry != null) {
+ endpointRegistry = domainRegistryFactory.getEndpointRegistry(domainRegistry, domainURI);
+ }
}
public void endpointAdded(Endpoint endpoint) {
@@ -111,6 +127,9 @@
public void stop() {
domainRegistryFactory.removeListener(this);
+ if (endpointRegistry instanceof LifeCycleListener) {
+ ((LifeCycleListener)endpointRegistry).stop();
+ }
super.stop();
}
Modified: tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/LocalDiscoveryService.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/LocalDiscoveryService.java?rev=897502&r1=897501&r2=897502&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/LocalDiscoveryService.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/LocalDiscoveryService.java Sat Jan 9 18:00:24 2010
@@ -19,6 +19,9 @@
package org.apache.tuscany.sca.osgi.service.discovery.impl;
import static org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.OSGiHelper.getConfiguration;
+import static org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_FRAMEWORK_UUID;
+import static org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID;
+import static org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_SERVICE_ID;
import java.net.URL;
import java.util.ArrayList;
@@ -45,7 +48,6 @@
import org.osgi.framework.Filter;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
import org.osgi.util.tracker.BundleTracker;
import org.osgi.util.tracker.BundleTrackerCustomizer;
import org.osgi.util.tracker.ServiceTracker;
@@ -88,14 +90,14 @@
private EndpointDescription createEndpointDescription(ServiceDescription sd) {
Map<String, Object> props = new HashMap<String, Object>(sd.getProperties());
props.put(Constants.OBJECTCLASS, sd.getInterfaces().toArray(new String[sd.getInterfaces().size()]));
- if (!props.containsKey(RemoteConstants.ENDPOINT_ID)) {
- props.put(RemoteConstants.ENDPOINT_ID, new Long(System.currentTimeMillis()));
+ if (!props.containsKey(ENDPOINT_SERVICE_ID)) {
+ props.put(ENDPOINT_SERVICE_ID, new Long(System.currentTimeMillis()));
}
- if (!props.containsKey(RemoteConstants.ENDPOINT_FRAMEWORK_UUID)) {
- props.put(RemoteConstants.ENDPOINT_FRAMEWORK_UUID, OSGiHelper.getFrameworkUUID(context));
+ if (!props.containsKey(ENDPOINT_FRAMEWORK_UUID)) {
+ props.put(ENDPOINT_FRAMEWORK_UUID, OSGiHelper.getFrameworkUUID(context));
}
- if (!props.containsKey(RemoteConstants.ENDPOINT_URI)) {
- props.put(RemoteConstants.ENDPOINT_URI, UUID.randomUUID().toString());
+ if (!props.containsKey(ENDPOINT_ID)) {
+ props.put(ENDPOINT_ID, UUID.randomUUID().toString());
}
EndpointDescription sed = new EndpointDescription(props);
Modified: tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointDescription.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointDescription.java?rev=897502&r1=897501&r2=897502&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointDescription.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointDescription.java Sat Jan 9 18:00:24 2010
@@ -1,5 +1,5 @@
/*
- * Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2008, 2010). 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.
@@ -42,18 +42,21 @@
* A description of an endpoint that provides sufficient information for a
* compatible distribution provider to create a connection to this endpoint
*
- * An Endpoint Description is easy to transfer between different systems. This
- * allows it to be used as a communications device to convey available endpoint
- * information to nodes in a network.
+ * An Endpoint Description is easy to transfer between different systems because
+ * it is property based where the property keys are strings and the values are
+ * simple types. This allows it to be used as a communications device to convey
+ * available endpoint information to nodes in a network.
*
- * An Endpoint Description reflects the perspective of an importer. That is, the
- * property keys have been chosen to match filters that are created by client
- * bundles that need a service. Therefore the map must not contain any
- * service.exported.* property and must contain the service.imported.* ones.
+ * An Endpoint Description reflects the perspective of an <i>importer</i>. That
+ * is, the property keys have been chosen to match filters that are created by
+ * client bundles that need a service. Therefore the map must not contain any
+ * <code>service.exported.*</code> property and must contain the corresponding
+ * <code>service.imported.*</code> ones.
*
- * The service.intents property contains the intents provided by the service
- * itself combined with the intents added by the exporting distribution
- * provider. Qualified intents appear expanded on this property.
+ * The <code>service.intents</code> property must contain the intents provided
+ * by the service itself combined with the intents added by the exporting
+ * distribution provider. Qualified intents appear fully expanded on this
+ * property.
*
* @Immutable
* @version $Revision$
@@ -62,15 +65,17 @@
public class EndpointDescription {
private final Map<String, Object> properties;
private final List<String> interfaces;
- private final long remoteServiceId;
+ private final long remoteServiceID;
private final String remoteFrameworkUUID;
- private final String remoteUri;
+ private final String remoteID;
/**
- * Create an Endpoint Description based on a Map.
+ * Create an Endpoint Description from a Map.
*
* <p>
- * The {@link RemoteConstants#ENDPOINT_URI} property must be set.
+ * The {@link RemoteConstants#ENDPOINT_ID endpoint.id},
+ * {@link RemoteConstants#SERVICE_IMPORTED_CONFIGS service.imported.configs}
+ * and <code>objectClass</code> properties must be set.
*
* @param properties The map from which to create the Endpoint Description.
* The keys in the map must be type <code>String</code> and, since
@@ -94,28 +99,46 @@
}
if (props.size() < properties.size()) {
throw new IllegalArgumentException(
- "duplicate keys with different cases in properties");
+ "duplicate keys with different cases in properties: "
+ + new ArrayList<String>(props.keySet())
+ .removeAll(properties.keySet()));
}
+ if (!props.containsKey(SERVICE_IMPORTED)) {
+ props.put(SERVICE_IMPORTED, Boolean.toString(true));
+ }
this.properties = Collections.unmodifiableMap(props);
/* properties must be initialized before calling the following methods */
interfaces = verifyObjectClassProperty();
- remoteServiceId = verifyLongProperty(ENDPOINT_ID);
+ remoteServiceID = verifyLongProperty(ENDPOINT_SERVICE_ID);
remoteFrameworkUUID = verifyStringProperty(ENDPOINT_FRAMEWORK_UUID);
- remoteUri = verifyStringProperty(ENDPOINT_URI);
- if (remoteUri == null) {
- throw new IllegalArgumentException(ENDPOINT_URI
+ remoteID = verifyStringProperty(ENDPOINT_ID);
+ if (remoteID == null) {
+ throw new IllegalArgumentException(ENDPOINT_ID
+ " property must be set");
}
+ if (getConfigurationTypes().isEmpty()) {
+ throw new IllegalArgumentException(SERVICE_IMPORTED_CONFIGS
+ + " property must be set and non-empty");
+ }
}
/**
- * Create an Endpoint Description based on a service reference and a map of
+ * Create an Endpoint Description based on a Service Reference and a Map of
* properties. The properties in the map take precedence over the properties
- * in the service reference.
+ * in the Service Reference.
*
* <p>
- * The {@link RemoteConstants#ENDPOINT_URI} property must be set.
+ * This method will automatically set the
+ * {@link RemoteConstants#ENDPOINT_FRAMEWORK_UUID endpoint.framework.uuid}
+ * and {@link RemoteConstants#ENDPOINT_SERVICE_ID endpoint.service.id}
+ * properties based on the specified Service Reference as well as the
+ * {@link RemoteConstants#SERVICE_IMPORTED service.imported} property if
+ * they are not specified as properties.
+ * <p>
+ * The {@link RemoteConstants#ENDPOINT_ID endpoint.id},
+ * {@link RemoteConstants#SERVICE_IMPORTED_CONFIGS service.imported.configs}
+ * and <code>objectClass</code> properties must be set.
*
* @param reference A service reference that can be exported.
* @param properties Map of properties. This argument can be
@@ -142,7 +165,9 @@
}
if (props.size() < properties.size()) {
throw new IllegalArgumentException(
- "duplicate keys with different cases in properties");
+ "duplicate keys with different cases in properties: "
+ + new ArrayList<String>(props.keySet())
+ .removeAll(properties.keySet()));
}
}
@@ -152,8 +177,8 @@
}
}
- if (!props.containsKey(ENDPOINT_ID)) {
- props.put(ENDPOINT_ID, reference.getProperty(Constants.SERVICE_ID));
+ if (!props.containsKey(ENDPOINT_SERVICE_ID)) {
+ props.put(ENDPOINT_SERVICE_ID, reference.getProperty(Constants.SERVICE_ID));
}
if (!props.containsKey(ENDPOINT_FRAMEWORK_UUID)) {
String uuid = null;
@@ -173,36 +198,43 @@
props.put(ENDPOINT_FRAMEWORK_UUID, uuid);
}
}
+ if (!props.containsKey(SERVICE_IMPORTED)) {
+ props.put(SERVICE_IMPORTED, Boolean.toString(true));
+ }
this.properties = Collections.unmodifiableMap(props);
/* properties must be initialized before calling the following methods */
interfaces = verifyObjectClassProperty();
- remoteServiceId = verifyLongProperty(ENDPOINT_ID);
+ remoteServiceID = verifyLongProperty(ENDPOINT_SERVICE_ID);
remoteFrameworkUUID = verifyStringProperty(ENDPOINT_FRAMEWORK_UUID);
- remoteUri = verifyStringProperty(ENDPOINT_URI);
- if (remoteUri == null) {
- throw new IllegalArgumentException(ENDPOINT_URI
+ remoteID = verifyStringProperty(ENDPOINT_ID);
+ if (remoteID == null) {
+ throw new IllegalArgumentException(ENDPOINT_ID
+ " property must be set");
}
+ if (getConfigurationTypes().isEmpty()) {
+ throw new IllegalArgumentException(SERVICE_IMPORTED_CONFIGS
+ + " property must be set and non-empty");
+ }
}
/**
* Verify and obtain the interface list from the properties.
*
* @return A list with the interface names.
- * @throws IllegalArgumentException When the properties do not contain the
- * right values for and interface list.
- *
+ * @throws IllegalArgumentException If the objectClass property is not set
+ * or is empty or if the package version property values are
+ * malformed.
*/
private List<String> verifyObjectClassProperty() {
Object o = properties.get(Constants.OBJECTCLASS);
- if (o == null) {
- return Collections.EMPTY_LIST;
- }
if (!(o instanceof String[])) {
throw new IllegalArgumentException(
"objectClass value must be of type String[]");
}
String[] objectClass = (String[]) o;
+ if (objectClass.length < 1) {
+ throw new IllegalArgumentException("objectClass is empty");
+ }
for (String interf : objectClass) {
int index = interf.lastIndexOf('.');
if (index == -1) {
@@ -269,19 +301,19 @@
}
/**
- * Returns the endpoint's URI.
+ * Returns the endpoint's id.
*
- * The URI is an opaque id for an endpoint in URI form. No two different
- * endpoints must have the same URI, two Endpoint Descriptions with the same
- * URI must represent the same endpoint.
+ * The id is an opaque id for an endpoint. No two different endpoints must
+ * have the same id. Two Endpoint Descriptions with the same id must
+ * represent the same endpoint.
*
- * The value of the URI is stored in the
- * {@link RemoteConstants#ENDPOINT_URI} property.
+ * The value of the id is stored in the
+ * {@link RemoteConstants#ENDPOINT_ID} property.
*
- * @return The URI of the endpoint, never <code>null</code>.
+ * @return The id of the endpoint, never <code>null</code>.
*/
- public String getRemoteURI() {
- return remoteUri;
+ public String getRemoteID() {
+ return remoteID;
}
/**
@@ -344,14 +376,14 @@
* id for a service.
*
* The value of the remote service id is stored in the
- * {@link RemoteConstants#ENDPOINT_ID} endpoint property.
+ * {@link RemoteConstants#ENDPOINT_SERVICE_ID} endpoint property.
*
* @return Service id of a service or 0 if this Endpoint Description does
- * not relate to an OSGi service
+ * not relate to an OSGi service.
*
*/
public long getRemoteServiceID() {
- return remoteServiceId;
+ return remoteServiceID;
}
/**
@@ -426,7 +458,7 @@
List<String> result = new ArrayList<String>(values.size());
for (Iterator< ? > iter = values.iterator(); iter.hasNext();) {
Object v = iter.next();
- if ((v != null) && (v instanceof String)) {
+ if (v instanceof String) {
result.add((String) v);
}
}
@@ -464,7 +496,7 @@
* as the given Endpoint Description.
*
* Two Endpoint Descriptions point to the same service if they have the same
- * URI or their framework UUIDs and remote service ids are equal.
+ * id or their framework UUIDs and remote service ids are equal.
*
* @param other The Endpoint Description to look at
* @return True if this endpoint description points to the same service as
@@ -490,7 +522,7 @@
* @return An integer which is a hash code value for this object.
*/
public int hashCode() {
- return getRemoteURI().hashCode();
+ return getRemoteID().hashCode();
}
/**
@@ -498,7 +530,7 @@
*
* <p>
* An Endpoint Description is considered to be <b>equal to</b> another
- * Endpoint Description if their URIs are equal.
+ * Endpoint Description if their ids are equal.
*
* @param other The <code>EndpointDescription</code> object to be compared.
* @return <code>true</code> if <code>object</code> is a
@@ -512,13 +544,13 @@
if (!(other instanceof EndpointDescription)) {
return false;
}
- return getRemoteURI().equals(
- ((EndpointDescription) other).getRemoteURI());
+ return getRemoteID().equals(
+ ((EndpointDescription) other).getRemoteID());
}
/**
- * Tests the properties of this <code>EndpointDescription</code> against the
- * given filter using a case insensitive match.
+ * Tests the properties of this <code>EndpointDescription</code> against
+ * the given filter using a case insensitive match.
*
* @param filter The filter to test.
* @return <code>true</code> If the properties of this
@@ -548,9 +580,10 @@
}
/**
- * Unmodifiable Dictionary wrapper for a Map.
+ * Unmodifiable Dictionary wrapper for a Map. This class is also used by
+ * EndpointPermission.
*/
- private static class UnmodifiableDictionary<K, V> extends Dictionary<K, V> {
+ static class UnmodifiableDictionary<K, V> extends Dictionary<K, V> {
private final Map<K, V> wrapped;
UnmodifiableDictionary(Map<K, V> wrapped) {
@@ -584,5 +617,9 @@
public int size() {
return wrapped.size();
}
+
+ public String toString() {
+ return wrapped.toString();
+ }
}
}