summaryrefslogtreecommitdiffstats
path: root/branches
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-07-04 07:37:12 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-07-04 07:37:12 +0000
commit3da108fdda088b9ed741a413d9cb05fb181c42f2 (patch)
treeb88ebac6961382b93ec066cbacaa4681f37897d3 /branches
parenta67b39eca908e3a76d1a35c9163d892dd36c9229 (diff)
TUSCANY-3128 - force the bean factory classloader to be the contribution classloader as it's reset by the application context on refresh.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@791072 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches')
-rw-r--r--branches/sca-java-1.x/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java31
1 files changed, 30 insertions, 1 deletions
diff --git a/branches/sca-java-1.x/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java b/branches/sca-java-1.x/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java
index 5961c52cc4..d53edf2325 100644
--- a/branches/sca-java-1.x/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java
+++ b/branches/sca-java-1.x/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java
@@ -36,8 +36,10 @@ import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.ConstructorArgumentValues;
import org.springframework.beans.factory.config.TypedStringValue;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.ManagedList;
import org.springframework.beans.factory.xml.XmlBeanFactory;
+import org.springframework.context.ApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.GenericApplicationContext;
@@ -57,6 +59,28 @@ public class SpringContextTie {
private boolean isAnnotationSupported;
private String versionSupported;
+ // TUSCANY-3128
+ // extension of the generic application context just to force the classloader
+ // on the bean factory to stay set to the contribution classloader
+ // instead of being set back to the application classloader
+ private class LocalGenericApplicationContext extends GenericApplicationContext{
+
+ ClassLoader classloader = null;
+
+ public LocalGenericApplicationContext(DefaultListableBeanFactory beanFactory,
+ ApplicationContext parent,
+ ClassLoader classloader) {
+ super(beanFactory, parent);
+ this.classloader = classloader;
+ }
+
+ @Override
+ protected void postProcessBeanFactory(
+ ConfigurableListableBeanFactory beanFactory) {
+ beanFactory.setBeanClassLoader(classloader);
+ }
+ }
+
public SpringContextTie(SpringImplementationStub implementation, URL resource, boolean annotationSupport, String versionSupported) throws Exception {
this.implementation = implementation;
this.isAnnotationSupported = annotationSupport;
@@ -134,8 +158,13 @@ public class SpringContextTie {
// use the generic application context as default
if (isAnnotationSupported)
+ {
includeAnnotationProcessors(beanFactory);
- appContext = new GenericApplicationContext(beanFactory, scaParentContext);
+ }
+
+ appContext = new LocalGenericApplicationContext(beanFactory,
+ scaParentContext,
+ implementation.getClassLoader());
return appContext;
}