Interface TemplateSupplier
TemplateSupplier
interface provides a mechanism for obtaining instances of Template
.
Template
is a utility class designed to enhance productivity by simplifying common NoSQL operations.
The TemplateSupplier
abstracts the complexity of database configuration and dependency injection,
facilitating seamless interaction with NoSQL databases, particularly schema-based databases.
Upon creation of a TemplateSupplier
instance, the Jakarta NoSQL provider is responsible for:
- Setting up the database credentials
- Initializing the database
- Configuring the dependency injection mechanism
Although Jakarta CDI (Contexts and Dependency Injection) is recommended as the dependency injection engine, its specific implementation is beyond the scope of the Jakarta NoSQL specification. The specification primarily focuses on configuration and management of database resources.
Once the TemplateSupplier
is instantiated and the Supplier.get()
method is invoked, it is expected that the
returned Template
instance is fully configured and ready for interaction with the database.
The Jakarta NoSQL provider must implement this interface as part of the Service Provider Interface (SPI)
to define the creation and configuration of the Template
.
public interface TemplateSupplier extends Supplier<Template> {
static TemplateSupplier template() {
ServiceLoader<TemplateSupplier> loader = ServiceLoader.load(TemplateSupplier.class);
return loader.findFirst()
.orElseThrow(() -> new IllegalStateException("The Template instance was not found"));
}
}
- Since:
- 1.0
- See Also:
-
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic TemplateSupplier
template()
Retrieves an instance ofTemplateSupplier
using theServiceLoader
mechanism.
-
Method Details
-
template
Retrieves an instance ofTemplateSupplier
using theServiceLoader
mechanism.- Returns:
- an instance of
TemplateSupplier
- Throws:
IllegalStateException
- if noTemplateSupplier
implementation is found
-