Search in sources :

Example 71 with ServiceName

use of org.jboss.msc.service.ServiceName in project wildfly by wildfly.

the class ResourceAdapterDeploymentService method start.

@Override
public void start(StartContext context) throws StartException {
    final URL url = connectorXmlDescriptor == null ? null : connectorXmlDescriptor.getUrl();
    deploymentName = connectorXmlDescriptor == null ? null : connectorXmlDescriptor.getDeploymentName();
    connectorServicesRegistrationName = deploymentName;
    final File root = connectorXmlDescriptor == null ? null : connectorXmlDescriptor.getRoot();
    DEPLOYMENT_CONNECTOR_LOGGER.debugf("DEPLOYMENT name = %s", deploymentName);
    final boolean fromModule = duServiceName.getParent().equals(RaOperationUtil.RAR_MODULE);
    final WildFLyRaDeployer raDeployer = new WildFLyRaDeployer(context.getChildTarget(), url, deploymentName, root, classLoader, cmd, activation, deploymentServiceName, fromModule);
    raDeployer.setConfiguration(config.getValue());
    ClassLoader old = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
    try {
        try {
            WritableServiceBasedNamingStore.pushOwner(duServiceName);
            WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
            raDeployment = raDeployer.doDeploy();
            deploymentName = raDeployment.getDeploymentName();
        } finally {
            WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(old);
            WritableServiceBasedNamingStore.popOwner();
        }
        if (raDeployer.checkActivation(cmd, activation)) {
            DEPLOYMENT_CONNECTOR_LOGGER.debugf("Activating: %s", deploymentName);
            ServiceName raServiceName = ConnectorServices.getResourceAdapterServiceName(deploymentName);
            value = new ResourceAdapterDeployment(raDeployment, deploymentName, raServiceName);
            managementRepository.getValue().getConnectors().add(value.getDeployment().getConnector());
            registry.getValue().registerResourceAdapterDeployment(value);
            ServiceTarget serviceTarget = context.getChildTarget();
            serviceTarget.addService(raServiceName, new ResourceAdapterService(raServiceName, value.getDeployment().getResourceAdapter())).setInitialMode(Mode.ACTIVE).install();
            final ServiceName deployerServiceName = ConnectorServices.RESOURCE_ADAPTER_DEPLOYER_SERVICE_PREFIX.append(connectorXmlDescriptor.getDeploymentName());
            IronJacamarActivationResourceService ijResourceService = new IronJacamarActivationResourceService(registration, deploymentResource, false);
            serviceTarget.addService(deployerServiceName.append(ConnectorServices.IRONJACAMAR_RESOURCE), ijResourceService).addDependency(ConnectorServices.IRONJACAMAR_MDR, AS7MetadataRepository.class, ijResourceService.getMdrInjector()).addDependency(deployerServiceName, ResourceAdapterDeployment.class, ijResourceService.getResourceAdapterDeploymentInjector()).setInitialMode(Mode.PASSIVE).install();
        } else {
            DEPLOYMENT_CONNECTOR_LOGGER.debugf("Not activating: %s", deploymentName);
        }
    } catch (Throwable t) {
        cleanupStartAsync(context, deploymentName, t, duServiceName, classLoader);
    }
}
Also used : ResourceAdapterDeployment(org.jboss.as.connector.metadata.deployment.ResourceAdapterDeployment) ServiceName(org.jboss.msc.service.ServiceName) ServiceTarget(org.jboss.msc.service.ServiceTarget) ResourceAdapterService(org.jboss.as.connector.services.resourceadapters.ResourceAdapterService) IronJacamarActivationResourceService(org.jboss.as.connector.services.resourceadapters.IronJacamarActivationResourceService) AS7MetadataRepository(org.jboss.as.connector.services.mdr.AS7MetadataRepository) File(java.io.File) URL(java.net.URL)

Example 72 with ServiceName

use of org.jboss.msc.service.ServiceName in project wildfly by wildfly.

the class ResourceAdapterXmlDeploymentService method start.

/**
     * Start
     */
@Override
public void start(StartContext context) throws StartException {
    try {
        Connector cmd = mdr.getValue().getResourceAdapter(deployment);
        File root = mdr.getValue().getRoot(deployment);
        Activation localRaXml = getRaxml();
        cmd = (new Merger()).mergeConnectorWithCommonIronJacamar(localRaXml, cmd);
        String id = ((ModifiableResourceAdapter) raxml).getId();
        final ServiceName raServiceName;
        if (id == null || id.trim().isEmpty()) {
            raServiceName = ConnectorServices.getResourceAdapterServiceName(raName);
            this.connectorServicesRegistrationName = raName;
        } else {
            raServiceName = ConnectorServices.getResourceAdapterServiceName(id);
            this.connectorServicesRegistrationName = id;
        }
        final WildFlyRaXmlDeployer raDeployer = new WildFlyRaXmlDeployer(context.getChildTarget(), connectorXmlDescriptor.getUrl(), raName, root, module.getClassLoader(), cmd, localRaXml, deploymentServiceName);
        raDeployer.setConfiguration(config.getValue());
        WritableServiceBasedNamingStore.pushOwner(duServiceName);
        ClassLoader old = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
        try {
            WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(module.getClassLoader());
            raxmlDeployment = raDeployer.doDeploy();
        } finally {
            WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(old);
            WritableServiceBasedNamingStore.popOwner();
        }
        value = new ResourceAdapterDeployment(raxmlDeployment, raName, raServiceName);
        managementRepository.getValue().getConnectors().add(value.getDeployment().getConnector());
        registry.getValue().registerResourceAdapterDeployment(value);
        context.getChildTarget().addService(raServiceName, new ResourceAdapterService(raServiceName, value.getDeployment().getResourceAdapter())).addDependency(deploymentServiceName).setInitialMode(ServiceController.Mode.ACTIVE).install();
    } catch (Throwable t) {
        cleanupStartAsync(context, raName, deploymentServiceName, t);
    }
}
Also used : ResourceAdapterDeployment(org.jboss.as.connector.metadata.deployment.ResourceAdapterDeployment) Connector(org.jboss.jca.common.api.metadata.spec.Connector) Merger(org.jboss.jca.common.metadata.merge.Merger) ServiceName(org.jboss.msc.service.ServiceName) ResourceAdapterService(org.jboss.as.connector.services.resourceadapters.ResourceAdapterService) Activation(org.jboss.jca.common.api.metadata.resourceadapter.Activation) ModifiableResourceAdapter(org.jboss.as.connector.subsystems.resourceadapters.ModifiableResourceAdapter) File(java.io.File)

Example 73 with ServiceName

use of org.jboss.msc.service.ServiceName in project wildfly by wildfly.

the class AbstractDataSourceService method start.

public synchronized void start(StartContext startContext) throws StartException {
    try {
        final ServiceContainer container = startContext.getController().getServiceContainer();
        deploymentMD = getDeployer().deploy(container);
        if (deploymentMD.getCfs().length != 1) {
            throw ConnectorLogger.ROOT_LOGGER.cannotStartDs();
        }
        sqlDataSource = new WildFlyDataSource((javax.sql.DataSource) deploymentMD.getCfs()[0], jndiName.getAbsoluteJndiName());
        DS_DEPLOYER_LOGGER.debugf("Adding datasource: %s", deploymentMD.getCfJndiNames()[0]);
        CommonDeploymentService cdService = new CommonDeploymentService(deploymentMD);
        final ServiceName cdServiceName = CommonDeploymentService.getServiceName(jndiName);
        startContext.getController().getServiceContainer().addService(cdServiceName, cdService).addDependency(getServiceName(jndiName)).setInitialMode(ServiceController.Mode.ACTIVE).install();
    } catch (Throwable t) {
        throw ConnectorLogger.ROOT_LOGGER.deploymentError(t, dsName);
    }
}
Also used : ServiceContainer(org.jboss.msc.service.ServiceContainer) ServiceName(org.jboss.msc.service.ServiceName) XaDataSource(org.jboss.jca.common.api.metadata.ds.XaDataSource) DataSource(javax.sql.DataSource) CommonDataSource(org.jboss.jca.common.api.metadata.ds.CommonDataSource)

Example 74 with ServiceName

use of org.jboss.msc.service.ServiceName in project wildfly by wildfly.

the class ConnectionPropertyAdd method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode recoveryEnvModel) throws OperationFailedException {
    final String configPropertyValue = CONNECTION_PROPERTY_VALUE.resolveModelAttribute(context, recoveryEnvModel).asString();
    final ModelNode address = operation.require(OP_ADDR);
    PathAddress path = PathAddress.pathAddress(address);
    final String jndiName = path.getElement(path.size() - 2).getValue();
    final String configPropertyName = PathAddress.pathAddress(address).getLastElement().getValue();
    ServiceName serviceName = DataSourceConfigService.SERVICE_NAME_BASE.append(jndiName).append("connection-properties").append(configPropertyName);
    final ServiceRegistry registry = context.getServiceRegistry(true);
    final ServiceName dataSourceConfigServiceName = DataSourceConfigService.SERVICE_NAME_BASE.append(jndiName);
    final ServiceController<?> dataSourceConfigController = registry.getService(dataSourceConfigServiceName);
    if (dataSourceConfigController == null || !((DataSource) dataSourceConfigController.getValue()).isEnabled()) {
        final ServiceTarget serviceTarget = context.getServiceTarget();
        final ConnectionPropertiesService service = new ConnectionPropertiesService(configPropertyName, configPropertyValue);
        serviceTarget.addService(serviceName, service).setInitialMode(ServiceController.Mode.NEVER).install();
    } else {
        context.reloadRequired();
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ServiceTarget(org.jboss.msc.service.ServiceTarget) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ModelNode(org.jboss.dmr.ModelNode) DataSource(org.jboss.jca.common.api.metadata.ds.DataSource)

Example 75 with ServiceName

use of org.jboss.msc.service.ServiceName in project wildfly by wildfly.

the class ConnectionPropertyRemove method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    if (context.isResourceServiceRestartAllowed()) {
        final ModelNode address = operation.require(OP_ADDR);
        final PathAddress path = PathAddress.pathAddress(address);
        final String jndiName = path.getElement(path.size() - 2).getValue();
        final String configPropertyName = PathAddress.pathAddress(address).getLastElement().getValue();
        ServiceName configPropertyServiceName = DataSourceConfigService.SERVICE_NAME_BASE.append(jndiName).append("connection-properties").append(configPropertyName);
        context.removeService(configPropertyServiceName);
    } else {
        context.reloadRequired();
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

ServiceName (org.jboss.msc.service.ServiceName)323 ServiceTarget (org.jboss.msc.service.ServiceTarget)62 PathAddress (org.jboss.as.controller.PathAddress)57 ModelNode (org.jboss.dmr.ModelNode)53 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)47 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)45 OperationFailedException (org.jboss.as.controller.OperationFailedException)35 ServiceController (org.jboss.msc.service.ServiceController)26 Module (org.jboss.modules.Module)24 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)22 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)22 ContextNames (org.jboss.as.naming.deployment.ContextNames)21 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)20 BinderService (org.jboss.as.naming.service.BinderService)20 ArrayList (java.util.ArrayList)17 HashSet (java.util.HashSet)17 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)16 HashMap (java.util.HashMap)14 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)14 OperationContext (org.jboss.as.controller.OperationContext)12