diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-07-18 12:58:09 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-07-18 12:58:09 +0000 |
commit | 2fdd677d2c1a0b9c423eb90a626070b38d5e2f15 (patch) | |
tree | 54e2cfa9484745cbbce4dd886e781c93abc639eb /sca-java-2.x/branches/2.0-Beta3 | |
parent | 63b05d0d32716968bb442de6ab2959694185e327 (diff) |
Merge the TUSCANY-3896 fix from trunk to beta3
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1147843 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/branches/2.0-Beta3')
2 files changed, 22 insertions, 6 deletions
diff --git a/sca-java-2.x/branches/2.0-Beta3/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java b/sca-java-2.x/branches/2.0-Beta3/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java index ce148438eb..7c4afb2660 100644 --- a/sca-java-2.x/branches/2.0-Beta3/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java +++ b/sca-java-2.x/branches/2.0-Beta3/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java @@ -22,6 +22,8 @@ package org.apache.tuscany.sca.client.impl; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Proxy; import java.net.URI; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.List; import org.apache.tuscany.sca.assembly.Endpoint; @@ -37,12 +39,16 @@ import org.oasisopen.sca.client.SCAClientFactoryFinder; public class SCAClientFactoryImpl extends SCAClientFactory { - private ExtensionPointRegistry extensionPointRegistry; - private DomainRegistry domainRegistry; - private boolean remoteClient; + protected ExtensionPointRegistry extensionPointRegistry; + protected DomainRegistry domainRegistry; + protected boolean remoteClient; public static URI default_domainURI = URI.create("default"); + public static SCAClientFactoryFinder getSCAClientFactoryFinder() { + return SCAClientFactory.factoryFinder; + } + public static void setSCAClientFactoryFinder(SCAClientFactoryFinder factoryFinder) { SCAClientFactory.factoryFinder = factoryFinder; } @@ -52,7 +58,7 @@ public class SCAClientFactoryImpl extends SCAClientFactory { findLocalRuntime(); } - private void findLocalRuntime() throws NoSuchDomainException { + protected void findLocalRuntime() throws NoSuchDomainException { String domainURI = getDomainURI().toString(); for (ExtensionPointRegistry xpr : ExtensionPointRegistryLocator.getExtensionPointRegistries()) { ExtensibleDomainRegistryFactory drf = ExtensibleDomainRegistryFactory.getInstance(xpr); @@ -105,6 +111,13 @@ public class SCAClientFactoryImpl extends SCAClientFactory { serviceInterface = (Class<T>)((RemoteServiceInvocationHandler)handler).serviceInterface; } - return (T)Proxy.newProxyInstance(serviceInterface.getClassLoader(), new Class[]{serviceInterface}, handler); + final Class _serviceInterface = serviceInterface; + ClassLoader cl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { + public ClassLoader run() { + return _serviceInterface.getClassLoader(); + } + }); + + return (T)Proxy.newProxyInstance(cl, new Class[]{serviceInterface}, handler); } } diff --git a/sca-java-2.x/branches/2.0-Beta3/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientModuleActivator.java b/sca-java-2.x/branches/2.0-Beta3/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientModuleActivator.java index 0cf41e071c..d2fdbc302d 100644 --- a/sca-java-2.x/branches/2.0-Beta3/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientModuleActivator.java +++ b/sca-java-2.x/branches/2.0-Beta3/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientModuleActivator.java @@ -24,7 +24,10 @@ import org.apache.tuscany.sca.core.ModuleActivator; public class SCAClientModuleActivator implements ModuleActivator { public void start() { - SCAClientFactoryImpl.setSCAClientFactoryFinder(new SCAClientFactoryFinderImpl()); + // Do not replace the finder if it's already been set by some other means + if (SCAClientFactoryImpl.getSCAClientFactoryFinder() == null) { + SCAClientFactoryImpl.setSCAClientFactoryFinder(new SCAClientFactoryFinderImpl()); + } } public void stop() { |