diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-05-21 07:11:35 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-05-21 07:11:35 +0000 |
commit | 8ee0725aa706eaa4f30316bcbd010365f455a32f (patch) | |
tree | 25beae4a5eed0daaf596545e9d959fbb3da2644a /sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany | |
parent | 5d0c1a742830af6063d2899ad576284028f4e581 (diff) |
Add start of a basic impl using Node to install contributions. Not much works yet but the helloworld type testcase does run
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@946913 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany')
3 files changed, 231 insertions, 1 deletions
diff --git a/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/Section10.java b/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/Section10.java index 625918646e..85a7d1491c 100644 --- a/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/Section10.java +++ b/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/Section10.java @@ -83,7 +83,8 @@ public interface Section10 { * 4595 [ASM12009]
* 4596 Note that in many cases, the dependent contribution list can be generated. In particular, if the creator of
* 4597 a Domain is careful to avoid creating duplicate definitions for the same qualified name, then it is easy for
- * 4598 this list to be generated by tooling. *
+ * 4598 this list to be generated by tooling.
+ *
* @param uri
* @param contributionURL
*/
diff --git a/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/Section10Factory.java b/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/Section10Factory.java new file mode 100644 index 0000000000..5824e5e494 --- /dev/null +++ b/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/Section10Factory.java @@ -0,0 +1,38 @@ +/*
+ * 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.something;
+
+import java.util.Properties;
+
+import org.apache.tuscany.sca.something.impl.Section10Impl;
+
+public class Section10Factory {
+
+ public static Section10 createSection10() {
+ Properties defaultConfig = new Properties();
+ defaultConfig.setProperty("defaultScheme", "vm");
+ defaultConfig.setProperty("defaultDomainName", "default");
+ return new Section10Impl(defaultConfig);
+ }
+
+ public static Section10 createSection10(Properties config) {
+ return new Section10Impl(config);
+ }
+}
diff --git a/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/Section10Impl.java b/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/Section10Impl.java new file mode 100644 index 0000000000..7d7e6d902c --- /dev/null +++ b/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/Section10Impl.java @@ -0,0 +1,191 @@ +/*
+ * 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.something.impl;
+
+import java.io.Reader;
+import java.net.URI;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.apache.tuscany.sca.node.impl.NodeFactoryImpl;
+import org.apache.tuscany.sca.node.impl.NodeImpl;
+import org.apache.tuscany.sca.something.Section10;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.client.SCAClientFactory;
+import org.w3c.dom.Document;
+
+public class Section10Impl implements Section10 {
+
+ private NodeFactory nodeFactory;
+ private Map<String, Node> installedContributions = new HashMap<String, Node>();
+
+ public Section10Impl(Properties config) {
+ this.nodeFactory = NodeFactory.newInstance(config);
+ ((NodeFactoryImpl)nodeFactory).start();
+ }
+
+ public String addDeploymentComposite(String contriubutionURI, String compositeXML) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String addDeploymentComposite(String contriubutionURI, Reader compositeXML) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void addToDomainLevelComposite(String compositeURI) {
+ String contributionURI = getContributionUriFromArtifactUri(compositeURI);
+ String artifactURI = compositeURI.substring(contributionURI.length()+1);
+ // TODO: now what? there doesn't appear to be any way yet to do this with the exsiting Node API
+ }
+
+ protected String getContributionUriFromArtifactUri(String artifactURI) {
+ String contributionURI = null;
+ for (String uri : installedContributions.keySet()) {
+ if (artifactURI.startsWith(uri)) {
+ contributionURI = uri;
+ break;
+ }
+ }
+ if (contributionURI == null) {
+ throw new IllegalArgumentException("no contribution found for: " + artifactURI);
+ }
+ return contributionURI;
+ }
+
+ public void deployContribution(String contributionURI) {
+ // TODO Auto-generated method stub
+ }
+
+ public Document getDomainLevelComposite() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getDomainLevelCompositeAsString() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object getQNameDefinition(String contributionURI, QName definition, QName symbolSpace) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public SCAClientFactory getSCAClientFactory() {
+ try {
+ return SCAClientFactory.newInstance(URI.create(getDomainName()));
+ } catch (NoSuchDomainException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ private String getDomainName() {
+ // TODO Auto-generated method stub
+ return "default";
+ }
+
+ public void installContribution(String uri, String contributionURL, List<String> dependentContributionURIs) {
+ if (dependentContributionURIs == null) {
+ dependentContributionURIs = Collections.emptyList();
+ }
+ String[] cs = new String[dependentContributionURIs.size()+1];
+ cs[0] = contributionURL;
+ for (int i=1; i<dependentContributionURIs.size(); i++) {
+ cs[i] = getContributionURL(dependentContributionURIs.get(i));
+ }
+ Node node = nodeFactory.createNode((String)null, cs);
+ node.start();
+ installedContributions.put(uri, node);
+ }
+
+ protected String getContributionURL(String contributionURI) {
+ Node n = installedContributions.get(contributionURI);
+ if (n == null) {
+ throw new IllegalStateException("not installed: " + contributionURI);
+ }
+ NodeConfiguration c = ((NodeImpl)n).getConfiguration();
+ return c.getContributions().get(0).getLocation();
+ }
+
+ public String installContribution(String contributionURL) {
+ installContribution(contributionURL, contributionURL, null);
+ return contributionURL;
+ }
+
+ public void installContribution(String uri, String contributionURL) {
+ installContribution(uri, contributionURL, null);
+ }
+
+ public void removeContribution(String contributionURI) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void removeFromDomainLevelComposite(String compositeURI) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void shutdown() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void startComponent(String componentURI) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void stopComponent(String componentURI) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void undeployContribution(String contributionURI) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateContribution(String uri, String contributionURL) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public String updateDeploymentComposite(String uri, String compositeXML) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String updateDeploymentComposite(String uri, Reader compositeXML) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
|