summaryrefslogtreecommitdiffstats
path: root/java/sca/modules
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-10-17 10:07:39 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-10-17 10:07:39 +0000
commitf632baf20a563299023dbbf06bfb8a34be7413df (patch)
treeb574e467955d11c86726ea8aa46caed81098bae6 /java/sca/modules
parent4de21f7b766b84439b9aae3362d71a5c945a7e03 (diff)
TUSCANY-3312 - change JavaInterface interface reference to a weak reference to avoid this holding onto the interface when stored in the JavaInterfaceFactory cache
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@826218 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules')
-rw-r--r--java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java17
1 files changed, 11 insertions, 6 deletions
diff --git a/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java b/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java
index 9f0071410e..0b418054c5 100644
--- a/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java
+++ b/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java
@@ -18,8 +18,9 @@
*/
package org.apache.tuscany.sca.interfacedef.java.impl;
-import javax.xml.namespace.QName;
+import java.lang.ref.WeakReference;
+import javax.xml.namespace.QName;
import org.apache.tuscany.sca.interfacedef.impl.InterfaceImpl;
import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
@@ -31,7 +32,7 @@ import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
public class JavaInterfaceImpl extends InterfaceImpl implements JavaInterface {
private String className;
- private Class<?> javaClass;
+ private WeakReference<Class<?>> javaClass;
private Class<?> callbackClass;
private QName qname;
@@ -42,7 +43,7 @@ public class JavaInterfaceImpl extends InterfaceImpl implements JavaInterface {
if (isUnresolved()) {
return className;
} else if (javaClass != null) {
- return javaClass.getName();
+ return javaClass.get().getName();
} else {
return null;
}
@@ -64,11 +65,15 @@ public class JavaInterfaceImpl extends InterfaceImpl implements JavaInterface {
}
public Class<?> getJavaClass() {
- return javaClass;
+ if (javaClass != null){
+ return javaClass.get();
+ } else {
+ return null;
+ }
}
public void setJavaClass(Class<?> javaClass) {
- this.javaClass = javaClass;
+ this.javaClass = new WeakReference<Class<?>>(javaClass);
if (javaClass != null) {
this.className = javaClass.getName();
}
@@ -119,7 +124,7 @@ public class JavaInterfaceImpl extends InterfaceImpl implements JavaInterface {
if (javaClass == null) {
if (other.javaClass != null)
return false;
- } else if (!javaClass.equals(other.javaClass))
+ } else if (!javaClass.get().equals(other.javaClass.get()))
return false;
if (callbackClass == null) {
if (other.callbackClass != null)