You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2012/02/06 08:49:12 UTC
[2/4] git commit: WICKET-4388 o.a.w.util.file.WebApplicationPath
duplicates the same logic as o.a.w.util.file.Path
WICKET-4388
o.a.w.util.file.WebApplicationPath duplicates the same logic as o.a.w.util.file.Path
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/69016338
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/69016338
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/69016338
Branch: refs/heads/master
Commit: 69016338dbd7a31709262064e2eb89ee83f702fb
Parents: bff7149
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Mon Feb 6 09:47:31 2012 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Mon Feb 6 09:48:42 2012 +0200
----------------------------------------------------------------------
.../wicket/util/file/WebApplicationPath.java | 47 +++++++--------
.../java/org/apache/wicket/util/file/Path.java | 4 +-
2 files changed, 25 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/69016338/wicket-core/src/main/java/org/apache/wicket/util/file/WebApplicationPath.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/util/file/WebApplicationPath.java b/wicket-core/src/main/java/org/apache/wicket/util/file/WebApplicationPath.java
index 6861618..5e2737d 100644
--- a/wicket-core/src/main/java/org/apache/wicket/util/file/WebApplicationPath.java
+++ b/wicket-core/src/main/java/org/apache/wicket/util/file/WebApplicationPath.java
@@ -22,7 +22,6 @@ import java.util.List;
import javax.servlet.ServletContext;
-import org.apache.wicket.util.resource.FileResourceStream;
import org.apache.wicket.util.resource.IResourceStream;
import org.apache.wicket.util.resource.UrlResourceStream;
import org.apache.wicket.util.string.StringList;
@@ -36,16 +35,13 @@ import org.slf4j.LoggerFactory;
*
* @author Johan Compagner
*/
-public final class WebApplicationPath implements IResourcePath
+public final class WebApplicationPath extends Path
{
private final static Logger log = LoggerFactory.getLogger(WebApplicationPath.class);
/** The list of urls in the path */
private final List<String> webappPaths = new ArrayList<String>();
- /** The list of folders in the path */
- private final List<Folder> folders = new ArrayList<Folder>();
-
/** The web apps servlet context */
private final ServletContext servletContext;
@@ -73,7 +69,7 @@ public final class WebApplicationPath implements IResourcePath
final Folder folder = new Folder(path);
if (folder.exists())
{
- folders.add(folder);
+ super.add(folder);
}
else
{
@@ -96,41 +92,42 @@ public final class WebApplicationPath implements IResourcePath
@Override
public IResourceStream find(final Class<?> clazz, final String pathname)
{
- for (Folder folder : folders)
- {
- final File file = new File(folder, pathname);
- if (file.exists())
- {
- return new FileResourceStream(file);
- }
- }
+ IResourceStream resourceStream = super.find(clazz, pathname);
- for (String path : webappPaths)
+ if (resourceStream == null)
{
- try
+ for (String path : webappPaths)
{
- final URL url = servletContext.getResource(path + pathname);
- if (url != null)
+ try
{
- return new UrlResourceStream(url);
+ final URL url = servletContext.getResource(path + pathname);
+ if (url != null)
+ {
+ resourceStream = new UrlResourceStream(url);
+ break;
+ }
+ }
+ catch (Exception ex)
+ {
+ // ignore, file couldn't be found
}
- }
- catch (Exception ex)
- {
- // ignore, file couldn't be found
}
}
- return null;
+ return resourceStream;
}
+ public List<String> getWebappPaths()
+ {
+ return webappPaths;
+ }
/**
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{
- return "[folders = " + StringList.valueOf(folders) + ", webapppaths: " +
+ return "[folders = " + StringList.valueOf(getFolders()) + ", webapppaths: " +
StringList.valueOf(webappPaths) + "]";
}
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/69016338/wicket-util/src/main/java/org/apache/wicket/util/file/Path.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/file/Path.java b/wicket-util/src/main/java/org/apache/wicket/util/file/Path.java
index a09fb4a..107acc6 100644
--- a/wicket-util/src/main/java/org/apache/wicket/util/file/Path.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/file/Path.java
@@ -29,7 +29,7 @@ import org.apache.wicket.util.string.StringList;
*
* @author Jonathan Locke
*/
-public final class Path implements IResourcePath
+public class Path implements IResourcePath
{
/** The list of folders in the path */
private final List<Folder> folders = new ArrayList<Folder>();
@@ -88,6 +88,7 @@ public final class Path implements IResourcePath
* Folder to add to path
* @see org.apache.wicket.util.file.IResourcePath#add(java.lang.String)
*/
+ @Override
public void add(final String path)
{
add(new Folder(path));
@@ -97,6 +98,7 @@ public final class Path implements IResourcePath
*
* @see org.apache.wicket.util.file.IResourceFinder#find(Class, String)
*/
+ @Override
public IResourceStream find(final Class<?> clazz, final String pathname)
{
for (Folder folder : folders)