diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2012-03-04 17:48:55 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2012-03-04 17:48:55 +0000 |
commit | 553a373be707a466b2fdac6eb10568572b6f10a1 (patch) | |
tree | c7be1e7c94ccea4246dbd14ade2577992e430851 /sca-java-2.x/trunk/modules/domain-node/src/main/java | |
parent | 3d87d97115e1f859cb5d452d16ede516908a37f0 (diff) |
TUSCANY-3312 - Copy JavaInterfaceFactory memory leak changes from 1.x + other related changes and some extensions to allow the cache to be reduced when contributions are unloaded in the domain node.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1296845 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.java | 29 |
1 files changed, 27 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 e95dd9f699..9ee36c1e38 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 @@ -38,6 +38,7 @@ import javax.xml.stream.XMLStreamException; import org.apache.tuscany.sca.Node; import org.apache.tuscany.sca.TuscanyRuntime; +import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.xml.Utils; import org.apache.tuscany.sca.common.java.io.IOHelper; @@ -51,8 +52,11 @@ import org.apache.tuscany.sca.contribution.resolver.ClassReference; import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver; import org.apache.tuscany.sca.contribution.resolver.ModelResolver; import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.core.UtilityExtensionPoint; +import org.apache.tuscany.sca.databinding.jaxb.JAXBContextHelper; import org.apache.tuscany.sca.deployment.Deployer; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.ValidationException; import org.apache.tuscany.sca.runtime.ActivationException; @@ -73,6 +77,8 @@ public class NodeImpl implements Node { private CompositeActivator compositeActivator; private DomainRegistry domainRegistry; private ExtensionPointRegistry extensionPointRegistry; + private UtilityExtensionPoint utilityExtensionPoint; + private FactoryExtensionPoint factoryExtensionPoint; private TuscanyRuntime tuscanyRuntime; private Map<String, Contribution> loadedContributions = new ConcurrentHashMap<String, Contribution>(); @@ -95,8 +101,11 @@ public class NodeImpl implements Node { this.domainRegistry = domainRegistry; this.extensionPointRegistry = extensionPointRegistry; this.tuscanyRuntime = tuscanyRuntime; - - extensionPointRegistry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(ActiveNodes.class).getActiveNodes().add(this); + + utilityExtensionPoint = extensionPointRegistry.getExtensionPoint(UtilityExtensionPoint.class); + factoryExtensionPoint = extensionPointRegistry.getExtensionPoint(FactoryExtensionPoint.class); + + utilityExtensionPoint.getUtility(ActiveNodes.class).getActiveNodes().add(this); domainRegistry.addContributionListener(new ContributionListener() { public void contributionInstalled(String uri) { @@ -226,6 +235,21 @@ public class NodeImpl implements Node { } public void uninstallContribution(String contributionURI) { + // give the runtime the chance to release only artifacts + // held by this contribution (and its classloader) + Contribution contribution = loadedContributions.get(contributionURI); + if (contribution != null) { + ClassLoader contributionClassloader = contribution.getClassLoader(); + + // These are very specific at the moment as there is no + // common lifecycle interface at this level + JAXBContextHelper jaxbContextHelper = utilityExtensionPoint.getUtility(JAXBContextHelper.class); + jaxbContextHelper.removeJAXBContextForContribution(contributionClassloader); + + JavaInterfaceFactory javaInterfaceFactory = factoryExtensionPoint.getFactory(JavaInterfaceFactory.class); + javaInterfaceFactory.removeInterfacesForContribution(contributionClassloader); + } + domainRegistry.uninstallContribution(contributionURI); // remove any stopped composite that used the contribution @@ -236,6 +260,7 @@ public class NodeImpl implements Node { i.remove(); } } + if (logger.isLoggable(quietLogging? Level.FINE : Level.INFO)) logger.log(quietLogging? Level.FINE : Level.INFO, "uninstallContribution: " + contributionURI); } |