Helper method for generating the instance of a handler from its map
definition in config. Ie. No mapped values for setters, or list of
constructor fields.

@param handler
178201
private static void initMapDefinedHandler(Map<String, Object> handler) {
		// If the handler is a map, the keys are the class name, values are the
		// parameters.
		for (Map.Entry<String, Object> entry : handler.entrySet()) {
			Tuple<String, Class> namedClass = splitClassAndName(entry.getKey());

			// If the values in the config are a map, construct the object using named
			// parameters.
			if (entry.getValue() instanceof Map) {
				HttpHandler httpHandler;
				try {
					httpHandler = (HttpHandler) ServiceUtil.constructByNamedParams(namedClass.second,
							(Map) entry.getValue());
				} catch (Exception e) {
					throw new RuntimeException(
							"Could not construct a handler with values provided as a map: " + namedClass.second);
				}
				registerMiddlewareHandler(httpHandler);
				handlers.put(namedClass.first, httpHandler);
				handlerListById.put(namedClass.first, Collections.singletonList(httpHandler));
			} else if (entry.getValue() instanceof List) {

				// If the values in the config are a list, call the constructor of the handler
				// with those fields.
				HttpHandler httpHandler;
				try {
					httpHandler = (HttpHandler) ServiceUtil.constructByParameterizedConstructor(namedClass.second,
							(List) entry.getValue());
				} catch (Exception e) {
					throw new RuntimeException(
							"Could not construct a handler with values provided as a list: " + namedClass.second);
				}
				registerMiddlewareHandler(httpHandler);
				handlers.put(namedClass.first, httpHandler);
				handlerListById.put(namedClass.first, Collections.singletonList(httpHandler));
			}
		}
	}
761182
@Override
  public void registerErrorHandler(final EventHandler<Exception> handler) {
    this.clientEventListener.registerErrorHandler(handler);
    this.serverEventListener.registerErrorHandler(handler);
  }
917572
public JsHandlerRegistration addGeometryIndexDeselectedHandler(final GeometryIndexDeselectedHandler handler) {
		org.geomajas.plugin.editing.client.event.state.GeometryIndexDeselectedHandler h;
		h = new org.geomajas.plugin.editing.client.event.state.GeometryIndexDeselectedHandler() {

			public void onGeometryIndexDeselected(GeometryIndexDeselectedEvent event) {
				org.geomajas.plugin.editing.jsapi.client.event.state.GeometryIndexDeselectedEvent e;
				List<GeometryIndex> indices = event.getIndices();
				e = new org.geomajas.plugin.editing.jsapi.client.event.state.GeometryIndexDeselectedEvent(
						event.getGeometry(), indices.toArray(new GeometryIndex[indices.size()]));
				handler.onGeometryIndexDeselected(e);
			}
		};
		return new JsHandlerRegistration(new HandlerRegistration[] { delegate.addGeometryIndexDeselectedHandler(h) });
	}
533453
public void addHandler(AbstractHandler handler) {
    HandlerList handlers = new HandlerList();
    handlers.addHandler(handler);
    for (Handler h : mServer.getHandlers()) {
      handlers.addHandler(h);
    }
    mServer.setHandler(handlers);
  }
919427
@Nonnull
	public final LToLongFunctionBuilder<T> withHandling(@Nonnull HandlingInstructions<RuntimeException, RuntimeException> handling) {
		Null.nonNullArg(handling, "handling");
		if (this.handling != null) {
			throw new UnsupportedOperationException("Handling is already set for this builder.");
		}
		this.handling = handling;
		return self();
	}
1165774
@Export
	public JsHandlerRegistration addDispatchStoppedHandler(final DispatchStoppedHandler handler) {
		HandlerRegistration registration = GwtCommandDispatcher.getInstance().addDispatchStoppedHandler(
				new org.geomajas.gwt.client.command.event.DispatchStoppedHandler() {

					public void onDispatchStopped(DispatchStoppedEvent event) {
						handler.onDispatchStopped(new org.geomajas.plugin.jsapi.client.event.DispatchStoppedEvent());
					}
				});
		return new JsHandlerRegistration(new HandlerRegistration[] { registration });
	}
1060881
public HandlerRegistration setLocationNotFoundHandler(LocationNotFoundHandler handler) {
		if (handlerManager.getHandlerCount(LocationNotFoundHandler.TYPE) > 0) {
			LocationNotFoundHandler previous = handlerManager.getHandler(LocationNotFoundHandler.TYPE, 0);
			handlerManager.removeHandler(LocationNotFoundHandler.TYPE, previous);
		}
		return handlerManager.addHandler(LocationNotFoundHandler.TYPE, handler);
	}
741429
@Override
    public void setErrorHandler(ErrorHandler handler) {
        if (errorHandlerLocked) {
            return;
        }
        if (handler == null) {
            handler = base;
        }
        this.errorHandler = handler;
    }
946320
public void visit(Consumer<I_CmsAttributeHandler> handler) {

        handler.accept(this);
        for (CmsAttributeHandler child : m_handlerById.values()) {
            child.visit(handler);
        }
    }
1000286
@Export
	public JsHandlerRegistration addDispatchStartedHandler(final DispatchStartedHandler handler) {
		HandlerRegistration registration = GwtCommandDispatcher.getInstance().addDispatchStartedHandler(
				new org.geomajas.gwt.client.command.event.DispatchStartedHandler() {

					public void onDispatchStarted(DispatchStartedEvent event) {
						handler.onDispatchStarted(new org.geomajas.plugin.jsapi.client.event.DispatchStartedEvent());
					}
				});
		return new JsHandlerRegistration(new HandlerRegistration[] { registration });
	}
445573
public JsHandlerRegistration addGeometryEditMoveHandler(final GeometryEditMoveHandler handler) {
		org.geomajas.plugin.editing.client.event.GeometryEditMoveHandler h;
		h = new org.geomajas.plugin.editing.client.event.GeometryEditMoveHandler() {

			public void onGeometryEditMove(GeometryEditMoveEvent event) {
				List<GeometryIndex> indices = event.getIndices();
				handler.onGeometryEditMove(new org.geomajas.plugin.editing.jsapi.client.event.GeometryEditMoveEvent(
						event.getGeometry(), indices.toArray(new GeometryIndex[indices.size()])));
			}
		};
		HandlerRegistration registration = delegate.addGeometryEditMoveHandler(h);
		return new JsHandlerRegistration(new HandlerRegistration[] { registration });
	}
830475
public void setExceptionHandlers(Map<Class<? extends Exception>, InternalExceptionHandler> handlers) {
        requireNonNull(handlers);
        this.exceptionHandlers = handlers;
    }
666029
public void setHandler(Object handler){
        if(handler instanceof ContentHandler)
            setContentHandler((ContentHandler)handler);
        if(handler instanceof EntityResolver)
            setEntityResolver((EntityResolver)handler);
        if(handler instanceof ErrorHandler)
            setErrorHandler((ErrorHandler)handler);
        if(handler instanceof DTDHandler)
            setDTDHandler((DTDHandler)handler);
        if(handler instanceof LexicalHandler)
            setLexicalHandler((LexicalHandler)handler);
        if(handler instanceof DeclHandler)
            setDeclHandler((DeclHandler)handler);
    }
370398
@SuppressWarnings("unchecked")
    public <E extends Throwable> 
    ExceptionHandler<? super E> addExceptionHandler(
            Class<E> type, ExceptionHandler<? super E> handler) {
        exceptionHandlerCache.clear();
        return (ExceptionHandler<? super E>) exceptionHandlers.put(type, handler);
    }
603411
public JsHandlerRegistration addLayersModelChangedHandler(final LayersModelChangedHandler handler) {
		HandlerRegistration registration = ((MapImpl) map).getMapWidget().getMapModel()
				.addMapModelChangedHandler(new MapModelChangedHandler() {

					public void onMapModelChanged(MapModelChangedEvent event) {
						handler.onLayersModelChanged(new LayersModelChangedEvent(map.getLayersModel()));
					}
				});
		return new JsHandlerRegistration(new HandlerRegistration[] { registration });
	}
524046
private static void initPrefixHandlers()
    {
        PrefixHandlerConfig[] prefixHandlers = ConfigUtil.getConfig().getPrefixHandlers();
        if ( prefixHandlers == null )
        {
            return;
        }
        for ( int i = 0; i < prefixHandlers.length; i++ )
        {
            try
            {
                Class prefixClass = Class.forName( prefixHandlers[i].getHandlerClass() );
                String name = prefixHandlers[i].getName();
                if ( name == null || name.equals( "" ) )
                {
                    _log.warn( "The name for the prefix handler '" + prefixHandlers[i].getHandlerClass()
                            + "' must not be null" );
                    continue;
                }
                Object o = prefixClass.newInstance();
                if ( !( o instanceof RequestParameterHandler ) )
                {
                    _log.warn( "The class '" + prefixHandlers[i].getHandlerClass()
                            + "' must be an instance of RequestParameterHandler" );
                    continue;
                }
                ProcessPopulate.registerPrefixHandler( name, ( RequestParameterHandler ) o );
            }
            catch ( ClassNotFoundException e )
            {
                _log.warn( "Class '" + prefixHandlers[i].getHandlerClass() + "' not found", e );
            }
            catch ( IllegalAccessException e )
            {
                _log.warn( "Illegal access on Class '" + prefixHandlers[i].getHandlerClass() + "'", e );

            }
            catch ( InstantiationException e )
            {
                _log.warn( "InstantiationException on Class '" + prefixHandlers[i].getHandlerClass() + "'",
                        e.getCause() );
            }
        }
    }
249032
public static <T extends Exception> void exception(Class<T> exceptionClass, ExceptionHandler<? super T> handler) {
        getInstance().exception(exceptionClass, handler);
    }