[jboss-cvs] JBossAS SVN: r105323 - in branches/Branch_AOP_1_5/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:45:53 EDT 2010
Author: flavia.rainone at jboss.com
Date: 2010-05-27 23:45:53 -0400 (Thu, 27 May 2010)
New Revision: 105323
Modified:
branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/advice/PerVmAdvice.java
branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/proxy/ClassProxyFactory.java
branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/proxy/ProxyFactory.java
branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/proxy/container/ContainerProxyFactory.java
Log:
[JBAOP-762] Add ProtectionDomain info to classes created at runtime.
Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/advice/PerVmAdvice.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/advice/PerVmAdvice.java 2010-05-28 03:35:21 UTC (rev 105322)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/advice/PerVmAdvice.java 2010-05-28 03:45:53 UTC (rev 105323)
@@ -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/Branch_AOP_1_5/aop/src/main/org/jboss/aop/proxy/ClassProxyFactory.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/proxy/ClassProxyFactory.java 2010-05-28 03:35:21 UTC (rev 105322)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/proxy/ClassProxyFactory.java 2010-05-28 03:45:53 UTC (rev 105323)
@@ -24,11 +24,21 @@
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
+import java.security.ProtectionDomain;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.WeakHashMap;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.CtField;
+import javassist.CtMethod;
+import javassist.CtNewMethod;
+import javassist.Modifier;
+import javassist.SerialVersionUID;
+
import org.jboss.aop.AspectManager;
import org.jboss.aop.ClassAdvisor;
import org.jboss.aop.ClassInstanceAdvisor;
@@ -37,13 +47,6 @@
import org.jboss.aop.util.reference.MethodPersistentReference;
import org.jboss.aop.util.reference.PersistentReference;
import org.jboss.util.collection.WeakValueHashMap;
-import javassist.ClassPool;
-import javassist.CtClass;
-import javassist.CtField;
-import javassist.CtMethod;
-import javassist.CtNewMethod;
-import javassist.Modifier;
-import javassist.SerialVersionUID;
/**
@@ -306,7 +309,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/Branch_AOP_1_5/aop/src/main/org/jboss/aop/proxy/ProxyFactory.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/proxy/ProxyFactory.java 2010-05-28 03:35:21 UTC (rev 105322)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/proxy/ProxyFactory.java 2010-05-28 03:45:53 UTC (rev 105323)
@@ -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/Branch_AOP_1_5/aop/src/main/org/jboss/aop/proxy/container/ContainerProxyFactory.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/proxy/container/ContainerProxyFactory.java 2010-05-28 03:35:21 UTC (rev 105322)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/proxy/container/ContainerProxyFactory.java 2010-05-28 03:45:53 UTC (rev 105323)
@@ -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