Search in sources :

Example 1 with AdminObject

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);
    }
}
Also used : Connector(org.jboss.jca.common.api.metadata.spec.Connector) TransactionIntegration(org.jboss.jca.core.spi.transaction.TransactionIntegration) HashMap(java.util.HashMap) Activation(org.jboss.jca.common.api.metadata.resourceadapter.Activation) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) CachedConnectionManager(org.jboss.jca.core.api.connectionmanager.ccm.CachedConnectionManager) ActivationImpl(org.jboss.jca.common.metadata.resourceadapter.ActivationImpl) ResourceAdapter(org.jboss.jca.common.api.metadata.spec.ResourceAdapter) StartException(org.jboss.msc.service.StartException) AdminObject(org.jboss.jca.common.api.metadata.spec.AdminObject) ServiceTarget(org.jboss.msc.service.ServiceTarget) AdminObjectImpl(org.jboss.jca.common.metadata.resourceadapter.AdminObjectImpl) AS7MetadataRepository(org.jboss.as.connector.services.mdr.AS7MetadataRepository) StartException(org.jboss.msc.service.StartException) ManagementRepository(org.jboss.jca.core.api.management.ManagementRepository) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 AS7MetadataRepository (org.jboss.as.connector.services.mdr.AS7MetadataRepository)1 Activation (org.jboss.jca.common.api.metadata.resourceadapter.Activation)1 AdminObject (org.jboss.jca.common.api.metadata.spec.AdminObject)1 Connector (org.jboss.jca.common.api.metadata.spec.Connector)1 ResourceAdapter (org.jboss.jca.common.api.metadata.spec.ResourceAdapter)1 ActivationImpl (org.jboss.jca.common.metadata.resourceadapter.ActivationImpl)1 AdminObjectImpl (org.jboss.jca.common.metadata.resourceadapter.AdminObjectImpl)1 CachedConnectionManager (org.jboss.jca.core.api.connectionmanager.ccm.CachedConnectionManager)1 ManagementRepository (org.jboss.jca.core.api.management.ManagementRepository)1 TransactionIntegration (org.jboss.jca.core.spi.transaction.TransactionIntegration)1 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1 StartException (org.jboss.msc.service.StartException)1