use of org.jboss.as.controller.transform.description.AttributeConverter in project wildfly by wildfly.
the class IIOPExtension method registerTransformers.
protected static void registerTransformers(final SubsystemRegistration subsystem) {
ChainedTransformationDescriptionBuilder chained = ResourceTransformationDescriptionBuilder.Factory.createChainedSubystemInstance(CURRENT_MODEL_VERSION);
ResourceTransformationDescriptionBuilder builder = chained.createBuilder(CURRENT_MODEL_VERSION, VERSION_1);
builder.getAttributeBuilder().addRejectCheck(RejectAttributeChecker.DEFINED, IIOPRootDefinition.SERVER_SSL_CONTEXT).addRejectCheck(RejectAttributeChecker.DEFINED, IIOPRootDefinition.CLIENT_SSL_CONTEXT).addRejectCheck(RejectAttributeChecker.DEFINED, IIOPRootDefinition.AUTHENTICATION_CONTEXT).addRejectCheck(new RejectAttributeChecker.DefaultRejectAttributeChecker() {
@Override
protected boolean rejectAttribute(PathAddress pathAddress, String s, ModelNode attributeValue, TransformationContext transformationContext) {
return attributeValue.asString().equals("true");
}
@Override
public String getRejectionLogMessage(Map<String, ModelNode> map) {
return IIOPLogger.ROOT_LOGGER.serverRequiresSslNotSupportedInPreviousVersions();
}
}, IIOPRootDefinition.SERVER_REQUIRES_SSL).addRejectCheck(new RejectAttributeChecker.DefaultRejectAttributeChecker() {
@Override
protected boolean rejectAttribute(PathAddress pathAddress, String s, ModelNode attributeValue, TransformationContext transformationContext) {
return attributeValue.asString().equalsIgnoreCase(Constants.ELYTRON);
}
@Override
public String getRejectionLogMessage(Map<String, ModelNode> map) {
return IIOPLogger.ROOT_LOGGER.elytronInitializerNotSupportedInPreviousVersions();
}
}, IIOPRootDefinition.SECURITY).setValueConverter(new AttributeConverter() {
@Override
public void convertOperationParameter(PathAddress pathAddress, String s, ModelNode attributeValue, ModelNode operation, TransformationContext transformationContext) {
convert(attributeValue);
}
@Override
public void convertResourceAttribute(PathAddress pathAddress, String s, ModelNode attributeValue, TransformationContext transformationContext) {
convert(attributeValue);
}
private void convert(ModelNode attributeValue) {
final boolean clientRequiresSsl = attributeValue.asBoolean();
if (clientRequiresSsl) {
attributeValue.set(SSLConfigValue.MUTUALAUTH.toString());
} else {
attributeValue.set(SSLConfigValue.NONE.toString());
}
}
}, IIOPRootDefinition.CLIENT_REQUIRES_SSL);
chained.buildAndRegister(subsystem, new ModelVersion[] { VERSION_1 });
}
use of org.jboss.as.controller.transform.description.AttributeConverter in project wildfly by wildfly.
the class RemoteSiteResourceDefinition method buildTransformation.
@SuppressWarnings("deprecation")
static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
ResourceTransformationDescriptionBuilder builder = parent.addChildResource(WILDCARD_PATH);
if (JGroupsModel.VERSION_3_0_0.requiresTransformation(version)) {
AttributeConverter converter = new AttributeConverter() {
@Override
public void convertOperationParameter(PathAddress address, String name, ModelNode value, ModelNode operation, TransformationContext context) {
// Nothing to convert
}
@Override
public void convertResourceAttribute(PathAddress address, String name, ModelNode value, TransformationContext context) {
ModelNode remoteSite = context.readResourceFromRoot(address).getModel();
String channelName = remoteSite.get(Attribute.CHANNEL.getName()).asString();
if (DeprecatedAttribute.STACK.getName().equals(name)) {
PathAddress subsystemAddress = address.subAddress(0, address.size() - 3);
PathAddress channelAddress = subsystemAddress.append(ChannelResourceDefinition.pathElement(channelName));
ModelNode channel = context.readResourceFromRoot(channelAddress).getModel();
if (channel.hasDefined(ChannelResourceDefinition.Attribute.STACK.getName())) {
value.set(channel.get(ChannelResourceDefinition.Attribute.STACK.getName()).asString());
} else {
ModelNode subsystem = context.readResourceFromRoot(subsystemAddress).getModel();
value.set(subsystem.get(JGroupsSubsystemResourceDefinition.Attribute.DEFAULT_STACK.getName()).asString());
}
} else if (DeprecatedAttribute.CLUSTER.getName().equals(name)) {
value.set(channelName);
} else {
throw new IllegalStateException();
}
}
};
builder.getAttributeBuilder().setValueConverter(converter, DeprecatedAttribute.STACK.getDefinition(), DeprecatedAttribute.CLUSTER.getDefinition()).setDiscard(DiscardAttributeChecker.ALWAYS, Attribute.CHANNEL.getDefinition()).end();
}
}
use of org.jboss.as.controller.transform.description.AttributeConverter in project wildfly by wildfly.
the class AbstractProtocolResourceDefinition method addTransformations.
/**
* Builds transformations common to both stack protocols and transport.
*/
@SuppressWarnings("deprecation")
static void addTransformations(ModelVersion version, ResourceTransformationDescriptionBuilder builder) {
if (JGroupsModel.VERSION_3_0_0.requiresTransformation(version)) {
AttributeConverter typeConverter = new AttributeConverter.DefaultAttributeConverter() {
@Override
protected void convertAttribute(PathAddress address, String name, ModelNode value, TransformationContext context) {
if (!value.isDefined()) {
value.set(address.getLastElement().getValue());
}
}
};
builder.getAttributeBuilder().setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(Attribute.MODULE.getDefinition().getDefaultValue()), Attribute.MODULE.getDefinition()).addRejectCheck(RejectAttributeChecker.DEFINED, Attribute.MODULE.getDefinition()).setValueConverter(typeConverter, DeprecatedAttribute.TYPE.getDefinition()).end();
builder.addRawOperationTransformationOverride(MapOperations.MAP_GET_DEFINITION.getName(), new SimpleOperationTransformer(new LegacyPropertyMapGetOperationTransformer()));
for (String opName : Operations.getAllWriteAttributeOperationNames()) {
builder.addOperationTransformationOverride(opName).inheritResourceAttributeDefinitions().setCustomOperationTransformer(new LegacyPropertyWriteOperationTransformer());
}
}
PropertyResourceDefinition.buildTransformation(version, builder);
}
use of org.jboss.as.controller.transform.description.AttributeConverter in project wildfly by wildfly.
the class RemoteTransactionResourceTransformer method accept.
@SuppressWarnings("deprecation")
@Override
public void accept(ModelVersion version) {
if (InfinispanModel.VERSION_15_0_0.requiresTransformation(version)) {
AttributeConverter converter = new SimpleAttributeConverter(new SimpleAttributeConverter.Converter() {
@Override
public void convert(PathAddress address, String name, ModelNode value, ModelNode model, TransformationContext context) {
ModelNode parentModel = context.readResourceFromRoot(address.getParent()).getModel();
if (parentModel.hasDefined(RemoteCacheContainerResourceDefinition.Attribute.TRANSACTION_TIMEOUT.getName())) {
value.set(parentModel.get(RemoteCacheContainerResourceDefinition.Attribute.TRANSACTION_TIMEOUT.getName()));
}
}
});
this.builder.getAttributeBuilder().setValueConverter(converter, RemoteTransactionResourceDefinition.Attribute.TIMEOUT.getDefinition());
}
}
Aggregations