use of org.jboss.as.controller.PathElement in project wildfly by wildfly.
the class EeLegacySubsystemTestCase method createAdditionalInitialization.
@Override
protected AdditionalInitialization createAdditionalInitialization() {
return new AdditionalInitialization() {
@Override
protected RunningMode getRunningMode() {
return RunningMode.ADMIN_ONLY;
}
@Override
protected void initializeExtraSubystemsAndModel(ExtensionRegistry extensionRegistry, Resource rootResource, ManagementResourceRegistration rootRegistration, RuntimeCapabilityRegistry capabilityRegistry) {
if (!extensionAdded) {
// extensionAdded = true;
// bean validation depends on EE, so we can't use the real subsystem here
final OperationDefinition removeExtension = new SimpleOperationDefinitionBuilder("remove", NonResolvingResourceDescriptionResolver.INSTANCE).build();
final OperationDefinition addExtension = new SimpleOperationDefinitionBuilder("add", NonResolvingResourceDescriptionResolver.INSTANCE).addParameter(new SimpleAttributeDefinitionBuilder("module", ModelType.STRING).setRequired(true).build()).build();
PathElement bvExtension = PathElement.pathElement(EXTENSION, "org.wildfly.extension.bean-validation");
ManagementResourceRegistration extensionRegistration = rootRegistration.registerSubModel(new SimpleResourceDefinition(bvExtension, NonResolvingResourceDescriptionResolver.INSTANCE));
extensionRegistration.registerReadOnlyAttribute(new SimpleAttributeDefinitionBuilder("module", ModelType.STRING).setRequired(true).build(), null);
extensionRegistration.registerOperationHandler(removeExtension, new ReloadRequiredRemoveStepHandler());
extensionRegistration.registerOperationHandler(addExtension, new ReloadRequiredAddStepHandler(new SimpleAttributeDefinitionBuilder("module", ModelType.STRING).setRequired(true).build()));
final OperationDefinition removeSubsystem = new SimpleOperationDefinitionBuilder("remove", NonResolvingResourceDescriptionResolver.INSTANCE).build();
final OperationDefinition addSubsystem = new SimpleOperationDefinitionBuilder("add", NonResolvingResourceDescriptionResolver.INSTANCE).build();
PathElement bvSubsystem = PathElement.pathElement(SUBSYSTEM, "bean-validation");
ManagementResourceRegistration subsystemRegistration = rootRegistration.registerSubModel(new SimpleResourceDefinition(bvSubsystem, NonResolvingResourceDescriptionResolver.INSTANCE));
subsystemRegistration.registerOperationHandler(removeSubsystem, new ReloadRequiredRemoveStepHandler());
subsystemRegistration.registerOperationHandler(addSubsystem, new ReloadRequiredAddStepHandler());
}
}
};
}
use of org.jboss.as.controller.PathElement in project wildfly by wildfly.
the class MigrateOperation method connectionFactoryIsUsingInVMConnectors.
private boolean connectionFactoryIsUsingInVMConnectors(OperationContext context, ModelNode connectionFactoryAddOp) {
ModelNode connector = connectionFactoryAddOp.get(CONNECTOR);
if (connector.isDefined()) {
PathAddress connectionFactoryAddress = pathAddress(connectionFactoryAddOp.get(OP_ADDR));
PathElement relativeLegacyServerAddress = connectionFactoryAddress.getParent().getLastElement();
// read the server resource related to the context current address (which is the messaging subsystem address).
Resource serverResource = context.readResource(pathAddress(relativeLegacyServerAddress), false);
Set<String> definedInVMConnectors = serverResource.getChildrenNames("in-vm-connector");
// legacy connector is a property list where the name is the connector and the value is undefined
List<Property> connectorProps = connector.asPropertyList();
for (Property connectorProp : connectorProps) {
String connectorName = connectorProp.getName();
if (definedInVMConnectors.contains(connectorName)) {
return true;
}
}
}
return false;
}
use of org.jboss.as.controller.PathElement in project wildfly by wildfly.
the class JacORBSubsystemTestCase method testParseEmptySubsystem.
@Test
public void testParseEmptySubsystem() throws Exception {
// parse the subsystem xml into operations.
String subsystemXml = "<subsystem xmlns=\"" + JacORBSubsystemParser.Namespace.CURRENT.getUriString() + "\">" + "</subsystem>";
List<ModelNode> operations = super.parse(subsystemXml);
// check that we have the expected number of operations.
Assert.assertEquals(1, operations.size());
// check that each operation has the correct content.
ModelNode addSubsystem = operations.get(0);
Assert.assertEquals(ADD, addSubsystem.get(OP).asString());
PathAddress addr = PathAddress.pathAddress(addSubsystem.get(OP_ADDR));
Assert.assertEquals(1, addr.size());
PathElement element = addr.getElement(0);
Assert.assertEquals(SUBSYSTEM, element.getKey());
Assert.assertEquals(JacORBExtension.SUBSYSTEM_NAME, element.getValue());
}
use of org.jboss.as.controller.PathElement in project wildfly by wildfly.
the class JacORBSubsystemTestCase method testParseEmptySubsystem_1_0.
@Test
public void testParseEmptySubsystem_1_0() throws Exception {
// parse the subsystem xml into operations.
String subsystemXml = "<subsystem xmlns=\"" + JacORBSubsystemParser.Namespace.JacORB_1_0.getUriString() + "\">" + "</subsystem>";
List<ModelNode> operations = super.parse(subsystemXml);
// check that we have the expected number of operations.
Assert.assertEquals(1, operations.size());
// check that each operation has the correct content.
ModelNode addSubsystem = operations.get(0);
Assert.assertEquals(ADD, addSubsystem.get(OP).asString());
PathAddress addr = PathAddress.pathAddress(addSubsystem.get(OP_ADDR));
Assert.assertEquals(1, addr.size());
PathElement element = addr.getElement(0);
Assert.assertEquals(SUBSYSTEM, element.getKey());
Assert.assertEquals(JacORBExtension.SUBSYSTEM_NAME, element.getValue());
}
use of org.jboss.as.controller.PathElement in project wildfly by wildfly.
the class JacORBSubsystemTestCase method testParseSubsystem_1_0.
// Tests for the version 1.0 of the JacORB subsystem configuration.
@Test
public void testParseSubsystem_1_0() throws Exception {
List<ModelNode> operations = super.parse(ModelTestUtils.readResource(this.getClass(), "subsystem-1.0.xml"));
// check that we have the expected number of operations.
Assert.assertEquals(1, operations.size());
// check that each operation has the correct content.
ModelNode addSubsystem = operations.get(0);
Assert.assertEquals(ADD, addSubsystem.get(OP).asString());
PathAddress addr = PathAddress.pathAddress(addSubsystem.get(OP_ADDR));
Assert.assertEquals(1, addr.size());
PathElement element = addr.getElement(0);
Assert.assertEquals(SUBSYSTEM, element.getKey());
Assert.assertEquals(JacORBExtension.SUBSYSTEM_NAME, element.getValue());
}
Aggregations