summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/implementation-java
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2012-03-04 17:48:55 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2012-03-04 17:48:55 +0000
commit553a373be707a466b2fdac6eb10568572b6f10a1 (patch)
treec7be1e7c94ccea4246dbd14ade2577992e430851 /sca-java-2.x/trunk/modules/implementation-java
parent3d87d97115e1f859cb5d452d16ede516908a37f0 (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/implementation-java')
-rw-r--r--sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaElementImpl.java27
1 files changed, 14 insertions, 13 deletions
diff --git a/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaElementImpl.java b/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaElementImpl.java
index e748a5f6fa..44dec0376a 100644
--- a/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaElementImpl.java
+++ b/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaElementImpl.java
@@ -21,6 +21,7 @@ package org.apache.tuscany.sca.implementation.java;
import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
+import java.lang.ref.WeakReference;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
@@ -36,8 +37,8 @@ import java.lang.reflect.Type;
public class JavaElementImpl {
private AnnotatedElement anchor;
private ElementType elementType;
- private Class<?> type;
- private Type genericType;
+ private WeakReference<Class<?>> type;
+ private WeakReference<Type> genericType;
private int index = -1;
private String name;
private Class<? extends Annotation> classifer;
@@ -45,24 +46,24 @@ public class JavaElementImpl {
public JavaElementImpl(Class<?> cls) {
this.anchor = cls;
this.elementType = ElementType.TYPE;
- this.type = cls;
- this.genericType = cls;
+ this.type = new WeakReference<Class<?>>(cls);
+ this.genericType = new WeakReference<Type>(cls);
this.name = cls.getName();
}
public JavaElementImpl(Field field) {
this.anchor = field;
this.elementType = ElementType.FIELD;
- this.type = field.getType();
- this.genericType = field.getGenericType();
+ this.type = new WeakReference<Class<?>>(field.getType());
+ this.genericType = new WeakReference<Type>(field.getGenericType());
this.name = field.getName();
}
public JavaElementImpl(Constructor<?> constructor, int index) {
this.anchor = constructor;
this.elementType = ElementType.PARAMETER;
- this.type = constructor.getParameterTypes()[index];
- this.genericType = constructor.getGenericParameterTypes()[index];
+ this.type = new WeakReference<Class<?>>(constructor.getParameterTypes()[index]);
+ this.genericType = new WeakReference<Type>(constructor.getGenericParameterTypes()[index]);
this.index = index;
this.name = "";
}
@@ -70,8 +71,8 @@ public class JavaElementImpl {
public JavaElementImpl(Method method, int index) {
this.anchor = method;
this.elementType = ElementType.PARAMETER;
- this.type = method.getParameterTypes()[index];
- this.genericType = method.getGenericParameterTypes()[index];
+ this.type = new WeakReference<Class<?>>(method.getParameterTypes()[index]);
+ this.genericType = new WeakReference<Type>(method.getGenericParameterTypes()[index]);
this.index = index;
this.name = "";
}
@@ -86,7 +87,7 @@ public class JavaElementImpl {
*/
public JavaElementImpl(String name, Class<?> type, Class<? extends Annotation> classifer) {
super();
- this.type = type;
+ this.type = new WeakReference<Class<?>>(type);
this.name = name;
this.classifer = classifer;
}
@@ -109,7 +110,7 @@ public class JavaElementImpl {
* @return the genericType
*/
public Type getGenericType() {
- return genericType;
+ return genericType.get();
}
/**
@@ -123,7 +124,7 @@ public class JavaElementImpl {
* @return the type
*/
public Class<?> getType() {
- return type;
+ return type.get();
}
/**