Search in sources :

Example 61 with ServiceTarget

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

the class MailSessionAdd method installRuntimeServices.

static void installRuntimeServices(OperationContext context, PathAddress address, ModelNode fullModel) throws OperationFailedException {
    String name = address.getLastElement().getValue();
    final String jndiName = getJndiName(fullModel, context);
    final ServiceTarget serviceTarget = context.getServiceTarget();
    final MailSessionConfig config = from(context, fullModel);
    final MailSessionService service = new MailSessionService(config);
    final ServiceName serviceName = MAIL_SESSION_SERVICE_NAME.append(name);
    final ServiceBuilder<?> mailSessionBuilder = serviceTarget.addService(serviceName, service);
    addOutboundSocketDependency(service, mailSessionBuilder, config.getImapServer());
    addCredentialStoreReference(config.getImapServer(), context, fullModel, mailSessionBuilder, MailSubsystemModel.IMAP_SERVER_PATH.getKey(), MailSubsystemModel.IMAP_SERVER_PATH.getValue());
    addOutboundSocketDependency(service, mailSessionBuilder, config.getPop3Server());
    addCredentialStoreReference(config.getPop3Server(), context, fullModel, mailSessionBuilder, MailSubsystemModel.POP3_SERVER_PATH.getKey(), MailSubsystemModel.POP3_SERVER_PATH.getValue());
    addOutboundSocketDependency(service, mailSessionBuilder, config.getSmtpServer());
    addCredentialStoreReference(config.getSmtpServer(), context, fullModel, mailSessionBuilder, MailSubsystemModel.SMTP_SERVER_PATH.getKey(), MailSubsystemModel.SMTP_SERVER_PATH.getValue());
    for (CustomServerConfig server : config.getCustomServers()) {
        if (server.getOutgoingSocketBinding() != null) {
            addOutboundSocketDependency(service, mailSessionBuilder, server);
        }
        addCredentialStoreReference(server, context, fullModel, mailSessionBuilder, MailSubsystemModel.CUSTOM_SERVER_PATH.getKey(), server.getProtocol());
    }
    final ManagedReferenceFactory valueManagedReferenceFactory = new MailSessionManagedReferenceFactory(service);
    final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(jndiName);
    final BinderService binderService = new BinderService(bindInfo.getBindName());
    final ServiceBuilder<?> binderBuilder = serviceTarget.addService(bindInfo.getBinderServiceName(), binderService).addInjection(binderService.getManagedObjectInjector(), valueManagedReferenceFactory).addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()).addListener(new AbstractServiceListener<Object>() {

        public void transition(final ServiceController<? extends Object> controller, final ServiceController.Transition transition) {
            switch(transition) {
                case STARTING_to_UP:
                    {
                        MailLogger.ROOT_LOGGER.boundMailSession(jndiName);
                        break;
                    }
                case START_REQUESTED_to_DOWN:
                    {
                        MailLogger.ROOT_LOGGER.unboundMailSession(jndiName);
                        break;
                    }
                case REMOVING_to_REMOVED:
                    {
                        MailLogger.ROOT_LOGGER.removedMailSession(jndiName);
                        break;
                    }
            }
        }
    });
    mailSessionBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
    binderBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
}
Also used : ServiceTarget(org.jboss.msc.service.ServiceTarget) BinderService(org.jboss.as.naming.service.BinderService) ServiceName(org.jboss.msc.service.ServiceName) ServiceBasedNamingStore(org.jboss.as.naming.ServiceBasedNamingStore) ManagedReferenceFactory(org.jboss.as.naming.ManagedReferenceFactory) ServiceController(org.jboss.msc.service.ServiceController) ContextNames(org.jboss.as.naming.deployment.ContextNames)

Example 62 with ServiceTarget

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

the class PropertyAdd method performRuntime.

@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
    //modify the runtime if we're booting, otherwise set reload required and leave the runtime unchanged
    if (context.isBooting()) {
        final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
        final String propertyName = address.getElement(address.size() - 1).getValue();
        final PathElement confElem = address.getElement(address.size() - 2);
        final String configType = confElem.getKey();
        final String configName = confElem.getValue();
        final String propertyValue = operation.has(VALUE) ? Attributes.VALUE.resolveModelAttribute(context, operation).asString() : null;
        final PropertyService service = new PropertyService(propertyName, propertyValue);
        final ServiceTarget target = context.getServiceTarget();
        final ServiceName configServiceName = getConfigServiceName(configType, configName);
        if (context.getServiceRegistry(false).getService(configServiceName) == null) {
            throw WSLogger.ROOT_LOGGER.missingConfig(configName);
        }
        final ServiceName propertyServiceName = getPropertyServiceName(configServiceName, propertyName);
        final ServiceBuilder<?> propertyServiceBuilder = target.addService(propertyServiceName, service);
        ServiceController<?> controller = propertyServiceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
    } else {
        context.reloadRequired();
    }
}
Also used : PathElement(org.jboss.as.controller.PathElement) PackageUtils.getPropertyServiceName(org.jboss.as.webservices.dmr.PackageUtils.getPropertyServiceName) PackageUtils.getConfigServiceName(org.jboss.as.webservices.dmr.PackageUtils.getConfigServiceName) ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ServiceTarget(org.jboss.msc.service.ServiceTarget) PropertyService(org.jboss.as.webservices.service.PropertyService)

Example 63 with ServiceTarget

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

the class WSSubsystemAdd method performBoottime.

protected void performBoottime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    WSLogger.ROOT_LOGGER.activatingWebservicesExtension();
    ModuleClassLoaderProvider.register();
    final boolean appclient = context.getProcessType() == ProcessType.APPLICATION_CLIENT;
    context.addStep(new AbstractDeploymentChainStep() {

        protected void execute(DeploymentProcessorTarget processorTarget) {
            // add the DUP for dealing with WS deployments
            WSDeploymentActivator.activate(processorTarget, appclient);
        }
    }, OperationContext.Stage.RUNTIME);
    ServiceTarget serviceTarget = context.getServiceTarget();
    final boolean jmxAvailable = isJMXSubsystemAvailable(context);
    if (appclient && model.hasDefined(WSDL_HOST)) {
        ServerConfigImpl serverConfig = createServerConfig(model, true, context);
        ServerConfigService.install(serviceTarget, serverConfig, getServerConfigDependencies(context, appclient), jmxAvailable, false);
    }
    if (!appclient) {
        ServerConfigImpl serverConfig = createServerConfig(model, false, context);
        ServerConfigService.install(serviceTarget, serverConfig, getServerConfigDependencies(context, appclient), jmxAvailable, true);
    }
    XTSClientIntegrationService.install(serviceTarget);
}
Also used : DeploymentProcessorTarget(org.jboss.as.server.DeploymentProcessorTarget) ServiceTarget(org.jboss.msc.service.ServiceTarget) AbstractDeploymentChainStep(org.jboss.as.server.AbstractDeploymentChainStep) ServerConfigImpl(org.jboss.as.webservices.config.ServerConfigImpl)

Example 64 with ServiceTarget

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

the class ClientConfigAdd method performRuntime.

@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
    //modify the runtime if we're booting, otherwise set reload required and leave the runtime unchanged
    if (context.isBooting()) {
        final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
        final String name = address.getLastElement().getValue();
        //get the server config object from the ServerConfigService (service installed and not started yet, but the object is fine for our needs here)
        final ServerConfig serverConfig = ASHelper.getMSCService(WSServices.CONFIG_SERVICE, ServerConfig.class, context);
        if (serverConfig == null) {
            throw WSLogger.ROOT_LOGGER.serviceNotAvailable(WSServices.CONFIG_SERVICE.getCanonicalName());
        }
        final ServiceName serviceName = getClientConfigServiceName(name);
        final ConfigService clientConfigService = new ConfigService(serverConfig, name, true);
        final ServiceTarget target = context.getServiceTarget();
        final ServiceBuilder<?> clientServiceBuilder = target.addService(serviceName, clientConfigService);
        for (ServiceName sn : PackageUtils.getServiceNameDependencies(context, serviceName, address, Constants.PROPERTY)) {
            //get a new injector instance each time
            clientServiceBuilder.addDependency(sn, PropertyService.class, clientConfigService.getPropertiesInjector());
        }
        for (ServiceName sn : PackageUtils.getServiceNameDependencies(context, serviceName, address, Constants.PRE_HANDLER_CHAIN)) {
            //get a new injector instance each time
            clientServiceBuilder.addDependency(sn, UnifiedHandlerChainMetaData.class, clientConfigService.getPreHandlerChainsInjector());
        }
        for (ServiceName sn : PackageUtils.getServiceNameDependencies(context, serviceName, address, Constants.POST_HANDLER_CHAIN)) {
            //get a new injector instance each time
            clientServiceBuilder.addDependency(sn, UnifiedHandlerChainMetaData.class, clientConfigService.getPostHandlerChainsInjector());
        }
        clientServiceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
    } else {
        context.reloadRequired();
    }
}
Also used : ServerConfig(org.jboss.wsf.spi.management.ServerConfig) ConfigService(org.jboss.as.webservices.service.ConfigService) PackageUtils.getClientConfigServiceName(org.jboss.as.webservices.dmr.PackageUtils.getClientConfigServiceName) ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ServiceTarget(org.jboss.msc.service.ServiceTarget)

Example 65 with ServiceTarget

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

the class EndpointServiceDeploymentAspect method start.

@Override
public void start(final Deployment dep) {
    final ServiceTarget target = getOptionalAttachment(dep, ServiceTarget.class);
    final DeploymentUnit unit = getRequiredAttachment(dep, DeploymentUnit.class);
    for (final Endpoint ep : dep.getService().getEndpoints()) {
        EndpointService.install(target, ep, unit);
    }
}
Also used : Endpoint(org.jboss.wsf.spi.deployment.Endpoint) ServiceTarget(org.jboss.msc.service.ServiceTarget) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

ServiceTarget (org.jboss.msc.service.ServiceTarget)108 ServiceName (org.jboss.msc.service.ServiceName)57 PathAddress (org.jboss.as.controller.PathAddress)30 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)26 ModelNode (org.jboss.dmr.ModelNode)26 Module (org.jboss.modules.Module)18 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)15 OperationFailedException (org.jboss.as.controller.OperationFailedException)12 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)11 ContextNames (org.jboss.as.naming.deployment.ContextNames)11 Resource (org.jboss.as.controller.registry.Resource)10 BinderService (org.jboss.as.naming.service.BinderService)10 AbstractDeploymentChainStep (org.jboss.as.server.AbstractDeploymentChainStep)10 DeploymentProcessorTarget (org.jboss.as.server.DeploymentProcessorTarget)10 PathElement (org.jboss.as.controller.PathElement)9 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)9 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)9 ServiceController (org.jboss.msc.service.ServiceController)8 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5