DeprecatedAttribute(org.jboss.as.clustering.controller.Attribute attribute) { this.definition = attribute.getDefinition(); }
void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) { ResourceTransformationDescriptionBuilder builder = parent.addChildResource(this.definition); if (JGroupsModel.VERSION_6_0_0.requiresTransformation(version)) { builder.getAttributeBuilder().setValueConverter(new DefaultValueAttributeConverter(this.queueLength.getDefinition()), this.queueLength.getName()); } if (JGroupsModel.VERSION_5_0_0.requiresTransformation(version)) { for (Attribute attribute : Arrays.asList(this.minThreads, this.maxThreads)) { builder.getAttributeBuilder().setValueConverter(new DefaultValueAttributeConverter(attribute.getDefinition()), attribute.getName()); } } } }
@Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.identifier = this.attribute.resolveModelAttribute(context, model).asString(); return this; }
XMLElement(Attribute attribute) { this.name = attribute.getName(); }
XMLAttribute(Attribute attribute) { this.name = attribute.getName(); }
public ResourceDescriptor addExtraParameters(Iterable<? extends Attribute> parameters) { for (Attribute parameter : parameters) { this.parameters.add(parameter.getDefinition()); } return this; }
private static void require(XMLExtendedStreamReader reader, ModelNode operation, Attribute... attributes) throws XMLStreamException { for (Attribute attribute : attributes) { if (!operation.hasDefined(attribute.getName())) { AttributeDefinition definition = attribute.getDefinition(); Set<String> names = Collections.singleton(definition.getXmlName()); throw definition.getParser().isParseAsElement() ? ParseUtils.missingRequiredElement(reader, names) : ParseUtils.missingRequired(reader, names); } } }
<E extends Enum<E> & org.jboss.as.clustering.controller.Attribute> LegacyAddOperationTransformation(Class<E> attributeClass) { // If none of the specified attributes are defined, then this is a legacy operation this.legacy = operation -> { for (org.jboss.as.clustering.controller.Attribute attribute : EnumSet.allOf(attributeClass)) { if (operation.hasDefined(attribute.getName())) return false; } return true; }; }
@Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { for (ColumnAttribute column : EnumSet.allOf(ColumnAttribute.class)) { ModelNode columnModel = column.resolveModelAttribute(context, model); String name = column.getColumnName().resolveModelAttribute(context, columnModel).asString(); String type = column.getColumnType().resolveModelAttribute(context, columnModel).asString(); this.columns.put(column, new AbstractMap.SimpleImmutableEntry<>(name, type)); } this.fetchSize = FETCH_SIZE.resolveModelAttribute(context, model).asInt(); this.prefix = this.prefixAttribute.resolveModelAttribute(context, model).asString(); return this; }
public ResourceDescriptor addAlias(Attribute alias, Attribute target) { this.attributeTranslations.put(alias.getDefinition(), () -> target); return this; }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { if (this.readHandler != null) { this.readHandler.execute(context, operation); } else { try { // If attribute has no read handler, simulate one ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS, false).getModel(); ModelNode result = context.getResult(); if (model.hasDefined(this.targetAttribute.getName())) { result.set(model.get(this.targetAttribute.getName())); } else if (Operations.isIncludeDefaults(operation)) { result.set(this.targetAttribute.getDefinition().getDefaultValue()); } } catch (Resource.NoSuchResourceException ignore) { // If the target resource does not exist return UNDEFINED return; } } ModelNode result = context.getResult(); result.set(this.translator.translate(context, result)); } }
private static boolean hasDefined(ModelNode model, Collection<? extends Attribute> attributes) { for (Attribute attribute : attributes) { if (model.hasDefined(attribute.getName())) return true; } return false; }
@Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { int maxThreads = this.definition.getMaxThreads().resolveModelAttribute(context, model).asInt(); int minThreads = this.definition.getMinThreads().resolveModelAttribute(context, model).asInt(); int queueLength = this.definition.getQueueLength().resolveModelAttribute(context, model).asInt(); long keepAliveTime = this.definition.getKeepAliveTime().resolveModelAttribute(context, model).asLong(); this.factory = new ExecutorFactory() { @Override public ExecutorService getExecutor(Properties property) { ThreadFactory clThreadFactory = new ClassLoaderThreadFactory(ClientThreadPoolServiceConfigurator.this, AccessController.doPrivileged((PrivilegedAction<ClassLoader>) ClassLoaderThreadFactory.class::getClassLoader)); return new ThreadPoolExecutor(minThreads, maxThreads, keepAliveTime, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(queueLength), clThreadFactory); } }; return this; }
public ResourceDescriptor addAttributes(Iterable<? extends Attribute> attributes) { for (Attribute attribute : attributes) { this.attributes.add(attribute.getDefinition()); } return this; }
@Override void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) { ResourceTransformationDescriptionBuilder builder = parent.addChildResource(this.getDefinition()); if (JGroupsModel.VERSION_6_0_0.requiresTransformation(version)) { for (Attribute attribute : Arrays.asList(this.getMinThreads(), this.getMaxThreads(), this.getQueueLength())) { builder.getAttributeBuilder().setValueConverter(new DefaultValueAttributeConverter(attribute.getDefinition()), attribute.getName()); } } } },
public static ModelNode createMapClearOperation(PathAddress address, Attribute attribute) { ModelNode operation = Util.createOperation(MapOperations.MAP_CLEAR_DEFINITION, address); operation.get(ModelDescriptionConstants.NAME).set(attribute.getName()); return operation; }
@Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { ThreadPoolExecutorFactory<?> factory = new BlockingThreadPoolExecutorFactory( this.definition.getMaxThreads().resolveModelAttribute(context, model).asInt(), this.definition.getMinThreads().resolveModelAttribute(context, model).asInt(), this.definition.getQueueLength().resolveModelAttribute(context, model).asInt(), this.definition.getKeepAliveTime().resolveModelAttribute(context, model).asLong() ) { @Override public ExecutorService createExecutor(ThreadFactory factory) { return super.createExecutor(new ClassLoaderThreadFactory(factory, WildFlySecurityManager.doUnchecked(GET_CLASS_LOADER_ACTION))); } }; this.builder.threadPoolFactory(factory); return this; }
public ResourceDescriptor addAttributeTranslation(Attribute sourceAttribute, AttributeTranslation translation) { this.attributeTranslations.put(sourceAttribute.getDefinition(), translation); return this; }
void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) { ResourceTransformationDescriptionBuilder builder = parent.addChildResource(this.definition); if (JGroupsModel.VERSION_6_0_0.requiresTransformation(version)) { builder.getAttributeBuilder().setValueConverter(new DefaultValueAttributeConverter(this.queueLength.getDefinition()), this.queueLength.getName()); } if (JGroupsModel.VERSION_5_0_0.requiresTransformation(version)) { for (Attribute attribute : Arrays.asList(this.minThreads, this.maxThreads)) { builder.getAttributeBuilder().setValueConverter(new DefaultValueAttributeConverter(attribute.getDefinition()), attribute.getName()); } } } }
/** * Creates an add operation using the specified address and parameters * @param address a path address * @param parameters a map of values per attribute * @return an add operation */ public static ModelNode createAddOperation(PathAddress address, Map<Attribute, ModelNode> parameters) { ModelNode operation = Util.createAddOperation(address); for (Map.Entry<Attribute, ModelNode> entry : parameters.entrySet()) { operation.get(entry.getKey().getName()).set(entry.getValue()); } return operation; }