Class ToolIntrospector

java.lang.Object
dyntabs.ai.assistant.ToolIntrospector

public final class ToolIntrospector extends Object
Uses reflection to discover public methods on POJOs and build ToolSpecification instances without requiring @Tool annotations.
  • Method Details

    • introspect

      public static List<ToolMethod> introspect(Object... toolObjects)
      Discovers all eligible public methods on the given objects and creates ToolMethod entries for each.

      If the object is a Jakarta EJB proxy (CDI/Weld-injected @Stateless, @Stateful, or @Singleton bean), 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).

    • resolveTargetClass

      public static Class<?> resolveTargetClass(Object obj)
      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