use of org.jboss.as.controller.transform.TransformationContext in project wildfly by wildfly.
the class JcaDistributedWorkManagerDefinition method registerTransformers300.
static void registerTransformers300(ResourceTransformationDescriptionBuilder parentBuilder) {
ResourceTransformationDescriptionBuilder builder = parentBuilder.addChildResource(PATH_DISTRIBUTED_WORK_MANAGER);
builder.addOperationTransformationOverride("add").inheritResourceAttributeDefinitions().setCustomOperationTransformer(new OperationTransformer() {
@Override
public TransformedOperation transformOperation(TransformationContext context, PathAddress address, ModelNode operation) throws OperationFailedException {
ModelNode copy = operation.clone();
copy.add("transport-jgroups-cluster").set(address.getLastElement().toString());
return new TransformedOperation(copy, TransformedOperation.ORIGINAL_RESULT);
}
}).end().getAttributeBuilder().setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(false, true, new ModelNode(false)), DWmParameters.ELYTRON_ENABLED.getAttribute()).addRejectCheck(RejectAttributeChecker.DEFINED, DWmParameters.ELYTRON_ENABLED.getAttribute()).end();
}
use of org.jboss.as.controller.transform.TransformationContext in project wildfly by wildfly.
the class XaDataSourceDefinition method registerTransformers120.
static void registerTransformers120(ResourceTransformationDescriptionBuilder parentBuilder) {
ResourceTransformationDescriptionBuilder builder = parentBuilder.addChildResource(PATH_XA_DATASOURCE);
builder.getAttributeBuilder().setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(new ModelNode(false)), CONNECTABLE).setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(false, false, new ModelNode(true)), STATISTICS_ENABLED).setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(new ModelNode(true)), ENLISTMENT_TRACE).setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(new ModelNode(LEGACY_MCP)), MCP).setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(false, true, new ModelNode(false)), Constants.ELYTRON_ENABLED, Constants.RECOVERY_ELYTRON_ENABLED).setDiscard(DiscardAttributeChecker.UNDEFINED, Constants.AUTHENTICATION_CONTEXT, RECOVERY_AUTHENTICATION_CONTEXT, CREDENTIAL_REFERENCE, RECOVERY_CREDENTIAL_REFERENCE).addRejectCheck(RejectAttributeChecker.DEFINED, ENLISTMENT_TRACE).addRejectCheck(RejectAttributeChecker.DEFINED, MCP).addRejectCheck(new RejectAttributeChecker.DefaultRejectAttributeChecker() {
@Override
public String getRejectionLogMessage(Map<String, ModelNode> attributes) {
return ConnectorLogger.ROOT_LOGGER.rejectAttributesMustBeTrue(attributes.keySet());
}
@Override
protected boolean rejectAttribute(PathAddress address, String attributeName, ModelNode attributeValue, TransformationContext context) {
//This will not get called if it was discarded, so reject if it is undefined (default==false) or if defined and != 'true'
return !attributeValue.isDefined() || !attributeValue.asString().equals("true");
}
}, STATISTICS_ENABLED).setDiscard(DiscardAttributeChecker.UNDEFINED, TRACKING).addRejectCheck(RejectAttributeChecker.DEFINED, TRACKING).addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, ENABLED).addRejectCheck(RejectAttributeChecker.DEFINED, Constants.ELYTRON_ENABLED, Constants.RECOVERY_ELYTRON_ENABLED, AUTHENTICATION_CONTEXT, RECOVERY_AUTHENTICATION_CONTEXT, CREDENTIAL_REFERENCE, RECOVERY_CREDENTIAL_REFERENCE).end().addOperationTransformationOverride(DATASOURCE_ENABLE.getName()).end().addOperationTransformationOverride(DATASOURCE_DISABLE.getName()).end();
}
use of org.jboss.as.controller.transform.TransformationContext in project wildfly by wildfly.
the class XaDataSourceDefinition method registerTransformers130.
static void registerTransformers130(ResourceTransformationDescriptionBuilder parentBuilder) {
ResourceTransformationDescriptionBuilder builder = parentBuilder.addChildResource(PATH_XA_DATASOURCE);
builder.getAttributeBuilder().setDiscard(new DiscardAttributeChecker.DefaultDiscardAttributeChecker() {
@Override
protected boolean isValueDiscardable(PathAddress address, String attributeName, ModelNode attributeValue, TransformationContext context) {
return attributeValue.equals(new ModelNode(false));
}
}, TRACKING).setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(false, true, new ModelNode(false)), Constants.ELYTRON_ENABLED, Constants.RECOVERY_ELYTRON_ENABLED).setDiscard(DiscardAttributeChecker.UNDEFINED, Constants.AUTHENTICATION_CONTEXT, RECOVERY_AUTHENTICATION_CONTEXT, CREDENTIAL_REFERENCE, RECOVERY_CREDENTIAL_REFERENCE).addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, ENABLED).addRejectCheck(RejectAttributeChecker.DEFINED, TRACKING).addRejectCheck(RejectAttributeChecker.DEFINED, Constants.ELYTRON_ENABLED, Constants.RECOVERY_ELYTRON_ENABLED, AUTHENTICATION_CONTEXT, RECOVERY_AUTHENTICATION_CONTEXT, CREDENTIAL_REFERENCE, RECOVERY_CREDENTIAL_REFERENCE).end();
}
use of org.jboss.as.controller.transform.TransformationContext 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.TransformationContext in project wildfly by wildfly.
the class JGroupsTransportResourceDefinition method buildTransformation.
@SuppressWarnings("deprecation")
static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
ResourceTransformationDescriptionBuilder builder = InfinispanModel.VERSION_4_0_0.requiresTransformation(version) ? parent.addChildRedirection(PATH, LEGACY_PATH) : parent.addChildResource(PATH);
if (InfinispanModel.VERSION_3_0_0.requiresTransformation(version)) {
// We need to reject if we cannot determine the underlying stack via the jgroups subsystem
Rejecter stackRejecter = new Rejecter() {
@Override
public boolean reject(PathAddress address, String name, ModelNode value, ModelNode model, TransformationContext context) {
if (value.isDefined())
return false;
PathAddress rootAddress = address.subAddress(0, address.size() - 3);
PathAddress subsystemAddress = rootAddress.append(JGroupsSubsystemResourceDefinition.PATH);
ModelNode subsystemModel = context.readResourceFromRoot(subsystemAddress).getModel();
String channelName = null;
if (model.hasDefined(Attribute.CHANNEL.getName())) {
ModelNode channel = model.get(Attribute.CHANNEL.getName());
if (channel.getType() == ModelType.STRING) {
channelName = channel.asString();
}
} else if (subsystemModel.hasDefined(JGroupsSubsystemResourceDefinition.Attribute.DEFAULT_CHANNEL.getName())) {
ModelNode defaultChannel = subsystemModel.get(JGroupsSubsystemResourceDefinition.Attribute.DEFAULT_CHANNEL.getName());
if (defaultChannel.getType() == ModelType.STRING) {
channelName = defaultChannel.asString();
}
}
if (channelName == null)
return true;
String stackName = null;
PathAddress channelAddress = subsystemAddress.append(ChannelResourceDefinition.pathElement(channelName));
try {
ModelNode channel = context.readResourceFromRoot(channelAddress).getModel();
if (channel.hasDefined(ChannelResourceDefinition.Attribute.STACK.getName())) {
ModelNode stack = channel.get(ChannelResourceDefinition.Attribute.STACK.getName());
if (stack.getType() == ModelType.STRING) {
stackName = stack.asString();
}
} else if (subsystemModel.hasDefined(JGroupsSubsystemResourceDefinition.Attribute.DEFAULT_STACK.getName())) {
ModelNode defaultStack = subsystemModel.get(JGroupsSubsystemResourceDefinition.Attribute.DEFAULT_STACK.getName());
if (defaultStack.getType() == ModelType.STRING) {
stackName = defaultStack.asString();
}
}
} catch (NoSuchResourceException e) {
// Ignore
}
return (stackName == null);
}
@Override
public String getRejectedMessage(Set<String> attributes) {
return InfinispanLogger.ROOT_LOGGER.indeterminiteStack();
}
};
// Lookup the stack via the jgroups channel resource, if necessary
Converter stackConverter = new Converter() {
@Override
public void convert(PathAddress address, String name, ModelNode value, ModelNode model, TransformationContext context) {
if (!value.isDefined()) {
PathAddress rootAddress = address.subAddress(0, address.size() - 3);
PathAddress subsystemAddress = rootAddress.append(JGroupsSubsystemResourceDefinition.PATH);
ModelNode subsystemModel = context.readResourceFromRoot(subsystemAddress).getModel();
String channelName = null;
if (model.hasDefined(Attribute.CHANNEL.getName())) {
ModelNode channel = model.get(Attribute.CHANNEL.getName());
if (channel.getType() == ModelType.STRING) {
channelName = channel.asString();
}
} else if (subsystemModel.hasDefined(JGroupsSubsystemResourceDefinition.Attribute.DEFAULT_CHANNEL.getName())) {
ModelNode defaultChannel = subsystemModel.get(JGroupsSubsystemResourceDefinition.Attribute.DEFAULT_CHANNEL.getName());
if (defaultChannel.getType() == ModelType.STRING) {
channelName = defaultChannel.asString();
}
}
if (channelName != null) {
PathAddress channelAddress = subsystemAddress.append(ChannelResourceDefinition.pathElement(channelName));
try {
ModelNode channel = context.readResourceFromRoot(channelAddress).getModel();
if (channel.hasDefined(ChannelResourceDefinition.Attribute.STACK.getName())) {
ModelNode stack = channel.get(ChannelResourceDefinition.Attribute.STACK.getName());
if (stack.getType() == ModelType.STRING) {
value.set(stack.asString());
}
} else if (subsystemModel.hasDefined(JGroupsSubsystemResourceDefinition.Attribute.DEFAULT_STACK.getName())) {
ModelNode defaultStack = subsystemModel.get(JGroupsSubsystemResourceDefinition.Attribute.DEFAULT_STACK.getName());
if (defaultStack.getType() == ModelType.STRING) {
value.set(defaultStack.asString());
}
}
} catch (NoSuchResourceException e) {
// Ignore
}
}
}
}
};
builder.getAttributeBuilder().addRejectCheck(new SimpleRejectAttributeChecker(stackRejecter), DeprecatedAttribute.STACK.getDefinition()).setValueConverter(new SimpleAttributeConverter(stackConverter), DeprecatedAttribute.STACK.getDefinition()).addRename(Attribute.CHANNEL.getDefinition(), DeprecatedAttribute.CLUSTER.getDefinition().getName()).end();
}
}
Aggregations