@Override @SuppressWarnings("deprecation") public Resource getRootResource() { return primaryContext.getRootResource(); }
context.getRootResource().navigate(PathAddress.pathAddress(PathElement.pathElement(PROFILE, profile))); } catch (NoSuchElementException e) { throw new OperationFailedException(new ModelNode().set(String.format("Unknown %s %s", PROFILE, profile))); context.getRootResource().navigate(PathAddress.pathAddress(PathElement.pathElement(SOCKET_BINDING_GROUP, socketBindingGroup))); } catch (NoSuchElementException e) { throw new OperationFailedException(new ModelNode().set(String.format("Unknown %s %s", SOCKET_BINDING_GROUP, socketBindingGroup)));
protected void performRemove(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final String deploymentName = PathAddress.pathAddress(operation.require(OP_ADDR)).getLastElement().getValue(); final Resource root = context.getRootResource(); 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) { String msg = String.format("Cannot remove deployment %s from the domain as it is still used by server groups %s", deploymentName, badGroups); throw new OperationFailedException(new ModelNode().set(msg)); } } super.performRemove(context, operation, model); }
} else { final ModelNode domainModel = Resource.Tools.readModel(context.getRootResource()); ParsedOp.ServerOperationProvider provider = new ParsedOp.ServerOperationProvider() {
void addSteps(final OperationContext context, final ModelNode operation, final ModelNode response, final boolean recordResponse) throws OperationFailedException { final PathAddress originalAddress = PathAddress.pathAddress(operation.get(OP_ADDR)); final ImmutableManagementResourceRegistration originalRegistration = context.getResourceRegistration(); if (originalRegistration == null) { String operationName = operation.require(OP).asString(); throw new OperationFailedException(new ModelNode().set(String.format("No handler for operation %s at address %s", operationName, originalAddress))); } final Resource root = context.getRootResource(); final ModelNode model = Resource.Tools.readModel(root); ParsedOp parsedOp = parseOperation(operation, 0, model); ModelNode domainOp = parsedOp.getDomainOperation(); if (domainOp.isDefined()) { addBasicStep(context, domainOp); } else { response.get(RESULT).set(IGNORED); } ServerOperationResolver resolver = new ServerOperationResolver(localHostControllerInfo.getLocalHostName()); ServerOperationsResolverHandler sorh = new ServerOperationsResolverHandler(localHostControllerInfo.getLocalHostName(), resolver, parsedOp, originalAddress, originalRegistration, response, recordResponse); context.addStep(sorh, OperationContext.Stage.DOMAIN); }
/** * {@inheritDoc} */ public void execute(OperationContext context, ModelNode operation) { final ModelNode opAddr = operation.get(OP_ADDR); PathAddress address = PathAddress.pathAddress(opAddr); String name = address.getLastElement().getValue(); final Resource deploymentResource = context.getRootResource().navigate(PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT, name))); ModelNode deployment = deploymentResource.getModel(); for (ModelNode content : deployment.require(CONTENT).asList()) { if ((content.hasDefined(HASH))) { byte[] hash = content.require(HASH).asBytes(); // Ensure the local repo has the files fileRepository.getDeploymentFiles(hash); } } final String runtimeName = operation.hasDefined(RUNTIME_NAME) ? operation.get(RUNTIME_NAME).asString() : deployment.get(RUNTIME_NAME).asString(); final Resource resource = context.createResource(PathAddress.EMPTY_ADDRESS); final ModelNode subModel = resource.getModel(); subModel.get(NAME).set(name); subModel.get(RUNTIME_NAME).set(runtimeName); subModel.get(ENABLED).set(operation.has(ENABLED) && operation.get(ENABLED).asBoolean()); // TODO consider starting context.completeStep(); } }
final Set<Resource.ResourceEntry> deploymentResource = context.getOperationContext().getRootResource().getChildren(DEPLOYMENT); for (final Resource.ResourceEntry entry : deploymentResource) { final ServiceController<?> deploymentUnitServiceController = serviceRegistry.getService(ServiceName.JBOSS.append("deployment", "unit", entry.getName()));
try { domainDeployment = context.getRootResource().requireChild(deploymentPath); } catch (Exception e) { throw operationFailed(String.format("No deployment with name %s found", name));