@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final boolean defaults = INCLUDE_DEFAULTS.resolveModelAttribute(context,operation).asBoolean(); final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS, false); final ModelNode subModel = resource.getModel(); if (subModel.hasDefined(aliasedAttribute.getName())) { final ModelNode result = subModel.get(aliasedAttribute.getName()); context.getResult().set(result); } else if (defaults && aliasedAttribute.getDefaultValue() != null) { // No defined value in the model. See if we should reply with a default from the metadata, // reply with undefined, or fail because it's a non-existent attribute name context.getResult().set(aliasedAttribute.getDefaultValue()); } else { // model had no defined value, but we treat its existence in the model or the metadata // as proof that it's a legit attribute name context.getResult(); // this initializes the "result" to ModelType.UNDEFINED } } }
protected void parseRemote(final XMLExtendedStreamReader reader, List<ModelNode> operations) throws XMLStreamException { final int count = reader.getAttributeCount(); ModelNode operation = Util.createAddOperation(SUBSYSTEM_PATH.append(SERVICE, REMOTE)); final EnumSet<EJB3SubsystemXMLAttribute> required = EnumSet.of(EJB3SubsystemXMLAttribute.CONNECTOR_REF, EJB3SubsystemXMLAttribute.THREAD_POOL_NAME); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); required.remove(attribute); switch (attribute) { case CONNECTOR_REF: EJB3RemoteResourceDefinition.CONNECTOR_REF.parseAndSetParameter(value, operation, reader); break; case THREAD_POOL_NAME: EJB3RemoteResourceDefinition.THREAD_POOL_NAME.parseAndSetParameter(value, operation, reader); break; default: throw unexpectedAttribute(reader, i); } } if (!required.isEmpty()) { throw missingRequired(reader, required); } operation.get(EJB3SubsystemModel.EXECUTE_IN_WORKER).set(new ModelNode(false)); requireNoContent(reader); operations.add(operation); }
private void writeArchiveValidation(XMLExtendedStreamWriter writer, ModelNode parentNode) throws XMLStreamException { if (parentNode.hasDefined(ARCHIVE_VALIDATION)) { ModelNode node = parentNode.get(ARCHIVE_VALIDATION).get(ARCHIVE_VALIDATION); if (ArchiveValidationParameters.ARCHIVE_VALIDATION_ENABLED.getAttribute().isMarshallable(node) || ArchiveValidationParameters.ARCHIVE_VALIDATION_FAIL_ON_ERROR.getAttribute().isMarshallable(node) || ArchiveValidationParameters.ARCHIVE_VALIDATION_FAIL_ON_WARN.getAttribute().isMarshallable(node)) { writer.writeEmptyElement(Element.ARCHIVE_VALIDATION.getLocalName()); ArchiveValidationParameters.ARCHIVE_VALIDATION_ENABLED.getAttribute().marshallAsAttribute(node, writer); ArchiveValidationParameters.ARCHIVE_VALIDATION_FAIL_ON_ERROR.getAttribute().marshallAsAttribute(node, writer); ArchiveValidationParameters.ARCHIVE_VALIDATION_FAIL_ON_WARN.getAttribute().marshallAsAttribute(node, writer); } } }
private void addAttribute(XMLExtendedStreamReader reader, ModelNode operation, SimpleAttributeDefinition attributeDefinition) throws XMLStreamException { String value = rawAttributeText(reader, attributeDefinition.getXmlName(), null); if (value != null) { attributeDefinition.parseAndSetParameter(value, operation, reader); } else { throw missingRequired(reader, attributeDefinition.getXmlName()); } }
@Override protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException { // add extra security validation: authentication contexts should only be defined when Elytron Enabled is false // domains should only be defined when Elytron enabled is undefined or false (default value) if (model.hasDefined(RECOVERY_AUTHENTICATION_CONTEXT.getName()) && !RECOVERY_ELYTRON_ENABLED.resolveModelAttribute(context, model).asBoolean()) { throw SUBSYSTEM_DATASOURCES_LOGGER.attributeRequiresTrueAttribute(RECOVERY_AUTHENTICATION_CONTEXT.getName(), RECOVERY_ELYTRON_ENABLED.getName()); } else if (RECOVERY_ELYTRON_ENABLED.resolveModelAttribute(context, model).asBoolean() && model.hasDefined(RECOVERY_SECURITY_DOMAIN.getName())) { throw SUBSYSTEM_DATASOURCES_LOGGER .attributeRequiresFalseOrUndefinedAttribute(RECOVERY_SECURITY_DOMAIN.getName(), RECOVERY_ELYTRON_ENABLED.getName()); } super.performRuntime(context, operation, model); }
private void populateModelWithObjectStoreConfig(ModelNode operation, ModelNode objectStoreModel) throws OperationFailedException { TransactionSubsystemRootResourceDefinition.OBJECT_STORE_RELATIVE_TO.validateAndSet(operation, objectStoreModel); TransactionSubsystemRootResourceDefinition.OBJECT_STORE_PATH.validateAndSet(operation, objectStoreModel); ModelNode relativeVal = objectStoreModel.get(TransactionSubsystemRootResourceDefinition.OBJECT_STORE_RELATIVE_TO.getName()); ModelNode pathVal = objectStoreModel.get(TransactionSubsystemRootResourceDefinition.OBJECT_STORE_PATH.getName()); if (!relativeVal.isDefined() && (!pathVal.isDefined() || pathVal.asString().equals(TransactionSubsystemRootResourceDefinition.OBJECT_STORE_PATH.getDefaultValue().asString()))) { relativeVal.set(new ModelNode().set("jboss.server.data.dir")); TransactionLogger.ROOT_LOGGER.objectStoreRelativeToIsSetToDefault(); } }
private void parseDefaultSecurityDomain(final XMLExtendedStreamReader reader, final ModelNode ejb3SubsystemAddOperation) throws XMLStreamException { final int count = reader.getAttributeCount(); final EnumSet<EJB3SubsystemXMLAttribute> missingRequiredAttributes = EnumSet.of(EJB3SubsystemXMLAttribute.VALUE); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case VALUE: EJB3SubsystemRootResourceDefinition.DEFAULT_SECURITY_DOMAIN.parseAndSetParameter(value, ejb3SubsystemAddOperation, reader); // found the mandatory attribute missingRequiredAttributes.remove(EJB3SubsystemXMLAttribute.VALUE); break; default: throw unexpectedAttribute(reader, i); } } requireNoContent(reader); if (!missingRequiredAttributes.isEmpty()) { throw missingRequired(reader, missingRequiredAttributes); } }
private void parseJobRepository(final XMLExtendedStreamReader reader, final PathAddress subsystemAddress, final String name, final List<ModelNode> ops) throws XMLStreamException { while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { final String localName = reader.getLocalName(); final Element element = Element.forName(localName); if (element == Element.IN_MEMORY) { ops.add(Util.createAddOperation(subsystemAddress.append(InMemoryJobRepositoryDefinition.NAME, name))); ParseUtils.requireNoContent(reader); } else if (element == Element.JDBC) { final Map<Attribute, String> attributes = AttributeParsers.readRequiredAttributes(reader, EnumSet.of(Attribute.DATA_SOURCE)); final ModelNode op = Util.createAddOperation(subsystemAddress.append(JdbcJobRepositoryDefinition.NAME, name)); JdbcJobRepositoryDefinition.DATA_SOURCE.parseAndSetParameter(attributes.get(Attribute.DATA_SOURCE), op, reader); ops.add(op); ParseUtils.requireNoContent(reader); } else { throw ParseUtils.unexpectedElement(reader); } } } }
private ModelNode parseMDB(final XMLExtendedStreamReader reader, List<ModelNode> operations, ModelNode ejb3SubsystemAddOperation) throws XMLStreamException { ModelNode mdbModelNode = new ModelNode(); // no attributes expected requireNoAttributes(reader); while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) { switch (EJB3SubsystemXMLElement.forName(reader.getLocalName())) { case BEAN_INSTANCE_POOL_REF: { final String poolName = readStringAttributeElement(reader, EJB3SubsystemXMLAttribute.POOL_NAME.getLocalName()); EJB3SubsystemRootResourceDefinition.DEFAULT_MDB_INSTANCE_POOL.parseAndSetParameter(poolName, ejb3SubsystemAddOperation, reader); break; } case RESOURCE_ADAPTER_REF: { final String resourceAdapterName = readStringAttributeElement(reader, EJB3SubsystemXMLAttribute.RESOURCE_ADAPTER_NAME.getLocalName()); EJB3SubsystemRootResourceDefinition.DEFAULT_RESOURCE_ADAPTER_NAME.parseAndSetParameter(resourceAdapterName, ejb3SubsystemAddOperation, reader); break; } default: { throw unexpectedElement(reader); } } } // if the resource-adapter-ref *hasn't* been explicitly specified, then default it to hornetq-ra if (!ejb3SubsystemAddOperation.hasDefined(EJB3SubsystemModel.DEFAULT_RESOURCE_ADAPTER_NAME)) { final ModelNode defaultRAName = EJB3SubsystemRootResourceDefinition.DEFAULT_RESOURCE_ADAPTER_NAME.getDefaultValue(); if (defaultRAName != null) { ejb3SubsystemAddOperation.get(EJB3SubsystemModel.DEFAULT_RESOURCE_ADAPTER_NAME).set(defaultRAName); } } return mdbModelNode; }
@Override protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException { final String attributeName = operation.require(NAME).asString(); ModelNode newValue = operation.hasDefined(VALUE) ? operation.get(VALUE) : LogStoreConstants.EXPOSE_ALL_LOGS.getDefaultValue(); final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); final ModelNode submodel = resource.getModel(); final ModelNode syntheticOp = new ModelNode(); syntheticOp.get(attributeName).set(newValue); LogStoreConstants.EXPOSE_ALL_LOGS.validateAndSet(syntheticOp, submodel); // ExposeAllRecordsAsMBeans JMX attribute will be set in LogStoreProbeHandler prior to eventual probe operation execution, // hence no need to do here anything else context.getResult().set(new ModelNode()); context.completeStep(OperationContext.ResultHandler.NOOP_RESULT_HANDLER); } }
private ModelNode parseBeanValidation(final XMLExtendedStreamReader reader, final ModelNode parentOperation) throws XMLStreamException { final ModelNode beanValidationOperation = new ModelNode(); beanValidationOperation.get(OP).set(ADD); final ModelNode beanValidationAddress = parentOperation.clone(); beanValidationAddress.add(BEAN_VALIDATION, BEAN_VALIDATION); beanValidationAddress.protect(); beanValidationOperation.get(OP_ADDR).set(beanValidationAddress); final int cnt = reader.getAttributeCount(); for (int i = 0; i < cnt; i++) { final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case ENABLED: { String value = rawAttributeText(reader, JcaBeanValidationDefinition.BeanValidationParameters.BEAN_VALIDATION_ENABLED.getAttribute().getXmlName()); JcaBeanValidationDefinition.BeanValidationParameters.BEAN_VALIDATION_ENABLED.getAttribute().parseAndSetParameter(value, beanValidationOperation, reader); break; } default: { throw unexpectedAttribute(reader, i); } } } // Handle elements requireNoContent(reader); return beanValidationOperation; }
private void writeConDef(XMLExtendedStreamWriter streamWriter, ModelNode conDef, final String poolName, final boolean isXa) throws XMLStreamException { streamWriter.writeStartElement(Activation.Tag.CONNECTION_DEFINITION.getLocalName()); CLASS_NAME.marshallAsAttribute(conDef, streamWriter); JNDINAME.marshallAsAttribute(conDef, streamWriter); ENABLED.marshallAsAttribute(conDef, streamWriter); CONNECTABLE.marshallAsAttribute(conDef, streamWriter); TRACKING.marshallAsAttribute(conDef, streamWriter); USE_JAVA_CONTEXT.marshallAsAttribute(conDef, streamWriter); streamWriter.writeAttribute("pool-name", poolName); USE_CCM.marshallAsAttribute(conDef, streamWriter); SHARABLE.marshallAsAttribute(conDef, streamWriter); ENLISTMENT.marshallAsAttribute(conDef, streamWriter); MCP.marshallAsAttribute(conDef, streamWriter); ENLISTMENT_TRACE.marshallAsAttribute(conDef, streamWriter); boolean poolRequired = INITIAL_POOL_SIZE.isMarshallable(conDef) || MAX_POOL_SIZE.isMarshallable(conDef) || MIN_POOL_SIZE.isMarshallable(conDef) || POOL_USE_STRICT_MIN.isMarshallable(conDef) || POOL_PREFILL.isMarshallable(conDef) || POOL_FAIR.isMarshallable(conDef) || POOL_FLUSH_STRATEGY.isMarshallable(conDef); final boolean capacityRequired = CAPACITY_INCREMENTER_CLASS.isMarshallable(conDef) || CAPACITY_INCREMENTER_PROPERTIES.isMarshallable(conDef) || CAPACITY_DECREMENTER_CLASS.isMarshallable(conDef) || CAPACITY_DECREMENTER_PROPERTIES.isMarshallable(conDef); poolRequired = poolRequired || capacityRequired; MIN_POOL_SIZE.marshallAsElement(conDef, streamWriter); INITIAL_POOL_SIZE.marshallAsElement(conDef, streamWriter); MAX_POOL_SIZE.marshallAsElement(conDef, streamWriter); POOL_PREFILL.marshallAsElement(conDef, streamWriter); POOL_FAIR.marshallAsElement(conDef, streamWriter); POOL_USE_STRICT_MIN.marshallAsElement(conDef, streamWriter); POOL_FLUSH_STRATEGY.marshallAsElement(conDef, streamWriter);
protected void parseUseJournalstore(final XMLExtendedStreamReader reader, final ModelNode logStoreOperation, final ModelNode operation) throws XMLStreamException { logStoreOperation.get(LogStoreConstants.LOG_STORE_TYPE.getName()).set("journal"); // Handle attributes final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case ENABLE_ASYNC_IO: TransactionSubsystemRootResourceDefinition.JOURNAL_STORE_ENABLE_ASYNC_IO.parseAndSetParameter(value, operation, reader); break; default: throw unexpectedAttribute(reader, i); } } // Handle elements requireNoContent(reader); }
protected void performRuntime(final OperationContext context, ModelNode operation, final ModelNode model) throws OperationFailedException { final ModelNode pathNode = FileDataStoreResourceDefinition.PATH.resolveModelAttribute(context, model); final String path = pathNode.isDefined() ? pathNode.asString() : null; final ModelNode relativeToNode = FileDataStoreResourceDefinition.RELATIVE_TO.resolveModelAttribute(context, model); final String relativeTo = relativeToNode.isDefined() ? relativeToNode.asString() : null; final FileTimerPersistence fileTimerPersistence = new FileTimerPersistence(true, path, relativeTo); final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); final ServiceName serviceName = TimerPersistence.SERVICE_NAME.append(address.getLastElement().getValue()); final ServiceBuilder sb = context.getServiceTarget().addService(serviceName, fileTimerPersistence); sb.addDependency(Services.JBOSS_SERVICE_MODULE_LOADER, ModuleLoader.class, fileTimerPersistence.getModuleLoader()); sb.addDependency(PathManagerService.SERVICE_NAME, PathManager.class, fileTimerPersistence.getPathManager()); sb.requires(context.getCapabilityServiceName("org.wildfly.transactions.global-default-local-provider", null)); sb.addDependency(context.getCapabilityServiceName("org.wildfly.transactions.transaction-synchronization-registry", null), TransactionSynchronizationRegistry.class, fileTimerPersistence.getTransactionSynchronizationRegistry()); sb.install(); }
@Override public void execute(OperationContext context, ModelNode operation) { operationDeprecated(context, operation); context.createResource(PathAddress.EMPTY_ADDRESS); String name = context.getCurrentAddressValue(); String value = operation.get(VALUE.getName()).asString(); PathAddress storeAddress = context.getCurrentAddress().getParent(); ModelNode putOperation = Operations.createMapPutOperation(storeAddress, StoreResourceDefinition.Attribute.PROPERTIES, name, value); context.addStep(putOperation, MapOperations.MAP_PUT_HANDLER, context.getCurrentStage()); } };
private void writeBootstrapContexts(XMLExtendedStreamWriter writer, ModelNode parentNode) throws XMLStreamException { if (parentNode.hasDefined(BOOTSTRAP_CONTEXT) && parentNode.get(BOOTSTRAP_CONTEXT).asList().size() != 0) { boolean started = false; ModelNode contexts = parentNode.get(BOOTSTRAP_CONTEXT); for (String name : contexts.keys()) { ModelNode context = contexts.get(name); if (!context.get(JcaBootstrapContextDefinition.BootstrapCtxParameters.NAME.getAttribute().getName()).asString().equals(DEFAULT_NAME) && (JcaBootstrapContextDefinition.BootstrapCtxParameters.NAME.getAttribute().isMarshallable(context) || JcaBootstrapContextDefinition.BootstrapCtxParameters.WORKMANAGER.getAttribute().isMarshallable(context))) { if (!started) { writer.writeStartElement(Element.BOOTSTRAP_CONTEXTS.getLocalName()); started = true; } writer.writeStartElement(Element.BOOTSTRAP_CONTEXT.getLocalName()); JcaBootstrapContextDefinition.BootstrapCtxParameters.NAME.getAttribute().marshallAsAttribute(context, writer); JcaBootstrapContextDefinition.BootstrapCtxParameters.WORKMANAGER.getAttribute().marshallAsAttribute(context, writer); writer.writeEndElement(); } } if (started) { writer.writeEndElement(); } } }
protected void parseObjectStoreEnvironmentElementAndEnrichOperation(final XMLExtendedStreamReader reader, ModelNode operation) throws XMLStreamException { final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case RELATIVE_TO: TransactionSubsystemRootResourceDefinition.OBJECT_STORE_RELATIVE_TO.parseAndSetParameter(value, operation, reader); needsDefaultRelativeTo = false; break; case PATH: TransactionSubsystemRootResourceDefinition.OBJECT_STORE_PATH.parseAndSetParameter(value, operation, reader); if (!value.equals(TransactionSubsystemRootResourceDefinition.OBJECT_STORE_PATH.getDefaultValue().asString())) { needsDefaultRelativeTo = false; } break; default: throw unexpectedAttribute(reader, i); } } // Handle elements requireNoContent(reader); }
if (SecuritySubsystemRootResourceDefinition.DEEP_COPY_SUBJECT_MODE.isMarshallable(node) || SecuritySubsystemRootResourceDefinition.INITIALIZE_JACC.isMarshallable(node)) { writer.writeEmptyElement(Element.SECURITY_MANAGEMENT.getLocalName()); if (SecuritySubsystemRootResourceDefinition.DEEP_COPY_SUBJECT_MODE.isMarshallable(node)) { SecuritySubsystemRootResourceDefinition.DEEP_COPY_SUBJECT_MODE.marshallAsAttribute(node, writer); if (SecuritySubsystemRootResourceDefinition.INITIALIZE_JACC.isMarshallable(node)) { SecuritySubsystemRootResourceDefinition.INITIALIZE_JACC.marshallAsAttribute(node, writer); if (node.hasDefined(SECURITY_DOMAIN) && node.get(SECURITY_DOMAIN).asInt() > 0) { writer.writeStartElement(Element.SECURITY_DOMAINS.getLocalName()); ModelNode securityDomains = node.get(SECURITY_DOMAIN); writer.writeAttribute(Attribute.NAME.getLocalName(), policy); ModelNode policyDetails = securityDomains.get(policy); SecurityDomainResourceDefinition.CACHE_TYPE.marshallAsAttribute(policyDetails, writer); writeSecurityDomainContent(writer, policyDetails); writer.writeEndElement(); ModelNode vault = node.get(Constants.VAULT, Constants.CLASSIC); writer.writeStartElement(Element.VAULT.getLocalName()); VaultResourceDefinition.CODE.marshallAsAttribute(vault, writer); if (vault.hasDefined(Constants.VAULT_OPTIONS)) {
JTA.marshallAsAttribute(dataSourceNode, writer); JNDI_NAME.marshallAsAttribute(dataSourceNode, writer); writer.writeAttribute("pool-name", dsName); ENABLED.marshallAsAttribute(dataSourceNode, writer); USE_JAVA_CONTEXT.marshallAsAttribute(dataSourceNode, writer); SPY.marshallAsAttribute(dataSourceNode, writer); USE_CCM.marshallAsAttribute(dataSourceNode, writer); CONNECTABLE.marshallAsAttribute(dataSourceNode, writer); TRACKING.marshallAsAttribute(dataSourceNode, writer); MCP.marshallAsAttribute(dataSourceNode, writer); ENLISTMENT_TRACE.marshallAsAttribute(dataSourceNode, writer); STATISTICS_ENABLED.marshallAsAttribute(dataSourceNode, writer); CONNECTION_URL.marshallAsElement(dataSourceNode, writer); DRIVER_CLASS.marshallAsElement(dataSourceNode, writer); DATASOURCE_CLASS.marshallAsElement(dataSourceNode, writer); if (dataSourceNode.hasDefined(CONNECTION_PROPERTIES.getName())) { XA_DATASOURCE_CLASS.marshallAsElement(dataSourceNode, writer); DATASOURCE_DRIVER.marshallAsElement(dataSourceNode, writer); URL_DELIMITER.marshallAsElement(dataSourceNode, writer); URL_PROPERTY.marshallAsElement(dataSourceNode, writer); URL_SELECTOR_STRATEGY_CLASS_NAME.marshallAsElement(dataSourceNode, writer); NEW_CONNECTION_SQL.marshallAsElement(dataSourceNode, writer); TRANSACTION_ISOLATION.marshallAsElement(dataSourceNode, writer);
protected void parseConfigProperties(final XMLExtendedStreamReader reader, final Map<String, ModelNode> map) throws XMLStreamException, ParserException { String name = rawAttributeText(reader, "name"); final ModelNode operation = new ModelNode(); operation.get(OP).set(ADD); String value = rawElementText(reader); CONFIG_PROPERTY_VALUE.parseAndSetParameter(value, operation, reader); if (map.containsKey(name)) { throw ParseUtils.unexpectedElement(reader); } map.put(name, operation); }