diff options
Diffstat (limited to 'sca-java-1.x/tags/1.2/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/management/impl')
4 files changed, 503 insertions, 0 deletions
diff --git a/sca-java-1.x/tags/1.2/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/management/impl/ContributionInfoImpl.java b/sca-java-1.x/tags/1.2/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/management/impl/ContributionInfoImpl.java new file mode 100644 index 0000000000..0ce961ae27 --- /dev/null +++ b/sca-java-1.x/tags/1.2/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/sca-java-1.x/tags/1.2/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/management/impl/DomainInfoImpl.java b/sca-java-1.x/tags/1.2/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/management/impl/DomainInfoImpl.java new file mode 100644 index 0000000000..4abbbd9466 --- /dev/null +++ b/sca-java-1.x/tags/1.2/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/management/impl/DomainInfoImpl.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.management.impl; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.domain.management.DomainInfo; + +/** + * 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/sca-java-1.x/tags/1.2/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/management/impl/NodeInfoImpl.java b/sca-java-1.x/tags/1.2/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/management/impl/NodeInfoImpl.java new file mode 100644 index 0000000000..558439db99 --- /dev/null +++ b/sca-java-1.x/tags/1.2/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/management/impl/NodeInfoImpl.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.management.impl; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.domain.management.NodeInfo; + +/** + * 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/sca-java-1.x/tags/1.2/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/management/impl/SCADomainManagerServiceImpl.java b/sca-java-1.x/tags/1.2/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/management/impl/SCADomainManagerServiceImpl.java new file mode 100644 index 0000000000..b4e1ff5972 --- /dev/null +++ b/sca-java-1.x/tags/1.2/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/management/impl/SCADomainManagerServiceImpl.java @@ -0,0 +1,228 @@ +/* + * 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.Externalizable; +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.SCADomainAPIService; +import org.apache.tuscany.sca.domain.SCADomainEventService; +import org.apache.tuscany.sca.domain.SCADomainSPI; +import org.apache.tuscany.sca.domain.management.DomainInfo; +import org.apache.tuscany.sca.domain.management.NodeInfo; +import org.apache.tuscany.sca.domain.management.SCADomainManagerInitService; +import org.apache.tuscany.sca.domain.management.SCADomainManagerService; +import org.apache.tuscany.sca.domain.model.DomainModel; +import org.apache.tuscany.sca.domain.model.NodeModel; +import org.apache.tuscany.sca.node.management.SCANodeManagerService; +import org.osoa.sca.CallableReference; +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 = {SCADomainEventService.class, SCADomainManagerInitService.class, SCADomainManagerService.class, SCADomainAPIService.class}) +public class SCADomainManagerServiceImpl implements SCADomainEventService, SCADomainManagerInitService, SCADomainManagerService, SCADomainAPIService { + + private final static Logger logger = Logger.getLogger(SCADomainManagerServiceImpl.class.getName()); + + private SCADomain domain; + private SCADomainSPI domainSPI; + private SCADomainEventService domainEventService; + + // DomainManagerInitService methods + + public void setDomain(SCADomain domain) { + this.domain = domain; + } + + public void setDomainSPI(SCADomainSPI domainSPI) { + this.domainSPI = domainSPI; + } + + public void setDomainEventService(SCADomainEventService domainEventService) { + this.domainEventService = domainEventService; + } + + // DomainEventService methods + + public void registerNode(String nodeURI, String nodeURL, Externalizable nodeManagerReference) throws DomainException{ + // get a reference to the node manager here so that the callable reference + // the right context to construct itself. Don't actually have to do + // anything with the result as the context is cached inside the callable + // reference + ((CallableReference<SCANodeManagerService>)nodeManagerReference).getService(); + + // pass on to the domain + domainEventService.registerNode(nodeURI, nodeURL, nodeManagerReference); + } + + public void unregisterNode(String nodeURI) throws DomainException { + domainEventService.unregisterNode(nodeURI); + } + + public void registerNodeStart(String nodeURI) throws DomainException { + domainEventService.registerNodeStart(nodeURI); + } + + public void registerNodeStop(String nodeURI) throws DomainException { + domainEventService.registerNodeStop(nodeURI); + } + + public void registerContribution(String nodeURI, String contributionURI, String contributionURL) throws DomainException { + domainEventService.registerContribution(nodeURI, contributionURI, contributionURL); + } + + public void unregisterContribution(String nodeURI,String contributionURI)throws DomainException { + domainEventService.unregisterContribution(nodeURI, contributionURI); + } + + public void registerDomainLevelComposite(String nodeURI, String compositeQNameString) throws DomainException{ + domainEventService.registerDomainLevelComposite(nodeURI, compositeQNameString); + } + + public void registerServiceEndpoint(String domainURI, String nodeUri, String serviceName, String bindingName, String URL) throws DomainException { + domainEventService.registerServiceEndpoint(domainURI, nodeUri, serviceName, bindingName, URL); + } + + public void unregisterServiceEndpoint(String domainURI, String nodeUri, String serviceName, String bindingName) throws DomainException{ + domainEventService.unregisterServiceEndpoint(domainURI, nodeUri, serviceName, bindingName); + } + + + public String findServiceEndpoint(String domainURI, String serviceName, String bindingName) throws DomainException{ + return domainEventService.findServiceEndpoint(domainURI, serviceName, bindingName); + } + + public String findServiceNode(String domainURI, String serviceName, String bindingName) throws DomainException { + return domainEventService.findServiceNode(domainURI, serviceName, bindingName); + } + + // DomainAPIService methods + + public void start() throws DomainException { + domain.start(); + } + + public void stop() throws DomainException { + domain.stop(); + } + + public void destroyDomain() throws DomainException { + domain.destroy(); + } + + public String getURI() { + return domain.getURI(); + } + + public void addContribution(String contributionURI, String contributionURL) throws DomainException { + try { + domain.addContribution(contributionURI, new URL(contributionURL)); + } catch (Exception ex) { + throw new DomainException (ex); + } + } + + public void updateContribution(String contributionURI, String contributionURL) throws DomainException { + try { + domain.updateContribution(contributionURI, new URL(contributionURL)); + } catch (Exception ex) { + throw new DomainException (ex); + } + } + + public void removeContribution(String contributionURI) throws DomainException { + domain.removeContribution(contributionURI); + } + + public void addDeploymentComposite(String contributionURI, String compositeXML) throws DomainException { + domain.addDeploymentComposite(contributionURI, compositeXML); + } + + public void updateDeploymentComposite(String contributionURI, String compositeXML) throws DomainException { + domain.updateDeploymentComposite(contributionURI, compositeXML); + } + + public void addToDomainLevelComposite(String compositeQName) throws DomainException { + domain.addToDomainLevelComposite(QName.valueOf(compositeQName)); + } + + public void removeFromDomainLevelComposite(String compositeQName) throws DomainException { + domain.removeFromDomainLevelComposite(QName.valueOf(compositeQName)); + } + + public String getDomainLevelComposite() throws DomainException { + return domain.getDomainLevelComposite(); + } + + public String getQNameDefinition(String artifact) throws DomainException { + return domain.getQNameDefinition(QName.valueOf(artifact)); + } + + public void startComposite(String compositeQName) throws DomainException { + domain.startComposite(QName.valueOf(compositeQName)); + } + + public void stopComposite(String compositeQName) throws DomainException { + domain.stopComposite(QName.valueOf(compositeQName)); + } + + // DomainManagementService methods + + public DomainInfo getDomainDescription(){ + + DomainInfo domainInfo = new DomainInfoImpl(); + DomainModel domain = domainSPI.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(); + DomainModel domain = domainSPI.getDomainModel(); + NodeModel 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; + } +} |