summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/implementation-osgi/src
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-10-27 21:04:51 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-10-27 21:04:51 +0000
commit5cfd47acaadaca214fa71ac58fb9225825d3f561 (patch)
tree590e5686b28c64c13a13a29dfc8a26910b83e5f3 /java/sca/modules/implementation-osgi/src
parent49992e45cb204a23cf1800d5c078e50600ff044c (diff)
Use sca-config XML files for SCA binding/policy definitions
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@830339 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/implementation-osgi/src')
-rw-r--r--java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/BindingDescriptions.java34
-rw-r--r--java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java154
-rw-r--r--java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/SCAConfig.java65
-rw-r--r--java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptionsFactory.java4
-rw-r--r--java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/SCAConfigImpl.java (renamed from java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/BindingDescriptionsImpl.java)34
-rw-r--r--java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsFactoryImpl.java6
-rw-r--r--java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/BindingDescriptionsProcessor.java114
-rw-r--r--java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/SCAConfigProcessor.java190
-rw-r--r--java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor2
9 files changed, 386 insertions, 217 deletions
diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/BindingDescriptions.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/BindingDescriptions.java
deleted file mode 100644
index 5265241920..0000000000
--- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/BindingDescriptions.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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;
-
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.sca.assembly.Binding;
-
-/**
- * OSGi RFC 119 SCA binding descriptions
- */
-public interface BindingDescriptions extends List<Binding> {
- String OSGI_SD_NS = ServiceDescriptions.OSGI_SD_NS;
- QName BINDINGS_QNAME = new QName(OSGI_SD_NS, "bindings");
-}
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 455071dbb8..e0b7f43add 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,85 +28,103 @@ public interface OSGiProperty {
String NAME = "name";
QName PROPERTY_QNAME = new QName(OSGiImplementation.SCA11_TUSCANY_NS, "osgi.property");
- String SCA_BINDINGS = "sca.bindings";
+ String REMOTE_CONFIG_SCA = "org.osgi.sca";
+ String SCA_BINDINGS = "org.osgi.sca.bindings";
String SCA_REFERENCE = "sca.reference";
String SCA_SERVICE = "sca.service";
String SCA_REFERENCE_BINDING = "sca.reference.binding";
String SCA_SERVICE_BINDING = "sca.service.binding";
- String REMOTE_CONFIG_SCA = "sca";
/**
- * The configuration types supported by this Distribution Provider. Services
- * that are suitable for distribution list the configuration types that
- * describe the configuration information for that service in the
- * SERVICE_EXPORTED_CONFIGS or SERVICE_IMPORTED_CONFIGS property. A
- * distribution provider must register a service that has this property and
- * enumerate all configuration types that it supports. The type of this
- * property String+
- *
- * @see SERVICE_EXPORTED_CONFIGS
- * @see SERVICE_IMPORTED_CONFIGS
+ * The configuration types supported by this Distribution Provider.
+ *
+ * Services that are suitable for distribution list the configuration types
+ * that describe the configuration information for that service in the
+ * {@link #SERVICE_EXPORTED_CONFIGS} or {@link #SERVICE_IMPORTED_CONFIGS}
+ * property.
+ *
+ * A distribution provider must register a service that has this property
+ * and enumerate all configuration types that it supports.
+ *
+ * The type of this property <code>String+</code>
+ *
+ * @see #SERVICE_EXPORTED_CONFIGS
+ * @see #SERVICE_IMPORTED_CONFIGS
*/
- String REMOTE_CONFIGS_SUPPORTED = "remote.configs.supported";
+ public final static String REMOTE_CONFIGS_SUPPORTED = "remote.configs.supported";
/**
* Service property that lists the intents supported by the distribution
- * provider. Each distribution provider must register a service that has
- * this property and enumerate all the supported intents, having any
- * qualified intents expanded. The value of this property is of type
- * String+.
- *
- * @see SERVICE_INTENTS
- * @see SERVICE_EXPORTED_INTENTS
- * @see SERVICE_EXPORTED_INTENTS_EXTRA
+ * provider.
+ *
+ * Each distribution provider must register a service that has this property
+ * and enumerate all the supported intents, having any qualified intents
+ * expanded.
+ *
+ * The value of this property is of type <code>String+</code>.
+ *
+ * @see #SERVICE_INTENTS
+ * @see #SERVICE_EXPORTED_INTENTS
+ * @see #SERVICE_EXPORTED_INTENTS_EXTRA
*/
- String REMOTE_INTENTS_SUPPORTED = "remote.intents.supported";
+ public final static String REMOTE_INTENTS_SUPPORTED = "remote.intents.supported";
/**
* A list of configuration types that should be used to export the service.
- * Configuration types can be synonymous or alternatives. In principle, a
- * distribution provider should create an endpoint for each recognized
- * configuration type, the deployer is responsible that synonyms do not
- * clash. Each configuration type has an associated specification that
- * describes how the configuration data for the exported service is
- * represented in an OSGi framework. The value of this property is of type
- * String+.
+ *
+ * Configuration types can be <em>synonymous</em> or <em>alternatives</em>.
+ * In principle, a distribution provider should create an endpoint for each
+ * recognized configuration type, the deployer is responsible that synonyms
+ * do not clash.
+ *
+ * Each configuration type has an associated specification that describes
+ * how the configuration data for the exported service is represented in an
+ * OSGi framework.
+ *
+ * The value of this property is of type <code>String+</code>.
*/
- String SERVICE_EXPORTED_CONFIGS = "service.exported.configs";
+ public final static String SERVICE_EXPORTED_CONFIGS = "service.exported.configs";
/**
* A list of intents that the distribution provider must implement to
* distribute the service. Intents listed in this property are reserved for
* intents that are critical for the code to function correctly, for
* example, ordering of messages. These intents should not be configurable.
- * The value of this property is of type String+.
+ *
+ * The value of this property is of type <code>String+</code>.
*/
- String SERVICE_EXPORTED_INTENTS = "service.exported.intents";
+ public final static String SERVICE_EXPORTED_INTENTS = "service.exported.intents";
/**
* Extra intents configured in addition to the the intents specified in
- * SERVICE_EXPORTED_INTENTS. These intents are merged with the service.
- * exported.intents and therefore have the same semantics. They are extra,
- * so that the SERVICE_EXPORTED_INTENTS can be set by the bundle developer
- * and this property is then set by the administrator/deployer. Bundles
- * should make this property configurable, for example through the
- * Configuration Admin service. The value of this property is of type
- * String+.
+ * {@link #SERVICE_EXPORTED_INTENTS}.
+ *
+ * These intents are merged with the service.exported.intents and therefore
+ * have the same semantics. They are extra, so that the
+ * {@link #SERVICE_EXPORTED_INTENTS} can be set by the bundle developer and
+ * this property is then set by the administrator/deployer. Bundles should
+ * make this property configurable, for example through the Configuration
+ * Admin service.
+ *
+ * The value of this property is of type <code>String+</code>.
*/
- String SERVICE_EXPORTED_INTENTS_EXTRA = "service.exported.intents.extra";
+ public final static String SERVICE_EXPORTED_INTENTS_EXTRA = "service.exported.intents.extra";
/**
- * Defines the interfaces under which this service can be exported. This
- * list must be a subset of the types listed in the objectClass service
- * property. The single value of an asterisk ('*' *) indicates all
+ * Defines the interfaces under which this service can be exported.
+ *
+ * This list must be a subset of the types listed in the objectClass service
+ * property. The single value of an asterisk ('*' \u002A) indicates all
* interfaces in the registration's objectClass property (not classes). It
* is highly recommended to only export interfaces and not concrete classes
- * due to the complexity of creating proxies for some type of classes. The
- * value of this property is of type String+.
+ * due to the complexity of creating proxies for some type of classes.
+ *
+ * The value of this property is of type String+.
*/
- String SERVICE_EXPORTED_INTERFACES = "service.exported.interfaces";
+ public final static String SERVICE_EXPORTED_INTERFACES = "service.exported.interfaces";
/**
- * Must be set by a distribution provider to true when it registers the
- * end-point proxy as an imported service. Can be used by a bundle to
- * prevent it from getting an imported service. The value of this property
- * is not defined, setting it is sufficient.
+ * Must be set by a distribution provider to <code>true</code> when it
+ * registers the end-point proxy as an imported service. Can be used by a
+ * bundle to prevent it from getting an imported service.
+ *
+ * The value of this property is not defined, setting it is sufficient.
*/
- String SERVICE_IMPORTED = "service.imported";
+ public final static String SERVICE_IMPORTED = "service.imported";
/**
* A list of intents that this service implements. This property has dual
* purpose. A bundle can use this service property to notify the
@@ -115,19 +133,41 @@ public interface OSGiProperty {
* must use this property to convey the combined intents of the exporting
* service and the intents that the distribution providers add. To export a
* service, a distribution provider must recognize all these intents and
- * expand any qualified intents. The value of this property is of type
- * String+.
+ * expand any qualified intents.
+ *
+ * The value of this property is of type <code>String+</code>.
*/
- String SERVICE_INTENTS = "service.intents";
+ public final static String SERVICE_INTENTS = "service.intents";
+ /**
+ * The property key for the endpoint service id. This is a unique id for a
+ * service based on the framework id '.' service id or another model. As far as this specification is
+ * concerned, this unique id is opaque.
+ */
+ final public static String SERVICE_REMOTE_FRAMEWORK_UUID = "service.remote.framework.id";
+ /**
+ * The property key for the endpoint service id. This is a unique id for a
+ * service based on the framework id '.' service id or another model. As far as this specification is
+ * concerned, this unique id is opaque.
+ */
+ final public static String SERVICE_REMOTE_ID = "service.remote.id";
+ /**
+ * The property key for the endpoint URI. This is a unique id for an
+ * endpoint following the URI syntax. As far as this specification is
+ * concerned, this unique id is opaque.
+ */
+ final public static String SERVICE_REMOTE_URI = "service.remote.uri";
/**
* The configuration type used to import this services, as described in
- * SERVICE_EXPORTED_CONFIGS. Any associated properties for this
+ * {@link #SERVICE_EXPORTED_CONFIGS}. Any associated properties for this
* configuration types must be properly mapped to the importing system. For
* example, a URL in these properties must point to a valid resource when
* used in the importing framework. Configuration types in this property
- * must be synonymous. The value of this property is of type String+.
+ * must be synonymous.
+ *
+ * The value of this property is of type <code>String+</code>.
*/
- String SERVICE_IMPORTED_CONFIGS = "service.imported.configs";
+ public final String SERVICE_IMPORTED_CONFIGS = "service.imported.configs";
+
String getValue();
diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/SCAConfig.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/SCAConfig.java
new file mode 100644
index 0000000000..a54324b027
--- /dev/null
+++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/SCAConfig.java
@@ -0,0 +1,65 @@
+/*
+ * 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;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ *
+ */
+public interface SCAConfig {
+ /**
+ * Returns the target namespace for this SCA Definition
+ * @return the target namespace
+ */
+ String getTargetNamespace();
+
+ /**
+ * Sets the target names for this SCA Definition.
+ *
+ * @param ns the target namespace for this SCA Definition
+ */
+ void setTargetNamespace(String ns);
+
+ /**
+ * Returns a list of domain wide Policy Intents
+ *
+ * @return a list of domain wide Policy Intents
+ */
+ List<Intent> getIntents();
+
+ /**
+ * Returns a list of domain wide PolicySets
+ *
+ * @return a list of domain wide PolicySets
+ */
+ List<PolicySet> getPolicySets();
+
+ /**
+ * Returns a list of domain wide binding definition objects
+ *
+ * @return a list of domain wide binding definition objects
+ */
+ List<Binding> getBindings();
+}
diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptionsFactory.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptionsFactory.java
index 249377e3ea..535bef2b6b 100644
--- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptionsFactory.java
+++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptionsFactory.java
@@ -26,6 +26,6 @@ public interface ServiceDescriptionsFactory {
ServiceDescriptions createServiceDescriptions();
ServiceDescription createServiceDescription();
-
- BindingDescriptions createBindingDescriptions();
+
+ SCAConfig createSCAConfig();
}
diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/BindingDescriptionsImpl.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/SCAConfigImpl.java
index 66ca01bacf..4bb1b2340f 100644
--- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/BindingDescriptionsImpl.java
+++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/SCAConfigImpl.java
@@ -19,18 +19,40 @@
package org.apache.tuscany.sca.implementation.osgi.impl;
-import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
import org.apache.tuscany.sca.assembly.Binding;
-import org.apache.tuscany.sca.implementation.osgi.BindingDescriptions;
+import org.apache.tuscany.sca.implementation.osgi.SCAConfig;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
/**
*
*/
-public class BindingDescriptionsImpl extends ArrayList<Binding> implements BindingDescriptions {
- private static final long serialVersionUID = 7647814680087128002L;
+public class SCAConfigImpl implements SCAConfig {
+ private String targetNamespace = null;
+ private List<Intent> intents = new CopyOnWriteArrayList<Intent>();
+ private List<PolicySet> policySets = new CopyOnWriteArrayList<PolicySet>();
+ private List<Binding> bindings = new CopyOnWriteArrayList<Binding>();
- public BindingDescriptionsImpl() {
- super();
+ public List<Intent> getIntents() {
+ return intents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public String getTargetNamespace() {
+ return targetNamespace;
+ }
+
+ public void setTargetNamespace(String ns) {
+ this.targetNamespace = ns;
+ }
+
+ public List<Binding> getBindings() {
+ return bindings;
}
}
diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsFactoryImpl.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsFactoryImpl.java
index 625f1e7cfb..716984a13b 100644
--- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsFactoryImpl.java
+++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsFactoryImpl.java
@@ -19,7 +19,7 @@
package org.apache.tuscany.sca.implementation.osgi.impl;
-import org.apache.tuscany.sca.implementation.osgi.BindingDescriptions;
+import org.apache.tuscany.sca.implementation.osgi.SCAConfig;
import org.apache.tuscany.sca.implementation.osgi.ServiceDescription;
import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptions;
import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory;
@@ -41,8 +41,8 @@ public class ServiceDescriptionsFactoryImpl implements ServiceDescriptionsFactor
return new ServiceDescriptionsImpl();
}
- public BindingDescriptions createBindingDescriptions() {
- return new BindingDescriptionsImpl();
+ public SCAConfig createSCAConfig() {
+ return new SCAConfigImpl();
}
}
diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/BindingDescriptionsProcessor.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/BindingDescriptionsProcessor.java
deleted file mode 100644
index ac05218fdf..0000000000
--- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/BindingDescriptionsProcessor.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * 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 javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
-
-import org.apache.tuscany.sca.assembly.Binding;
-import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
-import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
-import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
-import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
-import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
-import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.implementation.osgi.BindingDescriptions;
-import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory;
-
-/*
-<?xml version="1.0" encoding="UTF-8"?>
-<bindings xmlns="http://www.osgi.org/xmlns/sd/v1.0.0" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903">
- <binding.ws/>
- <binding.sca/>
-</bindings>
-*/
-public class BindingDescriptionsProcessor implements StAXArtifactProcessor<BindingDescriptions> {
- private StAXArtifactProcessor processor;
- private ServiceDescriptionsFactory factory;
-
- public BindingDescriptionsProcessor(ExtensionPointRegistry registry,
- StAXArtifactProcessor processor) {
- this.processor = processor;
- this.factory =
- registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(ServiceDescriptionsFactory.class);
- }
-
- public BindingDescriptions read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
- BindingDescriptions bindings = factory.createBindingDescriptions();
- boolean exit = false;
- while (!exit) {
- int event = reader.getEventType();
- switch (event) {
- case XMLStreamConstants.START_ELEMENT:
- QName name = reader.getName();
- if (!"bindings".equals(name.getLocalPart())) {
- Object element = null;
- try {
- element = processor.read(reader, context);
- } catch (ContributionReadException e) {
- throw e;
- }
- if (element instanceof Binding) {
- bindings.add((Binding)element);
- }
- }
- break;
- case XMLStreamConstants.END_ELEMENT:
- name = reader.getName();
- if ("bindings".equals(name.getLocalPart())) {
- exit = true;
- }
- break;
- }
- if (reader.hasNext()) {
- reader.next();
- } else {
- exit = true;
- }
- }
- return bindings;
- }
-
- public QName getArtifactType() {
- return BindingDescriptions.BINDINGS_QNAME;
- }
-
- public void write(BindingDescriptions model, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
- XMLStreamException {
- writer.writeStartElement(BindingDescriptions.OSGI_SD_NS, "bindings");
- for (Binding binding : model) {
- processor.write(model, writer, context);
- }
- writer.writeEndElement();
- }
-
- public Class<BindingDescriptions> getModelType() {
- return BindingDescriptions.class;
- }
-
- public void resolve(BindingDescriptions model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
- // TODO: To be implemented
- }
-}
diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/SCAConfigProcessor.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/SCAConfigProcessor.java
new file mode 100644
index 0000000000..9c529eecfc
--- /dev/null
+++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/SCAConfigProcessor.java
@@ -0,0 +1,190 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.osgi.SCAConfig;
+import org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/*
+<?xml version="1.0" encoding="UTF-8"?>
+<scact:sca-config targetNamespace="http://www.foocorp.com/definitions"
+ xmlns:scact="http://www.osgi.org/xmlns/scact/v1.0.0"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:foocorp="http://www.foocorp.com/definitions"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.osgi.org/xmlns/scact/v1.0.0 http://www.osgi.org/xmlns/scact/v1.0.0/sca-config.xsd">
+
+ <sca:binding.ws name="com.foocorp.FooOrderWebServiceBinding"
+ uri="http://www.foocorp.com/FooOrderService" requires="sca:soap.1_2" />
+ <foocorp:binding.rmi name="com.foocorp.FooOrderRMIBinding"
+ host="www.foocorp.com" port="8099" serviceName="FooOrderService" />
+</scact:sca-config>
+*/
+public class SCAConfigProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<SCAConfig> {
+ private static final QName SCA_CONFIG_QNAME = new QName("http://www.osgi.org/xmlns/scact/v1.0.0", "sca-config");
+ private ServiceDescriptionsFactory factory;
+ private StAXArtifactProcessor processor;
+
+ public SCAConfigProcessor(ExtensionPointRegistry registry, StAXArtifactProcessor processor) {
+ this.processor = processor;
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.factory = modelFactories.getFactory(ServiceDescriptionsFactory.class);
+ }
+
+ public SCAConfig read(XMLStreamReader reader, ProcessorContext context) throws XMLStreamException,
+ ContributionReadException {
+ int event = reader.getEventType();
+ SCAConfig definitions = factory.createSCAConfig();
+ String targetNamespace = null;
+ while (true) {
+ switch (event) {
+ case XMLStreamConstants.START_ELEMENT:
+ QName name = reader.getName();
+ if (SCA_CONFIG_QNAME.equals(name)) {
+ targetNamespace = reader.getAttributeValue(null, "targetNamespace");
+ definitions.setTargetNamespace(targetNamespace);
+ } else {
+ Object extension = processor.read(reader, context);
+ if (extension != null) {
+ if (extension instanceof Intent) {
+ Intent intent = (Intent)extension;
+ intent.setName(new QName(targetNamespace, intent.getName().getLocalPart()));
+ definitions.getIntents().add(intent);
+ for (Intent i : intent.getQualifiedIntents()) {
+ i.setName(new QName(targetNamespace, i.getName().getLocalPart()));
+ }
+ } else if (extension instanceof PolicySet) {
+ PolicySet policySet = (PolicySet)extension;
+ policySet.setName(new QName(targetNamespace, policySet.getName().getLocalPart()));
+ definitions.getPolicySets().add(policySet);
+ } else if (extension instanceof Binding) {
+ Binding binding = (Binding)extension;
+ definitions.getBindings().add(binding);
+ }
+ }
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ name = reader.getName();
+ if (SCA_CONFIG_QNAME.equals(name)) {
+ return definitions;
+ }
+ break;
+ }
+ if (reader.hasNext()) {
+ event = reader.next();
+ } else {
+ return definitions;
+ }
+ }
+ }
+
+ public QName getArtifactType() {
+ return SCA_CONFIG_QNAME;
+ }
+
+ public void write(SCAConfig definitions, XMLStreamWriter writer, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+
+ writeStartDocument(writer,
+ SCA_CONFIG_QNAME.getNamespaceURI(),
+ SCA_CONFIG_QNAME.getLocalPart(),
+ new XAttr("targetNamespace", definitions.getTargetNamespace()));
+
+ for (Intent policyIntent : definitions.getIntents()) {
+ processor.write(policyIntent, writer, context);
+ }
+
+ for (PolicySet policySet : definitions.getPolicySets()) {
+ processor.write(policySet, writer, context);
+ }
+
+ writeEndDocument(writer);
+ }
+
+ public void resolve(SCAConfig scaDefns, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException {
+ // start by adding all of the top level artifacts into the resolver as there
+ // are many cross artifact references in a definitions file and we don't want
+ // to be dependent on the order things appear
+
+ List<Intent> intents = new ArrayList<Intent>();
+ List<PolicySet> policySets = new ArrayList<PolicySet>();
+ List<PolicySet> referredPolicySets = new ArrayList<PolicySet>();
+
+ for (Intent intent : scaDefns.getIntents()) {
+ intents.add(intent);
+ resolver.addModel(intent, context);
+ for (Intent i : intent.getQualifiedIntents()) {
+ intents.add(i);
+ resolver.addModel(i, context);
+ }
+ }
+
+ for (PolicySet policySet : scaDefns.getPolicySets()) {
+ if (policySet.getReferencedPolicySets().isEmpty()) {
+ policySets.add(policySet);
+ } else {
+ referredPolicySets.add(policySet);
+ }
+
+ resolver.addModel(policySet, context);
+ }
+
+ // now resolve everything to ensure that any references between
+ // artifacts are satisfied
+
+ for (Intent policyIntent : intents)
+ processor.resolve(policyIntent, resolver, context);
+
+ for (PolicySet policySet : policySets)
+ processor.resolve(policySet, resolver, context);
+
+ for (PolicySet policySet : referredPolicySets)
+ processor.resolve(policySet, resolver, context);
+
+ }
+
+ public Class<SCAConfig> getModelType() {
+ return SCAConfig.class;
+ }
+
+}
diff --git a/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
index 045159deae..cc5e78c4cf 100644
--- a/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
+++ b/java/sca/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -19,4 +19,4 @@
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.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.BindingDescriptionsProcessor;qname=http://www.osgi.org/xmlns/sd/v1.0.0#bindings,model=org.apache.tuscany.sca.implementation.osgi.BindingDescriptions \ No newline at end of file
+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 \ No newline at end of file