public final class SimulatorHookExecutor
- Object
- SimulatorHookExecutor
Cross-platform registry of named actions that the JavaSE simulator exposes.
The simulator scans cn1libs (and the app itself) for
META-INF/codenameone/simulator-hooks.properties files; each hook
declared there is registered here under namespace:itemN keys. The
JavaSE port hooks into CN.execute(String) /
CN.canExecute(String) so cross-platform code (such
as a CN1 UnitTest under common/) can invoke a hook via the same
execute it would use for any other URL, with no JavaSE-only import.
On Android, iOS, JavaScript and other production targets this registry
is always empty, so execute returns false and isRegistered is
always false – the “running outside a simulator” signal.
Hooks can be menu-backed (shipped with a label and visible in the simulator’s menu bar) or API-only (no label, callable by URL only). Tests that want behavioral coverage of cn1lib internals lean on the API-only form so the menu UX stays focused on actions a human would click.
Methods
public static boolean execute(String hookId) | Invokes the action registered under hookId. |
public static boolean isRegistered(String hookId) | Returns true if a hook with the given id is registered. |
public static Collection<String> registeredIds() | Diagnostic view of every registered id. |
public static void register(Map<String, Runnable> registered) | Replaces the entire registry. |
Inherited methods
Method details
execute
public static boolean execute(String hookId)hookId. Returns true
if a hook with that id was found and dispatched, false
otherwise. Invocation is delegated to whatever the registering code
configured (the JavaSE port wraps each hook in
Display.callSeriallyAndWait, so menu actions and tests run on the
CN1 EDT and the call is synchronous from off-EDT callers).Parameters
hookIdString- opaque id of the form
namespace:hook(the exact value the hook author chose in the properties file).
isRegistered
public static boolean isRegistered(String hookId)true if a hook with the given id is registered.
Useful for tests that want to skip themselves gracefully when running
on a platform that doesn’t expose the relevant cn1lib hook.registeredIds
public static Collection<String> registeredIds()register
public static void register(Map<String, Runnable> registered)