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 2009/03/24 19:51:25 UTC
svn commit: r757952 - in /tuscany/java/sca/modules:
implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/
implementation-osgi/src/main/resources/META-INF/services/
node-impl-osgi/src/test/java/calculator/dosgi/test/ node-imp...
Author: rfeng
Date: Tue Mar 24 18:51:23 2009
New Revision: 757952
URL: http://svn.apache.org/viewvc?rev=757952&view=rev
Log:
Add coding to parse RFC-119 service-descriptions file
Added:
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsModelResolver.java (with props)
tuscany/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
tuscany/java/sca/modules/node-impl-osgi/src/test/resources/OSGI-INF/remote-service/
tuscany/java/sca/modules/node-impl-osgi/src/test/resources/OSGI-INF/remote-service/calculator-service-descriptions.xml (with props)
Modified:
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java
tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsDocumentProcessor.java
tuscany/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
tuscany/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
tuscany/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java
tuscany/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiTestCase.java
tuscany/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/OSGiTestBundles.java
Modified: tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java?rev=757952&r1=757951&r2=757952&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java (original)
+++ tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java Tue Mar 24 18:51:23 2009
@@ -45,6 +45,8 @@
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.ServiceDescription;
+import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions;
import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory;
import org.apache.tuscany.sca.interfacedef.Interface;
import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
@@ -176,6 +178,11 @@
mergeFromComponentType(impl, componentType, resolver);
}
+ ServiceDescriptions descriptions = serviceDescriptionsFactory.createServiceDescriptions();
+ descriptions = resolver.resolveModel(ServiceDescriptions.class, descriptions);
+ for(ServiceDescription ds: descriptions) {
+ System.out.println(ds);
+ }
// FIXME: How to find the RFC 119 service descriptions in the contribution and
// derive the SCA component type from them?
}
Modified: tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsDocumentProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsDocumentProcessor.java?rev=757952&r1=757951&r2=757952&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsDocumentProcessor.java (original)
+++ tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsDocumentProcessor.java Tue Mar 24 18:51:23 2009
@@ -50,7 +50,7 @@
StAXArtifactProcessor staxProcessor,
Monitor monitor) {
super();
- this.extensionProcessor = extensionProcessor;
+ this.extensionProcessor = staxProcessor;
this.inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class);
}
Added: tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsModelResolver.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsModelResolver.java?rev=757952&view=auto
==============================================================================
--- tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsModelResolver.java (added)
+++ tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsModelResolver.java Tue Mar 24 18:51:23 2009
@@ -0,0 +1,58 @@
+/*
+ * 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.xml;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions;
+import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory;
+
+/**
+ *
+ */
+public class ServiceDescriptionsModelResolver implements ModelResolver {
+ private ServiceDescriptions serviceDescriptions;
+
+ public ServiceDescriptionsModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) {
+ ServiceDescriptionsFactory factory = modelFactories.getFactory(ServiceDescriptionsFactory.class);
+ this.serviceDescriptions = factory.createServiceDescriptions();
+ }
+
+ public void addModel(Object resolved) {
+ // Merge the service descriptions
+ if (resolved instanceof ServiceDescriptions) {
+ serviceDescriptions.addAll((ServiceDescriptions)resolved);
+ }
+ }
+
+ public Object removeModel(Object resolved) {
+ // Remove the service descriptions
+ if (resolved instanceof ServiceDescriptions) {
+ serviceDescriptions.removeAll((ServiceDescriptions)resolved);
+ }
+ return resolved;
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved) {
+ // Always return the aggregated service descriptions
+ return modelClass.cast(serviceDescriptions);
+ }
+}
Propchange: tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsModelResolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsModelResolver.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: tuscany/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor?rev=757952&r1=757951&r2=757952&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor (original)
+++ tuscany/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor Tue Mar 24 18:51:23 2009
@@ -17,5 +17,5 @@
# 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/sd/v1.0.0#service-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
Modified: tuscany/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor?rev=757952&r1=757951&r2=757952&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor (original)
+++ tuscany/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor Tue Mar 24 18:51:23 2009
@@ -16,4 +16,4 @@
# under the License.
# Implementation class for the artifact processor extension
-org.apache.tuscany.sca.implementation.osgi.xml.ServiceDescriptionsDocumentProcessor;type=/OSGI-INF/remote-service/remote-services.xml,model=org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions
+org.apache.tuscany.sca.implementation.osgi.xml.ServiceDescriptionsDocumentProcessor;type=/OSGI-INF/remote-service/*.xml,model=org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions
Added: tuscany/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver?rev=757952&view=auto
==============================================================================
--- tuscany/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver (added)
+++ tuscany/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver Tue Mar 24 18:51:23 2009
@@ -0,0 +1,17 @@
+# 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.
+org.apache.tuscany.sca.implementation.osgi.xml.ServiceDescriptionsModelResolver;model=org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions
Modified: tuscany/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java?rev=757952&r1=757951&r2=757952&view=diff
==============================================================================
--- tuscany/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java (original)
+++ tuscany/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java Tue Mar 24 18:51:23 2009
@@ -84,7 +84,8 @@
bundles.add(OSGiTestBundles.createBundle("target/test-classes/calculator-bundle.jar",
"calculator/dosgi/META-INF/MANIFEST.MF",
new String[][] {
- {"OSGI-INF/calculator-component.xml", null},
+ {"OSGI-INF/remote-service/calculator-service-descriptions.xml"},
+ {"OSGI-INF/calculator-component.xml"},
{"calculator/dosgi/bundle.componentType",
"OSGI-INF/sca/bundle.componentType"},
{"calculator/dosgi/calculator.composite",
@@ -106,10 +107,10 @@
.createBundle("target/test-classes/operations-bundle.jar",
"calculator/dosgi/operations/META-INF/MANIFEST.MF",
new String[][] {
- {"OSGI-INF/add-component.xml", null},
- {"OSGI-INF/subtract-component.xml", null},
- {"OSGI-INF/multiply-component.xml", null},
- {"OSGI-INF/divide-component.xml", null},
+ {"OSGI-INF/add-component.xml"},
+ {"OSGI-INF/subtract-component.xml"},
+ {"OSGI-INF/multiply-component.xml"},
+ {"OSGI-INF/divide-component.xml"},
{"calculator/dosgi/operations/bundle.componentType",
"OSGI-INF/sca/bundle.componentType"},
{"calculator/dosgi/operations/operations.composite",
Modified: tuscany/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiTestCase.java?rev=757952&r1=757951&r2=757952&view=diff
==============================================================================
--- tuscany/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiTestCase.java (original)
+++ tuscany/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiTestCase.java Tue Mar 24 18:51:23 2009
@@ -64,7 +64,7 @@
bundles.add(OSGiTestBundles.createBundle("target/test-classes/calculator-bundle.jar",
"calculator/dosgi/META-INF/MANIFEST.MF",
new String[][] {
- {"OSGI-INF/calculator-component.xml", null},
+ {"OSGI-INF/calculator-component.xml"},
{"calculator/dosgi/bundle.componentType",
"OSGI-INF/sca/bundle.componentType"},
{"calculator/dosgi/calculator.composite",
@@ -77,10 +77,10 @@
bundles.add(OSGiTestBundles.createBundle("target/test-classes/operations-bundle.jar",
"calculator/dosgi/operations/META-INF/MANIFEST.MF",
new String[][] {
- {"OSGI-INF/add-component.xml", null},
- {"OSGI-INF/subtract-component.xml", null},
- {"OSGI-INF/multiply-component.xml", null},
- {"OSGI-INF/divide-component.xml", null},
+ {"OSGI-INF/add-component.xml"},
+ {"OSGI-INF/subtract-component.xml"},
+ {"OSGI-INF/multiply-component.xml"},
+ {"OSGI-INF/divide-component.xml"},
{"calculator/dosgi/operations/bundle.componentType",
"OSGI-INF/sca/bundle.componentType"},
{"calculator/dosgi/operations/operations.composite",
@@ -113,7 +113,7 @@
System.out.println(string(b, false));
}
}
-
+
// Sleep for 1 sec so that the DS is available
Thread.sleep(1000);
// Use the DS version
Modified: tuscany/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/OSGiTestBundles.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/OSGiTestBundles.java?rev=757952&r1=757951&r2=757952&view=diff
==============================================================================
--- tuscany/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/OSGiTestBundles.java (original)
+++ tuscany/java/sca/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/OSGiTestBundles.java Tue Mar 24 18:51:23 2009
@@ -64,7 +64,11 @@
if (resources != null) {
for (String resource[] : resources) {
- addResource(jarOut, OSGiTestBundles.class.getClassLoader(), resource[0], resource[1]);
+ if (resource.length >= 1) {
+ String r1 = resource[0];
+ String r2 = resource.length > 1 ? resource[1] : r1;
+ addResource(jarOut, OSGiTestBundles.class.getClassLoader(), r1, r2);
+ }
}
}
Added: tuscany/java/sca/modules/node-impl-osgi/src/test/resources/OSGI-INF/remote-service/calculator-service-descriptions.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl-osgi/src/test/resources/OSGI-INF/remote-service/calculator-service-descriptions.xml?rev=757952&view=auto
==============================================================================
--- tuscany/java/sca/modules/node-impl-osgi/src/test/resources/OSGI-INF/remote-service/calculator-service-descriptions.xml (added)
+++ tuscany/java/sca/modules/node-impl-osgi/src/test/resources/OSGI-INF/remote-service/calculator-service-descriptions.xml Tue Mar 24 18:51:23 2009
@@ -0,0 +1,65 @@
+<?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.
+-->
+<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="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>
+ <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-description>
+ <provide interface="calculator.operations.MultiplyService" />
+ <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">
+ multiplyService
+ </property>
+ </service-description>
+ <service-description>
+ <provide interface="calculator.operations.DivideService" />
+ <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">
+ divideService
+ </property>
+ </service-description>
+</service-descriptions>
Propchange: tuscany/java/sca/modules/node-impl-osgi/src/test/resources/OSGI-INF/remote-service/calculator-service-descriptions.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/java/sca/modules/node-impl-osgi/src/test/resources/OSGI-INF/remote-service/calculator-service-descriptions.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date