You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by sv...@apache.org on 2015/10/16 14:33:50 UTC

[7/8] wicket git commit: WICKET-6004 Wicket 8 cleanup - removed old MountMapper

WICKET-6004 Wicket 8 cleanup - removed old MountMapper


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/fb540d93
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/fb540d93
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/fb540d93

Branch: refs/heads/master
Commit: fb540d93ac75ede57f847fc4b42bc7e3bde38f7f
Parents: cf51882
Author: Sven Meier <sv...@apache.org>
Authored: Tue Oct 13 12:32:32 2015 +0200
Committer: Sven Meier <sv...@apache.org>
Committed: Fri Oct 16 14:24:53 2015 +0200

----------------------------------------------------------------------
 .../mapper/mount/IMountedRequestMapper.java     |  70 --------
 .../wicket/request/mapper/mount/Mount.java      |  73 --------
 .../request/mapper/mount/MountMapper.java       | 174 -------------------
 .../request/mapper/mount/MountParameters.java   | 121 -------------
 .../mapper/mount/UnmountedMapperAdapter.java    |  80 ---------
 .../mount/UnmountedRequestHandlerAdapter.java   |  77 --------
 6 files changed, 595 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/fb540d93/wicket-request/src/main/java/org/apache/wicket/request/mapper/mount/IMountedRequestMapper.java
----------------------------------------------------------------------
diff --git a/wicket-request/src/main/java/org/apache/wicket/request/mapper/mount/IMountedRequestMapper.java b/wicket-request/src/main/java/org/apache/wicket/request/mapper/mount/IMountedRequestMapper.java
deleted file mode 100644
index 3100b78..0000000
--- a/wicket-request/src/main/java/org/apache/wicket/request/mapper/mount/IMountedRequestMapper.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.request.mapper.mount;
-
-import org.apache.wicket.request.IRequestHandler;
-import org.apache.wicket.request.Request;
-
-/**
- * TODO javadoc, explain "parameters resolved from the mount"
- * 
- * @author igor.vaynberg
- * @deprecated Will be removed in Wicket 8.0
- */
-@Deprecated
-public interface IMountedRequestMapper
-{
-	/**
-	 * Returns {@link org.apache.wicket.request.IRequestHandler} for the request or <code>null</code> if the encoder does not
-	 * recognize the URL.
-	 *
-	 * @param request
-	 *            provides access to request data (i.e. Url and Parameters)
-	 * @param mountParams
-	 *            parameters resolved from the mount
-	 * @return RequestHandler instance or <code>null</code>
-	 */
-	IRequestHandler mapRequest(Request request, MountParameters mountParams);
-
-	/**
-	 * Returns the score representing how compatible this request mapper is to processing the given
-	 * request. When a request comes in all mappers are scored and are tried in order from highest
-	 * score to lowest.
-	 * <p>
-	 * A good criteria for calculating the score is the number of matched url segments. For example
-	 * when there are two encoders for mounted page, one mapped to <code>/foo</code> another to
-	 * <code>/foo/bar</code> and the incomming reqest URL is </code>/foo/bar/baz</code>, the encoder
-	 * mapped to <code>/foo/bar</code> will handle the request first as it has matching segments
-	 * count of 2 while the first one has only matching segments count of 1.
-	 * <p>
-	 * Note that the method can return value greater then zero even if the encoder can not decode
-	 * the request.
-	 *
-	 * @param request
-	 * @return count of matching segments
-	 */
-	int getCompatibilityScore(Request request);
-
-	/**
-	 * Returns the {@link Mount} for given {@link org.apache.wicket.request.IRequestHandler} or <code>null</code> if the
-	 * encoder does not recognize the request handler.
-	 * 
-	 * @param requestHandler
-	 * @return Url instance or <code>null</code>.
-	 */
-	Mount mapHandler(IRequestHandler requestHandler);
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/fb540d93/wicket-request/src/main/java/org/apache/wicket/request/mapper/mount/Mount.java
----------------------------------------------------------------------
diff --git a/wicket-request/src/main/java/org/apache/wicket/request/mapper/mount/Mount.java b/wicket-request/src/main/java/org/apache/wicket/request/mapper/mount/Mount.java
deleted file mode 100644
index 5040bf7..0000000
--- a/wicket-request/src/main/java/org/apache/wicket/request/mapper/mount/Mount.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.request.mapper.mount;
-
-import org.apache.wicket.request.Url;
-
-/**
- * @deprecated Will be removed in Wicket 8.0
- */
-@Deprecated
-public class Mount
-{
-	/**
-	 * The {@link org.apache.wicket.request.Url} to mount on
-	 */
-	private final Url url;
-
-	/**
-	 * A map of placeholder key/value pairs for the {@link #url}'s segments
-	 */
-	private MountParameters mountParameters = new MountParameters();
-
-	/**
-	 * Construct.
-	 * 
-	 * @param url
-	 */
-	public Mount(final Url url)
-	{
-		this.url = url;
-	}
-
-	/**
-	 * 
-	 * @param mountParameters
-	 */
-	public void setMountParameters(final MountParameters mountParameters)
-	{
-		this.mountParameters = mountParameters;
-	}
-
-	/**
-	 * 
-	 * @return mount parameters
-	 */
-	public MountParameters getMountParameters()
-	{
-		return mountParameters;
-	}
-
-	/**
-	 * 
-	 * @return Url
-	 */
-	public Url getUrl()
-	{
-		return url;
-	}
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/fb540d93/wicket-request/src/main/java/org/apache/wicket/request/mapper/mount/MountMapper.java
----------------------------------------------------------------------
diff --git a/wicket-request/src/main/java/org/apache/wicket/request/mapper/mount/MountMapper.java b/wicket-request/src/main/java/org/apache/wicket/request/mapper/mount/MountMapper.java
deleted file mode 100644
index 40d0edd..0000000
--- a/wicket-request/src/main/java/org/apache/wicket/request/mapper/mount/MountMapper.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * 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.request.mapper.mount;
-
-import org.apache.wicket.request.IRequestHandler;
-import org.apache.wicket.request.IRequestMapper;
-import org.apache.wicket.request.Request;
-import org.apache.wicket.request.Url;
-import org.apache.wicket.request.mapper.AbstractMapper;
-import org.apache.wicket.util.lang.Args;
-import org.apache.wicket.util.lang.Checks;
-import org.apache.wicket.util.string.StringValue;
-
-/**
- * {@link org.apache.wicket.request.IRequestMapper} that can mount requests onto urls. TODO docs and unit test
- *
- * @author igor.vaynberg
- * @deprecated Will be removed in Wicket 8.0
- */
-@Deprecated
-public class MountMapper extends AbstractMapper
-{
-	private final String[] mountSegments;
-	private final IMountedRequestMapper mapper;
-
-	/**
-	 * Construct.
-	 *
-	 * @param mountPath
-	 * @param mapper
-	 */
-	public MountMapper(final String mountPath, final IMountedRequestMapper mapper)
-	{
-		Args.notEmpty(mountPath, "mountPath");
-		Args.notNull(mapper, "mapper");
-
-		mountSegments = getMountSegments(mountPath);
-		this.mapper = mapper;
-	}
-
-	/**
-	 * Construct.
-	 *
-	 * @param mountPath
-	 * @param mapper
-	 */
-	public MountMapper(final String mountPath, final IRequestMapper mapper)
-	{
-		Args.notEmpty(mountPath, "mountPath");
-		Args.notNull(mapper, "mapper");
-
-		mountSegments = getMountSegments(mountPath);
-		this.mapper = new UnmountedMapperAdapter(mapper);
-	}
-
-	/**
-	 * Construct.
-	 *
-	 * @param mountPath
-	 * @param handler
-	 */
-	public MountMapper(final String mountPath, final IRequestHandler handler)
-	{
-		Args.notEmpty(mountPath, "mountPath");
-		Args.notNull(handler, "handler");
-
-		mountSegments = getMountSegments(mountPath);
-		mapper = new UnmountedRequestHandlerAdapter(handler);
-	}
-
-	/**
-	 * @see org.apache.wicket.request.IRequestMapper#getCompatibilityScore(org.apache.wicket.request.Request)
-	 */
-	@Override
-	public int getCompatibilityScore(final Request request)
-	{
-		if (urlStartsWith(request.getUrl(), mountSegments))
-		{
-			return mountSegments.length + mapper.getCompatibilityScore(dismountRequest(request));
-		}
-		else
-		{
-			return 0;
-		}
-	}
-
-	/**
-	 *
-	 * @param request
-	 *            a {@link org.apache.wicket.request.Request} with the all mount segments - mount ones and the ones for the
-	 *            delegated mapper
-	 * @return a {@link org.apache.wicket.request.Request} with {@link org.apache.wicket.request.Url} without the mount segments
-	 */
-	private Request dismountRequest(final Request request)
-	{
-		Url dismountedUrl = new Url(request.getUrl());
-		dismountedUrl.removeLeadingSegments(mountSegments.length);
-		return request.cloneWithUrl(dismountedUrl);
-	}
-
-	/**
-	 * @see org.apache.wicket.request.IRequestMapper#mapRequest(org.apache.wicket.request.Request)
-	 */
-	@Override
-	public final IRequestHandler mapRequest(final Request request)
-	{
-		final Url url = request.getUrl();
-
-		if ((url.getSegments().size() >= mountSegments.length) && urlStartsWith(url, mountSegments))
-		{
-			MountParameters params = new MountParameters();
-			for (int i = 0; i < mountSegments.length; i++)
-			{
-				String placeholder = getPlaceholder(mountSegments[i]);
-				if (placeholder != null)
-				{
-					params.setValue(placeholder, StringValue.valueOf(url.getSegments().get(i)));
-				}
-			}
-
-			return mapper.mapRequest(dismountRequest(request), params);
-		}
-
-		return null;
-	}
-
-	/**
-	 * @see org.apache.wicket.request.IRequestMapper#mapHandler(org.apache.wicket.request.IRequestHandler)
-	 */
-	@Override
-	public Url mapHandler(final IRequestHandler handler)
-	{
-		Mount mount = mapper.mapHandler(handler);
-		if (mount == null)
-		{
-			return null;
-		}
-
-		Checks.notNull(mount.getUrl(), "Mount's Url should not be null");
-		Checks.notNull(mount.getMountParameters(), "Mount's parameters should not be null");
-
-		for (int i = mountSegments.length; i > 0; i--)
-		{
-			String segment = mountSegments[i - 1];
-			String placeholder = getPlaceholder(segment);
-			String replacement = segment;
-
-			if (placeholder != null)
-			{
-				replacement = mount.getMountParameters().getValue(placeholder).toString();
-				Checks.notNull(replacement, "Cannot find a value for placeholder '%s'.",
-						placeholder);
-			}
-
-			mount.getUrl().getSegments().add(0, replacement);
-		}
-
-		return mount.getUrl();
-	}
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/fb540d93/wicket-request/src/main/java/org/apache/wicket/request/mapper/mount/MountParameters.java
----------------------------------------------------------------------
diff --git a/wicket-request/src/main/java/org/apache/wicket/request/mapper/mount/MountParameters.java b/wicket-request/src/main/java/org/apache/wicket/request/mapper/mount/MountParameters.java
deleted file mode 100644
index f5340fb..0000000
--- a/wicket-request/src/main/java/org/apache/wicket/request/mapper/mount/MountParameters.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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.request.mapper.mount;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.wicket.util.string.StringValue;
-
-/**
- * A container for the placeholders (e.g. ${placeholder}) found in the mount segments
- * 
- * @author igor.vaynberg
- * @deprecated Will be removed in Wicket 8.0
- */
-@Deprecated
-public class MountParameters
-{
-	private final Map<String, String> map = new HashMap<>();
-
-	/**
-	 * 
-	 * @param parameterName
-	 *            the name of the placeholder
-	 * @return a StringValue which contains either the actual value if there is a placeholder with
-	 *         name <code>parameterName</code> or <code>null</code> otherwise
-	 */
-	public final StringValue getValue(final String parameterName)
-	{
-		return StringValue.valueOf(map.get(parameterName));
-	}
-
-	/**
-	 * Sets new placeholder name/pair
-	 * 
-	 * @param parameterName
-	 * @param value
-	 */
-	public final void setValue(final String parameterName, final StringValue value)
-	{
-		map.put(parameterName, value.toString());
-	}
-
-	/**
-	 * @return an unmodifiable view of the parameters names
-	 */
-	public final Collection<String> getParameterNames()
-	{
-		return Collections.unmodifiableCollection(map.keySet());
-	}
-
-	/**
-	 * @see java.lang.Object#hashCode()
-	 */
-	@Override
-	public int hashCode()
-	{
-		final int prime = 31;
-		int result = 1;
-		result = prime * result + ((map == null) ? 0 : map.hashCode());
-		return result;
-	}
-
-	/**
-	 * @see java.lang.Object#equals(java.lang.Object)
-	 */
-	@Override
-	public boolean equals(final Object obj)
-	{
-		if (this == obj)
-		{
-			return true;
-		}
-		if (obj == null)
-		{
-			return false;
-		}
-		if (getClass() != obj.getClass())
-		{
-			return false;
-		}
-		MountParameters other = (MountParameters)obj;
-		if (map == null)
-		{
-			if (other.map != null)
-			{
-				return false;
-			}
-		}
-		else if (!map.equals(other.map))
-		{
-			return false;
-		}
-		return true;
-	}
-
-	/**
-	 * @see java.lang.Object#toString()
-	 */
-	@Override
-	public String toString()
-	{
-		return "MountParameters [" + map + "]";
-	}
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/fb540d93/wicket-request/src/main/java/org/apache/wicket/request/mapper/mount/UnmountedMapperAdapter.java
----------------------------------------------------------------------
diff --git a/wicket-request/src/main/java/org/apache/wicket/request/mapper/mount/UnmountedMapperAdapter.java b/wicket-request/src/main/java/org/apache/wicket/request/mapper/mount/UnmountedMapperAdapter.java
deleted file mode 100644
index a969b44..0000000
--- a/wicket-request/src/main/java/org/apache/wicket/request/mapper/mount/UnmountedMapperAdapter.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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.request.mapper.mount;
-
-import org.apache.wicket.request.IRequestHandler;
-import org.apache.wicket.request.IRequestMapper;
-import org.apache.wicket.request.Request;
-import org.apache.wicket.request.Url;
-
-/**
- * Adapts a {@link org.apache.wicket.request.IRequestMapper} to be used as a {@link IMountedRequestMapper}
- * 
- * TODO javadoc
- * 
- * @author igor.vaynberg
- * @deprecated Will be removed in Wicket 8.0
- */
-@Deprecated
-class UnmountedMapperAdapter implements IMountedRequestMapper
-{
-	private final IRequestMapper mapper;
-
-	/**
-	 * Construct.
-	 * 
-	 * @param mapper
-	 */
-	public UnmountedMapperAdapter(final IRequestMapper mapper)
-	{
-		super();
-		this.mapper = mapper;
-	}
-
-	/**
-	 * @see org.apache.wicket.request.mapper.mount.IMountedRequestMapper#getCompatibilityScore(org.apache.wicket.request.Request)
-	 */
-	@Override
-	public int getCompatibilityScore(final Request request)
-	{
-		return mapper.getCompatibilityScore(request);
-	}
-
-	/**
-	 * @see org.apache.wicket.request.mapper.mount.IMountedRequestMapper#mapHandler(org.apache.wicket.request.IRequestHandler)
-	 */
-	@Override
-	public Mount mapHandler(final IRequestHandler requestHandler)
-	{
-		Url url = mapper.mapHandler(requestHandler);
-		if (url != null)
-		{
-			return new Mount(url);
-		}
-		return null;
-	}
-
-	/**
-	 * @see org.apache.wicket.request.mapper.mount.IMountedRequestMapper#mapRequest(org.apache.wicket.request.Request,
-	 *      org.apache.wicket.request.mapper.mount.MountParameters)
-	 */
-	@Override
-	public IRequestHandler mapRequest(final Request request, final MountParameters mountParams)
-	{
-		return mapper.mapRequest(request);
-	}
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/fb540d93/wicket-request/src/main/java/org/apache/wicket/request/mapper/mount/UnmountedRequestHandlerAdapter.java
----------------------------------------------------------------------
diff --git a/wicket-request/src/main/java/org/apache/wicket/request/mapper/mount/UnmountedRequestHandlerAdapter.java b/wicket-request/src/main/java/org/apache/wicket/request/mapper/mount/UnmountedRequestHandlerAdapter.java
deleted file mode 100644
index 7c345d5..0000000
--- a/wicket-request/src/main/java/org/apache/wicket/request/mapper/mount/UnmountedRequestHandlerAdapter.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.request.mapper.mount;
-
-import org.apache.wicket.request.IRequestHandler;
-import org.apache.wicket.request.Request;
-import org.apache.wicket.request.Url;
-
-/**
- * Adapts a singleton {@link org.apache.wicket.request.IRequestHandler} instance to {@link IMountedRequestMapper}
- * 
- * TODO javadoc
- * 
- * @author igor.vaynberg
- * @deprecated Will be removed in Wicket 8.0
- */
-@Deprecated
-class UnmountedRequestHandlerAdapter implements IMountedRequestMapper
-{
-	private final IRequestHandler handler;
-
-	/**
-	 * Construct.
-	 * 
-	 * @param handler
-	 */
-	public UnmountedRequestHandlerAdapter(final IRequestHandler handler)
-	{
-		this.handler = handler;
-	}
-
-	/**
-	 * @see org.apache.wicket.request.mapper.mount.IMountedRequestMapper#getCompatibilityScore(org.apache.wicket.request.Request)
-	 */
-	@Override
-	public int getCompatibilityScore(final Request request)
-	{
-		return 0;
-	}
-
-	/**
-	 * @see org.apache.wicket.request.mapper.mount.IMountedRequestMapper#mapHandler(org.apache.wicket.request.IRequestHandler)
-	 */
-	@Override
-	public Mount mapHandler(final IRequestHandler requestHandler)
-	{
-		if (requestHandler.equals(handler))
-		{
-			return new Mount(new Url());
-		}
-		return null;
-	}
-
-	/**
-	 * @see org.apache.wicket.request.mapper.mount.IMountedRequestMapper#mapRequest(org.apache.wicket.request.Request,
-	 *      org.apache.wicket.request.mapper.mount.MountParameters)
-	 */
-	@Override
-	public IRequestHandler mapRequest(final Request request, final MountParameters mountParams)
-	{
-		return handler;
-	}
-}