Author: jsdelfino
Date: Sat Apr 26 12:40:09 2008
New Revision: 651850
URL: http://svn.apache.org/viewvc?rev=651850&view=rev
Log:
A better fix than SVN r651796 for the issue where node.stop() doesn't release
Jetty/Tomcat servers. Instead of stopping the whole runtime, we just stop the
composite loaded in the runtime, like before, but the Jetty and Tomcat servers
now release the HTTP ports in removeServletMapping(), which is more symmetric
too with the logic allocating the ports in addServletMapping().
Modified:
incubator/tuscany/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
incubator/tuscany/java/sca/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java
incubator/tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
Modified:
incubator/tuscany/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java?rev=651850&r1=651849&r2=651850&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
(original)
+++
incubator/tuscany/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
Sat Apr 26 12:40:09 2008
@@ -131,19 +131,18 @@
* Stop all the started servers.
*/
public void stop() {
- if (!ports.isEmpty()) {
- synchronized (joinLock) {
- joinLock.notifyAll();
- }
- try {
- Set<Entry<Integer, Port>> entries = new HashSet<Entry<Integer,
Port>>(ports.entrySet());
- for (Entry<Integer, Port> entry: entries) {
- entry.getValue().getServer().stop();
- ports.remove(entry.getKey());
- }
- } catch (Exception e) {
- throw new ServletMappingException(e);
+ synchronized (joinLock) {
+ joinLock.notifyAll();
+ }
+ try {
+ Set<Entry<Integer, Port>> entries = new HashSet<Entry<Integer,
Port>>(ports.entrySet());
+ for (Entry<Integer, Port> entry: entries) {
+ Port port = entry.getValue();
+ port.getServer().stop();
+ ports.remove(entry.getKey());
}
+ } catch (Exception e) {
+ throw new ServletMappingException(e);
}
}
@@ -394,12 +393,21 @@
throw new IllegalStateException(e);
}
mappings.remove(mapping);
- //logger.info("Remove Servlet mapping: " + path);
+ //logger.info("Removed Servlet mapping: " + path);
break;
}
}
if (removedServlet != null) {
servletHandler.setServletMappings(mappings.toArray(new
ServletMapping[mappings.size()]));
+
+ // Stop the port if there are no servlet mappings on it anymore
+ try {
+ port.getServer().stop();
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ ports.remove(portNumber);
+
} else {
logger.info("Trying to Remove servlet mapping: " + path + " where
mapping is not registered");
}
Modified:
incubator/tuscany/java/sca/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java?rev=651850&r1=651849&r2=651850&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java
(original)
+++
incubator/tuscany/java/sca/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java
Sat Apr 26 12:40:09 2008
@@ -198,8 +198,9 @@
try {
Set<Entry<Integer, Port>> entries = new HashSet<Entry<Integer,
Port>>(ports.entrySet());
for (Entry<Integer, Port> entry : entries) {
- entry.getValue().getConnector().stop();
- entry.getValue().getEngine().stop();
+ Port port = entry.getValue();
+ port.getConnector().stop();
+ port.getEngine().stop();
ports.remove(entry.getKey());
}
} catch (Exception e) {
@@ -509,10 +510,23 @@
try {
servletWrapper.destroyServlet();
} catch (Exception ex) {
- // Temporary hack to stop destruction of Servlets without
Servlet
- // context
+ // Hack to handle destruction of Servlets without Servlet
context
}
- //logger.info("Remove Servlet mapping: " + suri);
+
+ //logger.info("Removed Servlet mapping: " + suri);
+
+ // Stop the port if there's no servlets on it anymore
+ String[] contextNames =
port.getConnector().getMapper().getContextNames();
+ if (contextNames == null || contextNames.length ==0) {
+ try {
+ port.getConnector().stop();
+ port.getEngine().stop();
+ ports.remove(portNumber);
+ } catch (LifecycleException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
return servletWrapper.getServlet();
} else {
logger.info("Trying to Remove servlet mapping: " + mapping + "
where mapping is not registered");
Modified:
incubator/tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java?rev=651850&r1=651849&r2=651850&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
(original)
+++
incubator/tuscany/java/sca/modules/node2-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
Sat Apr 26 12:40:09 2008
@@ -327,9 +327,6 @@
// Deactivate the composite
compositeActivator.deactivate(composite);
- // Stop the runtime
- runtime.stop();
-
} catch (ActivationException e) {
throw new ServiceRuntimeException(e);
}