@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode recoveryEnvModel) throws OperationFailedException { final String configPropertyValue = CONNECTION_PROPERTY_VALUE.resolveModelAttribute(context, recoveryEnvModel).asString(); final ModelNode address = operation.require(OP_ADDR); PathAddress path = PathAddress.pathAddress(address); final String jndiName = path.getElement(path.size() - 2).getValue(); final String configPropertyName = PathAddress.pathAddress(address).getLastElement().getValue(); ServiceName serviceName = DataSourceConfigService.SERVICE_NAME_BASE.append(jndiName).append("connection-properties").append(configPropertyName); final ServiceRegistry registry = context.getServiceRegistry(true); final ServiceName dataSourceConfigServiceName = DataSourceConfigService.SERVICE_NAME_BASE .append(jndiName); final ServiceController<?> dataSourceConfigController = registry .getService(dataSourceConfigServiceName); if (dataSourceConfigController == null || !((DataSource) dataSourceConfigController.getValue()).isEnabled()) { final ServiceTarget serviceTarget = context.getServiceTarget(); final ConnectionPropertiesService service = new ConnectionPropertiesService(configPropertyName, configPropertyValue); serviceTarget.addService(serviceName, service).setInitialMode(ServiceController.Mode.NEVER) .install(); } else { context.reloadRequired(); } }
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); } });
@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); } }
@Override public void handleEvent(final ServiceController<?> controller, final LifecycleEvent event) { if (event == LifecycleEvent.DOWN) { controller.setMode(Mode.ACTIVE); controller.removeListener(this); } } });
static ListenerService getListenerService(OperationContext context) { final String name = context.getCurrentAddressValue(); ServiceName serviceName = LISTENER_CAPABILITY.getCapabilityServiceName(name); ServiceController<ListenerService> listenerSC = (ServiceController<ListenerService>) context.getServiceRegistry(false).getService(serviceName); if (listenerSC == null || listenerSC.getState() != ServiceController.State.UP) { return null; } return listenerSC.getValue(); }
@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); } } } });
@Override protected void performRuntime(OperationContext context, ModelNode operation, final Resource resource) throws OperationFailedException { if (!raModel.hasDefined(ARCHIVE.getName()) && !raModel.hasDefined(MODULE.getName())) { throw ConnectorLogger.ROOT_LOGGER.archiveOrModuleRequired(); archiveOrModuleName = MODULE.resolveModelAttribute(context, raModel).asString(); final String poolName = PathAddress.pathAddress(address).getLastElement().getValue(); ServiceName raServiceName = ServiceName.of(ConnectorServices.RA_SERVICE, raName); final ServiceTarget serviceTarget = context.getServiceTarget(); ServiceRegistry registry = context.getServiceRegistry(true); final ServiceController<?> RaxmlController = registry.getService(ServiceName.of(ConnectorServices.RA_SERVICE, raName)); Activation raxml = (Activation) RaxmlController.getValue(); ServiceName deploymentServiceName = ConnectorServices.getDeploymentServiceName(archiveOrModuleName, raName); String bootStrapCtxName = DEFAULT_NAME; .install(); PathElement peAO = PathElement.pathElement(Constants.STATISTICS_NAME, "extended");
@Override protected void executeRuntimeStep(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(); context.getFailureDescription().set(UndertowLogger.ROOT_LOGGER.unknownMetric(operation.require(ModelDescriptionConstants.NAME).asString())); } else { ModelNode result = new ModelNode(); 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 return; final UndertowDeploymentService deploymentService = (UndertowDeploymentService) controller.getService(); if (deploymentService == null || deploymentService.getDeployment() == null) { //we might be in shutdown and it is possible return;
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR)); final String jndiName = address.getLastElement().getValue(); final String attributeName = operation.require(NAME).asString(); final ServiceController<?> managementRepoService = context.getServiceRegistry(false).getService( ConnectorServices.MANAGEMENT_REPOSITORY_SERVICE); if (managementRepoService != null) { try { final ManagementRepository repository = (ManagementRepository) managementRepoService.getValue(); final ModelNode result = context.getResult(); List<StatisticsPlugin> stats = getMatchingStats(jndiName, repository); for (StatisticsPlugin stat : stats) { result.set("" + stat.getValue(attributeName)); } } catch (Exception e) { throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.failedToGetMetrics(e.getLocalizedMessage())); } } } }, OperationContext.Stage.RUNTIME);
@Override protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException { ModelNode opAddr = operation.require(OP_ADDR); PathAddress address = PathAddress.pathAddress(opAddr); final String securityDomain = address.getLastElement().getValue(); String principal = null; if (operation.hasDefined(Constants.PRINCIPAL_ARGUMENT)) principal = operation.get(Constants.PRINCIPAL_ARGUMENT).asString(); ServiceController<SecurityDomainContext> controller = getSecurityDomainService(context, securityDomain); if (controller != null) { // FIXME this is nasty. waitForService(controller); SecurityDomainContext sdc = controller.getValue(); @SuppressWarnings("unchecked") CacheableManager<?, Principal> manager = (CacheableManager<?, Principal>) sdc.getAuthenticationManager(); if (principal != null) manager.flushCache(new SimplePrincipal(principal)); else manager.flushCache(); } else { throw SecurityLogger.ROOT_LOGGER.noAuthenticationCacheAvailable(securityDomain); } // Can't rollback context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); } }
dataSourceController.getService() instanceof AbstractDataSourceService ? ((AbstractDataSourceService)dataSourceController.getService()).getCredentialSourceSupplierInjector().getOptionalValue() dataSourceController.getService() instanceof AbstractDataSourceService ? ((AbstractDataSourceService)dataSourceController.getService()).getRecoveryCredentialSourceSupplierInjector().getOptionalValue() for (ServiceName name : serviceNames) { if (xaDataSourceConfigServiceName.append("xa-datasource-properties").isParentOf(name)) { final ServiceController<?> xaConfigPropertyController = registry.getService(name); XaDataSourcePropertiesService xaPropService = (XaDataSourcePropertiesService) xaConfigPropertyController.getService(); if (!ServiceController.State.UP.equals(xaConfigPropertyController.getState())) { propertiesCount++; xaConfigPropertyController.setMode(ServiceController.Mode.ACTIVE); builder.addDependency(name, String.class, xaDataSourceConfigService.getXaDataSourcePropertyInjector(xaPropService.getName())); ConnectionPropertiesService connPropService = (ConnectionPropertiesService) connPropServiceController.getService(); if (!ServiceController.State.UP.equals(connPropServiceController.getState())) { connPropServiceController.setMode(ServiceController.Mode.ACTIVE); builder.addDependency(name, String.class, configService.getConnectionPropertyInjector(connPropService.getName())); if (!ServiceController.State.UP.equals(dataSourceController.getState())) { statsServiceSB.setInitialMode(ServiceController.Mode.PASSIVE); statsServiceSB.install(); dataSourceController.setMode(ServiceController.Mode.ACTIVE); } else { throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.serviceAlreadyStarted("Data-source", dsName));
@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 protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException { ModelNode opAddr = operation.require(OP_ADDR); PathAddress address = PathAddress.pathAddress(opAddr); final String securityDomain = address.getLastElement().getValue(); ServiceController<SecurityDomainContext> controller = getSecurityDomainService(context, securityDomain); if (controller != null) { // FIXME this is nasty. waitForService(controller); SecurityDomainContext sdc = controller.getValue(); @SuppressWarnings("unchecked") CacheableManager<?, Principal> manager = (CacheableManager<?, Principal>) sdc .getAuthenticationManager(); Set<Principal> cachedPrincipals = manager.getCachedKeys(); ModelNode result = context.getResult(); for (Principal principal : cachedPrincipals) { result.add(principal.getName()); } if (!result.isDefined()) result.setEmptyList(); } else { throw SecurityLogger.ROOT_LOGGER.noAuthenticationCacheAvailable(securityDomain); } context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); } }
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { ModelNode result = new ModelNode(); CachedConnectionManager ccm = (CachedConnectionManager) context.getServiceRegistry(false).getService(ConnectorServices.CCM_SERVICE).getValue(); ModelNode txResult = new ModelNode().set(ccm.getNumberOfConnections()); ccm = (CachedConnectionManager) context.getServiceRegistry(false).getService(ConnectorServices.NON_TX_CCM_SERVICE).getValue(); ModelNode nonTxResult = new ModelNode().set(ccm.getNumberOfConnections()); result.get(Constants.TX).set(txResult); result.get(Constants.NON_TX).set(nonTxResult); context.getResult().set(result); } }, OperationContext.Stage.RUNTIME);
private void applyModelToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode model) throws OperationFailedException { String name = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue(); ServiceRegistry registry = context.getServiceRegistry(true); EJBSuspendHandlerService service = (EJBSuspendHandlerService) registry.getRequiredService(EJBSuspendHandlerService.SERVICE_NAME).getValue(); if (service!= null && this.gracefulTxnShutdownAttribute.getName().equals(attributeName)) { boolean enableGracefulTxnShutdown = this.gracefulTxnShutdownAttribute.resolveModelAttribute(context, model) .asBoolean(); service.enableGracefulTxnShutdown(enableGracefulTxnShutdown); } }
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(); }
@Override protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, JcaSubsystemConfiguration handback) throws OperationFailedException { JcaSubsystemConfiguration config = (JcaSubsystemConfiguration) context.getServiceRegistry(true).getService(ConnectorServices.CONNECTOR_CONFIG_SERVICE).getValue(); if (attributeName.equals(JcaBeanValidationDefinition.BeanValidationParameters.BEAN_VALIDATION_ENABLED.getAttribute().getName())) { config.setBeanValidation(valueToRestore.asBoolean()); } } }
@Override protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<JcaSubsystemConfiguration> jcaSubsystemConfigurationHandbackHolder) throws OperationFailedException { final ModelNode address = operation.require(OP_ADDR); final String name = PathAddress.pathAddress(address).getLastElement().getValue(); Object wm = context.getServiceRegistry(true).getService(ConnectorServices.WORKMANAGER_SERVICE.append(name)).getValue(); switch (JcaDistributedWorkManagerDefinition.PolicyValue.valueOf(resolvedValue.asString())) { case NEVER: { namedDistributedWorkManager.setPolicy(new Never()); throw ROOT_LOGGER.unsupportedPolicy(resolvedValue.asString());
@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);