Search in sources :

Example 1 with IRequestMapperDelegate

use of org.apache.wicket.request.mapper.IRequestMapperDelegate in project wicket by apache.

the class WebApplication method unmount.

/**
 * Unregisters all {@link IRequestMapper}s which would match on a this path.
 * <p>
 * Useful in OSGi environments where a bundle may want to update the mount point.
 * </p>
 *
 * @param path
 *            the path to unmount
 */
public void unmount(String path) {
    Args.notNull(path, "path");
    if (path.charAt(0) == '/') {
        path = path.substring(1);
    }
    IRequestMapper mapper = getRootRequestMapper();
    while (mapper instanceof IRequestMapperDelegate) {
        mapper = ((IRequestMapperDelegate) mapper).getDelegateMapper();
    }
    /*
		 * Only attempt to unmount if root request mapper is either a compound, or wraps a compound to avoid leaving the
		 * application with no mappers installed.
		 */
    if (mapper instanceof ICompoundRequestMapper) {
        final Url url = Url.parse(path);
        Request request = new Request() {

            @Override
            public Url getUrl() {
                return url;
            }

            @Override
            public Url getClientUrl() {
                return url;
            }

            @Override
            public Locale getLocale() {
                return null;
            }

            @Override
            public Charset getCharset() {
                return null;
            }

            @Override
            public Object getContainerRequest() {
                return null;
            }
        };
        unmountFromCompound((ICompoundRequestMapper) mapper, request);
    }
}
Also used : ICompoundRequestMapper(org.apache.wicket.request.mapper.ICompoundRequestMapper) IRequestMapperDelegate(org.apache.wicket.request.mapper.IRequestMapperDelegate) WebRequest(org.apache.wicket.request.http.WebRequest) Request(org.apache.wicket.request.Request) ServletWebRequest(org.apache.wicket.protocol.http.servlet.ServletWebRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) IRequestMapper(org.apache.wicket.request.IRequestMapper) Url(org.apache.wicket.request.Url)

Aggregations

HttpServletRequest (javax.servlet.http.HttpServletRequest)1 ServletWebRequest (org.apache.wicket.protocol.http.servlet.ServletWebRequest)1 IRequestMapper (org.apache.wicket.request.IRequestMapper)1 Request (org.apache.wicket.request.Request)1 Url (org.apache.wicket.request.Url)1 WebRequest (org.apache.wicket.request.http.WebRequest)1 ICompoundRequestMapper (org.apache.wicket.request.mapper.ICompoundRequestMapper)1 IRequestMapperDelegate (org.apache.wicket.request.mapper.IRequestMapperDelegate)1