use of org.jboss.as.connector.services.driver.registry.DriverRegistry in project wildfly by wildfly.
the class GetInstalledDriverOperationHandler method execute.
@Override
public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException {
validator.validate(operation);
final String name = operation.require(DRIVER_NAME.getName()).asString();
if (context.isNormalServer()) {
context.addStep(new OperationStepHandler() {
@Override
public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException {
ServiceRegistry registry = context.getServiceRegistry(false);
DriverRegistry driverRegistry = (DriverRegistry) registry.getRequiredService(ConnectorServices.JDBC_DRIVER_REGISTRY_SERVICE).getValue();
ServiceModuleLoader serviceModuleLoader = (ServiceModuleLoader) registry.getRequiredService(Services.JBOSS_SERVICE_MODULE_LOADER).getValue();
ModelNode result = new ModelNode();
InstalledDriver driver = driverRegistry.getInstalledDriver(name);
ModelNode driverNode = new ModelNode();
driverNode.get(DRIVER_NAME.getName()).set(driver.getDriverName());
if (driver.isFromDeployment()) {
driverNode.get(DEPLOYMENT_NAME.getName()).set(driver.getDriverName());
driverNode.get(DRIVER_MODULE_NAME.getName());
driverNode.get(MODULE_SLOT.getName());
driverNode.get(DRIVER_DATASOURCE_CLASS_NAME.getName());
driverNode.get(DRIVER_XA_DATASOURCE_CLASS_NAME.getName());
} else {
driverNode.get(DEPLOYMENT_NAME.getName());
driverNode.get(DRIVER_MODULE_NAME.getName()).set(driver.getModuleName().getName());
driverNode.get(MODULE_SLOT.getName()).set(driver.getModuleName() != null ? driver.getModuleName().getSlot() : "");
driverNode.get(DRIVER_DATASOURCE_CLASS_NAME.getName()).set(driver.getDataSourceClassName() != null ? driver.getDataSourceClassName() : "");
driverNode.get(DRIVER_XA_DATASOURCE_CLASS_NAME.getName()).set(driver.getXaDataSourceClassName() != null ? driver.getXaDataSourceClassName() : "");
}
driverNode.get(DATASOURCE_CLASS_INFO.getName()).set(dsClsInfoNode(serviceModuleLoader, driver.getModuleName(), driver.getDataSourceClassName(), driver.getXaDataSourceClassName()));
driverNode.get(DRIVER_CLASS_NAME.getName()).set(driver.getDriverClassName());
driverNode.get(DRIVER_MAJOR_VERSION.getName()).set(driver.getMajorVersion());
driverNode.get(DRIVER_MINOR_VERSION.getName()).set(driver.getMinorVersion());
driverNode.get(JDBC_COMPLIANT.getName()).set(driver.isJdbcCompliant());
result.add(driverNode);
context.getResult().set(result);
}
}, OperationContext.Stage.RUNTIME);
}
}
Aggregations