Search in sources :

Example 1 with AdminObjectImpl

use of org.jboss.jca.common.metadata.resourceadapter.AdminObjectImpl 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.getCachedCapabilityServiceName(ConnectorServices.TRANSACTION_INTEGRATION_CAPABILITY_NAME), TransactionIntegration.class, activator.getTxIntegrationInjector()).addDependency(ConnectorServices.CONNECTOR_CONFIG_SERVICE, JcaSubsystemConfiguration.class, activator.getConfigInjector()).addDependency(ConnectorServices.CCM_SERVICE, CachedConnectionManager.class, activator.getCcmInjector());
        adminObjectServiceBuilder.requires(ConnectorServices.getCachedCapabilityServiceName(NamingService.CAPABILITY_NAME));
        adminObjectServiceBuilder.requires(ConnectorServices.getCachedCapabilityServiceName(ConnectorServices.LOCAL_TRANSACTION_PROVIDER_CAPABILITY));
        adminObjectServiceBuilder.requires(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) HashMap(java.util.HashMap) JcaSubsystemConfiguration(org.jboss.as.connector.subsystems.jca.JcaSubsystemConfiguration) ServiceTarget(org.jboss.msc.service.ServiceTarget) AdminObjectImpl(org.jboss.jca.common.metadata.resourceadapter.AdminObjectImpl) Activation(org.jboss.jca.common.api.metadata.resourceadapter.Activation) StartException(org.jboss.msc.service.StartException) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) ActivationImpl(org.jboss.jca.common.metadata.resourceadapter.ActivationImpl) ResourceAdapter(org.jboss.jca.common.api.metadata.spec.ResourceAdapter) ResourceAdapterRepository(org.jboss.jca.core.spi.rar.ResourceAdapterRepository) StartException(org.jboss.msc.service.StartException) AdminObject(org.jboss.jca.common.api.metadata.spec.AdminObject) HashMap(java.util.HashMap) Map(java.util.Map) ResourceAdapterDeploymentRegistry(org.jboss.as.connector.services.resourceadapters.deployment.registry.ResourceAdapterDeploymentRegistry)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 ResourceAdapterDeploymentRegistry (org.jboss.as.connector.services.resourceadapters.deployment.registry.ResourceAdapterDeploymentRegistry)1 JcaSubsystemConfiguration (org.jboss.as.connector.subsystems.jca.JcaSubsystemConfiguration)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 ResourceAdapterRepository (org.jboss.jca.core.spi.rar.ResourceAdapterRepository)1 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1 StartException (org.jboss.msc.service.StartException)1