cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stevend...@apache.org
Subject svn commit: r1155113 - /cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/util/SpringProxyHelper.java
Date Mon, 08 Aug 2011 21:30:46 GMT
Author: stevendolg
Date: Mon Aug  8 21:30:46 2011
New Revision: 1155113

URL: http://svn.apache.org/viewvc?rev=1155113&view=rev
Log:
Reworked class to fix warnings

Modified:
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/util/SpringProxyHelper.java

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/util/SpringProxyHelper.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/util/SpringProxyHelper.java?rev=1155113&r1=1155112&r2=1155113&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/util/SpringProxyHelper.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/util/SpringProxyHelper.java
Mon Aug  8 21:30:46 2011
@@ -18,27 +18,34 @@ package org.apache.cocoon.sitemap.util;
 
 import org.springframework.aop.framework.Advised;
 
-public class SpringProxyHelper {
+public final class SpringProxyHelper {
 
     private SpringProxyHelper() {
-        // only static usage
+        // hide utility class constructor
     }
 
     public static <T> T unpackProxy(T proxy) {
         if (proxy instanceof Advised) {
             Advised advised = (Advised) proxy;
-            try {
-                @SuppressWarnings("unchecked")
-                T target = (T) advised.getTargetSource().getTarget();
-                return target;
-            } catch (Exception e) {
-                throw new ProxyUnpackException(e);
-            }
+            return getTarget(advised);
         }
 
         return proxy;
     }
 
+    private static <T> T getTarget(Advised advised) {
+        try {
+            return asT(advised.getTargetSource().getTarget());
+        } catch (Exception e) {
+            throw new ProxyUnpackException(e);
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    private static <T> T asT(Object target) {
+        return (T) target;
+    }
+
     public static class ProxyUnpackException extends RuntimeException {
 
         private static final long serialVersionUID = 1L;



Mime
View raw message