org.springframework.messaging.simp.SimpMessageMappingInfo Java Examples

The following examples show how to use org.springframework.messaging.simp.SimpMessageMappingInfo. 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: SimpAnnotationMethodMessageHandler.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
protected void handleMatch(SimpMessageMappingInfo mapping, HandlerMethod handlerMethod,
		String lookupDestination, Message<?> message) {

	Set<String> patterns = mapping.getDestinationConditions().getPatterns();
	if (!CollectionUtils.isEmpty(patterns)) {
		String pattern = patterns.iterator().next();
		Map<String, String> vars = getPathMatcher().extractUriTemplateVariables(pattern, lookupDestination);
		if (!CollectionUtils.isEmpty(vars)) {
			MessageHeaderAccessor mha = MessageHeaderAccessor.getAccessor(message, MessageHeaderAccessor.class);
			Assert.state(mha != null && mha.isMutable());
			mha.setHeader(DestinationVariableMethodArgumentResolver.DESTINATION_TEMPLATE_VARIABLES_HEADER, vars);
		}
	}

	try {
		SimpAttributesContextHolder.setAttributesFromMessage(message);
		super.handleMatch(mapping, handlerMethod, lookupDestination, message);
	}
	finally {
		SimpAttributesContextHolder.resetAttributes();
	}
}
 
Example #2
Source File: SimpAnnotationMethodMessageHandler.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
protected void handleMatch(SimpMessageMappingInfo mapping, HandlerMethod handlerMethod,
		String lookupDestination, Message<?> message) {

	Set<String> patterns = mapping.getDestinationConditions().getPatterns();
	if (!CollectionUtils.isEmpty(patterns)) {
		String pattern = patterns.iterator().next();
		Map<String, String> vars = getPathMatcher().extractUriTemplateVariables(pattern, lookupDestination);
		if (!CollectionUtils.isEmpty(vars)) {
			MessageHeaderAccessor mha = MessageHeaderAccessor.getAccessor(message, MessageHeaderAccessor.class);
			Assert.state(mha != null && mha.isMutable(), "Mutable MessageHeaderAccessor required");
			mha.setHeader(DestinationVariableMethodArgumentResolver.DESTINATION_TEMPLATE_VARIABLES_HEADER, vars);
		}
	}

	try {
		SimpAttributesContextHolder.setAttributesFromMessage(message);
		super.handleMatch(mapping, handlerMethod, lookupDestination, message);
	}
	finally {
		SimpAttributesContextHolder.resetAttributes();
	}
}
 
Example #3
Source File: SimpAnnotationMethodMessageHandler.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Override
protected void handleMatch(SimpMessageMappingInfo mapping, HandlerMethod handlerMethod,
		String lookupDestination, Message<?> message) {

	Set<String> patterns = mapping.getDestinationConditions().getPatterns();
	if (!CollectionUtils.isEmpty(patterns)) {
		String pattern = patterns.iterator().next();
		Map<String, String> vars = getPathMatcher().extractUriTemplateVariables(pattern, lookupDestination);
		if (!CollectionUtils.isEmpty(vars)) {
			MessageHeaderAccessor mha = MessageHeaderAccessor.getAccessor(message, MessageHeaderAccessor.class);
			Assert.state(mha != null && mha.isMutable(), "Mutable MessageHeaderAccessor required");
			mha.setHeader(DestinationVariableMethodArgumentResolver.DESTINATION_TEMPLATE_VARIABLES_HEADER, vars);
		}
	}

	try {
		SimpAttributesContextHolder.setAttributesFromMessage(message);
		super.handleMatch(mapping, handlerMethod, lookupDestination, message);
	}
	finally {
		SimpAttributesContextHolder.resetAttributes();
	}
}
 
Example #4
Source File: SimpAnnotationMethodMessageHandler.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
protected Set<String> getDirectLookupDestinations(SimpMessageMappingInfo mapping) {
	Set<String> result = new LinkedHashSet<>();
	for (String pattern : mapping.getDestinationConditions().getPatterns()) {
		if (!this.pathMatcher.isPattern(pattern)) {
			result.add(pattern);
		}
	}
	return result;
}
 
Example #5
Source File: SimpAnnotationMethodMessageHandler.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected Comparator<SimpMessageMappingInfo> getMappingComparator(final Message<?> message) {
	return new Comparator<SimpMessageMappingInfo>() {
		@Override
		public int compare(SimpMessageMappingInfo info1, SimpMessageMappingInfo info2) {
			return info1.compareTo(info2, message);
		}
	};
}
 
Example #6
Source File: SimpAnnotationMethodMessageHandler.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected Set<String> getDirectLookupDestinations(SimpMessageMappingInfo mapping) {
	Set<String> result = new LinkedHashSet<String>();
	for (String pattern : mapping.getDestinationConditions().getPatterns()) {
		if (!this.pathMatcher.isPattern(pattern)) {
			result.add(pattern);
		}
	}
	return result;
}
 
Example #7
Source File: SimpAnnotationMethodMessageHandler.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected Set<String> getDirectLookupDestinations(SimpMessageMappingInfo mapping) {
	Set<String> result = new LinkedHashSet<>();
	for (String pattern : mapping.getDestinationConditions().getPatterns()) {
		if (!this.pathMatcher.isPattern(pattern)) {
			result.add(pattern);
		}
	}
	return result;
}
 
Example #8
Source File: SimpAnnotationMethodMessageHandler.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
@Nullable
protected SimpMessageMappingInfo getMatchingMapping(SimpMessageMappingInfo mapping, Message<?> message) {
	return mapping.getMatchingCondition(message);

}
 
Example #9
Source File: SimpAnnotationMethodMessageHandler.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
protected SimpMessageMappingInfo getMatchingMapping(SimpMessageMappingInfo mapping, Message<?> message) {
	return mapping.getMatchingCondition(message);

}
 
Example #10
Source File: SimpAnnotationMethodMessageHandler.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
private SimpMessageMappingInfo createSubscribeMappingCondition(String[] destinations) {
	String[] resolvedDestinations = resolveEmbeddedValuesInDestinations(destinations);
	return new SimpMessageMappingInfo(SimpMessageTypeMessageCondition.SUBSCRIBE,
			new DestinationPatternsMessageCondition(resolvedDestinations, this.pathMatcher));
}
 
Example #11
Source File: SimpAnnotationMethodMessageHandler.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
private SimpMessageMappingInfo createMessageMappingCondition(String[] destinations) {
	String[] resolvedDestinations = resolveEmbeddedValuesInDestinations(destinations);
	return new SimpMessageMappingInfo(SimpMessageTypeMessageCondition.MESSAGE,
			new DestinationPatternsMessageCondition(resolvedDestinations, this.pathMatcher));
}
 
Example #12
Source File: SimpAnnotationMethodMessageHandler.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
protected Comparator<SimpMessageMappingInfo> getMappingComparator(final Message<?> message) {
	return (info1, info2) -> info1.compareTo(info2, message);
}
 
Example #13
Source File: SimpAnnotationMethodMessageHandler.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private SimpMessageMappingInfo createMessageMappingCondition(String[] destinations) {
	String[] resolvedDestinations = resolveEmbeddedValuesInDestinations(destinations);
	return new SimpMessageMappingInfo(SimpMessageTypeMessageCondition.MESSAGE,
			new DestinationPatternsMessageCondition(resolvedDestinations, this.pathMatcher));
}
 
Example #14
Source File: SimpAnnotationMethodMessageHandler.java    From java-technology-stack with MIT License 4 votes vote down vote up
private SimpMessageMappingInfo createSubscribeMappingCondition(String[] destinations) {
	String[] resolvedDestinations = resolveEmbeddedValuesInDestinations(destinations);
	return new SimpMessageMappingInfo(SimpMessageTypeMessageCondition.SUBSCRIBE,
			new DestinationPatternsMessageCondition(resolvedDestinations, this.pathMatcher));
}
 
Example #15
Source File: SimpAnnotationMethodMessageHandler.java    From java-technology-stack with MIT License 4 votes vote down vote up
private SimpMessageMappingInfo createMessageMappingCondition(String[] destinations) {
	String[] resolvedDestinations = resolveEmbeddedValuesInDestinations(destinations);
	return new SimpMessageMappingInfo(SimpMessageTypeMessageCondition.MESSAGE,
			new DestinationPatternsMessageCondition(resolvedDestinations, this.pathMatcher));
}
 
Example #16
Source File: SimpAnnotationMethodMessageHandler.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
protected Comparator<SimpMessageMappingInfo> getMappingComparator(final Message<?> message) {
	return (info1, info2) -> info1.compareTo(info2, message);
}
 
Example #17
Source File: SimpAnnotationMethodMessageHandler.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
@Nullable
protected SimpMessageMappingInfo getMatchingMapping(SimpMessageMappingInfo mapping, Message<?> message) {
	return mapping.getMatchingCondition(message);

}
 
Example #18
Source File: SimpAnnotationMethodMessageHandler.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private SimpMessageMappingInfo createSubscribeMappingCondition(String[] destinations) {
	String[] resolvedDestinations = resolveEmbeddedValuesInDestinations(destinations);
	return new SimpMessageMappingInfo(SimpMessageTypeMessageCondition.SUBSCRIBE,
			new DestinationPatternsMessageCondition(resolvedDestinations, this.pathMatcher));
}