mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-10-01 11:49:04 +00:00
+5
-6
@@ -28,6 +28,7 @@ import org.springframework.core.ParameterNameDiscoverer;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.handler.HandlerMethod;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
@@ -106,15 +107,13 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||
public Object invoke(Message<?> message, Object... providedArgs) throws Exception {
|
||||
Object[] args = getMethodArgumentValues(message, providedArgs);
|
||||
if (logger.isTraceEnabled()) {
|
||||
StringBuilder sb = new StringBuilder("Invoking [");
|
||||
sb.append(getBeanType().getSimpleName()).append(".");
|
||||
sb.append(getMethod().getName()).append("] method with arguments ");
|
||||
sb.append(Arrays.asList(args));
|
||||
logger.trace(sb.toString());
|
||||
logger.trace("Invoking '" + ClassUtils.getQualifiedMethodName(getMethod(), getBeanType()) +
|
||||
"' with arguments " + Arrays.toString(args));
|
||||
}
|
||||
Object returnValue = doInvoke(args);
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Method [" + getMethod().getName() + "] returned [" + returnValue + "]");
|
||||
logger.trace("Method [" + ClassUtils.getQualifiedMethodName(getMethod(), getBeanType()) +
|
||||
"] returned [" + returnValue + "]");
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
+19
-43
@@ -133,13 +133,11 @@ public class SendToMethodReturnValueHandler implements HandlerMethodReturnValueH
|
||||
|
||||
@Override
|
||||
public boolean supportsReturnType(MethodParameter returnType) {
|
||||
if (returnType.hasMethodAnnotation(SendTo.class) ||
|
||||
return (returnType.hasMethodAnnotation(SendTo.class) ||
|
||||
AnnotatedElementUtils.hasAnnotation(returnType.getDeclaringClass(), SendTo.class) ||
|
||||
returnType.hasMethodAnnotation(SendToUser.class) ||
|
||||
AnnotatedElementUtils.hasAnnotation(returnType.getDeclaringClass(), SendToUser.class)) {
|
||||
return true;
|
||||
}
|
||||
return !this.annotationRequired;
|
||||
AnnotatedElementUtils.hasAnnotation(returnType.getDeclaringClass(), SendToUser.class) ||
|
||||
!this.annotationRequired);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -188,56 +186,34 @@ public class SendToMethodReturnValueHandler implements HandlerMethodReturnValueH
|
||||
}
|
||||
|
||||
private Object findAnnotation(MethodParameter returnType) {
|
||||
Annotation[] annot = new Annotation[4];
|
||||
annot[0] = AnnotatedElementUtils.findMergedAnnotation(returnType.getMethod(), SendToUser.class);
|
||||
annot[1] = AnnotatedElementUtils.findMergedAnnotation(returnType.getMethod(), SendTo.class);
|
||||
annot[2] = AnnotatedElementUtils.findMergedAnnotation(returnType.getDeclaringClass(), SendToUser.class);
|
||||
annot[3] = AnnotatedElementUtils.findMergedAnnotation(returnType.getDeclaringClass(), SendTo.class);
|
||||
Annotation[] anns = new Annotation[4];
|
||||
anns[0] = AnnotatedElementUtils.findMergedAnnotation(returnType.getMethod(), SendToUser.class);
|
||||
anns[1] = AnnotatedElementUtils.findMergedAnnotation(returnType.getMethod(), SendTo.class);
|
||||
anns[2] = AnnotatedElementUtils.findMergedAnnotation(returnType.getDeclaringClass(), SendToUser.class);
|
||||
anns[3] = AnnotatedElementUtils.findMergedAnnotation(returnType.getDeclaringClass(), SendTo.class);
|
||||
|
||||
if (annot[0] != null && !ObjectUtils.isEmpty(((SendToUser) annot[0]).value())) {
|
||||
return annot[0];
|
||||
if (anns[0] != null && !ObjectUtils.isEmpty(((SendToUser) anns[0]).value())) {
|
||||
return anns[0];
|
||||
}
|
||||
if (annot[1] != null && !ObjectUtils.isEmpty(((SendTo) annot[1]).value())) {
|
||||
return annot[1];
|
||||
if (anns[1] != null && !ObjectUtils.isEmpty(((SendTo) anns[1]).value())) {
|
||||
return anns[1];
|
||||
}
|
||||
if (annot[2] != null && !ObjectUtils.isEmpty(((SendToUser) annot[2]).value())) {
|
||||
return annot[2];
|
||||
if (anns[2] != null && !ObjectUtils.isEmpty(((SendToUser) anns[2]).value())) {
|
||||
return anns[2];
|
||||
}
|
||||
if (annot[3] != null && !ObjectUtils.isEmpty(((SendTo) annot[3]).value())) {
|
||||
return annot[3];
|
||||
if (anns[3] != null && !ObjectUtils.isEmpty(((SendTo) anns[3]).value())) {
|
||||
return anns[3];
|
||||
}
|
||||
|
||||
for (int i=0; i < 4; i++) {
|
||||
if (annot[i] != null) {
|
||||
return annot[i];
|
||||
if (anns[i] != null) {
|
||||
return anns[i];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private SendToUser getSendToUser(MethodParameter returnType) {
|
||||
SendToUser annot = AnnotatedElementUtils.findMergedAnnotation(returnType.getMethod(), SendToUser.class);
|
||||
if (annot != null && !ObjectUtils.isEmpty(annot.value())) {
|
||||
return annot;
|
||||
}
|
||||
SendToUser typeAnnot = AnnotatedElementUtils.findMergedAnnotation(returnType.getDeclaringClass(), SendToUser.class);
|
||||
if (typeAnnot != null && !ObjectUtils.isEmpty(typeAnnot.value())) {
|
||||
return typeAnnot;
|
||||
}
|
||||
return (annot != null ? annot : typeAnnot);
|
||||
}
|
||||
|
||||
private SendTo getSendTo(MethodParameter returnType) {
|
||||
SendTo sendTo = AnnotatedElementUtils.findMergedAnnotation(returnType.getMethod(), SendTo.class);
|
||||
if (sendTo != null && !ObjectUtils.isEmpty(sendTo.value())) {
|
||||
return sendTo;
|
||||
}
|
||||
else {
|
||||
return AnnotatedElementUtils.findMergedAnnotation(returnType.getDeclaringClass(), SendTo.class);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private PlaceholderResolver initVarResolver(MessageHeaders headers) {
|
||||
String name = DestinationVariableMethodArgumentResolver.DESTINATION_TEMPLATE_VARIABLES_HEADER;
|
||||
@@ -268,7 +244,7 @@ public class SendToMethodReturnValueHandler implements HandlerMethodReturnValueH
|
||||
}
|
||||
|
||||
return (destination.startsWith("/") ?
|
||||
new String[] {defaultPrefix + destination} : new String[] {defaultPrefix + "/" + destination});
|
||||
new String[] {defaultPrefix + destination} : new String[] {defaultPrefix + '/' + destination});
|
||||
}
|
||||
|
||||
private MessageHeaders createHeaders(String sessionId, MethodParameter returnType) {
|
||||
|
||||
+1
-1
@@ -210,7 +210,7 @@ public class StompHeaderAccessor extends SimpMessageHeaderAccessor {
|
||||
}
|
||||
trySetStompHeaderForSubscriptionId();
|
||||
if (getMessageId() == null) {
|
||||
String messageId = getSessionId() + "-" + messageIdCounter.getAndIncrement();
|
||||
String messageId = getSessionId() + '-' + messageIdCounter.getAndIncrement();
|
||||
setNativeHeader(STOMP_MESSAGE_ID_HEADER, messageId);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
|
||||
catch (UnknownHostException ex) {
|
||||
host = "unknown";
|
||||
}
|
||||
return host + "-" + UUID.randomUUID();
|
||||
return host + '-' + UUID.randomUUID();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user