You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sl...@apache.org on 2007/08/17 10:49:40 UTC
svn commit: r566967 - in
/incubator/tuscany/java/sca/modules/distributed-impl: ./
src/main/java/org/apache/tuscany/sca/distributed/domain/impl/
src/main/java/org/apache/tuscany/sca/distributed/management/impl/
src/main/java/org/apache/tuscany/sca/distr...
Author: slaws
Date: Fri Aug 17 01:49:38 2007
New Revision: 566967
URL: http://svn.apache.org/viewvc?view=rev&rev=566967
Log:
Allow for the service lookup to be remote
Added:
incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/domain/impl/DistributedSCADomainNetworkImpl.java
incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/management/impl/DistributedDomainManagerMemoryImpl.java
incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/management/impl/DistributedDomainManagerNetworkImpl.java
incubator/tuscany/java/sca/modules/distributed-impl/src/test/java/org/
incubator/tuscany/java/sca/modules/distributed-impl/src/test/java/org/apache/
incubator/tuscany/java/sca/modules/distributed-impl/src/test/java/org/apache/tuscany/
incubator/tuscany/java/sca/modules/distributed-impl/src/test/java/org/apache/tuscany/sca/
incubator/tuscany/java/sca/modules/distributed-impl/src/test/java/org/apache/tuscany/sca/distributed/
incubator/tuscany/java/sca/modules/distributed-impl/src/test/java/org/apache/tuscany/sca/distributed/impl/
incubator/tuscany/java/sca/modules/distributed-impl/src/test/java/org/apache/tuscany/sca/distributed/impl/InMemoryTestCase.java
incubator/tuscany/java/sca/modules/distributed-impl/src/test/resources/management/
incubator/tuscany/java/sca/modules/distributed-impl/src/test/resources/management/META-INF/
incubator/tuscany/java/sca/modules/distributed-impl/src/test/resources/management/META-INF/sca-contribution.xml
incubator/tuscany/java/sca/modules/distributed-impl/src/test/resources/management/management.composite
incubator/tuscany/java/sca/modules/distributed-impl/src/test/resources/nodeA/wsdl/add.wsdl
incubator/tuscany/java/sca/modules/distributed-impl/src/test/resources/nodeA/wsdl/multiply.wsdl
Removed:
incubator/tuscany/java/sca/modules/distributed-impl/src/test/java/InMemoryTestCase.java
Modified:
incubator/tuscany/java/sca/modules/distributed-impl/pom.xml
incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/domain/impl/DistributedSCADomainImpl.java
incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/management/impl/ServiceDiscoveryMemoryImpl.java
incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/management/impl/ServiceDiscoveryNetworkImpl.java
incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/node/impl/EmbeddedNode.java
Modified: incubator/tuscany/java/sca/modules/distributed-impl/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/distributed-impl/pom.xml?view=diff&rev=566967&r1=566966&r2=566967
==============================================================================
--- incubator/tuscany/java/sca/modules/distributed-impl/pom.xml (original)
+++ incubator/tuscany/java/sca/modules/distributed-impl/pom.xml Fri Aug 17 01:49:38 2007
@@ -56,6 +56,19 @@
<version>1.0-incubating-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-adb</artifactId>
+ <version>1.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-http-jetty</artifactId>
@@ -76,14 +89,7 @@
<version>1.0-incubating-SNAPSHOT</version>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-implementation-java-runtime</artifactId>
- <version>1.0-incubating-SNAPSHOT</version>
- <scope>runtime</scope>
- </dependency>
-
+
<!--dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
Modified: incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/domain/impl/DistributedSCADomainImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/domain/impl/DistributedSCADomainImpl.java?view=diff&rev=566967&r1=566966&r2=566967
==============================================================================
--- incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/domain/impl/DistributedSCADomainImpl.java (original)
+++ incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/domain/impl/DistributedSCADomainImpl.java Fri Aug 17 01:49:38 2007
@@ -28,6 +28,7 @@
import org.apache.tuscany.sca.binding.sca.impl.SCABindingImpl;
import org.apache.tuscany.sca.distributed.domain.DistributedSCADomain;
import org.apache.tuscany.sca.distributed.management.ServiceDiscovery;
+import org.apache.tuscany.sca.host.embedded.impl.EmbeddedSCADomain;
/**
@@ -41,6 +42,7 @@
private String nodeName;
private String domainName;
+ protected EmbeddedSCADomain domain;
public DistributedSCADomainImpl(String domainName){
this.domainName = domainName;
@@ -67,6 +69,10 @@
public void setDomainName(String domainName){
this.domainName = domainName;
}
+
+ public void setLocalDomain(EmbeddedSCADomain localDomain){
+ this.domain = localDomain;
+ }
public ServiceDiscovery getServiceDiscovery(){
return null;
Added: incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/domain/impl/DistributedSCADomainNetworkImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/domain/impl/DistributedSCADomainNetworkImpl.java?view=auto&rev=566967
==============================================================================
--- incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/domain/impl/DistributedSCADomainNetworkImpl.java (added)
+++ incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/domain/impl/DistributedSCADomainNetworkImpl.java Fri Aug 17 01:49:38 2007
@@ -0,0 +1,51 @@
+/*
+ * 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.distributed.domain.impl;
+
+import org.apache.tuscany.sca.distributed.management.ServiceDiscovery;
+import org.apache.tuscany.sca.distributed.management.impl.ServiceDiscoveryMemoryImpl;
+import org.apache.tuscany.sca.distributed.management.impl.ServiceDiscoveryNetworkImpl;
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+/**
+ * Represents the network services and clients for the domain running on a node
+ * this implementation uses tuscany itself to implement the network clients and
+ * endpoints
+ *
+ * @version $Rev: 552343 $ $Date: 2007-07-01 18:43:40 +0100 (Sun, 01 Jul 2007) $
+ */
+public class DistributedSCADomainNetworkImpl extends DistributedSCADomainImpl {
+
+ private ServiceDiscovery serviceDiscovery;
+
+ public DistributedSCADomainNetworkImpl(String domainName){
+ super(domainName);
+ }
+
+ public ServiceDiscovery getServiceDiscovery(){
+
+ if (serviceDiscovery == null){
+ serviceDiscovery = domain.getService(ServiceDiscovery.class, "ServiceDiscoveryComponent");
+ }
+
+ return serviceDiscovery;
+ }
+
+}
Added: incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/management/impl/DistributedDomainManagerMemoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/management/impl/DistributedDomainManagerMemoryImpl.java?view=auto&rev=566967
==============================================================================
--- incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/management/impl/DistributedDomainManagerMemoryImpl.java (added)
+++ incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/management/impl/DistributedDomainManagerMemoryImpl.java Fri Aug 17 01:49:38 2007
@@ -0,0 +1,91 @@
+/*
+ * 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.distributed.management.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.distributed.management.DistributedDomainManager;
+import org.apache.tuscany.sca.distributed.management.ServiceDiscovery;
+import org.apache.tuscany.sca.distributed.management.impl.ServiceDiscoveryMemoryImpl.ServiceEndpoint;
+import org.osoa.sca.annotations.Reference;
+
+
+/**
+ * Stores details of services exposed and retrieves details of remote services
+ *
+ * @version $Rev: 552343 $ $Date: 2007-07-01 18:43:40 +0100 (Sun, 01 Jul 2007) $
+ */
+public class DistributedDomainManagerMemoryImpl implements DistributedDomainManager{
+
+ List<Node> nodes = new ArrayList<Node>();
+
+ public class Node {
+ private String domainUri;
+ private String nodeUri;
+ private String nodeManagementUri;
+
+ public Node(String domainUri, String nodeUri, String nodeManagementUri){
+ this.domainUri = domainUri;
+ this.nodeUri = nodeUri;
+ this.nodeManagementUri = nodeManagementUri;
+ }
+
+ public String toString (){
+ return "[" +
+ domainUri + " " +
+ nodeUri + " " +
+ nodeManagementUri +
+ "]";
+ }
+ }
+
+ /**
+ * A node registers with the distributed domain manager. The mechanism whereby this
+ * registration interface is discovered is not defined. For example, JMS, JINI
+ * or a hard coded configuration could all be candidates in the java world.
+ *
+ * @param domainUri the string uri for the distributed domain
+ * @param nodeUri the string uri for the current node
+ * @param nodeManagementUrl the endpoint for the nodes management service
+ */
+ public void registerNode(String domainUri, String nodeUri, String nodeManagementUri){
+ Node node = new Node(domainUri, nodeUri, nodeManagementUri);
+ System.err.println("Registering node: " + node.toString());
+ }
+
+ /**
+ * Retrieve the configuration for the specified node. The return type is interesting
+ * here. There are many ways in which all of the information that comprises a
+ * configuration can be provisioned onto a node, for example, shared file system,
+ * ftp, http. The return value is the url of where to look for the configuration
+ * information. From a management point of view it is convenient to maintain all
+ * current and previous node configurations. This can easily be achieved by providing
+ * a different URL each time the configuration is changed.
+ *
+ * @param domainUri the string uri for the distributed domain
+ * @param nodeUri the string uri for the current node
+ * @return the URL from where the configuration can be retrieved
+ */
+ public String getDomainNodeConfiguration(String domainUri, String nodeUri){
+ return null;
+ }
+
+}
Added: incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/management/impl/DistributedDomainManagerNetworkImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/management/impl/DistributedDomainManagerNetworkImpl.java?view=auto&rev=566967
==============================================================================
--- incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/management/impl/DistributedDomainManagerNetworkImpl.java (added)
+++ incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/management/impl/DistributedDomainManagerNetworkImpl.java Fri Aug 17 01:49:38 2007
@@ -0,0 +1,75 @@
+/*
+ * 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.distributed.management.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.distributed.management.DistributedDomainManager;
+import org.apache.tuscany.sca.distributed.management.ServiceDiscovery;
+import org.apache.tuscany.sca.distributed.management.impl.ServiceDiscoveryMemoryImpl.ServiceEndpoint;
+import org.osoa.sca.annotations.Reference;
+
+
+/**
+ * Stores details of services exposed and retrieves details of remote services
+ *
+ * @version $Rev: 552343 $ $Date: 2007-07-01 18:43:40 +0100 (Sun, 01 Jul 2007) $
+ */
+public class DistributedDomainManagerNetworkImpl implements DistributedDomainManager{
+
+ @Reference
+ protected DistributedDomainManager distributedDomainManager;
+
+ /**
+ * A node registers with the distributed domain manager. The mechanism whereby this
+ * registration interface is discovered is not defined. For example, JMS, JINI
+ * or a hard coded configuration could all be candidates in the java world.
+ *
+ * @param domainUri the string uri for the distributed domain
+ * @param nodeUri the string uri for the current node
+ * @param nodeManagementUrl the endpoint for the nodes management service
+ */
+ public void registerNode(String domainUri, String nodeUri, String nodeManagementUri){
+ System.err.println("Registering node: " +
+ domainUri + " " +
+ nodeUri + " " +
+ nodeManagementUri );
+ distributedDomainManager.registerNode(domainUri, nodeUri, nodeManagementUri);
+ }
+
+ /**
+ * Retrieve the configuration for the specified node. The return type is interesting
+ * here. There are many ways in which all of the information that comprises a
+ * configuration can be provisioned onto a node, for example, shared file system,
+ * ftp, http. The return value is the url of where to look for the configuration
+ * information. From a management point of view it is convenient to maintain all
+ * current and previous node configurations. This can easily be achieved by providing
+ * a different URL each time the configuration is changed.
+ *
+ * @param domainUri the string uri for the distributed domain
+ * @param nodeUri the string uri for the current node
+ * @return the URL from where the configuration can be retrieved
+ */
+ public String getDomainNodeConfiguration(String domainUri, String nodeUri){
+ return null;
+ }
+
+}
Modified: incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/management/impl/ServiceDiscoveryMemoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/management/impl/ServiceDiscoveryMemoryImpl.java?view=diff&rev=566967&r1=566966&r2=566967
==============================================================================
--- incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/management/impl/ServiceDiscoveryMemoryImpl.java (original)
+++ incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/management/impl/ServiceDiscoveryMemoryImpl.java Fri Aug 17 01:49:38 2007
@@ -23,6 +23,7 @@
import java.util.List;
import org.apache.tuscany.sca.distributed.management.ServiceDiscovery;
+import org.osoa.sca.annotations.Scope;
/**
@@ -30,6 +31,7 @@
*
* @version $Rev: 552343 $ $Date: 2007-07-01 18:43:40 +0100 (Sun, 01 Jul 2007) $
*/
+@Scope("COMPOSITE")
public class ServiceDiscoveryMemoryImpl implements ServiceDiscovery{
List<ServiceEndpoint> serviceEndpoints = new ArrayList<ServiceEndpoint>();
@@ -79,10 +81,11 @@
* @param bindingName the remote binding that is providing the endpoint
* @param url the enpoint url
*/
- public void registerServiceEndpoint(String domainUri, String nodeUri, String serviceName, String bindingName, String URL){
+ public String registerServiceEndpoint(String domainUri, String nodeUri, String serviceName, String bindingName, String URL){
ServiceEndpoint serviceEndpoint = new ServiceEndpoint (domainUri, nodeUri, serviceName, bindingName, URL);
serviceEndpoints.add(serviceEndpoint);
System.err.println("Registering service: " + serviceEndpoint.toString());
+ return "";
}
@@ -101,7 +104,7 @@
bindingName +
"]");
- String url = null;
+ String url = "";
for(ServiceEndpoint serviceEndpoint : serviceEndpoints){
if ( serviceEndpoint.match(domainUri, serviceName, bindingName)){
Modified: incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/management/impl/ServiceDiscoveryNetworkImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/management/impl/ServiceDiscoveryNetworkImpl.java?view=diff&rev=566967&r1=566966&r2=566967
==============================================================================
--- incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/management/impl/ServiceDiscoveryNetworkImpl.java (original)
+++ incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/management/impl/ServiceDiscoveryNetworkImpl.java Fri Aug 17 01:49:38 2007
@@ -19,6 +19,15 @@
package org.apache.tuscany.sca.distributed.management.impl;
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.rpc.client.RPCServiceClient;
import org.apache.tuscany.sca.distributed.management.ServiceDiscovery;
import org.osoa.sca.annotations.Reference;
@@ -42,9 +51,15 @@
* @param bindingName the remote binding that is providing the endpoint
* @param url the enpoint url
*/
- public void registerServiceEndpoint(String domainUri, String nodeUri, String serviceName, String bindingName, String URL){
- System.err.println("Registering service " + serviceName);
- serviceDiscovery.registerServiceEndpoint(domainUri, nodeUri, serviceName, bindingName, URL);
+ public String registerServiceEndpoint(String domainUri, String nodeUri, String serviceName, String bindingName, String URL){
+ System.err.println("Registering service: [" +
+ domainUri + " " +
+ nodeUri + " " +
+ serviceName + " " +
+ bindingName + " " +
+ URL +
+ "]");
+ return serviceDiscovery.registerServiceEndpoint(domainUri, nodeUri, serviceName, bindingName, URL);
}
@@ -57,7 +72,12 @@
* @return url the endpoint url
*/
public String findServiceEndpoint(String domainUri, String serviceName, String bindingName){
- System.err.println("Finding service " + serviceName);
+ System.err.println("Finding service: [" +
+ domainUri + " " +
+ serviceName + " " +
+ bindingName +
+ "]");
+
return serviceDiscovery.findServiceEndpoint(domainUri, serviceName, bindingName);
}
Modified: incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/node/impl/EmbeddedNode.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/node/impl/EmbeddedNode.java?view=diff&rev=566967&r1=566966&r2=566967
==============================================================================
--- incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/node/impl/EmbeddedNode.java (original)
+++ incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/node/impl/EmbeddedNode.java Fri Aug 17 01:49:38 2007
@@ -24,31 +24,76 @@
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.contribution.Contribution;
import org.apache.tuscany.sca.contribution.service.ContributionService;
+import org.apache.tuscany.sca.core.runtime.ActivationException;
import org.apache.tuscany.sca.distributed.domain.DistributedSCADomain;
+import org.apache.tuscany.sca.distributed.domain.impl.DistributedSCADomainImpl;
import org.apache.tuscany.sca.host.embedded.SCADomain;
import org.apache.tuscany.sca.host.embedded.impl.EmbeddedSCADomain;
/**
- * This client program shows how to run a distributed SCA node. In this case a
- * calculator node has been constructed specifically for running the calculator
- * composite.
+ * An embeddable node implementation.
*/
public class EmbeddedNode {
+ // The data required to get the domain up and running on this node
private String nodeName;
private String domainName;
private EmbeddedSCADomain domain;
+ private DistributedSCADomainImpl distributedDomain;
- // should be a collection but assuming only one domain
- // per node for now
- private DistributedSCADomain distributedDomain;
+ // Node management
+ private EmbeddedSCADomain management;
- public EmbeddedNode(String nodeName){
+ public EmbeddedNode(String nodeName)
+ throws ActivationException {
this.nodeName = nodeName;
+
+ try {
+ // This is starting a local domain just to use component references to
+ // talk to the domain node. It maybe that we can slim this down when we have the
+ // remote service reference code working.
+
+ ClassLoader cl = EmbeddedNode.class.getClassLoader();
+
+ // start a local domain to run management components
+ management = new EmbeddedSCADomain(cl, "management");
+ management.start();
+
+ // add management composite to the management domain
+ ContributionService contributionService = management.getContributionService();
+ URL contributionURL = Thread.currentThread().getContextClassLoader().getResource("management/");
+
+ if ( contributionURL != null){
+ System.err.println(contributionURL.toString());
+ Contribution contribution = contributionService.contribute("http://management",
+ contributionURL,
+ null, //resolver,
+ false);
+ Composite composite = contribution.getDeployables().get(0);
+ management.getDomainComposite().getIncludes().add(composite);
+ management.getCompositeBuilder().build(composite);
+ management.getCompositeActivator().activate(composite);
+ management.getCompositeActivator().start(composite);
+
+ // get the management components out of the domain so that they
+ // can be configured/used. None are yet but this would be the place to
+ // get components out of the management domain and give them access to
+ // useful parts of the node
+
+ } else {
+ throw new ActivationException("Can't find the management contribution on the classpath");
+ }
+
+ } catch(Exception ex) {
+ System.err.println("Exception when creating management components " + ex.getMessage());
+ domain = null;
+ throw new ActivationException(ex);
+ }
+
}
- public SCADomain createDomain(DistributedSCADomain distributedDomain){
- this.distributedDomain = distributedDomain;
+ public SCADomain attachDomain(DistributedSCADomain distributedDomain){
+ this.distributedDomain = (DistributedSCADomainImpl) distributedDomain;
domainName = distributedDomain.getDomainName();
try {
@@ -64,8 +109,12 @@
domain = null;
}
- // add node information into the distributed domain
+ // add local information into the distributed domain
this.distributedDomain.setNodeName(nodeName);
+ this.distributedDomain.setLocalDomain(management);
+
+ // add domain information into the management components that need it
+
return domain;
}
Added: incubator/tuscany/java/sca/modules/distributed-impl/src/test/java/org/apache/tuscany/sca/distributed/impl/InMemoryTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/distributed-impl/src/test/java/org/apache/tuscany/sca/distributed/impl/InMemoryTestCase.java?view=auto&rev=566967
==============================================================================
--- incubator/tuscany/java/sca/modules/distributed-impl/src/test/java/org/apache/tuscany/sca/distributed/impl/InMemoryTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/distributed-impl/src/test/java/org/apache/tuscany/sca/distributed/impl/InMemoryTestCase.java Fri Aug 17 01:49:38 2007
@@ -0,0 +1,94 @@
+package org.apache.tuscany.sca.distributed.impl;
+
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.distributed.domain.DistributedSCADomain;
+import org.apache.tuscany.sca.distributed.domain.impl.DistributedSCADomainMemoryImpl;
+import org.apache.tuscany.sca.distributed.node.impl.EmbeddedNode;
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import calculator.CalculatorService;
+
+/**
+ * Runs a distributed domain in a single VM by using and in memory
+ * implementation of the distributed domain
+ */
+public class InMemoryTestCase {
+
+ private static String DEFULT_DOMAIN_NAME = "mydomain";
+
+ private static DistributedSCADomain distributedDomain;
+ private static EmbeddedNode nodeA;
+ private static SCADomain domainA;
+ private static EmbeddedNode nodeB;
+ private static SCADomain domainB;
+ private static EmbeddedNode nodeC;
+ private static SCADomain domainC;
+ private static CalculatorService calculatorServiceA;
+ private static CalculatorService calculatorServiceB;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ System.out.println("Setting up distributed nodes");
+
+ // Create the distributed domain representation
+ distributedDomain = new DistributedSCADomainMemoryImpl(DEFULT_DOMAIN_NAME);
+
+ // create the node that runs the
+ // calculator component
+ nodeA = new EmbeddedNode("nodeA");
+ domainA = nodeA.attachDomain(distributedDomain);
+ nodeA.addContribution(DEFULT_DOMAIN_NAME, null);
+
+ // create the node that runs the
+ // add component
+ nodeB = new EmbeddedNode("nodeB");
+ domainB = nodeB.attachDomain(distributedDomain);
+ nodeB.addContribution(DEFULT_DOMAIN_NAME, null);
+
+ // create the node that runs the
+ // subtract component
+ nodeC = new EmbeddedNode("nodeC");
+ domainC = nodeC.attachDomain(distributedDomain);
+ nodeC.addContribution(DEFULT_DOMAIN_NAME, null);
+
+
+ // start all of the nodes
+ nodeA.start();
+ nodeB.start();
+ nodeC.start();
+
+ // get a reference to the calculator service from domainA
+ // which will be running this component
+ calculatorServiceA = domainA.getService(CalculatorService.class, "CalculatorServiceComponent1");
+ calculatorServiceB = domainB.getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ // stop the nodes and hence the domains they contain
+ nodeA.stop();
+ nodeB.stop();
+ nodeC.stop();
+ }
+
+ @Test
+ public void testCalculator() throws Exception {
+
+ // Calculate
+ Assert.assertEquals(calculatorServiceA.add(3, 2), 5.0);
+ Assert.assertEquals(calculatorServiceA.subtract(3, 2), 1.0);
+ Assert.assertEquals(calculatorServiceA.multiply(3, 2), 6.0);
+ Assert.assertEquals(calculatorServiceA.divide(3, 2), 1.5);
+ Assert.assertEquals(calculatorServiceB.add(3, 2), 5.0);
+ Assert.assertEquals(calculatorServiceB.subtract(3, 2), 1.0);
+ Assert.assertEquals(calculatorServiceB.multiply(3, 2), 6.0);
+ Assert.assertEquals(calculatorServiceB.divide(3, 2), 1.5);
+
+ }
+}
Added: incubator/tuscany/java/sca/modules/distributed-impl/src/test/resources/management/META-INF/sca-contribution.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/distributed-impl/src/test/resources/management/META-INF/sca-contribution.xml?view=auto&rev=566967
==============================================================================
--- incubator/tuscany/java/sca/modules/distributed-impl/src/test/resources/management/META-INF/sca-contribution.xml (added)
+++ incubator/tuscany/java/sca/modules/distributed-impl/src/test/resources/management/META-INF/sca-contribution.xml Fri Aug 17 01:49:38 2007
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://management"
+ xmlns:management="http://management">
+ <deployable composite="management:Management"/>
+</contribution>
\ No newline at end of file
Added: incubator/tuscany/java/sca/modules/distributed-impl/src/test/resources/management/management.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/distributed-impl/src/test/resources/management/management.composite?view=auto&rev=566967
==============================================================================
--- incubator/tuscany/java/sca/modules/distributed-impl/src/test/resources/management/management.composite (added)
+++ incubator/tuscany/java/sca/modules/distributed-impl/src/test/resources/management/management.composite Fri Aug 17 01:49:38 2007
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://management"
+ xmlns:sample="http://management"
+ name="Management">
+
+
+ <component name="ServiceDiscoveryComponent">
+ <implementation.java class="org.apache.tuscany.sca.distributed.management.impl.ServiceDiscoveryNetworkImpl" />
+ <reference name="serviceDiscovery">
+ <binding.ws uri="http://localhost:8080/ServiceDiscoveryComponent/ServiceDiscovery"/>
+ </reference>
+ </component>
+
+
+</composite>
Added: incubator/tuscany/java/sca/modules/distributed-impl/src/test/resources/nodeA/wsdl/add.wsdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/distributed-impl/src/test/resources/nodeA/wsdl/add.wsdl?view=auto&rev=566967
==============================================================================
--- incubator/tuscany/java/sca/modules/distributed-impl/src/test/resources/nodeA/wsdl/add.wsdl (added)
+++ incubator/tuscany/java/sca/modules/distributed-impl/src/test/resources/nodeA/wsdl/add.wsdl Fri Aug 17 01:49:38 2007
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<wsdl:definitions targetNamespace="http://calculator/add"
+ xmlns:tns="http://calculator/add"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ name="add">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified"
+ targetNamespace="http://calculator/add"
+ xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="add">
+ <complexType>
+ <sequence>
+ <element name="n1" type="xsd:double"/>
+ <element name="n2" type="xsd:double"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="addResponse">
+ <complexType>
+ <sequence>
+ <element name="response" type="xsd:double"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="addRequest">
+ <wsdl:part element="tns:add" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="addResponse">
+ <wsdl:part element="tns:addResponse" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:portType name="Add">
+ <wsdl:operation name="add">
+ <wsdl:input message="tns:addRequest" name="addRequest"/>
+ <wsdl:output message="tns:addResponse" name="addResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="AddSoapBinding" type="tns:Add">
+ <wsdlsoap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="add">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="addRequest">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="addResponse">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="AddService">
+ <wsdl:port binding="tns:AddSoapBinding" name="AddSoapPort">
+ <!--wsdlsoap:address location="http://localhost:8085/sample-calculator-webapp-ws/services/AddService"/-->
+ <wsdlsoap:address location="http://localhost:8085/AddServiceComponent"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
Added: incubator/tuscany/java/sca/modules/distributed-impl/src/test/resources/nodeA/wsdl/multiply.wsdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/distributed-impl/src/test/resources/nodeA/wsdl/multiply.wsdl?view=auto&rev=566967
==============================================================================
--- incubator/tuscany/java/sca/modules/distributed-impl/src/test/resources/nodeA/wsdl/multiply.wsdl (added)
+++ incubator/tuscany/java/sca/modules/distributed-impl/src/test/resources/nodeA/wsdl/multiply.wsdl Fri Aug 17 01:49:38 2007
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<wsdl:definitions targetNamespace="http://calculator/multiply"
+ xmlns:tns="http://calculator/multiply"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ name="multiply">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified"
+ targetNamespace="http://calculator/multiply"
+ xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="multiply">
+ <complexType>
+ <sequence>
+ <element name="n1" type="xsd:double"/>
+ <element name="n2" type="xsd:double"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="multiplyResponse">
+ <complexType>
+ <sequence>
+ <element name="response" type="xsd:double"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="multiplyRequest">
+ <wsdl:part element="tns:multiply" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="multiplyResponse">
+ <wsdl:part element="tns:multiplyResponse" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:portType name="Multiply">
+ <wsdl:operation name="multiply">
+ <wsdl:input message="tns:multiplyRequest" name="multiplyRequest"/>
+ <wsdl:output message="tns:multiplyResponse" name="multiplyResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="MultiplySoapBinding" type="tns:Multiply">
+ <wsdlsoap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="multiply">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="multiplyRequest">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="multiplyResponse">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+</wsdl:definitions>
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org