Compare commits
No commits in common. '7c5a1f1a2b4b688c3cfc602f07e65b435d75eba7' and '120a9e915df2a9c1c31f03998efbeeb7355409d8' have entirely different histories.
7c5a1f1a2b
...
120a9e915d
@ -0,0 +1,33 @@
|
|||||||
|
package org.xbib.event;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class DefaultEvent implements Event {
|
||||||
|
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
private Map<String, Object> map;
|
||||||
|
|
||||||
|
public DefaultEvent() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setKey(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setMap(Map<String, Object> map) {
|
||||||
|
this.map = map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> getMap() {
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
@ -1,14 +1,14 @@
|
|||||||
package org.xbib.event.clock;
|
package org.xbib.event.clock;
|
||||||
|
|
||||||
import org.xbib.event.common.EventImpl;
|
import org.xbib.event.DefaultEvent;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
public class ClockEventImpl extends EventImpl implements ClockEvent {
|
public class DefaultClockEvent extends DefaultEvent implements ClockEvent {
|
||||||
|
|
||||||
private Instant instant;
|
private Instant instant;
|
||||||
|
|
||||||
public ClockEventImpl() {
|
public DefaultClockEvent() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -1,53 +0,0 @@
|
|||||||
package org.xbib.event.common;
|
|
||||||
|
|
||||||
import org.xbib.datastructures.json.tiny.Json;
|
|
||||||
import org.xbib.event.Event;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class EventImpl implements Event {
|
|
||||||
|
|
||||||
private String type;
|
|
||||||
|
|
||||||
private Map<String, Object> map;
|
|
||||||
|
|
||||||
public EventImpl() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setType(String type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setMap(Map<String, Object> map) {
|
|
||||||
this.map = map;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Object> getMap() {
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EventImpl fromJson(String json) {
|
|
||||||
Map<String, Object> map = Json.toMap(json);
|
|
||||||
EventImpl event = new EventImpl();
|
|
||||||
event.setType((String) map.get("type"));
|
|
||||||
event.setMap(map);
|
|
||||||
return event;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toJson() throws IOException {
|
|
||||||
return Json.toString(map);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isNullEvent() {
|
|
||||||
return type == null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
package org.xbib.event.common;
|
|
||||||
|
|
||||||
import org.xbib.event.bus.EventBus;
|
|
||||||
import org.xbib.settings.Settings;
|
|
||||||
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
|
|
||||||
public interface EventManagerService {
|
|
||||||
|
|
||||||
EventManagerService init(Settings settings, EventBus eventBus, ClassLoader classLoader, ExecutorService executorService);
|
|
||||||
}
|
|
@ -1,20 +1,20 @@
|
|||||||
package org.xbib.event.generic;
|
package org.xbib.event.generic;
|
||||||
|
|
||||||
import org.xbib.event.common.EventImpl;
|
import org.xbib.event.DefaultEvent;
|
||||||
|
|
||||||
public class GenericEventImpl extends EventImpl implements GenericEvent {
|
public class DefaultGenericEvent extends DefaultEvent implements GenericEvent {
|
||||||
|
|
||||||
private Listener listener;
|
private Listener listener;
|
||||||
|
|
||||||
public GenericEventImpl() {
|
public DefaultGenericEvent() {
|
||||||
this(null);
|
this(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GenericEventImpl(Listener listener) {
|
public DefaultGenericEvent(Listener listener) {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GenericEventImpl setListener(Listener listener) {
|
public DefaultGenericEvent setListener(Listener listener) {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
@ -1,16 +1,16 @@
|
|||||||
package org.xbib.event.path;
|
package org.xbib.event.path;
|
||||||
|
|
||||||
import org.xbib.event.common.EventImpl;
|
import org.xbib.event.DefaultEvent;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
public class FileFollowEventImpl extends EventImpl implements FileFollowEvent {
|
public class DefaultFileFollowEvent extends DefaultEvent implements FileFollowEvent {
|
||||||
|
|
||||||
private Path path;
|
private Path path;
|
||||||
|
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
public FileFollowEventImpl() {
|
public DefaultFileFollowEvent() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -1,14 +1,14 @@
|
|||||||
package org.xbib.event.timer;
|
package org.xbib.event.timer;
|
||||||
|
|
||||||
import org.xbib.event.common.EventImpl;
|
import org.xbib.event.DefaultEvent;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
public class TimerEventImpl extends EventImpl implements TimerEvent {
|
public class DefaultTimerEvent extends DefaultEvent implements TimerEvent {
|
||||||
|
|
||||||
private Instant instant;
|
private Instant instant;
|
||||||
|
|
||||||
public TimerEventImpl() {
|
public DefaultTimerEvent() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -1,4 +1,4 @@
|
|||||||
package org.xbib.event.clock;
|
package org.xbib.event.clock;
|
||||||
|
|
||||||
public class TestClockEvent extends ClockEventImpl {
|
public class TestClockEvent extends DefaultClockEvent {
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package org.xbib.event.path;
|
package org.xbib.event.path;
|
||||||
|
|
||||||
public class TestFileFollowEvent extends FileFollowEventImpl {
|
public class TestFileFollowEvent extends DefaultFileFollowEvent {
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package org.xbib.event.timer;
|
package org.xbib.event.timer;
|
||||||
|
|
||||||
public class TestTimerEvent extends TimerEventImpl {
|
public class TestTimerEvent extends DefaultTimerEvent {
|
||||||
}
|
}
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
dependencies {
|
|
||||||
api project(':event-common')
|
|
||||||
api libs.net.http.server.netty
|
|
||||||
api libs.net.http.client.netty
|
|
||||||
implementation libs.datastructures.json.tiny
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
module org.xbib.event.net.http {
|
|
||||||
exports org.xbib.event.net.http;
|
|
||||||
requires org.xbib.event.api;
|
|
||||||
requires org.xbib.event.common;
|
|
||||||
requires org.xbib.net.http;
|
|
||||||
requires org.xbib.net.http.client;
|
|
||||||
requires org.xbib.net.http.client.netty;
|
|
||||||
requires org.xbib.net.http.client.netty.secure;
|
|
||||||
requires org.xbib.net.http.server;
|
|
||||||
requires org.xbib.net.http.server.netty;
|
|
||||||
requires org.xbib.net.http.server.netty.secure;
|
|
||||||
requires java.logging;
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
package org.xbib.event.net.http;
|
|
||||||
|
|
||||||
import org.xbib.event.common.EventManager;
|
|
||||||
import org.xbib.event.common.EventImpl;
|
|
||||||
import org.xbib.net.http.HttpHeaderNames;
|
|
||||||
import org.xbib.net.http.HttpHeaderValues;
|
|
||||||
import org.xbib.net.http.HttpMethod;
|
|
||||||
import org.xbib.net.http.server.service.BaseHttpService;
|
|
||||||
import org.xbib.net.http.server.service.HttpService;
|
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
import static org.xbib.net.http.HttpResponseStatus.NOT_FOUND;
|
|
||||||
import static org.xbib.net.http.HttpResponseStatus.OK;
|
|
||||||
|
|
||||||
public class EventReceiverService {
|
|
||||||
|
|
||||||
private final EventManager eventManager;
|
|
||||||
|
|
||||||
public EventReceiverService(EventManager eventManager) {
|
|
||||||
this.eventManager = eventManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HttpService createService(String prefix) {
|
|
||||||
return BaseHttpService.builder()
|
|
||||||
.setPrefix(prefix)
|
|
||||||
.setPath("/event/{type}")
|
|
||||||
.setMethod(HttpMethod.POST)
|
|
||||||
.setHandler(ctx -> {
|
|
||||||
EventImpl event = EventImpl.fromJson(ctx.getRequest().asJson());
|
|
||||||
if (event.isNullEvent()) {
|
|
||||||
ctx.status(NOT_FOUND).done();
|
|
||||||
} else {
|
|
||||||
eventManager.submit(event);
|
|
||||||
ctx.status(OK)
|
|
||||||
.header(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.APPLICATION_JSON)
|
|
||||||
.charset(StandardCharsets.UTF_8)
|
|
||||||
.body(event.toJson())
|
|
||||||
.done();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
dependencies {
|
|
||||||
api project(':event-common')
|
|
||||||
implementation libs.datastructures.json.tiny
|
|
||||||
implementation libs.netty.handler
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
import org.xbib.event.common.EventManagerService;
|
|
||||||
import org.xbib.event.syslog.SyslogEventManagerService;
|
|
||||||
|
|
||||||
module org.xbib.event.syslog {
|
|
||||||
exports org.xbib.event.syslog;
|
|
||||||
provides EventManagerService with SyslogEventManagerService;
|
|
||||||
requires org.xbib.event.common;
|
|
||||||
requires org.xbib.datastructures.json.tiny;
|
|
||||||
requires io.netty.buffer;
|
|
||||||
requires io.netty.common;
|
|
||||||
requires io.netty.transport;
|
|
||||||
requires io.netty.handler;
|
|
||||||
requires io.netty.codec;
|
|
||||||
requires java.logging;
|
|
||||||
requires org.xbib.settings.api;
|
|
||||||
requires org.xbib.event.api;
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
org.xbib.event.syslog.SyslogEventManagerService
|
|
@ -1,3 +1,3 @@
|
|||||||
group = org.xbib
|
group = org.xbib
|
||||||
name = event
|
name = event
|
||||||
version = 0.2.0
|
version = 0.1.0
|
||||||
|
Loading…
Reference in New Issue