private static final Logger log = Logger.getLogger("org.jboss.as.connector.deployers.jdbc");
/** {@inheritDoc} */
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
final ServicesAttachment servicesAttachment = deploymentUnit.getAttachment(Attachments.SERVICES);
if (module != null && servicesAttachment != null) {
final ModuleClassLoader classLoader = module.getClassLoader();
final List<String> driverNames = servicesAttachment.getServiceImplementations(Driver.class.getName());
for (String driverClassName : driverNames) {
try {
final Class<? extends Driver> driverClass = classLoader.loadClass(driverClassName).asSubclass(Driver.class);
final Constructor<? extends Driver> constructor = driverClass.getConstructor();
final Driver driver = constructor.newInstance();
final int majorVersion = driver.getMajorVersion();
final int minorVersion = driver.getMinorVersion();
final boolean compliant = driver.jdbcCompliant();
if (compliant) {
log.infof("Deploying JDBC-compliant driver %s (version %d.%d)", driverClass,
Integer.valueOf(majorVersion), Integer.valueOf(minorVersion));
} else {
log.infof("Deploying non-JDBC-compliant driver %s (version %d.%d)", driverClass,
Integer.valueOf(majorVersion), Integer.valueOf(minorVersion));
}
String driverName = deploymentUnit.getName();
InstalledDriver driverMetadata = new InstalledDriver(driverName, driverClass.getName(), null, majorVersion,
minorVersion, compliant);
DriverService driverService = new DriverService(driverMetadata, driver);
phaseContext
.getServiceTarget()