protected void registerStopHook(Bus bus, final HttpService httpService, Server theServer,
final String contextRoot, final String propertyName) {
if (bus != null) {
theServer.getEndpoint().put(propertyName, contextRoot);
ServerLifeCycleListener stopHook = new ServerLifeCycleListener() {
public void stopServer(Server s) {
Object contextProperty = s.getEndpoint().get(propertyName);
if (contextProperty != null && contextProperty.equals(contextRoot)) {
httpService.unregister(contextRoot);
}