Author: ivaynberg
Date: Sat Mar 6 08:47:58 2010
New Revision: 919714
URL: http://svn.apache.org/viewvc?rev=919714&view=rev
Log:
cleaned up compound mappers. deprecated convenience mount methods in
application; they no longer make sense since request mappers can be chained in
front of each other potentially providing multiple mounting points in the url
scheme so the application can no longer know where to mount the page. this
change does require the users to know about MountedMapper directly but i dont
think it is a big deal
Added:
wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/CompoundRequestMapper.java
- copied, changed from r919712,
wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/ThreadsafeCompoundRequestMapper.java
Removed:
wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/ThreadsafeCompoundRequestMapper.java
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/Application.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/SystemMapper.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/ICompoundRequestMapper.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/request/CryptedUrlWebRequestCodingStrategyTest.java
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/Application.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/Application.java?rev=919714&r1=919713&r2=919714&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/Application.java
(original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/Application.java Sat
Mar 6 08:47:58 2010
@@ -50,7 +50,7 @@
import org.apache.wicket.markup.resolver.WicketMessageResolver;
import org.apache.wicket.ng.DefaultExceptionMapper;
import org.apache.wicket.ng.ThreadContext;
-import org.apache.wicket.ng.request.ICompoundRequestMapper;
+import org.apache.wicket.ng.request.IRequestMapper;
import org.apache.wicket.ng.request.component.IRequestablePage;
import org.apache.wicket.ng.request.component.PageParameters;
import org.apache.wicket.ng.request.cycle.RequestCycle;
@@ -171,7 +171,7 @@
private List<IHeaderContributor> renderHeadListeners;
/** root mapper */
- private ICompoundRequestMapper rootRequestMapper;
+ private IRequestMapper rootRequestMapper;
/** list of {...@link IComponentInstantiationListener}s. */
private IComponentInstantiationListener[]
componentInstantiationListeners = new IComponentInstantiationListener[0];
@@ -1202,7 +1202,7 @@
/**
* @return The root request mapper
*/
- public final ICompoundRequestMapper getRootRequestMapper()
+ public final IRequestMapper getRootRequestMapper()
{
return rootRequestMapper;
}
@@ -1212,7 +1212,7 @@
*
* @param rootRequestMapper
*/
- public final void setRootRequestMapper(final ICompoundRequestMapper
rootRequestMapper)
+ public final void setRootRequestMapper(final IRequestMapper
rootRequestMapper)
{
this.rootRequestMapper = rootRequestMapper;
}
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/SystemMapper.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/SystemMapper.java?rev=919714&r1=919713&r2=919714&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/SystemMapper.java
(original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/SystemMapper.java Sat
Mar 6 08:47:58 2010
@@ -18,10 +18,10 @@
import org.apache.wicket.ng.request.mapper.BookmarkableMapper;
import org.apache.wicket.ng.request.mapper.BufferedResponseMapper;
+import org.apache.wicket.ng.request.mapper.CompoundRequestMapper;
import org.apache.wicket.ng.request.mapper.HomePageMapper;
import org.apache.wicket.ng.request.mapper.PageInstanceMapper;
import org.apache.wicket.ng.request.mapper.ResourceReferenceMapper;
-import org.apache.wicket.ng.request.mapper.ThreadsafeCompoundRequestMapper;
import
org.apache.wicket.ng.request.mapper.parameters.SimplePageParametersEncoder;
import org.apache.wicket.util.IProvider;
@@ -32,20 +32,20 @@
* @author igor.vaynberg
*
*/
-public class SystemMapper extends ThreadsafeCompoundRequestMapper
+public class SystemMapper extends CompoundRequestMapper
{
/**
* Constructor
*/
public SystemMapper(Application application)
{
- register(RestartResponseAtInterceptPageException.MAPPER);
- register(new HomePageMapper());
- register(new PageInstanceMapper());
- register(new BookmarkableMapper());
- register(new ResourceReferenceMapper(new
SimplePageParametersEncoder(),
+ add(RestartResponseAtInterceptPageException.MAPPER);
+ add(new HomePageMapper());
+ add(new PageInstanceMapper());
+ add(new BookmarkableMapper());
+ add(new ResourceReferenceMapper(new
SimplePageParametersEncoder(),
new ParentFolderPlaceholderProvider(application)));
- register(new BufferedResponseMapper());
+ add(new BufferedResponseMapper());
}
private static class ParentFolderPlaceholderProvider implements
IProvider<String>
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/ICompoundRequestMapper.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/ICompoundRequestMapper.java?rev=919714&r1=919713&r2=919714&view=diff
==============================================================================
---
wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/ICompoundRequestMapper.java
(original)
+++
wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/ICompoundRequestMapper.java
Sat Mar 6 08:47:58 2010
@@ -17,21 +17,26 @@
package org.apache.wicket.ng.request;
/**
- * Mapper that delegates the mapping to other {...@link IRequestMapper}s.
+ * Mapper that delegates the mapping to a contained {...@link IRequestMapper}s
with the highest
+ * compatibility score.
+ *
+ * @author igor.vaynberg
*/
-public interface ICompoundRequestMapper extends IRequestMapper
+public interface ICompoundRequestMapper extends IRequestMapper,
Iterable<IRequestMapper>
{
/**
* Registers a {...@link IRequestMapper}
*
* @param encoder
+ * @return {...@code this} for chaining
*/
- void register(IRequestMapper encoder);
+ ICompoundRequestMapper add(IRequestMapper encoder);
/**
* Unregisters {...@link IRequestMapper}
*
* @param encoder
+ * @return {...@code this} for chaining
*/
- void unregister(IRequestMapper encoder);
+ ICompoundRequestMapper remove(IRequestMapper encoder);
}
\ No newline at end of file
Copied:
wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/CompoundRequestMapper.java
(from r919712,
wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/ThreadsafeCompoundRequestMapper.java)
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/CompoundRequestMapper.java?p2=wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/CompoundRequestMapper.java&p1=wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/ThreadsafeCompoundRequestMapper.java&r1=919712&r2=919714&rev=919714&view=diff
==============================================================================
---
wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/ThreadsafeCompoundRequestMapper.java
(original)
+++
wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/CompoundRequestMapper.java
Sat Mar 6 08:47:58 2010
@@ -18,6 +18,7 @@
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -33,9 +34,10 @@
* compatibility score and the orders they were registered. If two or more
{...@link IRequestMapper}s
* have the same compatibility score, the last registered mapper has highest
priority.
*
+ * @author igor.vaynberg
* @author Matej Knopp
*/
-public class ThreadsafeCompoundRequestMapper implements ICompoundRequestMapper
+public class CompoundRequestMapper implements ICompoundRequestMapper
{
/**
*
@@ -67,24 +69,26 @@
/**
* Construct.
*/
- public ThreadsafeCompoundRequestMapper()
+ public CompoundRequestMapper()
{
}
/**
- * @see
org.apache.wicket.ng.request.ICompoundRequestMapper#register(org.apache.wicket.ng.request.IRequestMapper)
+ * @see
org.apache.wicket.ng.request.ICompoundRequestMapper#add(org.apache.wicket.ng.request.IRequestMapper)
*/
- public void register(IRequestMapper encoder)
+ public CompoundRequestMapper add(IRequestMapper encoder)
{
mappers.add(0, encoder);
+ return this;
}
/**
- * @see
org.apache.wicket.ng.request.ICompoundRequestMapper#unregister(org.apache.wicket.ng.request.IRequestMapper)
+ * @see
org.apache.wicket.ng.request.ICompoundRequestMapper#remove(org.apache.wicket.ng.request.IRequestMapper)
*/
- public void unregister(IRequestMapper encoder)
+ public CompoundRequestMapper remove(IRequestMapper encoder)
{
mappers.remove(encoder);
+ return this;
}
/**
@@ -162,4 +166,10 @@
}
return score;
}
+
+ /** {...@inheritdoc} */
+ public Iterator<IRequestMapper> iterator()
+ {
+ return mappers.iterator();
+ }
}
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=919714&r1=919713&r2=919714&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
Sat Mar 6 08:47:58 2010
@@ -37,11 +37,13 @@
import org.apache.wicket.markup.html.pages.PageExpiredErrorPage;
import org.apache.wicket.markup.resolver.AutoLinkResolver;
import org.apache.wicket.ng.ThreadContext;
+import org.apache.wicket.ng.request.ICompoundRequestMapper;
import org.apache.wicket.ng.request.IRequestMapper;
import org.apache.wicket.ng.request.Url;
import org.apache.wicket.ng.request.handler.impl.RenderPageRequestHandler;
import org.apache.wicket.ng.request.handler.impl.render.PageRenderer;
import org.apache.wicket.ng.request.handler.impl.render.WebPageRenderer;
+import org.apache.wicket.ng.request.mapper.CompoundRequestMapper;
import org.apache.wicket.ng.request.mapper.MountedMapper;
import org.apache.wicket.ng.resource.ResourceReference;
import org.apache.wicket.session.HttpSessionStore;
@@ -279,12 +281,30 @@
*
* @param mapper
* the encoder that will be used for this mount
+ *
+ * @deprecated this is the same as {...@code
getRotmapperAsCompound().add(mapper)}
*/
+ @Deprecated
public final void mount(IRequestMapper mapper)
{
Checks.argumentNotNull(mapper, "mapper");
+ getRootMapperAsCompound().add(mapper);
+ }
- getRootRequestMapper().register(mapper);
+ /**
+ * Converts the root mapper to a {...@link ICompoundRequestMapper} if
necessary and returns the
+ * converted instance.
+ *
+ * @return compound instance of the root mapper
+ */
+ public ICompoundRequestMapper getRootMapperAsCompound()
+ {
+ IRequestMapper root = getRootRequestMapper();
+ if (!(root instanceof ICompoundRequestMapper))
+ {
+ root = new CompoundRequestMapper().add(root);
+ }
+ return (ICompoundRequestMapper)root;
}
@@ -298,7 +318,11 @@
* the path to mount the bookmarkable page class on
* @param bookmarkablePageClass
* the bookmarkable page class to mount
+ *
+ * @deprecated use mounted mapper instead, this method can be
represented as {...@code
+ * getRootMapperAsCompound().mount(new
MountedMapper(path,clazz))}
*/
+ @Deprecated
public final <T extends Page> void mountBookmarkablePage(final String
path,
final Class<T> bookmarkablePageClass)
{
@@ -313,7 +337,10 @@
* the path to mount the resource class on
* @param reference
* resource reference to be mounted
+ *
+ * @deprecated - not sure what to use yet but this will be deprecated :)
*/
+ @Deprecated
public final void mountSharedResource(final String path, final
ResourceReference reference)
{
getResourceReferenceRegistry().registerResourceReference(reference);
@@ -333,6 +360,7 @@
*/
public final void addIgnoreMountPath(String path)
{
+ // TODO how is this supposed to work :/
throw new UnsupportedOperationException();
}
Modified:
wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/request/CryptedUrlWebRequestCodingStrategyTest.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/request/CryptedUrlWebRequestCodingStrategyTest.java?rev=919714&r1=919713&r2=919714&view=diff
==============================================================================
---
wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/request/CryptedUrlWebRequestCodingStrategyTest.java
(original)
+++
wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/request/CryptedUrlWebRequestCodingStrategyTest.java
Sat Mar 6 08:47:58 2010
@@ -21,8 +21,8 @@
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.SimplePage;
import org.apache.wicket.ng.mock.MockApplication;
+import org.apache.wicket.ng.request.mapper.CompoundRequestMapper;
import org.apache.wicket.ng.request.mapper.CryptoMapper;
-import org.apache.wicket.ng.request.mapper.ThreadsafeCompoundRequestMapper;
import org.apache.wicket.util.crypt.Base64;
import org.apache.wicket.util.crypt.ICrypt;
import org.apache.wicket.util.crypt.ICryptFactory;
@@ -47,8 +47,8 @@
super.init();
// install crypto mapper to encrypt all
application urls
getSecuritySettings().setCryptFactory(new
TestCryptFactory());
- ThreadsafeCompoundRequestMapper root = new
ThreadsafeCompoundRequestMapper();
- root.register(new
CryptoMapper(getRootRequestMapper(), this));
+ CompoundRequestMapper root = new
CompoundRequestMapper();
+ root.add(new
CryptoMapper(getRootRequestMapper(), this));
setRootRequestMapper(root);
}
});