Skip to content

Commit f9649c0

Browse files
Dassi orleandomaibin
authored andcommitted
BAEL-1273: move code to another module (eugenp#3532)
* BAEL-1216: improve tests * BAEL-1448: Update Spring 5 articles to use the release version * Setting up the Maven Wrapper on a maven project * Add Maven Wrapper on spring-boot module * simple add * BAEL-976: Update spring version * BAEL-1273: Display RSS feed with spring mvc (AbstractRssFeedView) * Move RSS feed with Spring MVC from spring-boot to spring-mvc-simple
1 parent 70b81ca commit f9649c0

3 files changed

Lines changed: 74 additions & 0 deletions

File tree

‎spring-mvc-simple/pom.xml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<junit.jupiter.version>5.0.2</junit.jupiter.version>
3131
<junit.jupiter.version>5.0.2</junit.jupiter.version>
3232
<junit.platform.version>1.0.2</junit.platform.version>
33+
<rome.version>1.9.0</rome.version>
3334
</properties>
3435

3536
<dependencies>
@@ -115,6 +116,11 @@
115116
<version>${junit.jupiter.version}</version>
116117
<scope>test</scope>
117118
</dependency>
119+
<dependency>
120+
<groupId>com.rometools</groupId>
121+
<artifactId>rome</artifactId>
122+
<version>${rome.version}</version>
123+
</dependency>
118124
</dependencies>
119125
<build>
120126
<pluginManagement>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.baeldung.spring.controller.rss;
2+
3+
import com.rometools.rome.feed.rss.Channel;
4+
import com.rometools.rome.feed.rss.Description;
5+
import com.rometools.rome.feed.rss.Item;
6+
import org.springframework.stereotype.Service;
7+
import org.springframework.web.servlet.view.feed.AbstractRssFeedView;
8+
9+
import javax.servlet.http.HttpServletRequest;
10+
import javax.servlet.http.HttpServletResponse;
11+
import java.util.ArrayList;
12+
import java.util.Date;
13+
import java.util.List;
14+
import java.util.Map;
15+
16+
@Service("articleFeedView")
17+
public class ArticleFeedView extends AbstractRssFeedView {
18+
19+
protected Channel newFeed() {
20+
Channel channel = new Channel("rss_2.0");
21+
channel.setLink("http://localhost:8080/spring-mvc-simple/rss");
22+
channel.setTitle("Article Feed");
23+
channel.setDescription("Article Feed Description");
24+
channel.setPubDate(new Date());
25+
return channel;
26+
}
27+
28+
@Override
29+
protected List<Item> buildFeedItems(Map<String, Object> map, HttpServletRequest httpStRequest, HttpServletResponse httpStResponse) throws Exception {
30+
List list = new ArrayList<Item>();
31+
32+
Item item1 = new Item();
33+
item1.setLink("http://www.baeldung.com/netty-exception-handling");
34+
item1.setTitle("Exceptions in Netty");
35+
Description description1 = new Description();
36+
description1.setValue("In this quick article, we’ll be looking at exception handling in Netty.");
37+
item1.setDescription(description1);
38+
item1.setPubDate(new Date());
39+
item1.setAuthor("Carlos");
40+
41+
Item item2 = new Item();
42+
item2.setLink("http://www.baeldung.com/cockroachdb-java");
43+
item2.setTitle("Guide to CockroachDB in Java");
44+
Description description2 = new Description();
45+
description2.setValue("This tutorial is an introductory guide to using CockroachDB with Java.");
46+
item2.setDescription(description2);
47+
item2.setPubDate(new Date());
48+
item2.setAuthor("Baeldung");
49+
50+
list.add(item1);
51+
list.add(item2);
52+
return list;
53+
}
54+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.baeldung.spring.controller.rss;
2+
3+
import org.springframework.stereotype.Controller;
4+
import org.springframework.web.bind.annotation.GetMapping;
5+
6+
@Controller
7+
public class ArticleRssController {
8+
9+
@GetMapping(value = "/rss", produces = "application/*")
10+
public String articleFeed() {
11+
return "articleFeedView";
12+
}
13+
14+
}

0 commit comments

Comments
 (0)