use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.
the class XTSSubsystemTestCase method testBoot1_1_0.
private void testBoot1_1_0(ModelTestControllerVersion controllerVersion) throws Exception {
String subsystemXml = readResource("subsystem.xml");
ModelVersion modelVersion = ModelVersion.create(1, 1, 0);
//Use the non-runtime version of the extension which will happen on the HC
KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT).setSubsystemXml(subsystemXml);
builder.createLegacyKernelServicesBuilder(null, controllerVersion, modelVersion).configureReverseControllerCheck(AdditionalInitialization.MANAGEMENT, null, new OperationFixer() {
@Override
public ModelNode fixOperation(ModelNode operation) {
String name = operation.get(ModelDescriptionConstants.OP).asString();
PathAddress addr = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
if (name.equals(ModelDescriptionConstants.ADD) && addr.size() == 1 && addr.getElement(0).equals(XTSExtension.SUBSYSTEM_PATH)) {
operation.get(ModelDescriptionConstants.HOST).set("default-host");
operation.get(XTSSubsystemDefinition.DEFAULT_CONTEXT_PROPAGATION.getName()).set(false);
}
return operation;
}
}).addMavenResourceURL("org.jboss.as:jboss-as-xts:" + controllerVersion.getMavenGavVersion());
KernelServices mainServices = builder.build();
KernelServices legacyServices = mainServices.getLegacyServices(modelVersion);
Assert.assertTrue(mainServices.isSuccessfulBoot());
Assert.assertTrue(legacyServices.isSuccessfulBoot());
checkSubsystemModelTransformation(mainServices, modelVersion);
}
use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.
the class ProtocolResourceRegistrationHandler method findProtocol.
@Override
public Protocol findProtocol(OperationContext context) throws ClassNotFoundException, ModuleLoadException {
PathAddress address = context.getCurrentAddress();
String channelName = address.getParent().getLastElement().getValue();
String protocolName = address.getLastElement().getValue();
ServiceRegistry registry = context.getServiceRegistry(false);
ServiceController<?> controller = registry.getService(JGroupsRequirement.CHANNEL.getServiceName(context, channelName));
if (controller != null) {
Channel channel = (Channel) controller.getValue();
if (channel != null) {
controller = registry.getService(JGroupsRequirement.CHANNEL_SOURCE.getServiceName(context, channelName));
ChannelFactory factory = (ChannelFactory) controller.getValue();
if (factory != null) {
ProtocolStackConfiguration configuration = factory.getProtocolStackConfiguration();
ProtocolConfiguration<? extends TP> transport = configuration.getTransport();
if (transport.getName().equals(protocolName)) {
Class<? extends Protocol> protocolClass = transport.createProtocol().getClass();
return channel.getProtocolStack().findProtocol(protocolClass);
}
for (ProtocolConfiguration<? extends Protocol> protocol : configuration.getProtocols()) {
if (protocol.getName().equals(protocolName)) {
Class<? extends Protocol> protocolClass = protocol.createProtocol().getClass();
return channel.getProtocolStack().findProtocol(protocolClass);
}
}
}
}
}
return null;
}
use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.
the class RelayConfigurationBuilder method configure.
@Override
public Builder<RelayConfiguration> configure(OperationContext context, ModelNode model) throws OperationFailedException {
this.siteName = SITE.resolveModelAttribute(context, model).asString();
PathAddress address = context.getCurrentAddress();
Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
this.sites = resource.getChildren(RemoteSiteResourceDefinition.WILDCARD_PATH.getKey()).stream().map(entry -> new InjectedValueDependency<>(new RemoteSiteServiceNameProvider(address, entry.getPathElement()), RemoteSiteConfiguration.class)).collect(Collectors.toList());
return super.configure(context, model);
}
use of org.jboss.as.controller.PathAddress 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.PathAddress in project wildfly by wildfly.
the class ProtocolResourceRegistrationHandler method execute.
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
OverrideDescriptionProvider provider = new OverrideDescriptionProvider() {
@Override
public Map<String, ModelNode> getAttributeOverrideDescriptions(Locale locale) {
return Collections.emptyMap();
}
@Override
public Map<String, ModelNode> getChildTypeOverrideDescriptions(Locale locale) {
StandardResourceDescriptionResolver resolver = new JGroupsResourceDescriptionResolver();
String description = resolver.getChildTypeDescription(ProtocolResourceDefinition.WILDCARD_PATH.getKey(), locale, resolver.getResourceBundle(locale));
ModelNode result = new ModelNode();
result.get(ModelDescriptionConstants.DESCRIPTION).set(description);
return Collections.singletonMap(ProtocolResourceDefinition.WILDCARD_PATH.getKey(), result);
}
};
Resource resource = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS);
String stack = STACK.resolveModelAttribute(context, resource.getModel()).asString();
ManagementResourceRegistration registration = context.getResourceRegistrationForUpdate().registerOverrideModel(context.getCurrentAddressValue(), provider);
PathAddress stackAddress = context.getCurrentAddress().getParent().append(StackResourceDefinition.pathElement(stack));
Resource stackResource = context.readResourceFromRoot(stackAddress, false);
for (String name : stackResource.getChildrenNames(TransportResourceDefinition.WILDCARD_PATH.getKey())) {
PathAddress transportAddress = stackAddress.append(TransportResourceDefinition.pathElement(name));
ModelNode transport = context.readResourceFromRoot(transportAddress, false).getModel();
String moduleName = MODULE.resolveModelAttribute(context, transport).asString();
Class<? extends Protocol> transportClass = findProtocolClass(context, name, moduleName);
registration.registerSubModel(this.createProtocolResourceDefinition(name, transportClass));
resource.registerChild(ProtocolResourceDefinition.pathElement(name), PlaceholderResource.INSTANCE);
}
for (String name : stackResource.getChildrenNames(ProtocolResourceDefinition.WILDCARD_PATH.getKey())) {
Resource protocolResource = context.readResourceFromRoot(stackAddress.append(ProtocolResourceDefinition.pathElement(name)), false);
String moduleName = MODULE.resolveModelAttribute(context, protocolResource.getModel()).asString();
Class<? extends Protocol> protocolClass = findProtocolClass(context, name, moduleName);
registration.registerSubModel(this.createProtocolResourceDefinition(name, protocolClass));
resource.registerChild(ProtocolResourceDefinition.pathElement(name), PlaceholderResource.INSTANCE);
}
if (stackResource.hasChild(RelayResourceDefinition.PATH)) {
registration.registerSubModel(this.createProtocolResourceDefinition(RelayConfiguration.PROTOCOL_NAME, RELAY2.class));
resource.registerChild(ProtocolResourceDefinition.pathElement(RelayConfiguration.PROTOCOL_NAME), PlaceholderResource.INSTANCE);
}
}
Aggregations