[jboss-cvs] JBossAS SVN: r105322 - in branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop: proxy and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu May 27 23:35:21 EDT 2010
Author: flavia.rainone at jboss.com
Date: 2010-05-27 23:35:21 -0400 (Thu, 27 May 2010)
New Revision: 105322
Modified:
branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/advice/PerVmAdvice.java
branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/proxy/ClassProxyFactory.java
branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/proxy/ProxyFactory.java
branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/proxy/container/ContainerProxyFactory.java
Log:
[JBAOP-762] Add ProtectionDomain info to classes created at runtime.
Modified: branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/advice/PerVmAdvice.java
===================================================================
--- branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/advice/PerVmAdvice.java 2010-05-28 03:04:35 UTC (rev 105321)
+++ branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/advice/PerVmAdvice.java 2010-05-28 03:35:21 UTC (rev 105322)
@@ -23,6 +23,7 @@
import java.lang.reflect.Field;
import java.lang.reflect.Method;
+import java.security.ProtectionDomain;
import java.util.ArrayList;
import javassist.CannotCompileException;
@@ -78,8 +79,9 @@
}
}
}
-
- ClassPool pool = AspectManager.instance().findClassPool(aspect.getClass().getClassLoader());
+
+ ClassLoader cl = aspect.getClass().getClassLoader();
+ ClassPool pool = AspectManager.instance().findClassPool(cl);
CtClass clazz = pool.makeClass("org.jboss.aop.advice." + aspect.getClass().getName() + counter++);
// We need to know whether this Interceptor is actually advice.
@@ -127,7 +129,8 @@
CtMethod invoke = CtNewMethod.make(invokeBody, clazz);
invoke.setModifiers(javassist.Modifier.PUBLIC);
clazz.addMethod(invoke);
- Class iclass = clazz.toClass();
+ ProtectionDomain pd = aspect.getClass().getProtectionDomain();
+ Class iclass = clazz.toClass(cl, pd);
Interceptor rtn = (Interceptor) iclass.newInstance();
Field f = iclass.getField("aspectField");
@@ -137,7 +140,8 @@
public static Interceptor generateArgsInterceptor(Object aspect, Method advice, Joinpoint joinpoint) throws Exception
{
- ClassPool pool = AspectManager.instance().findClassPool(aspect.getClass().getClassLoader());
+ ClassLoader cl = aspect.getClass().getClassLoader();
+ ClassPool pool = AspectManager.instance().findClassPool(cl);
CtClass clazz = pool.makeClass("org.jboss.aop.advice." + aspect.getClass().getName() + counter++);
// We need to know whether this Interceptor is actually advice.
@@ -201,7 +205,8 @@
}
invoke.setModifiers(javassist.Modifier.PUBLIC);
clazz.addMethod(invoke);
- Class iclass = clazz.toClass();
+ ProtectionDomain pd = aspect.getClass().getProtectionDomain();
+ Class iclass = clazz.toClass(cl, pd);
Interceptor rtn = (Interceptor) iclass.newInstance();
Field f = iclass.getField("aspectField");
Modified: branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/proxy/ClassProxyFactory.java
===================================================================
--- branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/proxy/ClassProxyFactory.java 2010-05-28 03:04:35 UTC (rev 105321)
+++ branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/proxy/ClassProxyFactory.java 2010-05-28 03:35:21 UTC (rev 105322)
@@ -24,6 +24,7 @@
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
+import java.security.ProtectionDomain;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -309,7 +310,8 @@
private static Class generateProxy(Class clazz, ProxyMixin[] mixins) throws Exception
{
CtClass proxy = createProxyCtClass(mixins, clazz);
- Class proxyClass = proxy.toClass();
+ ProtectionDomain pd = clazz.getProtectionDomain();
+ Class proxyClass = proxy.toClass(null, pd);
Map methodmap = ClassProxyFactory.getMethodMap(proxyClass);
Field field = proxyClass.getDeclaredField("methodMap");
field.setAccessible(true);
Modified: branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/proxy/ProxyFactory.java
===================================================================
--- branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/proxy/ProxyFactory.java 2010-05-28 03:04:35 UTC (rev 105321)
+++ branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/proxy/ProxyFactory.java 2010-05-28 03:35:21 UTC (rev 105322)
@@ -35,6 +35,7 @@
import org.jboss.util.id.GUID;
import java.lang.reflect.Field;
+import java.security.ProtectionDomain;
import java.util.HashSet;
import java.util.Map;
@@ -111,8 +112,13 @@
throws Exception
{
CtClass proxy = createProxyCtClass(loader, mixins, interfaces);
-
- Class clazz = proxy.toClass(loader);
+ // Choose the first non-null ProtectionDomain
+ ProtectionDomain pd = null;
+ for(int n = 0; n < interfaces.length && pd == null; n ++)
+ {
+ pd = interfaces[n].getProtectionDomain();
+ }
+ Class clazz = proxy.toClass(loader, pd);
Map methodmap = ClassProxyFactory.getMethodMap(clazz);
Field field = clazz.getDeclaredField("methodMap");
field.setAccessible(true);
Modified: branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/proxy/container/ContainerProxyFactory.java
===================================================================
--- branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/proxy/container/ContainerProxyFactory.java 2010-05-28 03:04:35 UTC (rev 105321)
+++ branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/proxy/container/ContainerProxyFactory.java 2010-05-28 03:35:21 UTC (rev 105322)
@@ -22,6 +22,7 @@
package org.jboss.aop.proxy.container;
import java.lang.reflect.Method;
+import java.security.ProtectionDomain;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -129,8 +130,8 @@
{
ArrayList introductions = advisor.getInterfaceIntroductions();
CtClass proxy = createProxyCtClass(objectAsSuper, introductions, clazz, advisor);
-
- Class proxyClass = proxy.toClass();
+ ProtectionDomain pd = clazz.getProtectionDomain();
+ Class proxyClass = proxy.toClass(null, pd);
return proxyClass;
}
More information about the jboss-cvs-commits
mailing list