summaryrefslogtreecommitdiffstats
path: root/branches
diff options
context:
space:
mode:
authorbdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68>2009-09-16 17:15:41 +0000
committerbdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68>2009-09-16 17:15:41 +0000
commit4561b3563f5a213c8cfd6806e9f7c0b10c1f296f (patch)
tree607bddc767516b517a553b692b53d883fc33b442 /branches
parent9798b7a19c1dbea1183e06cde0c0fd1d9fed5ddd (diff)
TUSCANY-3278 Create a classloader with access to both cglib and application classes for use by the cglib enhancer
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@815893 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches')
-rw-r--r--branches/sca-java-1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/branches/sca-java-1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java b/branches/sca-java-1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java
index 0fa1d27d2a..0b3c043340 100644
--- a/branches/sca-java-1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java
+++ b/branches/sca-java-1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java
@@ -56,6 +56,25 @@ public class CglibProxyFactory implements ProxyFactory {
return createProxy(serviceReference);
}
+ private class CglibClassLoader extends ClassLoader {
+ private ClassLoader appLoader;
+ private ClassLoader bundleLoader;
+
+ @Override
+ public Class<?> loadClass(String className)
+ throws ClassNotFoundException {
+ try {
+ return appLoader.loadClass(className);
+ } catch (ClassNotFoundException ex ) {
+ return bundleLoader.loadClass(className);
+ }
+ }
+
+ CglibClassLoader(ClassLoader app, ClassLoader bundle) {
+ this.appLoader = app;
+ this.bundleLoader = bundle;
+ }
+ }
/**
* create the proxy with cglib. use the same JDKInvocationHandler as
* JDKProxyService.
@@ -63,6 +82,8 @@ public class CglibProxyFactory implements ProxyFactory {
public <T> T createProxy(CallableReference<T> callableReference) throws ProxyCreationException {
Enhancer enhancer = new Enhancer();
Class<T> interfaze = callableReference.getBusinessInterface();
+ ClassLoader cl = new CglibClassLoader(interfaze.getClassLoader(), getClass().getClassLoader());
+ enhancer.setClassLoader(cl);
enhancer.setSuperclass(interfaze);
enhancer.setCallback(new CglibMethodInterceptor<T>(callableReference));
Object proxy = enhancer.create();