org.jboss.as.controller.OperationFailedException Java Examples

The following examples show how to use org.jboss.as.controller.OperationFailedException. 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: SystemPropertyValueWriteAttributeHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName,
                                       ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<SysPropValue> handbackHolder) throws OperationFailedException {

    final String name = PathAddress.pathAddress(operation.get(OP_ADDR)).getLastElement().getValue();
    String setValue = resolvedValue.isDefined() ? resolvedValue.asString() : null;
    // This method will only be called if systemPropertyUpdater != null (see requiresRuntime())
    final boolean applyToRuntime = systemPropertyUpdater.isRuntimeSystemPropertyUpdateAllowed(name, setValue, context.isBooting());

    if (applyToRuntime) {
        final String oldValue = WildFlySecurityManager.getPropertyPrivileged(name, null);
        if (setValue != null) {
            WildFlySecurityManager.setPropertyPrivileged(name, setValue);
        } else {
            WildFlySecurityManager.clearPropertyPrivileged(name);
        }
        systemPropertyUpdater.systemPropertyUpdated(name, setValue);

        handbackHolder.setHandback(new SysPropValue(name, oldValue));
    }

    return !applyToRuntime;
}
 
Example #2
Source File: WorkerServerDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    XnioWorker worker = getXnioWorker(context);
    if (worker == null || worker.getMXBean() == null) {
        context.getResult().set(IOExtension.NO_METRICS);
        return;
    }
    XnioWorkerMXBean metrics = worker.getMXBean();
    Optional<XnioServerMXBean> serverMetrics = Optional.empty();
    for (XnioServerMXBean xnioServerMXBean : metrics.getServerMXBeans()) {
        if (xnioServerMXBean.getBindAddress().equals(context.getCurrentAddressValue())) {
            serverMetrics = Optional.of(xnioServerMXBean);
            break;
        }
    }
    if (serverMetrics.isPresent()) {
        context.getResult().set(getMetricValue(serverMetrics.get()));
    } else {
        context.getResult().set(IOExtension.NO_METRICS);
    }
}
 
Example #3
Source File: InterfaceCriteriaWriteHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException {
    nameValidator.validate(operation);
    final String attributeName = operation.require(NAME).asString();
    final ModelNode newValue = operation.hasDefined(VALUE) ? operation.get(VALUE) : new ModelNode();
    final ModelNode submodel = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS).getModel();
    final AttributeDefinition attributeDefinition = ATTRIBUTES.get(attributeName);
    if (attributeDefinition != null) {
        final ModelNode syntheticOp = new ModelNode();
        syntheticOp.get(attributeName).set(newValue);
        attributeDefinition.validateAndSet(syntheticOp, submodel);
    } else {
        throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.unknownAttribute(attributeName));
    }
    if (updateRuntime) {
        // Require a reload
        context.reloadRequired();
    }
    // Verify the model in a later step
    context.addStep(VERIFY_HANDLER, OperationContext.Stage.MODEL);
    OperationContext.RollbackHandler rollbackHandler = updateRuntime
            ? OperationContext.RollbackHandler.REVERT_RELOAD_REQUIRED_ROLLBACK_HANDLER
            : OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER;
    context.completeStep(rollbackHandler);
}
 
Example #4
Source File: SpecifiedInterfaceResolveHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void validateAndSet(final AttributeDefinition definition, final ModelNode operation, final ModelNode subModel) throws OperationFailedException {
    final String attributeName = definition.getName();
    final boolean has = operation.has(attributeName);
    if(! has && definition.isRequired(operation)) {
        throw ControllerLogger.ROOT_LOGGER.required(attributeName);
    }
    if(has) {
        if(! definition.isAllowed(operation)) {
            throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.invalid(attributeName));
        }
        definition.validateAndSet(operation, subModel);
    } else {
        // create the undefined node
        subModel.get(definition.getName());
    }
}
 
Example #5
Source File: ManagedDeploymentReadContentHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    if (context.getProcessType() == ProcessType.SELF_CONTAINED) {
        throw DomainControllerLogger.ROOT_LOGGER.cannotReadContentFromSelfContainedServer();
    }
    final Resource deploymentResource = context.readResource(PathAddress.EMPTY_ADDRESS);
    ModelNode contentItemNode = getContentItem(deploymentResource);
    // Validate this op is available
    if (!isManaged(contentItemNode)) {
        throw DomainControllerLogger.ROOT_LOGGER.cannotReadContentFromUnmanagedDeployment();
    }
    final byte[] deploymentHash = CONTENT_HASH.resolveModelAttribute(context, contentItemNode).asBytes();
    final ModelNode contentPath = CONTENT_PATH.resolveModelAttribute(context, operation);
    final String path = contentPath.isDefined() ? contentPath.asString() : "";
    try {
        TypedInputStream inputStream = contentRepository.readContent(deploymentHash, path);
        String uuid = context.attachResultStream(inputStream.getContentType(), inputStream);
        context.getResult().get(UUID).set(uuid);
    } catch (ExplodedContentException ex) {
        throw new OperationFailedException(ex.getMessage());
    }
}
 
Example #6
Source File: ThreadsWriteAttributeOperationHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
static TimeSpec getTimeSpec(OperationContext context, ModelNode model, TimeUnit defaultUnit) throws OperationFailedException {
    ModelNode value = PoolAttributeDefinitions.KEEPALIVE_TIME.resolveModelAttribute(context, model);
    if (!value.hasDefined(TIME)) {
        throw ThreadsLogger.ROOT_LOGGER.missingTimeSpecTime(TIME, KEEPALIVE_TIME);
    }
    final TimeUnit unit;
    if (!value.hasDefined(UNIT)) {
        unit = defaultUnit;
    } else {
        try {
        unit = Enum.valueOf(TimeUnit.class, value.get(UNIT).asString());
        } catch(IllegalArgumentException e) {
            throw ThreadsLogger.ROOT_LOGGER.failedToParseUnit(UNIT, Arrays.asList(TimeUnit.values()));
        }
    }
    return new TimeSpec(unit, value.get(TIME).asLong());
}
 
Example #7
Source File: DeploymentResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {

    for (AttributeDefinition attr : parent.getResourceAttributes()) {
        if (attr.getName().equals(DeploymentAttributes.STATUS.getName())) {
            resourceRegistration.registerMetric(attr, DeploymentStatusHandler.INSTANCE);
        } else if (attr.getName().equals(DeploymentAttributes.NAME.getName())) {
            resourceRegistration.registerReadOnlyAttribute(DeploymentAttributes.NAME, ReadResourceNameOperationStepHandler.INSTANCE);
        } else if (DeploymentAttributes.MANAGED.getName().equals(attr.getName())) {
            resourceRegistration.registerReadOnlyAttribute(DeploymentAttributes.MANAGED, new OperationStepHandler() {
                @Override
                public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
                    ModelNode deployment = context.readResource(PathAddress.EMPTY_ADDRESS, true).getModel();
                    if(deployment.hasDefined(CONTENT_RESOURCE_ALL.getName())) {
                        ModelNode content = deployment.get(CONTENT_RESOURCE_ALL.getName()).asList().get(0);
                        context.getResult().set(!isUnmanagedContent(content));
                    }
                }
            });
        } else {
            resourceRegistration.registerReadOnlyAttribute(attr, null);
        }
    }
}
 
Example #8
Source File: JdbcRealmDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public PasswordKeyMapper toPasswordKeyMapper(OperationContext context, ModelNode propertyNode) throws OperationFailedException {
    String algorithm = ALGORITHM.resolveModelAttribute(context, propertyNode).asStringOrNull();
    int password = PASSWORD.resolveModelAttribute(context, propertyNode).asInt();
    int salt = SALT.resolveModelAttribute(context, propertyNode).asInt();
    int iterationCount = ITERATION_COUNT.resolveModelAttribute(context, propertyNode).asInt();
    String hashEncoding = HASH_ENCODING.resolveModelAttribute(context, propertyNode).asStringOrNull();
    String saltEncoding = SALT_ENCODING.resolveModelAttribute(context, propertyNode).asStringOrNull();

    return PasswordKeyMapper.builder()
            .setDefaultAlgorithm(algorithm)
            .setHashColumn(password)
            .setSaltColumn(salt)
            .setIterationCountColumn(iterationCount)
            .setHashEncoding(HEX.equals(hashEncoding) ? PasswordKeyMapper.Encoding.HEX : PasswordKeyMapper.Encoding.BASE64)
            .setSaltEncoding(HEX.equals(saltEncoding) ? PasswordKeyMapper.Encoding.HEX : PasswordKeyMapper.Encoding.BASE64)
            .build();
}
 
Example #9
Source File: QueuelessThreadPoolWriteAttributeHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@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 #10
Source File: AdvancedModifiableKeyStoreDecorator.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
static CRLReason getCRLReason(String reason) throws OperationFailedException {
    switch (reason.toUpperCase(Locale.ENGLISH)) {
        case UNSPECIFIED:
            return CRLReason.UNSPECIFIED;
        case KEY_COMPROMISE:
            return CRLReason.KEY_COMPROMISE;
        case CA_COMPROMISE:
            return CRLReason.CA_COMPROMISE;
        case AFFILIATION_CHANGED:
            return CRLReason.AFFILIATION_CHANGED;
        case SUPERSEDED:
            return CRLReason.SUPERSEDED;
        case CESSATION_OF_OPERATION:
            return CRLReason.CESSATION_OF_OPERATION;
        case CERTIFICATE_HOLD:
            return CRLReason.CERTIFICATE_HOLD;
        case REMOVE_FROM_CRL:
            return CRLReason.REMOVE_FROM_CRL;
        case PRIVILEGE_WITHDRAWN:
            return CRLReason.PRIVILEGE_WITHDRAWN;
        case AA_COMPROMISE:
            return CRLReason.AA_COMPROMISE;
        default:
            throw ROOT_LOGGER.invalidCertificateRevocationReason(reason);
    }
}
 
Example #11
Source File: ThreadsSubsystemParsingTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testSimpleThreadFactory() throws Exception {
    List<ModelNode> updates = createSubSystem("<thread-factory name=\"test-factory\"/>");
    assertEquals(2, updates.size());
    for (ModelNode update : updates) {
        try {
            executeForResult(update);
        } catch (OperationFailedException e) {
            throw new RuntimeException(e.getFailureDescription().toString());
        }
    }

    ModelNode subsystem = model.require("subsystem").require("threads");
    ModelNode threadFactory = subsystem.require("thread-factory");
    assertEquals(1, threadFactory.keys().size());
}
 
Example #12
Source File: ThreadMXBeanFindDeadlockedThreadsHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {

    try {
        long[] ids = ManagementFactory.getThreadMXBean().findDeadlockedThreads();
        final ModelNode result = context.getResult();
        if (ids != null) {
            result.setEmptyList();
            for (long id : ids) {
                result.add(id);
            }
        }
    } catch (SecurityException e) {
        throw new OperationFailedException(e.toString());
    }
}
 
Example #13
Source File: NillableOrExpressionParameterValidator.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void validateParameter(String parameterName, ModelNode value) throws OperationFailedException {
    switch (value.getType()) {
        case EXPRESSION:
            if (!allowExpression) {
                throw ControllerLogger.ROOT_LOGGER.expressionNotAllowed(parameterName);
            }
            break;
        case UNDEFINED:
            if (allowNull != null) {
                if (!allowNull) {
                    throw ControllerLogger.ROOT_LOGGER.nullNotAllowed(parameterName);
                }
                break;
            } // else fall through and let the delegate validate
        default:
            delegate.validateParameter(parameterName, value);
    }
}
 
Example #14
Source File: CredentialStoreResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
    ServiceName credentialStoreServiceName = CREDENTIAL_STORE_UTIL.serviceName(operation);
    ServiceController<?> credentialStoreServiceController = context.getServiceRegistry(writeAccess).getRequiredService(credentialStoreServiceName);
    State serviceState;
    if ((serviceState = credentialStoreServiceController.getState()) != State.UP) {
        if (serviceMustBeUp) {
            try {
                // give it another chance to wait at most 500 mill-seconds
                credentialStoreServiceController.awaitValue(500, TimeUnit.MILLISECONDS);
            } catch (InterruptedException | IllegalStateException | TimeoutException e) {
                throw ROOT_LOGGER.requiredServiceNotUp(credentialStoreServiceName, credentialStoreServiceController.getState());
            }
        }
        serviceState = credentialStoreServiceController.getState();
        if (serviceState != State.UP) {
            if (serviceMustBeUp) {
                throw ROOT_LOGGER.requiredServiceNotUp(credentialStoreServiceName, serviceState);
            }
            return;
        }
    }
    CredentialStoreService service = (CredentialStoreService) credentialStoreServiceController.getService();
    performRuntime(context.getResult(), context, operation, service);
}
 
Example #15
Source File: PolicyDefinitions.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static Supplier<Policy> configureCustomPolicy(OperationContext context, ModelNode model) throws OperationFailedException {
    ModelNode policyModel = model.get(CUSTOM_POLICY);

    if (policyModel.isDefined()) {
        String className = CustomPolicyDefinition.CLASS_NAME.resolveModelAttribute(context, policyModel).asString();
        String module = CustomPolicyDefinition.MODULE.resolveModelAttribute(context, policyModel).asStringOrNull();

        return () -> newPolicy(className, module);
    }

    return null;
}
 
Example #16
Source File: ConnectorAdd.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
    final String connectorName = address.getLastElement().getValue();
    final ModelNode fullModel = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS));

    launchServices(context, connectorName, fullModel);
}
 
Example #17
Source File: WorkerResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void execute(OperationContext outContext, ModelNode operation) throws OperationFailedException {
    populateValueFromModel(outContext, operation);
    if (!PROFILE.equals(outContext.getCurrentAddress().getElement(0).getKey())) {
        outContext.addStep((context, op) -> {
            XnioWorker worker = getXnioWorker(context);
            if (worker != null) {
                executeWithWorker(context, op, worker);
            }
        }, OperationContext.Stage.RUNTIME);
    }
}
 
Example #18
Source File: TestHostCapableExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerOperations(ManagementResourceRegistration resourceRegistration) {
    super.registerOperations(resourceRegistration);
    resourceRegistration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);
    resourceRegistration.registerOperationHandler(TEST_OP, new OperationStepHandler() {
        @Override
        public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
            ServiceController<?> sc = context.getServiceRegistry(false).getService(createServiceName(context.getCurrentAddress()));
            context.getResult().set(sc != null);
        }
    });
}
 
Example #19
Source File: ErrorExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    if(Boolean.getBoolean(FAIL_REMOVAL)) {
        throw new OperationFailedException(ERROR_MESSAGE);
    }
    super.execute(context, operation);
}
 
Example #20
Source File: RoleMapperDefinitions.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
static ResourceDefinition getAddSuffixRoleMapperDefinition() {
    AbstractAddStepHandler add = new RoleMapperAddHandler(SUFFIX) {

        @Override
        protected ValueSupplier<RoleMapper> getValueSupplier(OperationContext context, ModelNode model) throws OperationFailedException {
            final String suffix = SUFFIX.resolveModelAttribute(context, model).asString();

            return () -> (Roles r) -> r.addSuffix(suffix);
        }

    };

    return new RoleMapperResourceDefinition(ElytronDescriptionConstants.ADD_SUFFIX_ROLE_MAPPER, add, SUFFIX);
}
 
Example #21
Source File: DomainDeploymentOverlayRedeployLinksHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Set<String> checkRequiredRuntimeNames(OperationContext context, ModelNode operation) throws OperationFailedException {
    Set<String> runtimeNames = domainRoot ? AffectedDeploymentOverlay.listAllLinks(context, context.getCurrentAddressValue()) : AffectedDeploymentOverlay.listLinks(context, context.getCurrentAddress());
    if(operation.hasDefined(RUNTIME_NAMES_DEFINITION.getName())) {
        Set<String> requiredRuntimeNames = new HashSet<>(RUNTIME_NAMES_DEFINITION.unwrap(context, operation));
        if(!requiredRuntimeNames.isEmpty()) {
            runtimeNames = requiredRuntimeNames;
        }
    }
    return runtimeNames;
}
 
Example #22
Source File: RejectedAttributesLogContext.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
String errorOrWarnOnResourceTransformation() throws OperationFailedException {
    if (op != null) {
        throw new IllegalStateException();
    }
    if (failedAttributes == null) {
        return "";
    }

    final TransformationTarget tgt = context.getContext().getTarget();
    final String legacyHostName = tgt.getHostName();
    final ModelVersion coreVersion = tgt.getVersion();
    final String subsystemName = findSubsystemName(address);
    final ModelVersion usedVersion = subsystemName == null ? coreVersion : tgt.getSubsystemVersion(subsystemName);

    final TransformersLogger logger = context.getContext().getLogger();
    final boolean error = tgt.isIgnoredResourceListAvailableAtRegistration();
    List<String> messages = error ? new ArrayList<String>() : null;

    for (Map.Entry<String, Map<String, ModelNode>> entry : failedAttributes.entrySet()) {
        RejectAttributeChecker checker = failedCheckers.get(entry.getKey());
        String message = checker.getRejectionLogMessage(entry.getValue());

        if (error) {
            //Create our own custom exception containing everything
            messages.add(message);
        } else {
            return logger.getAttributeWarning(address, op, message, entry.getValue().keySet());
        }
    }

    if (error) {
        // Target is  7.2.x or higher so we should throw an error
        if (subsystemName != null) {
            throw ControllerLogger.ROOT_LOGGER.rejectAttributesSubsystemModelResourceTransformer(address, legacyHostName, subsystemName, usedVersion, messages);
        }
        throw ControllerLogger.ROOT_LOGGER.rejectAttributesCoreModelResourceTransformer(address, legacyHostName, usedVersion, messages);
    }
    return null;
}
 
Example #23
Source File: ModifiableKeyStoreDecorator.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void executeRuntimeStep(final OperationContext context, final ModelNode operation) throws OperationFailedException {
    String alias = ALIAS.resolveModelAttribute(context, operation).asString();
    KeyStore keyStore = getModifiableKeyStore(context);

    try {
        keyStore.deleteEntry(alias);
    } catch (KeyStoreException e) {
        throw new OperationFailedException(e);
    }
}
 
Example #24
Source File: BasicRbacTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    context.addStep((ctx, op) -> {
        ctx.getServiceRegistry(modify); // causes read-runtime/write-runtime auth, otherwise ignored
        ctx.getResult().set(new Random().nextInt());
    }, OperationContext.Stage.RUNTIME);
}
 
Example #25
Source File: QueryOperationHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private ResultTransformer(ModelNode operation, PathAddress address) {
    this.multiTarget = address.isMultiTarget();
    try {
        this.filter = WHERE_ATT.validateOperation(operation);
        this.select = SELECT_ATT.validateOperation(operation);
        // Use resolveModelAttribute for OPERATOR_ATT to pull out the default value
        this.operator = Operator.valueOf(OPERATOR_ATT.resolveModelAttribute(ExpressionResolver.SIMPLE, operation).asString());
    } catch (OperationFailedException e) {
        // the validateOperation calls above would have already been invoked in QueryOperationHandler.execute
        // so this shouldn't happen
        throw new IllegalStateException(e);
    }
}
 
Example #26
Source File: LegacyConfigurationChangeResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Checks if the calling user may execute the operation. If he can then he cvan see it in the result.
 *
 * @param context
 * @param configurationChange
 * @throws OperationFailedException
 */
private void secureHistory(OperationContext context, ModelNode configurationChange) throws OperationFailedException {
    if (configurationChange.has(OPERATIONS)) {
        List<ModelNode> operations = configurationChange.get(OPERATIONS).asList();
        ModelNode authorizedOperations = configurationChange.get(OPERATIONS).setEmptyList();
        for (ModelNode operation : operations) {
            authorizedOperations.add(secureOperation(context, operation));
        }
    }
}
 
Example #27
Source File: SaslServerDefinitions.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model)
        throws OperationFailedException {
    RuntimeCapability<Void> runtimeCapability = SASL_SERVER_FACTORY_RUNTIME_CAPABILITY.fromBaseCapability(context.getCurrentAddressValue());
    ServiceName saslServerFactoryName = runtimeCapability.getCapabilityServiceName(SaslServerFactory.class);

    commonDependencies(installService(context, saslServerFactoryName, model))
        .setInitialMode(Mode.ACTIVE)
        .install();
}
 
Example #28
Source File: RemoteOutboundConnectionWriteHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Boolean> handbackHolder) throws OperationFailedException {
    final ModelNode model = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS));
    boolean handback = applyModelToRuntime(context, operation, model);
    handbackHolder.setHandback(handback);
    return handback;

}
 
Example #29
Source File: SizeResolver.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public long parseSize(final ModelNode value) throws OperationFailedException {
    final Matcher matcher = SIZE_PATTERN.matcher(value.asString());
    if (!matcher.matches()) {
        throw createOperationFailure(LoggingLogger.ROOT_LOGGER.invalidSize(value.asString()));
    }
    long qty = Long.parseLong(matcher.group(1), 10);
    final String chr = matcher.group(2);
    if (chr != null) {
        switch (chr.charAt(0)) {
            case 'b':
            case 'B':
                break;
            case 'k':
            case 'K':
                qty <<= 10L;
                break;
            case 'm':
            case 'M':
                qty <<= 20L;
                break;
            case 'g':
            case 'G':
                qty <<= 30L;
                break;
            case 't':
            case 'T':
                qty <<= 40L;
                break;
            default:
                throw createOperationFailure(LoggingLogger.ROOT_LOGGER.invalidSize(value.asString()));
        }
    }
    return qty;

}
 
Example #30
Source File: GenericOutboundConnectionWriteHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Void> voidHandbackHolder) throws OperationFailedException {
    final ModelNode fullModel = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS));
    applyModelToRuntime(context, operation, attributeName, fullModel);

    return false;

}