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/10/04 15:40:56 UTC
svn commit: r581897 [1/4] - in /incubator/tuscany/java/sca:
distribution/webapp/src/main/java/org/apache/tuscany/sca/webapp/
itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/
modules/ modules/binding-sca-axis2/src/main/ja...
Author: slaws
Date: Thu Oct 4 06:40:50 2007
New Revision: 581897
URL: http://svn.apache.org/viewvc?rev=581897&view=rev
Log:
TUSCANY-1637
First pass at new domain/node implementation
Potential problems with the wider build with these changes but I need to get a wider view on the problems that I'm seeing
Added:
incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/TestNode.java
incubator/tuscany/java/sca/modules/domain-api/src/main/java/org/apache/tuscany/sca/domain/DomainException.java
incubator/tuscany/java/sca/modules/domain-api/src/main/java/org/apache/tuscany/sca/domain/SCADomainFactory.java
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/DomainManagerNodeImpl.java
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/SCADomainFactoryImpl.java
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/SCADomainImpl.java
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/SCADomainUtil.java
incubator/tuscany/java/sca/modules/domain/src/main/java/org/apache/tuscany/sca/domain/DomainManagerInitService.java
incubator/tuscany/java/sca/modules/domain/src/main/java/org/apache/tuscany/sca/domain/SCADomainSPI.java
incubator/tuscany/java/sca/modules/node-api/ (with props)
incubator/tuscany/java/sca/modules/node-api/DISCLAIMER
incubator/tuscany/java/sca/modules/node-api/LICENSE
incubator/tuscany/java/sca/modules/node-api/NOTICE
incubator/tuscany/java/sca/modules/node-api/pom.xml
incubator/tuscany/java/sca/modules/node-api/src/
incubator/tuscany/java/sca/modules/node-api/src/main/
incubator/tuscany/java/sca/modules/node-api/src/main/java/
incubator/tuscany/java/sca/modules/node-api/src/main/java/org/
incubator/tuscany/java/sca/modules/node-api/src/main/java/org/apache/
incubator/tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/
incubator/tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/
incubator/tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/
incubator/tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeException.java
incubator/tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/SCADomainFinder.java
incubator/tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/SCANode.java
incubator/tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/SCANodeFactory.java
incubator/tuscany/java/sca/modules/node-api/src/test/
incubator/tuscany/java/sca/modules/node-api/src/test/java/
incubator/tuscany/java/sca/modules/node-api/src/test/resources/
incubator/tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCADomainFinderImpl.java
incubator/tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCADomainImpl.java
incubator/tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCANodeFactoryImpl.java
incubator/tuscany/java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/DomainDrivenTestCase.java
incubator/tuscany/java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeDrivenTestCase.java
- copied, changed from r580763, incubator/tuscany/java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/InMemoryTestCase.java
incubator/tuscany/java/sca/modules/node/src/main/java/org/apache/tuscany/sca/node/NodeFactoryImpl.java
- copied, changed from r580763, incubator/tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
incubator/tuscany/java/sca/modules/node/src/main/java/org/apache/tuscany/sca/node/SCADomainProxySPI.java
Removed:
incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/TestServiceDiscoveryImpl.java
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/SCADomainServiceImpl.java
incubator/tuscany/java/sca/modules/domain/src/main/java/org/apache/tuscany/sca/domain/SCADomainService.java
incubator/tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/ContributionManagerImpl.java
incubator/tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
incubator/tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCADomainServiceImpl.java
incubator/tuscany/java/sca/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/InMemoryTestCase.java
incubator/tuscany/java/sca/modules/node-impl/src/test/resources/nodeA/wsdl/
incubator/tuscany/java/sca/modules/node/src/main/java/org/apache/tuscany/sca/node/CompositeManager.java
incubator/tuscany/java/sca/modules/node/src/main/java/org/apache/tuscany/sca/node/ContributionManager.java
incubator/tuscany/java/sca/modules/node/src/main/java/org/apache/tuscany/sca/node/SCANode.java
Modified:
incubator/tuscany/java/sca/distribution/webapp/src/main/java/org/apache/tuscany/sca/webapp/WarContextListener.java
incubator/tuscany/java/sca/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceRemoteTestCase.java
incubator/tuscany/java/sca/modules/binding-sca-axis2/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAReferenceBindingProvider.java
incubator/tuscany/java/sca/modules/binding-sca-axis2/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAServiceBindingProvider.java
incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/AsynchTestCase.java
incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/BaseTest.java
incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/CallbackTestCase.java
incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/PromotionTestCase.java
incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/SimpleTestCase.java
incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/TestDomain.java
incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCAReferenceBindingProvider.java
incubator/tuscany/java/sca/modules/domain-api/pom.xml
incubator/tuscany/java/sca/modules/domain-api/src/main/java/org/apache/tuscany/sca/domain/SCADomain.java
incubator/tuscany/java/sca/modules/domain-impl/pom.xml
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/DomainManagerServiceImpl.java
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/NodeInfoImpl.java
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/ServiceInfoImpl.java
incubator/tuscany/java/sca/modules/domain-impl/src/main/resources/domain.composite
incubator/tuscany/java/sca/modules/domain/pom.xml
incubator/tuscany/java/sca/modules/domain/src/main/java/org/apache/tuscany/sca/domain/DomainManagerService.java
incubator/tuscany/java/sca/modules/domain/src/main/java/org/apache/tuscany/sca/domain/NodeInfo.java
incubator/tuscany/java/sca/modules/domain/src/main/java/org/apache/tuscany/sca/domain/ServiceInfo.java
incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/extension/helper/impl/BindingsActivator.java
incubator/tuscany/java/sca/modules/host-embedded/pom.xml
incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/DefaultLauncher.java
incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomain.java
incubator/tuscany/java/sca/modules/node-impl/pom.xml
incubator/tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/DomainManagerServiceImpl.java
incubator/tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeManagerServiceImpl.java
incubator/tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCANodeImpl.java
incubator/tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCANodeUtil.java
incubator/tuscany/java/sca/modules/node-impl/src/main/resources/node.composite
incubator/tuscany/java/sca/modules/node-impl/src/test/resources/nodeA/Calculator.composite
incubator/tuscany/java/sca/modules/node-impl/src/test/resources/nodeB/Calculator.composite
incubator/tuscany/java/sca/modules/node-impl/src/test/resources/nodeC/Calculator.composite
incubator/tuscany/java/sca/modules/node/pom.xml
incubator/tuscany/java/sca/modules/node/src/main/java/org/apache/tuscany/sca/node/ComponentManagerService.java
incubator/tuscany/java/sca/modules/node/src/main/java/org/apache/tuscany/sca/node/NodeManagerService.java
incubator/tuscany/java/sca/modules/pom.xml
incubator/tuscany/java/sca/samples/calculator-distributed/pom.xml
incubator/tuscany/java/sca/samples/calculator-distributed/src/main/java/node/CalculatorNode.java
incubator/tuscany/java/sca/samples/calculator-distributed/src/main/java/node/DomainNode.java
incubator/tuscany/java/sca/samples/calculator-distributed/src/main/resources/nodeA/Calculator.composite
incubator/tuscany/java/sca/samples/calculator-distributed/src/main/resources/nodeB/Calculator.composite
incubator/tuscany/java/sca/samples/calculator-distributed/src/main/resources/nodeC/Calculator.composite
incubator/tuscany/java/sca/samples/calculator-distributed/src/test/java/calculator/DomainInMemoryTestCase.java
incubator/tuscany/java/sca/samples/domain-webapp/src/main/java/node/DomainServer.java
Modified: incubator/tuscany/java/sca/distribution/webapp/src/main/java/org/apache/tuscany/sca/webapp/WarContextListener.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/distribution/webapp/src/main/java/org/apache/tuscany/sca/webapp/WarContextListener.java?rev=581897&r1=581896&r2=581897&view=diff
==============================================================================
--- incubator/tuscany/java/sca/distribution/webapp/src/main/java/org/apache/tuscany/sca/webapp/WarContextListener.java (original)
+++ incubator/tuscany/java/sca/distribution/webapp/src/main/java/org/apache/tuscany/sca/webapp/WarContextListener.java Thu Oct 4 06:40:50 2007
@@ -40,7 +40,9 @@
import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
import org.apache.tuscany.sca.contribution.service.ContributionException;
import org.apache.tuscany.sca.core.assembly.ActivationException;
-import org.apache.tuscany.sca.node.impl.ContributionManagerImpl;
+import org.apache.tuscany.sca.node.NodeException;
+import org.apache.tuscany.sca.node.SCANode;
+import org.apache.tuscany.sca.node.SCANodeFactory;
import org.apache.tuscany.sca.node.impl.SCANodeImpl;
/**
@@ -53,7 +55,7 @@
public class WarContextListener implements ServletContextListener {
private final static Logger logger = Logger.getLogger(WarContextListener.class.getName());
- protected SCANodeImpl node;
+ protected SCANode node;
protected AddableURLClassLoader classLoader;
protected File repository;
@@ -104,31 +106,34 @@
protected void initNode() throws ContributionException, ActivationException, IOException,
CompositeBuilderException, URISyntaxException {
- logger.log(Level.INFO, "SCA node starting");
-
- classLoader = new AddableURLClassLoader(new URL[] {}, Thread.currentThread().getContextClassLoader());
- Thread.currentThread().setContextClassLoader(classLoader);
- node = new SCANodeImpl(domainName, nodeName, classLoader);
- node.start();
-
- existingContributions = new HashMap<URL, Long>();
- URL[] contributions = getContributionJarURLs(repository);
- for (URL contribution : contributions) {
- try {
- addContribution(contribution);
- } catch (Throwable e) {
- e.printStackTrace();
- logger.log(Level.WARNING, "Exception adding contribution: " + e);
+ try {
+ logger.log(Level.INFO, "SCA node starting");
+
+ classLoader = new AddableURLClassLoader(new URL[] {}, Thread.currentThread().getContextClassLoader());
+ Thread.currentThread().setContextClassLoader(classLoader);
+
+ SCANodeFactory nodeFactory = SCANodeFactory.newInstance();
+ node = nodeFactory.createSCANode(nodeName, domainName);
+ node.start();
+
+ existingContributions = new HashMap<URL, Long>();
+ URL[] contributions = getContributionJarURLs(repository);
+ for (URL contribution : contributions) {
+
+ addContribution(contribution);
+
}
+
+ initHotDeploy(repository);
+ } catch (Throwable e) {
+ e.printStackTrace();
+ logger.log(Level.WARNING, "Exception adding contribution: " + e);
}
-
- initHotDeploy(repository);
-
}
- protected void addContribution(URL contribution) throws CompositeBuilderException, ContributionException, IOException, ActivationException, URISyntaxException {
+ protected void addContribution(URL contribution) throws URISyntaxException, NodeException {
classLoader.addURL(contribution);
- ((ContributionManagerImpl)node.getContributionManager()).addContribution(contribution);
+ node.addContribution(contribution.toString(), contribution);
existingContributions.put(contribution, new Long(new File(contribution.toURI()).lastModified()));
logger.log(Level.INFO, "Added contribution: " + contribution);
}
@@ -260,13 +265,13 @@
if (servletContext.getInitParameter("domainName") != null) {
domainName = servletContext.getInitParameter("domainName");
} else {
- domainName = SCANodeImpl.LOCAL_DOMAIN_URI;
+ domainName = null;
}
if (servletContext.getInitParameter("nodeName") != null) {
nodeName = servletContext.getInitParameter("nodeName");
} else {
- nodeName = SCANodeImpl.LOCAL_NODE_URI;
+ nodeName = "DefaultNode";
}
if (servletContext.getInitParameter("hotDeployInterval") != null) {
Modified: incubator/tuscany/java/sca/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceRemoteTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceRemoteTestCase.java?rev=581897&r1=581896&r2=581897&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceRemoteTestCase.java (original)
+++ incubator/tuscany/java/sca/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceRemoteTestCase.java Thu Oct 4 06:40:50 2007
@@ -21,13 +21,16 @@
import static junit.framework.Assert.assertEquals;
+import javax.xml.namespace.QName;
+
import junit.framework.Assert;
import org.apache.tuscany.sca.domain.SCADomain;
-import org.apache.tuscany.sca.node.impl.SCANodeImpl;
-import org.apache.tuscany.sca.node.impl.SCANodeUtil;
+import org.apache.tuscany.sca.domain.SCADomainFactory;
+import org.apache.tuscany.sca.node.SCANode;
+import org.apache.tuscany.sca.node.SCANodeFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -39,11 +42,11 @@
*/
public class CallableReferenceRemoteTestCase {
- private static String DEFAULT_DOMAIN_URL = "http://localhost:8877";
+ private static String DEFAULT_DOMAIN_URI = "http://localhost:8877";
private static SCADomain domain;
- private static SCADomain domainNodeA;
- private static SCADomain domainNodeB;
+ private static SCANode nodeA;
+ private static SCANode nodeB;
private static AComponent acomponent;
@@ -51,23 +54,29 @@
public static void init() throws Exception {
try {
- System.out.println("Setting up distributed registry");
- domain = SCADomain.newInstance("domain.composite");
+ System.out.println("Setting up domain");
+ SCADomainFactory domainFactory = SCADomainFactory.newInstance();
+ domain= domainFactory.createSCADomain(DEFAULT_DOMAIN_URI);
- System.out.println("Setting up distributed nodes");
-
- // create the node that runs the
- // calculator component
- domainNodeA = SCADomain.newInstance(DEFAULT_DOMAIN_URL, "nodeA", null, "nodeA/CompositeA.composite");
-
- // create the node that runs the
- // add component
- domainNodeB = SCADomain.newInstance(DEFAULT_DOMAIN_URL, "nodeB", null, "nodeB/CompositeB.composite");
-
+ System.out.println("Setting up nodes");
+
+ ClassLoader cl = CallableReferenceRemoteTestCase.class.getClassLoader();
+
+ SCANodeFactory nodeFactory = SCANodeFactory.newInstance();
+
+ nodeA = nodeFactory.createSCANode("nodeA", DEFAULT_DOMAIN_URI);
+ nodeA.addContribution("nodeA", cl.getResource("nodeA/"));
+ nodeA.startComposite(new QName("http://foo", "CompositeA"));
+ nodeA.start();
+
+ nodeB = nodeFactory.createSCANode("nodeB", DEFAULT_DOMAIN_URI);
+ nodeB.addContribution("nodeB", cl.getResource("nodeB/"));
+ nodeB.startComposite(new QName("http://foo", "CompositeB"));
+ nodeB.start();
// get a reference to the calculator service from domainA
// which will be running this component
- acomponent = domainNodeA.getService(AComponent.class, "AComponent/AComponent");
+ acomponent = nodeA.getDomain().getService(AComponent.class, "AComponent/AComponent");
} catch (Exception ex) {
System.out.println(ex.toString());
}
@@ -76,9 +85,8 @@
@AfterClass
public static void destroy() throws Exception {
// stop the nodes and hence the domains they contain
- domainNodeA.close();
- domainNodeB.close();
- domain.close();
+ nodeA.stop();
+ nodeB.stop();
}
@Test
Modified: incubator/tuscany/java/sca/modules/binding-sca-axis2/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAReferenceBindingProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-sca-axis2/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAReferenceBindingProvider.java?rev=581897&r1=581896&r2=581897&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-sca-axis2/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAReferenceBindingProvider.java (original)
+++ incubator/tuscany/java/sca/modules/binding-sca-axis2/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAReferenceBindingProvider.java Thu Oct 4 06:40:50 2007
@@ -28,7 +28,7 @@
import org.apache.tuscany.sca.binding.ws.axis2.Axis2ReferenceBindingProvider;
import org.apache.tuscany.sca.binding.ws.axis2.Java2WSDLHelper;
import org.apache.tuscany.sca.core.assembly.EndpointReferenceImpl;
-import org.apache.tuscany.sca.domain.SCADomainService;
+import org.apache.tuscany.sca.domain.SCADomainSPI;
import org.apache.tuscany.sca.host.http.ServletHost;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.Operation;
@@ -113,14 +113,14 @@
if ( serviceEPR == null && node != null ){
// try to resolve the service endpoint with the registry
- SCADomainService serviceDiscovery = node.getDomainService();
+ SCADomainSPI domainProxy = (SCADomainSPI)node.getDomain();
- if (serviceDiscovery != null){
+ if (domainProxy != null){
// The binding URI might be null in the case where this reference is completely
// dynamic, for example, in the case of callbacks
if (binding.getURI() != null) {
- String serviceUrl = serviceDiscovery.findServiceEndpoint(node.getDomainURI(),
+ String serviceUrl = domainProxy.findServiceEndpoint(node.getDomain().getURI(),
binding.getURI(),
SCABinding.class.getName());
Modified: incubator/tuscany/java/sca/modules/binding-sca-axis2/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAServiceBindingProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-sca-axis2/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAServiceBindingProvider.java?rev=581897&r1=581896&r2=581897&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-sca-axis2/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAServiceBindingProvider.java (original)
+++ incubator/tuscany/java/sca/modules/binding-sca-axis2/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAServiceBindingProvider.java Thu Oct 4 06:40:50 2007
@@ -34,7 +34,7 @@
import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
import org.apache.tuscany.sca.binding.ws.axis2.Axis2ServiceProvider;
import org.apache.tuscany.sca.binding.ws.axis2.Java2WSDLHelper;
-import org.apache.tuscany.sca.domain.SCADomainService;
+import org.apache.tuscany.sca.domain.SCADomainSPI;
import org.apache.tuscany.sca.host.http.ServletHost;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
@@ -63,7 +63,7 @@
public Axis2SCAServiceBindingProvider(SCANode node,
- RuntimeComponent component,
+ RuntimeComponent component,
RuntimeComponentService service,
DistributedSCABinding binding,
ServletHost servletHost,
@@ -94,66 +94,72 @@
if (node != null){
- // get the url out of the binding and send it to the registry if
- // a distributed domain is configured
- SCADomainService domainService = node.getDomainService();
-
- if (domainService != null) {
- // work out what the component service name is that will be registered
- // it should be the path element of the binding uri
- String componentServiceName = this.binding.getURI();
-
- try {
- URI servicePath = new URI(this.binding.getURI());
- componentServiceName = servicePath.getPath();
-
- // strip any leading slash
- if (componentServiceName.charAt(0) == '/'){
- componentServiceName = componentServiceName.substring(1, componentServiceName.length());
- }
- } catch(Exception ex) {
- // do nothing, the binding uri string will be used
- }
-
- // work out what the endpoint address is that the component service name will be registered
- // against. Be default this is the url calculated by the web services binding but
- // we have to adjust that to:
- // 1. correct the host and port in the case that this is a web app as the container controlls the port
+
+ SCADomainSPI domainProxy = (SCADomainSPI)node.getDomain();
+
+ if (domainProxy != null) {
+
+ // work out what the component service name is that will be registered
+ // it should be the path element of the binding uri
+ String componentServiceName = this.binding.getURI();
+
+ try {
+ URI servicePath = new URI(this.binding.getURI());
+ componentServiceName = servicePath.getPath();
+
+ // strip any leading slash
+ if (componentServiceName.charAt(0) == '/'){
+ componentServiceName = componentServiceName.substring(1, componentServiceName.length());
+ }
+ } catch(Exception ex) {
+ // do nothing, the binding uri string will be used
+ }
+
+ // work out what the endpoint address is that the component service name will be registered
+ // against. Be default this is the url calculated by the web services binding but
+ // we have to adjust that to:
+ // 1. correct the host and port in the case that this is a web app as the container controlls the port
// 2. correct the host name in the case that it's localhost
- String componentServiceUrlString = wsBinding.getURI();
- URL componentServiceUrl;
-
- try {
- componentServiceUrl = new URL(componentServiceUrlString);
- } catch (MalformedURLException ex) {
- throw new IllegalStateException("Unable to conver url " +
- componentServiceUrlString +
- " as generated by the web service binding into a URL");
- }
-
- String originalHost = componentServiceUrl.getHost();
- String newHost = originalHost;
- int originalPort = componentServiceUrl.getPort();
- int newPort = originalPort;
-
- // TODO - could do with a change to the ServletHost API so that we can just ask the servlet
- // host if it is controlling the URL
- if (servletHost.getClass().getName().equals("WebbAppServletHost")){
- // the service URL will likely be completely different to that
- // calculated by the ws binding so replace it with the node url
- // The node url will have been set via init parameters in the web app
- URL nodeUrl = node.getNodeURL();
-
+ String componentServiceUrlString = wsBinding.getURI();
+ URL componentServiceUrl;
+
+ try {
+ componentServiceUrl = new URL(componentServiceUrlString);
+ } catch (MalformedURLException ex) {
+ throw new IllegalStateException("Unable to conver url " +
+ componentServiceUrlString +
+ " as generated by the web service binding into a URL");
+ }
+
+ String originalHost = componentServiceUrl.getHost();
+ String newHost = originalHost;
+ int originalPort = componentServiceUrl.getPort();
+ int newPort = originalPort;
+
+ // TODO - could do with a change to the ServletHost API so that we can just ask the servlet
+ // host if it is controlling the URL
+ if (servletHost.getClass().getName().equals("WebbAppServletHost")){
+ // the service URL will likely be completely different to that
+ // calculated by the ws binding so replace it with the node url
+ // The node url will have been set via init parameters in the web app
+ URL nodeUrl;
+ try {
+ URI tmpURI = new URI(node.getURI());
+ nodeUrl = tmpURI.toURL();
+ } catch (Exception ex) {
+ throw new IllegalStateException("Node running inside a webapp and node was not created with a valid node url");
+ }
+
if (nodeUrl != null){
newHost = nodeUrl.getHost();
newPort = nodeUrl.getPort();
} else {
throw new IllegalStateException("Node running inside a webapp and node was not created with a valid node url");
}
- }
-
- // no good registering localhost as a host name when nodes are spread across
- // machines
+ }
+
+ // no good registering localhost as a host name when nodes are spread across
+ // machines
if ( newHost.equals("localhost")){
try {
newHost = InetAddress.getLocalHost().getHostName();
@@ -161,41 +167,33 @@
throw new IllegalStateException("Got unknown host while trying to get the local host name in order to regsiter service with the domain");
}
}
-
- // replace the old with the new
+
+ // replace the old with the new
componentServiceUrlString = componentServiceUrlString.replace(String.valueOf(originalPort), String.valueOf(newPort));
componentServiceUrlString = componentServiceUrlString.replace(originalHost, newHost);
-
- try {
- domainService.registerServiceEndpoint(node.getDomainURI(),
- node.getNodeURI(),
- componentServiceName,
- SCABinding.class.getName(),
- componentServiceUrlString);
+
+ try {
+ domainProxy.registerServiceEndpoint(node.getDomain().getURI(),
+ node.getURI(),
+ componentServiceName,
+ SCABinding.class.getName(),
+ componentServiceUrlString);
} catch(Exception ex) {
logger.log(Level.WARNING,
"Unable to register service: " +
- node.getDomainURI() + " " +
- node.getNodeURI() + " " +
+ node.getDomain().getURI() + " " +
+ node.getURI() + " " +
componentServiceName + " " +
SCABinding.class.getName() + " " +
componentServiceUrlString);
}
- } else {
- /* don't think we should thrown an exception here as it
- * may be a stand alone node
- throw new IllegalStateException("No service manager available for component: "+
- component.getName() +
- " and service: " +
- service.getName());
- */
- }
- } else {
- throw new IllegalStateException("No distributed domain available for component: "+
- component.getName() +
- " and service: " +
- service.getName());
- }
+ }
+ } else {
+ throw new IllegalStateException("No domain available for component: "+
+ component.getName() +
+ " and service: " +
+ service.getName());
+ }
}
Modified: incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/AsynchTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/AsynchTestCase.java?rev=581897&r1=581896&r2=581897&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/AsynchTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/AsynchTestCase.java Thu Oct 4 06:40:50 2007
@@ -29,8 +29,8 @@
public class AsynchTestCase extends BaseTest {
- public static TestDomain domainA;
- public static TestDomain domainB;
+ public static TestNode nodeA;
+ public static TestNode nodeB;
@BeforeClass
public static void init() throws Exception {
@@ -38,8 +38,8 @@
try {
// create and start domains
- domainA = createDomain("nodeG");
- domainB = createDomain("nodeH");
+ nodeA = createNode("nodeG");
+ nodeB = createNode("nodeH");
} catch (Exception ex) {
System.err.println("Exception when creating domain " + ex.getMessage());
@@ -50,14 +50,14 @@
@AfterClass
public static void destroy() throws Exception {
- domainA.stop();
- domainB.stop();
+ nodeA.stop();
+ nodeB.stop();
}
@Test
public void testHelloWorldAsynch() throws Exception {
HelloWorldClient helloWorldClientB;
- helloWorldClientB = domainA.getService(HelloWorldClient.class, "AHelloWorldClientCallbackRemote");
+ helloWorldClientB = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientCallbackRemote");
helloWorldClientB.getGreetings("fred");
System.out.println("Sleeping ...");
Thread.sleep(2000);
Modified: incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/BaseTest.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/BaseTest.java?rev=581897&r1=581896&r2=581897&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/BaseTest.java (original)
+++ incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/BaseTest.java Thu Oct 4 06:40:50 2007
@@ -22,10 +22,10 @@
public class BaseTest {
public static String DEFULT_DOMAIN_NAME = "mydomain";
- public static TestServiceDiscoveryImpl serviceDiscovery = new TestServiceDiscoveryImpl();
+ public static TestDomain testDomain = new TestDomain(DEFULT_DOMAIN_NAME);
- public static TestDomain createDomain(String nodeName) throws Exception {
+ public static TestNode createNode(String nodeName) throws Exception {
- return new TestDomain(DEFULT_DOMAIN_NAME, nodeName,serviceDiscovery);
+ return new TestNode(DEFULT_DOMAIN_NAME, nodeName, testDomain);
}
}
Modified: incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/CallbackTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/CallbackTestCase.java?rev=581897&r1=581896&r2=581897&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/CallbackTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/CallbackTestCase.java Thu Oct 4 06:40:50 2007
@@ -27,8 +27,8 @@
public class CallbackTestCase extends BaseTest {
- public static TestDomain domainA;
- public static TestDomain domainB;
+ public static TestNode nodeA;
+ public static TestNode nodeB;
@BeforeClass
public static void init() throws Exception {
@@ -36,8 +36,8 @@
try {
// create and start domains
- domainA = createDomain("nodeE");
- domainB = createDomain("nodeF");
+ nodeA = createNode("nodeE");
+ nodeB = createNode("nodeF");
} catch (Exception ex) {
System.err.println("Exception when creating domain " + ex.getMessage());
@@ -48,21 +48,21 @@
@AfterClass
public static void destroy() throws Exception {
- domainA.stop();
- domainB.stop();
+ nodeA.stop();
+ nodeB.stop();
}
//@Test
public void testHelloWorldCallbackLocal() throws Exception {
HelloWorldClient helloWorldClientB;
- helloWorldClientB = domainB.getService(HelloWorldClient.class, "BHelloWorldClientCallbackLocal");
+ helloWorldClientB = nodeB.getService(HelloWorldClient.class, "BHelloWorldClientCallbackLocal");
Assert.assertEquals("Hello callback fred", helloWorldClientB.getGreetings("fred"));
}
@Test
public void testHelloWorldCallbackRemote() throws Exception {
HelloWorldClient helloWorldClientA;
- helloWorldClientA = domainA.getService(HelloWorldClient.class, "AHelloWorldClientCallbackRemote");
+ helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientCallbackRemote");
Assert.assertEquals("Hello callback fred", helloWorldClientA.getGreetings("fred"));
}
Modified: incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/PromotionTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/PromotionTestCase.java?rev=581897&r1=581896&r2=581897&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/PromotionTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/PromotionTestCase.java Thu Oct 4 06:40:50 2007
@@ -24,8 +24,8 @@
public class PromotionTestCase extends BaseTest {
- public static TestDomain domainA;
- public static TestDomain domainB;
+ public static TestNode nodeA;
+ public static TestNode nodeB;
@BeforeClass
public static void init() throws Exception {
@@ -33,8 +33,8 @@
try {
// create and start domains
- domainA = createDomain("nodeC");
- domainB = createDomain("nodeD");
+ nodeA = createNode("nodeC");
+ nodeB = createNode("nodeD");
} catch (Exception ex) {
@@ -46,15 +46,15 @@
@AfterClass
public static void destroy() throws Exception {
- domainA.stop();
- domainB.stop();
+ nodeA.stop();
+ nodeB.stop();
}
@Test
public void testHelloWorldPromotion() throws Exception {
/*
HelloWorldClient helloWorldClientA;
- helloWorldClientA = domainA.getService(HelloWorldClient.class, "AHelloWorldClientRemotePromotion");
+ helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientRemotePromotion");
Assert.assertEquals(helloWorldClientA.getGreetings("fred"), "Hello fred");
*/
}
Modified: incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/SimpleTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/SimpleTestCase.java?rev=581897&r1=581896&r2=581897&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/SimpleTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/SimpleTestCase.java Thu Oct 4 06:40:50 2007
@@ -27,8 +27,8 @@
public class SimpleTestCase extends BaseTest {
- public static TestDomain domainA;
- public static TestDomain domainB;
+ public static TestNode nodeA;
+ public static TestNode nodeB;
@BeforeClass
public static void init() throws Exception {
@@ -36,8 +36,8 @@
try {
// create and start domains
- domainA = createDomain("nodeA");
- domainB = createDomain("nodeB");;
+ nodeA = createNode("nodeA");
+ nodeB = createNode("nodeB");;
} catch (Exception ex) {
System.err.println("Exception when creating domain " + ex.getMessage());
@@ -48,13 +48,13 @@
@AfterClass
public static void destroy() throws Exception {
- domainA.stop();
- domainB.stop();
+ nodeA.stop();
+ nodeB.stop();
}
@Test
public void testHelloWorldLocal() throws Exception {
- HelloWorldClient helloWorldClientA = domainA.getService(HelloWorldClient.class, "AHelloWorldClientLocal");
+ HelloWorldClient helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientLocal");
Assert.assertEquals(helloWorldClientA.getGreetings("fred"), "Hello fred");
}
@@ -62,24 +62,24 @@
@Test
public void testHelloWorldRemote() throws Exception {
HelloWorldClient helloWorldClientA;
- helloWorldClientA = domainA.getService(HelloWorldClient.class, "AHelloWorldClientRemote");
+ helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientRemote");
Assert.assertEquals(helloWorldClientA.getGreetings("fred"), "Hello fred");
}
@Test
public void testHelloWorldLocalAndRemote() throws Exception {
- HelloWorldClient helloWorldClientA = domainA.getService(HelloWorldClient.class, "AHelloWorldClientLocalAndRemote");
- HelloWorldClient helloWorldClientB = domainB.getService(HelloWorldClient.class, "BHelloWorldClientLocalAndRemote");
+ HelloWorldClient helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientLocalAndRemote");
+ HelloWorldClient helloWorldClientB = nodeB.getService(HelloWorldClient.class, "BHelloWorldClientLocalAndRemote");
Assert.assertEquals(helloWorldClientA.getGreetings("fred"), "Hello fred");
Assert.assertEquals(helloWorldClientB.getGreetings("fred"), "Hello fred");
}
@Test
public void testHelloWorldMultipleServices() throws Exception {
- HelloWorldClient helloWorldClientA = domainA.getService(HelloWorldClient.class, "AHelloWorldClientMultipleServices");
- HelloWorldClient helloWorldClientA2 = domainA.getService(HelloWorldClient.class, "AHelloWorldClientMultipleServices2");
- HelloWorldClient helloWorldClientB = domainB.getService(HelloWorldClient.class, "BHelloWorldClientMultipleServices");
+ HelloWorldClient helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientMultipleServices");
+ HelloWorldClient helloWorldClientA2 = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientMultipleServices2");
+ HelloWorldClient helloWorldClientB = nodeB.getService(HelloWorldClient.class, "BHelloWorldClientMultipleServices");
Assert.assertEquals(helloWorldClientA.getGreetings("fred"), "Hello fred");
Assert.assertEquals(helloWorldClientA2.getGreetings("fred"), "Hello fred");
Assert.assertEquals(helloWorldClientB.getGreetings("fred"), "Hello fred");
@@ -88,7 +88,7 @@
//@Test
public void testHelloWorldMultipleBindings() throws Exception {
HelloWorldClient helloWorldClientA;
- helloWorldClientA = domainA.getService(HelloWorldClient.class, "AHelloWorldClientMultipleBindings");
+ helloWorldClientA = nodeA.getService(HelloWorldClient.class, "AHelloWorldClientMultipleBindings");
Assert.assertEquals(helloWorldClientA.getGreetings("fred"), "Hello fred");
}
Modified: incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/TestDomain.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/TestDomain.java?rev=581897&r1=581896&r2=581897&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/TestDomain.java (original)
+++ incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/TestDomain.java Thu Oct 4 06:40:50 2007
@@ -20,6 +20,8 @@
package org.apache.tuscany.sca.binding.sca.axis2;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
import javax.xml.namespace.QName;
@@ -34,14 +36,16 @@
import org.apache.tuscany.sca.contribution.Contribution;
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.SCADomainService;
+import org.apache.tuscany.sca.domain.DomainException;
+import org.apache.tuscany.sca.domain.NodeInfo;
+import org.apache.tuscany.sca.domain.SCADomain;
+import org.apache.tuscany.sca.domain.SCADomainSPI;
+import org.apache.tuscany.sca.domain.ServiceInfo;
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.ComponentManager;
-import org.apache.tuscany.sca.node.ContributionManager;
+import org.apache.tuscany.sca.node.NodeException;
import org.apache.tuscany.sca.node.SCANode;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentContext;
@@ -56,212 +60,186 @@
*
* @version $Rev: 552343 $ $Date$
*/
-public class TestDomain implements SCANode {
+public class TestDomain implements SCADomainSPI {
- private String nodeName;
private String domainURI;
- private static SCADomainService serviceDiscovery;
- private ReallySmallRuntime nodeRuntime;
-
- private ClassLoader cl = BaseTest.class.getClassLoader();
- private Composite nodeComposite = null;
- public TestDomain(String domainURI, String nodeName, TestServiceDiscoveryImpl serviceDiscovery)
- throws Exception {
+ public TestDomain(String domainURI) {
this.domainURI = domainURI;
- this.nodeName = nodeName;
- this.serviceDiscovery = serviceDiscovery;
-
- try {
-
- // create and start domainA
- nodeRuntime = new ReallySmallRuntime(cl);
- nodeRuntime.start();
-
- // Create an in-memory domain level composite
- AssemblyFactory assemblyFactory = nodeRuntime.getAssemblyFactory();
- nodeComposite = assemblyFactory.createComposite();
- nodeComposite.setName(new QName(Constants.SCA10_NS, "domain"));
- nodeComposite.setURI(domainURI);
-
- // add the top level composite into the composite activator
- nodeRuntime.getCompositeActivator().setDomainComposite(nodeComposite);
-
- // make the domain available to the model.
- ModelFactoryExtensionPoint factories = nodeRuntime.getExtensionPointRegistry().getExtensionPoint(ModelFactoryExtensionPoint.class);
- NodeFactoryImpl domainFactory = new NodeFactoryImpl(this);
- factories.addFactory(domainFactory);
-
- // add a contribution to the domain
- ContributionService contributionService = nodeRuntime.getContributionService();
-
- // find the current directory as a URL. This is where our contribution
- // will come from
- URL contributionURL = Thread.currentThread().getContextClassLoader().getResource(nodeName + "/");
-
- // Contribute the SCA application
- Contribution contribution = contributionService.contribute("http://calculator", contributionURL, null, //resolver,
- false);
- Composite composite = contribution.getDeployables().get(0);
-
- // Add the deployable composite to the domain
- nodeComposite.getIncludes().add(composite);
- nodeRuntime.getCompositeBuilder().build(composite);
- nodeRuntime.getCompositeActivator().activate(composite);
- nodeRuntime.getCompositeActivator().start(composite);
-
- } catch (Exception ex) {
- System.err.println("Exception when creating domain " + ex.getMessage());
- ex.printStackTrace(System.err);
- throw ex;
- }
}
- public void start()
- throws ActivationException {
+ public void start() throws DomainException {
}
- public void stop()
- throws ActivationException {
- nodeRuntime.stop();
+ public void stop() throws DomainException {
}
- public String getNodeURI(){
- return nodeName;
- }
-
- public String getDomainURI(){
+ public String getURI(){
return domainURI;
- }
+ }
+
+ List<ServiceEndpoint> serviceEndpoints = new ArrayList<ServiceEndpoint>();
- public URL getNodeURL(){
+ public class ServiceEndpoint {
+ private String domainUri;
+ private String nodeUri;
+ private String serviceName;
+ private String bindingName;
+ private String url;
+
+ public ServiceEndpoint(String domainUri, String nodeUri, String serviceName, String bindingName, String URL){
+ this.domainUri = domainUri;
+ this.nodeUri = nodeUri;
+ this.serviceName = serviceName;
+ this.bindingName = bindingName;
+ this.url = URL;
+ }
+
+ public boolean match(String domainUri, String serviceName, String bindingName) {
+ // trap the case where the we are trying to map
+ // ComponentName/Service name with a registered ComponentName - this is OK
+ // ComponentName with a registered ComponentName/ServiceName - this should fail
+
+ boolean serviceNameMatch = false;
+
+ if (this.serviceName.equals(serviceName)) {
+ serviceNameMatch = true;
+ } else {
+ int s = serviceName.indexOf('/');
+ if ((s != -1) &&
+ (this.serviceName.equals(serviceName.substring(0, s)))){
+ serviceNameMatch = true;
+ }
+ }
+
+ return ((this.domainUri.equals(domainUri)) &&
+ (serviceNameMatch) &&
+ (this.bindingName.equals(bindingName)));
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ @Override
+ public String toString (){
+ return "[" +
+ domainUri + " " +
+ nodeUri + " " +
+ serviceName + " " +
+ bindingName + " " +
+ url +
+ "]";
+ }
+ }
+
+ public List<NodeInfo> getNodeInfo() {
return null;
- }
+ }
+
+ /**
+ * Accepts information about a service endpoint and holds onto it
+ *
+ * @param domainUri the string uri for the distributed domain
+ * @param nodeUri the string uri for the current node
+ * @param serviceName the name of the service that is exposed and the provided endpoint
+ * @param bindingName the remote binding that is providing the endpoint
+ * @param url the enpoint url
+ */
+ 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;
+ }
+ ServiceEndpoint serviceEndpoint = new ServiceEndpoint (domainUri, nodeUri, modifiedServiceName, bindingName, URL);
+ serviceEndpoints.add(serviceEndpoint);
+ System.err.println("Registering service: " + serviceEndpoint.toString());
+ return "";
+ }
+
+ public String removeServiceEndpoint(String domainUri, String nodeUri, String serviceName, String bindingName){
+ return "";
+ }
+ /**
+ * Locates information about a service endpoint
+ *
+ * @param domainUri the string uri for the distributed domain
+ * @param serviceName the name of the service that is exposed and the provided endpoint
+ * @param bindingName the remote binding that we want to find an endpoint for
+ * @return url the endpoint url
+ */
+ public String findServiceEndpoint(String domainUri, String serviceName, String bindingName){
+ System.err.println("Finding service: [" +
+ domainUri + " " +
+ serviceName + " " +
+ bindingName +
+ "]");
+
+ String url = null;
+
+ for(ServiceEndpoint serviceEndpoint : serviceEndpoints){
+ if ( serviceEndpoint.match(domainUri, serviceName, bindingName)){
+ url = serviceEndpoint.getUrl();
+ System.err.println("Matching service url: " + url);
+ }
+ }
+ return url;
+ }
- public URL getDomainURL(){
+ public ServiceInfo getServiceInfo() {
+ // TODO Auto-generated method stub
return null;
- }
+ }
- public SCADomainService getDomainService(){
- return serviceDiscovery;
- }
+ public SCADomain getDomain(){
+ return null;
+ }
- public ContributionManager getContributionManager(){
+ public String addNode(String nodeURI, String nodeURL){
return null;
}
- public ComponentManager getComponentManager(){
+
+ public String removeNode(String nodeURI){
return null;
- }
+ }
- public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException {
- return null;
+ public void addContribution(String contributionURI, URL contributionURL) throws DomainException {
}
+
- public <B> B getService(Class<B> businessInterface, String serviceName) {
- ServiceReference<B> serviceReference = getServiceReference(businessInterface, serviceName);
- if (serviceReference == null) {
- throw new ServiceRuntimeException("Service not found: " + serviceName);
- }
- return serviceReference.getService();
+ public void removeContribution(String contributionURI) throws DomainException {
+ }
+
+ public void addComposite(QName qname) throws DomainException {
+ }
+
+ public void removeComposite(QName qname) throws DomainException {
+ }
+
+ public void startComposite(QName compositeName) throws DomainException {
}
- private <B> ServiceReference<B> createServiceReference(Class<B> businessInterface, String targetURI) {
- try {
- AssemblyFactory assemblyFactory = nodeRuntime.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");
- nodeRuntime.getCompositeActivator().configureComponentContext(component);
- composite.getComponents().add(component);
- RuntimeComponentReference reference = (RuntimeComponentReference)assemblyFactory.createComponentReference();
- reference.setName("default");
- ModelFactoryExtensionPoint factories =
- nodeRuntime.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, nodeRuntime
- .getProxyFactory(), nodeRuntime.getCompositeActivator());
- } catch (Exception e) {
- throw new ServiceRuntimeException(e);
- }
+ public void stopComposite(QName compositeName) 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) {
-
- // 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 in the domain
-
- Component component = null;
-
- for (Composite composite: nodeComposite.getIncludes()) {
- for (Component componentLoop: composite.getComponents()) {
- if (componentLoop.getName().equals(componentName)) {
- component = componentLoop;
- break;
- }
- }
- }
- if (component == null) {
- // The component is not local in the partition, try to create a remote service ref
- return createServiceReference(businessInterface, name);
- }
- 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);
- }
- }
+ return null;
}
Added: incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/TestNode.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/TestNode.java?rev=581897&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/TestNode.java (added)
+++ incubator/tuscany/java/sca/modules/binding-sca-axis2/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/TestNode.java Thu Oct 4 06:40:50 2007
@@ -0,0 +1,263 @@
+/*
+ * 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.binding.sca.axis2;
+
+import java.net.URL;
+
+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.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.service.ContributionService;
+import org.apache.tuscany.sca.core.context.ServiceReferenceImpl;
+import org.apache.tuscany.sca.domain.SCADomain;
+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.NodeException;
+import org.apache.tuscany.sca.node.SCANode;
+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.ServiceReference;
+import org.osoa.sca.ServiceRuntimeException;
+
+/**
+ * The very minimum domain implementation to get these tests going without creating a dependency on
+ * domain-impl
+ *
+ * @version $Rev: 552343 $ $Date: 2007-09-20 14:53:40 +0100 (Thu, 20 Sep 2007) $
+ */
+public class TestNode implements SCANode {
+
+ private String nodeName;
+ private String domainURI;
+ private ReallySmallRuntime nodeRuntime;
+
+ private ClassLoader cl = BaseTest.class.getClassLoader();
+ private Composite nodeComposite = null;
+
+ private SCADomain scaDomain;
+
+
+ public TestNode(String domainURI, String nodeName, SCADomain domain)
+ throws Exception {
+ this.domainURI = domainURI;
+ this.nodeName = nodeName;
+ this.scaDomain = domain;
+
+ try {
+
+ // create and start domainA
+ nodeRuntime = new ReallySmallRuntime(cl);
+ nodeRuntime.start();
+
+ // Create an in-memory domain level composite
+ AssemblyFactory assemblyFactory = nodeRuntime.getAssemblyFactory();
+ nodeComposite = assemblyFactory.createComposite();
+ nodeComposite.setName(new QName(Constants.SCA10_NS, "domain"));
+ nodeComposite.setURI(domainURI);
+
+ // add the top level composite into the composite activator
+ nodeRuntime.getCompositeActivator().setDomainComposite(nodeComposite);
+
+ // make the domain available to the model.
+ ModelFactoryExtensionPoint factories = nodeRuntime.getExtensionPointRegistry().getExtensionPoint(ModelFactoryExtensionPoint.class);
+ NodeFactoryImpl domainFactory = new NodeFactoryImpl(this);
+ factories.addFactory(domainFactory);
+
+ // add a contribution to the domain
+ ContributionService contributionService = nodeRuntime.getContributionService();
+
+ // find the current directory as a URL. This is where our contribution
+ // will come from
+ URL contributionURL = Thread.currentThread().getContextClassLoader().getResource(nodeName + "/");
+
+ // Contribute the SCA application
+ Contribution contribution = contributionService.contribute("http://calculator", contributionURL, null, //resolver,
+ false);
+ Composite composite = contribution.getDeployables().get(0);
+
+ // Add the deployable composite to the domain
+ nodeComposite.getIncludes().add(composite);
+ nodeRuntime.getCompositeBuilder().build(composite);
+ nodeRuntime.getCompositeActivator().activate(composite);
+ nodeRuntime.getCompositeActivator().start(composite);
+
+ } catch (Exception ex) {
+ System.err.println("Exception when creating domain " + ex.getMessage());
+ ex.printStackTrace(System.err);
+ throw ex;
+ }
+ }
+
+ public void start()
+ throws NodeException {
+
+ }
+
+ public void stop()
+ throws NodeException {
+ try {
+ nodeRuntime.stop();
+ } catch(Exception ex) {
+ throw new NodeException(ex);
+ }
+ }
+
+
+ public String getURI(){
+ return nodeName;
+ }
+
+ public SCADomain getDomain(){
+ return scaDomain;
+ }
+
+ public void addContribution(String contributionURI, URL contributionURL) throws NodeException {
+ addContribution(contributionURI, contributionURL, null);
+ }
+
+ public void addContribution(String contributionURI, URL contributionURL, ClassLoader contributionClassLoader ) throws NodeException {
+
+ }
+
+ public void removeContributions() throws NodeException {
+
+ }
+
+ public void startComposite(QName compositeName) throws NodeException {
+
+ }
+
+ public void stopComposite() throws NodeException {
+
+ }
+
+ public <B> B getService(Class<B> businessInterface, String serviceName) {
+ ServiceReference<B> serviceReference = getServiceReference(businessInterface, serviceName);
+ if (serviceReference == null) {
+ throw new ServiceRuntimeException("Service not found: " + serviceName);
+ }
+ return serviceReference.getService();
+ }
+
+ private <B> ServiceReference<B> createServiceReference(Class<B> businessInterface, String targetURI) {
+ try {
+ AssemblyFactory assemblyFactory = nodeRuntime.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");
+ nodeRuntime.getCompositeActivator().configureComponentContext(component);
+ composite.getComponents().add(component);
+ RuntimeComponentReference reference = (RuntimeComponentReference)assemblyFactory.createComponentReference();
+ reference.setName("default");
+ ModelFactoryExtensionPoint factories =
+ nodeRuntime.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, nodeRuntime
+ .getProxyFactory(), nodeRuntime.getCompositeActivator());
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String name) {
+
+ // 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 in the domain
+
+ Component component = null;
+
+ for (Composite composite: nodeComposite.getIncludes()) {
+ for (Component componentLoop: composite.getComponents()) {
+ if (componentLoop.getName().equals(componentName)) {
+ component = componentLoop;
+ break;
+ }
+ }
+ }
+ if (component == null) {
+ // The component is not local in the partition, try to create a remote service ref
+ return createServiceReference(businessInterface, name);
+ }
+ 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);
+ }
+ }
+ }
+}
Modified: incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCAReferenceBindingProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCAReferenceBindingProvider.java?rev=581897&r1=581896&r2=581897&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCAReferenceBindingProvider.java (original)
+++ incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCAReferenceBindingProvider.java Thu Oct 4 06:40:50 2007
@@ -23,7 +23,7 @@
import org.apache.tuscany.sca.assembly.SCABinding;
import org.apache.tuscany.sca.binding.sca.DistributedSCABinding;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.domain.SCADomainService;
+import org.apache.tuscany.sca.domain.SCADomainSPI;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Invoker;
@@ -99,10 +99,10 @@
// at this node. The binding uri might be null here if the dynamic reference has been
// fully configured yet. It won't have all of the information until invocation time
if ((node != null) && (binding.getURI() != null)) {
- SCADomainService serviceDiscovery = node.getDomainService();
+ SCADomainSPI domainProxy = (SCADomainSPI)node.getDomain();
String serviceUrl =
- serviceDiscovery.findServiceEndpoint(node.getDomainURI(),
+ domainProxy.findServiceEndpoint(node.getDomain().getURI(),
binding.getURI(),
SCABinding.class.getName());
if ((serviceUrl == null) || serviceUrl.equals("")) {
Modified: incubator/tuscany/java/sca/modules/domain-api/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-api/pom.xml?rev=581897&r1=581896&r2=581897&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/domain-api/pom.xml (original)
+++ incubator/tuscany/java/sca/modules/domain-api/pom.xml Thu Oct 4 06:40:50 2007
@@ -28,7 +28,7 @@
</parent>
<artifactId>tuscany-domain-api</artifactId>
- <name>Apache Tuscany SCA Node API</name>
+ <name>Apache Tuscany SCA Domain API</name>
<dependencies>
<dependency>
Added: incubator/tuscany/java/sca/modules/domain-api/src/main/java/org/apache/tuscany/sca/domain/DomainException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-api/src/main/java/org/apache/tuscany/sca/domain/DomainException.java?rev=581897&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/domain-api/src/main/java/org/apache/tuscany/sca/domain/DomainException.java (added)
+++ incubator/tuscany/java/sca/modules/domain-api/src/main/java/org/apache/tuscany/sca/domain/DomainException.java Thu Oct 4 06:40:50 2007
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.domain;
+
+
+/**
+ * Denotes an error starting the runtime
+ *
+ * @version $Rev: 568826 $ $Date: 2007-08-23 06:27:34 +0100 (Thu, 23 Aug 2007) $
+ */
+public class DomainException extends Exception {
+
+ static final long serialVersionUID = 2096658015909178325L;
+
+ public DomainException(String message) {
+ super(message);
+ }
+
+ public DomainException(Throwable cause) {
+ super(cause);
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org