Modernize code for diamond, isEmpty & pattern matching
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,6 +36,7 @@ import org.springframework.ws.soap.SoapMessage;
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
@@ -73,8 +74,8 @@ public abstract class AbstractWebServiceInboundGateway extends MessagingGatewayS
|
||||
}
|
||||
catch (Exception e) {
|
||||
while ((e instanceof MessagingException || e instanceof ExpressionException) && // NOSONAR
|
||||
e.getCause() instanceof Exception) {
|
||||
e = (Exception) e.getCause();
|
||||
e.getCause() instanceof Exception exception) {
|
||||
e = exception;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
@@ -91,8 +92,7 @@ public abstract class AbstractWebServiceInboundGateway extends MessagingGatewayS
|
||||
builder.setHeader(propertyName, messageContext.getProperty(propertyName));
|
||||
}
|
||||
}
|
||||
if (request instanceof SoapMessage) {
|
||||
SoapMessage soapMessage = (SoapMessage) request;
|
||||
if (request instanceof SoapMessage soapMessage) {
|
||||
Map<String, ?> headers = this.headerMapper.toHeadersFromRequest(soapMessage);
|
||||
if (!CollectionUtils.isEmpty(headers)) {
|
||||
builder.copyHeaders(headers);
|
||||
@@ -101,9 +101,9 @@ public abstract class AbstractWebServiceInboundGateway extends MessagingGatewayS
|
||||
}
|
||||
|
||||
protected void toSoapHeaders(WebServiceMessage response, Message<?> replyMessage) {
|
||||
if (response instanceof SoapMessage) {
|
||||
if (response instanceof SoapMessage soapMessage) {
|
||||
this.headerMapper.fromHeadersToReply(
|
||||
replyMessage.getHeaders(), (SoapMessage) response);
|
||||
replyMessage.getHeaders(), soapMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ import org.springframework.xml.transform.TransformerObjectSupport;
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Christian Tzolov
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public abstract class AbstractWebServiceOutboundGateway extends AbstractReplyProducingMessageHandler {
|
||||
|
||||
@@ -206,8 +207,8 @@ public abstract class AbstractWebServiceOutboundGateway extends AbstractReplyPro
|
||||
}
|
||||
Object responsePayload = doHandle(uriWithVariables.toString(), requestMessage, this.requestCallback);
|
||||
if (responsePayload != null && !(this.ignoreEmptyResponses
|
||||
&& responsePayload instanceof String
|
||||
&& !StringUtils.hasText((String) responsePayload))) {
|
||||
&& responsePayload instanceof String string
|
||||
&& !StringUtils.hasText(string))) {
|
||||
|
||||
return responsePayload;
|
||||
}
|
||||
@@ -247,9 +248,9 @@ public abstract class AbstractWebServiceOutboundGateway extends AbstractReplyPro
|
||||
public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException {
|
||||
Object payload = this.requestMessage.getPayload();
|
||||
doWithMessageInternal(message, payload);
|
||||
if (message instanceof SoapMessage) {
|
||||
if (message instanceof SoapMessage soapMessage) {
|
||||
AbstractWebServiceOutboundGateway.this.headerMapper
|
||||
.fromHeadersToRequest(this.requestMessage.getHeaders(), (SoapMessage) message);
|
||||
.fromHeadersToRequest(this.requestMessage.getHeaders(), soapMessage);
|
||||
}
|
||||
if (this.reqCallback != null) {
|
||||
this.reqCallback.doWithMessage(message);
|
||||
@@ -270,9 +271,9 @@ public abstract class AbstractWebServiceOutboundGateway extends AbstractReplyPro
|
||||
|
||||
Object resultObject = this.doExtractData(message);
|
||||
|
||||
if (resultObject != null && message instanceof SoapMessage) {
|
||||
if (resultObject != null && message instanceof SoapMessage soapMessage) {
|
||||
Map<String, Object> mappedMessageHeaders =
|
||||
AbstractWebServiceOutboundGateway.this.headerMapper.toHeadersFromReply((SoapMessage) message);
|
||||
AbstractWebServiceOutboundGateway.this.headerMapper.toHeadersFromReply(soapMessage);
|
||||
return getMessageBuilderFactory()
|
||||
.withPayload(resultObject)
|
||||
.copyHeaders(mappedMessageHeaders)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2023 the original author or authors.
|
||||
* Copyright 2016-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,6 +39,7 @@ import org.springframework.ws.server.endpoint.adapter.MessageEndpointAdapter;
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Chris Bono
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 4.3
|
||||
*
|
||||
@@ -53,12 +54,12 @@ public class WsIntegrationConfigurationInitializer implements IntegrationConfigu
|
||||
|
||||
@Override
|
||||
public void initialize(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||
if (beanFactory instanceof BeanDefinitionRegistry) {
|
||||
if (beanFactory instanceof BeanDefinitionRegistry beanDefinitionRegistry) {
|
||||
if (beanFactory.getBeanNamesForType(EndpointAdapter.class, false, false).length > 0) {
|
||||
BeanDefinitionBuilder requestMappingBuilder =
|
||||
BeanDefinitionBuilder.genericBeanDefinition(MessageEndpointAdapter.class)
|
||||
.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
((BeanDefinitionRegistry) beanFactory).registerBeanDefinition(MESSAGE_ENDPOINT_ADAPTER_BEAN_NAME,
|
||||
beanDefinitionRegistry.registerBeanDefinition(MESSAGE_ENDPOINT_ADAPTER_BEAN_NAME,
|
||||
requestMappingBuilder.getBeanDefinition());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user