Package org.jboss.msc.service

Examples of org.jboss.msc.service.BatchBuilder


        super(Namespace.CURRENT.getUriString());
    }

    @Override
    protected <P> void applyUpdate(final UpdateContext updateContext, final UpdateResultHandler<? super Void, P> resultHandler, final P param) {
        final BatchBuilder batchBuilder = updateContext.getBatchBuilder();

        MBeanServerService.addService(batchBuilder);
        ManagedServiceContainerService.addService(batchBuilder);
    }
View Full Code Here


        this.registryBinding = registryBinding;
    }

    /** {@inheritDoc} */
    protected <P> void applyUpdate(UpdateContext updateContext, UpdateResultHandler<? super Void, P> resultHandler, P param) {
        final BatchBuilder builder = updateContext.getBatchBuilder();
        JMXConnectorService.addService(builder, serverBinding, registryBinding)
            .addListener(new UpdateResultHandler.ServiceStartListener<P>(resultHandler, param));
    }
View Full Code Here

            // so we do it directly
            transition(false);
            return;
        }

        BatchBuilder batchBuilder = serviceContainer.batchBuilder();
        UpdateContext updateContext = new SimpleUpdateContext(serviceContainer, batchBuilder);
        for (ServerModelUpdateTuple<?,?> update : updates) {

            logger.debugf("Applying update %s", update.getUpdate().toString());

            if (status != Status.ACTIVE) {
                // Don't execute this update; just notify any handler and
                // count it as updated for overall completion tracking
                update.handleCancellation();
                continue;
            }

            boolean appliedToModel = false;
            ServerModelUpdateTuple<Object, ?> rollbackTuple = null;
            try {
                rollbackTuple = update.getRollbackTuple(serverModel);

                serverModel.update(update.getUpdate());
                appliedToModel = true;
                if (allowRuntimeUpdates) {
                    update.applyUpdate(updateContext);
                }
                else {
                    // We won't get a callback from a result handler, so
                    // directly record the completion for overall completion tracking
                    updateComplete();
                }

                // As the last thing in this try block, add the rollbackTuple
                // to the rollback list. Do it last because if this update
                // directly fails, we roll it back in catch block below.
                // The 'rollbacks' list is for updates that succeeeded.
                if (allowOverallRollback && rollbackTuple != null) {
                    // Add this latest update's rollback to the list
                    rollbacks.add(0, rollbackTuple);
                }
            }
            catch (Exception e) {
                update.handleFailure(e);

                if (rollbackTuple != null) {
                    if (appliedToModel) {
                        try {
                            if (allowRuntimeUpdates) {
                                // FIXME this is likely incorrect given we are now
                                // using a batch!!!
                                rollbackTuple.applyUpdate(updateContext);
                            }
                            serverModel.update(rollbackTuple.getUpdate());
                        } catch (UpdateFailedException e1) {
                            rollbackTuple.handleFailure(e1);
                        }
                    }
                }
                // else there was no compensating update or creating the
                // rollbackTuple failed at the beginning of 'try'
                // and there is nothing else needing to be done here
            }
        }

        if (status == Status.ACTIVE) {
            try {
                batchBuilder.install();
            } catch (ServiceRegistryException e) {
                handleRollback();
            }
        }
View Full Code Here

            // so we do it directly
            transition(false);
            return;
        }

        BatchBuilder batchBuilder = serviceContainer.batchBuilder();
        UpdateContext updateContext = new SimpleUpdateContext(serviceContainer, batchBuilder);
        boolean failed = false;
        try {
            for (ServerModelUpdateTuple<?, ?> update : rollbacks) {

                if (failed) {
                    update.handleCancellation();
                }
                else {
                    try {
                        serverModel.update(update.getUpdate());
                    }
                    catch (Exception e) {
                        update.handleFailure(e);
                    }
                    finally {
                        try {
                            if (allowRuntimeUpdates) {
                                update.applyUpdate(updateContext);
                            }
                            else {
                                rollbackComplete();
                            }
                        }
                        catch (Exception e) {
                            update.handleFailure(e);
                        }
                    }
                }
            }

            batchBuilder.install();

            if (logger.isDebugEnabled()) {
                logger.debugf("%s rollbacks applied", rollbacks.size());
            }
        }
View Full Code Here

        this.socketBinding = socketBinding;
    }

    /** {@inheritDoc} */
    protected <P> void applyUpdate(UpdateContext updateContext, UpdateResultHandler<? super Void, P> resultHandler, P param) {
        final BatchBuilder batchBuilder = updateContext.getBatchBuilder();
        final OptionMap.Builder builder = OptionMap.builder();

        // First, apply options to option map.
        if (saslElement != null) saslElement.applyTo(builder);
        // TODO apply connector properties to option map

        // Create the service.
        final ConnectorService connectorService = new ConnectorService();
        connectorService.setOptionMap(builder.getMap());

        // The update handler
        final UpdateResultHandler.ServiceStartListener<P> listener = new UpdateResultHandler.ServiceStartListener<P>(resultHandler, param);

        // Register the service with the container and inject dependencies.
        final ServiceName connectorName = ConnectorElement.connectorName(name);
        final BatchServiceBuilder<ChannelListener<ConnectedStreamChannel<InetSocketAddress>>> serviceBuilder = batchBuilder.addService(connectorName, connectorService);
        serviceBuilder.addDependency(connectorName.append("auth-provider"), ServerAuthenticationProvider.class, connectorService.getAuthenticationProviderInjector());
        serviceBuilder.addDependency(RemotingSubsystemElement.JBOSS_REMOTING_ENDPOINT, Endpoint.class, connectorService.getEndpointInjector());
        serviceBuilder.addListener(listener);
        serviceBuilder.setInitialMode(ServiceController.Mode.ACTIVE);

        // TODO create XNIO connector service from socket-binding, with dependency on connectorName
        try {
            batchBuilder.install();
        } catch (ServiceRegistryException e) {
            resultHandler.handleFailure(e, param);
        }
    }
View Full Code Here

        final ClassLoader classLoader = module.getClassLoader();
        final Value<ClassLoader> classLoaderValue = Values.immediateValue(classLoader);

        final JBossServiceXmlDescriptor.ControllerMode controllerMode = serviceXmlDescriptor.getControllerMode();
        final List<JBossServiceConfig> serviceConfigs = serviceXmlDescriptor.getServiceConfigs();
        final BatchBuilder batchBuilder = context.getBatchBuilder();
        for(final JBossServiceConfig serviceConfig : serviceConfigs) {
            addService(batchBuilder, serviceConfig, classLoaderValue);
        }
    }
View Full Code Here

        super(SarExtension.NAMESPACE);
    }

    @Override
    protected <P> void applyUpdate(final UpdateContext updateContext, final UpdateResultHandler<? super Void, P> resultHandler, final P param) {
        final BatchBuilder batchBuilder = updateContext.getBatchBuilder();
        batchBuilder.addServiceValueIfNotExist(DeploymentChainProviderService.SERVICE_NAME, new DeploymentChainProviderService());

        final Value<DeploymentChain> deploymentChainValue = Values.immediateValue((DeploymentChain)new DeploymentChainImpl(SAR_DEPLOYMENT_CHAIN_SERVICE_NAME.toString()))   ;
        final DeploymentChainService deploymentChainService = new DeploymentChainService(deploymentChainValue);
        batchBuilder.addService(SAR_DEPLOYMENT_CHAIN_SERVICE_NAME, deploymentChainService)
            .addDependency(DeploymentChainProviderService.SERVICE_NAME, DeploymentChainProvider.class, new DeploymentChainProviderInjector<DeploymentChain>(deploymentChainValue, new SarDeploymentChainSelector(), SAR_DEPLOYMENT_CHAIN_PRIORITY));

        addDeploymentProcessor(batchBuilder, new ManifestAttachmentProcessor(), ManifestAttachmentProcessor.PRIORITY);
        addDeploymentProcessor(batchBuilder, new ServiceActivatorDependencyProcessor(), ServiceActivatorDependencyProcessor.PRIORITY);
        addDeploymentProcessor(batchBuilder, new ModuleDependencyProcessor(), ModuleDependencyProcessor.PRIORITY);
View Full Code Here

        }

        private static final long serialVersionUID = 2522252040771977214L;

        public void activate(final ServiceActivatorContext serviceActivatorContext) {
            final BatchBuilder batchBuilder = serviceActivatorContext.getBatchBuilder();

            final ServerManagerConnectionService smConnection = new ServerManagerConnectionService();
            batchBuilder.addService(ServerManagerConnectionService.SERVICE_NAME, smConnection)
                .addInjection(smConnection.getSmAddressInjector(), managementSocket)
                .setInitialMode(ServiceController.Mode.ACTIVE);

            final ServerManagerClient client = new ServerManagerClient();
            batchBuilder.addService(ServerManagerClient.SERVICE_NAME, client)
                .addDependency(ServerManagerConnectionService.SERVICE_NAME, Connection.class, client.getSmConnectionInjector())
                .addDependency(ServerController.SERVICE_NAME, ServerController.class, client.getServerControllerInjector())
                .setInitialMode(ServiceController.Mode.ACTIVE);
        }
View Full Code Here

        this.append = append;
    }

    protected <P> void applyUpdate(final UpdateContext updateContext, final UpdateResultHandler<? super Void, P> handler, final P param) {
        try {
            final BatchBuilder batchBuilder = updateContext.getBatchBuilder();
            final FileHandlerService service = new FileHandlerService();
            final BatchServiceBuilder<Handler> serviceBuilder = batchBuilder.addService(LogServices.handlerName(getName()), service);
            final String relativeTo = this.relativeTo;
            if (relativeTo != null) {
                serviceBuilder.addDependency(AbstractPathService.pathNameOf(relativeTo), String.class, service.getRelativeToInjector());
            }
            service.setLevel(Level.parse(getLevelName()));
View Full Code Here

     */
    protected <P> void applyUpdate(UpdateContext updateContext, UpdateResultHandler<? super Void, P> resultHandler, P param) {
        try {
            final RootLoggerService service = new RootLoggerService();
            service.setLevel(Level.parse(getLevelName()));
            final BatchBuilder batchBuilder = updateContext.getBatchBuilder();
            final BatchServiceBuilder<Logger> builder = batchBuilder.addService(LogServices.ROOT_LOGGER, service);
            builder.setInitialMode(ServiceController.Mode.ACTIVE);
            builder.addListener(new UpdateResultHandler.ServiceStartListener<P>(resultHandler, param));
        } catch (Throwable t) {
            resultHandler.handleFailure(t, param);
            return;
View Full Code Here

TOP

Related Classes of org.jboss.msc.service.BatchBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.