summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-01-12 14:12:11 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-01-12 14:12:11 +0000
commit43ee4b5c54e6a8acc6684b7c194126bda27391b3 (patch)
tree27913bca7afa707635133803c59110fb67341f37 /sca-java-2.x/trunk
parent10b62c591f85d60e51cee79d88aecaccf5356a7d (diff)
Start an empty node to initialize the endpoint regsitry before any sca apps are started
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@898334 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk')
-rw-r--r--sca-java-2.x/trunk/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.java35
1 files changed, 32 insertions, 3 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 2a8e066b94..dc6ae2b601 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,6 +20,7 @@
package org.apache.tuscany.sca.tomcat;
import java.io.File;
+import java.lang.reflect.Constructor;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.logging.Logger;
@@ -47,6 +48,9 @@ public class TuscanyStandardContext extends StandardContext {
// ?? is that comment still true?
private static URLClassLoader tuscanyClassLoader;
+ public TuscanyStandardContext() {
+ }
+
/**
* Overrides the getLoader method in the Tomcat StandardContext as its a convenient
* point to insert the Tuscany initilization. This gets called the first time during
@@ -62,6 +66,9 @@ public class TuscanyStandardContext extends StandardContext {
ClassLoader parent = getParentClassLoader();
if (isSCAApp = isSCAApplication()) {
+ if (tuscanyClassLoader == null) {
+ initTuscany();
+ }
setParentClassLoader(getTuscanyClassloader(parent));
setDefaultWebXml("conf/tuscany-web.xml");
}
@@ -121,7 +128,16 @@ public class TuscanyStandardContext extends StandardContext {
return true;
}
- private synchronized URLClassLoader getTuscanyClassloader(ClassLoader parent) {
+ private URLClassLoader getTuscanyClassloader(ClassLoader parent) {
+ return tuscanyClassLoader;
+ }
+
+ private void initTuscany() {
+ initTuscanyClassloader(getParentClassLoader());
+ initDomain();
+ }
+
+ private void initTuscanyClassloader(ClassLoader parent) {
if (tuscanyClassLoader == null) {
File tuscanyWar = new File(System.getProperty(TuscanyLifecycleListener.TUSCANY_WAR_PROP));
File[] runtimeJars = new File(tuscanyWar, "tuscany-lib").listFiles();
@@ -131,12 +147,25 @@ public class TuscanyStandardContext extends StandardContext {
jarURLs[i] = runtimeJars[i].toURI().toURL();
}
tuscanyClassLoader = new URLClassLoader(jarURLs, parent);
- return tuscanyClassLoader;
+
} catch (Exception e) {
throw new RuntimeException(e);
}
}
- return tuscanyClassLoader;
+ }
+
+ private void initDomain() {
+ ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(tuscanyClassLoader);
+ Class<?> domainNodeClass = Class.forName("org.apache.tuscany.sca.domain.node.DomainNode", true, tuscanyClassLoader);
+ Constructor<?> domainNodeConstructor = domainNodeClass.getConstructor(new Class[] {String.class, new String[0].getClass()});
+ domainNodeConstructor.newInstance(TuscanyLifecycleListener.getDomainURI(), new String[0]);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldCL);
+ }
}
}