Skip to content

Commit

Permalink
Merge pull request wildfly#17694 from ehsavoie/WFLY-19087
Browse files Browse the repository at this point in the history
[WFLY-19087]: External messaging resources can't be updated.
  • Loading branch information
bstansberry committed Mar 15, 2024
2 parents 9348516 + 6544742 commit a829ae4
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 95 deletions.
Expand Up @@ -39,7 +39,7 @@ public abstract class AbstractTransportDefinition extends PersistentResourceDefi
static final RuntimeCapability<Void> CONNECTOR_CAPABILITY = RuntimeCapability.Builder.of(CONNECTOR_CAPABILITY_NAME, true, ConnectorService.class)
.setDynamicNameMapper(TransportCapabilityNameMapper.INSTANCE)
.build();
private final boolean registerRuntimeOnly;
private final boolean registerRuntimeOnlyValid;
private final AttributeDefinition[] attrs;
protected final boolean isAcceptor;

Expand Down Expand Up @@ -143,7 +143,7 @@ public String[] getRequirementPatternSegments(String dynamicElement, PathAddress
}
}

protected AbstractTransportDefinition(final boolean isAcceptor, final String specificType, final boolean registerRuntimeOnly, AttributeDefinition... attrs) {
protected AbstractTransportDefinition(final boolean isAcceptor, final String specificType, final boolean registerRuntimeOnlyValid, AttributeDefinition... attrs) {
super(new SimpleResourceDefinition.Parameters(PathElement.pathElement(specificType),
new StandardResourceDescriptionResolver((isAcceptor ? CommonAttributes.ACCEPTOR : CommonAttributes.CONNECTOR),
MessagingExtension.RESOURCE_NAME, MessagingExtension.class.getClassLoader(), true, false) {
Expand All @@ -158,11 +158,11 @@ public String getResourceDescription(Locale locale, ResourceBundle bundle) {
.setAddHandler(isAcceptor ? new ActiveMQReloadRequiredHandlers.AddStepHandler(attrs) : new ConnectorAdd(attrs))
.setRemoveHandler(new ActiveMQReloadRequiredHandlers.RemoveStepHandler()));
this.isAcceptor = isAcceptor;
this.registerRuntimeOnly = registerRuntimeOnly;
this.registerRuntimeOnlyValid = registerRuntimeOnlyValid;
this.attrs = attrs;
}

protected AbstractTransportDefinition(final boolean isAcceptor, final String specificType, final boolean registerRuntimeOnly, ModelVersion deprecatedSince, AttributeDefinition... attrs) {
protected AbstractTransportDefinition(final boolean isAcceptor, final String specificType, final boolean registerRuntimeOnlyValid, ModelVersion deprecatedSince, AttributeDefinition... attrs) {
super(new SimpleResourceDefinition.Parameters(PathElement.pathElement(specificType),
new StandardResourceDescriptionResolver((isAcceptor ? CommonAttributes.ACCEPTOR : CommonAttributes.CONNECTOR),
MessagingExtension.RESOURCE_NAME, MessagingExtension.class.getClassLoader(), true, false) {
Expand All @@ -175,7 +175,7 @@ public String getResourceDescription(Locale locale, ResourceBundle bundle) {
.setRemoveHandler(new ActiveMQReloadRequiredHandlers.RemoveStepHandler())
.setDeprecatedSince(deprecatedSince));
this.isAcceptor = isAcceptor;
this.registerRuntimeOnly = registerRuntimeOnly;
this.registerRuntimeOnlyValid = registerRuntimeOnlyValid;
this.attrs = attrs;
}

Expand All @@ -200,7 +200,7 @@ public void registerAttributes(ManagementResourceRegistration registry) {

@Override
public void registerOperations(ManagementResourceRegistration registry) {
if (isAcceptor && registerRuntimeOnly) {
if (isAcceptor && registerRuntimeOnlyValid) {
AcceptorControlHandler.INSTANCE.registerOperations(registry, getResourceDescriptionResolver());
}

Expand Down
Expand Up @@ -27,15 +27,15 @@ public class GenericTransportDefinition extends AbstractTransportDefinition {

static AttributeDefinition[] ATTRIBUTES = { CommonAttributes.FACTORY_CLASS, SOCKET_BINDING, CommonAttributes.PARAMS };

static GenericTransportDefinition createAcceptorDefinition(boolean registerRuntimeOnly) {
return new GenericTransportDefinition(true, registerRuntimeOnly, CommonAttributes.ACCEPTOR);
static GenericTransportDefinition createAcceptorDefinition(boolean registerRuntimeOnlyValid) {
return new GenericTransportDefinition(true, registerRuntimeOnlyValid, CommonAttributes.ACCEPTOR);
}

static GenericTransportDefinition createConnectorDefinition(boolean registerRuntimeOnly) {
return new GenericTransportDefinition(false, registerRuntimeOnly, CommonAttributes.CONNECTOR);
static GenericTransportDefinition createConnectorDefinition(boolean registerRuntimeOnlyValid) {
return new GenericTransportDefinition(false, registerRuntimeOnlyValid, CommonAttributes.CONNECTOR);
}

private GenericTransportDefinition(boolean isAcceptor, boolean registerRuntimeOnly, String specificType) {
super(isAcceptor, specificType, registerRuntimeOnly, ATTRIBUTES);
private GenericTransportDefinition(boolean isAcceptor, boolean registerRuntimeOnlyValid, String specificType) {
super(isAcceptor, specificType, registerRuntimeOnlyValid, ATTRIBUTES);
}
}
Expand Up @@ -49,7 +49,10 @@ public void marshallAsAttribute(AttributeDefinition attribute, ModelNode resourc
.setAllowExpression(false)
.build();

public HTTPConnectorDefinition(boolean registerRuntimeOnly) {
super(false, CommonAttributes.HTTP_CONNECTOR, registerRuntimeOnly, SOCKET_BINDING, ENDPOINT, SERVER_NAME, PARAMS, CommonAttributes.SSL_CONTEXT);
/**
* @param registerRuntimeOnlyValid: no effect
*/
public HTTPConnectorDefinition(boolean registerRuntimeOnlyValid) {
super(false, CommonAttributes.HTTP_CONNECTOR, registerRuntimeOnlyValid, SOCKET_BINDING, ENDPOINT, SERVER_NAME, PARAMS, CommonAttributes.SSL_CONTEXT);
}
}
Expand Up @@ -38,15 +38,18 @@ public void marshallAsAttribute(AttributeDefinition attribute, ModelNode resourc

static AttributeDefinition[] ATTRIBUTES = { SERVER_ID, PARAMS };

public static InVMTransportDefinition createAcceptorDefinition(final boolean registerRuntimeOnly) {
return new InVMTransportDefinition(registerRuntimeOnly, true, CommonAttributes.IN_VM_ACCEPTOR);
public static InVMTransportDefinition createAcceptorDefinition(final boolean registerRuntimeOnlyValid) {
return new InVMTransportDefinition(registerRuntimeOnlyValid, true, CommonAttributes.IN_VM_ACCEPTOR);
}

public static InVMTransportDefinition createConnectorDefinition(final boolean registerRuntimeOnly) {
return new InVMTransportDefinition(registerRuntimeOnly, false, CommonAttributes.IN_VM_CONNECTOR);
/**
* @param registerRuntimeOnlyValid: no effect
*/
public static InVMTransportDefinition createConnectorDefinition(final boolean registerRuntimeOnlyValid) {
return new InVMTransportDefinition(registerRuntimeOnlyValid, false, CommonAttributes.IN_VM_CONNECTOR);
}

private InVMTransportDefinition(final boolean registerRuntimeOnly, boolean isAcceptor, String specificType) {
super(isAcceptor, specificType, registerRuntimeOnly, ATTRIBUTES);
private InVMTransportDefinition(final boolean registerRuntimeOnlyValid, boolean isAcceptor, String specificType) {
super(isAcceptor, specificType, registerRuntimeOnlyValid, ATTRIBUTES);
}
}
Expand Up @@ -353,7 +353,7 @@ public void initialize(ExtensionContext context) {
final SubsystemRegistration subsystemRegistration = context.registerSubsystem(SUBSYSTEM_NAME, CURRENT_MODEL_VERSION);
subsystemRegistration.registerXMLElementWriter(CURRENT_PARSER);

boolean registerRuntimeOnly = context.isRuntimeOnlyRegistrationValid();
boolean registerRuntimeOnlyValid = context.isRuntimeOnlyRegistrationValid();

BiConsumer<OperationContext, String> broadcastCommandDispatcherFactoryInstaller = new BroadcastCommandDispatcherFactoryInstaller();

Expand All @@ -362,20 +362,20 @@ public void initialize(ExtensionContext context) {
subsystem.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);

// WFLY-10518 - register new client resources under subsystem
subsystem.registerSubModel(new DiscoveryGroupDefinition(registerRuntimeOnly, true));
subsystem.registerSubModel(new JGroupsDiscoveryGroupDefinition(registerRuntimeOnly, true));
subsystem.registerSubModel(new SocketDiscoveryGroupDefinition(registerRuntimeOnly, true));
subsystem.registerSubModel(GenericTransportDefinition.createConnectorDefinition(registerRuntimeOnly));
subsystem.registerSubModel(InVMTransportDefinition.createConnectorDefinition(registerRuntimeOnly));
subsystem.registerSubModel(RemoteTransportDefinition.createConnectorDefinition(registerRuntimeOnly));
subsystem.registerSubModel(new HTTPConnectorDefinition(registerRuntimeOnly));
subsystem.registerSubModel(new ExternalConnectionFactoryDefinition(registerRuntimeOnly));
subsystem.registerSubModel(new DiscoveryGroupDefinition(false, true));
subsystem.registerSubModel(new JGroupsDiscoveryGroupDefinition(false, true));
subsystem.registerSubModel(new SocketDiscoveryGroupDefinition(false, true));
subsystem.registerSubModel(GenericTransportDefinition.createConnectorDefinition(false));
subsystem.registerSubModel(InVMTransportDefinition.createConnectorDefinition(false));
subsystem.registerSubModel(RemoteTransportDefinition.createConnectorDefinition(false));
subsystem.registerSubModel(new HTTPConnectorDefinition(false));
subsystem.registerSubModel(new ExternalConnectionFactoryDefinition());
subsystem.registerSubModel(new ExternalPooledConnectionFactoryDefinition(false));
subsystem.registerSubModel(new ExternalJMSQueueDefinition(registerRuntimeOnly));
subsystem.registerSubModel(new ExternalJMSTopicDefinition(registerRuntimeOnly));
subsystem.registerSubModel(new ExternalJMSQueueDefinition(false));
subsystem.registerSubModel(new ExternalJMSTopicDefinition(false));

// ActiveMQ Servers
final ManagementResourceRegistration server = subsystem.registerSubModel(new ServerDefinition(broadcastCommandDispatcherFactoryInstaller, registerRuntimeOnly));
final ManagementResourceRegistration server = subsystem.registerSubModel(new ServerDefinition(broadcastCommandDispatcherFactoryInstaller, registerRuntimeOnlyValid));

for (PathElement path : List.of(JOURNAL_DIRECTORY_PATH, BINDINGS_DIRECTORY_PATH, LARGE_MESSAGES_DIRECTORY_PATH, PAGING_DIRECTORY_PATH)) {
ManagementResourceRegistration pathRegistry = server.registerSubModel(new PathDefinition(path));
Expand All @@ -384,18 +384,18 @@ public void initialize(ExtensionContext context) {

subsystem.registerSubModel(new JMSBridgeDefinition());

if (registerRuntimeOnly) {
if (registerRuntimeOnlyValid) {
final ManagementResourceRegistration deployment = subsystemRegistration.registerDeploymentModel(new SimpleResourceDefinition(
new Parameters(SUBSYSTEM_PATH, getResourceDescriptionResolver("deployed")).setFeature(false).setRuntime()));
deployment.registerSubModel(new ExternalConnectionFactoryDefinition(registerRuntimeOnly));
deployment.registerSubModel(new ExternalConnectionFactoryDefinition());
deployment.registerSubModel(new ExternalPooledConnectionFactoryDefinition(true));
deployment.registerSubModel(new ExternalJMSQueueDefinition(registerRuntimeOnly));
deployment.registerSubModel(new ExternalJMSTopicDefinition(registerRuntimeOnly));
deployment.registerSubModel(new ExternalJMSQueueDefinition(true));
deployment.registerSubModel(new ExternalJMSTopicDefinition(true));
final ManagementResourceRegistration deployedServer = deployment.registerSubModel(new SimpleResourceDefinition(
new Parameters(SERVER_PATH, getResourceDescriptionResolver(SERVER)).setFeature(false).setRuntime()));
deployedServer.registerSubModel(new JMSQueueDefinition(true, registerRuntimeOnly));
deployedServer.registerSubModel(new JMSTopicDefinition(true, registerRuntimeOnly));
deployedServer.registerSubModel(new PooledConnectionFactoryDefinition(true));
deployedServer.registerSubModel(new JMSQueueDefinition(true, registerRuntimeOnlyValid));
deployedServer.registerSubModel(new JMSTopicDefinition(true, registerRuntimeOnlyValid));
deployedServer.registerSubModel(new PooledConnectionFactoryDefinition(registerRuntimeOnlyValid));
}
}

Expand Down
Expand Up @@ -2,7 +2,6 @@
* Copyright The WildFly Authors
* SPDX-License-Identifier: Apache-2.0
*/

package org.wildfly.extension.messaging.activemq;

import static org.jboss.as.controller.SimpleAttributeDefinitionBuilder.create;
Expand Down Expand Up @@ -37,15 +36,18 @@ public void marshallAsAttribute(AttributeDefinition attribute, ModelNode resourc

static AttributeDefinition[] ATTRIBUTES = {SOCKET_BINDING, CommonAttributes.PARAMS, CommonAttributes.SSL_CONTEXT};

static RemoteTransportDefinition createAcceptorDefinition(boolean registerRuntimeOnly) {
return new RemoteTransportDefinition(true, CommonAttributes.REMOTE_ACCEPTOR, registerRuntimeOnly);
static RemoteTransportDefinition createAcceptorDefinition(boolean registerRuntimeOnlyValid) {
return new RemoteTransportDefinition(true, CommonAttributes.REMOTE_ACCEPTOR, registerRuntimeOnlyValid);
}

static RemoteTransportDefinition createConnectorDefinition(boolean registerRuntimeOnly) {
return new RemoteTransportDefinition(false, CommonAttributes.REMOTE_CONNECTOR, registerRuntimeOnly);
/**
* @param registerRuntimeOnlyValid: no effect
*/
static RemoteTransportDefinition createConnectorDefinition(boolean registerRuntimeOnlyValid) {
return new RemoteTransportDefinition(false, CommonAttributes.REMOTE_CONNECTOR, registerRuntimeOnlyValid);
}

private RemoteTransportDefinition(boolean isAcceptor, String specificType, boolean registerRuntimeOnly) {
super(isAcceptor, specificType, registerRuntimeOnly, ATTRIBUTES);
private RemoteTransportDefinition(boolean isAcceptor, String specificType, boolean registerRuntimeOnlyValid) {
super(isAcceptor, specificType, registerRuntimeOnlyValid, ATTRIBUTES);
}
}

0 comments on commit a829ae4

Please sign in to comment.