Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
youfanx committed Aug 26, 2024
1 parent 1015b15 commit 105a572
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
13 changes: 3 additions & 10 deletions rxlib/src/main/java/org/rx/core/ShellCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,6 @@ public void invoke(ShellCommand s, PrintOutEventArgs e) throws Throwable {
}
}

@RequiredArgsConstructor
@Getter
public static class ExitedEventArgs extends EventArgs {
private static final long serialVersionUID = 6563058539741657972L;
final int exitValue;
}

public static final TripleAction<ShellCommand, PrintOutEventArgs> CONSOLE_OUT_HANDLER = (s, e) -> System.out.print(e.toString());
static final String LINUX_BASH = "bash -c ", WIN_CMD = "cmd /c ";
static final List<ShellCommand> KILL_LIST = newConcurrentList(true);
Expand Down Expand Up @@ -184,7 +177,7 @@ static List<String> translateCommandline(final String toProcess) {
}

public final Delegate<ShellCommand, PrintOutEventArgs> onPrintOut = Delegate.create();
public final Delegate<ShellCommand, ExitedEventArgs> onExited = Delegate.create();
public final Delegate<ShellCommand, Integer> onExited = Delegate.create();

final long daemonPeriod;
@Getter
Expand Down Expand Up @@ -279,7 +272,7 @@ public synchronized ShellCommand start() {
synchronized (this) {
int exitValue = tmp.exitValue();
log.debug("exit={} {}", exitValue, shell);
raiseEvent(onExited, new ExitedEventArgs(exitValue));
raiseEvent(onExited, exitValue);
}
}
});
Expand Down Expand Up @@ -328,7 +321,7 @@ public synchronized void kill() {
log.debug("kill {}", shell);
process.destroyForcibly();
daemonFuture.cancel(true);
raiseEvent(onExited, new ExitedEventArgs(process.exitValue()));
raiseEvent(onExited, process.exitValue());
}

public synchronized void restart() {
Expand Down
8 changes: 4 additions & 4 deletions rxlib/src/main/java/org/rx/core/cache/DiskCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class DiskCache<TK, TV> implements Cache<TK, TV>, EventPublisher<DiskCach
IOC.register(DiskCache.class, new DiskCache<>());
}

public final Delegate<DiskCache<TK, TV>, NEventArgs<Map.Entry<TK, TV>>> onExpired = Delegate.create();
public final Delegate<DiskCache<TK, TV>, Map.Entry<TK, TV>> onExpired = Delegate.create();
final Cache<TK, DiskCacheItem<TV>> cache;
final KeyValueStore<TK, DiskCacheItem<TV>> store;
int defaultExpireSeconds = 60 * 60 * 24 * 365; //1 year
Expand All @@ -41,7 +41,7 @@ void onRemoval(@Nullable TK key, DiskCacheItem<TV> item, @NonNull RemovalCause r
return;
}
if (item.isExpired()) {
raiseEvent(onExpired, new NEventArgs<>(new AbstractMap.SimpleEntry<>(key, item.value)));
raiseEvent(onExpired, new AbstractMap.SimpleEntry<>(key, item.value));
return;
}
if (!(key instanceof Serializable && item.value instanceof Serializable)) {
Expand Down Expand Up @@ -87,9 +87,9 @@ private TV unwrap(TK key, DiskCacheItem<TV> item, boolean doRenew) {
if (onExpired == null) {
return null;
}
NEventArgs<Map.Entry<TK, TV>> args = new NEventArgs<>(new AbstractMap.SimpleEntry<>(key, item.value));
Map.Entry<TK, TV> args = new AbstractMap.SimpleEntry<>(key, item.value);
raiseEvent(onExpired, args);
return args.getValue().getValue();
return args.getValue();
}
if (doRenew && item.slidingRenew()) {
cache.put(key, item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) {
}
if (tryAs(pack, PingPacket.class, p -> {
log.info("clientHeartbeat pong {} {}ms", channel.remoteAddress(), NtpClock.UTC.millis() - p.getTimestamp());
raiseEventAsync(onPong, new NEventArgs<>(p));
raiseEventAsync(onPong, p);
})) {
return;
}
Expand Down Expand Up @@ -110,7 +110,7 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
onReconnected = Delegate.create();
public final Delegate<TcpClient, NEventArgs<Serializable>> onSend = Delegate.create(),
onReceive = Delegate.create();
public final Delegate<TcpClient, NEventArgs<PingPacket>> onPong = Delegate.create();
public final Delegate<TcpClient, PingPacket> onPong = Delegate.create();
public final Delegate<TcpClient, NEventArgs<Throwable>> onError = Delegate.create();
@Getter
final TcpClientConfig config;
Expand Down

0 comments on commit 105a572

Please sign in to comment.