@Override public void execute(OperationContext context, ModelNode operation) { operationDeprecated(context, operation); context.createResource(PathAddress.EMPTY_ADDRESS); String name = context.getCurrentAddressValue(); String value = operation.get(VALUE.getName()).asString(); PathAddress storeAddress = context.getCurrentAddress().getParent(); ModelNode putOperation = Operations.createMapPutOperation(storeAddress, StoreResourceDefinition.Attribute.PROPERTIES, name, value); context.addStep(putOperation, MapOperations.MAP_PUT_HANDLER, context.getCurrentStage()); } };
protected void installServices(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException { final String groupName = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.ADDRESS)).getLastElement() .getValue(); final boolean active = MdbDeliveryGroupResourceDefinition.ACTIVE.resolveModelAttribute(context, model).asBoolean(); context.getServiceTarget().addService(getDeliveryGroupServiceName(groupName), Service.NULL) .setInitialMode(active? ServiceController.Mode.ACTIVE: ServiceController.Mode.NEVER).install(); } }
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final String parameterName = operation.require(NAME).asString(); final ModelNode submodel = context.readResource(PathAddress.EMPTY_ADDRESS, false).getModel(); final ModelNode currentValue = submodel.hasDefined(parameterName) ? submodel.get(parameterName).clone() : new ModelNode(); context.getResult().set(currentValue); } }
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { context.reloadRequired(); context.completeStep(OperationContext.RollbackHandler.REVERT_RELOAD_REQUIRED_ROLLBACK_HANDLER); } }, OperationContext.Stage.RUNTIME);
@Override protected void recordCapabilitiesAndRequirements(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { super.recordCapabilitiesAndRequirements(context, operation, resource); ModelNode parentModel = context.readResourceFromRoot(context.getCurrentAddress().getParent(), false).getModel(); final String defaultServerName = UndertowRootDefinition.DEFAULT_SERVER.resolveModelAttribute(context, parentModel).asString(); boolean isDefaultServer = context.getCurrentAddressValue().equals(defaultServerName); if (isDefaultServer) { context.registerCapability(CommonWebServer.CAPABILITY); } }
@Override protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, Void handback) throws OperationFailedException { final ModelNode restored = context.readResource(PathAddress.EMPTY_ADDRESS).getModel().clone(); restored.get(attributeName).set(valueToRestore); updateDefaultAdapterService(context, restored); }
protected void performRuntime(final OperationContext context, ModelNode operation, final ModelNode model) throws OperationFailedException { final ModelNode pathNode = FileDataStoreResourceDefinition.PATH.resolveModelAttribute(context, model); final String path = pathNode.isDefined() ? pathNode.asString() : null; final ModelNode relativeToNode = FileDataStoreResourceDefinition.RELATIVE_TO.resolveModelAttribute(context, model); final String relativeTo = relativeToNode.isDefined() ? relativeToNode.asString() : null; final FileTimerPersistence fileTimerPersistence = new FileTimerPersistence(true, path, relativeTo); final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); final ServiceName serviceName = TimerPersistence.SERVICE_NAME.append(address.getLastElement().getValue()); final ServiceBuilder sb = context.getServiceTarget().addService(serviceName, fileTimerPersistence); sb.addDependency(Services.JBOSS_SERVICE_MODULE_LOADER, ModuleLoader.class, fileTimerPersistence.getModuleLoader()); sb.addDependency(PathManagerService.SERVICE_NAME, PathManager.class, fileTimerPersistence.getPathManager()); sb.requires(context.getCapabilityServiceName("org.wildfly.transactions.global-default-local-provider", null)); sb.addDependency(context.getCapabilityServiceName("org.wildfly.transactions.transaction-synchronization-registry", null), TransactionSynchronizationRegistry.class, fileTimerPersistence.getTransactionSynchronizationRegistry()); sb.install(); }
@Override public void execute(OperationContext operationContext, ModelNode modelNode) throws OperationFailedException { final Resource jacorbResource = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS); final ModelNode jacorbModel = Resource.Tools.readModel(jacorbResource).clone(); warnings.add(JacORBLogger.ROOT_LOGGER.cannotEmulatePropertiesWarning(unsupportedProperties)); for(String unsupportedProperty : unsupportedProperties){ jacorbModel.get(unsupportedProperty).clear(); warnings.addAll(ConfigValidator.validateConfig(context, openjdkModel)); final PathAddress openjdkAddress = subsystemsAddress.append(OPENJDK_SUBSYSTEM_ELEMENT); addOpenjdkSubsystem(openjdkAddress, openjdkModel, migrateOperations); final PathAddress jacorbAddress = subsystemsAddress.append(JACORB_SUBSYSTEM_ELEMENT); removeJacorbSubsystem(jacorbAddress, migrateOperations, context.getProcessType() == ProcessType.STANDALONE_SERVER); result.get(MIGRATION_WARNINGS).set(rw); context.getResult().set(result); } else { context.completeStep(new OperationContext.ResultHandler() { @Override public void handleResult(OperationContext.ResultAction resultAction, OperationContext context, ModelNode operation) {
@Override protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { ModelNode model = resource.getModel(); final String name = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.ADDRESS)).getLastElement().getValue(); final String jndiName = ContextServiceResourceDefinition.JNDI_NAME_AD.resolveModelAttribute(context, model).asString(); final boolean useTransactionSetupProvider = ContextServiceResourceDefinition.USE_TRANSACTION_SETUP_PROVIDER_AD.resolveModelAttribute(context, model).asBoolean(); // install the service which manages the default context service final ContextServiceService contextServiceService = new ContextServiceService(name, jndiName, new DefaultContextSetupProviderImpl()); final ServiceBuilder<ContextServiceImpl> serviceBuilder = context.getServiceTarget().addService(ConcurrentServiceNames.getContextServiceServiceName(name), contextServiceService); if (useTransactionSetupProvider) { // add it to deps of context service's service, for injection of its value serviceBuilder.addDependency(ConcurrentServiceNames.TRANSACTION_SETUP_PROVIDER_SERVICE_NAME,TransactionSetupProvider.class,contextServiceService.getTransactionSetupProvider()); } serviceBuilder.install(); } }
@Override public AttributeValueTranslator getReadTranslator() { return (context, value) -> { String poolName = value.asString(); PathAddress address = context.getCurrentAddress(); PathAddress rootAddress = address.subAddress(0, address.size() - 4); PathAddress subsystemAddress = rootAddress.append(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "datasources")); Resource subsystem = context.readResourceFromRoot(subsystemAddress); for (String type : Arrays.asList("data-source", "xa-data-source")) { Resource resource = subsystem.getChild(PathElement.pathElement(type, poolName)); if (resource != null) { return resource.getModel().get("jndi-name"); } } throw InfinispanLogger.ROOT_LOGGER.dataSourceNotFound(poolName); }; }
private static String getRuntimeName(final OperationContext context, final PathElement element) { final ModelNode deploymentModel = context.readResourceFromRoot(PathAddress.pathAddress(element), false).getModel(); if (!deploymentModel.hasDefined(ModelDescriptionConstants.RUNTIME_NAME)) { throw BatchLogger.LOGGER.couldNotFindDeploymentName(context.getCurrentAddress().toString()); } return deploymentModel.get(ModelDescriptionConstants.RUNTIME_NAME).asString(); } }
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode recoveryEnvModel) throws OperationFailedException { final String configPropertyValue = CONFIG_PROPERTY_VALUE.resolveModelAttribute(context, recoveryEnvModel).asString(); final ModelNode address = operation.require(OP_ADDR); PathAddress path = PathAddress.pathAddress(address); final String archiveName = path.getElement(path.size() -2).getValue(); final String configPropertyName = PathAddress.pathAddress(address).getLastElement().getValue(); ServiceName serviceName = ServiceName.of(ConnectorServices.RA_SERVICE, archiveName, configPropertyName); ServiceName raServiceName = ServiceName.of(ConnectorServices.RA_SERVICE, archiveName); final ServiceTarget serviceTarget = context.getServiceTarget(); final ConfigPropertiesService service = new ConfigPropertiesService(configPropertyName, configPropertyValue); serviceTarget.addService(serviceName, service).setInitialMode(ServiceController.Mode.ACTIVE) .addDependency(raServiceName, ModifiableResourceAdapter.class, service.getRaInjector() ) .install(); } }
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final PathAddress address = context.getCurrentAddress(); final PathAddress serverAddress = address.getParent(); final PathAddress subsystemAddress = serverAddress.getParent(); final ModelNode subsystemModel = Resource.Tools.readModel(context.readResourceFromRoot(subsystemAddress, false), 0); final ModelNode serverModel = Resource.Tools.readModel(context.readResourceFromRoot(serverAddress, false), 0); final ServiceBuilder<Host> builder = context.getCapabilityServiceTarget().addCapability(HostDefinition.HOST_CAPABILITY, service) .addCapabilityRequirement(Capabilities.CAPABILITY_SERVER, Server.class, service.getServerInjection(), serverName) .addCapabilityRequirement(Capabilities.CAPABILITY_UNDERTOW, UndertowService.class, service.getUndertowService()) if (context.getProcessType() == ProcessType.STANDALONE_SERVER) { final ConsoleRedirectService redirectService = new ConsoleRedirectService(); final ServiceBuilder<ConsoleRedirectService> redirectBuilder = context.getServiceTarget().addService(consoleRedirectName, redirectService) .addDependency(UndertowHttpManagementService.SERVICE_NAME, HttpManagement.class, redirectService.getHttpManagementInjector()) .addDependency(virtualHostServiceName, Host.class, redirectService.getHostInjector()) final ServiceBuilder<ConsoleRedirectService> redirectBuilder = context.getServiceTarget().addService(consoleRedirectName, redirectService) .addDependency(virtualHostServiceName, Host.class, redirectService.getHostInjector()) .setInitialMode(Mode.PASSIVE);
@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 protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { // Cache the TransactionManager service name for use by our runtime services ConnectorServices.registerCapabilityServiceName(LOCAL_TRANSACTION_PROVIDER_CAPABILITY, context.getCapabilityServiceName(LOCAL_TRANSACTION_PROVIDER_CAPABILITY, null)); final Resource subsystemResource = context.readResourceFromRoot(PathAddress.pathAddress(ResourceAdaptersExtension.SUBSYSTEM_PATH)); ResourceAdaptersSubsystemService service = new ResourceAdaptersSubsystemService(); CopyOnWriteArrayListMultiMap<String, ServiceName> value = service.getValue(); for (Resource.ResourceEntry re : subsystemResource.getChildren(RESOURCEADAPTER_NAME)) { value.putIfAbsent(re.getModel().get(ARCHIVE.getName()).asString(), ConnectorServices.RA_SERVICE.append(re.getName())); } final ServiceBuilder<?> builder = context.getServiceTarget().addService(ConnectorServices.RESOURCEADAPTERS_SUBSYSTEM_SERVICE, service); builder.setInitialMode(ServiceController.Mode.ACTIVE).install(); } }
@Override protected void handleNode(OperationContext context, ModClusterStatus.LoadBalancer ctx, ModelNode operation) throws OperationFailedException { final String stickySessionCookie = ctx.getStickySessionCookie(); if(stickySessionCookie == null) { context.getResult().set(new ModelNode()); } else { context.getResult().set(new ModelNode(stickySessionCookie)); } } });
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); final String name = address.getLastElement().getValue(); int bufferSize = BufferCacheDefinition.BUFFER_SIZE.resolveModelAttribute(context, model).asInt(); int buffersPerRegions = BufferCacheDefinition.BUFFERS_PER_REGION.resolveModelAttribute(context, model).asInt(); int maxRegions = BufferCacheDefinition.MAX_REGIONS.resolveModelAttribute(context, model).asInt(); final BufferCacheService service = new BufferCacheService(bufferSize, buffersPerRegions, maxRegions); final ServiceTarget target = context.getServiceTarget(); target.addService(BufferCacheService.SERVICE_NAME.append(name), service) .setInitialMode(ServiceController.Mode.ON_DEMAND) .install(); } }
private boolean checkJtsEnabled(final OperationContext context) { try { final ModelNode jtsNode = context.readResourceFromRoot(PathAddress.pathAddress("subsystem", "transactions"), false) .getModel().get("jts"); return jtsNode.isDefined() ? jtsNode.asBoolean() : false; } catch (NoSuchResourceException ex) { return false; } } }
@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()); } } }
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); } }