use of org.jboss.jca.common.api.metadata.spec.AdminObject in project wildfly by wildfly.
the class DirectAdminObjectActivatorService method start.
@Override
public void start(StartContext context) throws StartException {
ROOT_LOGGER.debugf("started DirectConnectionFactoryActivatorService %s", context.getController().getName());
String aoClass = null;
try {
Connector cmd = mdr.getValue().getResourceAdapter(raId);
if (cmd.getVersion() == Connector.Version.V_10) {
throw ConnectorLogger.ROOT_LOGGER.adminObjectForJCA10(resourceAdapter, jndiName);
} else {
ResourceAdapter ra1516 = (ResourceAdapter) cmd.getResourceadapter();
if (ra1516.getAdminObjects() != null) {
for (AdminObject ao : ra1516.getAdminObjects()) {
if (ao.getAdminobjectClass().getValue().equals(className))
aoClass = ao.getAdminobjectClass().getValue();
}
}
}
if (aoClass == null || !aoClass.equals(className)) {
throw ConnectorLogger.ROOT_LOGGER.invalidAdminObject(aoClass, resourceAdapter, jndiName);
}
Map<String, String> raConfigProperties = new HashMap<String, String>();
Map<String, String> aoConfigProperties = new HashMap<String, String>();
if (properties != null) {
for (Map.Entry<String, String> prop : properties.entrySet()) {
String key = prop.getKey();
String value = prop.getValue();
if (key.startsWith("ra.")) {
raConfigProperties.put(key.substring(3), value);
} else if (key.startsWith("ao.")) {
aoConfigProperties.put(key.substring(3), value);
} else {
aoConfigProperties.put(key, value);
}
}
}
org.jboss.jca.common.api.metadata.resourceadapter.AdminObject ao = new AdminObjectImpl(aoConfigProperties, aoClass, jndiName, poolName(aoClass, className), Boolean.TRUE, Boolean.TRUE);
Activation activation = new ActivationImpl(null, null, TransactionSupportEnum.LocalTransaction, Collections.<ConnectionDefinition>emptyList(), Collections.singletonList(ao), null, Collections.<String>emptyList(), null, null);
String serviceName = jndiName;
serviceName = serviceName.replace(':', '_');
serviceName = serviceName.replace('/', '_');
ResourceAdapterActivatorService activator = new ResourceAdapterActivatorService(cmd, activation, module.getClassLoader(), serviceName);
activator.setCreateBinderService(false);
activator.setBindInfo(bindInfo);
ServiceTarget serviceTarget = context.getChildTarget();
ServiceBuilder adminObjectServiceBuilder = serviceTarget.addService(ConnectorServices.RESOURCE_ADAPTER_ACTIVATOR_SERVICE.append(serviceName), activator).addDependency(ConnectorServices.IRONJACAMAR_MDR, AS7MetadataRepository.class, activator.getMdrInjector()).addDependency(ConnectorServices.RA_REPOSITORY_SERVICE, ResourceAdapterRepository.class, activator.getRaRepositoryInjector()).addDependency(ConnectorServices.MANAGEMENT_REPOSITORY_SERVICE, ManagementRepository.class, activator.getManagementRepositoryInjector()).addDependency(ConnectorServices.RESOURCE_ADAPTER_REGISTRY_SERVICE, ResourceAdapterDeploymentRegistry.class, activator.getRegistryInjector()).addDependency(ConnectorServices.TRANSACTION_INTEGRATION_SERVICE, TransactionIntegration.class, activator.getTxIntegrationInjector()).addDependency(ConnectorServices.CONNECTOR_CONFIG_SERVICE, JcaSubsystemConfiguration.class, activator.getConfigInjector()).addDependency(ConnectorServices.CCM_SERVICE, CachedConnectionManager.class, activator.getCcmInjector()).addDependency(NamingService.SERVICE_NAME).addDependency(TxnServices.JBOSS_TXN_TRANSACTION_MANAGER).addDependency(ConnectorServices.BOOTSTRAP_CONTEXT_SERVICE.append("default"));
adminObjectServiceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
} catch (Exception e) {
throw new StartException(e);
}
}
Aggregations