summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/implementation-node
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-05-11 22:34:11 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-05-11 22:34:11 +0000
commit9ffd76a9e84f4addb400367d9a2582dffff0d109 (patch)
treef3c76db9b63eaf3cbdaf204f991d73350c9f5bcc /java/sca/modules/implementation-node
parentb50da63b11e3e39f64b92c1e4e5b0c067df94927 (diff)
Add default impl and processor for the node configuration
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@773715 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/implementation-node')
-rw-r--r--java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/BindingConfiguration.java2
-rw-r--r--java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/ContributionConfiguration.java22
-rw-r--r--java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/DefaultNodeConfigurationFactory.java28
-rw-r--r--java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/DeploymentComposite.java29
-rw-r--r--java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java4
-rw-r--r--java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfigurationFactory.java16
-rw-r--r--java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/impl/BindingConfigurationImpl.java48
-rw-r--r--java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/impl/ContributionConfigurationImpl.java85
-rw-r--r--java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/impl/DeploymentCompositeImpl.java67
-rw-r--r--java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationFactoryImpl.java62
-rw-r--r--java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java63
-rw-r--r--java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java190
-rw-r--r--java/sca/modules/implementation-node/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml25
-rw-r--r--java/sca/modules/implementation-node/src/test/resources/org/apache/tuscany/sca/node/configuration/node2.xml5
14 files changed, 624 insertions, 22 deletions
diff --git a/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/BindingConfiguration.java b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/BindingConfiguration.java
index ecd6ec513f..489a3fd2e3 100644
--- a/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/BindingConfiguration.java
+++ b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/BindingConfiguration.java
@@ -34,7 +34,7 @@ public interface BindingConfiguration {
QName getBindingType();
/**
- *
+ * Set the type of the binding
* @param type
*/
void setBindingType(QName type);
diff --git a/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/ContributionConfiguration.java b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/ContributionConfiguration.java
index a408ae0716..7d75cb32ac 100644
--- a/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/ContributionConfiguration.java
+++ b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/ContributionConfiguration.java
@@ -19,6 +19,10 @@
package org.apache.tuscany.sca.node.configuration;
+import java.util.List;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+
/**
* Configuration for an SCA contribution used by the SCA node
*/
@@ -46,4 +50,22 @@ public interface ContributionConfiguration {
* @param location The location of the contribution
*/
void setLocation(String location);
+
+ /**
+ * Get the contribution
+ * @return
+ */
+ Contribution getContribution();
+
+ /**
+ * Set the contribution
+ * @param contribution
+ */
+ void setContribution(Contribution contribution);
+
+ /**
+ * Get the list of deployment composites that are attached to the contribution
+ * @return
+ */
+ List<DeploymentComposite> getDeploymentComposites();
}
diff --git a/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/DefaultNodeConfigurationFactory.java b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/DefaultNodeConfigurationFactory.java
new file mode 100644
index 0000000000..a14a4ac9eb
--- /dev/null
+++ b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/DefaultNodeConfigurationFactory.java
@@ -0,0 +1,28 @@
+/*
+ * 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.node.configuration;
+
+import org.apache.tuscany.sca.node.configuration.impl.NodeConfigurationFactoryImpl;
+
+/**
+ * Default NodeConfigurationFactory
+ */
+public class DefaultNodeConfigurationFactory extends NodeConfigurationFactoryImpl {
+}
diff --git a/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/DeploymentComposite.java b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/DeploymentComposite.java
index d94c70a759..09bf3ee0ef 100644
--- a/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/DeploymentComposite.java
+++ b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/DeploymentComposite.java
@@ -19,6 +19,9 @@
package org.apache.tuscany.sca.node.configuration;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+
/**
* Configuration for a deployment composite
*/
@@ -42,18 +45,34 @@ public interface DeploymentComposite {
*/
String getContent();
+ /**
+ * Set the XML content for the composite
+ * @param compositeXML
+ */
void setContent(String compositeXML);
/**
- * Get the URI of the owning contribution
+ * Get the composite
+ * @return
+ */
+ Composite getComposite();
+
+ /**
+ * Set the composite
+ * @param composite
+ */
+ void setComposite(Composite composite);
+
+ /**
+ * Get the contribution that this deployment composite is attached to
* @return
*/
- String getContributionURI();
+ Contribution getContribution();
/**
- * Set the URI of the owning contribution
- * @param contributionURI
+ * Set the contribution that this deployment composite is attached to
+ * @param contribution
*/
- void setContributionURI(String contributionURI);
+ void setContribution(Contribution contribution);
}
diff --git a/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java
index bd1d9aebb0..c546b1e412 100644
--- a/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java
+++ b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java
@@ -29,9 +29,9 @@ public interface NodeConfiguration {
void setDomainURI(String domainURI);
- DeploymentComposite getDeploymentComposite();
+ String getURI();
- void setDeploymentComposite(DeploymentComposite deploymentComposite);
+ void setURI(String uri);
List<ContributionConfiguration> getContributions();
diff --git a/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfigurationFactory.java b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfigurationFactory.java
index e20fef27c1..ca1afee923 100644
--- a/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfigurationFactory.java
+++ b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfigurationFactory.java
@@ -23,11 +23,27 @@ package org.apache.tuscany.sca.node.configuration;
* The factory to create java models related to the node configuration
*/
public interface NodeConfigurationFactory {
+ /**
+ * Create a new instance of NodeConfiguration
+ * @return
+ */
NodeConfiguration createNodeConfiguration();
+ /**
+ * Create a new instance of ContributionConfiguration
+ * @return
+ */
ContributionConfiguration createContributionConfiguration();
+ /**
+ * Create a new instance of BindingConfiguration
+ * @return
+ */
BindingConfiguration createBindingConfiguration();
+ /**
+ * Create a new instance of DeploymentComposite
+ * @return
+ */
DeploymentComposite createDeploymentComposite();
}
diff --git a/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/impl/BindingConfigurationImpl.java b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/impl/BindingConfigurationImpl.java
new file mode 100644
index 0000000000..eb5ac2915b
--- /dev/null
+++ b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/impl/BindingConfigurationImpl.java
@@ -0,0 +1,48 @@
+/*
+ * 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.node.configuration.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.node.configuration.BindingConfiguration;
+
+/**
+ *
+ */
+class BindingConfigurationImpl implements BindingConfiguration {
+ private QName type;
+ private List<String> baseURIs = new ArrayList<String>();
+
+ public List<String> getBaseURIs() {
+ return baseURIs;
+ }
+
+ public QName getBindingType() {
+ return type;
+ }
+
+ public void setBindingType(QName type) {
+ this.type = type;
+ }
+
+}
diff --git a/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/impl/ContributionConfigurationImpl.java b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/impl/ContributionConfigurationImpl.java
new file mode 100644
index 0000000000..1793a99cc1
--- /dev/null
+++ b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/impl/ContributionConfigurationImpl.java
@@ -0,0 +1,85 @@
+/*
+ * 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.node.configuration.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.node.configuration.ContributionConfiguration;
+import org.apache.tuscany.sca.node.configuration.DeploymentComposite;
+
+/**
+ * Configuration for an SCA contribution used by the SCA node
+ */
+class ContributionConfigurationImpl implements ContributionConfiguration {
+ private List<DeploymentComposite> deploymentComposites = new ArrayList<DeploymentComposite>();
+ private Contribution contribution;
+ private String uri;
+ private String location;
+
+ public Contribution getContribution() {
+ return contribution;
+ }
+
+ public void setContribution(Contribution contribution) {
+ this.contribution = contribution;
+ }
+
+ /**
+ * Get the URI of the contribution
+ * @return The URI of the contribution
+ */
+ public String getURI() {
+ return uri;
+ }
+
+ /**
+ * Set the URI of the contribution
+ * @param uri The URI of the contribution
+ */
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ /**
+ * Get the location of the contribution
+ * @return The location of the contribution
+ */
+ public String getLocation() {
+ return location;
+ }
+
+ /**
+ * Set the location of the contribution
+ * @param location The location of the contribution
+ */
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ /**
+ * Get the list of deployment composites that are attached to the contribution
+ * @return
+ */
+ public List<DeploymentComposite> getDeploymentComposites() {
+ return deploymentComposites;
+ }
+}
diff --git a/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/impl/DeploymentCompositeImpl.java b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/impl/DeploymentCompositeImpl.java
new file mode 100644
index 0000000000..7113ad0d36
--- /dev/null
+++ b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/impl/DeploymentCompositeImpl.java
@@ -0,0 +1,67 @@
+/*
+ * 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.node.configuration.impl;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.node.configuration.DeploymentComposite;
+
+/**
+ * Configuration for a deployment composite
+ */
+class DeploymentCompositeImpl implements DeploymentComposite {
+ private String location;
+ private String content;
+ private Composite composite;
+ private Contribution contribution;
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+ public Composite getComposite() {
+ return composite;
+ }
+
+ public void setComposite(Composite composite) {
+ this.composite = composite;
+ }
+
+ public Contribution getContribution() {
+ return contribution;
+ }
+
+ public void setContribution(Contribution contribution) {
+ this.contribution = contribution;
+ }
+
+}
diff --git a/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationFactoryImpl.java b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationFactoryImpl.java
new file mode 100644
index 0000000000..96ca3e6199
--- /dev/null
+++ b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationFactoryImpl.java
@@ -0,0 +1,62 @@
+/*
+ * 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.node.configuration.impl;
+
+import org.apache.tuscany.sca.node.configuration.BindingConfiguration;
+import org.apache.tuscany.sca.node.configuration.ContributionConfiguration;
+import org.apache.tuscany.sca.node.configuration.DeploymentComposite;
+import org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory;
+
+/**
+ * The factory to create java models related to the node configuration
+ */
+public abstract class NodeConfigurationFactoryImpl implements NodeConfigurationFactory {
+ /**
+ * Create a new instance of NodeConfiguration
+ * @return
+ */
+ public NodeConfigurationImpl createNodeConfiguration() {
+ return new NodeConfigurationImpl();
+ }
+
+ /**
+ * Create a new instance of ContributionConfiguration
+ * @return
+ */
+ public ContributionConfiguration createContributionConfiguration() {
+ return new ContributionConfigurationImpl();
+ }
+
+ /**
+ * Create a new instance of BindingConfiguration
+ * @return
+ */
+ public BindingConfiguration createBindingConfiguration() {
+ return new BindingConfigurationImpl();
+ }
+
+ /**
+ * Create a new instance of DeploymentComposite
+ * @return
+ */
+ public DeploymentComposite createDeploymentComposite() {
+ return new DeploymentCompositeImpl();
+ }
+}
diff --git a/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java
new file mode 100644
index 0000000000..4f13959ced
--- /dev/null
+++ b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java
@@ -0,0 +1,63 @@
+/*
+ * 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.node.configuration.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.node.configuration.BindingConfiguration;
+import org.apache.tuscany.sca.node.configuration.ContributionConfiguration;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+
+/**
+ *
+ */
+class NodeConfigurationImpl implements NodeConfiguration {
+ private String uri;
+ private String domainURI;
+ private List<ContributionConfiguration> contributions = new ArrayList<ContributionConfiguration>();
+ private List<BindingConfiguration> bindings = new ArrayList<BindingConfiguration>();
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public String getDomainURI() {
+ return domainURI;
+ }
+
+ public void setDomainURI(String domainURI) {
+ this.domainURI = domainURI;
+ }
+
+ public List<ContributionConfiguration> getContributions() {
+ return contributions;
+ }
+
+ public List<BindingConfiguration> getBindings() {
+ return bindings;
+ }
+
+
+}
diff --git a/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java
new file mode 100644
index 0000000000..1d79062c0d
--- /dev/null
+++ b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.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.node.configuration.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+
+import java.util.StringTokenizer;
+
+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.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Composite;
+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.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.node.configuration.BindingConfiguration;
+import org.apache.tuscany.sca.node.configuration.ContributionConfiguration;
+import org.apache.tuscany.sca.node.configuration.DeploymentComposite;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory;
+
+/**
+ * Implements a StAX artifact processor for node implementations.
+ *
+ * @version $Rev: 750323 $ $Date: 2009-03-04 21:52:01 -0800 (Wed, 04 Mar 2009) $
+ */
+public class NodeConfigurationProcessor extends BaseStAXArtifactProcessor implements
+ StAXArtifactProcessor<NodeConfiguration> {
+ private static final String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+ private static final QName NODE = new QName(SCA11_TUSCANY_NS, "node");
+ private static final QName CONTRIBUTION = new QName(SCA11_TUSCANY_NS, "contribution");
+ private static final QName BINDING = new QName(SCA11_TUSCANY_NS, "binding");
+ private static final QName DEPLOYMENT_COMPOSITE = new QName(SCA11_TUSCANY_NS, "deploymentComposite");
+
+ private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903";
+ private static final QName COMPOSITE = new QName(SCA11_NS, "composite");
+
+ private StAXArtifactProcessor processor;
+ private AssemblyFactory assemblyFactory;
+ private NodeConfigurationFactory nodeConfigurationFactory;
+
+ public NodeConfigurationProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor processor,
+ Monitor monitor) {
+ this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ this.nodeConfigurationFactory = modelFactories.getFactory(NodeConfigurationFactory.class);
+ this.processor = processor;
+ }
+
+ public QName getArtifactType() {
+ // Returns the QName of the XML element processed by this processor
+ return NODE;
+ }
+
+ public Class<NodeConfiguration> getModelType() {
+ // Returns the type of model processed by this processor
+ return NodeConfiguration.class;
+ }
+
+ public NodeConfiguration read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+
+ NodeConfiguration node = null;
+ ContributionConfiguration contribution = null;
+ DeploymentComposite composite = null;
+
+ // Skip to end element
+ while (true) {
+ int event = reader.getEventType();
+ switch (event) {
+ case XMLStreamConstants.START_ELEMENT:
+ QName name = reader.getName();
+ if (NODE.equals(name)) {
+ node = nodeConfigurationFactory.createNodeConfiguration();
+ node.setURI(reader.getAttributeValue(null, "uri"));
+ node.setDomainURI(reader.getAttributeValue(null, "domain"));
+ } else if (CONTRIBUTION.equals(name)) {
+ contribution = nodeConfigurationFactory.createContributionConfiguration();
+ contribution.setURI(reader.getAttributeValue(null, "uri"));
+ contribution.setLocation(reader.getAttributeValue(null, "location"));
+ node.getContributions().add(contribution);
+ } else if (BINDING.equals(name)) {
+ BindingConfiguration binding = nodeConfigurationFactory.createBindingConfiguration();
+ binding.setBindingType(getQName(reader, "name"));
+ String baseURIs = reader.getAttributeValue(null, "baseURIs");
+ if (baseURIs != null) {
+ StringTokenizer tokenizer = new StringTokenizer(baseURIs);
+ while (tokenizer.hasMoreTokens()) {
+ binding.getBaseURIs().add(tokenizer.nextToken());
+ }
+ }
+ node.getBindings().add(binding);
+ } else if (DEPLOYMENT_COMPOSITE.equals(name)) {
+ composite = nodeConfigurationFactory.createDeploymentComposite();
+ composite.setLocation(reader.getAttributeValue(null, "location"));
+ if (contribution != null) {
+ contribution.getDeploymentComposites().add(composite);
+ }
+ } else if (COMPOSITE.equals(name)) {
+ Object model = processor.read(reader);
+ if (model instanceof Composite) {
+ composite.setComposite((Composite)model);
+ }
+ }
+ break;
+
+ case END_ELEMENT:
+ name = reader.getName();
+ if (NODE.equals(name)) {
+ return node;
+ } else if (CONTRIBUTION.equals(name)) {
+ contribution = null;
+ }
+ }
+ if (reader.hasNext()) {
+ reader.next();
+ } else {
+ break;
+ }
+ }
+
+ return node;
+ }
+
+ public void resolve(NodeConfiguration node, ModelResolver resolver) throws ContributionResolveException {
+ }
+
+ public void write(NodeConfiguration node, XMLStreamWriter writer) throws ContributionWriteException,
+ XMLStreamException {
+
+ writeStart(writer,
+ NODE.getNamespaceURI(),
+ NODE.getLocalPart(),
+ new XAttr("uri", node.getURI()),
+ new XAttr("domain", node.getDomainURI()));
+
+ for (ContributionConfiguration c : node.getContributions()) {
+ writeStart(writer,
+ CONTRIBUTION.getNamespaceURI(),
+ CONTRIBUTION.getLocalPart(),
+ new XAttr("uri", c.getURI()),
+ new XAttr("location", c.getLocation()));
+ writeEnd(writer);
+ }
+
+ for (BindingConfiguration b : node.getBindings()) {
+ StringBuffer uris = new StringBuffer();
+ for (String uri : b.getBaseURIs()) {
+ uris.append(uri).append(' ');
+ }
+ if (uris.length() > 0) {
+ uris.deleteCharAt(uris.length() - 1); // Remove the trailing space
+ } else {
+ uris = null;
+ }
+ writeStart(writer,
+ BINDING.getNamespaceURI(),
+ BINDING.getLocalPart(),
+ new XAttr("name", b.getBindingType()),
+ new XAttr("baseURIs", uris.toString()));
+ writeEnd(writer);
+ }
+
+ writeEnd(writer);
+ }
+}
diff --git a/java/sca/modules/implementation-node/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml b/java/sca/modules/implementation-node/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml
index e96749286d..e4d7925efe 100644
--- a/java/sca/modules/implementation-node/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml
+++ b/java/sca/modules/implementation-node/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml
@@ -20,19 +20,9 @@
<node xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
xmlns="http://tuscany.apache.org/xmlns/sca/1.1"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
- targetNamespace="http://sample/node"
- name="TestNode1"
+ uri="http://sample/nodes/TestNode1"
domain="http://domain1">
- <!-- The deployment composite is optional -->
- <!-- The deployment composite can be defined inline or referenced using a URI -->
- <!-- Should we make it a child of contribution element? -->
- <!-- Can we have more than one deployment composites -->
- <deploymentComposite contribution="http://c2" location="test/Test.composite">
- <sca:composite>
- </sca:composite>
- </deploymentComposite>
-
<!-- Configure the base URIs for a given binding -->
<!-- Each base URI is for a protocol supported by the binding -->
<binding name="sca:binding.ws" baseURIs="http://localhost:8080/ws https://localhost:8081/ws"/>
@@ -40,6 +30,17 @@
<!-- Configure a list of contributions -->
<contribution uri="http://c1" location="file:///a.jar"/>
- <contribution uri="http://c2" location="http://locahost/repo/b.jar"/>
+ <contribution uri="http://c2" location="http://locahost/repo/b.jar">
+ <!-- The deployment composite is optional -->
+ <!-- The deployment composite can be defined inline or referenced using a URI -->
+ <!-- Can we have more than one deployment composites -->
+ <deploymentComposite>
+ <sca:composite>
+ </sca:composite>
+ </deploymentComposite>
+ </contribution>
<contribution uri="http://c3" location="http://locahost/repo/c.jar"/>
+ <deploymentComposite location="test/Test.composite">
+ </deploymentComposite>
+ </contribution>
</node> \ No newline at end of file
diff --git a/java/sca/modules/implementation-node/src/test/resources/org/apache/tuscany/sca/node/configuration/node2.xml b/java/sca/modules/implementation-node/src/test/resources/org/apache/tuscany/sca/node/configuration/node2.xml
index 0f5578c8b4..d8781f1b8c 100644
--- a/java/sca/modules/implementation-node/src/test/resources/org/apache/tuscany/sca/node/configuration/node2.xml
+++ b/java/sca/modules/implementation-node/src/test/resources/org/apache/tuscany/sca/node/configuration/node2.xml
@@ -23,10 +23,11 @@
targetNamespace="http://sample/node"
name="TestNode2"
domain="http://domain1">
- <deploymentComposite contribution="http://c1" location="test/Test.composite"/>
<binding name="sca:binding.ws" baseURIs="http://localhost:8080/ws https://localhost:8081/ws"/>
<binding name="tuscany:binding.rmi" baseURIs="rmi://localhost:8080/rmi"/>
- <contribution uri="http://c1" location="file:///a.jar"/>
+ <contribution uri="http://c1" location="file:///a.jar">
+ <deploymentComposite location="test/Test.composite"/>
+ </contribution>
<contribution uri="http://c4" location="http://locahost/repo/d.jar"/>
</node> \ No newline at end of file