* @throws DeploymentUnitProcessingException
*
*/
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ConnectorXmlDescriptor connectorXmlDescriptor = deploymentUnit
.getAttachment(ConnectorXmlDescriptor.ATTACHMENT_KEY);
if (connectorXmlDescriptor == null) {
return; // Skip non ra deployments
}
ResourceAdapters raxmls = null;
// getResourceAdaptersAttachment(deploymentUnit);
final ServiceController<?> raService = phaseContext.getServiceRegistry().getService(
ConnectorServices.RESOURCEADAPTERS_SERVICE);
if (raService != null)
raxmls = ((ResourceAdapters) raService.getValue());
if (raxmls == null)
return;
log.tracef("processing Raxml");
Module module = deploymentUnit.getAttachment(Attachments.MODULE);
if (module == null)
throw new DeploymentUnitProcessingException("Failed to get module attachment for " + deploymentUnit);
try {
final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
for (org.jboss.jca.common.api.metadata.resourceadapter.ResourceAdapter raxml : raxmls.getResourceAdapters()) {
if (deploymentUnit.getName().equals(raxml.getArchive())) {
final String deployment;
if (deploymentUnit.getName().lastIndexOf('.') == -1) {
deployment = deploymentUnit.getName();
} else {
deployment = deploymentUnit.getName().substring(0, deploymentUnit.getName().lastIndexOf('.'));
}
ResourceAdapterXmlDeploymentService service = new ResourceAdapterXmlDeploymentService(connectorXmlDescriptor,
raxml, module, deployment);
// Create the service
serviceTarget
.addService(
ConnectorServices.RESOURCE_ADAPTER_XML_SERVICE_PREFIX.append(connectorXmlDescriptor
.getDeploymentName()), service)
.addDependency(ConnectorServices.IRONJACAMAR_MDR, MetadataRepository.class, service.getMdrInjector())
.addDependency(ConnectorServices.RA_REPOSISTORY_SERVICE, ResourceAdapterRepository.class,
service.getRaRepositoryInjector())
.addDependency(ConnectorServices.MANAGEMENT_REPOSISTORY_SERVICE, ManagementRepository.class,
service.getManagementRepositoryInjector())
.addDependency(ConnectorServices.RESOURCE_ADAPTER_REGISTRY_SERVICE,
ResourceAdapterDeploymentRegistry.class, service.getRegistryInjector())
.addDependency(ConnectorServices.TRANSACTION_INTEGRATION_SERVICE, TransactionIntegration.class,
service.getTxIntegrationInjector())
.addDependency(ConnectorServices.CONNECTOR_CONFIG_SERVICE, JcaSubsystemConfiguration.class,
service.getConfigInjector())
.addDependency(SubjectFactoryService.SERVICE_NAME, SubjectFactory.class,
service.getSubjectFactoryInjector())
.addDependency(ConnectorServices.CCM_SERVICE, CachedConnectionManager.class, service.getCcmInjector())
.addDependency(NamingService.SERVICE_NAME)
.addDependencies(
ConnectorServices.RESOURCE_ADAPTER_SERVICE_PREFIX.append(connectorXmlDescriptor
.getDeploymentName())).setInitialMode(Mode.ACTIVE).install();
}
}
} catch (Throwable t) {
throw new DeploymentUnitProcessingException(t);