use of org.apache.wicket.request.mapper.ICompoundRequestMapper in project wicket by apache.
the class Application method getRootRequestMapperAsCompound.
/**
* Converts the root mapper to a {@link ICompoundRequestMapper} if necessary and returns the
* converted instance.
*
* @return compound instance of the root mapper
*/
public final ICompoundRequestMapper getRootRequestMapperAsCompound() {
IRequestMapper root = getRootRequestMapper();
if (!(root instanceof ICompoundRequestMapper)) {
root = new SystemMapper(this).add(root);
setRootRequestMapper(root);
}
return (ICompoundRequestMapper) root;
}
use of org.apache.wicket.request.mapper.ICompoundRequestMapper 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);
}
}
Aggregations