Skip to content

Commit ed0b42d

Browse files
authored
Add InstanceEvents to Jackson module
This commit adds a Jackson module, which allows for easy (de-)serialization of the InstanceEvents. fixes #1348
1 parent 2eb8745 commit ed0b42d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2314
-96
lines changed

spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/domain/events/InstanceDeregisteredEvent.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2018 the original author or authors.
2+
* Copyright 2014-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,14 +30,16 @@
3030
@lombok.ToString(callSuper = true)
3131
public class InstanceDeregisteredEvent extends InstanceEvent {
3232

33+
public static final String TYPE = "DEREGISTERED";
34+
3335
private static final long serialVersionUID = 1L;
3436

3537
public InstanceDeregisteredEvent(InstanceId instance, long version) {
3638
this(instance, version, Instant.now());
3739
}
3840

3941
public InstanceDeregisteredEvent(InstanceId instance, long version, Instant timestamp) {
40-
super(instance, version, "DEREGISTERED", timestamp);
42+
super(instance, version, TYPE, timestamp);
4143
}
4244

4345
}

spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/domain/events/InstanceEndpointsDetectedEvent.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2018 the original author or authors.
2+
* Copyright 2014-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,6 +31,8 @@
3131
@lombok.ToString(callSuper = true)
3232
public class InstanceEndpointsDetectedEvent extends InstanceEvent {
3333

34+
public static final String TYPE = "ENDPOINTS_DETECTED";
35+
3436
private static final long serialVersionUID = 1L;
3537

3638
private final Endpoints endpoints;
@@ -40,7 +42,7 @@ public InstanceEndpointsDetectedEvent(InstanceId instance, long version, Endpoin
4042
}
4143

4244
public InstanceEndpointsDetectedEvent(InstanceId instance, long version, Instant timestamp, Endpoints endpoints) {
43-
super(instance, version, "ENDPOINTS_DETECTED", timestamp);
45+
super(instance, version, TYPE, timestamp);
4446
this.endpoints = endpoints;
4547
}
4648

spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/domain/events/InstanceInfoChangedEvent.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2018 the original author or authors.
2+
* Copyright 2014-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,6 +31,8 @@
3131
@lombok.ToString(callSuper = true)
3232
public class InstanceInfoChangedEvent extends InstanceEvent {
3333

34+
public static final String TYPE = "INFO_CHANGED";
35+
3436
private static final long serialVersionUID = 1L;
3537

3638
private final Info info;
@@ -40,7 +42,7 @@ public InstanceInfoChangedEvent(InstanceId instance, long version, Info info) {
4042
}
4143

4244
public InstanceInfoChangedEvent(InstanceId instance, long version, Instant timestamp, Info info) {
43-
super(instance, version, "INFO_CHANGED", timestamp);
45+
super(instance, version, TYPE, timestamp);
4446
this.info = info;
4547
}
4648

spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/domain/events/InstanceRegisteredEvent.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2018 the original author or authors.
2+
* Copyright 2014-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,6 +31,8 @@
3131
@lombok.ToString(callSuper = true)
3232
public class InstanceRegisteredEvent extends InstanceEvent {
3333

34+
public static final String TYPE = "REGISTERED";
35+
3436
private static final long serialVersionUID = 1L;
3537

3638
private final Registration registration;
@@ -40,7 +42,7 @@ public InstanceRegisteredEvent(InstanceId instance, long version, Registration r
4042
}
4143

4244
public InstanceRegisteredEvent(InstanceId instance, long version, Instant timestamp, Registration registration) {
43-
super(instance, version, "REGISTERED", timestamp);
45+
super(instance, version, TYPE, timestamp);
4446
this.registration = registration;
4547
}
4648

spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/domain/events/InstanceRegistrationUpdatedEvent.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2018 the original author or authors.
2+
* Copyright 2014-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,6 +31,8 @@
3131
@lombok.ToString(callSuper = true)
3232
public class InstanceRegistrationUpdatedEvent extends InstanceEvent {
3333

34+
public static final String TYPE = "REGISTRATION_UPDATED";
35+
3436
private static final long serialVersionUID = 1L;
3537

3638
private final Registration registration;
@@ -41,7 +43,7 @@ public InstanceRegistrationUpdatedEvent(InstanceId instance, long version, Regis
4143

4244
public InstanceRegistrationUpdatedEvent(InstanceId instance, long version, Instant timestamp,
4345
Registration registration) {
44-
super(instance, version, "REGISTRATION_UPDATED", timestamp);
46+
super(instance, version, TYPE, timestamp);
4547
this.registration = registration;
4648
}
4749

spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/domain/events/InstanceStatusChangedEvent.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2018 the original author or authors.
2+
* Copyright 2014-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,6 +31,8 @@
3131
@lombok.ToString(callSuper = true)
3232
public class InstanceStatusChangedEvent extends InstanceEvent {
3333

34+
public static final String TYPE = "STATUS_CHANGED";
35+
3436
private static final long serialVersionUID = 1L;
3537

3638
private final StatusInfo statusInfo;
@@ -40,7 +42,7 @@ public InstanceStatusChangedEvent(InstanceId instance, long version, StatusInfo
4042
}
4143

4244
public InstanceStatusChangedEvent(InstanceId instance, long version, Instant timestamp, StatusInfo statusInfo) {
43-
super(instance, version, "STATUS_CHANGED", timestamp);
45+
super(instance, version, TYPE, timestamp);
4446
this.statusInfo = statusInfo;
4547
}
4648

spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/domain/values/BuildVersion.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2018 the original author or authors.
2+
* Copyright 2014-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@
2222

2323
import javax.annotation.Nullable;
2424

25-
import com.fasterxml.jackson.annotation.JsonValue;
2625
import org.springframework.util.Assert;
2726

2827
@lombok.Data
@@ -65,7 +64,6 @@ public static BuildVersion from(Map<String, ?> map) {
6564
return null;
6665
}
6766

68-
@JsonValue
6967
public String getValue() {
7068
return this.value;
7169
}

spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/domain/values/Info.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2018 the original author or authors.
2+
* Copyright 2014-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,8 +23,6 @@
2323

2424
import javax.annotation.Nullable;
2525

26-
import com.fasterxml.jackson.annotation.JsonAnyGetter;
27-
2826
/**
2927
* Represents the info fetched from the info actuator endpoint
3028
*
@@ -57,7 +55,6 @@ public static Info empty() {
5755
return EMPTY;
5856
}
5957

60-
@JsonAnyGetter
6158
public Map<String, Object> getValues() {
6259
return this.values;
6360
}

spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/domain/values/InstanceId.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2017 the original author or authors.
2+
* Copyright 2014-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,8 +18,6 @@
1818

1919
import java.io.Serializable;
2020

21-
import com.fasterxml.jackson.annotation.JsonCreator;
22-
import com.fasterxml.jackson.annotation.JsonValue;
2321
import org.springframework.util.Assert;
2422

2523
/**
@@ -35,12 +33,10 @@ private InstanceId(String value) {
3533
this.value = value;
3634
}
3735

38-
@JsonCreator
3936
public static InstanceId of(String value) {
4037
return new InstanceId(value);
4138
}
4239

43-
@JsonValue
4440
@Override
4541
public String toString() {
4642
return value;

spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/domain/values/StatusInfo.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2018 the original author or authors.
2+
* Copyright 2014-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,7 +25,6 @@
2525

2626
import javax.annotation.Nullable;
2727

28-
import com.fasterxml.jackson.annotation.JsonIgnore;
2928
import org.springframework.util.Assert;
3029

3130
import static java.util.Arrays.asList;
@@ -103,22 +102,18 @@ public Map<String, Object> getDetails() {
103102
return Collections.unmodifiableMap(details);
104103
}
105104

106-
@JsonIgnore
107105
public boolean isUp() {
108106
return STATUS_UP.equals(status);
109107
}
110108

111-
@JsonIgnore
112109
public boolean isOffline() {
113110
return STATUS_OFFLINE.equals(status);
114111
}
115112

116-
@JsonIgnore
117113
public boolean isDown() {
118114
return STATUS_DOWN.equals(status);
119115
}
120116

121-
@JsonIgnore
122117
public boolean isUnknown() {
123118
return STATUS_UNKNOWN.equals(status);
124119
}

0 commit comments

Comments
 (0)