forked from Linyuzai/concept
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
tanghanzheng
committed
Aug 1, 2022
1 parent
400442c
commit 8e3676b
Showing
36 changed files
with
260 additions
and
278 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
...concept-event-core/src/main/java/com/github/linyuzai/event/core/bus/AbstractEventBus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.github.linyuzai.event.core.bus; | ||
|
||
import com.github.linyuzai.event.core.concept.EventConcept; | ||
import com.github.linyuzai.event.core.exchange.EventExchange; | ||
|
||
public class AbstractEventBus implements EventBus { | ||
|
||
private EventConcept concept; | ||
|
||
private EventExchange exchange; | ||
|
||
public void publish(Object event) { | ||
concept.template().publish(event); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...t-event/concept-event-core/src/main/java/com/github/linyuzai/event/core/bus/EventBus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.github.linyuzai.event.core.bus; | ||
|
||
public interface EventBus { | ||
|
||
|
||
} |
20 changes: 0 additions & 20 deletions
20
...t-event-core/src/main/java/com/github/linyuzai/event/core/codec/AbstractEventDecoder.java
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
...t-event-core/src/main/java/com/github/linyuzai/event/core/codec/EventDecodeException.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...nt-core/src/main/java/com/github/linyuzai/event/core/codec/SerializationEventDecoder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.github.linyuzai.event.core.codec; | ||
|
||
import com.github.linyuzai.event.core.context.EventContext; | ||
import lombok.SneakyThrows; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.ObjectInputStream; | ||
|
||
public class SerializationEventDecoder implements EventDecoder { | ||
@SneakyThrows | ||
@Override | ||
public Object decode(Object event, EventContext context) { | ||
if (event instanceof byte[]) { | ||
try (ByteArrayInputStream is = new ByteArrayInputStream((byte[]) event); | ||
ObjectInputStream ois = new ObjectInputStream(is)) { | ||
return ois.readObject(); | ||
} | ||
} | ||
throw new IllegalArgumentException("Byte array required but " + event.getClass()); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...nt-core/src/main/java/com/github/linyuzai/event/core/codec/SerializationEventEncoder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.github.linyuzai.event.core.codec; | ||
|
||
import com.github.linyuzai.event.core.context.EventContext; | ||
import lombok.SneakyThrows; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.ObjectOutputStream; | ||
|
||
public class SerializationEventEncoder implements EventEncoder { | ||
@SneakyThrows | ||
@Override | ||
public Object encode(Object event, EventContext context) { | ||
try (ByteArrayOutputStream os = new ByteArrayOutputStream(); | ||
ObjectOutputStream oos = new ObjectOutputStream(os)) { | ||
oos.writeObject(event); | ||
return os.toByteArray(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.