Java Code Examples for org.jboss.as.controller.OperationContext#readResourceFromRoot()
The following examples show how to use
org.jboss.as.controller.OperationContext#readResourceFromRoot() .
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: ReadMasterDomainModelHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { // if the calling process has already acquired a lock, don't relock. if (lock) { context.acquireControllerLock(); } final Transformers.ResourceIgnoredTransformationRegistry ignoredTransformationRegistry; final Resource resource = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS); // The host info is only null in the tests if (hostInfo == null) { ignoredTransformationRegistry = Transformers.DEFAULT; } else { final ReadMasterDomainModelUtil.RequiredConfigurationHolder rc = hostInfo.populateRequiredConfigurationHolder(resource, extensionRegistry); ignoredTransformationRegistry = ReadMasterDomainModelUtil.createHostIgnoredRegistry(hostInfo, rc); } final OperationStepHandler handler = new ReadDomainModelHandler(ignoredTransformationRegistry, transformers, lock); context.addStep(handler, OperationContext.Stage.MODEL); }
Example 2
Source File: AbstractOrderedChildResourceSyncModelTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final ModelNode syncOperation = new ModelNode(); syncOperation.get(OP).set("calculate-diff-and-sync"); syncOperation.get(OP_ADDR).setEmptyList(); syncOperation.get(DOMAIN_MODEL).set(operation.get(DOMAIN_MODEL)); Resource original = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS); final TestRepository repo = new TestRepository(); final HostControllerRegistrationHandler.OperationExecutor internalExecutor = getControllerService().getInternalExecutor(); SyncModelParameters parameters = new SyncModelParameters(new MockDomainController(), ignoredDomainResourceRegistry, hostControllerEnvironment, extensionRegistry, internalExecutor, true, Collections.<String, ProxyController>emptyMap(), repo, repo); final SyncServerGroupOperationHandler handler = new SyncServerGroupOperationHandler("slave", original, parameters); context.addStep(syncOperation, handler, OperationContext.Stage.MODEL, true); }
Example 3
Source File: DeploymentOverlayIndex.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private static void handleContent(OperationContext context, Map<String, Map<String, byte[]>> wildcards, String overlay, String deployment) { Map<String, byte[]> contentMap = wildcards.get(deployment); if(contentMap == null) { wildcards.put(deployment, contentMap = new HashMap<String, byte[]>()); } Set<String> content = context.readResourceFromRoot(PathAddress.pathAddress(pathElement(DEPLOYMENT_OVERLAY, overlay))).getChildrenNames(CONTENT); for(String contentItem : content) { Resource cr = context.readResourceFromRoot(PathAddress.pathAddress(pathElement(DEPLOYMENT_OVERLAY, overlay), pathElement(CONTENT, contentItem))); ModelNode sha; try { sha = DeploymentOverlayContentDefinition.CONTENT_ATTRIBUTE.resolveModelAttribute(context, cr.getModel()); } catch (OperationFailedException e) { throw new RuntimeException(e); } String key = contentItem.startsWith("/") ? contentItem.substring(1) : contentItem; contentMap.put(key, sha.asBytes()); } }
Example 4
Source File: DeploymentRemoveHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
protected void checkCanRemove(OperationContext context, ModelNode operation) throws OperationFailedException { final String deploymentName = PathAddress.pathAddress(operation.require(OP_ADDR)).getLastElement().getValue(); final Resource root = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS); if(root.hasChild(PathElement.pathElement(SERVER_GROUP))) { final List<String> badGroups = new ArrayList<String>(); for(final Resource.ResourceEntry entry : root.getChildren(SERVER_GROUP)) { if(entry.hasChild(PathElement.pathElement(DEPLOYMENT, deploymentName))) { badGroups.add(entry.getName()); } } if (badGroups.size() > 0) { throw new OperationFailedException(DomainControllerLogger.ROOT_LOGGER.cannotRemoveDeploymentInUse(deploymentName, badGroups)); } } }
Example 5
Source File: HandlerUtil.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
static void checkNoOtherHandlerWithTheSameName(OperationContext context) throws OperationFailedException { final PathAddress address = context.getCurrentAddress(); final PathAddress parentAddress = address.subAddress(0, address.size() - 1); final Resource resource = context.readResourceFromRoot(parentAddress); final PathElement element = address.getLastElement(); final String handlerType = element.getKey(); final String handlerName = element.getValue(); for (String otherHandler: HANDLER_TYPES) { if (handlerType.equals(otherHandler)) { // we need to check other handler types for the same name continue; } final PathElement check = PathElement.pathElement(otherHandler, handlerName); if (resource.hasChild(check)) { throw DomainManagementLogger.ROOT_LOGGER.handlerAlreadyExists(check.getValue(), parentAddress.append(check)); } } }
Example 6
Source File: DeploymentAddHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private void validateRuntimeNames(String deploymentName, OperationContext context) throws OperationFailedException { ModelNode deployment = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); if (ENABLED.resolveModelAttribute(context, deployment).asBoolean()) { String runtimeName = getRuntimeName(deploymentName, deployment); Resource root = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS); for (Resource.ResourceEntry re : root.getChildren(DEPLOYMENT)) { String reName = re.getName(); if (!deploymentName.equals(reName)) { ModelNode otherDepl = re.getModel(); if (ENABLED.resolveModelAttribute(context, otherDepl).asBoolean()) { String otherRuntimeName = getRuntimeName(reName, otherDepl); if (runtimeName.equals(otherRuntimeName)) { throw ServerLogger.ROOT_LOGGER.runtimeNameMustBeUnique(reName, runtimeName); } } } } } }
Example 7
Source File: SyslogAuditLogHandlerResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static SyslogAuditLogHandler createHandler(final PathManagerService pathManager, final OperationContext context, final EnvironmentNameReader environmentReader) throws OperationFailedException { final PathAddress pathAddress = getAffectedHandlerAddress(context); final String name = Util.getNameFromAddress(pathAddress); final Resource handlerResource = context.readResourceFromRoot(pathAddress); return createHandler(pathManager, context, name, handlerResource, environmentReader); }
Example 8
Source File: AffectedDeploymentOverlay.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Returns all the deployment runtime names associated with an overlay. * * @param context the current OperationContext. * @param overlayAddress the address for the averlay. * @return all the deployment runtime names associated with an overlay. */ public static Set<String> listLinks(OperationContext context, PathAddress overlayAddress) { Resource overlayResource = context.readResourceFromRoot(overlayAddress); if (overlayResource.hasChildren(DEPLOYMENT)) { return overlayResource.getChildrenNames(DEPLOYMENT); } return Collections.emptySet(); }
Example 9
Source File: DeploymentOverlayAdd.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { //check that if this is a server group level op the referenced deployment overlay exists final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); if (address.size() > 1) { final String name = address.getLastElement().getValue(); context.readResourceFromRoot(PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT_OVERLAY, name))); } super.execute(context, operation); }
Example 10
Source File: PrincipalAdd.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void validateUniqueness(final OperationContext context, final String roleName, final PathAddress roleAddress, final AuthorizerConfiguration.PrincipalType principalType, final String realm, final String name) throws OperationFailedException { Resource roleResource = context.readResourceFromRoot(roleAddress); ModelNode model = Resource.Tools.readModel(roleResource); int matchesFound = 0; for (Property current : getIncludeExclude(model)) { if (matches(context, current.getValue(), principalType, realm, name)) { if (++matchesFound > 1) { throw DomainManagementLogger.ROOT_LOGGER.duplicateIncludeExclude(roleName, matchType.toString(), principalType.toString(), name, realm != null ? realm : "undefined"); } } } }
Example 11
Source File: SyslogAuditLogHandlerResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { auditLogger.getUpdater().rollbackChanges(); String name = Util.getNameFromAddress(operation.require(OP_ADDR)); final Resource handlerResource = context.readResourceFromRoot(getAffectedHandlerAddress(context)); SyslogAuditLogHandlerService.installService(context, SYSLOG_AUDIT_HANDLER.append(name), handlerResource); }
Example 12
Source File: SyncModelServerStateTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final ModelNode syncOperation = new ModelNode(); syncOperation.get(OP).set("calculate-diff-and-sync"); syncOperation.get(OP_ADDR).setEmptyList(); syncOperation.get(DOMAIN_MODEL).set(operation.get(DOMAIN_MODEL)); Resource original = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS); final HostControllerRegistrationHandler.OperationExecutor internalExecutor = getControllerService().getInternalExecutor(); Map<String, ProxyController> serverProxies = new HashMap<>(); for (Map.Entry<String, MockServerProxy> entry : SyncModelServerStateTestCase.this.serverProxies.entrySet()) { serverProxies.put(entry.getKey(), entry.getValue()); } SyncModelParameters parameters = new SyncModelParameters(new MockDomainController(), ignoredDomainResourceRegistry, hostControllerEnvironment, extensionRegistry, internalExecutor, true, serverProxies, repository, repository); final Resource hostResource = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS).getChildren(HOST).iterator().next(); final ProductConfig cfg = new ProductConfig("product", "version", "main"); final HostInfo hostInfo = HostInfo.fromModelNode( HostInfo.createLocalHostHostInfo(hostControllerInfo, cfg, ignoredDomainResourceRegistry, hostResource)); final SyncDomainModelOperationHandler handler = new SyncDomainModelOperationHandler(hostInfo, parameters); context.addStep(syncOperation, handler, OperationContext.Stage.MODEL, true); }
Example 13
Source File: Transformers.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Creates a new {@code TransformationInputs} from the given operation context. * @param context the operation context. Cannot be {@code null} */ public TransformationInputs(OperationContext context) { this.originalModel = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, true); this.registration = context.getRootResourceRegistration(); this.processType = context.getProcessType(); this.runningMode = context.getRunningMode(); this.transformerOperationAttachment = context.getAttachment(TransformerOperationAttachment.KEY); }
Example 14
Source File: SyslogAuditLogProtocolResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void checkNoOtherProtocol(OperationContext context, ModelNode operation) throws OperationFailedException { PathAddress opAddr = PathAddress.pathAddress(operation.require(OP_ADDR)); PathAddress addr = opAddr.subAddress(0, opAddr.size() - 1); Resource resource = context.readResourceFromRoot(addr); Set<ResourceEntry> existing = resource.getChildren(PROTOCOL); if (existing.size() > 1) { for (ResourceEntry entry : existing) { PathElement mine = addr.getLastElement(); if (!entry.getPathElement().equals(mine)) { throw DomainManagementLogger.ROOT_LOGGER.sysLogProtocolAlreadyConfigured(addr.append(mine)); } } } }
Example 15
Source File: SyslogAuditLogProtocolResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { PathAddress handlerAddress = SyslogAuditLogHandlerResourceDefinition.getAffectedHandlerAddress(context); try { Resource handleResource = context.readResourceFromRoot(handlerAddress); String name = Util.getNameFromAddress(handlerAddress); auditLogger.getUpdater().updateHandler(SyslogAuditLogHandlerResourceDefinition.createHandler(pathManager, context, name, handleResource, environmentReader)); } catch (Resource.NoSuchResourceException ignored) { // WFCORE-810 handler resource has been removed in this same op, so we do nothing } }
Example 16
Source File: ManagementUtil.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static void updateUserDomainCallbackHandler(final OperationContext context, final ModelNode operation, final boolean forRollback) { UserDomainCallbackHandler cbh = getUserDomainCallbackHandler(context, operation); if (cbh != null) { PathAddress authAddress = getXmlAuthenticationAddress(operation); Resource root = forRollback ? context.getOriginalRootResource() : context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS); ModelNode userMap; try { Resource authResource = root.navigate(authAddress); userMap = context.resolveExpressions(Resource.Tools.readModel(authResource)); } catch (Exception e) { userMap = new ModelNode().setEmptyObject(); } cbh.setUserDomain(userMap); } }
Example 17
Source File: ReadFeatureDescriptionHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private String getExtension(OperationContext context, String subsystem) { for (String extensionName : context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false).getChildrenNames(EXTENSION)) { Resource extension = context.readResourceFromRoot(PathAddress.pathAddress(EXTENSION, extensionName), false); if (extension.getChildrenNames(SUBSYSTEM).contains(subsystem)) { return extensionName; } } return null; }
Example 18
Source File: LogStreamExtension.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private void logPropValue(OperationContext context) { Resource res = context.readResourceFromRoot(PathAddress.pathAddress(SYSTEM_PROPERTY, LOG_MESSAGE_PROP)); String key = res.getModel().get(VALUE).asString(); log.info(getLogMessage(key)); }
Example 19
Source File: HandlerUtil.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
static boolean lookForFormatter(OperationContext context, PathAddress addr, String name) { PathAddress referenceAddress = addr.subAddress(0, addr.size() - 1).append(JSON_FORMATTER, name); final Resource root = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS); return lookForResource(root, referenceAddress); }
Example 20
Source File: RemoteDomainConnectionService.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { resource = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS); }