Account -> Orders
This commit is contained in:
@@ -31,7 +31,7 @@ public abstract class Aggregate<E extends Event, ID extends Serializable> extend
|
||||
Value<Link> {
|
||||
|
||||
@JsonProperty("id")
|
||||
abstract ID getIdentity();
|
||||
public abstract ID getIdentity();
|
||||
|
||||
private final ApplicationContext applicationContext = Optional.ofNullable(Provider.getApplicationContext())
|
||||
.orElse(null);
|
||||
@@ -123,7 +123,7 @@ public abstract class Aggregate<E extends Event, ID extends Serializable> extend
|
||||
.stream()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if(!super.hasLink("self"))
|
||||
if (!super.hasLink("self"))
|
||||
links.add(getId());
|
||||
|
||||
return links;
|
||||
@@ -165,12 +165,14 @@ public abstract class Aggregate<E extends Event, ID extends Serializable> extend
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <A extends Aggregate> Service<A, ID> getEntityService() {
|
||||
return (Service<A, ID>) getProvider().getDefaultService();
|
||||
@JsonIgnore
|
||||
protected Service<Aggregate<E, ID>, ID> getEntityService() {
|
||||
return (Service<Aggregate<E, ID>, ID>) getProvider().getDefaultService();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private EventService<E, ID> getEventService() {
|
||||
@JsonIgnore
|
||||
protected EventService<E, ID> getEventService() {
|
||||
return (EventService<E, ID>) getProvider().getDefaultEventService();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public abstract class Provider<T extends Aggregate> implements ApplicationContex
|
||||
Provider.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
public abstract Service<?, ?> getDefaultService();
|
||||
public abstract Service<? extends Aggregate, ?> getDefaultService();
|
||||
|
||||
public abstract EventService<?, ?> getDefaultEventService();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package demo.event;
|
||||
|
||||
import demo.domain.Aggregate;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.stream.messaging.Source;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.hateoas.Link;
|
||||
@@ -27,7 +28,9 @@ import java.net.URI;
|
||||
class EventServiceImpl<T extends Event, ID extends Serializable> implements EventService<T, ID> {
|
||||
|
||||
private static final Logger log = Logger.getLogger(EventServiceImpl.class);
|
||||
private static final String EVENT_PROCESSOR_URL = "http://localhost:8083/v1/events";
|
||||
|
||||
@Value("${events.worker:http://localhost:8080/v1/events}")
|
||||
private String eventsWorker;
|
||||
|
||||
private final EventRepository<T, ID> eventRepository;
|
||||
private final Source eventStream;
|
||||
@@ -41,7 +44,7 @@ class EventServiceImpl<T extends Event, ID extends Serializable> implements Even
|
||||
|
||||
public <E extends Aggregate, S extends T> S send(S event, Link... links) {
|
||||
// Assemble request to the event stream processor
|
||||
RequestEntity<Resource<T>> requestEntity = RequestEntity.post(URI.create(EVENT_PROCESSOR_URL))
|
||||
RequestEntity<Resource<T>> requestEntity = RequestEntity.post(URI.create(eventsWorker))
|
||||
.contentType(MediaTypes.HAL_JSON)
|
||||
.body(new Resource<T>(event), Resource.class);
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ public class ProviderTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
Long getIdentity() {
|
||||
public Long getIdentity() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user