summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/domain-node/src/main/java
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2011-09-07 12:01:59 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2011-09-07 12:01:59 +0000
commitd54bf09575c67a1d4f75f98e5b700d87ad61aa13 (patch)
tree8f866a2a28de5ca3f8ab574e2a7bbe4caf3de80e /sca-java-2.x/trunk/modules/domain-node/src/main/java
parent292aa4dc6260e72feee974a5c0c6721fb9a2347d (diff)
TUSCANY-3939: when a loaded contribution is unloaded use ClassLoaderUtil.releaseLoader to unloack the jar
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1166140 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/domain-node/src/main/java')
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java20
1 files changed, 18 insertions, 2 deletions
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
index a0889ee9d3..6b601da19d 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
@@ -21,6 +21,7 @@ package org.apache.tuscany.sca.impl;
import java.io.Reader;
import java.io.StringReader;
+import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -60,6 +61,8 @@ import org.apache.tuscany.sca.runtime.DomainRegistry;
import org.apache.tuscany.sca.runtime.RuntimeProperties;
import org.oasisopen.sca.NoSuchServiceException;
+import sun.misc.ClassLoaderUtil;
+
public class NodeImpl implements Node {
private static final Logger logger = Logger.getLogger(NodeImpl.class.getName());
@@ -77,6 +80,8 @@ public class NodeImpl implements Node {
private boolean endpointsIncludeDomainName;
private boolean quietLogging;
+ private boolean releaseOnUnload;
+
public NodeImpl(Deployer deployer,
CompositeActivator compositeActivator,
DomainRegistry domainRegistry,
@@ -92,16 +97,27 @@ public class NodeImpl implements Node {
domainRegistry.addContributionListener(new ContributionListener() {
public void contributionUpdated(String uri) {
- loadedContributions.remove(uri);
+ unloadContribution(uri);
}
public void contributionRemoved(String uri) {
- loadedContributions.remove(uri);
+ unloadContribution(uri);
+ }
+ private void unloadContribution(String curi) {
+ Contribution c = loadedContributions.remove(curi);
+ if (releaseOnUnload && (c != null)) {
+ ClassLoader cl = c.getClassLoader();
+ if (cl instanceof URLClassLoader) {
+ ClassLoaderUtil.releaseLoader((URLClassLoader)cl);
+ }
+ }
}
});
endpointsIncludeDomainName = !TuscanyRuntime.DEFAUL_DOMAIN_NAME.equals(domainRegistry.getDomainName());
UtilityExtensionPoint utilities = extensionPointRegistry.getExtensionPoint(UtilityExtensionPoint.class);
+ this.releaseOnUnload = Boolean.parseBoolean(utilities.getUtility(RuntimeProperties.class).getProperties().getProperty(RuntimeProperties.RELEASE_ON_UNLOAD, "true"));
+
this.quietLogging = Boolean.parseBoolean(utilities.getUtility(RuntimeProperties.class).getProperties().getProperty(RuntimeProperties.QUIET_LOGGING));
if (logger.isLoggable(quietLogging? Level.FINE : Level.INFO)) logger.log(quietLogging? Level.FINE : Level.INFO, "domain: " + domainRegistry.getDomainName() + (!domainRegistry.getDomainName().equals(domainRegistry.getDomainURI()) ? "" : (" domainURI: " + domainRegistry.getDomainURI())));
}