Package org.pjdbc.capabilities
Class PjdbcCapabilities
java.lang.Object
org.pjdbc.capabilities.PjdbcCapabilities
Runtime introspection API for PJDBC driver capabilities.
This class provides access to the capabilities manifest that describes all available PJDBC drivers, their parameters, dependencies, and side effects.
Example usage:
PjdbcCapabilities caps = PjdbcCapabilities.load();
// Find all caching drivers
List<DriverCapability> cachingDrivers = caps.findByCapability("caching");
// Get a specific driver by prefix
Optional<DriverCapability> pool = caps.findByPrefix("pool");
// Check if a driver has optional dependencies
pool.ifPresent(d -> {
if (!d.dependencies().isEmpty()) {
System.out.println("Requires: " + d.dependencies());
}
});
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic enumSource from which capabilities were loaded. -
Method Summary
Modifier and TypeMethodDescriptionstatic PjdbcCapabilities.Builderbuilder()Builder for creating PjdbcCapabilities instances programmatically.findByCapability(String capability) Finds all drivers with the specified capability.findByClass(String className) Finds a driver by its class name.findByPrefix(String prefix) Finds a driver by its URL prefix.findBySideEffect(String sideEffect) Finds all drivers that produce the specified side effect.Finds all drivers that are composable (can be chained).Finds all terminal drivers (those that don't delegate).Finds all drivers with external dependencies.Returns a list of all available capability tags across all drivers.Returns all available drivers.intReturns the number of available drivers.Returns the source from which capabilities were loaded.Returns the schema version of the capabilities manifest.booleanChecks if a driver with the given prefix is available.static PjdbcCapabilitiesload()Loads capabilities, trying manifest first then falling back to reflection.static PjdbcCapabilitiesForces loading from the manifest only.static PjdbcCapabilitiesForces loading via runtime reflection on annotated driver classes.static PjdbcCapabilitiesreload()Forces a reload of capabilities, trying manifest first then reflection.toString()
-
Method Details
-
load
Loads capabilities, trying manifest first then falling back to reflection.This method first attempts to load from the pjdbc.capabilities.json manifest. If the manifest is not found, it falls back to discovering drivers via runtime reflection on annotated classes.
- Returns:
- The loaded capabilities
- Throws:
PjdbcCapabilitiesException- if capabilities cannot be loaded from either source
-
loadFromManifest
Forces loading from the manifest only.- Returns:
- The loaded capabilities
- Throws:
PjdbcCapabilitiesException- if the manifest cannot be loaded or parsed
-
loadFromReflection
Forces loading via runtime reflection on annotated driver classes.This method scans known driver classes for @DriverCapability annotations and builds the capabilities model from those annotations. Useful during development when the manifest may not be up to date.
- Returns:
- The loaded capabilities
-
reload
Forces a reload of capabilities, trying manifest first then reflection. Useful for testing or when the manifest may have changed.- Returns:
- The reloaded capabilities
-
getVersion
Returns the schema version of the capabilities manifest. -
getSource
Returns the source from which capabilities were loaded. -
getAllDrivers
Returns all available drivers. -
findByPrefix
Finds a driver by its URL prefix.- Parameters:
prefix- The URL prefix (e.g., "pool", "log")- Returns:
- The driver if found
-
findByClass
Finds a driver by its class name.- Parameters:
className- The fully qualified class name- Returns:
- The driver if found
-
findByCapability
Finds all drivers with the specified capability.- Parameters:
capability- The capability tag (e.g., "caching", "pooling")- Returns:
- List of matching drivers
-
findComposable
Finds all drivers that are composable (can be chained). -
findTerminal
Finds all terminal drivers (those that don't delegate). -
findWithDependencies
Finds all drivers with external dependencies. -
findBySideEffect
Finds all drivers that produce the specified side effect.- Parameters:
sideEffect- One of: "logging", "metrics", "network", "filesystem", "stateful"- Returns:
- List of matching drivers
-
getAllCapabilityTags
Returns a list of all available capability tags across all drivers. -
hasDriver
Checks if a driver with the given prefix is available. -
getDriverCount
public int getDriverCount()Returns the number of available drivers. -
toString
-
builder
Builder for creating PjdbcCapabilities instances programmatically. Primarily useful for testing.
-