summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache
diff options
context:
space:
mode:
Diffstat (limited to 'branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache')
-rw-r--r--branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/DomainManagerNodeImpl.java170
-rw-r--r--branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/DomainManagerServiceImpl.java118
-rw-r--r--branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/SCADomainFactoryImpl.java54
-rw-r--r--branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/SCADomainImpl.java662
-rw-r--r--branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/SCADomainUtil.java86
-rw-r--r--branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/management/impl/ContributionInfoImpl.java89
-rw-r--r--branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/management/impl/DomainInfoImpl.java99
-rw-r--r--branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/management/impl/NodeInfoImpl.java99
-rw-r--r--branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/CompositeImpl.java54
-rw-r--r--branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/ContributionImpl.java87
-rw-r--r--branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/DomainImpl.java94
-rw-r--r--branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/DomainModelFactoryImpl.java80
-rw-r--r--branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/NodeImpl.java93
-rw-r--r--branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/ServiceImpl.java89
14 files changed, 1874 insertions, 0 deletions
diff --git a/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/DomainManagerNodeImpl.java b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/DomainManagerNodeImpl.java
new file mode 100644
index 0000000000..d5a7cebf81
--- /dev/null
+++ b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/DomainManagerNodeImpl.java
@@ -0,0 +1,170 @@
+ /*
+ * 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.domain.impl;
+
+import java.net.URL;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.domain.DomainException;
+import org.apache.tuscany.sca.domain.SCADomain;
+import org.apache.tuscany.sca.domain.SCADomainSPI;
+import org.apache.tuscany.sca.domain.model.Domain;
+import org.apache.tuscany.sca.node.NodeException;
+import org.apache.tuscany.sca.node.SCANode;
+import org.osoa.sca.CallableReference;
+import org.osoa.sca.ServiceReference;
+
+/**
+ * A dummy representation of and SCA Node used simply to control the
+ * endpoint of a callable reference
+ * We can remove this if we change the runtime over to referencing the
+ * domain directly rather than going via the node.
+ *
+ * @version $Rev: 552343 $ $Date: 2007-09-09 23:54:46 +0100 (Sun, 09 Sep 2007) $
+ */
+public class DomainManagerNodeImpl implements SCANode {
+
+ private final static Logger logger = Logger.getLogger(DomainManagerNodeImpl.class.getName());
+
+ private String nodeEndpoint;
+ private SCADomain scaDomain = new DomainManagerDomainImpl();
+ private SCADomainSPI realSCADomain = null;
+
+ class DomainManagerDomainImpl implements SCADomainSPI {
+ public String addNode(String nodeURI, String nodeURL){
+ return null;
+ }
+
+ public String removeNode(String nodeURI){
+ return null;
+ }
+
+ public void registerContribution(String nodeURI, String contributionURI, String contributionURL) {
+ }
+
+ public void unregisterContribution(String contributionURI){
+ }
+
+ public String registerServiceEndpoint(String domainUri, String nodeUri, String serviceName, String bindingName, String URL){
+ return null;
+ }
+
+ public String removeServiceEndpoint(String domainUri, String nodeUri, String serviceName, String bindingName){
+ return null;
+ }
+
+ public String findServiceEndpoint(String domainUri, String serviceName, String bindingName){
+ if (nodeEndpoint != null){
+ return nodeEndpoint;
+ } else {
+ return realSCADomain.findServiceEndpoint(domainUri, serviceName, bindingName);
+ }
+
+ }
+
+ public Domain getDomainModel(){
+ return null;
+ }
+
+ // SCADomain API methods
+
+ public void start() throws DomainException {
+ }
+
+ public void stop() throws DomainException {
+ }
+
+ public String getURI(){
+ return null;
+ }
+
+ public void addContribution(String contributionURI, URL contributionURL) throws DomainException {
+ }
+
+ public void removeContribution(String uri) throws DomainException {
+ }
+
+ public void addDeploymentComposite(String contributionURI, String compositeXML) throws DomainException {
+ }
+
+ public void addToDomainLevelComposite(QName compositeQName) throws DomainException {
+ }
+
+ public void removeFromDomainLevelComposite(QName compositeQName) throws DomainException {
+ }
+
+ public void startComposite(QName compositeName) throws DomainException {
+ }
+
+ public void stopComposite(QName qname) throws DomainException {
+ }
+
+ public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException {
+
+ return null;
+ }
+
+ public <B> B getService(Class<B> businessInterface, String serviceName) {
+ return null;
+ }
+
+ public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String name) {
+ return null;
+ }
+
+ }
+
+ public DomainManagerNodeImpl(SCADomainSPI scaDomain) {
+ this.realSCADomain = scaDomain;
+ }
+
+ public void setNodeEndpoint(String nodeEndpoint) {
+ this.nodeEndpoint = nodeEndpoint;
+ }
+
+ // API methods
+
+ public void start() throws NodeException {
+ }
+
+ public void stop() throws NodeException {
+
+ }
+
+ public String getURI(){
+ return null;
+ }
+
+ public SCADomain getDomain(){
+ return scaDomain;
+ }
+
+ public void addContribution(String contributionURI, URL contributionURL) throws NodeException {
+ }
+
+
+ public void deployComposite(QName compositeName) throws NodeException {
+
+ }
+
+
+}
diff --git a/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/DomainManagerServiceImpl.java b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/DomainManagerServiceImpl.java
new file mode 100644
index 0000000000..b843bde72a
--- /dev/null
+++ b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/DomainManagerServiceImpl.java
@@ -0,0 +1,118 @@
+/*
+ * 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.domain.impl;
+
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.domain.DomainManagerInitService;
+import org.apache.tuscany.sca.domain.DomainManagerNodeEventService;
+import org.apache.tuscany.sca.domain.SCADomainSPI;
+import org.apache.tuscany.sca.domain.management.DomainInfo;
+import org.apache.tuscany.sca.domain.management.DomainManagementService;
+import org.apache.tuscany.sca.domain.management.NodeInfo;
+import org.apache.tuscany.sca.domain.management.impl.DomainInfoImpl;
+import org.apache.tuscany.sca.domain.management.impl.NodeInfoImpl;
+import org.apache.tuscany.sca.domain.model.Domain;
+import org.apache.tuscany.sca.domain.model.Node;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+
+/**
+ * Stores details of services exposed and retrieves details of remote services
+ *
+ * @version $Rev: 552343 $ $Date: 2007-09-07 12:41:52 +0100 (Fri, 07 Sep 2007) $
+ */
+@Scope("COMPOSITE")
+@Service(interfaces = {DomainManagerNodeEventService.class, DomainManagerInitService.class, DomainManagementService.class})
+public class DomainManagerServiceImpl implements DomainManagerNodeEventService, DomainManagerInitService, DomainManagementService {
+
+ private final static Logger logger = Logger.getLogger(DomainManagerServiceImpl.class.getName());
+
+ private SCADomainSPI scaDomain;
+
+ // DomainManagerInitService methods
+
+ public void setDomain(SCADomainSPI scaDomain) {
+ this.scaDomain = scaDomain;
+ }
+
+ // DomainManagerNodeEventService methods
+
+ public String registerNode(String nodeURI, String nodeURL){
+ return scaDomain.addNode(nodeURI, nodeURL);
+ }
+
+ public String removeNode(String nodeURI){
+ return scaDomain.removeNode(nodeURI);
+ }
+
+ public void registerContribution(String nodeURI, String contributionURI, String contributionURL) {
+ scaDomain.registerContribution(nodeURI, contributionURI, contributionURL);
+ }
+
+ public void unregisterContribution(String contributionURI){
+ scaDomain.unregisterContribution(contributionURI);
+ }
+
+ public String registerServiceEndpoint(String domainUri, String nodeUri, String serviceName, String bindingName, String URL){
+ return scaDomain.registerServiceEndpoint(domainUri, nodeUri, serviceName, bindingName, URL);
+ }
+
+ public String removeServiceEndpoint(String domainUri, String nodeUri, String serviceName, String bindingName){
+ return scaDomain.removeServiceEndpoint(domainUri, nodeUri, serviceName, bindingName);
+ }
+
+
+ public String findServiceEndpoint(String domainUri, String serviceName, String bindingName){
+ return scaDomain.findServiceEndpoint(domainUri, serviceName, bindingName);
+ }
+
+ // DomainManagementService methods
+
+ public DomainInfo getDomainDescription(){
+
+ DomainInfo domainInfo = new DomainInfoImpl();
+ Domain domain = scaDomain.getDomainModel();
+
+ domainInfo.setDomainURI(domain.getDomainURI());
+ domainInfo.setDomainURL(domain.getDomainURL());
+ domainInfo.getNodes().addAll(domain.getNodes().keySet());
+ domainInfo.getContributions().addAll(domain.getContributions().keySet());
+ domainInfo.getDeployedComposites().addAll(domain.getDeployedComposites().keySet());
+
+ return domainInfo;
+ }
+
+ public NodeInfo getNodeDescription(String nodeURI){
+
+ NodeInfo nodeInfo = new NodeInfoImpl();
+ Domain domain = scaDomain.getDomainModel();
+ Node node = domain.getNodes().get(nodeURI);
+
+ nodeInfo.setNodeURI(nodeURI);
+ nodeInfo.setNodeURL(node.getNodeURL());
+ nodeInfo.getContributions().addAll(node.getContributions().keySet());
+ nodeInfo.getDeployedComposites().addAll(node.getDeployedComposites().keySet());
+ nodeInfo.getServices().addAll(node.getServices().keySet());
+
+ return nodeInfo;
+ }
+}
diff --git a/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/SCADomainFactoryImpl.java b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/SCADomainFactoryImpl.java
new file mode 100644
index 0000000000..8f741d7ea9
--- /dev/null
+++ b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/SCADomainFactoryImpl.java
@@ -0,0 +1,54 @@
+/*
+ * 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.domain.impl;
+
+import org.apache.tuscany.sca.domain.DomainException;
+import org.apache.tuscany.sca.domain.SCADomain;
+import org.apache.tuscany.sca.domain.SCADomainFactory;
+
+/**
+ * A finder for SCA domains.
+ *
+ * @version $Rev: 580520 $ $Date: 2007-09-29 00:50:25 +0100 (Sat, 29 Sep 2007) $
+ */
+public class SCADomainFactoryImpl extends SCADomainFactory {
+
+
+ /**
+ * Returns a new SCA domain finder instance.
+ *
+ * @return a new SCA domain finder
+ */
+ public SCADomainFactoryImpl() {
+
+ }
+
+ /**
+ * Finds an existing SCA domain.
+ *
+ * @param domainURI the URI of the domain, this is the endpoint
+ * URI of the domain administration service
+ * @return the SCA domain
+ */
+ public SCADomain createSCADomain(String domainURI) throws DomainException {
+ return new SCADomainImpl(domainURI);
+ }
+
+}
diff --git a/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/SCADomainImpl.java b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/SCADomainImpl.java
new file mode 100644
index 0000000000..cdbc8f799c
--- /dev/null
+++ b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/SCADomainImpl.java
@@ -0,0 +1,662 @@
+ /*
+ * 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.domain.impl;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.DeployedArtifact;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.service.ContributionService;
+import org.apache.tuscany.sca.core.assembly.ActivationException;
+import org.apache.tuscany.sca.core.context.ServiceReferenceImpl;
+import org.apache.tuscany.sca.domain.DomainException;
+import org.apache.tuscany.sca.domain.DomainManagerInitService;
+import org.apache.tuscany.sca.domain.SCADomainSPI;
+import org.apache.tuscany.sca.domain.model.Domain;
+import org.apache.tuscany.sca.domain.model.DomainModelFactory;
+import org.apache.tuscany.sca.domain.model.Node;
+import org.apache.tuscany.sca.domain.model.Service;
+import org.apache.tuscany.sca.domain.model.impl.DomainModelFactoryImpl;
+import org.apache.tuscany.sca.host.embedded.impl.ReallySmallRuntime;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.node.NodeManagerService;
+import org.apache.tuscany.sca.node.NodeFactoryImpl;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentContext;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.osoa.sca.CallableReference;
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.ServiceRuntimeException;
+
+/**
+ * The SCA domain implementation. In Tuscany we currently have a model of the
+ * SCA Domain that relies on a central domain manager this class provides that
+ * central manager.
+ *
+ * @version $Rev: 552343 $ $Date: 2007-09-09 23:54:46 +0100 (Sun, 09 Sep 2007) $
+ */
+public class SCADomainImpl implements SCADomainSPI {
+
+ private final static Logger logger = Logger.getLogger(SCADomainImpl.class.getName());
+
+ // class loader used to get the runtime going
+ private ClassLoader domainClassLoader;
+
+ // management runtime
+ private ReallySmallRuntime domainManagementRuntime;
+ private ContributionService domainManagementContributionService;
+ private Composite domainManagementComposite;
+ private DomainManagerNodeImpl domainManagerNode;
+
+ // management services
+ private DomainManagerInitService domainManagerInitService;
+
+ // The domain model
+ private DomainModelFactory domainModelFactory = new DomainModelFactoryImpl();
+ private Domain domainModel;
+ private HashMap<String, Contribution> contributions = new HashMap<String, Contribution>();
+
+
+ /**
+ * Create a domain giving the URI for the domain.
+ *
+ * @param domainUri - identifies what host and port the domain service is running on, e.g. http://localhost:8081
+ * @throws ActivationException
+ */
+ public SCADomainImpl(String domainURI) throws DomainException {
+ this.domainModel = domainModelFactory.createDomain();
+ this.domainModel.setDomainURI(domainURI);
+ this.domainClassLoader = SCADomainImpl.class.getClassLoader();
+ init();
+ }
+
+ /**
+ * Create the domain management runtime etc
+ */
+ private void init() throws DomainException {
+ try {
+ // check whether domain uri is a url
+ URI tmpURI;
+ try {
+ tmpURI = new URI(domainModel.getDomainURI());
+ if (tmpURI.isAbsolute()){
+ domainModel.setDomainURL(tmpURI.toURL().toExternalForm());
+ }
+ } catch(Exception ex) {
+ throw new ActivationException("domain uri " +
+ domainModel.getDomainURI() +
+ "must be a valid url");
+ }
+
+ // create a runtime for the domain management services to run on
+ domainManagementRuntime = new ReallySmallRuntime(domainClassLoader);
+ domainManagementRuntime.start();
+
+ // Create an in-memory domain level management composite
+ AssemblyFactory assemblyFactory = domainManagementRuntime.getAssemblyFactory();
+ domainManagementComposite = assemblyFactory.createComposite();
+ domainManagementComposite.setName(new QName(Constants.SCA10_NS, "domainManagement"));
+ domainManagementComposite.setURI(domainModel.getDomainURI() + "/Management");
+
+ // Set up the domain so that we can push in the node endpoint before we
+ // call a node
+ domainManagerNode = new DomainManagerNodeImpl(this);
+ ModelFactoryExtensionPoint factories = domainManagementRuntime.getExtensionPointRegistry().getExtensionPoint(ModelFactoryExtensionPoint.class);
+ NodeFactoryImpl domainFactory = new NodeFactoryImpl(domainManagerNode);
+ factories.addFactory(domainFactory);
+
+ // Find the composite that will configure the domain
+ String domainCompositeName = "domain.composite";
+ URL contributionURL = SCADomainUtil.findContributionFromComposite(domainClassLoader, domainCompositeName);
+
+ if ( contributionURL != null ){
+ logger.log(Level.INFO, "Domain management configured from " + contributionURL);
+
+ // add node composite to the management domain
+ domainManagementContributionService = domainManagementRuntime.getContributionService();
+ Contribution contribution = null;
+
+ contribution = domainManagementContributionService.contribute(domainModel.getDomainURI(),
+ contributionURL,
+ false);
+
+ Composite composite = null;
+ for (DeployedArtifact artifact: contribution.getArtifacts()) {
+ if (domainCompositeName.equals(artifact.getURI())) {
+ composite = (Composite)artifact.getModel();
+ }
+ }
+
+ if (composite != null) {
+
+ domainManagementComposite.getIncludes().add(composite);
+ domainManagementRuntime.getCompositeBuilder().build(composite);
+
+ // TODO fix up the domain manager URI to match the provided
+ // domain uri
+
+ domainManagementRuntime.getCompositeActivator().activate(composite);
+ domainManagementRuntime.getCompositeActivator().start(composite);
+
+ // get the management components out of the domain so that they
+ // can be configured/used.
+ domainManagerInitService = getService(DomainManagerInitService.class,
+ "DomainManagerComponent/DomainManagerInitService",
+ domainManagementRuntime,
+ domainManagementComposite);
+ domainManagerInitService.setDomain((SCADomainSPI)this);
+
+
+ } else {
+ throw new ActivationException("Domain management contribution " +
+ contributionURL +
+ " found but could not be loaded");
+ }
+ } else {
+ throw new ActivationException("Domain management contribution " +
+ domainCompositeName +
+ " not found on the classpath");
+ }
+
+ } catch(Exception ex) {
+ throw new DomainException(ex);
+ }
+ }
+
+ public Component getComponent(String componentName) {
+ for (Composite composite: domainManagementComposite.getIncludes()) {
+ for (Component component: composite.getComponents()) {
+ if (component.getName().equals(componentName)) {
+ return component;
+ }
+ }
+ }
+ return null;
+ }
+
+ // SCADomain SPI methods
+
+ public Domain getDomainModel(){
+ return domainModel;
+ }
+
+ public String addNode(String nodeURI, String nodeURL){
+ // try and remove it first just in case it's already registered
+ removeNode(nodeURI);
+
+ Node node = domainModelFactory.createNode();
+ node.setNodeURI(nodeURI);
+ node.setNodeURL(nodeURL);
+ domainModel.getNodes().put(nodeURI, node);
+
+ logger.log(Level.INFO, "Registered node: " +
+ nodeURI +
+ " at endpoint " +
+ nodeURL);
+
+ return "DummyReturn";
+ }
+
+ public String removeNode(String nodeURI){
+
+ domainModel.getNodes().remove(nodeURI);
+
+ logger.log(Level.INFO, "Removed node: " + nodeURI);
+
+ return "DummyReturn";
+ }
+
+
+ public void registerContribution(String nodeURI, String contributionURI, String contributionURL){
+ try {
+ if ( domainModel.getContributions().containsKey(contributionURI) == false ){
+ // add the contribution information to the domain model
+ org.apache.tuscany.sca.domain.model.Contribution contributionModel =
+ parseContribution(contributionURI, contributionURL);
+ }
+
+
+ // assign the contribution to the referenced node
+ } catch (Exception ex) {
+ logger.log(Level.SEVERE, "Exception when registering contribution " +
+ contributionURI +
+ ex.toString() );
+ }
+
+ }
+
+
+ public void unregisterContribution(String contributionURI){
+ // TODO
+
+ }
+
+ public String registerServiceEndpoint(String domainURI, String nodeURI, String serviceName, String bindingName, String URL){
+ // if the service name ends in a "/" remove it
+ String modifiedServiceName = null;
+ if ( serviceName.endsWith("/") ) {
+ modifiedServiceName = serviceName.substring(0, serviceName.length() - 1);
+ } else {
+ modifiedServiceName = serviceName;
+ }
+
+ // collect the service info
+ Service service = domainModelFactory.createService();
+ service.setServiceURI(modifiedServiceName);
+ service.setServiceURL(URL);
+ service.setServiceBinding(bindingName);
+
+ // find the node
+ Node node = domainModel.getNodes().get(nodeURI);
+
+ if (node != null){
+ //store the service
+ node.getServices().put(serviceName+bindingName, service);
+ logger.log(Level.INFO, "Registered service: " + modifiedServiceName);
+ } else {
+ logger.log(Level.WARNING, "Trying to register service: " +
+ modifiedServiceName +
+ " for a node " +
+ nodeURI +
+ "that isn't registered");
+ }
+
+ return "";
+ }
+
+ public String removeServiceEndpoint(String domainUri, String nodeURI, String serviceName, String bindingName){
+ Node node = domainModel.getNodes().get(nodeURI);
+ node.getServices().remove(serviceName + bindingName);
+ logger.log(Level.INFO, "Removed service: " + serviceName );
+
+ return "";
+ }
+
+ public String findServiceEndpoint(String domainUri, String serviceName, String bindingName){
+ logger.log(Level.INFO, "Finding service: [" +
+ domainUri + " " +
+ serviceName + " " +
+ bindingName +
+ "]");
+
+ String url = "";
+ String serviceKey = serviceName + bindingName;
+
+ for (Node node : domainModel.getNodes().values()){
+ Service service = node.getServices().get(serviceKey);
+
+ if (service != null){
+ url = service.getServiceURL();
+ //url = replacePort(url, "8085", "8086");
+ logger.log(Level.INFO, "Found service url: " + url);
+ break;
+ }
+ }
+
+ return url;
+ }
+
+ /**
+ * Converts a port number to something else to allow for debugging using a
+ * HTTP sniffer
+ * @param url
+ * @param fromPort the port to look for
+ * @param toPort the port to replace it with
+ * @return the new url
+ */
+ private String replacePort(String url, String fromPort, String toPort) {
+ return url.replace(fromPort, toPort);
+ }
+
+
+ // SCADomain API methods
+
+ public void start() throws DomainException {
+ // TODO
+ }
+
+
+ public void stop() throws DomainException {
+ try {
+ // Stop the node
+ domainManagementRuntime.stop();
+
+ } catch(ActivationException ex) {
+ throw new DomainException(ex);
+ }
+
+ }
+
+ public String getURI(){
+ return domainModel.getDomainURI();
+ }
+
+ private org.apache.tuscany.sca.domain.model.Contribution parseContribution(String contributionURI, String contributionURL) throws DomainException {
+ // add the contribution information to the domain model
+ org.apache.tuscany.sca.domain.model.Contribution contributionModel = domainModelFactory.createContribution();
+ contributionModel.setContributionURI(contributionURI);
+ contributionModel.setContributionURL(contributionURL);
+ domainModel.getContributions().put(contributionURI, contributionModel);
+
+ // read the assembly model objects.
+ try {
+ // Create a local model from the contribution. Using the contribution
+ // processor from the domain management runtime just because we already have it
+ Contribution contribution = domainManagementContributionService.contribute(contributionURI,
+ new URL(contributionURL),
+ false);
+
+ // store the contribution
+ contributions.put(contributionURI, contribution);
+
+ // add the composite info to the domain model
+ for (DeployedArtifact artifact : contribution.getArtifacts()) {
+ if (artifact.getModel() instanceof Composite) {
+ Composite composite = (Composite)artifact.getModel();
+ org.apache.tuscany.sca.domain.model.Composite compositeModel =
+ domainModelFactory.createComposite();
+ compositeModel.setCompositeQName(composite.getName());
+ contributionModel.getComposites().put(compositeModel.getCompositeQName(), compositeModel);
+
+ }
+ }
+
+ // add all composites into the domain model
+ for (Composite composite : contribution.getDeployables()) {
+ org.apache.tuscany.sca.domain.model.Composite compositeModel =
+ domainModelFactory.createComposite();
+ compositeModel.setCompositeQName(composite.getName());
+ contributionModel.getComposites().put(compositeModel.getCompositeQName(), compositeModel);
+ }
+
+ // add the deployable composite info to the domain model
+ for (Composite composite : contribution.getDeployables()) {
+ org.apache.tuscany.sca.domain.model.Composite compositeModel =
+ contributionModel.getComposites().get(composite.getName());
+ contributionModel.getDeployableComposites().put(compositeModel.getCompositeQName(), compositeModel);
+ domainModel.getDeployedComposites().put(compositeModel.getCompositeQName(), compositeModel);
+ }
+
+ } catch(Exception ex) {
+ throw new DomainException(ex);
+ }
+
+ return contributionModel;
+ }
+
+ private void assignContributionToNode(org.apache.tuscany.sca.domain.model.Contribution contributionModel) throws DomainException {
+ // Find a node to run the contribution.
+ // TODO - add some more sophisticated algorithm here
+ // find a node without a contribution and add it to it. There is no deployment
+ // step here we just assume the contribution is available.
+
+ boolean foundFreeNode = false;
+
+ for(Node node : domainModel.getNodes().values()) {
+ if ( node.getContributions().isEmpty()){
+ foundFreeNode = true;
+ node.getContributions().put(contributionModel.getContributionURI(), contributionModel);
+ break;
+ }
+ }
+
+ if (foundFreeNode == false){
+ throw new DomainException("No free node available for contribution " +
+ contributionModel.getContributionURI());
+ }
+ }
+
+ public void addContribution(String contributionURI, URL contributionURL) throws DomainException {
+ // add the contribution information to the domain model
+ org.apache.tuscany.sca.domain.model.Contribution contributionModel =
+ parseContribution(contributionURI, contributionURL.toExternalForm());
+
+ assignContributionToNode(contributionModel);
+ }
+
+ public void removeContribution(String uri) throws DomainException {
+
+ // TODO
+ }
+
+ public void addDeploymentComposite(String contributionURI, String compositeXML) throws DomainException {
+ // TODO
+ }
+
+ public void addToDomainLevelComposite(QName compositeName) throws DomainException {
+ // find the nodes with this composite and add the composite as a deployable composite
+ for ( Node node : domainModel.getNodes().values()) {
+ for (org.apache.tuscany.sca.domain.model.Contribution contribution : node.getContributions().values()){
+ org.apache.tuscany.sca.domain.model.Composite composite =
+ contribution.getComposites().get(compositeName);
+ if (composite != null) {
+ contribution.getDeployableComposites().put(compositeName, composite);
+ domainModel.getDeployedComposites().put(compositeName, composite);
+ }
+ }
+ }
+ }
+
+ public void removeFromDomainLevelComposite(QName qname) throws DomainException {
+ // TODO
+ }
+
+ public void startComposite(QName compositeName) throws DomainException {
+ for (Node node : domainModel.getNodes().values()){
+ boolean startNode = false;
+
+ for (org.apache.tuscany.sca.domain.model.Contribution contribution : node.getContributions().values()){
+ org.apache.tuscany.sca.domain.model.Composite composite =
+ contribution.getDeployableComposites().get(compositeName);
+ if (composite != null) {
+ startNode = true;
+ break;
+ }
+ }
+
+ if (startNode == true){
+ // get the endpoint of the node in question and set it into the
+ // domain manager node in order to flip the node reference to
+ // the correct endpoint
+ String nodeURL = node.getNodeURL();
+ domainManagerNode.setNodeEndpoint(nodeURL);
+
+
+ // get a node manager service reference. This will have to have its
+ // physical endpoint set by the domain node manage we have just
+ // configured
+ NodeManagerService nodeManagerService = getService(NodeManagerService.class,
+ "NodeManagerComponent/NodeManagerService",
+ domainManagementRuntime,
+ domainManagementComposite);
+
+ // add contributions
+ for (org.apache.tuscany.sca.domain.model.Contribution contribution : node.getContributions().values()){
+ nodeManagerService.addContribution(contribution.getContributionURI(),
+ contribution.getContributionURL().toString());
+ }
+
+ // deploy composite
+ nodeManagerService.deployComposite(compositeName.toString());
+
+ // start node
+ nodeManagerService.start();
+
+ // TODO
+ // somewhere we need to add the deployed composites into the node model
+
+ // reset the endpoint setting function
+ domainManagerNode.setNodeEndpoint(null);
+ }
+ }
+ }
+
+ public void stopComposite(QName qname) throws DomainException {
+ // TODO
+ }
+
+ public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException {
+ return (R)cast(target, domainManagementRuntime);
+ }
+
+ private <B, R extends CallableReference<B>> R cast(B target, ReallySmallRuntime runtime) throws IllegalArgumentException {
+ return (R)runtime.getProxyFactory().cast(target);
+ }
+
+ public <B> B getService(Class<B> businessInterface, String serviceName) {
+ return getService( businessInterface, serviceName, domainManagementRuntime, null);
+ }
+
+ private <B> B getService(Class<B> businessInterface, String serviceName, ReallySmallRuntime runtime, Composite domainComposite) {
+
+ ServiceReference<B> serviceReference = getServiceReference(businessInterface, serviceName, runtime, domainComposite);
+ if (serviceReference == null) {
+ throw new ServiceRuntimeException("Service not found: " + serviceName);
+ }
+ return serviceReference.getService();
+ }
+
+ private <B> ServiceReference<B> createServiceReference(Class<B> businessInterface, String targetURI) {
+ return createServiceReference(businessInterface, targetURI, domainManagementRuntime, null);
+ }
+
+
+ private <B> ServiceReference<B> createServiceReference(Class<B> businessInterface, String targetURI, ReallySmallRuntime runtime, Composite domainComposite) {
+ try {
+
+ AssemblyFactory assemblyFactory = runtime.getAssemblyFactory();
+ Composite composite = assemblyFactory.createComposite();
+ composite.setName(new QName(Constants.SCA10_TUSCANY_NS, "default"));
+ RuntimeComponent component = (RuntimeComponent)assemblyFactory.createComponent();
+ component.setName("default");
+ component.setURI("default");
+ runtime.getCompositeActivator().configureComponentContext(component);
+ composite.getComponents().add(component);
+ RuntimeComponentReference reference = (RuntimeComponentReference)assemblyFactory.createComponentReference();
+ reference.setName("default");
+ ModelFactoryExtensionPoint factories =
+ runtime.getExtensionPointRegistry().getExtensionPoint(ModelFactoryExtensionPoint.class);
+ JavaInterfaceFactory javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
+ InterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
+ interfaceContract.setInterface(javaInterfaceFactory.createJavaInterface(businessInterface));
+ reference.setInterfaceContract(interfaceContract);
+ component.getReferences().add(reference);
+ reference.setComponent(component);
+ SCABindingFactory scaBindingFactory = factories.getFactory(SCABindingFactory.class);
+ SCABinding binding = scaBindingFactory.createSCABinding();
+ binding.setURI(targetURI);
+ reference.getBindings().add(binding);
+ return new ServiceReferenceImpl<B>(businessInterface, component, reference, binding, runtime
+ .getProxyFactory(), runtime.getCompositeActivator());
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+
+
+ public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String name) {
+ return getServiceReference(businessInterface, name, domainManagementRuntime, null);
+ }
+
+
+ private <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String name, ReallySmallRuntime runtime, Composite domainComposite) {
+
+ // Extract the component name
+ String componentName;
+ String serviceName;
+ int i = name.indexOf('/');
+ if (i != -1) {
+ componentName = name.substring(0, i);
+ serviceName = name.substring(i + 1);
+
+ } else {
+ componentName = name;
+ serviceName = null;
+ }
+
+ // Lookup the component
+ Component component = null;
+
+ if ( domainComposite != null ) {
+ for (Composite composite: domainComposite.getIncludes()) {
+ for (Component compositeComponent: composite.getComponents()) {
+ if (compositeComponent.getName().equals(componentName)) {
+ component = compositeComponent;
+ }
+ }
+ }
+ }
+
+ if (component == null) {
+ // The component is not local in the partition, try to create a remote service ref
+ return createServiceReference(businessInterface, name, runtime, domainComposite);
+ }
+ RuntimeComponentContext componentContext = null;
+
+ // If the component is a composite, then we need to find the
+ // non-composite component that provides the requested service
+ if (component.getImplementation() instanceof Composite) {
+ for (ComponentService componentService : component.getServices()) {
+ if (serviceName == null || serviceName.equals(componentService.getName())) {
+ CompositeService compositeService = (CompositeService)componentService.getService();
+ if (compositeService != null) {
+ if (serviceName != null) {
+ serviceName = "$promoted$." + serviceName;
+ }
+ componentContext =
+ ((RuntimeComponent)compositeService.getPromotedComponent()).getComponentContext();
+ return componentContext.createSelfReference(businessInterface, compositeService
+ .getPromotedService());
+ }
+ break;
+ }
+ }
+ // No matching service is found
+ throw new ServiceRuntimeException("Composite service not found: " + name);
+ } else {
+ componentContext = ((RuntimeComponent)component).getComponentContext();
+ if (serviceName != null) {
+ return componentContext.createSelfReference(businessInterface, serviceName);
+ } else {
+ return componentContext.createSelfReference(businessInterface);
+ }
+ }
+ }
+
+}
diff --git a/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/SCADomainUtil.java b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/SCADomainUtil.java
new file mode 100644
index 0000000000..df618458d4
--- /dev/null
+++ b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/SCADomainUtil.java
@@ -0,0 +1,86 @@
+/*
+ * 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.domain.impl;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.MalformedURLException;
+import java.net.ServerSocket;
+import java.net.URI;
+import java.net.URL;
+import java.net.UnknownHostException;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.service.util.FileHelper;
+import org.apache.tuscany.sca.core.assembly.ActivationException;
+
+
+/**
+ * Some utility methods for the Domain implementation
+ *
+ * @version $Rev: 556897 $ $Date: 2007-09-07 12:41:52 +0100 (Fri, 07 Sep 2007) $
+ */
+public class SCADomainUtil {
+ private final static Logger logger = Logger.getLogger(SCADomainUtil.class.getName());
+
+ /**
+ * Given the name of a composite this method finds the contribution that it belongs to
+ * this could be either a local directory of a jar file.
+ *
+ * @param classLoader
+ * @param compositeString
+ * @return the contribution URL
+ * @throws MalformedURLException
+ */
+ public static URL findContributionFromComposite(ClassLoader classLoader, String compositeString)
+ throws MalformedURLException {
+
+ URL contributionURL = classLoader.getResource(compositeString);
+
+ if ( contributionURL != null ){
+ String contributionURLString = contributionURL.toExternalForm();
+ String protocol = contributionURL.getProtocol();
+
+ if ("file".equals(protocol)) {
+ // directory contribution
+ if (contributionURLString.endsWith(compositeString)) {
+ String location = contributionURLString.substring(0, contributionURLString.lastIndexOf(compositeString));
+ // workaround from evil url/uri form maven
+ contributionURL = FileHelper.toFile(new URL(location)).toURI().toURL();
+ }
+
+ } else if ("jar".equals(protocol)) {
+ // jar contribution
+ String location = contributionURLString.substring(4, contributionURLString.lastIndexOf("!/"));
+ // workaround for evil url/uri from maven
+ contributionURL = FileHelper.toFile(new URL(location)).toURI().toURL();
+ }
+ }
+
+ return contributionURL;
+ }
+} \ No newline at end of file
diff --git a/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/management/impl/ContributionInfoImpl.java b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/management/impl/ContributionInfoImpl.java
new file mode 100644
index 0000000000..090bf21fc1
--- /dev/null
+++ b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/management/impl/ContributionInfoImpl.java
@@ -0,0 +1,89 @@
+/*
+ * 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.domain.management.impl;
+
+import java.io.Serializable;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.domain.management.ContributionInfo;
+/**
+ * Information relating to an exposed service
+ *
+ * @version $Rev: 552343 $ $Date: 2007-09-07 12:41:52 +0100 (Fri, 07 Sep 2007) $
+ */
+public class ContributionInfoImpl implements ContributionInfo, Serializable {
+
+ static final long serialVersionUID = 7669181086005969428L;
+
+ private String contributionURI;
+ private URL contributionURL;
+ private List<QName> composites = new ArrayList<QName>();
+ private List<QName> deployableComposites = new ArrayList<QName>();
+
+
+ /**
+ * Retrieve the contribution uri
+ *
+ * @return contribution uri
+ */
+ public String getContributionURI() {
+ return contributionURI;
+ }
+
+ /**
+ * Set the contribution uri
+ *
+ * @param contributionURI
+ */
+ public void setContributionURI(String contributionURI){
+ this.contributionURI = contributionURI;
+ }
+
+ /**
+ * Retrieve the contribution url
+ *
+ * @return contribution url
+ */
+ public URL getContributionURL(){
+ return contributionURL;
+ }
+
+ /**
+ * Set the contribution url
+ *
+ * @param contributionURL
+ */
+ public void setContributionURL(URL contributionURL){
+ this.contributionURL = contributionURL;
+ }
+
+ public List<QName> getComposites(){
+ return composites;
+ }
+
+ public List<QName> getDeployableComposites(){
+ return deployableComposites;
+ }
+
+}
diff --git a/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/management/impl/DomainInfoImpl.java b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/management/impl/DomainInfoImpl.java
new file mode 100644
index 0000000000..b331d366a7
--- /dev/null
+++ b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/management/impl/DomainInfoImpl.java
@@ -0,0 +1,99 @@
+/*
+ * 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.domain.management.impl;
+
+import java.io.Serializable;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.domain.management.DomainInfo;
+import org.apache.tuscany.sca.domain.model.Composite;
+import org.apache.tuscany.sca.domain.model.Contribution;
+import org.apache.tuscany.sca.domain.model.Node;
+
+/**
+ * A data transport object for the management interface
+ *
+ * @version $Rev: 552343 $ $Date: 2007-09-07 12:41:52 +0100 (Fri, 07 Sep 2007) $
+ */
+public class DomainInfoImpl implements DomainInfo, Serializable {
+
+ static final long serialVersionUID = 7669181086005969428L;
+
+ private String domainURI;
+ private String domainURL;
+ private List<String> nodes = new ArrayList<String>();
+ private List<String> contributions = new ArrayList<String>();
+ private List<QName> composites = new ArrayList<QName>();
+
+ /**
+ * Retrieve the domain uri
+ *
+ * @return domain uri
+ */
+ public String getDomainURI(){
+ return domainURI;
+ }
+
+ /**
+ * Set the domain uri
+ *
+ * @param domainURI
+ */
+ public void setDomainURI(String domainURI){
+ this.domainURI = domainURI;
+ }
+
+ /**
+ * Retrieve the domain url
+ *
+ * @return domain url
+ */
+ public String getDomainURL(){
+ return domainURL;
+ }
+
+ /**
+ * Set the domain url
+ *
+ * @param domainURL
+ */
+ public void setDomainURL(String domainURL){
+ this.domainURL = domainURL;
+ }
+
+ public List<String> getNodes(){
+ return nodes;
+ }
+
+ public List<String> getContributions(){
+ return contributions;
+ }
+
+ public List<QName> getDeployedComposites(){
+ return composites;
+ }
+
+}
diff --git a/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/management/impl/NodeInfoImpl.java b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/management/impl/NodeInfoImpl.java
new file mode 100644
index 0000000000..1d547d33d7
--- /dev/null
+++ b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/management/impl/NodeInfoImpl.java
@@ -0,0 +1,99 @@
+/*
+ * 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.domain.management.impl;
+
+import java.io.Serializable;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.domain.management.NodeInfo;
+import org.apache.tuscany.sca.domain.model.Composite;
+import org.apache.tuscany.sca.domain.model.Contribution;
+import org.apache.tuscany.sca.domain.model.Service;
+
+/**
+ * Information relating to an exposed service
+ *
+ * @version $Rev: 552343 $ $Date: 2007-09-07 12:41:52 +0100 (Fri, 07 Sep 2007) $
+ */
+public class NodeInfoImpl implements NodeInfo, Serializable {
+
+ static final long serialVersionUID = 7669181086005969428L;
+
+ private String nodeURI;
+ private String nodeURL;
+ private List<String> contributions = new ArrayList<String>();
+ private List<QName> composites = new ArrayList<QName>();
+ private List<String> services = new ArrayList<String>();
+
+ /**
+ * Retrieve the node uri
+ *
+ * @return node uri
+ */
+ public String getNodeURI(){
+ return nodeURI;
+ }
+
+ /**
+ * Set the node uri
+ *
+ * @param nodeURI
+ */
+ public void setNodeURI(String nodeURI){
+ this.nodeURI = nodeURI;
+ }
+
+ /**
+ * Retrieve the node url
+ *
+ * @return node url
+ */
+ public String getNodeURL() {
+ return nodeURL;
+ }
+
+ /**
+ * Set the node url
+ *
+ * @param nodeURL
+ */
+ public void setNodeURL(String nodeURL){
+ this.nodeURL = nodeURL;
+ }
+
+ public List<String> getContributions(){
+ return contributions;
+ }
+
+ public List<QName> getDeployedComposites(){
+ return composites;
+ }
+
+ public List<String> getServices(){
+ return services;
+ }
+
+}
diff --git a/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/CompositeImpl.java b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/CompositeImpl.java
new file mode 100644
index 0000000000..f2717aeeef
--- /dev/null
+++ b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/CompositeImpl.java
@@ -0,0 +1,54 @@
+/*
+ * 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.domain.model.impl;
+
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.domain.model.Composite;
+
+
+/**
+ * A composite.
+ *
+ * @version $Rev: 552343 $ $Date: 2007-09-07 12:41:52 +0100 (Fri, 07 Sep 2007) $
+ */
+public class CompositeImpl implements Composite {
+
+ private QName compositeQName;
+
+ /**
+ * Retrieve the composite qname
+ *
+ * @return composite qname
+ */
+ public QName getCompositeQName(){
+ return compositeQName;
+ }
+
+ /**
+ * Set the composite qname
+ *
+ * @param compositeQName
+ */
+ public void setCompositeQName(QName compositeQName) {
+ this.compositeQName = compositeQName;
+ }
+}
diff --git a/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/ContributionImpl.java b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/ContributionImpl.java
new file mode 100644
index 0000000000..ed2456067e
--- /dev/null
+++ b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/ContributionImpl.java
@@ -0,0 +1,87 @@
+/*
+ * 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.domain.model.impl;
+
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.domain.model.Composite;
+import org.apache.tuscany.sca.domain.model.Contribution;
+
+/**
+ * A contribution.
+ *
+ * @version $Rev: 552343 $ $Date: 2007-09-07 12:41:52 +0100 (Fri, 07 Sep 2007) $
+ */
+public class ContributionImpl implements Contribution {
+
+ private String contributionURI;
+ private String contributionURL;
+ private Map<QName, Composite> composites = new HashMap<QName, Composite>();
+ private Map<QName, Composite> deployableComposites = new HashMap<QName, Composite>();
+
+
+ /**
+ * Retrieve the contribution uri
+ *
+ * @return contribution uri
+ */
+ public String getContributionURI() {
+ return contributionURI;
+ }
+
+ /**
+ * Set the contribution uri
+ *
+ * @param contributionURI
+ */
+ public void setContributionURI(String contributionURI){
+ this.contributionURI = contributionURI;
+ }
+
+ /**
+ * Retrieve the contribution url
+ *
+ * @return contribution url
+ */
+ public String getContributionURL(){
+ return contributionURL;
+ }
+
+ /**
+ * Set the contribution url
+ *
+ * @param contributionURL
+ */
+ public void setContributionURL(String contributionURL){
+ this.contributionURL = contributionURL;
+ }
+
+ public Map<QName, Composite> getComposites(){
+ return composites;
+ }
+
+ public Map<QName, Composite> getDeployableComposites(){
+ return deployableComposites;
+ }
+}
diff --git a/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/DomainImpl.java b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/DomainImpl.java
new file mode 100644
index 0000000000..0f6af482f7
--- /dev/null
+++ b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/DomainImpl.java
@@ -0,0 +1,94 @@
+/*
+ * 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.domain.model.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.domain.model.Composite;
+import org.apache.tuscany.sca.domain.model.Contribution;
+import org.apache.tuscany.sca.domain.model.Node;
+import org.apache.tuscany.sca.domain.model.Domain;
+
+
+/**
+ * A domain. Manages nodes
+ *
+ * @version $Rev: 552343 $ $Date: 2007-09-07 12:41:52 +0100 (Fri, 07 Sep 2007) $
+ */
+public class DomainImpl implements Domain {
+
+ private String domainURI;
+ private String domainURL;
+ private Map<String, Node> nodes = new HashMap<String, Node>();
+ private Map<String, Contribution> contributions = new HashMap<String, Contribution>();
+ private Map<QName, Composite> composites = new HashMap<QName, Composite>();
+
+
+ /**
+ * Retrieve the domain uri
+ *
+ * @return domain uri
+ */
+ public String getDomainURI(){
+ return domainURI;
+ }
+
+ /**
+ * Set the domain uri
+ *
+ * @param domainURI
+ */
+ public void setDomainURI(String domainURI){
+ this.domainURI = domainURI;
+ }
+
+ /**
+ * Retrieve the domain url
+ *
+ * @return domain url
+ */
+ public String getDomainURL(){
+ return domainURL;
+ }
+
+ /**
+ * Set the domain url
+ *
+ * @param domainURL
+ */
+ public void setDomainURL(String domainURL){
+ this.domainURL = domainURL;
+ }
+
+ public Map<String, Node> getNodes(){
+ return nodes;
+ }
+
+ public Map<String, Contribution> getContributions(){
+ return contributions;
+ }
+
+ public Map<QName, Composite> getDeployedComposites(){
+ return composites;
+ }
+}
diff --git a/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/DomainModelFactoryImpl.java b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/DomainModelFactoryImpl.java
new file mode 100644
index 0000000000..768f2658a4
--- /dev/null
+++ b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/DomainModelFactoryImpl.java
@@ -0,0 +1,80 @@
+/*
+ * 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.domain.model.impl;
+
+import org.apache.tuscany.sca.domain.model.Composite;
+import org.apache.tuscany.sca.domain.model.Contribution;
+import org.apache.tuscany.sca.domain.model.Domain;
+import org.apache.tuscany.sca.domain.model.DomainModelFactory;
+import org.apache.tuscany.sca.domain.model.Node;
+import org.apache.tuscany.sca.domain.model.Service;
+
+/**
+ * A node. Runs SCA composites
+ *
+ * @version $Rev: 552343 $ $Date: 2007-09-07 12:41:52 +0100 (Fri, 07 Sep 2007) $
+ */
+public class DomainModelFactoryImpl implements DomainModelFactory {
+
+ /**
+ * Create a new domain model
+ *
+ * @return new domain model
+ */
+ public Domain createDomain(){
+ return new DomainImpl();
+ }
+ /**
+ * Create a new node model
+ *
+ * @return new node model
+ */
+ public Node createNode(){
+ return new NodeImpl();
+ }
+
+ /**
+ * Create a new contribution model
+ *
+ * @return new contribution model
+ */
+ public Contribution createContribution(){
+ return new ContributionImpl();
+ }
+
+ /**
+ * Create a new composite model
+ *
+ * @return new composite model
+ */
+ public Composite createComposite(){
+ return new CompositeImpl();
+ }
+
+ /**
+ * Create a new service model
+ *
+ * @return new service model
+ */
+ public Service createService(){
+ return new ServiceImpl();
+ }
+
+}
diff --git a/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/NodeImpl.java b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/NodeImpl.java
new file mode 100644
index 0000000000..dc6454bf7e
--- /dev/null
+++ b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/NodeImpl.java
@@ -0,0 +1,93 @@
+/*
+ * 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.domain.model.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.domain.model.Composite;
+import org.apache.tuscany.sca.domain.model.Contribution;
+import org.apache.tuscany.sca.domain.model.Node;
+import org.apache.tuscany.sca.domain.model.Service;
+
+
+/**
+ * A node. Runs SCA composites
+ *
+ * @version $Rev: 552343 $ $Date: 2007-09-07 12:41:52 +0100 (Fri, 07 Sep 2007) $
+ */
+public class NodeImpl implements Node {
+
+ private String nodeURI;
+ private String nodeURL;
+ private Map<String, Contribution> contributions = new HashMap<String, Contribution>();
+ private Map<QName, Composite> composites = new HashMap<QName, Composite>();
+ private Map<String, Service> services = new HashMap<String, Service>();
+
+ /**
+ * Retrieve the node uri
+ *
+ * @return node uri
+ */
+ public String getNodeURI(){
+ return nodeURI;
+ }
+
+ /**
+ * Set the node uri
+ *
+ * @param nodeURI
+ */
+ public void setNodeURI(String nodeURI){
+ this.nodeURI = nodeURI;
+ }
+
+ /**
+ * Retrieve the node url
+ *
+ * @return node url
+ */
+ public String getNodeURL() {
+ return nodeURL;
+ }
+
+ /**
+ * Set the node url
+ *
+ * @param nodeURL
+ */
+ public void setNodeURL(String nodeURL){
+ this.nodeURL = nodeURL;
+ }
+
+ public Map<String, Contribution> getContributions(){
+ return contributions;
+ }
+
+ public Map<QName, Composite> getDeployedComposites(){
+ return composites;
+ }
+
+ public Map<String, Service> getServices(){
+ return services;
+ }
+}
diff --git a/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/ServiceImpl.java b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/ServiceImpl.java
new file mode 100644
index 0000000000..bf2ec8a6a3
--- /dev/null
+++ b/branches/sca-java-1.0.1/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/ServiceImpl.java
@@ -0,0 +1,89 @@
+/*
+ * 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.domain.model.impl;
+
+import org.apache.tuscany.sca.domain.model.Service;
+
+/**
+ * A service.
+ *
+ * @version $Rev: 552343 $ $Date: 2007-09-07 12:41:52 +0100 (Fri, 07 Sep 2007) $
+ */
+public class ServiceImpl implements Service {
+
+ private String serviceURI;
+ private String serviceURL;
+ private String serviceBinding;
+
+ /**
+ * Retrieve the service uri
+ *
+ * @return service uri
+ */
+ public String getServiceURI(){
+ return serviceURI;
+ }
+
+ /**
+ * Set the service uri
+ *
+ * @param serviceURI
+ */
+ public void setServiceURI(String serviceURI){
+ this.serviceURI = serviceURI;
+ }
+
+ /**
+ * Retrieve the service url
+ *
+ * @return service url
+ */
+ public String getServiceURL(){
+ return serviceURL;
+ }
+
+ /**
+ * Set the service url
+ *
+ * @param serviceURL
+ */
+ public void setServiceURL(String serviceURL){
+ this.serviceURL = serviceURL;
+ }
+
+
+ /**
+ * Retrieve the service binding
+ *
+ * @return service binding
+ */
+ public String getServiceBinding(){
+ return serviceBinding;
+ }
+
+ /**
+ * Set the service binding
+ *
+ * @param serviceBinding
+ */
+ public void setServiceBinding(String serviceBinding){
+ this.serviceBinding = serviceBinding;
+ }
+}