openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1429403 - /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java
Date Sat, 05 Jan 2013 22:21:22 GMT
Author: struberg
Date: Sat Jan  5 22:21:22 2013
New Revision: 1429403

URL: http://svn.apache.org/viewvc?rev=1429403&view=rev
Log:
OWB-344 getInternalInstance and JavaDoc

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java?rev=1429403&r1=1429402&r2=1429403&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java
Sat Jan  5 22:21:22 2013
@@ -94,14 +94,50 @@ public class InterceptorDecoratorProxyFa
         }
     }
 
+    /**
+     * @return the internal instance which gets proxied.
+     */
+    public <T> T getInternalInstance(OwbInterceptorProxy proxyInstance)
+    {
+        try
+        {
+            Field internalInstanceField = proxyInstance.getClass().getDeclaredField(FIELD_PROXIED_INSTANCE);
+            internalInstanceField.setAccessible(true);
+            return (T) internalInstanceField.get(proxyInstance);
+        }
+        catch (Exception e)
+        {
+            throw new RuntimeException(e);
+        }
+    }
+
 
     /**
-     * Create a decorator and interceptor proxy for the given type.
+     * <p>Create a decorator and interceptor proxy for the given type. A single instance
+     * of such a proxy class has exactly one single internal instance.</p>
+     *
+     * <p>There are 3 different kind of methods:
+     * <ol>
+     *     <li>
+     *         private methods - they do not get proxied at all! If you like to invoke a
private method,
+     *         then you can use {@link #getInternalInstance(OwbInterceptorProxy)} and use
reflection on it.
+     *     </li>
+     *     <li>
+     *         non-proxied methods - all methods which do not have a business interceptor
nor decorator
+     *         will get delegated to the internal instance without invoking any InterceptorHandler
nor
+     *         doing reflection. Just plain java bytecode will get generated!
+     *     </li>
+     *     <li>
+     *         proxied methods - all calls to such a proxied method will get forwarded to
the
+     *         InterceptorHandler which got set for this instance.
+     *     </li>
+     * </ol>
+     * </p>
      *
      *
      * @param classLoader to use for creating the class in
-     * @param classToProxy
-     * @param interceptedMethods the list of intercepted or decorated methods
+     * @param classToProxy the class for which a subclass will get generated
+     * @param interceptedMethods the list of intercepted or decorated business methods.
      * @param nonInterceptedMethods all methods which are <b>not</b> intercepted
nor decorated and shall get delegated directly
      * @param <T>
      * @return the proxy class



Mime
View raw message