Skip to content

Commit 77706c0

Browse files
committed
Hacked a web application for Boot Upgrade report
A web application decoupled from the shell allows scanning a dir and creates a report from asciidoc and provides it as web page. From this report requests can be sent to run single recipes to remediate changes. After each recipe a new report is created allowing to "check off" the list of changes.
1 parent e38c0da commit 77706c0

File tree

29 files changed

+530
-190
lines changed

29 files changed

+530
-190
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000 --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED -jar spring-boot-upgrade.jar /Users/fkrueger/projects/sbm-projects/demo-spring-song-app
2+
java --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED -jar spring-boot-upgrade.jar /Users/fkrueger/projects/sbm-projects/demo-spring-song-app

applications/rest-service/pom.xml

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,9 @@
3131
<dependencies>
3232
<dependency>
3333
<groupId>org.springframework.sbm</groupId>
34-
<artifactId>sbm-recipes-spring-framework</artifactId>
35-
<version>${project.version}</version>
36-
</dependency>
37-
<dependency>
38-
<groupId>org.springframework.sbm</groupId>
39-
<artifactId>sbm-recipes-jee-to-boot</artifactId>
34+
<artifactId>sbm-recipes-boot-upgrade</artifactId>
4035
<version>0.12.1-SNAPSHOT</version>
4136
</dependency>
42-
<dependency>
43-
<groupId>org.springframework.sbm</groupId>
44-
<artifactId>sbm-core</artifactId>
45-
<version>${project.version}</version>
46-
</dependency>
4737
<dependency>
4838
<groupId>org.springframework.boot</groupId>
4939
<artifactId>spring-boot-starter</artifactId>
@@ -53,30 +43,10 @@
5343
<artifactId>spring-boot-starter-test</artifactId>
5444
<scope>test</scope>
5545
</dependency>
56-
<dependency>
57-
<groupId>org.springframework.sbm</groupId>
58-
<artifactId>test-helper</artifactId>
59-
<scope>test</scope>
60-
</dependency>
61-
62-
<dependency>
63-
<groupId>org.springframework.sbm</groupId>
64-
<artifactId>sbm-support-weblogic</artifactId>
65-
<version>0.12.1-SNAPSHOT</version>
66-
</dependency>
67-
<dependency>
68-
<groupId>org.springframework.sbm</groupId>
69-
<artifactId>openrewrite-spring-recipes</artifactId>
70-
<version>${project.version}</version>
71-
</dependency>
7246
<dependency>
7347
<groupId>org.springframework.boot</groupId>
7448
<artifactId>spring-boot-starter-web</artifactId>
7549
</dependency>
76-
<dependency>
77-
<groupId>org.springframework.boot</groupId>
78-
<artifactId>spring-boot-starter-actuator</artifactId>
79-
</dependency>
8050
</dependencies>
8151

8252
<build>
@@ -90,6 +60,19 @@
9060
<goals>
9161
<goal>repackage</goal>
9262
</goals>
63+
<configuration>
64+
<requiresUnpack>
65+
<dependency>
66+
<groupId>org.asciidoctor</groupId>
67+
<artifactId>asciidoctorj</artifactId>
68+
</dependency>
69+
<dependency>
70+
<groupId>io.spring.asciidoctor.backends</groupId>
71+
<artifactId>spring-asciidoctor-backends</artifactId>
72+
</dependency>
73+
</requiresUnpack>
74+
<finalName>spring-boot-upgrade</finalName>
75+
</configuration>
9376
</execution>
9477
</executions>
9578
</plugin>
Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,18 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.springframework.sbm.service;
16+
package org.springframework.sbm;
1717

18-
import static org.assertj.core.api.Assertions.assertThat;
19-
20-
import org.junit.jupiter.api.Test;
21-
import org.springframework.beans.factory.annotation.Autowired;
22-
import org.springframework.boot.test.context.SpringBootTest;
23-
24-
@SpringBootTest
25-
public class SpringBootMigratorServiceAppTest {
26-
27-
@Autowired
28-
RestApi restApi;
29-
30-
@Test
31-
void contextLoads() {
32-
assertThat(restApi).isNotNull();
33-
}
18+
import lombok.Getter;
19+
import lombok.Setter;
20+
import org.springframework.stereotype.Component;
3421

22+
/**
23+
* @author Fabian Krüger
24+
*/
25+
@Component
26+
@Getter
27+
@Setter
28+
public class ReportHolder {
29+
private String report = "";
3530
}

applications/rest-service/src/main/java/org/springframework/sbm/SpringBootMigratorServiceApp.java

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,86 @@
1515
*/
1616
package org.springframework.sbm;
1717

18+
import org.springframework.beans.factory.annotation.Autowired;
19+
import org.springframework.boot.ApplicationArguments;
20+
import org.springframework.boot.ApplicationRunner;
1821
import org.springframework.boot.SpringApplication;
1922
import org.springframework.boot.autoconfigure.SpringBootApplication;
23+
import org.springframework.context.annotation.Configuration;
24+
import org.springframework.context.event.EventListener;
25+
import org.springframework.http.MediaType;
26+
import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportFileSystemRenderer;
27+
import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportRenderer;
28+
import org.springframework.sbm.engine.commands.ApplyCommand;
29+
import org.springframework.sbm.engine.commands.ScanCommand;
30+
import org.springframework.sbm.engine.context.ProjectContext;
31+
import org.springframework.sbm.engine.context.ProjectContextHolder;
32+
import org.springframework.sbm.engine.events.*;
33+
import org.springframework.stereotype.Controller;
34+
import org.springframework.web.bind.annotation.GetMapping;
35+
import org.springframework.web.bind.annotation.PostMapping;
36+
import org.springframework.web.bind.annotation.RequestParam;
37+
import org.springframework.web.bind.annotation.ResponseBody;
2038

2139
@SpringBootApplication
22-
public class SpringBootMigratorServiceApp {
40+
public class SpringBootMigratorServiceApp implements ApplicationRunner {
2341

2442
public static void main(String[] args) {
43+
if(args.length == 0) {
44+
System.err.println("PLease provide the path to the application as parameter.");
45+
return;
46+
}
2547
SpringApplication.run(SpringBootMigratorServiceApp.class, args);
2648
}
2749

50+
@Autowired
51+
private ScanCommand scanCommand;
52+
@Autowired
53+
private ApplyCommand applyCommand;
54+
@Autowired
55+
private SpringBootUpgradeReportRenderer upgradeReportRenderer;
56+
@Autowired
57+
private ProjectContextHolder contextHolder;
58+
59+
@Autowired
60+
private ReportHolder reportHolder;
61+
62+
@Override
63+
public void run(ApplicationArguments args) {
64+
String applicationPath = args.getSourceArgs()[0];
65+
System.out.println("Scanning " + applicationPath);
66+
ProjectContext context = scanCommand.execute(applicationPath);
67+
contextHolder.setProjectContext(context);
68+
System.out.println("finished scan. Please open: http://localhost:8080/spring-boot-upgrade");
69+
}
70+
71+
72+
}
73+
74+
@Controller
75+
class ReportController{
76+
77+
@Autowired
78+
private ApplyCommand applyCommand;
79+
@Autowired
80+
private ReportHolder reportHolder;
81+
82+
@Autowired
83+
private ProjectContextHolder contextHolder;
84+
85+
@GetMapping(path = "/spring-boot-upgrade", produces = MediaType.TEXT_HTML_VALUE)
86+
@ResponseBody
87+
public String upgrade() {
88+
applyCommand.execute(contextHolder.getProjectContext(), "boot-2.7-3.0-upgrade-report2");
89+
return reportHolder.getReport();
90+
}
91+
92+
@PostMapping(path = "/spring-boot-upgrade", produces = MediaType.TEXT_HTML_VALUE)
93+
@ResponseBody
94+
public String applyRecipe(@RequestParam String recipeName) {
95+
ProjectContext context = contextHolder.getProjectContext();
96+
applyCommand.execute(context, recipeName);
97+
applyCommand.execute(context, "boot-2.7-3.0-upgrade-report2");
98+
return reportHolder.getReport();
99+
}
28100
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2021 - 2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.sbm;
17+
18+
import org.springframework.beans.factory.annotation.Autowired;
19+
import org.springframework.context.annotation.Primary;
20+
import org.springframework.sbm.boot.upgrade.common.UpgradeReportUtil;
21+
import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportRenderer;
22+
import org.springframework.stereotype.Component;
23+
24+
/**
25+
* @author Fabian Krüger
26+
*/
27+
@Component
28+
@Primary
29+
public class SpringBootUpgradeReportStringRenderer implements SpringBootUpgradeReportRenderer {
30+
31+
@Autowired
32+
private ReportHolder reportHolder;
33+
@Override
34+
public void processReport(String renderedReport) {
35+
String htmlReport = UpgradeReportUtil.renderHtml(renderedReport);
36+
reportHolder.setReport(htmlReport);
37+
}
38+
}

applications/rest-service/src/main/resources/application.properties

Whitespace-only changes.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
,╓╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔╔µ, ,
3+
#╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╦ ]╬⌐
4+
@╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╦ ╔╣╚╣
5+
║╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▒ ║╩ ╟▒
6+
,╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣#╣└ ╣╕
7+
╔╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╝└ ╙╣
8+
@╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣╙ ╫▒
9+
╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╝╙ "╬
10+
,╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣╩╙ ╫▒
11+
φ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣╣╬╝╩╙╙└² ]╣
12+
Å╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣╩╙└└ ╬b
13+
.╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣╩└ . ║▒
14+
╒╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╩ ,⌐ ╚╬
15+
#╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╩ ╓╩ ]╬
16+
║╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣ @╩ ]╬▒
17+
║╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ φ╣╙ ]╬╬▒
18+
╫╬╬╬╬╬╬╬╬╬╬╬╬╬╣ ╔╣╣` ║╬╬╬
19+
╚╬╬╬╬╬╬╬╬╬╬╬╬╬▒ é╣╬╜ ╣╬╬╛
20+
╙╬╬╬╬╬╬╬╬╬╬╬╬⌐ ╓▒╬╬╩ ]╬╬╙
21+
└╣╬╬╬╬╬╬╬╬╬╬⌐ »▒╣╬╬╩² ╣╣└
22+
╬╬╬╬╬╬╬╬╬╬▒ ,╔▒╬╬╬╣╙ ╟╬
23+
╚╬╬╬╬╬╬╬╬╬⌐ ╓#▒╣╬╬╬╬╩└ ╬╩
24+
╙╬╬╬╬╬╬╬╬╣ε ²╓╗▒╬╣╬╬╬╬╬╣╨└ ╔╣╙
25+
"╣╬╬╬╬╬╬╬╬▒┐ ,╓╔╗@▒╣╬╬╬╬╬╬╬╬╬╣╨╙ ╔╬╣
26+
╢╬╬╬╬╬╬╬╬╬╣▒▒╬╣╬╬╬╬╬╬╬╬╬╬╬╬╣╩╙└ ╓▒╣╬╬
27+
╚╬╬╬╬╜ ╙╣╬╬╬╬╬╬╬╬╝╩╙└ ,╓φ▒╣╬╬╬╬╨
28+
╙╣╬▒ .╬╬╬╬╬╠╗╗@@###@@╗╗╗╗╗╗╗╗╗╗╗╗╗╗#@▒▒╬╣╣╬╬╬╬╬╬╬╬╬┘
29+
²╣╣╓ ,║╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣
30+
║╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╩
31+
╙╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╙
32+
└╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣└
33+
└╜╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣╨└
34+
²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²
35+
36+
37+
_______ _______ _______ _______ _______ _______ __ __ _______ _______ ______ _______ ______ _______
38+
| _ || || || | | | | _ | | | | || || || _ | | _ || | | |
39+
| |_| || _ || _ ||_ _| |___ | | | | | | | | || _ || ___|| | || | |_| || _ || ___|
40+
| || | | || | | | | | ___| | | | | | | |_| || |_| || | __ | |_||_ | || | | || |___
41+
| _ | | |_| || |_| | | | |___ | ___ | |_| | | || ___|| || || __ || || |_| || ___|
42+
| |_| || || | | | ___| || | | | | || | | |_| || | | || _ || || |___
43+
|_______||_______||_______| |___| |_______||___| |_______| |_______||___| |_______||___| |_||__| |__||______| |_______|

applications/rest-service/src/main/resources/static/css/site.css

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

applications/rest-service/src/main/resources/static/css/site.css.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 16 additions & 0 deletions
Loading
Lines changed: 8 additions & 0 deletions
Loading
Lines changed: 8 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)