Search in sources :

Example 1 with DriverRegistry

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);
    }
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) InstalledDriver(org.jboss.as.connector.services.driver.InstalledDriver) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) DriverRegistry(org.jboss.as.connector.services.driver.registry.DriverRegistry) OperationFailedException(org.jboss.as.controller.OperationFailedException) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ServiceModuleLoader(org.jboss.as.server.moduleservice.ServiceModuleLoader) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

InstalledDriver (org.jboss.as.connector.services.driver.InstalledDriver)1 DriverRegistry (org.jboss.as.connector.services.driver.registry.DriverRegistry)1 OperationContext (org.jboss.as.controller.OperationContext)1 OperationFailedException (org.jboss.as.controller.OperationFailedException)1 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)1 ServiceModuleLoader (org.jboss.as.server.moduleservice.ServiceModuleLoader)1 ModelNode (org.jboss.dmr.ModelNode)1 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)1