summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/distribution/tomcat/tomcat-hook
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-03-22 08:28:29 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-03-22 08:28:29 +0000
commitfe6b55056d4afd1a9d3caf8806a1986e97c26ae7 (patch)
treecabd2ab5699e38615ed1957ebba28bb727857b33 /sca-java-2.x/trunk/distribution/tomcat/tomcat-hook
parentf954cf1a6fc059e30a63ffcef953d6e40a0fd917 (diff)
Remove commons logging from tomcat war license
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@925994 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/distribution/tomcat/tomcat-hook')
-rw-r--r--sca-java-2.x/trunk/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.java25
1 files changed, 21 insertions, 4 deletions
diff --git a/sca-java-2.x/trunk/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.java b/sca-java-2.x/trunk/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.java
index 8b7af4c268..ca9c81f1c3 100644
--- a/sca-java-2.x/trunk/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.java
+++ b/sca-java-2.x/trunk/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.java
@@ -20,7 +20,6 @@
package org.apache.tuscany.sca.tomcat;
import java.io.File;
-import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.net.URI;
import java.net.URL;
@@ -31,6 +30,7 @@ import javax.naming.NameClassPair;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
+import org.apache.catalina.LifecycleException;
import org.apache.catalina.Loader;
import org.apache.catalina.core.StandardContext;
@@ -49,6 +49,9 @@ public class TuscanyStandardContext extends StandardContext {
// TODO: this gives an instance per webapp, work out how to have only one per server
// ?? is that comment still true?
private static URLClassLoader tuscanyClassLoader;
+ private static Object node;
+ private static Class<?> nodeClass;
+ private static Method nodeStopMethod;
public TuscanyStandardContext() {
}
@@ -165,9 +168,10 @@ public class TuscanyStandardContext extends StandardContext {
Object instance = getInstanceMethod.invoke(null);
Method createNodeMethod = nodeFactoryClass.getMethod("createNode", new Class[]{URI.class, new String[0].getClass()});
URI domainURI = URI.create(TuscanyLifecycleListener.getDomainURI());
- Object node = createNodeMethod.invoke(instance, new Object[]{domainURI, new String[0]});
- Class<?> nodeClass = Class.forName("org.apache.tuscany.sca.node.Node", true, tuscanyClassLoader);
+ this.node = createNodeMethod.invoke(instance, new Object[]{domainURI, new String[0]});
+ this.nodeClass = Class.forName("org.apache.tuscany.sca.node.Node", true, tuscanyClassLoader);
Method nodeStartMethod = nodeClass.getMethod("start", new Class[0]);
+ this.nodeStopMethod = nodeClass.getMethod("stop", new Class[0]);
nodeStartMethod.invoke(node);
} catch (Exception e) {
throw new RuntimeException(e);
@@ -175,5 +179,18 @@ public class TuscanyStandardContext extends StandardContext {
Thread.currentThread().setContextClassLoader(oldCL);
}
}
-
+
+ @Override
+ public synchronized void stop() throws LifecycleException {
+ super.stop();
+
+ if (node != null && nodeStopMethod != null) {
+ try {
+ nodeStopMethod.invoke(node);
+ node = null;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
}