Class ToolIntrospector
ToolSpecification instances for them.
Exposure policy (since 3.0.0): two entry points with different safety postures.
introspect(Object...)— opt-in (default, safe): only methods annotated withEasyToolare turned into tools. Unannotated methods stay invisible to the model. This is whatwithTools(...)uses.introspectAllPublic(Object...)— escape hatch (unsafe): every eligible public method becomes a tool, annotated or not. This is whatwithAllPublicMethodsAsTools(...)uses and should be reserved for prototypes.
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<ToolMethod> introspect(Object... toolObjects) Discovers opt-in tool methods — those annotated withEasyTool— on the given objects and creates aToolMethodentry for each.static List<ToolMethod> introspectAllPublic(Object... toolObjects) Discovers every eligible public method (annotated or not) on the given objects.static Class<?> resolveTargetClass(Object obj) Resolves the actual bean class behind a CDI/EJB proxy.
-
Method Details
-
introspect
Discovers opt-in tool methods — those annotated withEasyTool— on the given objects and creates aToolMethodentry for each. Unannotated methods are ignored, so they can never be invoked by the model.If the object is a Jakarta EJB proxy (CDI/Weld-injected
@Stateless,@Stateful, or@Singletonbean), the methods are read from the actual bean class (the proxy's superclass) while the proxy instance is kept as the invocation target. This ensures method calls still go through the container pipeline (transactions, security, interceptors).- Parameters:
toolObjects- the service objects to scan (POJOs or injected EJB proxies)- Returns:
- one
ToolMethodper@EasyTool-annotated method
-
introspectAllPublic
Discovers every eligible public method (annotated or not) on the given objects.Unsafe by design. This is the escape hatch behind
withAllPublicMethodsAsTools(...)and exposes the whole public surface of the beans to the model. Preferintrospect(Object...)plusEasyTooleverywhere but throwaway prototypes.- Parameters:
toolObjects- the service objects to scan (POJOs or injected EJB proxies)- Returns:
- one
ToolMethodper eligible public method
-
resolveTargetClass
Resolves the actual bean class behind a CDI/EJB proxy.CDI containers (Weld, OpenWebBeans, etc.) create proxy subclasses when injecting EJB beans. The proxy class itself has no business methods declared — they live on the superclass (the real bean class). This method detects whether the object is such a proxy by checking if the superclass carries a Jakarta EJB annotation (
@Stateless,@Stateful, or@Singleton). If so, the superclass is returned for method discovery; otherwise the object's own class is returned.- Parameters:
obj- the tool object (possibly a proxy)- Returns:
- the class to use for method discovery
-