diff --git a/spring-cloud-bus/pom.xml b/spring-cloud-bus/pom.xml index 27f2768..9a7eb68 100644 --- a/spring-cloud-bus/pom.xml +++ b/spring-cloud-bus/pom.xml @@ -54,11 +54,6 @@ spring-cloud-stream-test-support test - - org.projectlombok - lombok - true - diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusProperties.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusProperties.java index 002f6e6..9b48983 100644 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusProperties.java +++ b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusProperties.java @@ -18,13 +18,10 @@ package org.springframework.cloud.bus; import org.springframework.boot.context.properties.ConfigurationProperties; -import lombok.Data; - /** * @author Dave Syer * */ -@Data @ConfigurationProperties("spring.cloud.bus") public class BusProperties { @@ -54,23 +51,68 @@ public class BusProperties { */ private boolean enabled = true; - @Data + public Env getEnv() { + return env; + } + + public Refresh getRefresh() { + return refresh; + } + + public Ack getAck() { + return ack; + } + + public Trace getTrace() { + return trace; + } + + public String getDestination() { + return destination; + } + + public void setDestination(String destination) { + this.destination = destination; + } + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + public static class Env { /** * Flag to switch off environment change events (default on). */ private boolean enabled = true; + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } } - @Data public static class Refresh { /** * Flag to switch off refresh events (default on). */ private boolean enabled = true; + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } } - @Data public static class Ack { /** * Flag to switch off acks (default on). @@ -80,14 +122,37 @@ public class BusProperties { * Service that wants to listen to acks. By default null (meaning all services). */ private String destinationService; + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public String getDestinationService() { + return destinationService; + } + + public void setDestinationService(String destinationService) { + this.destinationService = destinationService; + } } - @Data public static class Trace { /** * Flag to switch on tracing of acks (default off). */ private boolean enabled = false; + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } } } diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/AckRemoteApplicationEvent.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/AckRemoteApplicationEvent.java index d5aa25b..1fae5e7 100644 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/AckRemoteApplicationEvent.java +++ b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/AckRemoteApplicationEvent.java @@ -16,9 +16,6 @@ package org.springframework.cloud.bus.event; -import lombok.Data; -import lombok.EqualsAndHashCode; - /** * An event that signals an ack of a specific {@link RemoteApplicationEvent}. These events * can be monitored by any applications that want to audit the responses to bus events. @@ -29,8 +26,6 @@ import lombok.EqualsAndHashCode; * */ @SuppressWarnings("serial") -@Data -@EqualsAndHashCode(callSuper = false) public class AckRemoteApplicationEvent extends RemoteApplicationEvent { private final String ackId; @@ -53,4 +48,57 @@ public class AckRemoteApplicationEvent extends RemoteApplicationEvent { this.ackId = ackId; this.event = type; } + + public String getAckId() { + return ackId; + } + + public String getAckDestinationService() { + return ackDestinationService; + } + + public Class getEvent() { + return event; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((ackDestinationService == null) ? 0 + : ackDestinationService.hashCode()); + result = prime * result + ((ackId == null) ? 0 : ackId.hashCode()); + result = prime * result + ((event == null) ? 0 : event.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + AckRemoteApplicationEvent other = (AckRemoteApplicationEvent) obj; + if (ackDestinationService == null) { + if (other.ackDestinationService != null) + return false; + } + else if (!ackDestinationService.equals(other.ackDestinationService)) + return false; + if (ackId == null) { + if (other.ackId != null) + return false; + } + else if (!ackId.equals(other.ackId)) + return false; + if (event == null) { + if (other.event != null) + return false; + } + else if (!event.equals(other.event)) + return false; + return true; + } } diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/EnvironmentChangeListener.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/EnvironmentChangeListener.java index d6ce6de..5f33122 100644 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/EnvironmentChangeListener.java +++ b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/EnvironmentChangeListener.java @@ -2,8 +2,8 @@ package org.springframework.cloud.bus.event; import java.util.Map; -import lombok.extern.apachecommons.CommonsLog; - +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.context.environment.EnvironmentManager; import org.springframework.context.ApplicationListener; @@ -11,9 +11,11 @@ import org.springframework.context.ApplicationListener; /** * @author Spencer Gibb */ -@CommonsLog -public class EnvironmentChangeListener implements - ApplicationListener { +public class EnvironmentChangeListener + implements ApplicationListener { + + private static Log log = LogFactory.getLog(EnvironmentChangeListener.class); + @Autowired private EnvironmentManager env; diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/EnvironmentChangeRemoteApplicationEvent.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/EnvironmentChangeRemoteApplicationEvent.java index ebdbd94..a796251 100644 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/EnvironmentChangeRemoteApplicationEvent.java +++ b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/EnvironmentChangeRemoteApplicationEvent.java @@ -2,15 +2,10 @@ package org.springframework.cloud.bus.event; import java.util.Map; -import lombok.Data; -import lombok.EqualsAndHashCode; - /** * @author Spencer Gibb */ @SuppressWarnings("serial") -@Data -@EqualsAndHashCode(callSuper = false) public class EnvironmentChangeRemoteApplicationEvent extends RemoteApplicationEvent { private final Map values; @@ -27,4 +22,34 @@ public class EnvironmentChangeRemoteApplicationEvent extends RemoteApplicationEv this.values = values; } + public Map getValues() { + return values; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((values == null) ? 0 : values.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + EnvironmentChangeRemoteApplicationEvent other = (EnvironmentChangeRemoteApplicationEvent) obj; + if (values == null) { + if (other.values != null) + return false; + } + else if (!values.equals(other.values)) + return false; + return true; + } + } diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/RefreshListener.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/RefreshListener.java index 25b760c..3ef7ec3 100644 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/RefreshListener.java +++ b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/RefreshListener.java @@ -2,18 +2,19 @@ package org.springframework.cloud.bus.event; import java.util.Arrays; -import lombok.extern.apachecommons.CommonsLog; - +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.springframework.cloud.endpoint.RefreshEndpoint; import org.springframework.context.ApplicationListener; /** * @author Spencer Gibb */ -@CommonsLog -public class RefreshListener implements - ApplicationListener { - +public class RefreshListener + implements ApplicationListener { + + private static Log log = LogFactory.getLog(RefreshListener.class); + private RefreshEndpoint endpoint; public RefreshListener(RefreshEndpoint endpoint) { @@ -23,6 +24,7 @@ public class RefreshListener implements @Override public void onApplicationEvent(RefreshRemoteApplicationEvent event) { String[] keys = endpoint.refresh(); - log.info("Received remote refresh request. Keys refreshed " + Arrays.asList(keys)); + log.info( + "Received remote refresh request. Keys refreshed " + Arrays.asList(keys)); } } diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/RemoteApplicationEvent.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/RemoteApplicationEvent.java index bd6d2a5..446226d 100644 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/RemoteApplicationEvent.java +++ b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/RemoteApplicationEvent.java @@ -7,15 +7,10 @@ import org.springframework.context.ApplicationEvent; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonTypeInfo; -import lombok.Data; -import lombok.EqualsAndHashCode; - /** * @author Spencer Gibb */ @SuppressWarnings("serial") -@Data -@EqualsAndHashCode(callSuper = false) @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") @JsonIgnoreProperties("source") public abstract class RemoteApplicationEvent extends ApplicationEvent { @@ -47,4 +42,58 @@ public abstract class RemoteApplicationEvent extends ApplicationEvent { protected RemoteApplicationEvent(Object source, String originService) { this(source, originService, null); } + + public String getOriginService() { + return originService; + } + + public String getDestinationService() { + return destinationService; + } + + public String getId() { + return id; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((destinationService == null) ? 0 : destinationService.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + + ((originService == null) ? 0 : originService.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + RemoteApplicationEvent other = (RemoteApplicationEvent) obj; + if (destinationService == null) { + if (other.destinationService != null) + return false; + } + else if (!destinationService.equals(other.destinationService)) + return false; + if (id == null) { + if (other.id != null) + return false; + } + else if (!id.equals(other.id)) + return false; + if (originService == null) { + if (other.originService != null) + return false; + } + else if (!originService.equals(other.originService)) + return false; + return true; + } } diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/SentApplicationEvent.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/SentApplicationEvent.java index 88bf7a0..cc6640b 100644 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/SentApplicationEvent.java +++ b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/SentApplicationEvent.java @@ -5,9 +5,6 @@ import org.springframework.context.ApplicationEvent; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonTypeInfo; -import lombok.Data; -import lombok.EqualsAndHashCode; - /** * An event signalling that a remote event was sent somewhere in the system. This is not * itself a {@link RemoteApplicationEvent}, so it isn't sent over the bus, instead it is @@ -19,8 +16,6 @@ import lombok.EqualsAndHashCode; * @author Dave Syer */ @SuppressWarnings("serial") -@Data -@EqualsAndHashCode(callSuper = false) @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") @JsonIgnoreProperties("source") public class SentApplicationEvent extends ApplicationEvent { @@ -52,4 +47,73 @@ public class SentApplicationEvent extends ApplicationEvent { this.destinationService = destinationService; this.id = id; } + + public Class getType() { + return type; + } + + public void setType(Class type) { + this.type = type; + } + + public String getOriginService() { + return originService; + } + + public String getDestinationService() { + return destinationService; + } + + public String getId() { + return id; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((destinationService == null) ? 0 : destinationService.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + + ((originService == null) ? 0 : originService.hashCode()); + result = prime * result + ((type == null) ? 0 : type.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + SentApplicationEvent other = (SentApplicationEvent) obj; + if (destinationService == null) { + if (other.destinationService != null) + return false; + } + else if (!destinationService.equals(other.destinationService)) + return false; + if (id == null) { + if (other.id != null) + return false; + } + else if (!id.equals(other.id)) + return false; + if (originService == null) { + if (other.originService != null) + return false; + } + else if (!originService.equals(other.originService)) + return false; + if (type == null) { + if (other.type != null) + return false; + } + else if (!type.equals(other.type)) + return false; + return true; + } } diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/TraceListener.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/TraceListener.java index cec0317..3415ebd 100644 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/TraceListener.java +++ b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/TraceListener.java @@ -3,20 +3,21 @@ package org.springframework.cloud.bus.event; import java.util.LinkedHashMap; import java.util.Map; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.springframework.boot.actuate.trace.TraceRepository; import org.springframework.context.event.EventListener; -import lombok.extern.apachecommons.CommonsLog; - /** * A listener for sends and acks of remote application events. Inserts a record for each * signal in the {@link TraceRepository}. * * @author Dave Syer */ -@CommonsLog public class TraceListener { + private static Log log = LogFactory.getLog(TraceListener.class); + private TraceRepository repository; public TraceListener(TraceRepository repository) { diff --git a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/jackson/SubtypeModuleTests.java b/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/jackson/SubtypeModuleTests.java index a22a7e8..7bcbaf7 100644 --- a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/jackson/SubtypeModuleTests.java +++ b/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/jackson/SubtypeModuleTests.java @@ -19,10 +19,9 @@ public class SubtypeModuleTests { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new SubtypeModule(MyRemoteApplicationEvent.class)); - RemoteApplicationEvent event = mapper - .readValue( - "{\"type\":\"my\", \"destinationService\":\"myservice\", \"originService\":\"myorigin\"}", - RemoteApplicationEvent.class); + RemoteApplicationEvent event = mapper.readValue( + "{\"type\":\"my\", \"destinationService\":\"myservice\", \"originService\":\"myorigin\"}", + RemoteApplicationEvent.class); assertTrue("event is wrong type", event instanceof MyRemoteApplicationEvent); MyRemoteApplicationEvent myEvent = MyRemoteApplicationEvent.class.cast(event); assertEquals("originService was wrong", "myorigin", myEvent.getOriginService()); @@ -34,6 +33,7 @@ public class SubtypeModuleTests { assertTrue("event is wrong type", event instanceof AnotherRemoteApplicationEvent); } + @SuppressWarnings("serial") @JsonTypeName("my") public static class MyRemoteApplicationEvent extends RemoteApplicationEvent { @SuppressWarnings("unused") @@ -50,6 +50,7 @@ public class SubtypeModuleTests { } } + @SuppressWarnings("serial") @JsonTypeName("another") public static class AnotherRemoteApplicationEvent extends RemoteApplicationEvent { @SuppressWarnings("unused")