private ModelNode createAddOperation(PathAddress parentAddress, String name, String value) { return Util.createAddOperation(parentAddress.append(name, value)); }
private void parseObjectMemory(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = cacheAddress.append(ObjectMemoryResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { this.parseMemoryAttribute(reader, i, operation); } ParseUtils.requireNoContent(reader); }
private void parseAuthentication(List<ModelNode> list, PathAddress parentAddress, XMLExtendedStreamReader reader) throws XMLStreamException { requireNoAttributes(reader); PathAddress address = parentAddress.append(AUTHENTICATION, CLASSIC); ModelNode op = Util.createAddOperation(address); list.add(op); parseLoginModules(reader, address, list); }
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 parseJDBCStoreStringTable(XMLExtendedStreamReader reader, PathAddress storeAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = storeAddress.append(StringTableResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(storeAddress.getParent().append(StoreResourceDefinition.WILDCARD_PATH).append(StringTableResourceDefinition.PATH), operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case PREFIX: { readAttribute(reader, i, operation, StringTableResourceDefinition.Attribute.PREFIX); break; } default: { this.parseJDBCStoreTableAttribute(reader, i, operation); } } } this.parseJDBCStoreTableElements(reader, operation); }
@Override public ModelNode transformOperation(ModelNode operation) { if (operation.hasDefined(PROPERTIES)) { final ModelNode addOperation = operation.clone(); List<Property> properties = addOperation.remove(PROPERTIES).asPropertyList(); List<ModelNode> operations = new ArrayList<>(properties.size() + 1); operations.add(addOperation); PathAddress address = this.addressResolver.apply(addOperation); for (final Property property : properties) { String key = property.getName(); ModelNode value = property.getValue(); ModelNode propertyAddOperation = Util.createAddOperation(address.append(PathElement.pathElement(PROPERTY, key))); propertyAddOperation.get(VALUE).set(value); operations.add(propertyAddOperation); } return Operations.createCompositeOperation(operations); } return operation; } }
@Override public ModelNode transformOperation(ModelNode operation) { if (operation.get(NAME).asString().equals(PROPERTIES)) { String key = operation.get("key").asString(); PathAddress address = Operations.getPathAddress(operation); ModelNode transformedOperation = Util.createOperation(READ_ATTRIBUTE_OPERATION, address.append(PathElement.pathElement(PROPERTY, key))); transformedOperation.get(NAME).set(VALUE); return transformedOperation; } return operation; } }
@Override public void transformResource(ResourceTransformationContext context, PathAddress address, Resource resource) throws OperationFailedException { PathAddress transactionAddress = address.append(TransactionResourceDefinition.PATH); try { ModelNode transaction = context.readResourceFromRoot(transactionAddress).getModel(); if (transaction.hasDefined(TransactionResourceDefinition.Attribute.MODE.getName())) { ModelNode mode = transaction.get(TransactionResourceDefinition.Attribute.MODE.getName()); if ((mode.getType() == ModelType.STRING) && (TransactionMode.valueOf(mode.asString()) == TransactionMode.BATCH)) { resource.getModel().get(DeprecatedAttribute.BATCHING.getName()).set(true); } } } catch (NoSuchElementException e) { // Ignore, nothing to convert } context.addTransformedResource(PathAddress.EMPTY_ADDRESS, resource).processChildren(resource); } };
private void addOpenjdkExtension(final OperationContext context, final Map<PathAddress, ModelNode> migrateOperations) { final PathAddress extensionAddress = PathAddress.EMPTY_ADDRESS.append(OPENJDK_EXTENSION_ELEMENT); OperationEntry addEntry = context.getRootResourceRegistration().getOperationEntry(extensionAddress, ADD); final ModelNode addOperation = Util.createAddOperation(extensionAddress); if (describe) { migrateOperations.put(extensionAddress, addOperation); } else { context.addStep(context.getResult().get(extensionAddress.toString()), addOperation, addEntry.getOperationHandler(), MODEL); } }
@Override public AttributeValueTranslator getReadTranslator() { return (context, value) -> { String poolName = value.asString(); PathAddress address = context.getCurrentAddress(); PathAddress rootAddress = address.subAddress(0, address.size() - 4); PathAddress subsystemAddress = rootAddress.append(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "datasources")); Resource subsystem = context.readResourceFromRoot(subsystemAddress); for (String type : Arrays.asList("data-source", "xa-data-source")) { Resource resource = subsystem.getChild(PathElement.pathElement(type, poolName)); if (resource != null) { return resource.getModel().get("jndi-name"); } } throw InfinispanLogger.ROOT_LOGGER.dataSourceNotFound(poolName); }; }
private void parseLookupBinding(final XMLExtendedStreamReader reader, List<ModelNode> operations, PathAddress parentAddress) throws XMLStreamException { final int attCount = reader.getAttributeCount(); String name = null; final ModelNode bindingAdd = Util.createAddOperation(); bindingAdd.get(BINDING_TYPE).set(LOOKUP); final EnumSet<NamingSubsystemXMLAttribute> required = EnumSet.of(NamingSubsystemXMLAttribute.NAME, NamingSubsystemXMLAttribute.LOOKUP); for (int i = 0; i < attCount; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final NamingSubsystemXMLAttribute attribute = NamingSubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); required.remove(attribute); switch (attribute) { break; default: throw unexpectedAttribute(reader, i); bindingAdd.get(OP_ADDR).set(parentAddress.append(BINDING, name).toModelNode()); operations.add(bindingAdd);
private void parseJDBCStoreBinaryTable(XMLExtendedStreamReader reader, PathAddress storeAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = storeAddress.append(BinaryTableResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(storeAddress.getParent().append(StoreResourceDefinition.WILDCARD_PATH).append(BinaryTableResourceDefinition.PATH), operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case PREFIX: { readAttribute(reader, i, operation, BinaryTableResourceDefinition.Attribute.PREFIX); break; } default: { this.parseJDBCStoreTableAttribute(reader, i, operation); } } } this.parseJDBCStoreTableElements(reader, operation); }
private void parseRemoteNaming(final XMLExtendedStreamReader reader, final List<ModelNode> operations, PathAddress parent) throws XMLStreamException { requireNoAttributes(reader); requireNoContent(reader); operations.add(Util.createAddOperation(parent.append(NamingSubsystemModel.SERVICE, NamingSubsystemModel.REMOTE_NAMING))); }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { // If this is a legacy configuration containing a default-stack, but no default-channel, then fabricate a default channel using the default stack // This ensures that the default channel factory capability is available to the /subsystem=infinispan/cache-container=*/transport=jgroups resource, which requires them // We can drop this compatibility workaround after we drop support for model version 3.0. if (!operation.hasDefined(Attribute.DEFAULT_CHANNEL.getName()) && operation.hasDefined(Attribute.DEFAULT_STACK.getName())) { String defaultChannel = "auto"; PathAddress channelAddress = context.getCurrentAddress().append(ChannelResourceDefinition.pathElement(defaultChannel)); ModelNode channelOperation = Util.createAddOperation(channelAddress); channelOperation.get(ChannelResourceDefinition.Attribute.STACK.getName()).set(operation.get(Attribute.DEFAULT_STACK.getName())); context.addStep(channelOperation, context.getRootResourceRegistration().getOperationHandler(channelAddress, ModelDescriptionConstants.ADD), OperationContext.Stage.MODEL); operation.get(Attribute.DEFAULT_CHANNEL.getName()).set(new ModelNode(defaultChannel)); } handler.execute(context, operation); } };
private ModelNode createAddStrictMaxBeanInstancePoolOperation(final String name, final Integer maxPoolSize, final Long timeout, final String timeoutUnit) { // create /subsystem=ejb3/strict-max-bean-instance-pool=name:add(...) final ModelNode addStrictMaxPoolOperation = new ModelNode(); addStrictMaxPoolOperation.get(OP).set(ADD); // set the address for this operation final PathAddress address = this.getEJB3SubsystemAddress().append(PathElement.pathElement(STRICT_MAX_BEAN_INSTANCE_POOL, name)); addStrictMaxPoolOperation.get(OP_ADDR).set(address.toModelNode()); // set the params for the operation if (maxPoolSize != null) { addStrictMaxPoolOperation.get(MAX_POOL_SIZE).set(maxPoolSize); } if (timeout != null) { addStrictMaxPoolOperation.get(INSTANCE_ACQUISITION_TIMEOUT).set(timeout); } if (timeoutUnit != null) { addStrictMaxPoolOperation.get(INSTANCE_ACQUISITION_TIMEOUT_UNIT).set(timeoutUnit); } return addStrictMaxPoolOperation; }
private void parseBinaryMemory(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = cacheAddress.append(BinaryMemoryResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { this.parseBinaryMemoryAttribute(reader, i, operation); } ParseUtils.requireNoContent(reader); }
@SuppressWarnings("deprecation") @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { PathAddress address = context.getCurrentAddress().append(BinaryTableResourceDefinition.PATH); ModelNode table = Operations.getAttributeValue(operation); for (Class<? extends org.jboss.as.clustering.controller.Attribute> attributeClass : Arrays.asList(BinaryTableResourceDefinition.Attribute.class, TableResourceDefinition.Attribute.class, TableResourceDefinition.DeprecatedAttribute.class)) { for (org.jboss.as.clustering.controller.Attribute attribute : attributeClass.getEnumConstants()) { ModelNode writeAttributeOperation = Operations.createWriteAttributeOperation(address, attribute, table.get(attribute.getName())); context.addStep(writeAttributeOperation, context.getResourceRegistration().getAttributeAccess(PathAddress.pathAddress(BinaryTableResourceDefinition.PATH), attribute.getName()).getWriteHandler(), context.getCurrentStage()); } } } };
private void parseRandomElectionPolicy(XMLExtendedStreamReader reader, PathAddress policyAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = policyAddress.append(RandomElectionPolicyResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); ParseUtils.requireNoAttributes(reader); this.parsePreferences(reader, operation); }
private void parseLookupBinding(final XMLExtendedStreamReader reader, List<ModelNode> operations, PathAddress parentAddress) throws XMLStreamException { final int attCount = reader.getAttributeCount(); String name = null; final ModelNode bindingAdd = Util.createAddOperation(); bindingAdd.get(BINDING_TYPE).set(LOOKUP); final EnumSet<NamingSubsystemXMLAttribute> required = EnumSet.of(NamingSubsystemXMLAttribute.NAME, NamingSubsystemXMLAttribute.LOOKUP); for (int i = 0; i < attCount; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final NamingSubsystemXMLAttribute attribute = NamingSubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); required.remove(attribute); switch (attribute) { break; default: throw unexpectedAttribute(reader, i); bindingAdd.get(OP_ADDR).set(parentAddress.append(BINDING, name).toModelNode()); operations.add(bindingAdd);
private void parseRemoteCacheContainerSecurity(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = cacheAddress.append(SecurityResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case SSL_CONTEXT: { readAttribute(reader, i, operation, SecurityResourceDefinition.Attribute.SSL_CONTEXT); break; } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } ParseUtils.requireNoContent(reader); }