Upgrade to rome-2.0.0; fix deprecation
* Fix `FeedInboundChannelAdapterParser` to properly populate a `Resource` ctor arg
This commit is contained in:
@@ -98,7 +98,7 @@ ext {
|
||||
r2dbch2Version = '1.0.0.RELEASE'
|
||||
reactorVersion = '2022.0.3'
|
||||
resilience4jVersion = '2.0.2'
|
||||
romeToolsVersion = '1.18.0'
|
||||
romeToolsVersion = '2.0.0'
|
||||
rsocketVersion = '1.1.3'
|
||||
servletApiVersion = '6.0.0'
|
||||
smackVersion = '4.4.6'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -21,6 +21,7 @@ import org.w3c.dom.Element;
|
||||
import org.springframework.beans.BeanMetadataElement;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.integration.config.xml.AbstractPollingInboundChannelAdapterParser;
|
||||
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
|
||||
import org.springframework.integration.feed.inbound.FeedEntryMessageSource;
|
||||
@@ -50,18 +51,21 @@ public class FeedInboundChannelAdapterParser extends AbstractPollingInboundChann
|
||||
boolean hasResource = StringUtils.hasText(resource);
|
||||
|
||||
if (hasUrl == hasResource) {
|
||||
parserContext.getReaderContext().error(
|
||||
"Exactly one of the 'url', 'reader' or 'resource' is required.", element);
|
||||
parserContext.getReaderContext().error("Exactly one of the 'url' or 'resource' is required.", element);
|
||||
}
|
||||
|
||||
if (hasUrl) {
|
||||
sourceBuilder.addConstructorArgValue(url);
|
||||
}
|
||||
else if (hasResource) {
|
||||
sourceBuilder.addConstructorArgValue(resource);
|
||||
else {
|
||||
sourceBuilder.getBeanDefinition()
|
||||
.getConstructorArgumentValues()
|
||||
.addIndexedArgumentValue(0, resource, Resource.class.getName());
|
||||
}
|
||||
|
||||
sourceBuilder.addConstructorArgValue(element.getAttribute(ID_ATTRIBUTE));
|
||||
sourceBuilder.getBeanDefinition()
|
||||
.getConstructorArgumentValues()
|
||||
.addIndexedArgumentValue(1, element.getAttribute(ID_ATTRIBUTE));
|
||||
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(sourceBuilder, element, "metadata-store");
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(sourceBuilder, element, "feed-input", "syndFeedInput");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -16,8 +16,13 @@
|
||||
|
||||
package org.springframework.integration.feed.inbound;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -26,6 +31,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import com.rometools.rome.feed.synd.SyndEntry;
|
||||
import com.rometools.rome.feed.synd.SyndFeed;
|
||||
import com.rometools.rome.io.FeedException;
|
||||
import com.rometools.rome.io.SyndFeedInput;
|
||||
import com.rometools.rome.io.XmlReader;
|
||||
|
||||
@@ -220,10 +226,7 @@ public class FeedEntryMessageSource extends AbstractMessageSource<SyndEntry> {
|
||||
private SyndFeed getFeed() {
|
||||
try {
|
||||
synchronized (this.feedMonitor) {
|
||||
Reader reader = this.feedUrl != null
|
||||
? new XmlReader(this.feedUrl)
|
||||
: new XmlReader(this.feedResource.getInputStream());
|
||||
SyndFeed feed = this.syndFeedInput.build(reader);
|
||||
SyndFeed feed = buildSyndFeed();
|
||||
logger.debug(() -> "Retrieved feed for [" + this + "]");
|
||||
if (feed == null) {
|
||||
logger.debug(() -> "No feeds updated for [" + this + "], returning null");
|
||||
@@ -236,6 +239,29 @@ public class FeedEntryMessageSource extends AbstractMessageSource<SyndEntry> {
|
||||
}
|
||||
}
|
||||
|
||||
private SyndFeed buildSyndFeed() throws IOException, URISyntaxException, InterruptedException, FeedException {
|
||||
InputStream inputStream;
|
||||
if (this.feedResource != null) {
|
||||
inputStream = this.feedResource.getInputStream();
|
||||
}
|
||||
else {
|
||||
HttpRequest request =
|
||||
HttpRequest.newBuilder()
|
||||
.GET()
|
||||
.uri(this.feedUrl.toURI())
|
||||
.build();
|
||||
|
||||
inputStream =
|
||||
HttpClient.newHttpClient()
|
||||
.send(request, HttpResponse.BodyHandlers.ofInputStream())
|
||||
.body();
|
||||
}
|
||||
|
||||
try (inputStream) {
|
||||
return this.syndFeedInput.build(new XmlReader(inputStream));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FeedEntryMessageSource{" +
|
||||
|
||||
Reference in New Issue
Block a user