/** * Indicates whether or not this operation expects to include default values. * @param operation an operation * @return true, if default values are expected, false otherwise. */ public static boolean isIncludeDefaults(ModelNode operation) { return operation.hasDefined(ModelDescriptionConstants.INCLUDE_DEFAULTS) ? operation.get(ModelDescriptionConstants.INCLUDE_DEFAULTS).asBoolean() : true; }
public static Boolean getBooleanIfSetOrGetDefault(final OperationContext context, final ModelNode dataSourceNode, final SimpleAttributeDefinition key) throws OperationFailedException { ModelNode resolvedNode = key.resolveModelAttribute(context, dataSourceNode); return resolvedNode.isDefined() ? resolvedNode.asBoolean() : null; }
public WebSocketInfo getConfig(final OperationContext context, final ModelNode model) throws OperationFailedException { if (!model.isDefined()) { return null; } boolean dispatchToWorker = DISPATCH_TO_WORKER.resolveModelAttribute(context, model).asBoolean(); String bufferPool = BUFFER_POOL.resolveModelAttribute(context, model).asString(); String worker = WORKER.resolveModelAttribute(context, model).asString(); boolean perMessageDeflate = PER_MESSAGE_DEFLATE.resolveModelAttribute(context, model).asBoolean(); int deflaterLevel = DEFLATER_LEVEL.resolveModelAttribute(context, model).asInt(); return new WebSocketInfo(worker, bufferPool, dispatchToWorker, perMessageDeflate, deflaterLevel); }
@Override public Map<String, Boolean> getDeploymentsStatus() { final ModelNode op = Util.getEmptyOperation(READ_CHILDREN_RESOURCES_OPERATION, new ModelNode()); op.get(CHILD_TYPE).set(DEPLOYMENT); ModelNode response = privilegedExecution().execute(controllerClient::execute, op); // Ensure the operation succeeded before we use the result if(response.get(OUTCOME).isDefined() && !SUCCESS.equals(response.get(OUTCOME).asString())) throw ROOT_LOGGER.deployModelOperationFailed(response.get(FAILURE_DESCRIPTION).asString()); final ModelNode result = response.get(RESULT); final Map<String, Boolean> deployments = new HashMap<String, Boolean>(); if (result.isDefined()) { for (Property property : result.asPropertyList()) { deployments.put(property.getName(), property.getValue().get(ENABLED).asBoolean(false)); } } return deployments; }
@Override public HttpHandler createHttpHandler(Predicate predicate, ModelNode model, HttpHandler next) { String expression = model.get(TARGET.getName()).asString(); boolean redirect = model.get(REDIRECT.getName()).asBoolean(); if(predicate == null) { return create(next, expression, redirect); } else { return Handlers.predicate(predicate, create(next, expression, redirect), next); } }
private static ServerConfig readServerConfig(final OperationContext operationContext, final ModelNode model) throws OperationFailedException { final String socket = MailServerDefinition.OUTBOUND_SOCKET_BINDING_REF.resolveModelAttribute(operationContext, model).asString(); final Credentials credentials = readCredentials(operationContext, model); boolean ssl = MailServerDefinition.SSL.resolveModelAttribute(operationContext, model).asBoolean(); boolean tls = MailServerDefinition.TLS.resolveModelAttribute(operationContext, model).asBoolean(); return new ServerConfig(socket, credentials, ssl, tls, null); }
private Boolean needRemoting(OperationContext context, ModelNode attributeValue) { // Set up a fake model to resolve the USE_MANAGEMENT_ENDPOINT value ModelNode model = new ModelNode(); model.get(USE_MANAGEMENT_ENDPOINT.getName()).set(attributeValue); try { return !USE_MANAGEMENT_ENDPOINT.resolveModelAttribute(context, model).asBoolean(); } catch (OperationFailedException ofe) { if (model.get(USE_MANAGEMENT_ENDPOINT.getName()).getType() == ModelType.EXPRESSION) { // Must be a vault expression or something we can't resolve in Stage.MODEL. // So we can only do nothing and hope for the best when they reload return null; } throw new IllegalStateException(ofe); } } };
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 void applySetting(final IIOPSettingsService service, OperationContext context, final ModelNode model) throws OperationFailedException { final boolean value = ENABLE_BY_DEFAULT.resolveModelAttribute(context, model).asBoolean(); service.setUseQualifiedName(value); } });
@Override protected void populateModel(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { super.populateModel(context, operation, resource); ModelNode model = resource.getModel(); boolean enableJacc = false; if (model.hasDefined(ENABLE_JACC.getName())) { enableJacc = ENABLE_JACC.resolveModelAttribute(context, model).asBoolean(); } knownApplicationSecurityDomains.add(new ApplicationSecurityDomainConfig(context.getCurrentAddressValue(), enableJacc)); }
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(); } }
@Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.passivation = PASSIVATION.resolveModelAttribute(context, model).asBoolean(); this.fetchState = FETCH_STATE.resolveModelAttribute(context, model).asBoolean(); this.preload = PRELOAD.resolveModelAttribute(context, model).asBoolean(); this.purge = PURGE.resolveModelAttribute(context, model).asBoolean(); this.shared = SHARED.resolveModelAttribute(context, model).asBoolean(); this.maxBatchSize = MAX_BATCH_SIZE.resolveModelAttribute(context, model).asInt(); this.properties.clear(); for (Property property : ModelNodes.optionalPropertyList(PROPERTIES.resolveModelAttribute(context, model)).orElse(Collections.emptyList())) { this.properties.setProperty(property.getName(), property.getValue().asString()); } return this; }
public static List<GlobalModule> createModuleList(final OperationContext context, final ModelNode globalMods) throws OperationFailedException { final List<GlobalModule> ret = new ArrayList<>(); if (globalMods.isDefined()) { for (final ModelNode module : globalMods.asList()) { String name = NAME_AD.resolveModelAttribute(context, module).asString(); String slot = SLOT_AD.resolveModelAttribute(context, module).asString(); boolean annotations = ANNOTATIONS_AD.resolveModelAttribute(context, module).asBoolean(); boolean services = SERVICES_AD.resolveModelAttribute(context, module).asBoolean(); boolean metaInf = META_INF_AD.resolveModelAttribute(context, module).asBoolean(); ret.add(new GlobalModule(ModuleIdentifier.create(name, slot), annotations, services, metaInf)); } } return ret; }
private void validateStoreConfig(ModelNode operation, ModelNode model) throws OperationFailedException { if (operation.hasDefined(USE_JDBC_STORE) && operation.get(USE_JDBC_STORE).asBoolean() && operation.hasDefined(USE_JOURNAL_STORE) && operation.get(USE_JOURNAL_STORE).asBoolean()) { throw TransactionLogger.ROOT_LOGGER.onlyOneCanBeTrue(USE_JDBC_STORE, USE_JOURNAL_STORE); } if (operation.hasDefined(USE_JDBC_STORE) && operation.get(USE_JDBC_STORE).asBoolean() && !operation.hasDefined(JDBC_STORE_DATASOURCE)) { throw TransactionLogger.ROOT_LOGGER.mustBeDefinedIfTrue(JDBC_STORE_DATASOURCE, USE_JDBC_STORE); } }
@Override public Map<String, Boolean> getDeploymentsStatus() { final ModelNode op = Util.getEmptyOperation(READ_CHILDREN_RESOURCES_OPERATION, new ModelNode()); op.get(CHILD_TYPE).set(DEPLOYMENT); ModelNode response = privilegedExecution().execute(controllerClient::execute, op); // Ensure the operation succeeded before we use the result if(response.get(OUTCOME).isDefined() && !SUCCESS.equals(response.get(OUTCOME).asString())) throw ROOT_LOGGER.deployModelOperationFailed(response.get(FAILURE_DESCRIPTION).asString()); final ModelNode result = response.get(RESULT); final Map<String, Boolean> deployments = new HashMap<String, Boolean>(); if (result.isDefined()) { for (Property property : result.asPropertyList()) { deployments.put(property.getName(), property.getValue().get(ENABLED).asBoolean(false)); } } return deployments; }
@Override protected boolean applyUpdateToRuntime(final OperationContext context, final ModelNode operation, final String parameterName, final ModelNode newValue, final ModelNode currentValue, final HandbackHolder<List<DataSource>> handbackHolder) throws OperationFailedException { final String jndiName = context.readResource(PathAddress.EMPTY_ADDRESS).getModel().get(Constants.JNDI_NAME.getName()).asString(); final ServiceController<?> managementRepoService = context.getServiceRegistry(false).getService( ConnectorServices.MANAGEMENT_REPOSITORY_SERVICE); Boolean boolValue = Constants.ENLISTMENT_TRACE.resolveValue(context, newValue).asBoolean(); try { final ManagementRepository repository = (ManagementRepository) managementRepoService.getValue(); if (repository.getDataSources() != null) { for (DataSource dataSource : repository.getDataSources()) { if (jndiName.equalsIgnoreCase(dataSource.getJndiName())) { dataSource.setEnlistmentTrace(boolValue); } } List<DataSource> list = new ArrayList<>(); for (DataSource ds : repository.getDataSources()) { if (jndiName.equalsIgnoreCase(ds.getJndiName())) { list.add(ds); } } handbackHolder.setHandback(list); } } catch (Exception e) { throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.failedToSetAttribute(e.getLocalizedMessage())); } return false; }
private void performCoreEnvironmentBootTime(OperationContext context, ModelNode coreEnvModel) throws OperationFailedException { // Configure the core configuration. final String nodeIdentifier = TransactionSubsystemRootResourceDefinition.NODE_IDENTIFIER.resolveModelAttribute(context, coreEnvModel).asString(); TransactionLogger.ROOT_LOGGER.debugf("nodeIdentifier=%s%n", nodeIdentifier); final CoreEnvironmentService coreEnvironmentService = new CoreEnvironmentService(nodeIdentifier); String socketBindingName = null; if (TransactionSubsystemRootResourceDefinition.PROCESS_ID_UUID.resolveModelAttribute(context, coreEnvModel).asBoolean(false)) { // Use the UUID based id UuidProcessId id = new UuidProcessId(); coreEnvironmentService.setProcessImplementation(id); } else { // Use the socket process id coreEnvironmentService.setProcessImplementationClassName(ProcessIdType.SOCKET.getClazz()); socketBindingName = TransactionSubsystemRootResourceDefinition.PROCESS_ID_SOCKET_BINDING.resolveModelAttribute(context, coreEnvModel).asString(); int ports = TransactionSubsystemRootResourceDefinition.PROCESS_ID_SOCKET_MAX_PORTS.resolveModelAttribute(context, coreEnvModel).asInt(); coreEnvironmentService.setSocketProcessIdMaxPorts(ports); } final ServiceBuilder<?> coreEnvBuilder = context.getServiceTarget().addService(TxnServices.JBOSS_TXN_CORE_ENVIRONMENT, coreEnvironmentService); if (socketBindingName != null) { // Add a dependency on the socket id binding ServiceName bindingName = SocketBinding.JBOSS_BINDING_NAME.append(socketBindingName); coreEnvBuilder.addDependency(bindingName, SocketBinding.class, coreEnvironmentService.getSocketProcessBindingInjector()); } coreEnvBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install(); }