ConditionalOnPod constructor
const
ConditionalOnPod({})
The ConditionalOnPod
annotation in Jetleaf allows developers to
conditionally process classes or methods based on the presence of specific
pods in the application context.
This is especially useful when you want a configuration, service, or pod to only be loaded if another pod (or set of pods) already exists. Conditions can be defined by pod type, annotation, or name.
Key Features:
- Require specific pod types to exist in the context.
- Require pods annotated with certain annotations.
- Require pods with given names.
Usage Examples:
// Require a specific pod type
@ConditionalOnPod(types: [ClassType<DataSource>()])
class JdbcTemplateConfig {}
// Require a pod with a specific name
@ConditionalOnPod(names: ['myCustomService'])
class FallbackServiceConfig {}
Using this annotation ensures your configuration or beans are only registered when the expected pods are already available in the Jetleaf context.
Implementation
const ConditionalOnPod({this.types = const [], this.names = const []});