aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-base
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2011-06-10 16:35:45 +0000
committerOlivier Lamy <olamy@apache.org>2011-06-10 16:35:45 +0000
commite6a1d209a2e5a3849ba5cd73d0b96254f5580759 (patch)
treea218f0a574457c12d6aaca6b66f0a25d17bbb345 /archiva-modules/archiva-base
parent35292049954fe9cea9815ac322ea53aab17037ea (diff)
downloadarchiva-e6a1d209a2e5a3849ba5cd73d0b96254f5580759.tar.gz
archiva-e6a1d209a2e5a3849ba5cd73d0b96254f5580759.zip
use sisu container classloader as tccl during lookup
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1134376 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-base')
-rw-r--r--archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/PlexusSisuBridge.java41
1 files changed, 36 insertions, 5 deletions
diff --git a/archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/PlexusSisuBridge.java b/archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/PlexusSisuBridge.java
index e13f9b4bd..3a995697b 100644
--- a/archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/PlexusSisuBridge.java
+++ b/archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/PlexusSisuBridge.java
@@ -58,6 +58,8 @@ public class PlexusSisuBridge
private URL overridingComponentsXml;
+ private ClassRealm containerRealm;
+
private DefaultPlexusContainer plexusContainer;
@PostConstruct
@@ -76,7 +78,7 @@ public class PlexusSisuBridge
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
- ClassRealm classRealm = new ClassRealm( classWorld, "maven", tccl );
+ containerRealm = new ClassRealm( classWorld, "maven", tccl );
// olamy hackhish but plexus-sisu need a URLClassLoader with URL filled
@@ -85,11 +87,11 @@ public class PlexusSisuBridge
URL[] urls = ( (URLClassLoader) tccl ).getURLs();
for ( URL url : urls )
{
- classRealm.addURL( url );
+ containerRealm.addURL( url );
}
}
- conf.setRealm( classRealm );
+ conf.setRealm( containerRealm );
//conf.setClassWorld( classWorld );
@@ -97,13 +99,15 @@ public class PlexusSisuBridge
try
{
- Thread.currentThread().setContextClassLoader( classRealm );
+ Thread.currentThread().setContextClassLoader( containerRealm );
plexusContainer = new DefaultPlexusContainer( conf );
}
catch ( PlexusContainerException e )
{
throw new PlexusSisuBridgeException( e.getMessage(), e );
- } finally {
+ }
+ finally
+ {
Thread.currentThread().setContextClassLoader( ori );
}
}
@@ -131,52 +135,79 @@ public class PlexusSisuBridge
public <T> T lookup( Class<T> clazz )
throws PlexusSisuBridgeException
{
+ ClassLoader ori = Thread.currentThread().getContextClassLoader();
try
{
+ Thread.currentThread().setContextClassLoader( containerRealm );
return plexusContainer.lookup( clazz );
}
catch ( ComponentLookupException e )
{
throw new PlexusSisuBridgeException( e.getMessage(), e );
}
+ finally
+ {
+ Thread.currentThread().setContextClassLoader( ori );
+ }
}
public <T> T lookup( Class<T> clazz, String hint )
throws PlexusSisuBridgeException
{
+ ClassLoader ori = Thread.currentThread().getContextClassLoader();
+
try
{
+ Thread.currentThread().setContextClassLoader( containerRealm );
return plexusContainer.lookup( clazz, hint );
}
catch ( ComponentLookupException e )
{
throw new PlexusSisuBridgeException( e.getMessage(), e );
}
+ finally
+ {
+ Thread.currentThread().setContextClassLoader( ori );
+ }
}
public <T> List<T> lookupList( Class<T> clazz )
throws PlexusSisuBridgeException
{
+ ClassLoader ori = Thread.currentThread().getContextClassLoader();
+
try
{
+ Thread.currentThread().setContextClassLoader( containerRealm );
return plexusContainer.lookupList( clazz );
}
catch ( ComponentLookupException e )
{
throw new PlexusSisuBridgeException( e.getMessage(), e );
}
+ finally
+ {
+ Thread.currentThread().setContextClassLoader( ori );
+ }
}
public <T> Map<String, T> lookupMap( Class<T> clazz )
throws PlexusSisuBridgeException
{
+ ClassLoader ori = Thread.currentThread().getContextClassLoader();
+
try
{
+ Thread.currentThread().setContextClassLoader( containerRealm );
return plexusContainer.lookupMap( clazz );
}
catch ( ComponentLookupException e )
{
throw new PlexusSisuBridgeException( e.getMessage(), e );
}
+ finally
+ {
+ Thread.currentThread().setContextClassLoader( ori );
+ }
}
}