Skip to content

Commit dabeefe

Browse files
committed
feat: FSM 2
1 parent 01a1b46 commit dabeefe

12 files changed

+529
-318
lines changed
Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,21 @@
1818

1919
import org.jetbrains.annotations.NotNull;
2020

21-
public interface ProtocolAdapterTransition {
22-
@NotNull ProtocolAdapterTransitionResponse transition(
23-
final @NotNull ProtocolAdapterState toState,
24-
final @NotNull ProtocolAdapterInstance session,
25-
final @NotNull ProtocolAdapterTransitionRequest request);
21+
import java.util.function.Supplier;
22+
23+
public final class ClassLoaderUtils {
24+
private ClassLoaderUtils() {
25+
}
26+
27+
public static <T> @NotNull T runWithContextLoader(
28+
final @NotNull ClassLoader contextLoader,
29+
final @NotNull Supplier<T> wrapperSupplier) {
30+
final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
31+
try {
32+
Thread.currentThread().setContextClassLoader(contextLoader);
33+
return wrapperSupplier.get();
34+
} finally {
35+
Thread.currentThread().setContextClassLoader(contextClassLoader);
36+
}
37+
}
2638
}

hivemq-edge/src/main/java/com/hivemq/protocols/fsm/I18nProtocolAdapterMessage.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public enum I18nProtocolAdapterMessage implements I18nError {
2626
FSM_TRANSITION_FAILURE_UNABLE_TO_TRANSITION_FROM_STATE_TO_STATE,
2727
FSM_TRANSITION_SUCCESS_STATE_IS_UNCHANGED,
2828
FSM_TRANSITION_SUCCESS_TRANSITIONED_FROM_STATE_TO_STATE,
29+
PROTOCOL_ADAPTER_MANAGER_PROTOCOL_ADAPTER_DELETED,
30+
PROTOCOL_ADAPTER_MANAGER_PROTOCOL_ADAPTER_NOT_FOUND,
2931
;
3032

3133
private static final @NotNull String RESOURCE_NAME_PREFIX = "templates/protocol-adapter-messages-";

hivemq-edge/src/main/java/com/hivemq/protocols/fsm/ProtocolAdapterConnectionState.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,36 @@ public enum ProtocolAdapterConnectionState {
4242
final @NotNull Object context) {
4343
return transitionFunction.apply(context);
4444
}
45+
46+
public boolean isClosed() {
47+
return this == Closed;
48+
}
49+
50+
public boolean isClosing() {
51+
return this == Closing;
52+
}
53+
54+
public boolean isConnected() {
55+
return this == Connected;
56+
}
57+
58+
public boolean isConnecting() {
59+
return this == Connecting;
60+
}
61+
62+
public boolean isDisconnecting() {
63+
return this == Disconnecting;
64+
}
65+
66+
public boolean isDisconnected() {
67+
return this == Disconnected;
68+
}
69+
70+
public boolean isError() {
71+
return this == Error;
72+
}
73+
74+
public boolean isErrorClosing() {
75+
return this == ErrorClosing;
76+
}
4577
}

hivemq-edge/src/main/java/com/hivemq/protocols/fsm/ProtocolAdapterManager2.java

Lines changed: 351 additions & 0 deletions
Large diffs are not rendered by default.

hivemq-edge/src/main/java/com/hivemq/protocols/fsm/ProtocolAdapterOperatorState.java renamed to hivemq-edge/src/main/java/com/hivemq/protocols/fsm/ProtocolAdapterManagerState.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package com.hivemq.protocols.fsm;
1818

19-
public enum ProtocolAdapterOperatorState {
19+
public enum ProtocolAdapterManagerState {
2020
Idle,
2121
Running,
2222
;

hivemq-edge/src/main/java/com/hivemq/protocols/fsm/ProtocolAdapterOperator.java

Lines changed: 0 additions & 221 deletions
This file was deleted.

0 commit comments

Comments
 (0)