Skip to content

Commit fb3645d

Browse files
committed
Move boot metric to rest full
1 parent a703253 commit fb3645d

10 files changed

Lines changed: 68 additions & 127 deletions

File tree

‎spring-security-mvc-ldap/src/main/java/org/baeldung/SampleLDAPApplication.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public static void main(String[] args) {
2424
@Override
2525
public void addViewControllers(ViewControllerRegistry registry) {
2626
registry.addViewController("/login").setViewName("login");
27-
registry.addViewController("/graph").setViewName("graph");
2827
}
2928

3029
}

‎spring-security-mvc-ldap/src/main/java/org/baeldung/controller/MyController.java‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,18 @@
77
import java.util.Map;
88
import java.util.Set;
99

10-
import org.baeldung.metric.IMetricService;
11-
import org.springframework.beans.factory.annotation.Autowired;
1210
import org.springframework.security.core.Authentication;
1311
import org.springframework.security.core.GrantedAuthority;
1412
import org.springframework.security.core.userdetails.UserDetails;
1513
import org.springframework.stereotype.Controller;
1614
import org.springframework.web.bind.annotation.RequestMapping;
17-
import org.springframework.web.bind.annotation.RequestMethod;
18-
import org.springframework.web.bind.annotation.ResponseBody;
1915

2016
/**
2117
* Spring Controller Definitions.
2218
*/
2319
@Controller
2420
public class MyController {
2521

26-
@Autowired
27-
private IMetricService metricService;
28-
2922
@RequestMapping("/")
3023
public String init(Map<String, Object> model, Principal principal) {
3124
model.put("title", "PUBLIC AREA");
@@ -44,12 +37,6 @@ public String secure(Map<String, Object> model, Principal principal) {
4437
return "home";
4538
}
4639

47-
@RequestMapping(value = "/metric-graph-data", method = RequestMethod.GET)
48-
@ResponseBody
49-
public Object[][] getMetricData() {
50-
return metricService.getGraphData();
51-
}
52-
5340
private String getUserName(Principal principal) {
5441
if (principal == null) {
5542
return "anonymous";

‎spring-security-mvc-ldap/src/main/java/org/baeldung/metric/MetricFilter.java‎

Lines changed: 0 additions & 36 deletions
This file was deleted.

‎spring-security-mvc-ldap/src/main/resources/templates/graph.html‎

Lines changed: 0 additions & 42 deletions
This file was deleted.

‎spring-security-rest-full/pom.xml‎

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,42 @@
99

1010
<dependencies>
1111

12+
<!-- Spring Boot Dependencies -->
13+
<dependency>
14+
<groupId>org.springframework.boot</groupId>
15+
<artifactId>spring-boot-starter-web</artifactId>
16+
</dependency>
17+
<!-- <dependency>
18+
<groupId>org.springframework.boot</groupId>
19+
<artifactId>spring-boot-starter-thymeleaf</artifactId>
20+
</dependency> -->
21+
<dependency>
22+
<groupId>org.springframework.boot</groupId>
23+
<artifactId>spring-boot-starter-actuator</artifactId>
24+
</dependency>
25+
26+
<dependency>
27+
<groupId>org.aspectj</groupId>
28+
<artifactId>aspectjweaver</artifactId>
29+
</dependency>
30+
31+
1232
<!-- Spring Security -->
1333

1434
<dependency>
1535
<groupId>org.springframework.security</groupId>
1636
<artifactId>spring-security-web</artifactId>
17-
<version>${org.springframework.security.version}</version>
1837
</dependency>
1938
<dependency>
2039
<groupId>org.springframework.security</groupId>
2140
<artifactId>spring-security-config</artifactId>
22-
<version>${org.springframework.security.version}</version>
2341
</dependency>
2442

2543
<!-- Spring -->
2644

2745
<dependency>
2846
<groupId>org.springframework</groupId>
2947
<artifactId>spring-core</artifactId>
30-
<version>${org.springframework.version}</version>
3148
<exclusions>
3249
<exclusion>
3350
<artifactId>commons-logging</artifactId>
@@ -38,43 +55,35 @@
3855
<dependency>
3956
<groupId>org.springframework</groupId>
4057
<artifactId>spring-context</artifactId>
41-
<version>${org.springframework.version}</version>
4258
</dependency>
4359
<dependency>
4460
<groupId>org.springframework</groupId>
4561
<artifactId>spring-jdbc</artifactId>
46-
<version>${org.springframework.version}</version>
4762
</dependency>
4863
<dependency>
4964
<groupId>org.springframework</groupId>
5065
<artifactId>spring-beans</artifactId>
51-
<version>${org.springframework.version}</version>
5266
</dependency>
5367
<dependency>
5468
<groupId>org.springframework</groupId>
5569
<artifactId>spring-aop</artifactId>
56-
<version>${org.springframework.version}</version>
5770
</dependency>
5871
<dependency>
5972
<groupId>org.springframework</groupId>
6073
<artifactId>spring-tx</artifactId>
61-
<version>${org.springframework.version}</version>
6274
</dependency>
6375
<dependency>
6476
<groupId>org.springframework</groupId>
6577
<artifactId>spring-expression</artifactId>
66-
<version>${org.springframework.version}</version>
6778
</dependency>
6879

6980
<dependency>
7081
<groupId>org.springframework</groupId>
7182
<artifactId>spring-web</artifactId>
72-
<version>${org.springframework.version}</version>
7383
</dependency>
7484
<dependency>
7585
<groupId>org.springframework</groupId>
7686
<artifactId>spring-webmvc</artifactId>
77-
<version>${org.springframework.version}</version>
7887
</dependency>
7988

8089
<!-- Querydsl -->
@@ -113,17 +122,14 @@
113122
<dependency>
114123
<groupId>org.springframework</groupId>
115124
<artifactId>spring-orm</artifactId>
116-
<version>${org.springframework.version}</version>
117125
</dependency>
118126
<dependency>
119127
<groupId>org.springframework.data</groupId>
120128
<artifactId>spring-data-jpa</artifactId>
121-
<version>${spring-data-jpa.version}</version>
122129
</dependency>
123130
<dependency>
124131
<groupId>org.hibernate</groupId>
125132
<artifactId>hibernate-entitymanager</artifactId>
126-
<version>${hibernate.version}</version>
127133
</dependency>
128134
<dependency>
129135
<groupId>xml-apis</groupId>
@@ -133,12 +139,10 @@
133139
<dependency>
134140
<groupId>org.javassist</groupId>
135141
<artifactId>javassist</artifactId>
136-
<version>3.19.0-GA</version>
137142
</dependency>
138143
<dependency>
139144
<groupId>mysql</groupId>
140145
<artifactId>mysql-connector-java</artifactId>
141-
<version>${mysql-connector-java.version}</version>
142146
<scope>runtime</scope>
143147
</dependency>
144148

@@ -147,7 +151,6 @@
147151
<dependency>
148152
<groupId>javax.servlet</groupId>
149153
<artifactId>javax.servlet-api</artifactId>
150-
<version>3.0.1</version>
151154
<scope>provided</scope>
152155
</dependency>
153156

@@ -162,7 +165,6 @@
162165
<dependency>
163166
<groupId>com.fasterxml.jackson.core</groupId>
164167
<artifactId>jackson-databind</artifactId>
165-
<version>${jackson.version}</version>
166168
</dependency>
167169

168170
<dependency>
@@ -184,32 +186,27 @@
184186
<dependency>
185187
<groupId>org.slf4j</groupId>
186188
<artifactId>slf4j-api</artifactId>
187-
<version>${org.slf4j.version}</version>
188189
</dependency>
189190
<dependency>
190191
<groupId>ch.qos.logback</groupId>
191192
<artifactId>logback-classic</artifactId>
192-
<version>${logback.version}</version>
193193
<!-- <scope>runtime</scope> -->
194194
</dependency>
195195
<dependency>
196196
<groupId>org.slf4j</groupId>
197197
<artifactId>jcl-over-slf4j</artifactId>
198-
<version>${org.slf4j.version}</version>
199198
<!-- <scope>runtime</scope> --> <!-- some spring dependencies need to compile against jcl -->
200199
</dependency>
201200
<dependency> <!-- needed to bridge to slf4j for projects that use the log4j APIs directly -->
202201
<groupId>org.slf4j</groupId>
203202
<artifactId>log4j-over-slf4j</artifactId>
204-
<version>${org.slf4j.version}</version>
205203
</dependency>
206204

207205
<!-- test scoped -->
208206

209207
<dependency>
210208
<groupId>org.springframework</groupId>
211209
<artifactId>spring-test</artifactId>
212-
<version>${org.springframework.version}</version>
213210
<scope>test</scope>
214211
</dependency>
215212

@@ -266,7 +263,6 @@
266263
<plugin>
267264
<groupId>org.apache.maven.plugins</groupId>
268265
<artifactId>maven-compiler-plugin</artifactId>
269-
<version>${maven-compiler-plugin.version}</version>
270266
<configuration>
271267
<source>1.7</source>
272268
<target>1.7</target>
@@ -276,13 +272,11 @@
276272
<plugin>
277273
<groupId>org.apache.maven.plugins</groupId>
278274
<artifactId>maven-war-plugin</artifactId>
279-
<version>${maven-war-plugin.version}</version>
280275
</plugin>
281276

282277
<plugin>
283278
<groupId>org.apache.maven.plugins</groupId>
284279
<artifactId>maven-surefire-plugin</artifactId>
285-
<version>${maven-surefire-plugin.version}</version>
286280
<configuration>
287281
<excludes>
288282
<exclude>**/*IntegrationTest.java</exclude>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package org.baeldung.spring;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
5+
import org.springframework.context.annotation.ComponentScan;
6+
import org.springframework.scheduling.annotation.EnableScheduling;
7+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
8+
9+
/**
10+
* Main Application Class - uses Spring Boot. Just run this as a normal Java
11+
* class to run up a Jetty Server (on http://localhost:8080)
12+
*
13+
*/
14+
@EnableScheduling
15+
@EnableAutoConfiguration
16+
@ComponentScan("org.baeldung")
17+
public class Application extends WebMvcConfigurerAdapter {
18+
19+
public static void main(final String[] args) {
20+
SpringApplication.run(Application.class, args);
21+
}
22+
23+
}

‎spring-security-rest-full/src/main/java/org/baeldung/web/controller/RootController.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import javax.servlet.http.HttpServletRequest;
77
import javax.servlet.http.HttpServletResponse;
88

9+
import org.baeldung.web.metric.IActuatorMetricService;
910
import org.baeldung.web.metric.IMetricService;
1011
import org.baeldung.web.util.LinkUtil;
1112
import org.springframework.beans.factory.annotation.Autowired;
@@ -23,6 +24,9 @@ public class RootController {
2324
@Autowired
2425
private IMetricService metricService;
2526

27+
@Autowired
28+
private IActuatorMetricService actMetricService;
29+
2630
public RootController() {
2731
super();
2832
}
@@ -62,4 +66,10 @@ public Object[][] drawMetric() {
6266
}
6367
return result;
6468
}
69+
70+
@RequestMapping(value = "/metric-graph-data", method = RequestMethod.GET)
71+
@ResponseBody
72+
public Object[][] getActuatorMetricData() {
73+
return actMetricService.getGraphData();
74+
}
6575
}

0 commit comments

Comments
 (0)