Example usage for org.springframework.messaging.handler HandlerMethod equals

List of usage examples for org.springframework.messaging.handler HandlerMethod equals

Introduction

In this page you can find the example usage for org.springframework.messaging.handler HandlerMethod equals.

Prototype

@Override
    public boolean equals(@Nullable Object other) 

Source Link

Usage

From source file:org.springframework.messaging.handler.invocation.AbstractMethodMessageHandler.java

/**
 * Register a handler method and its unique mapping.
 * @param handler the bean name of the handler or the handler instance
 * @param method the method to register/*ww w . j a v  a2  s  .c  om*/
 * @param mapping the mapping conditions associated with the handler method
 * @throws IllegalStateException if another method was already registered
 * under the same mapping
 */
protected void registerHandlerMethod(Object handler, Method method, T mapping) {
    Assert.notNull(mapping, "Mapping must not be null");
    HandlerMethod newHandlerMethod = createHandlerMethod(handler, method);
    HandlerMethod oldHandlerMethod = this.handlerMethods.get(mapping);

    if (oldHandlerMethod != null && !oldHandlerMethod.equals(newHandlerMethod)) {
        throw new IllegalStateException("Ambiguous mapping found. Cannot map '" + newHandlerMethod.getBean()
                + "' bean method \n" + newHandlerMethod + "\nto " + mapping + ": There is already '"
                + oldHandlerMethod.getBean() + "' bean method\n" + oldHandlerMethod + " mapped.");
    }

    this.handlerMethods.put(mapping, newHandlerMethod);
    if (logger.isInfoEnabled()) {
        logger.info("Mapped \"" + mapping + "\" onto " + newHandlerMethod);
    }

    for (String pattern : getDirectLookupDestinations(mapping)) {
        this.destinationLookup.add(pattern, mapping);
    }
}

From source file:org.springframework.messaging.handler.invocation.reactive.AbstractMethodMessageHandler.java

/**
 * Register a handler method and its unique mapping.
 * <p><strong>Note:</strong> This method is protected and can be invoked by
 * sub-classes. Keep in mind however that the registration is not protected
 * for concurrent use, and is expected to be done on startup.
 * @param handler the bean name of the handler or the handler instance
 * @param method the method to register//ww w.  j  av  a 2s .  co  m
 * @param mapping the mapping conditions associated with the handler method
 * @throws IllegalStateException if another method was already registered
 * under the same mapping
 */
protected final void registerHandlerMethod(Object handler, Method method, T mapping) {
    Assert.notNull(mapping, "Mapping must not be null");
    HandlerMethod newHandlerMethod = createHandlerMethod(handler, method);
    HandlerMethod oldHandlerMethod = this.handlerMethods.get(mapping);

    if (oldHandlerMethod != null && !oldHandlerMethod.equals(newHandlerMethod)) {
        throw new IllegalStateException("Ambiguous mapping found. Cannot map '" + newHandlerMethod.getBean()
                + "' bean method \n" + newHandlerMethod + "\nto " + mapping + ": There is already '"
                + oldHandlerMethod.getBean() + "' bean method\n" + oldHandlerMethod + " mapped.");
    }

    this.handlerMethods.put(mapping, newHandlerMethod);

    for (String pattern : getDirectLookupMappings(mapping)) {
        this.destinationLookup.add(pattern, mapping);
    }
}