forked from sermakov/JavaPatternMirea
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtsk14.java
More file actions
93 lines (77 loc) · 2.93 KB
/
tsk14.java
File metadata and controls
93 lines (77 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package a;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.endpoint.annotation.DeleteOperation;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Component;
// .../res/application.properties:
// management.endpoints.web.exposure.include=hm,ps,us
@SpringBootApplication
public class tsk14 {
public static void main(String[] args)
{ SpringApplication.run(tsk14.class, args); }
public static class ps {
private String tx;
private long cd;
@Override public String toString() { return tx + ' ' + cd; }
}
public static class us {
private String fn;
private String ln;
private String mn;
private long bd;
@Override public String toString()
{ return fn + ' ' + ln + ' ' + mn + ' ' + bd; }
}
@SuppressWarnings("unused") @Component @Endpoint(id = "hm")
public static class A {
// curl localhost:8080/actuator/hm
@ReadOperation public String a() { return """
<html>
<body>
<span id="ln">ln</span>
<span id="nm">nm</span>
<span id="gp">ik</span>
<span id="vr">06</span>
</body>
"""; }
}
@SuppressWarnings("unused") @Component @Endpoint(id = "ps")
public static class B {
private ps p = null;
// curl localhost:8080/actuator/ps
@ReadOperation public String gt()
{ return p == null ? "null" : p.toString(); }
// curl -X POST -d '{"a":"ps","b":123}' \
// -H "Content-type:application/json" http://localhost:8080/actuator/ps
@WriteOperation
public void st(String a, long b) {
var q = p == null ? (p = new ps()) : p;
q.tx = a;
q.cd = b;
}
// curl -X DELETE localhost:8080/actuator/ps
@DeleteOperation public void dl() { p = null; }
}
@SuppressWarnings("unused") @Component @Endpoint(id = "us")
public static class C {
private us u = null;
// curl localhost:8080/actuator/us
@ReadOperation public String gt()
{ return u == null ? "null" : u.toString(); }
// curl -X POST -d '{"a":"fn","b":"ln","c":"mn","d":123}' \
// -H "Content-type:application/json" http://localhost:8080/actuator/us
@WriteOperation
public void st(String a, String b, String c, long d) {
var q = u == null ? (u = new us()) : u;
q.fn = a;
q.ln = b;
q.mn = c;
q.bd = d;
}
// curl -X DELETE localhost:8080/actuator/us
@DeleteOperation public void dl() { u = null; }
}
}