portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r758985 - in /portals/jetspeed-2/portal/trunk: components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/folder/proxy/ components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/ jetspeed-commons/src/main/jav...
Date Fri, 27 Mar 2009 02:28:15 GMT
Author: ate
Date: Fri Mar 27 02:28:14 2009
New Revision: 758985

URL: http://svn.apache.org/viewvc?rev=758985&view=rev
Log:
Adding proper Proxy InvocationTargetException unwrapping

Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/LinkProxy.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageProxy.java
    portals/jetspeed-2/portal/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/portlet/PortletObjectProxy.java
    portals/jetspeed-2/portal/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/util/DelegatingObjectProxy.java

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java?rev=758985&r1=758984&r2=758985&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java
Fri Mar 27 02:28:14 2009
@@ -17,6 +17,7 @@
 package org.apache.jetspeed.om.folder.proxy;
 
 import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.util.ArrayList;
@@ -294,8 +295,15 @@
             throw new RuntimeException("Folder instance is immutable from proxy.");
         }
 
-        // attempt to invoke method on delegate Folder instance
-        return m.invoke(defaultFolder, args);
+        try
+        {
+            // attempt to invoke method on delegate Folder instance
+            return m.invoke(defaultFolder, args);
+        }
+        catch (InvocationTargetException ite)
+        {
+            throw ite.getTargetException();
+        }
     }
 
     /**

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/LinkProxy.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/LinkProxy.java?rev=758985&r1=758984&r2=758985&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/LinkProxy.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/LinkProxy.java
Fri Mar 27 02:28:14 2009
@@ -17,6 +17,7 @@
 package org.apache.jetspeed.om.page.proxy;
 
 import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 
@@ -112,8 +113,15 @@
             throw new RuntimeException("Link instance is immutable from proxy.");
         }
 
-        // attempt to invoke method on delegate Link instance
-        return m.invoke(link, args);
+        try
+        {
+            // attempt to invoke method on delegate Link instance
+            return m.invoke(link, args);
+        }
+        catch (InvocationTargetException ite)
+        {
+            throw ite.getTargetException();
+        }
     }
 
     /**

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageProxy.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageProxy.java?rev=758985&r1=758984&r2=758985&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageProxy.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageProxy.java
Fri Mar 27 02:28:14 2009
@@ -17,6 +17,7 @@
 package org.apache.jetspeed.om.page.proxy;
 
 import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 
@@ -126,8 +127,15 @@
             throw new RuntimeException("Page instance is immutable from proxy.");
         }
 
-        // attempt to invoke method on delegate Page instance
-        return m.invoke(page, args);
+        try
+        {
+            // attempt to invoke method on delegate Page instance
+            return m.invoke(page, args);
+        }
+        catch (InvocationTargetException ite)
+        {
+            throw ite.getTargetException();
+        }
     }
 
     /**

Modified: portals/jetspeed-2/portal/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/portlet/PortletObjectProxy.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/portlet/PortletObjectProxy.java?rev=758985&r1=758984&r2=758985&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/portlet/PortletObjectProxy.java
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/portlet/PortletObjectProxy.java
Fri Mar 27 02:28:14 2009
@@ -17,6 +17,7 @@
 package org.apache.jetspeed.portlet;
 
 import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.lang.reflect.Modifier;
@@ -87,6 +88,7 @@
     private String customConfigModePortletUniqueName;
     private List<Supports> supports;
     
+    @SuppressWarnings("unchecked")
     public static Object createProxy(Object proxiedObject, boolean autoSwitchEditDefaultsModeToEditMode,
boolean autoSwitchConfigMode, String customConfigModePortletUniqueName)
     {
         HashSet<Class> interfaces = new HashSet<Class>();
@@ -146,34 +148,39 @@
     public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
     {
         Object result = null;
-        boolean handledHere = false;
-        Class declaringClass = method.getDeclaringClass();
+        Class<? extends Object> declaringClass = method.getDeclaringClass();
         
-        if (declaringClass == Portlet.class || declaringClass == ResourceServingPortlet.class
|| declaringClass == EventPortlet.class)
+        try
         {
-            if (renderMethod.equals(method))
+            if (declaringClass == Portlet.class || declaringClass == ResourceServingPortlet.class
|| declaringClass == EventPortlet.class)
             {
-                proxyRender((RenderRequest) args[0], (RenderResponse) args[1]);
-                return null;
+                if (renderMethod.equals(method))
+                {
+                    proxyRender((RenderRequest) args[0], (RenderResponse) args[1]);
+                    return null;
+                }
+                else if (processActionMethod.equals(method))
+                {
+                    proxyProcessAction((ActionRequest) args[0], (ActionResponse) args[1]);
+                }
+                else
+                {
+                    result = method.invoke(this.portletObject, args);
+                }
             }
-            else if (processActionMethod.equals(method))
+            else if (declaringClass == SupportsHeaderPhase.class)
             {
-                proxyProcessAction((ActionRequest) args[0], (ActionResponse) args[1]);
+                result = method.invoke(this.portletObject, args);
             }
             else
             {
-                result = method.invoke(this.portletObject, args);
+                result = super.invoke(proxy, method, args);
             }
         }
-        else if (declaringClass == SupportsHeaderPhase.class)
-        {
-            result = method.invoke(this.portletObject, args);
-        }
-        else
+        catch (InvocationTargetException ite)
         {
-            result = super.invoke(proxy, method, args);
+            throw ite.getTargetException();
         }
-        
         return result;
     }
 

Modified: portals/jetspeed-2/portal/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/util/DelegatingObjectProxy.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/util/DelegatingObjectProxy.java?rev=758985&r1=758984&r2=758985&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/util/DelegatingObjectProxy.java
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/util/DelegatingObjectProxy.java
Fri Mar 27 02:28:14 2009
@@ -17,6 +17,7 @@
 package org.apache.jetspeed.util;
 
 import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.util.HashMap;
@@ -88,14 +89,21 @@
             }
         }
         
-        if (targetProxyInterface != null)
+        try
         {
-            ObjectMethodPair targetObjectMethodPair = findDelegatorObjectMethodPair(targetProxyInterface,
method);
-            return targetObjectMethodPair.method.invoke(targetObjectMethodPair.object, args);
+            if (targetProxyInterface != null)
+            {
+                ObjectMethodPair targetObjectMethodPair = findDelegatorObjectMethodPair(targetProxyInterface,
method);            
+                return targetObjectMethodPair.method.invoke(targetObjectMethodPair.object,
args);
+            }
+            else
+            {
+                return super.invoke(proxy, method, args);
+            }
         }
-        else
+        catch (InvocationTargetException ite)
         {
-            return super.invoke(proxy, method, args);
+            throw ite.getTargetException();
         }
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message