Class 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.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanInvokes the action registered underhookId.static booleanisRegistered(String hookId) Returnstrueif a hook with the given id is registered.static voidReplaces the entire registry.static Collection<String> Diagnostic view of every registered id.
-
Method Details
-
execute
Invokes the action registered under
hookId. Returnstrueif a hook with that id was found and dispatched,falseotherwise. Invocation is delegated to whatever the registering code configured (the JavaSE port wraps each hook inDisplay.callSeriallyAndWait, so menu actions and tests run on the CN1 EDT and the call is synchronous from off-EDT callers).Parameters
hookId: opaque id of the formnamespace:hook(the exact value the hook author chose in the properties file).
-
isRegistered
Returnstrueif 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
Diagnostic view of every registered id. Returns an unmodifiable snapshot -- never null. Intended for tests/inspectors; ordinary app code shouldn't need this. -
register
-