static ModClusterService service(String name) { final ServiceContainer serviceContainer = CurrentServiceContainer.getServiceContainer(); if(serviceContainer == null) { //for tests return null; } ServiceController<?> cluster = serviceContainer.getService(UndertowService.FILTER.append(name)); if(cluster == null) { return null; } return (ModClusterService) cluster.getService(); } }
public void rebind(Name name, Object object) throws NamingException { final Object owner = requireOwner(); // re-set the existent binder service injected value final ServiceName bindName = buildServiceName(name); final ServiceController<?> controller = getServiceRegistry().getService(bindName); if (controller == null) { bind(name, object, owner, bindName); } else { final BinderService binderService = (BinderService) controller.getService(); if (owner instanceof ServiceName) { final ServiceName deploymentUnitServiceName = (ServiceName) owner; binderService.acquire(); final RuntimeBindReleaseService.References duBindingReferences = (RuntimeBindReleaseService.References) controller.getServiceContainer().getService(JndiNamingDependencyProcessor.serviceName(deploymentUnitServiceName)).getValue(); duBindingReferences.add(binderService); } binderService.getManagedObjectInjector().setValue(new ImmediateValue(new ImmediateManagedReferenceFactory(object))); } }
private static InstancesService putIfAbsent(ServiceRegistry registry, ServiceName name, ServiceBuilder builder) throws StartException { for (; ; ) { try { ServiceController sc = registry.getService(name); if (sc == null) { sc = builder.install(); } return (InstancesService) sc.getService(); } catch (DuplicateServiceException ignored) { } catch (Exception e) { throw new StartException(e); } } }
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); }
private void executeRuntime(final OperationContext context, final ModelNode operation) throws OperationFailedException { final ServiceController<?> controller = context.getServiceRegistry(modify).getService(getServiceName(context)); final WildFlyJobOperator jobOperator = (WildFlyJobOperator) controller.getService(); execute(context, operation, jobOperator); }
@Override protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Void> handbackHolder) throws OperationFailedException { ServiceController<?> controller = context.getServiceRegistry(false).getService(UndertowService.UNDERTOW); if (controller != null) { UndertowService service = (UndertowService) controller.getService(); if (service != null) { service.setStatisticsEnabled(resolvedValue.asBoolean()); } } return false; }
@Override protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, Void handback) throws OperationFailedException { ServiceController<?> controller = context.getServiceRegistry(false).getService(UndertowService.UNDERTOW); if (controller != null) { UndertowService service = (UndertowService) controller.getService(); if (service != null) { service.setStatisticsEnabled(valueToRestore.asBoolean()); } } } });
@Override protected void executeRuntimeStep(final OperationContext context, final ModelNode operation) throws OperationFailedException { final String poolName = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue(); final ServiceName serviceName = StrictMaxPoolConfigService.EJB_POOL_CONFIG_BASE_SERVICE_NAME.append(poolName); final ServiceRegistry registry = context.getServiceRegistry(true); ServiceController<?> sc = registry.getService(serviceName); if (sc != null) { StrictMaxPoolConfigService smpc = (StrictMaxPoolConfigService) sc.getService(); if (smpc != null) { context.getResult().set(smpc.getDerivedSize()); return; } } throw EjbLogger.ROOT_LOGGER.cannotReadStrictMaxPoolDerivedSize(serviceName); } }
private void setValue(final OperationContext context, final ModelNode value) { final BatchConfigurationService service = (BatchConfigurationService) context.getServiceRegistry(true) .getService(context.getCapabilityServiceName(Capabilities.BATCH_CONFIGURATION_CAPABILITY.getName(), BatchConfiguration.class)).getService(); service.setRestartOnResume(value.asBoolean()); } });
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { if (context.isDefaultRequiresRuntime()) { context.addStep((ctx, op) -> { RuntimeCapability<Void> runtimeCapability = APPLICATION_SECURITY_DOMAIN_RUNTIME_CAPABILITY.fromBaseCapability(context.getCurrentAddressValue()); ServiceName serviceName = runtimeCapability.getCapabilityServiceName(ApplicationSecurityDomain.class); ServiceRegistry serviceRegistry = context.getServiceRegistry(false); ServiceController<?> controller = serviceRegistry.getRequiredService(serviceName); ModelNode deploymentList = new ModelNode(); if (controller.getState() == State.UP) { Service service = controller.getService(); if (service instanceof ApplicationSecurityDomainService) { for (String current : ((ApplicationSecurityDomainService) service).getDeployments()) { deploymentList.add(current); } } } context.getResult().set(deploymentList); }, OperationContext.Stage.RUNTIME); } } }
private void applyModelToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode model) throws OperationFailedException { final String poolName = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue(); final ServiceName serviceName = StrictMaxPoolConfigService.EJB_POOL_CONFIG_BASE_SERVICE_NAME.append(poolName); final ServiceRegistry registry = context.getServiceRegistry(true); ServiceController<?> sc = registry.getService(serviceName); if (sc != null) { StrictMaxPoolConfigService smpc = (StrictMaxPoolConfigService) sc.getService(); if (smpc != null) { if (StrictMaxPoolResourceDefinition.MAX_POOL_SIZE.getName().equals(attributeName)) { int maxPoolSize = StrictMaxPoolResourceDefinition.MAX_POOL_SIZE.resolveModelAttribute(context, model).asInt(-1); smpc.setMaxPoolSize(maxPoolSize); } else if (StrictMaxPoolResourceDefinition.DERIVE_SIZE.getName().equals(attributeName)) { StrictMaxPoolConfigService.Derive derive = StrictMaxPoolResourceDefinition.parseDeriveSize(context, model); smpc.setDerive(derive); } else if (StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT.getName().equals(attributeName)) { long timeout = StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT.resolveModelAttribute(context, model).asLong(); smpc.setTimeout(timeout); } else if (StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT_UNIT.getName().equals(attributeName)) { String timeoutUnit = StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT_UNIT.resolveModelAttribute(context, model).asString(); smpc.setTimeoutUnit(TimeUnit.valueOf(timeoutUnit)); } } } }
@Override public void execute(final OperationContext context, final ModelNode operation) { final ServiceController<?> deploymentServiceController = context.getServiceRegistry(false).getService(UndertowService.deploymentServiceName(server, host, path)); if (deploymentServiceController == null) { return; } final UndertowDeploymentService deploymentService = (UndertowDeploymentService) deploymentServiceController.getService(); final DeploymentInfo deploymentInfo = deploymentService.getDeploymentInfoInjectedValue().getValue(); final UndertowMetricsCollector collector = (UndertowMetricsCollector)deploymentInfo.getMetricsCollector(); MetricsHandler.MetricResult result = collector != null ? collector.getMetrics(context.getCurrentAddressValue()) : null; if (result != null) { final ModelNode response = new ModelNode(); handle(response, result); context.getResult().set(response); } } }, OperationContext.Stage.RUNTIME);
return; final UndertowDeploymentService deploymentService = (UndertowDeploymentService) controller.getService(); if (deploymentService == null || deploymentService.getDeployment() == null) { //we might be in shutdown and it is possible return;
@Override public void handleEvent(ServiceController controller, LifecycleEvent event) { latch.awaitUninterruptibly(); if (event == LifecycleEvent.DOWN) { try { final ServiceController<?> RaxmlController = registry.getService(ServiceName.of(ConnectorServices.RA_SERVICE, id)); Activation raxml = (Activation) RaxmlController.getValue(); ((ResourceAdapterXmlDeploymentService) controller.getService()).setRaxml(raxml); controller.compareAndSetMode(ServiceController.Mode.NEVER, originalMode); } finally { controller.removeListener(this); } } } });
private static SessionManager getSessionManager(OperationContext context, ModelNode operation) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)); final Resource web = context.readResourceFromRoot(address.subAddress(0, address.size()), false); final ModelNode subModel = web.getModel(); final String host = VIRTUAL_HOST.resolveModelAttribute(context, subModel).asString(); final String path = CONTEXT_ROOT.resolveModelAttribute(context, subModel).asString(); final String server = SERVER.resolveModelAttribute(context, subModel).asString(); final UndertowDeploymentService deploymentService; final ServiceController<?> controller = context.getServiceRegistry(false).getService(UndertowService.deploymentServiceName(server, host, path)); if (controller != null && controller.getState() != ServiceController.State.UP) {//check if deployment is active at all throw UndertowLogger.ROOT_LOGGER.sessionManagerNotAvailable(); } else { deploymentService = (UndertowDeploymentService) controller.getService(); if (deploymentService == null || deploymentService.getDeployment() == null) { //we might be in shutdown and it is possible throw UndertowLogger.ROOT_LOGGER.sessionManagerNotAvailable(); } } Deployment deployment = deploymentService.getDeployment(); return deployment.getSessionManager(); }
throw e; BinderService service = (BinderService) registered.getService(); if (!service.getSource().equals(bindingConfiguration.getSource())) throw EeLogger.ROOT_LOGGER.conflictingBinding(bindingName, bindingConfiguration.getSource());
dataSourceController.getService() instanceof AbstractDataSourceService ? ((AbstractDataSourceService)dataSourceController.getService()).getCredentialSourceSupplierInjector().getOptionalValue() dataSourceController.getService() instanceof AbstractDataSourceService ? ((AbstractDataSourceService)dataSourceController.getService()).getRecoveryCredentialSourceSupplierInjector().getOptionalValue() if (xaDataSourceConfigServiceName.append("xa-datasource-properties").isParentOf(name)) { final ServiceController<?> xaConfigPropertyController = registry.getService(name); XaDataSourcePropertiesService xaPropService = (XaDataSourcePropertiesService) xaConfigPropertyController.getService(); if (dataSourceCongServiceName.append("connection-properties").isParentOf(name)) { final ServiceController<?> connPropServiceController = registry.getService(name); ConnectionPropertiesService connPropService = (ConnectionPropertiesService) connPropServiceController.getService();
if (registered == null) throw e; BinderService service = (BinderService) registered.getService(); if (!service.getSource().equals(bindingConfiguration.getSource())) throw EeLogger.ROOT_LOGGER.conflictingBinding(bindingName, bindingConfiguration.getSource()); if (controller == null) throw e; service = (BinderService) controller.getService(); if (!equals(service.getSource(), bindingConfiguration.getSource())) { throw EeLogger.ROOT_LOGGER.conflictingBinding(bindingName, bindingConfiguration.getSource());
@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); } }