Search in sources :

Example 26 with ServiceName

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

the class AdminObjectAdd method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, final Resource resource) throws OperationFailedException {
    final ModelNode address = operation.require(OP_ADDR);
    PathAddress path = PathAddress.pathAddress(address);
    final String raName = context.getCurrentAddress().getParent().getLastElement().getValue();
    final String archiveOrModuleName;
    ModelNode raModel = context.readResourceFromRoot(path.subAddress(0, path.size() - 1)).getModel();
    final boolean statsEnabled = STATISTICS_ENABLED.resolveModelAttribute(context, raModel).asBoolean();
    if (!raModel.hasDefined(ARCHIVE.getName()) && !raModel.hasDefined(MODULE.getName())) {
        throw ConnectorLogger.ROOT_LOGGER.archiveOrModuleRequired();
    }
    if (raModel.get(ARCHIVE.getName()).isDefined()) {
        archiveOrModuleName = ARCHIVE.resolveModelAttribute(context, raModel).asString();
    } else {
        archiveOrModuleName = MODULE.resolveModelAttribute(context, raModel).asString();
    }
    final String poolName = PathAddress.pathAddress(address).getLastElement().getValue();
    final ModifiableAdminObject adminObjectValue;
    try {
        adminObjectValue = RaOperationUtil.buildAdminObjects(context, operation, poolName);
    } catch (ValidateException e) {
        throw new OperationFailedException(e, new ModelNode().set(ConnectorLogger.ROOT_LOGGER.failedToCreate("AdminObject", operation, e.getLocalizedMessage())));
    }
    ServiceName serviceName = ServiceName.of(ConnectorServices.RA_SERVICE, raName, poolName);
    ServiceName raServiceName = ServiceName.of(ConnectorServices.RA_SERVICE, raName);
    final ServiceTarget serviceTarget = context.getServiceTarget();
    final AdminObjectService service = new AdminObjectService(adminObjectValue);
    serviceTarget.addService(serviceName, service).setInitialMode(ServiceController.Mode.ACTIVE).addDependency(raServiceName, ModifiableResourceAdapter.class, service.getRaInjector()).install();
    ServiceRegistry registry = context.getServiceRegistry(true);
    final ServiceController<?> RaxmlController = registry.getService(ServiceName.of(ConnectorServices.RA_SERVICE, raName));
    Activation raxml = (Activation) RaxmlController.getValue();
    ServiceName deploymentServiceName = ConnectorServices.getDeploymentServiceName(archiveOrModuleName, raName);
    String bootStrapCtxName = DEFAULT_NAME;
    if (raxml.getBootstrapContext() != null && !raxml.getBootstrapContext().equals("undefined")) {
        bootStrapCtxName = raxml.getBootstrapContext();
    }
    AdminObjectStatisticsService adminObjectStatisticsService = new AdminObjectStatisticsService(context.getResourceRegistrationForUpdate(), poolName, statsEnabled);
    ServiceBuilder statsServiceBuilder = serviceTarget.addService(serviceName.append(ConnectorServices.STATISTICS_SUFFIX), adminObjectStatisticsService);
    statsServiceBuilder.addDependency(ConnectorServices.BOOTSTRAP_CONTEXT_SERVICE.append(bootStrapCtxName), adminObjectStatisticsService.getBootstrapContextInjector()).addDependency(deploymentServiceName, adminObjectStatisticsService.getResourceAdapterDeploymentInjector()).setInitialMode(ServiceController.Mode.PASSIVE).install();
    PathElement peAO = PathElement.pathElement(Constants.STATISTICS_NAME, "extended");
    final Resource aoResource = new IronJacamarResource.IronJacamarRuntimeResource();
    resource.registerChild(peAO, aoResource);
}
Also used : ValidateException(org.jboss.jca.common.api.validator.ValidateException) AdminObjectStatisticsService(org.jboss.as.connector.services.resourceadapters.statistics.AdminObjectStatisticsService) ServiceTarget(org.jboss.msc.service.ServiceTarget) OperationFailedException(org.jboss.as.controller.OperationFailedException) Resource(org.jboss.as.controller.registry.Resource) Activation(org.jboss.jca.common.api.metadata.resourceadapter.Activation) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) PathElement(org.jboss.as.controller.PathElement) ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ModelNode(org.jboss.dmr.ModelNode)

Example 27 with ServiceName

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

the class RaServicesFactory method createDeploymentService.

public static void createDeploymentService(final ManagementResourceRegistration registration, ConnectorXmlDescriptor connectorXmlDescriptor, Module module, ServiceTarget serviceTarget, final String deploymentUnitName, ServiceName deploymentUnitServiceName, String deployment, Activation raxml, final Resource deploymentResource, final ServiceRegistry serviceRegistry) {
    // Create the service
    ServiceName serviceName = ConnectorServices.getDeploymentServiceName(deploymentUnitName, raxml);
    ResourceAdapterXmlDeploymentService service = new ResourceAdapterXmlDeploymentService(connectorXmlDescriptor, raxml, module, deployment, serviceName, deploymentUnitServiceName);
    String bootStrapCtxName = DEFAULT_NAME;
    if (raxml.getBootstrapContext() != null && !raxml.getBootstrapContext().equals("undefined")) {
        bootStrapCtxName = raxml.getBootstrapContext();
    }
    ServiceBuilder<ResourceAdapterDeployment> builder = Services.addServerExecutorDependency(serviceTarget.addService(serviceName, service), service.getExecutorServiceInjector(), false).addDependency(ConnectorServices.IRONJACAMAR_MDR, AS7MetadataRepository.class, service.getMdrInjector()).addDependency(ConnectorServices.RA_REPOSITORY_SERVICE, ResourceAdapterRepository.class, service.getRaRepositoryInjector()).addDependency(ConnectorServices.MANAGEMENT_REPOSITORY_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(ConnectorServices.CCM_SERVICE, CachedConnectionManager.class, service.getCcmInjector()).addDependency(ConnectorServices.IDLE_REMOVER_SERVICE).addDependency(ConnectorServices.CONNECTION_VALIDATOR_SERVICE).addDependency(NamingService.SERVICE_NAME).addDependency(ConnectorServices.BOOTSTRAP_CONTEXT_SERVICE.append(bootStrapCtxName)).addDependency(ConnectorServices.RESOURCE_ADAPTER_DEPLOYER_SERVICE_PREFIX.append(connectorXmlDescriptor.getDeploymentName()));
    if (ActivationSecurityUtil.isLegacySecurityRequired(raxml)) {
        builder.addDependency(SubjectFactoryService.SERVICE_NAME, SubjectFactory.class, service.getSubjectFactoryInjector()).addDependency(SimpleSecurityManagerService.SERVICE_NAME, ServerSecurityManager.class, service.getServerSecurityManager());
    }
    String raName = deployment;
    if (raxml.getId() != null) {
        raName = raxml.getId();
    }
    ServiceName parentName = ServiceName.of(ConnectorServices.RA_SERVICE, raName);
    for (ServiceName subServiceName : serviceRegistry.getServiceNames()) {
        if (parentName.isParentOf(subServiceName) && !subServiceName.getSimpleName().equals(ConnectorServices.STATISTICS_SUFFIX)) {
            builder.addDependency(subServiceName);
        }
    }
    if (registration != null && deploymentResource != null) {
        if (registration.isAllowsOverride() && registration.getOverrideModel(deploymentUnitName) == null) {
            registration.registerOverrideModel(deploymentUnitName, new OverrideDescriptionProvider() {

                @Override
                public Map<String, ModelNode> getAttributeOverrideDescriptions(Locale locale) {
                    return Collections.emptyMap();
                }

                @Override
                public Map<String, ModelNode> getChildTypeOverrideDescriptions(Locale locale) {
                    return Collections.emptyMap();
                }
            });
        }
    }
    builder.setInitialMode(ServiceController.Mode.ACTIVE).install();
}
Also used : ResourceAdapterDeployment(org.jboss.as.connector.metadata.deployment.ResourceAdapterDeployment) Locale(java.util.Locale) TransactionIntegration(org.jboss.jca.core.spi.transaction.TransactionIntegration) SubjectFactory(org.jboss.security.SubjectFactory) ResourceAdapterXmlDeploymentService(org.jboss.as.connector.services.resourceadapters.deployment.ResourceAdapterXmlDeploymentService) OverrideDescriptionProvider(org.jboss.as.controller.descriptions.OverrideDescriptionProvider) AS7MetadataRepository(org.jboss.as.connector.services.mdr.AS7MetadataRepository) CachedConnectionManager(org.jboss.jca.core.api.connectionmanager.ccm.CachedConnectionManager) ManagementRepository(org.jboss.jca.core.api.management.ManagementRepository) ServiceName(org.jboss.msc.service.ServiceName) Map(java.util.Map)

Example 28 with ServiceName

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

the class ResourceAdaptersSubsystemAdd method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    final Resource subsystemResource = context.readResourceFromRoot(PathAddress.pathAddress(ResourceAdaptersExtension.SUBSYSTEM_PATH));
    ResourceAdaptersSubsystemService service = new ResourceAdaptersSubsystemService();
    CopyOnWriteArrayListMultiMap<String, ServiceName> value = service.getValue();
    for (Resource.ResourceEntry re : subsystemResource.getChildren(RESOURCEADAPTER_NAME)) {
        value.putIfAbsent(re.getModel().get(ARCHIVE.getName()).asString(), ConnectorServices.RA_SERVICE.append(re.getName()));
    }
    final ServiceBuilder<?> builder = context.getServiceTarget().addService(ConnectorServices.RESOURCEADAPTERS_SUBSYSTEM_SERVICE, service);
    builder.setInitialMode(ServiceController.Mode.ACTIVE).install();
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) Resource(org.jboss.as.controller.registry.Resource)

Example 29 with ServiceName

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

the class ConnectorServices method getDeploymentServiceName.

// resource-adapter DMR resource
public static synchronized ServiceName getDeploymentServiceName(final String raName, final Activation raxml) {
    if (raName == null)
        throw ConnectorLogger.ROOT_LOGGER.undefinedVar("RaName");
    ServiceName serviceName = null;
    ModifiableResourceAdapter ra = (ModifiableResourceAdapter) raxml;
    if (ra != null && ra.getId() != null) {
        serviceName = getDeploymentServiceName(raName, ra.getId());
    } else {
        serviceName = getDeploymentServiceName(raName, (String) null);
    }
    ROOT_LOGGER.tracef("ConnectorServices: getDeploymentServiceName(%s,%s) -> %s", raName, raxml, serviceName);
    return serviceName;
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ModifiableResourceAdapter(org.jboss.as.connector.subsystems.resourceadapters.ModifiableResourceAdapter)

Example 30 with ServiceName

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

the class EEJndiViewExtension method execute.

public void execute(final JndiViewExtensionContext context) throws OperationFailedException {
    final ModelNode applicationsNode = context.getResult().get("applications");
    final ServiceRegistry serviceRegistry = context.getOperationContext().getServiceRegistry(false);
    final Set<Resource.ResourceEntry> deploymentResource = context.getOperationContext().readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false).getChildren(DEPLOYMENT);
    for (final Resource.ResourceEntry entry : deploymentResource) {
        final ServiceController<?> deploymentUnitServiceController = serviceRegistry.getService(ServiceName.JBOSS.append("deployment", "unit", entry.getName()));
        if (deploymentUnitServiceController != null) {
            final ModelNode deploymentNode = applicationsNode.get(entry.getName());
            final DeploymentUnit deploymentUnit = DeploymentUnit.class.cast(deploymentUnitServiceController.getValue());
            final String appName = cleanName(deploymentUnit.getName());
            final ServiceName appContextName = ContextNames.contextServiceNameOfApplication(appName);
            final ServiceController<?> appContextController = serviceRegistry.getService(appContextName);
            if (appContextController != null) {
                final NamingStore appStore = NamingStore.class.cast(appContextController.getValue());
                try {
                    context.addEntries(deploymentNode.get("java:app"), new NamingContext(appStore, null));
                } catch (NamingException e) {
                    throw new OperationFailedException(e, new ModelNode().set(EeLogger.ROOT_LOGGER.failedToRead("java:app", appName)));
                }
            }
            if (DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
                final List<ResourceRoot> roots = deploymentUnit.getAttachmentList(org.jboss.as.server.deployment.Attachments.RESOURCE_ROOTS);
                if (roots != null)
                    for (ResourceRoot root : roots) {
                        if (SubDeploymentMarker.isSubDeployment(root)) {
                            final ResourceRoot parentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
                            final String relativePath = root.getRoot().getPathNameRelativeTo(parentRoot.getRoot());
                            final ServiceName subDeploymentServiceName = Services.deploymentUnitName(deploymentUnit.getName(), relativePath);
                            final ServiceController<?> subDeploymentController = serviceRegistry.getService(subDeploymentServiceName);
                            if (subDeploymentController != null) {
                                final DeploymentUnit subDeploymentUnit = DeploymentUnit.class.cast(subDeploymentController.getValue());
                                handleModule(context, subDeploymentUnit, deploymentNode.get("modules"), serviceRegistry);
                            }
                        }
                    }
            } else {
                handleModule(context, deploymentUnit, deploymentNode.get("modules"), serviceRegistry);
            }
        }
    }
}
Also used : NamingStore(org.jboss.as.naming.NamingStore) Resource(org.jboss.as.controller.registry.Resource) OperationFailedException(org.jboss.as.controller.OperationFailedException) NamingContext(org.jboss.as.naming.NamingContext) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) ServiceName(org.jboss.msc.service.ServiceName) NamingException(javax.naming.NamingException) ServiceController(org.jboss.msc.service.ServiceController) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ModelNode(org.jboss.dmr.ModelNode) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

ServiceName (org.jboss.msc.service.ServiceName)289 ServiceTarget (org.jboss.msc.service.ServiceTarget)56 PathAddress (org.jboss.as.controller.PathAddress)54 ModelNode (org.jboss.dmr.ModelNode)48 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)44 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)40 OperationFailedException (org.jboss.as.controller.OperationFailedException)33 Module (org.jboss.modules.Module)23 ServiceController (org.jboss.msc.service.ServiceController)23 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)22 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)22 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)19 BinderService (org.jboss.as.naming.service.BinderService)18 HashSet (java.util.HashSet)17 ContextNames (org.jboss.as.naming.deployment.ContextNames)17 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)15 HashMap (java.util.HashMap)14 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)14 ArrayList (java.util.ArrayList)13 OperationContext (org.jboss.as.controller.OperationContext)12