Author: slaws
Date: Mon Feb 20 12:50:59 2012
New Revision: 1291234
URL: http://svn.apache.org/viewvc?rev=1291234&view=rev
Log:
TUSCANY-4016 - when a composite fails to start ensure that it is stopped and
move it to the stopped list so that calls to remove unused contributions work.
Added:
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/ (with props)
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/pom.xml
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/java/
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/java/helloworld/
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/java/helloworld/HelloWorldClientImpl.java
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/java/helloworld/HelloWorldImpl.java
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/java/helloworld/HelloWorldService.java
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/resources/
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/resources/META-INF/
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/resources/META-INF/sca-contribution.xml
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/resources/helloworld.composite
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/test/
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/test/java/
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/test/java/helloworld/
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/test/java/helloworld/DomainNodeTestCase.java
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/test/resources/
Modified:
tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
tuscany/sca-java-2.x/trunk/testing/itest/nodes/pom.xml
Modified:
tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java?rev=1291234&r1=1291233&r2=1291234&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
Mon Feb 20 12:50:59 2012
@@ -348,18 +348,34 @@ public class NodeImpl implements Node {
throw new IllegalStateException("composite already started: " +
compositeURI);
}
DeployedComposite dc = stoppedComposites.remove(key);
- if (dc != null) {
- dc.start();
- startedComposites.put(key, dc);
- } else {
- ContributionDescription cd =
getInstalledContribution(contributionURI);
- Contribution contribution = loadContribution(cd);
- Composite composite = contribution.getArtifactModel(compositeURI);
- List<Contribution> dependentContributions =
calculateDependentContributions(cd);
- dc = new DeployedComposite(composite, contribution,
dependentContributions, deployer, compositeActivator, domainRegistry,
extensionPointRegistry, endpointsIncludeDomainName);
- dc.start();
- startedComposites.put(key, dc);
- }
+ try {
+ if (dc != null) {
+ dc.start();
+ startedComposites.put(key, dc);
+ } else {
+ ContributionDescription cd =
getInstalledContribution(contributionURI);
+ Contribution contribution = loadContribution(cd);
+ Composite composite =
contribution.getArtifactModel(compositeURI);
+ List<Contribution> dependentContributions =
calculateDependentContributions(cd);
+ dc = new DeployedComposite(composite, contribution,
dependentContributions, deployer, compositeActivator, domainRegistry,
extensionPointRegistry, endpointsIncludeDomainName);
+ dc.start();
+ startedComposites.put(key, dc);
+ }
+ }catch(ActivationException e){
+ if(dc != null){
+ try {
+ // try to stop the composite. This should have already
happened
+ // in the activator if the composite failed to start but
we're
+ // being sure
+ dc.stop();
+ } catch (Exception ex) {
+ // do nothing as we are going to throw the
+ // original exception
+ }
+ stoppedComposites.put(key, dc);
+ }
+ throw e;
+ }
if (logger.isLoggable(quietLogging? Level.FINE : Level.INFO))
logger.log(quietLogging? Level.FINE : Level.INFO, "startComposite: " + key);
}
@@ -395,18 +411,22 @@ public class NodeImpl implements Node {
public void stopCompositeAndUninstallUnused(String contributionURI, String
compositeURI) throws ActivationException {
String key = contributionURI+"/"+compositeURI;
DeployedComposite dc = startedComposites.remove(key);
- if (dc == null) {
- throw new IllegalArgumentException("No startd composite found: " +
key);
+ if (dc != null) {
+ dc.stop();
+ } else {
+ // check in the stopped list in case it stopped on failure during
start
+ dc = stoppedComposites.get(key);
}
- dc.stop();
- loop: for (String curi : dc.getContributionURIs()) {
- for (DeployedComposite started : startedComposites.values()) {
- if (started.getContributionURIs().contains(curi)) {
- continue loop;
+ if (dc != null) {
+ loop: for (String curi : dc.getContributionURIs()) {
+ for (DeployedComposite started : startedComposites.values()) {
+ if (started.getContributionURIs().contains(curi)) {
+ continue loop;
+ }
}
+ uninstallContribution(curi);
}
- uninstallContribution(curi);
}
if (logger.isLoggable(quietLogging? Level.FINE : Level.INFO))
logger.log(quietLogging? Level.FINE : Level.INFO,
"stopCompositeAndUninstallUnused: " + key);
}
Propchange: tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Feb 20 12:50:59 2012
@@ -0,0 +1,4 @@
+.classpath
+.project
+.settings
+target
Added: tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/pom.xml
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/pom.xml?rev=1291234&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/pom.xml (added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/pom.xml Mon Feb
20 12:50:59 2012
@@ -0,0 +1,59 @@
+<?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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-nodes</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-node-domain-node</artifactId>
+ <name>Apache Tuscany SCA iTest Node DomainNode</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-base-runtime-pom</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rmi-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+<!--
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ <version>6.1.19</version>
+ </dependency>
+-->
+
+ </dependencies>
+
+ <build>
+ <finalName>${project.artifactId}</finalName>
+ </build>
+
+</project>
Added:
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/java/helloworld/HelloWorldClientImpl.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/java/helloworld/HelloWorldClientImpl.java?rev=1291234&view=auto
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/java/helloworld/HelloWorldClientImpl.java
(added)
+++
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/java/helloworld/HelloWorldClientImpl.java
Mon Feb 20 12:50:59 2012
@@ -0,0 +1,37 @@
+/*
+ * 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 helloworld;
+
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(HelloWorldService.class)
+public class HelloWorldClientImpl implements HelloWorldService {
+
+ @Reference
+ protected HelloWorldService hwService;
+
+ public String getGreetings(String name) {
+ return "Hello " + hwService.getGreetings(name);
+ }
+}
Added:
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/java/helloworld/HelloWorldImpl.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/java/helloworld/HelloWorldImpl.java?rev=1291234&view=auto
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/java/helloworld/HelloWorldImpl.java
(added)
+++
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/java/helloworld/HelloWorldImpl.java
Mon Feb 20 12:50:59 2012
@@ -0,0 +1,32 @@
+/*
+ * 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 helloworld;
+
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(HelloWorldService.class)
+public class HelloWorldImpl implements HelloWorldService {
+
+ public String getGreetings(String name) {
+ return "Hello " + name;
+ }
+}
Added:
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/java/helloworld/HelloWorldService.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/java/helloworld/HelloWorldService.java?rev=1291234&view=auto
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/java/helloworld/HelloWorldService.java
(added)
+++
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/java/helloworld/HelloWorldService.java
Mon Feb 20 12:50:59 2012
@@ -0,0 +1,33 @@
+/*
+ * 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 helloworld;
+
+import javax.jws.WebService;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldService {
+
+ public String getGreetings(String name);
+}
+
Added:
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/resources/META-INF/sca-contribution.xml
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/resources/META-INF/sca-contribution.xml?rev=1291234&view=auto
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/resources/META-INF/sca-contribution.xml
(added)
+++
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/resources/META-INF/sca-contribution.xml
Mon Feb 20 12:50:59 2012
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:hw="http://helloworld">
+ <deployable composite="hw:helloworldws" />
+</contribution>
Added:
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/resources/helloworld.composite
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/resources/helloworld.composite?rev=1291234&view=auto
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/resources/helloworld.composite
(added)
+++
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/main/resources/helloworld.composite
Mon Feb 20 12:50:59 2012
@@ -0,0 +1,47 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://helloworld"
+ xmlns:hw="http://helloworld"
+ xmlns:wsdli="http://www.w3.org/ns/wsdl-instance"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ name="helloworldws">
+
+ <component name="HelloWorldClientComponent">
+ <implementation.java class="helloworld.HelloWorldClientImpl" />
+ <service name="HelloWorldService">
+ <binding.sca/>
+ </service>
+ <reference name="hwService" target="HelloWorldServiceComponent">
+<!--
+ <binding.ws
uri="http://localhost:8085/HelloWorldServiceComponent"/>
+-->
+ </reference>
+ </component>
+
+ <component name="HelloWorldServiceComponent">
+ <implementation.java class="helloworld.HelloWorldImpl" />
+ <service name="HelloWorldService">
+ <tuscany:binding.rmi uri="rmi://duffuri"/>
+ </service>
+ </component>
+
+</composite>
Added:
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/test/java/helloworld/DomainNodeTestCase.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/test/java/helloworld/DomainNodeTestCase.java?rev=1291234&view=auto
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/test/java/helloworld/DomainNodeTestCase.java
(added)
+++
tuscany/sca-java-2.x/trunk/testing/itest/nodes/domain-node/src/test/java/helloworld/DomainNodeTestCase.java
Mon Feb 20 12:50:59 2012
@@ -0,0 +1,90 @@
+/*
+ * 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 helloworld;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchServiceException;
+
+
+/**
+ * Tests that the helloworld server is available
+ */
+public class DomainNodeTestCase{
+
+ private Node node;
+
+ @Before
+ public void startServer() throws Exception {
+ node = TuscanyRuntime.newInstance().createNode("default");
+ node.installContribution("helloworld", "target/classes", null, null);
+ try {
+ node.startComposite("helloworld", "helloworld.composite");
+ } catch (Exception ex) {
+ System.out.println("Caught exception on composite start : " + ex);
+ }
+ }
+
+ @Ignore
+ @Test
+ public void testWaitForInput() {
+ System.out.println("Press a key to end");
+ try {
+ System.in.read();
+ } catch (Exception ex) {
+ }
+ System.out.println("Shutting down");
+ }
+
+ @Test
+ public void testContributionUninstall() throws IOException,
NoSuchServiceException {
+ List<String> installedContributions =
node.getInstalledContributionURIs();
+ System.out.println(installedContributions);
+
+ assertEquals(1, installedContributions.size());
+
+ try {
+ node.stopCompositeAndUninstallUnused("helloworld",
"helloworld.composite");
+ } catch (Exception ex) {
+ System.out.println("Caught exception on composite stop : " + ex);
+ }
+
+ installedContributions = node.getInstalledContributionURIs();
+ assertEquals(0, installedContributions.size());
+ }
+
+
+ @After
+ public void stopServer() throws Exception {
+ if (node != null) {
+ node.stop();
+ }
+ }
+
+}
Modified: tuscany/sca-java-2.x/trunk/testing/itest/nodes/pom.xml
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/nodes/pom.xml?rev=1291234&r1=1291233&r2=1291234&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/nodes/pom.xml (original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/nodes/pom.xml Mon Feb 20 12:50:59
2012
@@ -58,6 +58,7 @@
<!--
<module>three-nodes-three-vms-test</module>
-->
+ <module>domain-node</module>
</modules>
</project>