[jboss-cvs] JBossAS SVN: r95328 - in projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor: util and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 21 14:15:16 EDT 2009
Author: marius.bogoevici
Date: 2009-10-21 14:15:16 -0400 (Wed, 21 Oct 2009)
New Revision: 95328
Added:
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/proxy/
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/proxy/TargetInstanceProxy.java
Modified:
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorMethodHandler.java
projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/InterceptionUtils.java
Log:
Add support for unwrapping the target object.
Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorMethodHandler.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorMethodHandler.java 2009-10-21 18:14:55 UTC (rev 95327)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorMethodHandler.java 2009-10-21 18:15:16 UTC (rev 95328)
@@ -20,13 +20,14 @@
import org.jboss.interceptor.registry.InterceptorClassMetadataRegistry;
import org.jboss.interceptor.util.ReflectionUtils;
import org.jboss.interceptor.util.InterceptionUtils;
+import org.jboss.interceptor.util.proxy.TargetInstanceProxy;
import javassist.util.proxy.MethodHandler;
/**
* @author Marius Bogoevici
*/
-public class InterceptorMethodHandler implements MethodHandler, Serializable
+public class InterceptorMethodHandler implements Serializable, TargetInstanceProxy<Object>
{
private static ThreadLocal<Set<MethodHolder>> interceptionStack = new ThreadLocal<Set<MethodHolder>>();
@@ -74,6 +75,16 @@
targetClassInterceptorMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(targetClazz);
}
+ public Object getTargetInstance()
+ {
+ return target;
+ }
+
+ public Class<?> getTargetClass()
+ {
+ return targetClazz;
+ }
+
public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable
{
ReflectionUtils.ensureAccessible(thisMethod);
Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/InterceptionUtils.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/InterceptionUtils.java 2009-10-21 18:14:55 UTC (rev 95327)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/InterceptionUtils.java 2009-10-21 18:15:16 UTC (rev 95328)
@@ -25,6 +25,7 @@
import org.jboss.interceptor.proxy.LifecycleMixin;
import org.jboss.interceptor.registry.InterceptorRegistry;
import org.jboss.interceptor.InterceptorException;
+import org.jboss.interceptor.util.proxy.TargetInstanceProxy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -220,4 +221,13 @@
return EXCLUDE_CLASS_INTERCEPTORS_ANNOTATION_CLASS;
}
+ public static <T> T getRawInstance(T proxy)
+ {
+ while (proxy instanceof TargetInstanceProxy)
+ {
+ proxy = ((TargetInstanceProxy<T>)proxy).getTargetInstance();
+ }
+ return proxy;
+ }
+
}
Added: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/proxy/TargetInstanceProxy.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/proxy/TargetInstanceProxy.java (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/proxy/TargetInstanceProxy.java 2009-10-21 18:15:16 UTC (rev 95328)
@@ -0,0 +1,13 @@
+package org.jboss.interceptor.util.proxy;
+
+import javassist.util.proxy.MethodHandler;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public interface TargetInstanceProxy<T> extends MethodHandler
+{
+ T getTargetInstance();
+
+ Class<? extends T> getTargetClass();
+}
More information about the jboss-cvs-commits
mailing list