summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/interface-java
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2008-11-19 05:27:58 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2008-11-19 05:27:58 +0000
commit5f3869c451e46aadc943d00087d6847877dd1c50 (patch)
treee22baaff1fb9ea42606b7d04af52e032e3bc03bc /java/sca/modules/interface-java
parent60744a36aae604ac3c4499ed54f1082ab8f5947d (diff)
Merging the 1.x delta on top of the equinox based modules
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@718858 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/interface-java')
-rw-r--r--java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceFactoryImpl.java17
1 files changed, 14 insertions, 3 deletions
diff --git a/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceFactoryImpl.java b/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceFactoryImpl.java
index b1efd6e197..1454851fb1 100644
--- a/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceFactoryImpl.java
+++ b/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceFactoryImpl.java
@@ -19,7 +19,10 @@
package org.apache.tuscany.sca.interfacedef.java.impl;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
+import java.util.Map;
+import java.util.WeakHashMap;
import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
@@ -36,6 +39,7 @@ public abstract class JavaInterfaceFactoryImpl implements JavaInterfaceFactory {
private List<JavaInterfaceVisitor> visitors = new ArrayList<JavaInterfaceVisitor>();
private JavaInterfaceIntrospectorImpl introspector;
+ private Map<Class<?>, JavaInterface> cache = Collections.synchronizedMap(new WeakHashMap<Class<?>, JavaInterface>());
public JavaInterfaceFactoryImpl() {
introspector = new JavaInterfaceIntrospectorImpl(this);
@@ -46,9 +50,16 @@ public abstract class JavaInterfaceFactoryImpl implements JavaInterfaceFactory {
}
public JavaInterface createJavaInterface(Class<?> interfaceClass) throws InvalidInterfaceException {
- JavaInterface javaInterface = createJavaInterface();
- introspector.introspectInterface(javaInterface, interfaceClass);
- return javaInterface;
+ // TODO: Review if the sharing of JavaInterface is ok
+ synchronized (interfaceClass) {
+ JavaInterface javaInterface = cache.get(interfaceClass);
+ if (javaInterface == null) {
+ javaInterface = createJavaInterface();
+ introspector.introspectInterface(javaInterface, interfaceClass);
+ cache.put(interfaceClass, javaInterface);
+ }
+ return javaInterface;
+ }
}
public void createJavaInterface(JavaInterface javaInterface, Class<?> interfaceClass) throws InvalidInterfaceException {