You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by cm...@apache.org on 2012/07/03 15:11:42 UTC
git commit: WICKET-4617 some cleanup
Updated Branches:
refs/heads/sandbox/resourcefinder 3b7febb59 -> 12ee50952
WICKET-4617 some cleanup
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/12ee5095
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/12ee5095
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/12ee5095
Branch: refs/heads/sandbox/resourcefinder
Commit: 12ee50952a0e75c6cf22a607a902894611dc16ef
Parents: 3b7febb
Author: Carl-Eric Menzel <cm...@wicketbuch.de>
Authored: Tue Jul 3 15:11:06 2012 +0200
Committer: Carl-Eric Menzel <cm...@wicketbuch.de>
Committed: Tue Jul 3 15:11:06 2012 +0200
----------------------------------------------------------------------
.../main/java/org/apache/wicket/Application.java | 16 --------
.../wicket/core/util/file/WebApplicationPath.java | 2 +-
.../util/resource/ClassPathResourceFinder.java | 21 ++++++++++-
.../resource/locator/ResourceStreamLocator.java | 6 +---
.../wicket/protocol/http/WebApplication.java | 28 ++++-----------
.../apache/wicket/settings/IResourceSettings.java | 10 -----
.../wicket/settings/def/ResourceSettings.java | 10 +-----
.../java/org/apache/wicket/util/file/Path.java | 2 +-
8 files changed, 31 insertions(+), 64 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/12ee5095/wicket-core/src/main/java/org/apache/wicket/Application.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/Application.java b/wicket-core/src/main/java/org/apache/wicket/Application.java
index e50cc0d..98a7145 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Application.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Application.java
@@ -109,9 +109,6 @@ import org.apache.wicket.settings.def.ResourceSettings;
import org.apache.wicket.settings.def.SecuritySettings;
import org.apache.wicket.settings.def.StoreSettings;
import org.apache.wicket.util.IProvider;
-import org.apache.wicket.util.file.Folder;
-import org.apache.wicket.util.file.IResourceFinder;
-import org.apache.wicket.util.file.Path;
import org.apache.wicket.util.io.IOUtils;
import org.apache.wicket.util.io.Streams;
import org.apache.wicket.util.lang.Args;
@@ -1703,17 +1700,4 @@ public abstract class Application implements UnboundListener, IEventSink
{
return RuntimeConfigurationType.DEPLOYMENT.equals(getConfigurationType());
}
-
- /**
- * Create a resource finder to look in the given path. The default implementation returns a
- * {@link Path} which will look in the filesystem.
- *
- * @param path
- * path
- * @return a {@link Path}
- */
- public IResourceFinder getResourceFinderForPath(String path)
- {
- return new Path(new Folder(path));
- }
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/12ee5095/wicket-core/src/main/java/org/apache/wicket/core/util/file/WebApplicationPath.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/file/WebApplicationPath.java b/wicket-core/src/main/java/org/apache/wicket/core/util/file/WebApplicationPath.java
index 7bdd94d..412a084 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/util/file/WebApplicationPath.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/util/file/WebApplicationPath.java
@@ -43,7 +43,7 @@ public final class WebApplicationPath implements IResourceFinder
/** The web apps servlet context */
private final ServletContext servletContext;
- private String path;
+ private final String path;
/**
* Constructor
http://git-wip-us.apache.org/repos/asf/wicket/blob/12ee5095/wicket-core/src/main/java/org/apache/wicket/core/util/resource/ClassPathResourceFinder.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/resource/ClassPathResourceFinder.java b/wicket-core/src/main/java/org/apache/wicket/core/util/resource/ClassPathResourceFinder.java
index bc304cf..fc4e029 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/util/resource/ClassPathResourceFinder.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/util/resource/ClassPathResourceFinder.java
@@ -19,6 +19,7 @@ package org.apache.wicket.core.util.resource;
import java.net.URL;
import org.apache.wicket.util.file.IResourceFinder;
+import org.apache.wicket.util.lang.Args;
import org.apache.wicket.util.resource.IResourceStream;
import org.apache.wicket.util.string.Strings;
@@ -41,6 +42,10 @@ public class ClassPathResourceFinder implements IResourceFinder
{
this.prefix = "";
}
+ else if (prefix.endsWith("/"))
+ {
+ this.prefix = prefix;
+ }
else
{
this.prefix = prefix + "/";
@@ -50,7 +55,8 @@ public class ClassPathResourceFinder implements IResourceFinder
@Override
public IResourceStream find(Class<?> clazz, String path)
{
- String fullPath = prefix + path;
+ Args.notEmpty(path, "path");
+ String fullPath = prefix + (path.startsWith("/") ? path.substring(1) : path);
IResourceStream resourceStream;
if (clazz != null)
{
@@ -92,4 +98,17 @@ public class ClassPathResourceFinder implements IResourceFinder
}
return null;
}
+
+ @Override
+ public String toString()
+ {
+ if (Strings.isEmpty(prefix))
+ {
+ return "[classpath]";
+ }
+ else
+ {
+ return "[classpath: " + prefix + "]";
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/12ee5095/wicket-core/src/main/java/org/apache/wicket/core/util/resource/locator/ResourceStreamLocator.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/resource/locator/ResourceStreamLocator.java b/wicket-core/src/main/java/org/apache/wicket/core/util/resource/locator/ResourceStreamLocator.java
index d18910d..e81a679 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/util/resource/locator/ResourceStreamLocator.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/util/resource/locator/ResourceStreamLocator.java
@@ -126,11 +126,7 @@ public class ResourceStreamLocator implements IResourceStreamLocator
IResourceStream result;
for (IResourceFinder finder : finders)
{
- // Log attempt
- if (log.isDebugEnabled())
- {
- log.debug("Attempting to locate resource '" + path + "' on path " + finder);
- }
+ log.debug("Attempting to locate resource '{}' using finder'{}'", path, finder);
result = finder.find(clazz, path);
if (result != null)
{
http://git-wip-us.apache.org/repos/asf/wicket/blob/12ee5095/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
index f2775b5..7a3892a 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
@@ -75,7 +75,6 @@ import org.apache.wicket.util.IProvider;
import org.apache.wicket.util.crypt.CharEncoding;
import org.apache.wicket.util.file.FileCleaner;
import org.apache.wicket.util.file.IFileCleaner;
-import org.apache.wicket.util.file.IResourceFinder;
import org.apache.wicket.util.file.Path;
import org.apache.wicket.util.lang.Args;
import org.apache.wicket.util.lang.PackageName;
@@ -635,13 +634,15 @@ public abstract class WebApplication extends Application
getResourceSettings().setFileCleaner(new FileCleaner());
- // Add optional sourceFolder for resources.
- String resourceFolder = getInitParameter("sourceFolder");
- if (resourceFolder != null)
+ if (getConfigurationType() == RuntimeConfigurationType.DEVELOPMENT)
{
- getResourceSettings().addResourceFolder(resourceFolder);
+ // Add optional sourceFolder for resources.
+ String resourceFolder = getInitParameter("sourceFolder");
+ if (resourceFolder != null)
+ {
+ getResourceSettings().getResourceFinders().add(new Path(resourceFolder));
+ }
}
-
setPageRendererProvider(new WebPageRendererProvider());
setSessionStoreProvider(new WebSessionStoreProvider());
setAjaxRequestTargetProvider(new DefaultAjaxRequestTargetProvider());
@@ -788,21 +789,6 @@ public abstract class WebApplication extends Application
}
/**
- * Create a resource finder to look in the given path. The implementation in
- * {@link WebApplication} returns a {@link WebApplicationPath} which will look in the webapp
- * context.
- *
- * @param path
- * path
- * @return a {@link Path}
- */
- @Override
- public IResourceFinder getResourceFinderForPath(String path)
- {
- return new WebApplicationPath(getServletContext(), path);
- }
-
- /**
* Creates a new ajax request target used to control ajax responses
*
* @param page
http://git-wip-us.apache.org/repos/asf/wicket/blob/12ee5095/wicket-core/src/main/java/org/apache/wicket/settings/IResourceSettings.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/settings/IResourceSettings.java b/wicket-core/src/main/java/org/apache/wicket/settings/IResourceSettings.java
index 8e89ed9..c9edd31 100644
--- a/wicket-core/src/main/java/org/apache/wicket/settings/IResourceSettings.java
+++ b/wicket-core/src/main/java/org/apache/wicket/settings/IResourceSettings.java
@@ -93,16 +93,6 @@ public interface IResourceSettings extends IPropertiesFactoryContext
void addResourceFactory(final String name, final IResourceFactory resourceFactory);
/**
- * Convenience method that sets the resource search path to a single folder. use when searching
- * for resources. By default, the resources are located on the classpath. If you want to
- * configure other, additional, search paths, you can use this method
- *
- * @param resourceFolder
- * The resourceFolder to set
- */
- void addResourceFolder(final String resourceFolder);
-
- /**
* Get the the default cache duration for resources.
* <p/>
*
http://git-wip-us.apache.org/repos/asf/wicket/blob/12ee5095/wicket-core/src/main/java/org/apache/wicket/settings/def/ResourceSettings.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/settings/def/ResourceSettings.java b/wicket-core/src/main/java/org/apache/wicket/settings/def/ResourceSettings.java
index 5c7c472..cc613a4 100644
--- a/wicket-core/src/main/java/org/apache/wicket/settings/def/ResourceSettings.java
+++ b/wicket-core/src/main/java/org/apache/wicket/settings/def/ResourceSettings.java
@@ -200,15 +200,6 @@ public class ResourceSettings implements IResourceSettings
}
/**
- * @see org.apache.wicket.settings.IResourceSettings#addResourceFolder(java.lang.String)
- */
- @Override
- public void addResourceFolder(final String resourceFolder)
- {
- getResourceFinders().add(Application.get().getResourceFinderForPath(resourceFolder));
- }
-
- /**
* @see org.apache.wicket.settings.IResourceSettings#getLocalizer()
*/
@Override
@@ -384,6 +375,7 @@ public class ResourceSettings implements IResourceSettings
@Override
public void setResourceFinders(final List<IResourceFinder> resourceFinders)
{
+ Args.notNull(resourceFinders, "resourceFinders");
this.resourceFinders = resourceFinders;
// Cause resource locator to get recreated
http://git-wip-us.apache.org/repos/asf/wicket/blob/12ee5095/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 efa1924..7338e73 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
@@ -30,7 +30,7 @@ import org.apache.wicket.util.resource.IResourceStream;
*/
public class Path implements IResourceFinder
{
- private Folder folder;
+ private final Folder folder;
/**
* Constructor