use of org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder in project wildfly by wildfly.
the class TimerServiceResourceDefinition method registerDataStoreTransformers.
private static void registerDataStoreTransformers(ResourceTransformationDescriptionBuilder timerService) {
DataStoreTransformer dataStoreTransformer = new DataStoreTransformer();
timerService.getAttributeBuilder().setDiscard(DiscardAttributeChecker.ALWAYS, //this is ok, as default-data-store only has any sense with new model, but it is always set!
EJB3SubsystemModel.DEFAULT_DATA_STORE).end();
timerService.discardOperations(ModelDescriptionConstants.ADD);
timerService.setCustomResourceTransformer(dataStoreTransformer);
timerService.rejectChildResource(EJB3SubsystemModel.DATABASE_DATA_STORE_PATH);
ResourceTransformationDescriptionBuilder fileDataStore = timerService.addChildRedirection(EJB3SubsystemModel.FILE_DATA_STORE_PATH, new PathAddressTransformer() {
@Override
public PathAddress transform(PathElement current, Builder builder) {
return builder.getCurrent();
}
});
fileDataStore.addOperationTransformationOverride(ModelDescriptionConstants.ADD).inheritResourceAttributeDefinitions().setCustomOperationTransformer(dataStoreTransformer).end();
}
use of org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder in project wildfly by wildfly.
the class DynamicLoadProviderDefinition method buildTransformation.
static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder builder) {
ResourceTransformationDescriptionBuilder loadProviderBuilder = builder.addChildResource(PATH);
LoadMetricDefinition.buildTransformation(version, loadProviderBuilder);
CustomLoadMetricDefinition.buildTransformation(version, loadProviderBuilder);
}
use of org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder in project wildfly by wildfly.
the class ChannelResourceDefinition method buildTransformation.
static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
if (JGroupsModel.VERSION_3_0_0.requiresTransformation(version)) {
DynamicDiscardPolicy channelDiscardRejectPolicy = new DynamicDiscardPolicy() {
@Override
public DiscardPolicy checkResource(TransformationContext context, PathAddress address) {
// Check whether all channel resources are used by the infinispan subsystem, and transformed
// by its corresponding transformers; reject otherwise
// n.b. we need to hard-code the values because otherwise we would end up with cyclical dependency
String channelName = address.getLastElement().getValue();
PathAddress rootAddress = address.subAddress(0, address.size() - 2);
PathAddress subsystemAddress = rootAddress.append(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "infinispan"));
Resource infinispanResource;
try {
infinispanResource = context.readResourceFromRoot(subsystemAddress);
} catch (Resource.NoSuchResourceException ex) {
return DiscardPolicy.REJECT_AND_WARN;
}
ModelNode infinispanModel = Resource.Tools.readModel(infinispanResource);
if (infinispanModel.hasDefined("cache-container")) {
for (ModelNode container : infinispanModel.get("cache-container").asList()) {
ModelNode cacheContainer = container.get(0);
if (cacheContainer.hasDefined("transport")) {
ModelNode transport = cacheContainer.get("transport").get("jgroups");
if (transport.hasDefined("channel")) {
String channel = transport.get("channel").asString();
if (channel.equals(channelName)) {
return DiscardPolicy.SILENT;
}
} else {
// In that case, if this were the default channel, it can be discarded too
ModelNode subsystem = context.readResourceFromRoot(address.subAddress(0, address.size() - 1)).getModel();
if (subsystem.hasDefined(JGroupsSubsystemResourceDefinition.Attribute.DEFAULT_CHANNEL.getName())) {
if (subsystem.get(JGroupsSubsystemResourceDefinition.Attribute.DEFAULT_CHANNEL.getName()).asString().equals(channelName)) {
return DiscardPolicy.SILENT;
}
}
}
}
}
}
// No references to this channel, we need to reject it.
return DiscardPolicy.REJECT_AND_WARN;
}
};
parent.addChildResource(WILDCARD_PATH, channelDiscardRejectPolicy);
} else {
ResourceTransformationDescriptionBuilder builder = parent.addChildResource(WILDCARD_PATH);
if (JGroupsModel.VERSION_4_0_0.requiresTransformation(version)) {
DiscardAttributeChecker discarder = new DefaultDiscardAttributeChecker(false, true) {
@Override
protected boolean isValueDiscardable(PathAddress address, String attributeName, ModelNode attributeValue, TransformationContext context) {
return !attributeValue.isDefined() || attributeValue.equals(new ModelNode(address.getLastElement().getValue()));
}
};
builder.getAttributeBuilder().setDiscard(discarder, Attribute.CLUSTER.getDefinition()).addRejectCheck(RejectAttributeChecker.DEFINED, Attribute.CLUSTER.getDefinition());
}
ProtocolRegistration.buildTransformation(version, builder);
}
}
use of org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder in project wildfly by wildfly.
the class TransportResourceDefinition method buildTransformation.
static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
ResourceTransformationDescriptionBuilder builder = parent.addChildResource(WILDCARD_PATH);
AbstractProtocolResourceDefinition.addTransformations(version, builder);
if (JGroupsModel.VERSION_3_0_0.requiresTransformation(version)) {
builder.getAttributeBuilder().setValueConverter(new DefaultValueAttributeConverter(Attribute.SHARED.getDefinition()), Attribute.SHARED.getDefinition());
builder.setCustomResourceTransformer(new ResourceTransformer() {
@Override
public void transformResource(ResourceTransformationContext context, PathAddress address, Resource resource) throws OperationFailedException {
new LegacyPropertyResourceTransformer().transformResource(context, LEGACY_ADDRESS_TRANSFORMER.transform(address), resource);
}
});
builder.addOperationTransformationOverride(ModelDescriptionConstants.ADD).setCustomOperationTransformer(new SimpleOperationTransformer(new org.jboss.as.clustering.controller.transform.OperationTransformer() {
@Override
public ModelNode transformOperation(final ModelNode operation) {
operation.get(ModelDescriptionConstants.OP_ADDR).set(LEGACY_ADDRESS_TRANSFORMER.transform(Operations.getPathAddress(operation)).toModelNode());
return new LegacyPropertyAddOperationTransformer().transformOperation(operation);
}
})).inheritResourceAttributeDefinitions();
builder.addOperationTransformationOverride(ModelDescriptionConstants.REMOVE).setCustomOperationTransformer(new SimpleRemoveOperationTransformer(LEGACY_ADDRESS_TRANSFORMER));
builder.addOperationTransformationOverride(ModelDescriptionConstants.READ_ATTRIBUTE_OPERATION).setCustomOperationTransformer(new SimpleReadAttributeOperationTransformer(LEGACY_ADDRESS_TRANSFORMER));
builder.addOperationTransformationOverride(ModelDescriptionConstants.DESCRIBE).setCustomOperationTransformer(new SimpleDescribeOperationTransformer(LEGACY_ADDRESS_TRANSFORMER));
List<OperationTransformer> getOpTransformerChain = new LinkedList<>();
getOpTransformerChain.add(new SimplePathOperationTransformer(LEGACY_ADDRESS_TRANSFORMER));
getOpTransformerChain.add(new SimpleOperationTransformer(new LegacyPropertyMapGetOperationTransformer()));
ChainedOperationTransformer getOpChainedTransformer = new ChainedOperationTransformer(getOpTransformerChain, false);
builder.addRawOperationTransformationOverride(MapOperations.MAP_GET_DEFINITION.getName(), getOpChainedTransformer);
List<OperationTransformer> writeOpTransformerChain = new LinkedList<>();
writeOpTransformerChain.add(new SimplePathOperationTransformer(LEGACY_ADDRESS_TRANSFORMER));
writeOpTransformerChain.add(new LegacyPropertyWriteOperationTransformer());
ChainedOperationTransformer writeOpChainedTransformer = new ChainedOperationTransformer(writeOpTransformerChain, false);
for (String opName : Operations.getAllWriteAttributeOperationNames()) {
builder.addOperationTransformationOverride(opName).inheritResourceAttributeDefinitions().setCustomOperationTransformer(writeOpChainedTransformer);
}
// Reject thread pool configuration, discard if undefined, support EAP 6.x slaves using deprecated attributes
builder.addChildResource(ThreadPoolResourceDefinition.WILDCARD_PATH, RequiredChildResourceDiscardPolicy.REJECT_AND_WARN);
} else {
EnumSet.allOf(ThreadPoolResourceDefinition.class).forEach(p -> p.buildTransformation(version, parent));
}
}
use of org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder in project wildfly by wildfly.
the class RelayResourceDefinition method buildTransformation.
@SuppressWarnings("deprecation")
static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
ResourceTransformationDescriptionBuilder builder = parent.addChildResource(PATH);
RemoteSiteResourceDefinition.buildTransformation(version, builder);
PropertyResourceDefinition.buildTransformation(version, builder);
}
Aggregations