Package com.tnsai.actions
Class ActionDiscovery
java.lang.Object
com.tnsai.actions.ActionDiscovery
Discovers actions from Role classes using reflection.
Scans public methods with @Action annotation and converts them to ActionMetadata.
Following ADR-004: Action Discovery via Reflection
- Public methods with @Action annotation = Actions
- Methods without @Action = Helper methods (ignored)
- Private/protected methods = Helper methods (ignored)
- Results are cached for performance
IMPORTANT: @Action annotation is MANDATORY for methods to be discovered as actions.
Inherited public instance actions remain available until overridden. An override
without
@ActionSpec removes exposure; an annotated override supplies the
complete method metadata. The same override rule applies to capability defaults.
Thread-safe with concurrent cache.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidClears the entire cache.static voidclearCache(Class<?> roleClass) Clears the cache for a specific role class.static DiscoveredRoleActionsdiscoverActions(Role role) Discovers all actions from a Role instance.static DiscoveredRoleActionsdiscoverActions(Class<?> roleClass) Discovers all actions from a Role class.static intGets the current cache size.static booleanChecks if a role class is cached.
-
Constructor Details
-
ActionDiscovery
public ActionDiscovery()
-
-
Method Details
-
discoverActions
Discovers all actions from a Role instance. Results are cached by role class.- Parameters:
role- the role instance- Returns:
- role metadata with all discovered actions
-
discoverActions
Discovers all actions from a Role class. Results are cached by role class.Thread-safe: Uses computeIfAbsent to ensure atomic cache operations and prevent duplicate reflection work across concurrent threads.
- Parameters:
roleClass- the role class- Returns:
- role metadata with all discovered actions
-
clearCache
Clears the cache for a specific role class. Useful for testing or dynamic reloading.- Parameters:
roleClass- the role class to clear from cache
-
clearAllCache
public static void clearAllCache()Clears the entire cache. Useful for testing. -
getCacheSize
public static int getCacheSize()Gets the current cache size.- Returns:
- number of cached role classes
-
isCached
Checks if a role class is cached.- Parameters:
roleClass- the role class to check- Returns:
- true if cached
-