You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2012/01/26 01:50:53 UTC
svn commit: r1236000 - in
/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc:
internal/util/URLChangeTracker.java services/ClassFabUtils.java
services/MethodIterator.java
Author: hlship
Date: Thu Jan 26 00:50:53 2012
New Revision: 1236000
URL: http://svn.apache.org/viewvc?rev=1236000&view=rev
Log:
Remove deprecated class ClassFabUtils, moving its remaining static methods to the classes that make use of them
Removed:
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassFabUtils.java
Modified:
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/URLChangeTracker.java
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/MethodIterator.java
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/URLChangeTracker.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/URLChangeTracker.java?rev=1236000&r1=1235999&r2=1236000&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/URLChangeTracker.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/URLChangeTracker.java Thu Jan 26 00:50:53 2012
@@ -15,11 +15,11 @@
package org.apache.tapestry5.ioc.internal.util;
import org.apache.tapestry5.ioc.internal.services.ClasspathURLConverterImpl;
-import org.apache.tapestry5.ioc.services.ClassFabUtils;
import org.apache.tapestry5.ioc.services.ClasspathURLConverter;
import java.io.File;
import java.io.IOException;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.Map;
@@ -102,6 +102,29 @@ public class URLChangeTracker
}
/**
+ * Converts a URL with protocol "file" to a File instance.
+ *
+ * @since 5.2.0
+ */
+ public static File toFileFromFileProtocolURL(URL url)
+ {
+ assert url != null;
+
+ if (!url.getProtocol().equals("file"))
+ throw new IllegalArgumentException(String.format("URL %s does not use the 'file' protocol.", url));
+
+ // http://weblogs.java.net/blog/kohsuke/archive/2007/04/how_to_convert.html
+
+ try
+ {
+ return new File(url.toURI());
+ } catch (URISyntaxException ex)
+ {
+ return new File(url.getPath());
+ }
+ }
+
+ /**
* Stores a new URL into the tracker, or returns the previous time stamp for a previously added URL. Filters out all
* non-file URLs.
*
@@ -120,7 +143,7 @@ public class URLChangeTracker
if (!converted.getProtocol().equals("file"))
return timestampForNonFileURL(converted);
- File resourceFile = ClassFabUtils.toFileFromFileProtocolURL(converted);
+ File resourceFile = toFileFromFileProtocolURL(converted);
if (fileToTimestamp.containsKey(resourceFile))
return fileToTimestamp.get(resourceFile);
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/MethodIterator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/MethodIterator.java?rev=1236000&r1=1235999&r2=1236000&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/MethodIterator.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/MethodIterator.java Thu Jan 26 00:50:53 2012
@@ -62,9 +62,24 @@ public class MethodIterator
Collections.sort(signatures, COMPARATOR);
}
+ /**
+ * Returns true if the method is the standard toString() method. Very few interfaces will ever include this method
+ * as part of the interface, but we have to be sure.
+ */
+ public static boolean isToString(Method method)
+ {
+ if (!method.getName().equals("toString"))
+ return false;
+
+ if (method.getParameterTypes().length > 0)
+ return false;
+
+ return method.getReturnType().equals(String.class);
+ }
+
private void processMethod(Method m, Map<String, MethodSignature> map)
{
- toString |= ClassFabUtils.isToString(m);
+ toString |= isToString(m);
MethodSignature sig = new MethodSignature(m);
String uid = sig.getUniqueId();