@Override protected boolean applyUpdateToRuntime(final OperationContext context, final ModelNode operation, final String parameterName, final ModelNode newValue, final ModelNode currentValue, final HandbackHolder<List<PoolConfiguration>> handbackHolder) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR)); final String poolName = address.getLastElement().getValue(); final ServiceController<?> managementRepoService = context.getServiceRegistry(false).getService( ConnectorServices.MANAGEMENT_REPOSITORY_SERVICE); List<PoolConfiguration> poolConfigs = null; if (managementRepoService != null) { try { final ManagementRepository repository = (ManagementRepository) managementRepoService.getValue(); poolConfigs = getMatchingPoolConfigs(poolName, repository); updatePoolConfigs(poolConfigs, parameterName, newValue); handbackHolder.setHandback(poolConfigs); } catch (Exception e) { throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.failedToSetAttribute(e.getLocalizedMessage())); } } return (IDLETIMEOUTMINUTES.getName().equals(parameterName) || BACKGROUNDVALIDATION.getName().equals(parameterName) || BACKGROUNDVALIDATIONMILLIS.getName().equals(parameterName) || POOL_PREFILL.getName().equals(parameterName) || POOL_FLUSH_STRATEGY.getName().equals(parameterName) || MAX_POOL_SIZE.getName().equals(parameterName) || MIN_POOL_SIZE.getName().equals(parameterName)); }
@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); } } }
if (!context.isResourceServiceRestartAllowed()) { context.reloadRequired(); context.completeStep(new OperationContext.RollbackHandler() { @Override public void handleRollback(OperationContext context, ModelNode operation) { ServiceController<?> serviceController = context.getServiceRegistry(false).getService(raServiceName); final ModifiableResourceAdapter resourceAdapter; if (serviceController != null) { resourceAdapter = (ModifiableResourceAdapter) serviceController.getValue(); } else { resourceAdapter = null; final List<ServiceName> serviceNameList = context.getServiceRegistry(false).getServiceNames(); for (ServiceName name : serviceNameList) { if (raServiceName.isParentOf(name)) { if (model.get(MODULE.getName()).isDefined()) {
private void addConfigSourcesFromServices(ConfigBuilder builder, ServiceRegistry serviceRegistry, ClassLoader classloader) { List<ServiceName> serviceNames = serviceRegistry.getServiceNames(); for (ServiceName serviceName: serviceNames) { if (ServiceNames.CONFIG_SOURCE.isParentOf(serviceName)) { ServiceController<?> service = serviceRegistry.getService(serviceName); ConfigSource configSource = ConfigSource.class.cast(service.getValue()); builder.withSources(configSource); } else if (ServiceNames.CONFIG_SOURCE_PROVIDER.isParentOf(serviceName)) { ServiceController<?> service = serviceRegistry.getService(serviceName); ConfigSourceProvider configSourceProvider = ConfigSourceProvider.class.cast(service.getValue()); for (ConfigSource configSource : configSourceProvider.getConfigSources(classloader)) { builder.withSources(configSource); } } } }
@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;
void updateRegexAllowed(final OperationContext context, final ModelNode model) throws OperationFailedException { final ModelNode allowRegex = this.attributeDefinition.resolveModelAttribute(context, model); final ServiceRegistry registry = context.getServiceRegistry(true); final ServiceController<?> ejbNameServiceController = registry.getService(EjbNameRegexService.SERVICE_NAME); EjbNameRegexService service = (EjbNameRegexService) ejbNameServiceController.getValue(); if (!allowRegex.isDefined()) { service.setEjbNameRegexAllowed(false); } else { service.setEjbNameRegexAllowed(allowRegex.asBoolean()); } }
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { ServiceRegistry registry = context.getServiceRegistry(false); DriverRegistry driverRegistry = (DriverRegistry)registry.getRequiredService(ConnectorServices.JDBC_DRIVER_REGISTRY_SERVICE).getValue(); ServiceModuleLoader serviceModuleLoader = (ServiceModuleLoader)registry.getRequiredService(Services.JBOSS_SERVICE_MODULE_LOADER).getValue(); Resource rootNode = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false); ModelNode rootModel = rootNode.getModel(); String profile = rootModel.hasDefined("profile-name") ? rootModel.get("profile-name").asString() : null; ModelNode result = context.getResult(); for (InstalledDriver driver : driverRegistry.getInstalledDrivers()) { ModelNode driverNode = new ModelNode();
if (ELYTRON_ENABLED.resolveModelAttribute(context, model).asBoolean()) { if (model.hasDefined(SECURITY_DOMAIN.getName())) throw SUBSYSTEM_RA_LOGGER.attributeRequiresFalseOrUndefinedAttribute(SECURITY_DOMAIN.getName(), ELYTRON_ENABLED.getName()); else if (model.hasDefined(SECURITY_DOMAIN_AND_APPLICATION.getName())) throw SUBSYSTEM_RA_LOGGER.attributeRequiresFalseOrUndefinedAttribute(SECURITY_DOMAIN_AND_APPLICATION.getName(), ELYTRON_ENABLED.getName()); else if (model.hasDefined(APPLICATION.getName())) final String name = context.getCurrentAddressValue(); final String archiveOrModuleName; final boolean statsEnabled = STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean(); } else { RaOperationUtil.installRaServicesAndDeployFromModule(context, name, resourceAdapter, archiveOrModuleName, newControllers); if (context.isBooting()) { context.addStep(new OperationStepHandler() { public void execute(final OperationContext context, ModelNode operation) throws OperationFailedException { ServiceRegistry registry = context.getServiceRegistry(true); final ServiceController<?> RaxmlController = registry.getService(ServiceName.of(ConnectorServices.RA_SERVICE, name)); Activation raxml = (Activation) RaxmlController.getValue(); ServiceName serviceName = ConnectorServices.getDeploymentServiceName(archiveOrModuleName, name); String bootStrapCtxName = DEFAULT_NAME; .install(); PathElement peStats = PathElement.pathElement(Constants.STATISTICS_NAME, "extended");
@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(); } }
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(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 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)); } } } }
static void secondRuntimeStep(OperationContext context, ModelNode operation, ManagementResourceRegistration datasourceRegistration, ModelNode model, boolean isXa) throws OperationFailedException { final ServiceTarget serviceTarget = context.getServiceTarget(); final ModelNode address = operation.require(OP_ADDR); final String dsName = PathAddress.pathAddress(address).getLastElement().getValue(); final String jndiName = JNDI_NAME.resolveModelAttribute(context, model).asString(); final ServiceRegistry registry = context.getServiceRegistry(true); final List<ServiceName> serviceNames = registry.getServiceNames(); final boolean elytronEnabled = ELYTRON_ENABLED.resolveModelAttribute(context, model).asBoolean(); final ServiceName dataSourceServiceName = context.getCapabilityServiceName(Capabilities.DATA_SOURCE_CAPABILITY_NAME, dsName, DataSource.class); final ServiceController<?> dataSourceController = registry.getService(dataSourceServiceName); 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(); final ServiceController<?> connPropServiceController = registry.getService(name); ConnectionPropertiesService connPropService = (ConnectionPropertiesService) connPropServiceController.getService();
@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);
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { ServiceRegistry registry = context.getServiceRegistry(false); DriverRegistry driverRegistry = (DriverRegistry)registry.getRequiredService(ConnectorServices.JDBC_DRIVER_REGISTRY_SERVICE).getValue(); ServiceModuleLoader serviceModuleLoader = (ServiceModuleLoader)registry.getRequiredService(Services.JBOSS_SERVICE_MODULE_LOADER).getValue(); ModelNode result = new ModelNode(); InstalledDriver driver = driverRegistry.getInstalledDriver(name); ModelNode driverNode = new ModelNode(); driverNode.get(DRIVER_NAME.getName()).set(driver.getDriverName()); if (driver.isFromDeployment()) { driverNode.get(DEPLOYMENT_NAME.getName()).set(driver.getDriverName()); result.add(driverNode); context.getResult().set(result);
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(); }
private FileSystemDeploymentService getExistingScanner(OperationContext context, ModelNode operation) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); final String name = address.getLastElement().getValue(); ServiceController<?> serviceController = context.getServiceRegistry(true).getService(DeploymentScannerService.getServiceName(name)); if(serviceController != null && serviceController.getState() == ServiceController.State.UP) { DeploymentScannerService service = (DeploymentScannerService) serviceController.getService(); return (FileSystemDeploymentService) service.getValue(); } return null; } }
@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());