Java Code Examples for org.springframework.messaging.handler.HandlerMethod#equals()

The following examples show how to use org.springframework.messaging.handler.HandlerMethod#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractMethodMessageHandler.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * 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
 * @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);
	}
}
 
Example 2
Source File: AbstractMethodMessageHandler.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * 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
 * @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);

	for (String pattern : getDirectLookupDestinations(mapping)) {
		this.destinationLookup.add(pattern, mapping);
	}
}
 
Example 3
Source File: AbstractMethodMessageHandler.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * 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
 * @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.isTraceEnabled()) {
		logger.trace("Mapped \"" + mapping + "\" onto " + newHandlerMethod);
	}

	for (String pattern : getDirectLookupDestinations(mapping)) {
		this.destinationLookup.add(pattern, mapping);
	}
}
 
Example 4
Source File: AbstractMethodMessageHandler.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * 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
 * @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);
	}
}