Java Code Examples for org.jboss.as.controller.OperationContext#getCurrentAddressValue()
The following examples show how to use
org.jboss.as.controller.OperationContext#getCurrentAddressValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FilterResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override protected void populateModel(final OperationContext context, final ModelNode operation, final Resource resource) throws OperationFailedException { // Check the name isn't a reserved filter name final String name = context.getCurrentAddressValue(); if (reservedNames.contains(name)) { throw LoggingLogger.ROOT_LOGGER.reservedFilterName(name, reservedNames); } // Check the name has no special characters if (!Character.isJavaIdentifierStart(name.charAt(0))) { throw LoggingLogger.ROOT_LOGGER.invalidFilterNameStart(name, name.charAt(0)); } for (char c : name.toCharArray()) { if (!Character.isJavaIdentifierPart(c)) { throw LoggingLogger.ROOT_LOGGER.invalidFilterName(name, c); } } super.populateModel(context, operation, resource); }
Example 2
Source File: CustomComponentDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { ServiceTarget serviceTarget = context.getServiceTarget(); String address = context.getCurrentAddressValue(); RuntimeCapability<?> primaryCapability = runtimeCapabilities[0]; ServiceName primaryServiceName = toServiceName(primaryCapability, address); final String module = MODULE.resolveModelAttribute(context, model).asStringOrNull(); final String className = CLASS_NAME.resolveModelAttribute(context, model).asString(); final Map<String, String> configurationMap; configurationMap = CONFIGURATION.unwrap(context, model); ServiceBuilder<?> serviceBuilder = serviceTarget.addService(primaryServiceName); for (int i = 1; i < runtimeCapabilities.length; i++) { serviceBuilder.addAliases(toServiceName(runtimeCapabilities[i], address)); } commonRequirements(serviceBuilder) .setInstance(new TrivialService<>(() -> createValue(module, className, configurationMap))) .setInitialMode(Mode.ACTIVE) .install(); }
Example 3
Source File: OutboundSocketBindingWriteHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Boolean> handbackHolder) throws OperationFailedException { final String bindingName = context.getCurrentAddressValue(); final ModelNode bindingModel = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); final ServiceName serviceName = OUTBOUND_SOCKET_BINDING_CAPABILITY.getCapabilityServiceName(bindingName, OutboundSocketBinding.class); final ServiceController<?> controller = context.getServiceRegistry(true).getRequiredService(serviceName); final OutboundSocketBinding binding = controller.getState() == ServiceController.State.UP ? OutboundSocketBinding.class.cast(controller.getValue()) : null; final boolean bound = binding != null && binding.isConnected(); // FIXME see if this can be used, or remove if (binding == null) { // existing is not started, so can't "update" it. Instead reinstall the service handleBindingReinstall(context, bindingModel, serviceName); handbackHolder.setHandback(Boolean.TRUE); } else { // We don't allow runtime changes without a context reload for outbound socket bindings // since any services which might have already injected/depended on the outbound // socket binding service would have use the (now stale) attributes. context.reloadRequired(); } return false; // we handle the reloadRequired stuff ourselves; it's clearer }
Example 4
Source File: ScheduledThreadPoolWriteAttributeHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override protected ServiceController<?> getService(final OperationContext context, final ModelNode model) throws OperationFailedException { final String name = context.getCurrentAddressValue(); ServiceName serviceName = null; ServiceController<?> controller = null; if(capability != null) { serviceName = capability.getCapabilityServiceName(context.getCurrentAddress()); controller = context.getServiceRegistry(true).getService(serviceName); if(controller != null) { return controller; } } if (serviceNameBase != null) { serviceName = serviceNameBase.append(name); controller = context.getServiceRegistry(true).getService(serviceName); } if(controller == null) { throw ThreadsLogger.ROOT_LOGGER.scheduledThreadPoolServiceNotFound(serviceName); } return controller; }
Example 5
Source File: LdapRealmDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { ServiceTarget serviceTarget = context.getServiceTarget(); String address = context.getCurrentAddressValue(); ServiceName mainServiceName = MODIFIABLE_SECURITY_REALM_RUNTIME_CAPABILITY.fromBaseCapability(address).getCapabilityServiceName(); ServiceName aliasServiceName = SECURITY_REALM_RUNTIME_CAPABILITY.fromBaseCapability(address).getCapabilityServiceName(); final LdapSecurityRealmBuilder builder = LdapSecurityRealmBuilder.builder(); if (DIRECT_VERIFICATION.resolveModelAttribute(context, model).asBoolean()) { boolean allowBlankPassword = ALLOW_BLANK_PASSWORD.resolveModelAttribute(context, model).asBoolean(); builder.addDirectEvidenceVerification(allowBlankPassword); } TrivialService<SecurityRealm> ldapRealmService = new TrivialService<>(builder::build); ServiceBuilder<SecurityRealm> serviceBuilder = serviceTarget.addService(mainServiceName, ldapRealmService) .addAliases(aliasServiceName); commonDependencies(serviceBuilder); configureIdentityMapping(context, model, builder); configureDirContext(context, model, builder, serviceBuilder); serviceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install(); }
Example 6
Source File: HandlerOperations.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model, final LogContextConfiguration logContextConfiguration) throws OperationFailedException { final String name = context.getCurrentAddressValue(); final HandlerConfiguration configuration = logContextConfiguration.getHandlerConfiguration(name); if (configuration == null) { throw createOperationFailure(LoggingLogger.ROOT_LOGGER.handlerConfigurationNotFound(name)); } // Get the handler name, uses the operation to get the single handler name being added final String handlerName = HANDLER_NAME.resolveModelAttribute(context, operation).asString(); if (name.equals(handlerName)) { throw createOperationFailure(LoggingLogger.ROOT_LOGGER.cannotAddHandlerToSelf(configuration.getName())); } if (configuration.getHandlerNames().contains(handlerName)) { LoggingLogger.ROOT_LOGGER.tracef("Handler %s is already assigned to handler %s", handlerName, handlerName); } else { configuration.addHandlerName(handlerName); } }
Example 7
Source File: BindingRemoveHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { String name = context.getCurrentAddressValue(); ServiceName svcName = SOCKET_BINDING_CAPABILITY.getCapabilityServiceName(name); ServiceRegistry registry = context.getServiceRegistry(true); ServiceController<?> controller = registry.getService(svcName); if (controller != null) { // We didn't remove it, we just set reloadRequired context.revertReloadRequired(); } else { try { BindingAddHandler.installBindingService(context, model, name); }catch (UnknownHostException e) { throw new OperationFailedException(e.toString()); } } }
Example 8
Source File: PatternFormatterResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model, final LogContextConfiguration logContextConfiguration) throws OperationFailedException { final String name = context.getCurrentAddressValue(); if (name.endsWith(DEFAULT_FORMATTER_SUFFIX)) { throw LoggingLogger.ROOT_LOGGER.illegalFormatterName(); } FormatterConfiguration configuration = logContextConfiguration.getFormatterConfiguration(name); if (configuration == null) { LoggingLogger.ROOT_LOGGER.tracef("Adding formatter '%s' at '%s'", name, context.getCurrentAddress()); configuration = logContextConfiguration.addFormatterConfiguration(null, PatternFormatter.class.getName(), name); } for (PropertyAttributeDefinition attribute : ATTRIBUTES) { attribute.setPropertyValue(context, model, configuration); } }
Example 9
Source File: CustomFormatterResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model, final LogContextConfiguration logContextConfiguration) throws OperationFailedException { final String name = context.getCurrentAddressValue(); FormatterConfiguration configuration = logContextConfiguration.getFormatterConfiguration(name); final String className = CLASS.resolveModelAttribute(context, model).asString(); final ModelNode moduleNameNode = MODULE.resolveModelAttribute(context, model); final String moduleName = moduleNameNode.isDefined() ? moduleNameNode.asString() : null; final ModelNode properties = PROPERTIES.resolveModelAttribute(context, model); if (configuration != null) { if (!className.equals(configuration.getClassName()) || (moduleName == null ? configuration.getModuleName() != null : !moduleName.equals(configuration.getModuleName()))) { LoggingLogger.ROOT_LOGGER.tracef("Replacing formatter '%s' at '%s'", name, context.getCurrentAddress()); logContextConfiguration.removeFormatterConfiguration(name); configuration = logContextConfiguration.addFormatterConfiguration(moduleName, className, name); } } else { LoggingLogger.ROOT_LOGGER.tracef("Adding formatter '%s' at '%s'", name, context.getCurrentAddress()); configuration = logContextConfiguration.addFormatterConfiguration(moduleName, className, name); } if (properties.isDefined()) { for (Property property : properties.asPropertyList()) { configuration.setPropertyValueString(property.getName(), property.getValue().asString()); } } }
Example 10
Source File: QueuelessThreadPoolWriteAttributeHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override protected ServiceController<?> getService(final OperationContext context, final ModelNode model) throws OperationFailedException { final String name = context.getCurrentAddressValue(); ServiceName serviceName = null; ServiceController<?> controller = null; if(capability != null) { serviceName = capability.getCapabilityServiceName(context.getCurrentAddress()); controller = context.getServiceRegistry(true).getService(serviceName); if(controller != null) { return controller; } } if (serviceNameBase != null) { serviceName = serviceNameBase.append(name); controller = context.getServiceRegistry(true).getService(serviceName); } if(controller == null) { throw ThreadsLogger.ROOT_LOGGER.queuelessThreadPoolServiceNotFound(serviceName); } return controller; }
Example 11
Source File: LogFileResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { final ModelNode model = context.getResult(); final String name = context.getCurrentAddressValue(); final String logDir = pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath(); validateFile(context, logDir, name); final Path path = Paths.get(logDir, name); if (Files.notExists(path)) { throw LoggingLogger.ROOT_LOGGER.logFileNotFound(name, logDir); } try { updateModel(path, model); } catch (IOException e) { throw new RuntimeException(e); } context.completeStep(ResultHandler.NOOP_RESULT_HANDLER); }
Example 12
Source File: FilterResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model, final LogContextConfiguration logContextConfiguration) throws OperationFailedException { final String name = context.getCurrentAddressValue(); final FilterConfiguration configuration = logContextConfiguration.getFilterConfiguration(name); if (configuration == null) { throw LoggingLogger.ROOT_LOGGER.filterNotFound(name); } logContextConfiguration.removeFilterConfiguration(name); }
Example 13
Source File: HandlerOperations.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public final void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model, final LogContextConfiguration logContextConfiguration) throws OperationFailedException { final String name = context.getCurrentAddressValue(); final HandlerConfiguration configuration = logContextConfiguration.getHandlerConfiguration(name); if (configuration == null) { throw createOperationFailure(LoggingLogger.ROOT_LOGGER.handlerConfigurationNotFound(name)); } final AttributeDefinition[] attributes = getAttributes(); if (attributes != null) { boolean restartRequired = false; boolean reloadRequired = false; for (AttributeDefinition attribute : attributes) { // Only update if the attribute is on the operation if (operation.has(attribute.getName())) { handleProperty(attribute, context, model, logContextConfiguration, configuration); restartRequired = restartRequired || Logging.requiresRestart(attribute.getFlags()); reloadRequired = reloadRequired || Logging.requiresReload(attribute.getFlags()); } } if (restartRequired) { context.restartRequired(); } else if (reloadRequired) { context.reloadRequired(); } } // It's important that properties are written in the correct order, reorder the properties if // needed before the commit. addOrderPropertiesStep(context, propertySorter, configuration); }
Example 14
Source File: WorkerResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static XnioWorker getXnioWorker(OperationContext context) { String name = context.getCurrentAddressValue(); if (!context.getCurrentAddress().getLastElement().getKey().equals(IOExtension.WORKER_PATH.getKey())) { //we are somewhere deeper, lets find worker name for (PathElement pe : context.getCurrentAddress()) { if (pe.getKey().equals(IOExtension.WORKER_PATH.getKey())) { name = pe.getValue(); break; } } } return getXnioWorker(context.getServiceRegistry(false), name); }
Example 15
Source File: InterfaceAddHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { String name = context.getCurrentAddressValue(); ParsedInterfaceCriteria parsed = getCriteria(context, operation); if (parsed.getFailureMessage() != null) { throw new OperationFailedException(parsed.getFailureMessage()); } performRuntime(context, operation, model, name, parsed); }
Example 16
Source File: PatternFormatterResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model, final LogContextConfiguration logContextConfiguration) throws OperationFailedException { final String name = context.getCurrentAddressValue(); final FormatterConfiguration configuration = logContextConfiguration.getFormatterConfiguration(name); if (configuration == null) { throw createOperationFailure(LoggingLogger.ROOT_LOGGER.formatterNotFound(name)); } logContextConfiguration.removeFormatterConfiguration(name); }
Example 17
Source File: UpdateScannerWriteAttributeHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected boolean applyUpdateToRuntime(final OperationContext context, final ModelNode operation, final String attributeName, final ModelNode resolvedValue, final ModelNode currentValue, final HandbackHolder<DeploymentScanner> handbackHolder) throws OperationFailedException { final String name = context.getCurrentAddressValue(); final ServiceController<?> controller = context.getServiceRegistry(true).getRequiredService(DeploymentScannerService.getServiceName(name)); if (controller.getState() == ServiceController.State.UP) {// https://issues.jboss.org/browse/WFCORE-1635 DeploymentScanner scanner = (DeploymentScanner) controller.getValue(); updateScanner(attributeName, scanner, resolvedValue); handbackHolder.setHandback(scanner); } return false; }
Example 18
Source File: ThreadFactoryAdd.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException { ModelNode priorityModelNode = PoolAttributeDefinitions.PRIORITY.resolveModelAttribute(context, model); ModelNode groupNameModelNode = PoolAttributeDefinitions.GROUP_NAME.resolveModelAttribute(context, model); ModelNode threadNamePatternModelNode = PoolAttributeDefinitions.THREAD_NAME_PATTERN.resolveModelAttribute(context, model); final String threadNamePattern = threadNamePatternModelNode.isDefined() ? threadNamePatternModelNode.asString() : null; final Integer priority = priorityModelNode.isDefined() ? priorityModelNode.asInt() : null; final String groupName = groupNameModelNode.isDefined() ? groupNameModelNode.asString() : null; final String name = context.getCurrentAddressValue(); final ServiceTarget target = context.getServiceTarget(); final ThreadFactoryService service = new ThreadFactoryService(); service.setNamePattern(threadNamePattern); service.setPriority(priority); service.setThreadGroupName(groupName); if (cap != null) { target.addService(cap.getCapabilityServiceName(context.getCurrentAddress()), service) .addAliases(ThreadsServices.threadFactoryName(name)) .setInitialMode(ServiceController.Mode.ACTIVE) .install(); } else { target.addService(ThreadsServices.threadFactoryName(name), service) .setInitialMode(ServiceController.Mode.ACTIVE) .install(); } }
Example 19
Source File: OutboundSocketBindingWriteHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, Boolean handback) throws OperationFailedException { if (handback != null && handback.booleanValue()) { final String bindingName = context.getCurrentAddressValue(); final ModelNode bindingModel = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); // Back to the old service revertBindingReinstall(context, bindingName, bindingModel, attributeName, valueToRestore); } else { context.revertReloadRequired(); } }
Example 20
Source File: StructuredFormatterResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@SuppressWarnings({"OverlyStrongTypeCast", "StatementWithEmptyBody"}) @Override public void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model, final LogContextConfiguration logContextConfiguration) throws OperationFailedException { String keyOverrides = null; if (model.hasDefined(KEY_OVERRIDES.getName())) { keyOverrides = modelValueToMetaData(KEY_OVERRIDES.resolveModelAttribute(context, model)); } final String name = context.getCurrentAddressValue(); if (name.endsWith(PatternFormatterResourceDefinition.DEFAULT_FORMATTER_SUFFIX)) { throw LoggingLogger.ROOT_LOGGER.illegalFormatterName(); } FormatterConfiguration configuration = logContextConfiguration.getFormatterConfiguration(name); final String className = type.getName(); if (configuration == null) { LoggingLogger.ROOT_LOGGER.tracef("Adding formatter '%s' at '%s'", name, context.getCurrentAddress()); if (keyOverrides == null) { configuration = logContextConfiguration.addFormatterConfiguration(null, className, name); } else { configuration = logContextConfiguration.addFormatterConfiguration(null, className, name, "keyOverrides"); configuration.setPropertyValueString("keyOverrides", keyOverrides); } } else if (isSamePropertyValue(configuration, "keyOverrides", keyOverrides)) { LoggingLogger.ROOT_LOGGER.tracef("Removing then adding formatter '%s' at '%s'", name, context.getCurrentAddress()); logContextConfiguration.removeFormatterConfiguration(name); configuration = logContextConfiguration.addFormatterConfiguration(null, className, name, "keyOverrides"); configuration.setPropertyValueString("keyOverrides", keyOverrides); } // Process the attributes for (AttributeDefinition attribute : attributes) { if (attribute == META_DATA) { final String metaData = modelValueToMetaData(META_DATA.resolveModelAttribute(context, model)); if (metaData != null) { if (isSamePropertyValue(configuration, "metaData", metaData)) { configuration.setPropertyValueString("metaData", metaData); } } else { configuration.removeProperty("metaData"); } } else if (attribute == KEY_OVERRIDES) { // Ignore the key-overrides as it was already taken care of } else { if (attribute instanceof PropertyAttributeDefinition) { ((PropertyAttributeDefinition) attribute).setPropertyValue(context, model, configuration); } else { final ModelNode value = attribute.resolveModelAttribute(context, model); if (value.isDefined()) { if (isSamePropertyValue(configuration, attribute.getName(), value.asString())) { configuration.setPropertyValueString(attribute.getName(), value.asString()); } } else { configuration.removeProperty(attribute.getName()); } } } } }