Author: jdonnerstag
Date: Fri Jun 26 19:40:12 2009
New Revision: 788831
URL: http://svn.apache.org/viewvc?rev=788831&view=rev
Log:
fixed: Make ModificationWatcher replacable
Issue: WICKET-2340
Added:
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/watch/IModificationWatcher.java
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ReloadingClassLoader.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/IResourceSettings.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/Settings.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/watch/ModificationWatcher.java
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ReloadingClassLoader.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ReloadingClassLoader.java?rev=788831&r1=788830&r2=788831&view=diff
==============================================================================
---
wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ReloadingClassLoader.java
(original)
+++
wicket/trunk/wicket/src/main/java/org/apache/wicket/application/ReloadingClassLoader.java
Fri Jun 26 19:40:12 2009
@@ -29,6 +29,7 @@
import org.apache.wicket.util.file.File;
import org.apache.wicket.util.listener.IChangeListener;
import org.apache.wicket.util.time.Duration;
+import org.apache.wicket.util.watch.IModificationWatcher;
import org.apache.wicket.util.watch.ModificationWatcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,7 +53,7 @@
private final Duration pollFrequency = Duration.seconds(3);
- private final ModificationWatcher watcher;
+ private final IModificationWatcher watcher;
static
{
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java?rev=788831&r1=788830&r2=788831&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java
(original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java
Fri Jun 26 19:40:12 2009
@@ -31,6 +31,7 @@
import org.apache.wicket.util.resource.IResourceStream;
import org.apache.wicket.util.resource.ResourceStreamNotFoundException;
import org.apache.wicket.util.watch.IModifiable;
+import org.apache.wicket.util.watch.IModificationWatcher;
import org.apache.wicket.util.watch.ModificationWatcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -174,7 +175,7 @@
// resources no longer in the cache. Note that you can
not use
// Application.get() since removeMarkup() will be call
from a
// ModificationWatcher thread which has no associated
Application.
- final ModificationWatcher watcher =
application.getResourceSettings()
+ final IModificationWatcher watcher =
application.getResourceSettings()
.getResourceWatcher(true);
if (watcher != null)
{
@@ -528,7 +529,7 @@
return markup;
}
// Watch file in the future
- final ModificationWatcher watcher = Application.get()
+ final IModificationWatcher watcher = Application.get()
.getResourceSettings()
.getResourceWatcher(true);
if (watcher != null)
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java?rev=788831&r1=788830&r2=788831&view=diff
==============================================================================
---
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
(original)
+++
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
Fri Jun 26 19:40:12 2009
@@ -52,7 +52,7 @@
import org.apache.wicket.util.file.WebApplicationPath;
import org.apache.wicket.util.lang.Generics;
import org.apache.wicket.util.lang.PackageName;
-import org.apache.wicket.util.watch.ModificationWatcher;
+import org.apache.wicket.util.watch.IModificationWatcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -521,7 +521,7 @@
protected void internalDestroy()
{
// destroy the resource watcher
- ModificationWatcher resourceWatcher =
getResourceSettings().getResourceWatcher(false);
+ IModificationWatcher resourceWatcher =
getResourceSettings().getResourceWatcher(false);
if (resourceWatcher != null)
{
resourceWatcher.destroy();
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java?rev=788831&r1=788830&r2=788831&view=diff
==============================================================================
---
wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java
(original)
+++
wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java
Fri Jun 26 19:40:12 2009
@@ -33,6 +33,7 @@
import org.apache.wicket.util.resource.ResourceStreamNotFoundException;
import org.apache.wicket.util.resource.locator.IResourceStreamLocator;
import org.apache.wicket.util.value.ValueMap;
+import org.apache.wicket.util.watch.IModificationWatcher;
import org.apache.wicket.util.watch.ModificationWatcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -224,7 +225,7 @@
}
// Watch file modifications
- final ModificationWatcher watcher =
application.getResourceSettings()
+ final IModificationWatcher watcher =
application.getResourceSettings()
.getResourceWatcher(true);
if (watcher != null)
{
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/IResourceSettings.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/IResourceSettings.java?rev=788831&r1=788830&r2=788831&view=diff
==============================================================================
---
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/IResourceSettings.java
(original)
+++
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/IResourceSettings.java
Fri Jun 26 19:40:12 2009
@@ -30,7 +30,7 @@
import org.apache.wicket.util.file.IResourceFinder;
import org.apache.wicket.util.resource.locator.IResourceStreamLocator;
import org.apache.wicket.util.time.Duration;
-import org.apache.wicket.util.watch.ModificationWatcher;
+import org.apache.wicket.util.watch.IModificationWatcher;
/**
@@ -191,7 +191,7 @@
* @return Resource watcher with polling frequency determined by
setting, or null if no polling
* frequency has been set.
*/
- ModificationWatcher getResourceWatcher(boolean start);
+ IModificationWatcher getResourceWatcher(boolean start);
/**
* @see #addStringResourceLoader(IStringResourceLoader)
@@ -283,6 +283,13 @@
void setResourceStreamLocator(IResourceStreamLocator
resourceStreamLocator);
/**
+ * Sets the resource watcher
+ *
+ * @param watcher
+ */
+ void setResourceWatcher(IModificationWatcher watcher);
+
+ /**
* @see
org.apache.wicket.settings.IExceptionSettings#setThrowExceptionOnMissingResource(boolean)
*
* @param throwExceptionOnMissingResource
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/Settings.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/Settings.java?rev=788831&r1=788830&r2=788831&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/Settings.java
(original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/Settings.java
Fri Jun 26 19:40:12 2009
@@ -66,6 +66,7 @@
import org.apache.wicket.util.resource.locator.ResourceStreamLocator;
import org.apache.wicket.util.string.Strings;
import org.apache.wicket.util.time.Duration;
+import org.apache.wicket.util.watch.IModificationWatcher;
import org.apache.wicket.util.watch.ModificationWatcher;
@@ -236,7 +237,7 @@
private IResourceStreamLocator resourceStreamLocator;
/** ModificationWatcher to watch for changes in markup files */
- private ModificationWatcher resourceWatcher;
+ private IModificationWatcher resourceWatcher;
/** List of {...@link IResponseFilter}s. */
private List<IResponseFilter> responseFilters;
@@ -699,9 +700,9 @@
/**
* @see
org.apache.wicket.settings.IResourceSettings#getResourceWatcher(boolean)
*/
- public ModificationWatcher getResourceWatcher(boolean start)
+ public IModificationWatcher getResourceWatcher(boolean start)
{
- if (resourceWatcher == null && start)
+ if ((resourceWatcher == null) && start)
{
final Duration pollFrequency =
getResourcePollFrequency();
if (pollFrequency != null)
@@ -1110,6 +1111,14 @@
}
/**
+ * @see
org.apache.wicket.settings.IResourceSettings#setResourceWatcher(org.apache.wicket.util.watch.IModificationWatcher)
+ */
+ public void setResourceWatcher(IModificationWatcher watcher)
+ {
+ resourceWatcher = watcher;
+ }
+
+ /**
* @see
org.apache.wicket.settings.IRequestCycleSettings#setResponseRequestEncoding(java.lang.String)
*/
public void setResponseRequestEncoding(final String
responseRequestEncoding)
Added:
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/watch/IModificationWatcher.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/watch/IModificationWatcher.java?rev=788831&view=auto
==============================================================================
---
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/watch/IModificationWatcher.java
(added)
+++
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/watch/IModificationWatcher.java
Fri Jun 26 19:40:12 2009
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.util.watch;
+
+import java.util.Set;
+
+import org.apache.wicket.util.listener.IChangeListener;
+import org.apache.wicket.util.time.Duration;
+
+
+/**
+ * Monitors one or more <code>IModifiable</code> objects, calling a {...@link
IChangeListener
+ * IChangeListener} when a given object's modification time changes.
+ *
+ * @author Juergen Donnerstag
+ */
+public interface IModificationWatcher
+{
+ /**
+ * Adds an <code>IModifiable</code> object and an
<code>IChangeListener</code> object to call
+ * when the modifiable object is modified.
+ *
+ * @param modifiable
+ * an <code>IModifiable</code> object to monitor
+ * @param listener
+ * an <code>IChangeListener</code> to call if the
<code>IModifiable</code> object is
+ * modified
+ * @return <code>true</code> if the set did not already contain the
specified element
+ */
+ boolean add(final IModifiable modifiable, final IChangeListener
listener);
+
+ /**
+ * Removes all entries associated with an <code>IModifiable</code>
object.
+ *
+ * @param modifiable
+ * an <code>IModifiable</code> object
+ * @return the <code>IModifiable</code> object that was removed, else
<code>null</code>
+ */
+ IModifiable remove(final IModifiable modifiable);
+
+ /**
+ * Starts watching at a given <code>Duration</code> polling rate.
+ *
+ * @param pollFrequency
+ * the polling rate <code>Duration</code>
+ */
+ void start(final Duration pollFrequency);
+
+ /**
+ * Stops this <code>ModificationWatcher</code>.
+ */
+ void destroy();
+
+ /**
+ * Retrieves a key set of all <code>IModifiable</code> objects
currently being monitored.
+ *
+ * @return a <code>Set</code> of all <code>IModifiable</code> entries
currently maintained
+ */
+ Set<IModifiable> getEntries();
+}
\ No newline at end of file
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/watch/ModificationWatcher.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/watch/ModificationWatcher.java?rev=788831&r1=788830&r2=788831&view=diff
==============================================================================
---
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/watch/ModificationWatcher.java
(original)
+++
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/watch/ModificationWatcher.java
Fri Jun 26 19:40:12 2009
@@ -39,7 +39,7 @@
* @author Jonathan Locke
* @since 1.2.6
*/
-public final class ModificationWatcher
+public class ModificationWatcher implements IModificationWatcher
{
/** logger */
private static final Logger log =
LoggerFactory.getLogger(ModificationWatcher.class);
@@ -84,15 +84,7 @@
}
/**
- * Adds an <code>IModifiable</code> object and an
<code>IChangeListener</code> object to call
- * when the modifiable object is modified.
- *
- * @param modifiable
- * an <code>IModifiable</code> object to monitor
- * @param listener
- * an <code>IChangeListener</code> to call if the
<code>IModifiable</code> object is
- * modified
- * @return <code>true</code> if the set did not already contain the
specified element
+ * @see
org.apache.wicket.util.watch.IModificationWatcher#add(org.apache.wicket.util.watch.IModifiable,
org.apache.wicket.util.listener.IChangeListener)
*/
public final boolean add(final IModifiable modifiable, final
IChangeListener listener)
{
@@ -131,11 +123,7 @@
}
/**
- * Removes all entries associated with an <code>IModifiable</code>
object.
- *
- * @param modifiable
- * an <code>IModifiable</code> object
- * @return the <code>IModifiable</code> object that was removed, else
<code>null</code>
+ * @see
org.apache.wicket.util.watch.IModificationWatcher#remove(org.apache.wicket.util.watch.IModifiable)
*/
public IModifiable remove(final IModifiable modifiable)
{
@@ -148,10 +136,7 @@
}
/**
- * Starts watching at a given <code>Duration</code> polling rate.
- *
- * @param pollFrequency
- * the polling rate <code>Duration</code>
+ * @see
org.apache.wicket.util.watch.IModificationWatcher#start(org.apache.wicket.util.time.Duration)
*/
public void start(final Duration pollFrequency)
{
@@ -188,7 +173,7 @@
}
/**
- * Stops this <code>ModificationWatcher</code>.
+ * @see org.apache.wicket.util.watch.IModificationWatcher#destroy()
*/
public void destroy()
{
@@ -200,9 +185,7 @@
}
/**
- * Retrieves a key set of all <code>IModifiable</code> objects
currently being monitored.
- *
- * @return a <code>Set</code> of all <code>IModifiable</code> entries
currently maintained
+ * @see org.apache.wicket.util.watch.IModificationWatcher#getEntries()
*/
public final Set<IModifiable> getEntries()
{