public CommonDeployment deploy(ServiceContainer serviceContainer) throws DeployException {
      try {
        if (serviceContainer == null) {
          throw new DeployException("ServiceContainer not provided");
        }
        this.serviceContainer = serviceContainer;

        HashMap<String, org.jboss.jca.common.api.metadata.ds.Driver> drivers =
            new HashMap<String, org.jboss.jca.common.api.metadata.ds.Driver>(1);

        DataSources dataSources = null;
        if (dataSourceConfig != null) {
          InstalledDriver installedDriver =
              driverRegistry.getValue().getInstalledDriver(dataSourceConfig.getDriver());
          org.jboss.jca.common.api.metadata.ds.Driver driver =
              new DriverImpl(
                  installedDriver.getDriverName(),
                  installedDriver.getMajorVersion(),
                  installedDriver.getMinorVersion(),
                  installedDriver.getModuleName().getName(),
                  installedDriver.getDriverClassName(),
                  installedDriver.getXaDataSourceClassName());
          drivers.put(driver.getName(), driver);
          dataSources = new DatasourcesImpl(Arrays.asList(dataSourceConfig), null, drivers);
        } else if (xaDataSourceConfig != null) {
          InstalledDriver installedDriver =
              driverRegistry.getValue().getInstalledDriver(xaDataSourceConfig.getDriver());
          org.jboss.jca.common.api.metadata.ds.Driver driver =
              new DriverImpl(
                  installedDriver.getDriverName(),
                  installedDriver.getMajorVersion(),
                  installedDriver.getMinorVersion(),
                  installedDriver.getModuleName().getName(),
                  installedDriver.getDriverClassName(),
                  installedDriver.getXaDataSourceClassName());
          drivers.put(driver.getName(), driver);
          dataSources = new DatasourcesImpl(null, Arrays.asList(xaDataSourceConfig), drivers);
        }

        CommonDeployment c =
            createObjectsAndInjectValue(
                new URL("file://DataSourceDeployment"),
                jndiName,
                "uniqueJdbcLocalId",
                "uniqueJdbcXAId",
                dataSources,
                AbstractDataSourceService.class.getClassLoader());
        return c;
      } catch (MalformedURLException e) {
        throw new DeployException("unable to deploy", e);
      } catch (ValidateException e) {
        throw new DeployException("unable to validate and deploy ds or xads", e);
      }
    }
    @Override
    protected ManagedConnectionFactory createMcf(XaDataSource arg0, String arg1, ClassLoader arg2)
        throws NotFoundException, DeployException {
      final WildFlyXaMCF xaManagedConnectionFactory = new WildFlyXaMCF();

      if (xaDataSourceConfig.getUrlDelimiter() != null) {
        xaManagedConnectionFactory.setURLDelimiter(xaDataSourceConfig.getUrlDelimiter());
      }
      if (xaDataSourceConfig.getXaDataSourceClass() != null) {
        xaManagedConnectionFactory.setXADataSourceClass(xaDataSourceConfig.getXaDataSourceClass());
      }
      if (xaDataSourceConfig.getXaDataSourceProperty() != null) {
        xaManagedConnectionFactory.setXaProps(xaDataSourceConfig.getXaDataSourceProperty());
      }
      if (xaDataSourceConfig.getUrlSelectorStrategyClassName() != null) {
        xaManagedConnectionFactory.setUrlSelectorStrategyClassName(
            xaDataSourceConfig.getUrlSelectorStrategyClassName());
      }
      if (xaDataSourceConfig.getXaPool() != null
          && xaDataSourceConfig.getXaPool().isSameRmOverride() != null) {
        xaManagedConnectionFactory.setIsSameRMOverrideValue(
            xaDataSourceConfig.getXaPool().isSameRmOverride());
      }

      if (xaDataSourceConfig.getNewConnectionSql() != null) {
        xaManagedConnectionFactory.setNewConnectionSQL(xaDataSourceConfig.getNewConnectionSql());
      }

      if (xaDataSourceConfig.getUrlSelectorStrategyClassName() != null) {
        xaManagedConnectionFactory.setUrlSelectorStrategyClassName(
            xaDataSourceConfig.getUrlSelectorStrategyClassName());
      }

      setMcfProperties(
          xaManagedConnectionFactory, xaDataSourceConfig, xaDataSourceConfig.getStatement());
      return xaManagedConnectionFactory;
    }
    public CommonDeployment deploy(ServiceContainer serviceContainer) throws DeployException {
      try {
        if (serviceContainer == null) {
          throw new DeployException(ConnectorLogger.ROOT_LOGGER.nullVar("ServiceContainer"));
        }

        HashMap<String, org.jboss.jca.common.api.metadata.ds.Driver> drivers =
            new HashMap<String, org.jboss.jca.common.api.metadata.ds.Driver>(1);

        DataSources dataSources = null;
        if (dataSourceConfig != null) {
          String driverName = dataSourceConfig.getDriver();
          InstalledDriver installedDriver =
              driverRegistry.getValue().getInstalledDriver(driverName, profile);
          if (installedDriver != null) {
            String moduleName =
                installedDriver.getModuleName() != null
                    ? installedDriver.getModuleName().getName()
                    : null;
            org.jboss.jca.common.api.metadata.ds.Driver driver =
                new DriverImpl(
                    installedDriver.getDriverName(),
                    installedDriver.getMajorVersion(),
                    installedDriver.getMinorVersion(),
                    moduleName,
                    installedDriver.getDriverClassName(),
                    installedDriver.getDataSourceClassName(),
                    installedDriver.getXaDataSourceClassName());
            drivers.put(driverName, driver);
          }
          dataSources = new DatasourcesImpl(Arrays.asList(dataSourceConfig), null, drivers);
        } else if (xaDataSourceConfig != null) {
          String driverName = xaDataSourceConfig.getDriver();
          InstalledDriver installedDriver =
              driverRegistry.getValue().getInstalledDriver(driverName, profile);
          if (installedDriver != null) {
            String moduleName =
                installedDriver.getModuleName() != null
                    ? installedDriver.getModuleName().getName()
                    : null;
            org.jboss.jca.common.api.metadata.ds.Driver driver =
                new DriverImpl(
                    installedDriver.getDriverName(),
                    installedDriver.getMajorVersion(),
                    installedDriver.getMinorVersion(),
                    moduleName,
                    installedDriver.getDriverClassName(),
                    installedDriver.getDataSourceClassName(),
                    installedDriver.getXaDataSourceClassName());
            drivers.put(driverName, driver);
          }
          dataSources = new DatasourcesImpl(null, Arrays.asList(xaDataSourceConfig), drivers);
        }

        CommonDeployment c =
            createObjectsAndInjectValue(
                new URL("file://DataSourceDeployment"),
                dsName,
                "uniqueJdbcLocalId",
                "uniqueJdbcXAId",
                dataSources,
                AbstractDataSourceService.class.getClassLoader());
        return c;
      } catch (MalformedURLException e) {
        throw ConnectorLogger.ROOT_LOGGER.cannotDeploy(e);
      } catch (ValidateException e) {
        throw ConnectorLogger.ROOT_LOGGER.cannotDeployAndValidate(e);
      }
    }
  private void writeXADsElement(XMLExtendedStreamWriter streamWriter, XaDataSource ds)
      throws XMLStreamException {
    streamWriter.writeStartElement(DataSources.Tag.DATASOURCE.getLocalName());
    streamWriter.writeAttribute(XaDataSource.Attribute.JNDINAME.getLocalName(), ds.getJndiName());
    if (ds.isEnabled() != null)
      streamWriter.writeAttribute(
          XaDataSource.Attribute.ENABLED.getLocalName(), ds.isEnabled().toString());
    if (ds.isUseJavaContext() != null)
      streamWriter.writeAttribute(
          XaDataSource.Attribute.USEJAVACONTEXT.getLocalName(), ds.isUseJavaContext().toString());
    streamWriter.writeAttribute(XaDataSource.Attribute.POOL_NAME.getLocalName(), ds.getPoolName());

    if (ds.getXaDataSourceProperty() != null) {
      for (Entry<String, String> entry : ds.getXaDataSourceProperty().entrySet()) {
        writeXaProperty(streamWriter, entry);
      }
    }

    if (ds.getXaDataSourceClass() != null) {
      streamWriter.writeStartElement(XaDataSource.Tag.XADATASOURCECLASS.getLocalName());
      streamWriter.writeCharacters(ds.getXaDataSourceClass());
      streamWriter.writeEndElement();
    }

    if (ds.getModule() != null) {
      streamWriter.writeStartElement(XaDataSource.Tag.MODULE.getLocalName());
      streamWriter.writeCharacters(ds.getModule());
      streamWriter.writeEndElement();
    }

    if (ds.getUrlDelimiter() != null) {
      streamWriter.writeStartElement(XaDataSource.Tag.URLDELIMITER.getLocalName());
      streamWriter.writeCharacters(ds.getUrlDelimiter());
      streamWriter.writeEndElement();
    }

    if (ds.getUrlSelectorStrategyClassName() != null) {
      streamWriter.writeStartElement(XaDataSource.Tag.URLSELECTORSTRATEGYCLASSNAME.getLocalName());
      streamWriter.writeCharacters(ds.getUrlSelectorStrategyClassName());
      streamWriter.writeEndElement();
    }

    if (ds.getNewConnectionSql() != null) {
      streamWriter.writeStartElement(XaDataSource.Tag.NEWCONNECTIONSQL.getLocalName());
      streamWriter.writeCharacters(ds.getNewConnectionSql());
      streamWriter.writeEndElement();
    }

    if (ds.getTransactionIsolation() != null) {
      streamWriter.writeStartElement(XaDataSource.Tag.TRANSACTIONISOLATION.getLocalName());
      streamWriter.writeCharacters(ds.getTransactionIsolation().name());
      streamWriter.writeEndElement();
    }

    streamWriter.writeStartElement(XaDataSource.Tag.XA_POOL.getLocalName());
    writeXaPool(streamWriter, ds.getXaPool());
    streamWriter.writeEndElement();

    streamWriter.writeStartElement(XaDataSource.Tag.SECURITY.getLocalName());
    writeSecurity(streamWriter, ds.getSecurity());
    streamWriter.writeEndElement();

    streamWriter.writeStartElement(XaDataSource.Tag.VALIDATION.getLocalName());
    writeValidation(streamWriter, ds.getValidation());
    streamWriter.writeEndElement();

    streamWriter.writeStartElement(XaDataSource.Tag.TIMEOUT.getLocalName());
    writeTimeOut(streamWriter, ds.getTimeOut());
    streamWriter.writeEndElement();

    streamWriter.writeStartElement(XaDataSource.Tag.STATEMENT.getLocalName());
    writeStatement(streamWriter, ds.getStatement());
    streamWriter.writeEndElement();

    streamWriter.writeEndElement();
  }