Java Code Examples for org.springframework.messaging.handler.annotation.SendTo#value()

The following examples show how to use org.springframework.messaging.handler.annotation.SendTo#value() . 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: MethodJmsListenerEndpoint.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Return the default response destination, if any.
 */
@Nullable
protected String getDefaultResponseDestination() {
	Method specificMethod = getMostSpecificMethod();
	if (specificMethod == null) {
		return null;
	}
	SendTo ann = getSendTo(specificMethod);
	if (ann != null) {
		Object[] destinations = ann.value();
		if (destinations.length != 1) {
			throw new IllegalStateException("Invalid @" + SendTo.class.getSimpleName() + " annotation on '" +
					specificMethod + "' one destination must be set (got " + Arrays.toString(destinations) + ")");
		}
		return resolve((String) destinations[0]);
	}
	return null;
}
 
Example 2
Source File: MethodJmsListenerEndpoint.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Return the default response destination, if any.
 */
@Nullable
protected String getDefaultResponseDestination() {
	Method specificMethod = getMostSpecificMethod();
	if (specificMethod == null) {
		return null;
	}
	SendTo ann = getSendTo(specificMethod);
	if (ann != null) {
		Object[] destinations = ann.value();
		if (destinations.length != 1) {
			throw new IllegalStateException("Invalid @" + SendTo.class.getSimpleName() + " annotation on '" +
					specificMethod + "' one destination must be set (got " + Arrays.toString(destinations) + ")");
		}
		return resolve((String) destinations[0]);
	}
	return null;
}
 
Example 3
Source File: StreamAnnotationCommonMethodUtils.java    From spring-cloud-stream with Apache License 2.0 6 votes vote down vote up
public static String getOutboundBindingTargetName(Method method) {
	SendTo sendTo = AnnotationUtils.findAnnotation(method, SendTo.class);
	if (sendTo != null) {
		Assert.isTrue(!ObjectUtils.isEmpty(sendTo.value()),
				StreamAnnotationErrorMessages.ATLEAST_ONE_OUTPUT);
		Assert.isTrue(sendTo.value().length == 1,
				StreamAnnotationErrorMessages.SEND_TO_MULTIPLE_DESTINATIONS);
		Assert.hasText(sendTo.value()[0],
				StreamAnnotationErrorMessages.SEND_TO_EMPTY_DESTINATION);
		return sendTo.value()[0];
	}
	Output output = AnnotationUtils.findAnnotation(method, Output.class);
	if (output != null) {
		Assert.isTrue(StringUtils.hasText(output.value()),
				StreamAnnotationErrorMessages.ATLEAST_ONE_OUTPUT);
		return output.value();
	}
	return null;
}
 
Example 4
Source File: StreamListenerMethodUtils.java    From spring-cloud-stream with Apache License 2.0 6 votes vote down vote up
protected static String getOutboundBindingTargetName(Method method) {
	SendTo sendTo = AnnotationUtils.findAnnotation(method, SendTo.class);
	if (sendTo != null) {
		Assert.isTrue(!ObjectUtils.isEmpty(sendTo.value()),
				StreamListenerErrorMessages.ATLEAST_ONE_OUTPUT);
		Assert.isTrue(sendTo.value().length == 1,
				StreamListenerErrorMessages.SEND_TO_MULTIPLE_DESTINATIONS);
		Assert.hasText(sendTo.value()[0],
				StreamListenerErrorMessages.SEND_TO_EMPTY_DESTINATION);
		return sendTo.value()[0];
	}
	Output output = AnnotationUtils.findAnnotation(method, Output.class);
	if (output != null) {
		Assert.isTrue(StringUtils.hasText(output.value()),
				StreamListenerErrorMessages.ATLEAST_ONE_OUTPUT);
		return output.value();
	}
	return null;
}
 
Example 5
Source File: MethodJmsListenerEndpoint.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Return the default response destination, if any.
 */
protected String getDefaultResponseDestination() {
	Method specificMethod = getMostSpecificMethod();
	SendTo ann = AnnotationUtils.getAnnotation(specificMethod, SendTo.class);
	if (ann != null) {
		Object[] destinations = ann.value();
		if (destinations.length != 1) {
			throw new IllegalStateException("Invalid @" + SendTo.class.getSimpleName() + " annotation on '" +
					specificMethod + "' one destination must be set (got " + Arrays.toString(destinations) + ")");
		}
		return resolve((String) destinations[0]);
	}
	return null;
}
 
Example 6
Source File: KafkaStreamsStreamListenerSetupMethodOrchestrator.java    From spring-cloud-stream-binder-kafka with Apache License 2.0 5 votes vote down vote up
private static String[] getOutboundBindingTargetNames(Method method) {
	SendTo sendTo = AnnotationUtils.findAnnotation(method, SendTo.class);
	if (sendTo != null) {
		Assert.isTrue(!ObjectUtils.isEmpty(sendTo.value()),
				StreamListenerErrorMessages.ATLEAST_ONE_OUTPUT);
		Assert.isTrue(sendTo.value().length >= 1,
				"At least one outbound destination need to be provided.");
		return sendTo.value();
	}
	return null;
}