/** * Releases the service, returns <code>true</code> if the service is removed as a result, or false otherwise * @return */ public boolean release() { if (refcnt != null && refcnt.decrementAndGet() <= 0 && controller != null) { controller.setMode(ServiceController.Mode.REMOVE); return true; } return false; }
@Override public void handleEvent(final ServiceController<?> controller, final LifecycleEvent event) { if (event == LifecycleEvent.DOWN) { controller.setMode(Mode.ACTIVE); controller.removeListener(this); } } });
@Override public void handleEvent(ServiceController<?> controller, LifecycleEvent event) { if (event == LifecycleEvent.DOWN) { controller.setMode(Mode.ACTIVE); controller.removeListener(this); } } }
@Override public void undeploy(DeploymentUnit context) { final ServiceName weldTransactionServiceName = context.getServiceName().append(ServiceNames.WELD_TRANSACTION_SERVICES_SERVICE_NAME); final ServiceController<?> serviceController = context.getServiceRegistry().getService(weldTransactionServiceName); if (serviceController != null) { serviceController.setMode(ServiceController.Mode.REMOVE); } }
private static void removeInstance(ServiceRegistry registry, BeanState state, final Class<?> clazz, Object bean) { if (clazz == null) return; ServiceController controller = registry.getService(BeanMetaDataConfig.toInstancesName(clazz, state)); if (controller != null) { InstancesService service = (InstancesService) controller.getService(); synchronized (clazz) { service.instances.remove(bean); invokeCallbacks(uncallbacks, state, clazz, bean); if (service.instances.isEmpty()) { beans.remove(new TypeBeanStateKey(clazz, state)); controller.setMode(ServiceController.Mode.REMOVE); } } } removeInstance(registry, state, clazz.getSuperclass(), bean); Class<?>[] ifaces = clazz.getInterfaces(); for (Class<?> iface : ifaces) removeInstance(registry, state, iface, bean); }
} finally { monitor.removeController(controller); controller.setMode(ServiceController.Mode.REMOVE);
private void transition(State targetState) { // Short-circuit if the service is already at the target state if (this.controller.getState() == targetState) return; StabilityMonitor monitor = new StabilityMonitor(); monitor.addController(this.controller); try { // Force service to transition to desired state Mode targetMode = modeToggle.get(targetState).get(this.controller.getMode()); if (targetMode != null) { this.controller.setMode(targetMode); } monitor.awaitStability(); if (this.controller.getState() == ServiceController.State.START_FAILED) { throw new IllegalStateException(this.controller.getStartException()); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { monitor.removeController(this.controller); } } }
@Override protected void executeAgainstComponent(OperationContext context, ModelNode operation, MessageDrivenComponent component, String opName, PathAddress address) throws OperationFailedException { if (START_DELIVERY.equals(opName)) { if (component.isDeliveryControlled()) { context.getServiceRegistry(true).getRequiredService(component.getDeliveryControllerName()).setMode(ServiceController.Mode.PASSIVE); } else { component.startDelivery(); } } else if (STOP_DELIVERY.equals(opName)) { if (component.isDeliveryControlled()) { context.getServiceRegistry(true).getRequiredService(component.getDeliveryControllerName()).setMode( ServiceController.Mode.NEVER); } else { component.stopDelivery(); } } else { super.executeAgainstComponent(context, operation, component, opName, address); } } }
@Override public void undeploy(DeploymentUnit deploymentUnit) { AbstractSecurityDeployer<?> deployer = null; 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); } } }
protected void updateDeliveryGroup(OperationContext context, ModelNode currentValue, ModelNode resolvedValue) throws OperationFailedException { if (currentValue.equals(resolvedValue)) { return; } String groupName = context.getCurrentAddress().getLastElement().getValue(); context.getServiceRegistry(true).getRequiredService(getDeliveryGroupServiceName(groupName)).setMode( resolvedValue.asBoolean() ? ServiceController.Mode.ACTIVE : ServiceController.Mode.NEVER); } });
controller.setMode(Mode.NEVER); return;
raServiceController.setMode(ServiceController.Mode.NEVER); } finally { latch.countDown();
protected void removeProcessEngineJndiBinding() { bindingService.setMode(Mode.REMOVE); }
@Override public void undeploy(DeploymentUnit deploymentUnit) { final EEModuleConfiguration moduleConfiguration = deploymentUnit.getAttachment(EE_MODULE_CONFIGURATION); if (moduleConfiguration == null) { return; } final ServiceRegistry serviceRegistry = deploymentUnit.getServiceRegistry(); boolean clusteredSingletonFound = false; for (final ComponentConfiguration configuration : moduleConfiguration.getComponentConfigurations()) { final ComponentDescription description = configuration.getComponentDescription(); if (description instanceof MessageDrivenComponentDescription) { MessageDrivenComponentDescription mdbDescription = (MessageDrivenComponentDescription) description; clusteredSingletonFound = clusteredSingletonFound || mdbDescription.isClusteredSingleton(); if (mdbDescription.isClusteredSingleton() || mdbDescription.getDeliveryGroup() != null) { serviceRegistry.getRequiredService(mdbDescription.getDeliveryControllerName()).setMode(Mode.REMOVE); } } } } }
public void unbind(final Name name) throws NamingException { requireOwner(); final ServiceName bindName = buildServiceName(name); final ServiceController<?> controller = getServiceRegistry().getService(bindName); if (controller == null) { throw NamingLogger.ROOT_LOGGER.cannotResolveService(bindName); } controller.setMode(ServiceController.Mode.REMOVE); final StabilityMonitor monitor = new StabilityMonitor(); monitor.addController(controller); try { monitor.awaitStability(); } catch (Exception e) { throw namingException("Failed to unbind [" + bindName + "]", e); } finally { monitor.removeController(controller); } }
@Override public void deploy(DeploymentPhaseContext context) throws DeploymentUnitProcessingException { DeploymentUnit unit = context.getDeploymentUnit(); if (unit.getParent() == null) { SingletonPolicy policy = context.getAttachment(POLICY_KEY); if (policy != null) { CapabilityServiceSupport support = unit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT); // Ideally, we would just install the next phase using the singleton policy, however deployment unit phases do not currently support restarts // Restart the deployment using the attached phase builder, but only if a builder was not already attached if (unit.putAttachment(Attachments.DEPLOYMENT_UNIT_PHASE_BUILDER, new SingletonDeploymentUnitPhaseBuilder(support, policy)) == null) { SingletonLogger.ROOT_LOGGER.singletonDeploymentDetected(policy); ServiceController<?> controller = context.getServiceRegistry().getRequiredService(unit.getServiceName()); controller.addListener(this); controller.setMode(Mode.NEVER); } } } }
xaConfigPropertyController.setMode(ServiceController.Mode.ACTIVE); builder.addDependency(name, String.class, xaDataSourceConfigService.getXaDataSourcePropertyInjector(xaPropService.getName())); connPropServiceController.setMode(ServiceController.Mode.ACTIVE); builder.addDependency(name, String.class, configService.getConnectionPropertyInjector(connPropService.getName())); statsServiceSB.setInitialMode(ServiceController.Mode.PASSIVE); statsServiceSB.install(); dataSourceController.setMode(ServiceController.Mode.ACTIVE); } else { throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.serviceAlreadyStarted("Data-source", dsName));
@SuppressWarnings("unchecked") public void unregisterProcessEngine(ProcessEngine processEngine) { if(processEngine == null) { throw new ProcessEngineException("Cannot unregister process engine with Msc Runtime Container: process engine is 'null'"); } ServiceName serviceName = ServiceNames.forManagedProcessEngine(processEngine.getName()); // remove the service asynchronously ServiceController<ProcessEngine> service = (ServiceController<ProcessEngine>) serviceContainer.getService(serviceName); if(service != null && service.getService() instanceof MscManagedProcessEngine) { service.setMode(Mode.REMOVE); } }
@SuppressWarnings("unchecked") public void unregisterProcessEngine(ProcessEngine processEngine) { if(processEngine == null) { throw new ProcessEngineException("Cannot unregister process engine with Msc Runtime Container: process engine is 'null'"); } ServiceName serviceName = ServiceNames.forManagedProcessEngine(processEngine.getName()); // remove the service asynchronously ServiceController<ProcessEngine> service = (ServiceController<ProcessEngine>) serviceContainer.getService(serviceName); if(service != null && service.getService() instanceof MscManagedProcessEngine) { service.setMode(Mode.REMOVE); } }
@SuppressWarnings("unchecked") public void unregisterProcessEngine(ProcessEngine processEngine) { if(processEngine == null) { throw new ProcessEngineException("Cannot unregister process engine with Msc Runtime Container: process engine is 'null'"); } ServiceName serviceName = ServiceNames.forManagedProcessEngine(processEngine.getName()); // remove the service asynchronously ServiceController<ProcessEngine> service = (ServiceController<ProcessEngine>) serviceContainer.getService(serviceName); if(service != null && service.getService() instanceof MscManagedProcessEngine) { service.setMode(Mode.REMOVE); } }