use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class ModClusterSubsystemAdd method populateModel.
/**
* This is here so legacy configuration can be supported.
*/
@Override
protected void populateModel(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
if (operation.hasDefined(CommonAttributes.MOD_CLUSTER_CONFIG)) {
PathAddress opAddress = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR));
PathAddress parent = opAddress.append(ModClusterConfigResourceDefinition.PATH);
ModelNode targetOperation = Util.createAddOperation(parent);
for (AttributeDefinition def : ModClusterConfigResourceDefinition.ATTRIBUTES) {
def.validateAndSet(operation, targetOperation);
}
context.addStep(targetOperation, ModClusterConfigAdd.INSTANCE, OperationContext.Stage.MODEL, true);
}
// Inform handlers for child resources that we are part of the set of operations
// so they know we'll be utilizing any model they write. We do this in Stage.MODEL
// so in their Stage.MODEL they can decide to skip adding a runtime step
context.attach(SUBSYSTEM_ADD_KEY, Boolean.TRUE);
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class PooledConnectionFactoryAdd method getAdapterParams.
static List<PooledConnectionFactoryConfigProperties> getAdapterParams(ModelNode model, OperationContext context) throws OperationFailedException {
List<PooledConnectionFactoryConfigProperties> configs = new ArrayList<PooledConnectionFactoryConfigProperties>();
for (ConnectionFactoryAttribute nodeAttribute : PooledConnectionFactoryDefinition.ATTRIBUTES) {
if (!nodeAttribute.isResourceAdapterProperty())
continue;
AttributeDefinition definition = nodeAttribute.getDefinition();
ModelNode node = definition.resolveModelAttribute(context, model);
if (node.isDefined()) {
String value = node.asString();
configs.add(new PooledConnectionFactoryConfigProperties(nodeAttribute.getPropertyName(), value, nodeAttribute.getClassType()));
}
}
return configs;
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class AbstractFederationResourceDefinition method createAttributeWriterHandler.
@Override
protected OperationStepHandler createAttributeWriterHandler() {
List<SimpleAttributeDefinition> attributes = getAttributes();
final List<AttributeDefinition> alternativeAttributes = getAlternativesAttributes();
return new ReloadRequiredWriteAttributeHandler(attributes.toArray(new AttributeDefinition[attributes.size()])) {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
if (!alternativeAttributes.isEmpty()) {
context.addStep(new AlternativeAttributeValidationStepHandler(alternativeAttributes.toArray(new AttributeDefinition[alternativeAttributes.size()])), OperationContext.Stage.MODEL);
}
doRegisterModelWriteAttributeHandler(context, operation);
super.execute(context, operation);
}
};
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class AbstractIDMResourceDefinition method createAttributeWriterHandler.
@Override
protected OperationStepHandler createAttributeWriterHandler() {
List<SimpleAttributeDefinition> attributes = getAttributes();
final List<AttributeDefinition> alternativeAttributes = getAlternativesAttributes();
return new IDMConfigWriteAttributeHandler(attributes.toArray(new AttributeDefinition[attributes.size()])) {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
if (!alternativeAttributes.isEmpty()) {
context.addStep(new AlternativeAttributeValidationStepHandler(alternativeAttributes.toArray(new AttributeDefinition[alternativeAttributes.size()])), OperationContext.Stage.MODEL);
}
doRegisterModelWriteAttributeHandler(context, operation);
super.execute(context, operation);
}
};
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class EjbJarRuntimeResourceTestBase method testComponent.
/*
TODO implement a test of entity beans
@Test
public void testEntityBean() throws Exception {
testComponent(EJBComponentType.ENTITY, ???.class.getSimpleName());
}
*/
private void testComponent(EJBComponentType type, String name, boolean expectTimer) throws Exception {
ModelNode address = getComponentAddress(type, name).toModelNode();
address.protect();
ModelNode resourceDescription = executeOperation(managementClient, ModelDescriptionConstants.READ_RESOURCE_DESCRIPTION_OPERATION, address);
ModelNode resource = executeOperation(managementClient, ModelDescriptionConstants.READ_RESOURCE_OPERATION, address);
assertTrue(resourceDescription.get(ATTRIBUTES, COMPONENT_CLASS_NAME.getName()).isDefined());
assertEquals(ModelType.STRING, resourceDescription.get(ATTRIBUTES, COMPONENT_CLASS_NAME.getName(), DESCRIPTION).getType());
assertEquals(ModelType.STRING, resourceDescription.get(ATTRIBUTES, COMPONENT_CLASS_NAME.getName(), TYPE).asType());
assertTrue(resource.get(COMPONENT_CLASS_NAME.getName()).isDefined());
validateSecurity(address, resourceDescription, resource);
if (type.hasPool()) {
validatePool(address, resourceDescription, resource);
} else {
for (AttributeDefinition attr : POOL_ATTRIBUTES) {
assertFalse(resourceDescription.get(ModelDescriptionConstants.ATTRIBUTES).has(attr.getName()));
assertFalse(resource.has(attr.getName()));
}
}
if (type.hasTimer()) {
validateTimer(address, resourceDescription, resource, expectTimer);
} else {
assertFalse(resourceDescription.get(ModelDescriptionConstants.ATTRIBUTES).has(TimerAttributeDefinition.INSTANCE.getName()));
assertFalse(resource.has(TimerAttributeDefinition.INSTANCE.getName()));
}
}
Aggregations