You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2014/07/21 14:18:36 UTC
[4/9] git commit: ISIS-839: further fix for Vfs discovery of
@DomainService classes
ISIS-839: further fix for Vfs discovery of @DomainService classes
(get rid of noisy/harmless exception stack trace).
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/19cfaa86
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/19cfaa86
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/19cfaa86
Branch: refs/heads/prepare/isis-1.6.0-RC2
Commit: 19cfaa8630475aa23bf9a064d463ca534644529a
Parents: 4e93d1b
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Mon Jul 21 12:32:21 2014 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Jul 21 12:33:42 2014 +0100
----------------------------------------------------------------------
.../ClassDiscoveryServiceUsingReflections.java | 111 +++++++++++--------
1 file changed, 64 insertions(+), 47 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/19cfaa86/core/applib/src/main/java/org/apache/isis/applib/services/classdiscovery/ClassDiscoveryServiceUsingReflections.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/classdiscovery/ClassDiscoveryServiceUsingReflections.java b/core/applib/src/main/java/org/apache/isis/applib/services/classdiscovery/ClassDiscoveryServiceUsingReflections.java
index 993319f..ea123e7 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/classdiscovery/ClassDiscoveryServiceUsingReflections.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/classdiscovery/ClassDiscoveryServiceUsingReflections.java
@@ -23,13 +23,13 @@ import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLDecoder;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.Set;
import com.google.common.collect.Lists;
import org.reflections.Reflections;
import org.reflections.scanners.SubTypesScanner;
import org.reflections.util.ClasspathHelper;
-import org.reflections.util.ConfigurationBuilder;
import org.reflections.vfs.SystemDir;
import org.reflections.vfs.Vfs;
import org.apache.isis.applib.AbstractService;
@@ -53,16 +53,13 @@ public class ClassDiscoveryServiceUsingReflections
@Override
public <T> Set<Class<? extends T>> findSubTypesOfClasses(Class<T> type) {
- List<Vfs.UrlType> urlTypes = getUrlTypes();
- Vfs.setDefaultURLTypes(urlTypes);
+ Vfs.setDefaultURLTypes(getUrlTypes());
- ConfigurationBuilder configuration = ConfigurationBuilder.build(
+ final Reflections reflections = new Reflections(
ClasspathHelper.forClassLoader(Thread.currentThread().getContextClassLoader()),
ClasspathHelper.forClass(Object.class),
- new SubTypesScanner(false));
- // doesn't seem to do anything
- // configuration = configuration.filterInputsBy(ignorePom());
- final Reflections reflections = new Reflections(configuration);
+ new SubTypesScanner(false)
+ );
return reflections.getSubTypesOf(type);
}
@@ -87,8 +84,28 @@ public class ClassDiscoveryServiceUsingReflections
}
public Vfs.Dir createDir(final URL url) throws Exception {
- return null;
+ return emptyVfsDir(url);
+ }
+
+ private static Vfs.Dir emptyVfsDir(final URL url) {
+ return new Vfs.Dir() {
+ @Override
+ public String getPath() {
+ return url.toExternalForm();
+ }
+
+ @Override
+ public Iterable<Vfs.File> getFiles() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public void close() {
+ //
+ }
+ };
}
+
}
public static class JettyConsoleUrlType implements Vfs.UrlType {
@@ -102,47 +119,47 @@ public class ClassDiscoveryServiceUsingReflections
public Vfs.Dir createDir(final URL url) throws Exception {
return new SystemDir(getFile(url));
}
- }
- /**
- * try to get {@link java.io.File} from url
- *
- * <p>
- * Copied from {@link org.reflections.vfs.Vfs} (not publicly accessible)
- * </p>
- */
- static java.io.File getFile(URL url) {
- java.io.File file;
- String path;
-
- try {
- path = url.toURI().getSchemeSpecificPart();
- if ((file = new java.io.File(path)).exists()) return file;
- } catch (URISyntaxException e) {
- }
+ /**
+ * try to get {@link java.io.File} from url
+ *
+ * <p>
+ * Copied from {@link org.reflections.vfs.Vfs} (not publicly accessible)
+ * </p>
+ */
+ static java.io.File getFile(URL url) {
+ java.io.File file;
+ String path;
+
+ try {
+ path = url.toURI().getSchemeSpecificPart();
+ if ((file = new java.io.File(path)).exists()) return file;
+ } catch (URISyntaxException e) {
+ }
+
+ try {
+ path = URLDecoder.decode(url.getPath(), "UTF-8");
+ if (path.contains(".jar!")) path = path.substring(0, path.lastIndexOf(".jar!") + ".jar".length());
+ if ((file = new java.io.File(path)).exists()) return file;
+
+ } catch (UnsupportedEncodingException e) {
+ }
+
+ try {
+ path = url.toExternalForm();
+ if (path.startsWith("jar:")) path = path.substring("jar:".length());
+ if (path.startsWith("file:")) path = path.substring("file:".length());
+ if (path.contains(".jar!")) path = path.substring(0, path.indexOf(".jar!") + ".jar".length());
+ if ((file = new java.io.File(path)).exists()) return file;
+
+ path = path.replace("%20", " ");
+ if ((file = new java.io.File(path)).exists()) return file;
+
+ } catch (Exception e) {
+ }
- try {
- path = URLDecoder.decode(url.getPath(), "UTF-8");
- if (path.contains(".jar!")) path = path.substring(0, path.lastIndexOf(".jar!") + ".jar".length());
- if ((file = new java.io.File(path)).exists()) return file;
-
- } catch (UnsupportedEncodingException e) {
- }
-
- try {
- path = url.toExternalForm();
- if (path.startsWith("jar:")) path = path.substring("jar:".length());
- if (path.startsWith("file:")) path = path.substring("file:".length());
- if (path.contains(".jar!")) path = path.substring(0, path.indexOf(".jar!") + ".jar".length());
- if ((file = new java.io.File(path)).exists()) return file;
-
- path = path.replace("%20", " ");
- if ((file = new java.io.File(path)).exists()) return file;
-
- } catch (Exception e) {
+ return null;
}
-
- return null;
}
}
\ No newline at end of file