diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-09-19 11:45:40 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-09-19 11:45:40 +0000 |
commit | e32b64d161654e654012f343e795d069bcf40ff8 (patch) | |
tree | 8687375c3744869fb9779ec5d20176652fe17677 /sca-java-2.x/trunk/modules/interface-java/src/main/java | |
parent | 7f5009617f19b9ee4313999f1ac4bf1c4775ed40 (diff) |
TUSCANY-3948: Apply patch from Greg Dritschler to support @Remotable on implementation class, reference field, or reference setter method
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1172577 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/interface-java/src/main/java')
2 files changed, 32 insertions, 4 deletions
diff --git a/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceFactory.java b/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceFactory.java index 4f4e9d8268..55d694d7f8 100644 --- a/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceFactory.java +++ b/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceFactory.java @@ -45,7 +45,15 @@ public interface JavaInterfaceFactory { * @return */ JavaInterface createJavaInterface(Class<?> interfaceClass) throws InvalidInterfaceException; - + + /** + * Creates a new Java interface model from an interface class. + * @param interfaceClass the interface class to introspect. + * @param forceRemotable allows the caller to force the interface remotable to be remotable. + * @return + */ + JavaInterface createJavaInterface(Class<?> interfaceClass, boolean forceRemotable) throws InvalidInterfaceException; + /** * Creates the contents of a Java interface model from an interface class. * @param javaInterface the Java interface model diff --git a/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceFactoryImpl.java b/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceFactoryImpl.java index dbedf1d55a..8229c7812d 100644 --- a/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceFactoryImpl.java +++ b/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceFactoryImpl.java @@ -41,8 +41,9 @@ 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>()); - + private Map<Class<?>, JavaInterface> normalCache = Collections.synchronizedMap(new WeakHashMap<Class<?>, JavaInterface>()); + private Map<Class<?>, JavaInterface> forceRemotableCache = Collections.synchronizedMap(new WeakHashMap<Class<?>, JavaInterface>()); + public JavaInterfaceFactoryImpl() { introspector = new JavaInterfaceIntrospectorImpl(this); } @@ -50,13 +51,32 @@ public abstract class JavaInterfaceFactoryImpl implements JavaInterfaceFactory { public JavaInterface createJavaInterface() { return new JavaInterfaceImpl(); } - + public JavaInterface createJavaInterface(Class<?> interfaceClass) throws InvalidInterfaceException { + return createJavaInterface(interfaceClass, false); + } + + /** + * Creates a new Java interface model from an interface class. + * + * The forceRemotable argument allows the caller to force the interface to be remotable. + * The ServiceProcessor and ReferenceProcessor introspectors use this argument to + * propagate a @Remotable annotation on an implementation class, field, or setter method + * to the corresponding service or reference interface. The remotable flag must be set + * on the interface model prior to instrospection since some introspectors build + * different models for remotable vs local interfaces. This also means separate caches + * must be kept for interfaces that are processed normally vs. those forced to be remotable. + */ + public JavaInterface createJavaInterface(Class<?> interfaceClass, boolean forceRemotable) throws InvalidInterfaceException { // TODO: Review if the sharing of JavaInterface is ok synchronized (interfaceClass) { + Map<Class<?>, JavaInterface> cache = (forceRemotable ? forceRemotableCache : normalCache); JavaInterface javaInterface = cache.get(interfaceClass); if (javaInterface == null) { javaInterface = createJavaInterface(); + if (forceRemotable) { + javaInterface.setRemotable(true); + } introspector.introspectInterface(javaInterface, interfaceClass); // Now that all introspection is complete we can mark the interface resolved javaInterface.setUnresolved(false); |