Interface Introspection

All Known Implementing Classes:
IntrospectionImpl

public sealed interface Introspection permits IntrospectionImpl

The introspection api provides read-only access to JDA-Commands property system and allows subscribing to FrameworkEvents in the frameworks interaction execution process.

To access the api, you can either

When accessing trough accessScoped(), you have to pay attention where you do so. An Introspection instance is set in most but not in all places, to know where you can use it take a look at the IntrospectionAccess annotation on user implementable methods provided by the framework.

Inside of interaction controller methods (the ones having ComponentEvent, CommandEvent etc. as a parameter and are defined inside a class annotated with Interaction ) the Introspection instance is always set with the stage Stage.INTERACTION, providing access to all Propertys.

Stage and Properties access

The Property API allows accessing all public components and configuration options of JDA-Commands. It can be used to retrieve framework services like MessageResolver, config options like Property.GLOBAL_REPLY_CONFIG or context dependent information like InvocationContext.

Please note that access is read-only, you can't set the value of a Property after starting the framework.

Based on the location (in code) where you access this api, the available Properties may very. To know what property is accessible, take a look at currentStage() and compare it to Property.stage(). A hint on the current stage is also provided by IntrospectionAccess.value().

FrameworkEvents

Sometimes it's convenient to execute some custom code at some point during runtime based on events inside the framework.

An example can be found inside the guice extension, were we use a RuntimeCloseEvent to remove the interaction controller instances inside the cache at the end of a conversation.

To subscribe to a FrameworkEvent you use subscribe(Class, Subscriber) which returns a Subscription allowing you to "unsubscribe" from this event later. If an FrameworkEvent is fired by JDA-Commands all Subscribers of that event are called.

It's important to know that the events are published by multiple threads perhaps concurrently, thus Subscribers may be also called concurrently. They have to be written with threadsafety in mind!

Implementation Note:
Internally accessScoped() uses ScopedValues. For further clarification on how this works with Threads take a look there.