Java Code Examples for org.springframework.web.method.HandlerMethod#equals()

The following examples show how to use org.springframework.web.method.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: AbstractHandlerMethodMapping.java    From java-technology-stack with MIT License 6 votes vote down vote up
private void addMappingName(String name, HandlerMethod handlerMethod) {
	List<HandlerMethod> oldList = this.nameLookup.get(name);
	if (oldList == null) {
		oldList = Collections.emptyList();
	}

	for (HandlerMethod current : oldList) {
		if (handlerMethod.equals(current)) {
			return;
		}
	}

	List<HandlerMethod> newList = new ArrayList<>(oldList.size() + 1);
	newList.addAll(oldList);
	newList.add(handlerMethod);
	this.nameLookup.put(name, newList);
}
 
Example 2
Source File: AbstractHandlerMethodMapping.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
private void removeMappingName(MappingRegistration<T> definition) {
	String name = definition.getMappingName();
	if (name == null) {
		return;
	}
	HandlerMethod handlerMethod = definition.getHandlerMethod();
	List<HandlerMethod> oldList = this.nameLookup.get(name);
	if (oldList == null) {
		return;
	}
	if (oldList.size() <= 1) {
		this.nameLookup.remove(name);
		return;
	}
	List<HandlerMethod> newList = new ArrayList<HandlerMethod>(oldList.size() - 1);
	for (HandlerMethod current : oldList) {
		if (!current.equals(handlerMethod)) {
			newList.add(current);
		}
	}
	this.nameLookup.put(name, newList);
}
 
Example 3
Source File: AbstractHandlerMethodMapping.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private void removeMappingName(MappingRegistration<T> definition) {
	String name = definition.getMappingName();
	if (name == null) {
		return;
	}
	HandlerMethod handlerMethod = definition.getHandlerMethod();
	List<HandlerMethod> oldList = this.nameLookup.get(name);
	if (oldList == null) {
		return;
	}
	if (oldList.size() <= 1) {
		this.nameLookup.remove(name);
		return;
	}
	List<HandlerMethod> newList = new ArrayList<HandlerMethod>(oldList.size() - 1);
	for (HandlerMethod current : oldList) {
		if (!current.equals(handlerMethod)) {
			newList.add(current);
		}
	}
	this.nameLookup.put(name, newList);
}
 
Example 4
Source File: AbstractHandlerMethodMapping.java    From java-technology-stack with MIT License 6 votes vote down vote up
private void removeMappingName(MappingRegistration<T> definition) {
	String name = definition.getMappingName();
	if (name == null) {
		return;
	}
	HandlerMethod handlerMethod = definition.getHandlerMethod();
	List<HandlerMethod> oldList = this.nameLookup.get(name);
	if (oldList == null) {
		return;
	}
	if (oldList.size() <= 1) {
		this.nameLookup.remove(name);
		return;
	}
	List<HandlerMethod> newList = new ArrayList<>(oldList.size() - 1);
	for (HandlerMethod current : oldList) {
		if (!current.equals(handlerMethod)) {
			newList.add(current);
		}
	}
	this.nameLookup.put(name, newList);
}
 
Example 5
Source File: AbstractHandlerMethodMapping.java    From spring-analysis-note with MIT License 6 votes vote down vote up
private void removeMappingName(MappingRegistration<T> definition) {
	String name = definition.getMappingName();
	if (name == null) {
		return;
	}
	HandlerMethod handlerMethod = definition.getHandlerMethod();
	List<HandlerMethod> oldList = this.nameLookup.get(name);
	if (oldList == null) {
		return;
	}
	if (oldList.size() <= 1) {
		this.nameLookup.remove(name);
		return;
	}
	List<HandlerMethod> newList = new ArrayList<>(oldList.size() - 1);
	for (HandlerMethod current : oldList) {
		if (!current.equals(handlerMethod)) {
			newList.add(current);
		}
	}
	this.nameLookup.put(name, newList);
}
 
Example 6
Source File: AbstractHandlerMethodMapping.java    From spring-analysis-note with MIT License 6 votes vote down vote up
private void addMappingName(String name, HandlerMethod handlerMethod) {
	List<HandlerMethod> oldList = this.nameLookup.get(name);
	if (oldList == null) {
		oldList = Collections.emptyList();
	}

	for (HandlerMethod current : oldList) {
		if (handlerMethod.equals(current)) {
			return;
		}
	}

	List<HandlerMethod> newList = new ArrayList<>(oldList.size() + 1);
	newList.addAll(oldList);
	newList.add(handlerMethod);
	this.nameLookup.put(name, newList);
}
 
Example 7
Source File: AbstractHandlerMethodMapping.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected CorsConfiguration getCorsConfiguration(Object handler, ServerWebExchange exchange) {
	CorsConfiguration corsConfig = super.getCorsConfiguration(handler, exchange);
	if (handler instanceof HandlerMethod) {
		HandlerMethod handlerMethod = (HandlerMethod) handler;
		if (handlerMethod.equals(PREFLIGHT_AMBIGUOUS_MATCH)) {
			return ALLOW_CORS_CONFIG;
		}
		CorsConfiguration methodConfig = this.mappingRegistry.getCorsConfiguration(handlerMethod);
		corsConfig = (corsConfig != null ? corsConfig.combine(methodConfig) : methodConfig);
	}
	return corsConfig;
}
 
Example 8
Source File: AbstractHandlerMethodMapping.java    From java-technology-stack with MIT License 5 votes vote down vote up
private void assertUniqueMethodMapping(HandlerMethod newHandlerMethod, T mapping) {
	HandlerMethod handlerMethod = this.mappingLookup.get(mapping);
	if (handlerMethod != null && !handlerMethod.equals(newHandlerMethod)) {
		throw new IllegalStateException(
				"Ambiguous mapping. Cannot map '" + newHandlerMethod.getBean() + "' method \n" +
						newHandlerMethod + "\nto " + mapping + ": There is already '" +
						handlerMethod.getBean() + "' bean method\n" + handlerMethod + " mapped.");
	}
}
 
Example 9
Source File: AbstractHandlerMethodMapping.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected CorsConfiguration getCorsConfiguration(Object handler, HttpServletRequest request) {
	CorsConfiguration corsConfig = super.getCorsConfiguration(handler, request);
	if (handler instanceof HandlerMethod) {
		HandlerMethod handlerMethod = (HandlerMethod) handler;
		if (handlerMethod.equals(PREFLIGHT_AMBIGUOUS_MATCH)) {
			return AbstractHandlerMethodMapping.ALLOW_CORS_CONFIG;
		}
		else {
			CorsConfiguration corsConfigFromMethod = this.mappingRegistry.getCorsConfiguration(handlerMethod);
			corsConfig = (corsConfig != null ? corsConfig.combine(corsConfigFromMethod) : corsConfigFromMethod);
		}
	}
	return corsConfig;
}
 
Example 10
Source File: AbstractHandlerMethodMapping.java    From java-technology-stack with MIT License 5 votes vote down vote up
private void assertUniqueMethodMapping(HandlerMethod newHandlerMethod, T mapping) {
	HandlerMethod handlerMethod = this.mappingLookup.get(mapping);
	if (handlerMethod != null && !handlerMethod.equals(newHandlerMethod)) {
		throw new IllegalStateException(
				"Ambiguous mapping. Cannot map '" +	newHandlerMethod.getBean() + "' method \n" +
				newHandlerMethod + "\nto " + mapping + ": There is already '" +
				handlerMethod.getBean() + "' bean method\n" + handlerMethod + " mapped.");
	}
}
 
Example 11
Source File: AbstractHandlerMethodMapping.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
protected CorsConfiguration getCorsConfiguration(Object handler, ServerWebExchange exchange) {
	CorsConfiguration corsConfig = super.getCorsConfiguration(handler, exchange);
	if (handler instanceof HandlerMethod) {
		HandlerMethod handlerMethod = (HandlerMethod) handler;
		if (handlerMethod.equals(PREFLIGHT_AMBIGUOUS_MATCH)) {
			return ALLOW_CORS_CONFIG;
		}
		CorsConfiguration methodConfig = this.mappingRegistry.getCorsConfiguration(handlerMethod);
		corsConfig = (corsConfig != null ? corsConfig.combine(methodConfig) : methodConfig);
	}
	return corsConfig;
}
 
Example 12
Source File: AbstractHandlerMethodMapping.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private void validateMethodMapping(HandlerMethod handlerMethod, T mapping) {
	// Assert that the supplied mapping is unique.
	HandlerMethod existingHandlerMethod = this.mappingLookup.get(mapping);
	if (existingHandlerMethod != null && !existingHandlerMethod.equals(handlerMethod)) {
		throw new IllegalStateException(
				"Ambiguous mapping. Cannot map '" + handlerMethod.getBean() + "' method \n" +
				handlerMethod + "\nto " + mapping + ": There is already '" +
				existingHandlerMethod.getBean() + "' bean method\n" + existingHandlerMethod + " mapped.");
	}
}
 
Example 13
Source File: AbstractHandlerMethodMapping.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected CorsConfiguration getCorsConfiguration(Object handler, HttpServletRequest request) {
	CorsConfiguration corsConfig = super.getCorsConfiguration(handler, request);
	if (handler instanceof HandlerMethod) {
		HandlerMethod handlerMethod = (HandlerMethod) handler;
		if (handlerMethod.equals(PREFLIGHT_AMBIGUOUS_MATCH)) {
			return AbstractHandlerMethodMapping.ALLOW_CORS_CONFIG;
		}
		else {
			CorsConfiguration corsConfigFromMethod = this.mappingRegistry.getCorsConfiguration(handlerMethod);
			corsConfig = (corsConfig != null ? corsConfig.combine(corsConfigFromMethod) : corsConfigFromMethod);
		}
	}
	return corsConfig;
}
 
Example 14
Source File: AbstractHandlerMethodMapping.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private void assertUniqueMethodMapping(HandlerMethod newHandlerMethod, T mapping) {
	HandlerMethod handlerMethod = this.mappingLookup.get(mapping);
	if (handlerMethod != null && !handlerMethod.equals(newHandlerMethod)) {
		throw new IllegalStateException(
				"Ambiguous mapping. Cannot map '" +	newHandlerMethod.getBean() + "' method \n" +
				newHandlerMethod + "\nto " + mapping + ": There is already '" +
				handlerMethod.getBean() + "' bean method\n" + handlerMethod + " mapped.");
	}
}
 
Example 15
Source File: AbstractHandlerMethodMapping.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private void addMappingName(String name, HandlerMethod handlerMethod) {
	List<HandlerMethod> oldList = this.nameLookup.get(name);
	if (oldList == null) {
		oldList = Collections.<HandlerMethod>emptyList();
	}

	for (HandlerMethod current : oldList) {
		if (handlerMethod.equals(current)) {
			return;
		}
	}

	if (logger.isTraceEnabled()) {
		logger.trace("Mapping name '" + name + "'");
	}

	List<HandlerMethod> newList = new ArrayList<HandlerMethod>(oldList.size() + 1);
	newList.addAll(oldList);
	newList.add(handlerMethod);
	this.nameLookup.put(name, newList);

	if (newList.size() > 1) {
		if (logger.isTraceEnabled()) {
			logger.trace("Mapping name clash for handlerMethods " + newList +
					". Consider assigning explicit names.");
		}
	}
}
 
Example 16
Source File: AbstractHandlerMethodMapping.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
protected CorsConfiguration getCorsConfiguration(Object handler, HttpServletRequest request) {
	CorsConfiguration corsConfig = super.getCorsConfiguration(handler, request);
	if (handler instanceof HandlerMethod) {
		HandlerMethod handlerMethod = (HandlerMethod) handler;
		if (handlerMethod.equals(PREFLIGHT_AMBIGUOUS_MATCH)) {
			return AbstractHandlerMethodMapping.ALLOW_CORS_CONFIG;
		}
		else {
			CorsConfiguration corsConfigFromMethod = this.mappingRegistry.getCorsConfiguration(handlerMethod);
			corsConfig = (corsConfig != null ? corsConfig.combine(corsConfigFromMethod) : corsConfigFromMethod);
		}
	}
	return corsConfig;
}
 
Example 17
Source File: AbstractHandlerMethodMapping.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected CorsConfiguration getCorsConfiguration(Object handler, HttpServletRequest request) {
	CorsConfiguration corsConfig = super.getCorsConfiguration(handler, request);
	if (handler instanceof HandlerMethod) {
		HandlerMethod handlerMethod = (HandlerMethod) handler;
		if (handlerMethod.equals(PREFLIGHT_AMBIGUOUS_MATCH)) {
			return AbstractHandlerMethodMapping.ALLOW_CORS_CONFIG;
		}
		else {
			CorsConfiguration corsConfigFromMethod = this.mappingRegistry.getCorsConfiguration(handlerMethod);
			corsConfig = (corsConfig != null ? corsConfig.combine(corsConfigFromMethod) : corsConfigFromMethod);
		}
	}
	return corsConfig;
}
 
Example 18
Source File: AbstractHandlerMethodMapping.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private void assertUniqueMethodMapping(HandlerMethod newHandlerMethod, T mapping) {
	HandlerMethod handlerMethod = this.mappingLookup.get(mapping);
	if (handlerMethod != null && !handlerMethod.equals(newHandlerMethod)) {
		throw new IllegalStateException(
				"Ambiguous mapping. Cannot map '" +	newHandlerMethod.getBean() + "' method \n" +
				newHandlerMethod + "\nto " + mapping + ": There is already '" +
				handlerMethod.getBean() + "' bean method\n" + handlerMethod + " mapped.");
	}
}
 
Example 19
Source File: AbstractHandlerMethodMapping.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private void addMappingName(String name, HandlerMethod handlerMethod) {
	List<HandlerMethod> oldList = this.nameLookup.get(name);
	if (oldList == null) {
		oldList = Collections.<HandlerMethod>emptyList();
	}

	for (HandlerMethod current : oldList) {
		if (handlerMethod.equals(current)) {
			return;
		}
	}

	if (logger.isTraceEnabled()) {
		logger.trace("Mapping name '" + name + "'");
	}

	List<HandlerMethod> newList = new ArrayList<HandlerMethod>(oldList.size() + 1);
	newList.addAll(oldList);
	newList.add(handlerMethod);
	this.nameLookup.put(name, newList);

	if (newList.size() > 1) {
		if (logger.isTraceEnabled()) {
			logger.trace("Mapping name clash for handlerMethods " + newList +
					". Consider assigning explicit names.");
		}
	}
}
 
Example 20
Source File: AbstractHandlerMethodMapping.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private void validateMethodMapping(HandlerMethod handlerMethod, T mapping) {
	// Assert that the supplied mapping is unique.
	HandlerMethod existingHandlerMethod = this.mappingLookup.get(mapping);
	if (existingHandlerMethod != null && !existingHandlerMethod.equals(handlerMethod)) {
		throw new IllegalStateException(
				"Ambiguous mapping. Cannot map '" + handlerMethod.getBean() + "' method \n" +
				handlerMethod + "\nto " + mapping + ": There is already '" +
				existingHandlerMethod.getBean() + "' bean method\n" + existingHandlerMethod + " mapped.");
	}
}