Package org.jboss.msc.service

Examples of org.jboss.msc.service.ServiceRegistry


                        final ModelNode address = operation.require(OP_ADDR);
                        final String dsName = PathAddress.pathAddress(address).getLastElement().getValue();
                        final String jndiName = model.get(JNDINAME.getName()).asString();

                        final ServiceRegistry registry = context.getServiceRegistry(true);

                        final ServiceName dataSourceServiceName = AbstractDataSourceService.SERVICE_NAME_BASE.append(jndiName);
                        final ServiceController<?> dataSourceController = registry.getService(dataSourceServiceName);
                        if (dataSourceController != null) {
                            if (ServiceController.State.UP.equals(dataSourceController.getState())) {
                                dataSourceController.setMode(ServiceController.Mode.NEVER);
                            } else {
                                throw new OperationFailedException(new ModelNode().set(MESSAGES.serviceNotEnabled("Data-source", dsName)));
                            }
                        } else {
                            throw new OperationFailedException(new ModelNode().set(MESSAGES.serviceNotAvailable("Data-source", dsName)));
                        }

                        final ServiceName referenceServiceName = DataSourceReferenceFactoryService.SERVICE_NAME_BASE.append(dsName);
                        final ServiceController<?> referenceController = registry.getService(referenceServiceName);
                        if (referenceController != null ) {
                            context.removeService(referenceController);
                        }

                        final ServiceName binderServiceName = ContextNames.bindInfoFor(jndiName).getBinderServiceName();

                        final ServiceController<?> binderController = registry.getService(binderServiceName);
                        if (binderController != null ) {
                            context.removeService(binderController);
                        }

                        final ServiceName dataSourceConfigServiceName = DataSourceConfigService.SERVICE_NAME_BASE.append(dsName);
                        final ServiceController<?> dataSourceConfigController = registry.getService(dataSourceConfigServiceName);


                        final List<ServiceName> serviceNames = registry.getServiceNames();


                        final ServiceName xaDataSourceConfigServiceName = XADataSourceConfigService.SERVICE_NAME_BASE.append(dsName);
                        final ServiceController<?> xaDataSourceConfigController = registry.getService(xaDataSourceConfigServiceName);


                        for (ServiceName name : serviceNames) {
                            if (dataSourceConfigServiceName.append("connection-properties").isParentOf(name)) {
                                final ServiceController<?> connPropertyController = registry.getService(name);

                                if (connPropertyController != null) {
                                    if (ServiceController.State.UP.equals(connPropertyController.getState())) {
                                        connPropertyController.setMode(ServiceController.Mode.NEVER);
                                    } else {
                                        throw new OperationFailedException(new ModelNode().set(MESSAGES.serviceAlreadyStarted("Data-source.connectionProperty", name)));
                                    }
                                } else {
                                    throw new OperationFailedException(new ModelNode().set(MESSAGES.serviceNotAvailable("Data-source.connectionProperty", name)));
                                }
                            }
                            if (xaDataSourceConfigServiceName.append("xa-datasource-properties").isParentOf(name)) {
                                final ServiceController<?> xaConfigPropertyController = registry.getService(name);

                                if (xaConfigPropertyController != null) {
                                    if (ServiceController.State.UP.equals(xaConfigPropertyController.getState())) {
                                        xaConfigPropertyController.setMode(ServiceController.Mode.NEVER);
                                    } else {
View Full Code Here


    @Override
    public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {

        final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
        final String contextName = deploymentUnit.getName();
        final ServiceRegistry serviceRegistry = phaseContext.getServiceRegistry();

        // Check if we already have a BundleInfo
        BundleInfo info = BundleInfoAttachment.getBundleInfo(deploymentUnit);
        ServiceController<Deployment> deploymentController = DeploymentHolderService.getDeployment(serviceRegistry, contextName);
        if (info != null || deploymentController != null)
View Full Code Here

        if (deployment != null)
            return;

        // Check if {@link InstallHandlerIntegration} provided the {@link Deployment}
        if (deployment == null) {
            ServiceRegistry serviceRegistry = phaseContext.getServiceRegistry();
            ServiceController<Deployment> controller = DeploymentHolderService.getDeployment(serviceRegistry, contextName);
            if (controller != null) {
                deployment = controller.getValue();
                deployment.setAutoStart(false);
                controller.setMode(Mode.REMOVE);
View Full Code Here

    }

    @Override
    protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model, ServiceVerificationHandler verificationHandler, List<ServiceController<?>> newControllers) throws OperationFailedException {

        ServiceRegistry registry = context.getServiceRegistry(false);
        final ServiceName hqServiceName = MessagingServices.getHornetQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
        ServiceController<?> hqService = registry.getService(hqServiceName);
        if (hqService != null) {
            context.reloadRequired();
        }
        // else MessagingSubsystemAdd will add a handler that calls ConnectorServiceAdd.addConnectorServiceConfigs
    }
View Full Code Here

    void updateOptimisticLocking(final OperationContext context, final ModelNode model, List<ServiceController<?>> newControllers) throws OperationFailedException {

        final ModelNode enabled = EJB3SubsystemRootResourceDefinition.DEFAULT_ENTITY_BEAN_OPTIMISTIC_LOCKING.resolveModelAttribute(context, model);

        final ServiceRegistry serviceRegistry = context.getServiceRegistry(true);
        ServiceController existingService = serviceRegistry.getService(SERVICE_NAME);
        // if a default optimistic locking config is installed, remove it
        if (existingService != null) {
            context.removeService(existingService);
        }
View Full Code Here

    void updateDefaultAdapterService(final OperationContext context, final ModelNode model, List<ServiceController<?>> newControllers) throws OperationFailedException {

        final ModelNode adapterNameNode = EJB3SubsystemRootResourceDefinition.DEFAULT_RESOURCE_ADAPTER_NAME.resolveModelAttribute(context, model);
        final String adapterName =  adapterNameNode.isDefined() ? adapterNameNode.asString() : null;

        final ServiceRegistry serviceRegistry = context.getServiceRegistry(true);
        ServiceController<DefaultResourceAdapterService> existingDefaultRANameService = (ServiceController<DefaultResourceAdapterService>) serviceRegistry.getService(DefaultResourceAdapterService.DEFAULT_RA_NAME_SERVICE_NAME);
        // if a default RA name service is already installed then just update the resource adapter name
        if (existingDefaultRANameService != null) {
            existingDefaultRANameService.getValue().setResourceAdapterName(adapterName);
        } else if (adapterName != null) {
            // create a new one and install
View Full Code Here

    }

    private void applyModelToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode model) throws OperationFailedException {
        String name = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
        ServiceName serviceName = BackingCacheEntryStoreSourceService.getServiceName(name);
        ServiceRegistry registry = context.getServiceRegistry(true);
        @SuppressWarnings("unchecked")
        ServiceController<S> service = (ServiceController<S>) registry.getService(serviceName);
        if (service != null) {
            S config = service.getValue();
            if (config != null) {
                AttributeDefinition maxSizeDefinition = this.getMaxSizeDefinition();
                if (maxSizeDefinition.getName().equals(attributeName)) {
View Full Code Here

    }

    private T getComponent(final ServiceName serviceName, final PathAddress operationAddress,
                           final OperationContext context, final boolean forWrite) throws OperationFailedException {

        ServiceRegistry registry = context.getServiceRegistry(forWrite);
        ServiceController<?> controller = registry.getService(serviceName);
        if (controller == null) {
            String exceptionMessage = MESSAGES.noComponentAvailableForAddress(operationAddress);
            throw new OperationFailedException(new ModelNode().set(exceptionMessage));
        }
        ServiceController.State controllerState = controller.getState();
View Full Code Here

    }


    private void applyModelToRuntime(OperationContext context, final ModelNode model) throws OperationFailedException {
        long timeout = attribute.resolveModelAttribute(context, model).asLong();
        final ServiceRegistry serviceRegistry = context.getServiceRegistry(true);
        ServiceController<DefaultAccessTimeoutService> controller = (ServiceController<DefaultAccessTimeoutService>) serviceRegistry.getService(serviceName);
        if (controller != null) {
            DefaultAccessTimeoutService service = controller.getValue();
            if (service != null) {
                service.setDefaultAccessTimeout(timeout);
            }
View Full Code Here

        deployer = new EjbSecurityDeployer();
        deployer.undeploy(deploymentUnit);

        // EJBs maybe included directly in war deployment
        ServiceName jaccServiceName = getJaccServiceName(deploymentUnit);
        ServiceRegistry registry = deploymentUnit.getServiceRegistry();
        if(registry != null){
            ServiceController<?> serviceController = registry.getService(jaccServiceName);
            if (serviceController != null) {
                serviceController.setMode(ServiceController.Mode.REMOVE);
            }
        }
    }
View Full Code Here

TOP

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

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.