repo
stringlengths 1
191
⌀ | file
stringlengths 23
351
| code
stringlengths 0
5.32M
| file_length
int64 0
5.32M
| avg_line_length
float64 0
2.9k
| max_line_length
int64 0
288k
| extension_type
stringclasses 1
value |
|---|---|---|---|---|---|---|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/QueueConfigurationWriteHandler.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
/**
* Write attribute handler for attributes that update the persistent configuration of a core queue.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class QueueConfigurationWriteHandler extends ReloadRequiredWriteAttributeHandler {
public static final QueueConfigurationWriteHandler INSTANCE = new QueueConfigurationWriteHandler();
private QueueConfigurationWriteHandler() {
super(QueueDefinition.ATTRIBUTES);
}
}
| 1,599
| 39
| 103
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/AddressSettingsWriteHandler.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import static org.wildfly.extension.messaging.activemq.ActiveMQActivationService.getActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.jboss.as.controller.AbstractWriteAttributeHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.registry.Resource;
import org.jboss.dmr.ModelNode;
/**
* @author Emanuel Muckenhuber
*/
class AddressSettingsWriteHandler extends AbstractWriteAttributeHandler<AddressSettingsWriteHandler.RevertHandback> {
static final AddressSettingsWriteHandler INSTANCE = new AddressSettingsWriteHandler();
protected AddressSettingsWriteHandler() {
super(AddressSettingDefinition.ATTRIBUTES);
}
@Override
protected void finishModelStage(OperationContext context, ModelNode operation, String attributeName, ModelNode newValue, ModelNode oldValue, Resource model) throws OperationFailedException {
super.finishModelStage(context, operation, attributeName, newValue, oldValue, model);
AddressSettingsValidator.validateModel(context, operation, model);
}
@Override
protected boolean applyUpdateToRuntime(final OperationContext context, final ModelNode operation, final String attributeName, final ModelNode resolvedValue,
final ModelNode currentValue, final HandbackHolder<RevertHandback> handbackHolder) throws OperationFailedException {
final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
final ActiveMQServer server = getActiveMQServer(context, operation);
if(server != null) {
final ModelNode model = resource.getModel();
final AddressSettings settings = AddressSettingAdd.createSettings(context, model);
final HierarchicalRepository<AddressSettings> repository = server.getAddressSettingsRepository();
final String match = context.getCurrentAddressValue();
final AddressSettings existingSettings = repository.getMatch(match);
repository.addMatch(match, settings);
if(existingSettings != null) {
handbackHolder.setHandback(new RevertHandback() {
@Override
public void doRevertUpdateToRuntime() {
// Restore the old settings
repository.addMatch(match, existingSettings);
}
});
}
}
return false;
}
@Override
protected void revertUpdateToRuntime(final OperationContext context, final ModelNode operation, final String attributeName, final ModelNode valueToRestore,
final ModelNode valueToRevert, final RevertHandback handback) throws OperationFailedException {
if(handback != null) {
handback.doRevertUpdateToRuntime();
}
}
interface RevertHandback {
void doRevertUpdateToRuntime();
}
}
| 4,307
| 44.829787
| 194
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/DiscoveryGroupDefinition.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import static org.jboss.as.controller.SimpleAttributeDefinitionBuilder.create;
import static org.jboss.as.controller.client.helpers.MeasurementUnit.MILLISECONDS;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.DeprecationData;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.registry.Resource;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
import org.wildfly.extension.messaging.activemq.shallow.ShallowResourceDefinition;
/**
* Discovery group resource definition
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat Inc.
* @deprecated Use JGroupsDiscoveryGroupDefinition or SocketDiscoveryGroupDefinition.
*/
public class DiscoveryGroupDefinition extends ShallowResourceDefinition {
public static final PathElement PATH = PathElement.pathElement(CommonAttributes.DISCOVERY_GROUP);
/**
* @see ActiveMQDefaultConfiguration#getDefaultBroadcastRefreshTimeout
*/
public static final SimpleAttributeDefinition REFRESH_TIMEOUT = create("refresh-timeout", ModelType.LONG)
.setDefaultValue(new ModelNode(10000))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_DISCOVERY_INITIAL_WAIT_TIMEOUT
*/
public static final SimpleAttributeDefinition INITIAL_WAIT_TIMEOUT = create("initial-wait-timeout", ModelType.LONG)
.setDefaultValue(new ModelNode(10000L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
@Deprecated
public static final SimpleAttributeDefinition JGROUPS_CHANNEL_FACTORY = create(CommonAttributes.JGROUPS_CHANNEL_FACTORY)
.build();
public static final SimpleAttributeDefinition JGROUPS_CHANNEL = create(CommonAttributes.JGROUPS_CHANNEL)
.build();
public static final SimpleAttributeDefinition JGROUPS_CLUSTER = create(CommonAttributes.JGROUPS_CLUSTER)
.build();
public static final SimpleAttributeDefinition SOCKET_BINDING = create(CommonAttributes.SOCKET_BINDING)
.build();
public static final AttributeDefinition[] ATTRIBUTES = {JGROUPS_CHANNEL_FACTORY, JGROUPS_CHANNEL, JGROUPS_CLUSTER, SOCKET_BINDING,
REFRESH_TIMEOUT, INITIAL_WAIT_TIMEOUT
};
protected DiscoveryGroupDefinition(final boolean registerRuntimeOnly, final boolean subsystemResource) {
super(new SimpleResourceDefinition.Parameters(PATH, MessagingExtension.getResourceDescriptionResolver(CommonAttributes.DISCOVERY_GROUP))
.setAddHandler(DiscoveryGroupAdd.INSTANCE)
.setRemoveHandler(DiscoveryGroupRemove.INSTANCE)
.setDeprecationData(new DeprecationData(MessagingExtension.VERSION_9_0_0, true))
.setFeature(false),
registerRuntimeOnly);
}
@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(ATTRIBUTES);
}
@Override
public PathAddress convert(OperationContext context, ModelNode operation) {
PathAddress parent = context.getCurrentAddress().getParent();
PathAddress targetAddress = parent.append(CommonAttributes.JGROUPS_DISCOVERY_GROUP, context.getCurrentAddressValue());
try {
context.readResourceFromRoot(targetAddress, false);
return targetAddress;
} catch (Resource.NoSuchResourceException ex) {
return parent.append(CommonAttributes.SOCKET_DISCOVERY_GROUP, context.getCurrentAddressValue());
}
}
@Override
public Set<String> getIgnoredAttributes(OperationContext context, ModelNode operation) {
PathAddress targetAddress = context.getCurrentAddress().getParent().append(CommonAttributes.JGROUPS_DISCOVERY_GROUP, context.getCurrentAddressValue());
Set<String> ignoredAttributes = new HashSet<>();
try {
context.readResourceFromRoot(targetAddress, false);
ignoredAttributes.add(SOCKET_BINDING.getName());
} catch (Resource.NoSuchResourceException ex) {
ignoredAttributes.add(JGROUPS_CHANNEL_FACTORY.getName());
ignoredAttributes.add(JGROUPS_CHANNEL.getName());
ignoredAttributes.add(JGROUPS_CLUSTER.getName());
}
return ignoredAttributes;
}
@Override
protected boolean isUsingSocketBinding(PathAddress targetAddress) {
return CommonAttributes.SOCKET_DISCOVERY_GROUP.equals(targetAddress.getLastElement().getKey());
}
}
| 6,254
| 44.326087
| 159
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/MessagingExtension.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import static org.jboss.as.controller.PathElement.pathElement;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.PATH;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.ADDRESS_SETTING;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.BINDINGS_DIRECTORY;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.BRIDGE;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.BROADCAST_GROUP;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.CLUSTER_CONNECTION;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.CONFIGURATION;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.CONNECTOR_SERVICE;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.EXTERNAL_JMS_QUEUE;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.EXTERNAL_JMS_TOPIC;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.GROUPING_HANDLER;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.HA_POLICY;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.HTTP_ACCEPTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.HTTP_CONNECTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.JGROUPS_BROADCAST_GROUP;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.JMS_QUEUE;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.JMS_TOPIC;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.JOURNAL_DIRECTORY;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.LARGE_MESSAGES_DIRECTORY;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.LEGACY_CONNECTION_FACTORY;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.LIVE_ONLY;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.MASTER;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.PAGING_DIRECTORY;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.PRIMARY;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.QUEUE;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.REPLICATION_COLOCATED;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.REPLICATION_MASTER;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.REPLICATION_PRIMARY;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.REPLICATION_SECONDARY;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.REPLICATION_SLAVE;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.ROLE;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.RUNTIME_QUEUE;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.SECONDARY;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.SECURITY_SETTING;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.SERVER;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.SHARED_STORE_COLOCATED;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.SHARED_STORE_MASTER;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.SHARED_STORE_PRIMARY;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.SHARED_STORE_SECONDARY;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.SHARED_STORE_SLAVE;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.SLAVE;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.SOCKET_BROADCAST_GROUP;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
import org.jboss.as.controller.Extension;
import org.jboss.as.controller.ExtensionContext;
import org.jboss.as.controller.ModelVersion;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.SimpleResourceDefinition.Parameters;
import org.jboss.as.controller.SubsystemRegistration;
import org.jboss.as.controller.access.constraint.ApplicationTypeConfig;
import org.jboss.as.controller.access.constraint.SensitivityClassification;
import org.jboss.as.controller.access.management.AccessConstraintDefinition;
import org.jboss.as.controller.access.management.ApplicationTypeAccessConstraintDefinition;
import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition;
import org.jboss.as.controller.descriptions.ResourceDescriptionResolver;
import org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver;
import org.jboss.as.controller.operations.common.GenericSubsystemDescribeHandler;
import org.jboss.as.controller.parsing.ExtensionParsingContext;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.wildfly.extension.messaging.activemq.broadcast.BroadcastCommandDispatcherFactoryInstaller;
import org.wildfly.extension.messaging.activemq.jms.ExternalConnectionFactoryDefinition;
import org.wildfly.extension.messaging.activemq.jms.ExternalJMSQueueDefinition;
import org.wildfly.extension.messaging.activemq.jms.ExternalJMSTopicDefinition;
import org.wildfly.extension.messaging.activemq.jms.ExternalPooledConnectionFactoryDefinition;
import org.wildfly.extension.messaging.activemq.jms.JMSQueueDefinition;
import org.wildfly.extension.messaging.activemq.jms.JMSTopicDefinition;
import org.wildfly.extension.messaging.activemq.jms.PooledConnectionFactoryDefinition;
import org.wildfly.extension.messaging.activemq.jms.bridge.JMSBridgeDefinition;
import io.netty.util.internal.logging.InternalLoggerFactory;
import io.netty.util.internal.logging.JdkLoggerFactory;
/**
* Domain extension that integrates Apache ActiveMQ Artemis 2.x.
*
* <dl>
* <dt><strong>Current</strong> - WildFly 28</dt>
* <dd>
* <ul>
* <li>XML namespace: urn:jboss:domain:messaging-activemq:15.0</li>
* <li>Management model: 15.0.0</li>
* </ul>
* </dd>
* <dt>WildFly 27</dt>
* <dd>
* <ul>
* <li>XML namespace: urn:jboss:domain:messaging-activemq:14.0</li>
* <li>Management model: 14.0.0</li>
* </ul>
* </dd>
* <dt>WildFly 26.1</dt>
* <dd>
* <ul>
* <li>XML namespace: urn:jboss:domain:messaging-activemq:13.1</li>
* <li>Management model: 13.1.0</li>
* </ul>
* </dd>
* <dt>
* <dt>WildFly 23</dt>
* <dd>
* <ul>
* <li>XML namespace: urn:jboss:domain:messaging-activemq:13.0</li>
* <li>Management model: 13.0.0</li>
* </ul>
* </dd>
* <dt> - WildFly 22</dt>
* <dd>
* <ul>
* <li>XML namespace: urn:jboss:domain:messaging-activemq:12.0</li>
* <li>Management model: 12.0.0</li>
* </ul>
* </dd>
* <dt><strong>Current</strong> - WildFly 21</dt>
* <dd>
* <ul>
* <li>XML namespace: urn:jboss:domain:messaging-activemq:11.0</li>
* <li>Management model: 11.0.0</li>
* </ul>
* </dd>
* <dt>WildFly 20</dt>
* <dd>
* <ul>
* <li>XML namespace: urn:jboss:domain:messaging-activemq:10.0</li>
* <li>Management model: 10.0.0</li>
* </ul>
* </dd>
* <dt>WildFly 19</dt>
* * <dd>
* * <ul>
* * <li>XML namespace: urn:jboss:domain:messaging-activemq:9.0</li>
* * <li>Management model: 9.0.0</li>
* * </ul>
* * </dd>
* <dt>WildFly 18</dt>
* <dd>
* <ul>
* <li>XML namespace: urn:jboss:domain:messaging-activemq:8.0</li>
* <li>Management model: 8.0.0</li>
* </ul>
* </dd>
* <dt>WildFly 17</dt>
* <dd>
* <ul>
* <li>XML namespace: urn:jboss:domain:messaging-activemq:7.0</li>
* <li>Management model: 7.0.0</li>
* </ul>
* </dd>
* <dt>WildFly 16</dt>
* <dd>
* <ul>
* <li>XML namespace: urn:jboss:domain:messaging-activemq:6.0</li>
* <li>Management model: 6.0.0</li>
* </ul>
* </dd>
* <dt>WildFly 15</dt>
* <dd>
* <ul>
* <li>XML namespace: urn:jboss:domain:messaging-activemq:5.0</li>
* <li>Management model: 5.0.0</li>
* </ul>
* </dd>
* <dt>WildFly 14</dt>
* <dd>
* <ul>
* <li>XML namespace: urn:jboss:domain:messaging-activemq:4.0</li>
* <li>Management model: 4.0.0</li>
* </ul>
* </dd>
* <dt>WildFly 12</dt>
* <dd>
* <ul>
* <li>XML namespace: urn:jboss:domain:messaging-activemq:3.0</li>
* <li>Management model: 3.0.0</li>
* </ul>
* </dd>
* <dt>WildFly 11</dt>
* <dd>
* <ul>
* <li>XML namespace: urn:jboss:domain:messaging-activemq:2.0</li>
* <li>Management model: 2.0.0</li>
* </ul>
* </dd>
* <dt>WildFly 10</dt>
* <dd>
* <ul>
* <li>XML namespace: urn:jboss:domain:messaging-activemq:1.0</li>
* <li>Management model: 1.0.0</li>
* </ul>
* </dd>
* </dl>
*
* @author Emanuel Muckenhuber
* @author <a href="mailto:andy.taylor@jboss.com">Andy Taylor</a>
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class MessagingExtension implements Extension {
public static final String SUBSYSTEM_NAME = "messaging-activemq";
static final PathElement SUBSYSTEM_PATH = pathElement(SUBSYSTEM, SUBSYSTEM_NAME);
static final PathElement SERVER_PATH = pathElement(SERVER);
public static final PathElement LIVE_ONLY_PATH = pathElement(HA_POLICY, LIVE_ONLY);
public static final PathElement REPLICATION_MASTER_PATH = pathElement(HA_POLICY, REPLICATION_MASTER);
public static final PathElement REPLICATION_SLAVE_PATH = pathElement(HA_POLICY, REPLICATION_SLAVE);
public static final PathElement REPLICATION_PRIMARY_PATH = pathElement(HA_POLICY, REPLICATION_PRIMARY);
public static final PathElement REPLICATION_SECONDARY_PATH = pathElement(HA_POLICY, REPLICATION_SECONDARY);
public static final PathElement SHARED_STORE_MASTER_PATH = pathElement(HA_POLICY, SHARED_STORE_MASTER);
public static final PathElement SHARED_STORE_SLAVE_PATH = pathElement(HA_POLICY, SHARED_STORE_SLAVE);
public static final PathElement SHARED_STORE_PRIMARY_PATH = pathElement(HA_POLICY, SHARED_STORE_PRIMARY);
public static final PathElement SHARED_STORE_SECONDARY_PATH = pathElement(HA_POLICY, SHARED_STORE_SECONDARY);
public static final PathElement SHARED_STORE_COLOCATED_PATH = pathElement(HA_POLICY, SHARED_STORE_COLOCATED);
public static final PathElement REPLICATION_COLOCATED_PATH = pathElement(HA_POLICY, REPLICATION_COLOCATED);
public static final PathElement CONFIGURATION_MASTER_PATH = pathElement(CONFIGURATION, MASTER);
public static final PathElement CONFIGURATION_SLAVE_PATH = pathElement(CONFIGURATION, SLAVE);
public static final PathElement CONFIGURATION_PRIMARY_PATH = pathElement(CONFIGURATION, PRIMARY);
public static final PathElement CONFIGURATION_SECONDARY_PATH = pathElement(CONFIGURATION, SECONDARY);
static final PathElement BINDINGS_DIRECTORY_PATH = pathElement(PATH, BINDINGS_DIRECTORY);
static final PathElement JOURNAL_DIRECTORY_PATH = pathElement(PATH, JOURNAL_DIRECTORY);
static final PathElement PAGING_DIRECTORY_PATH = pathElement(PATH, PAGING_DIRECTORY);
static final PathElement LARGE_MESSAGES_DIRECTORY_PATH = pathElement(PATH, LARGE_MESSAGES_DIRECTORY);
static final PathElement CONNECTOR_SERVICE_PATH = pathElement(CONNECTOR_SERVICE);
static final PathElement QUEUE_PATH = pathElement(QUEUE);
static final PathElement RUNTIME_QUEUE_PATH = pathElement(RUNTIME_QUEUE);
static final PathElement GROUPING_HANDLER_PATH = pathElement(GROUPING_HANDLER);
static final PathElement HTTP_CONNECTOR_PATH = pathElement(HTTP_CONNECTOR);
static final PathElement HTTP_ACCEPTOR_PATH = pathElement(HTTP_ACCEPTOR);
static final PathElement BROADCAST_GROUP_PATH = pathElement(BROADCAST_GROUP);
static final PathElement JGROUPS_BROADCAST_GROUP_PATH = pathElement(JGROUPS_BROADCAST_GROUP);
static final PathElement SOCKET_BROADCAST_GROUP_PATH = pathElement(SOCKET_BROADCAST_GROUP);
static final PathElement CLUSTER_CONNECTION_PATH = pathElement(CLUSTER_CONNECTION);
static final PathElement BRIDGE_PATH = pathElement(BRIDGE);
static final PathElement ADDRESS_SETTING_PATH = pathElement(ADDRESS_SETTING);
static final PathElement ROLE_PATH = pathElement(ROLE);
static final PathElement SECURITY_SETTING_PATH = pathElement(SECURITY_SETTING);
public static final PathElement EXTERNAL_JMS_QUEUE_PATH = pathElement(EXTERNAL_JMS_QUEUE);
public static final PathElement EXTERNAL_JMS_TOPIC_PATH = pathElement(EXTERNAL_JMS_TOPIC);
public static final PathElement JMS_QUEUE_PATH = pathElement(JMS_QUEUE);
public static final PathElement JMS_TOPIC_PATH = pathElement(JMS_TOPIC);
public static final PathElement POOLED_CONNECTION_FACTORY_PATH = pathElement(CommonAttributes.POOLED_CONNECTION_FACTORY);
public static final PathElement CONNECTION_FACTORY_PATH = pathElement(CommonAttributes.CONNECTION_FACTORY);
public static final PathElement JMS_BRIDGE_PATH = pathElement(CommonAttributes.JMS_BRIDGE);
public static final PathElement LEGACY_CONNECTION_FACTORY_PATH = pathElement(LEGACY_CONNECTION_FACTORY);
public static final SensitiveTargetAccessConstraintDefinition MESSAGING_SECURITY_SENSITIVE_TARGET = new SensitiveTargetAccessConstraintDefinition(new SensitivityClassification(SUBSYSTEM_NAME, "messaging-security", false, false, true));
public static final SensitiveTargetAccessConstraintDefinition MESSAGING_MANAGEMENT_SENSITIVE_TARGET = new SensitiveTargetAccessConstraintDefinition(new SensitivityClassification(SUBSYSTEM_NAME, "messaging-management", false, false, true));
static final AccessConstraintDefinition SECURITY_SETTING_ACCESS_CONSTRAINT = new ApplicationTypeAccessConstraintDefinition( new ApplicationTypeConfig(SUBSYSTEM_NAME, SECURITY_SETTING));
static final AccessConstraintDefinition QUEUE_ACCESS_CONSTRAINT = new ApplicationTypeAccessConstraintDefinition(new ApplicationTypeConfig(SUBSYSTEM_NAME, QUEUE));
public static final AccessConstraintDefinition JMS_QUEUE_ACCESS_CONSTRAINT = new ApplicationTypeAccessConstraintDefinition(new ApplicationTypeConfig(SUBSYSTEM_NAME, CommonAttributes.JMS_QUEUE));
public static final AccessConstraintDefinition JMS_TOPIC_ACCESS_CONSTRAINT = new ApplicationTypeAccessConstraintDefinition(new ApplicationTypeConfig(SUBSYSTEM_NAME, CommonAttributes.JMS_TOPIC));
static final String RESOURCE_NAME = MessagingExtension.class.getPackage().getName() + ".LocalDescriptions";
protected static final ModelVersion VERSION_15_0_0 = ModelVersion.create(15, 0, 0);
protected static final ModelVersion VERSION_14_0_0 = ModelVersion.create(14, 0, 0);
protected static final ModelVersion VERSION_13_1_0 = ModelVersion.create(13, 1, 0);
protected static final ModelVersion VERSION_13_0_0 = ModelVersion.create(13, 0, 0);
protected static final ModelVersion VERSION_12_0_0 = ModelVersion.create(12, 0, 0);
protected static final ModelVersion VERSION_11_0_0 = ModelVersion.create(11, 0, 0);
protected static final ModelVersion VERSION_10_0_0 = ModelVersion.create(10, 0, 0);
protected static final ModelVersion VERSION_9_0_0 = ModelVersion.create(9, 0, 0);
protected static final ModelVersion VERSION_8_0_0 = ModelVersion.create(8, 0, 0);
protected static final ModelVersion VERSION_7_0_0 = ModelVersion.create(7, 0, 0);
protected static final ModelVersion VERSION_6_0_0 = ModelVersion.create(6, 0, 0);
protected static final ModelVersion VERSION_5_0_0 = ModelVersion.create(5, 0, 0);
protected static final ModelVersion VERSION_4_0_0 = ModelVersion.create(4, 0, 0);
protected static final ModelVersion VERSION_3_0_0 = ModelVersion.create(3, 0, 0);
protected static final ModelVersion VERSION_2_0_0 = ModelVersion.create(2, 0, 0);
protected static final ModelVersion VERSION_1_0_0 = ModelVersion.create(1, 0, 0);
private static final ModelVersion CURRENT_MODEL_VERSION = VERSION_15_0_0;
private static final MessagingSubsystemParser_15_0 CURRENT_PARSER = new MessagingSubsystemParser_15_0();
// ARTEMIS-2273 introduced audit logging at a info level which is rather verbose. We need to use static loggers
// to ensure the log levels are set to WARN and there is a strong reference to the loggers. This hack will likely
// be removed in the future.
private static final Logger BASE_AUDIT_LOGGER;
private static final Logger MESSAGE_AUDIT_LOGGER;
private static final Logger RESOURCE_AUDIT_LOGGER;
static {
// There is no guarantee that the configured loggers will contain the logger names even if they've been
// configured, however it's unlikely it will be an issue. Checking the logger names is to avoid overriding
// the loggers if they were previously configured.
final Collection<String> configuredLoggers = Collections.list(LogManager.getLogManager().getLoggerNames());
if (configuredLoggers.contains("org.apache.activemq.audit.base")) {
BASE_AUDIT_LOGGER = null;
} else {
BASE_AUDIT_LOGGER = Logger.getLogger("org.apache.activemq.audit.base");
BASE_AUDIT_LOGGER.setLevel(Level.WARNING);
}
if (configuredLoggers.contains("org.apache.activemq.audit.message")) {
MESSAGE_AUDIT_LOGGER = null;
} else {
MESSAGE_AUDIT_LOGGER = Logger.getLogger("org.apache.activemq.audit.message");
MESSAGE_AUDIT_LOGGER.setLevel(Level.WARNING);
}
if (configuredLoggers.contains("org.apache.activemq.audit.resource")) {
RESOURCE_AUDIT_LOGGER = null;
} else {
RESOURCE_AUDIT_LOGGER = Logger.getLogger("org.apache.activemq.audit.resource");
RESOURCE_AUDIT_LOGGER.setLevel(Level.WARNING);
}
}
public static ResourceDescriptionResolver getResourceDescriptionResolver(final String... keyPrefix) {
return getResourceDescriptionResolver(true, keyPrefix);
}
public static ResourceDescriptionResolver getResourceDescriptionResolver(final boolean useUnprefixedChildTypes, final String... keyPrefix) {
StringBuilder prefix = new StringBuilder();
for (String kp : keyPrefix) {
if (prefix.length() > 0){
prefix.append('.');
}
prefix.append(kp);
}
return new StandardResourceDescriptionResolver(prefix.toString(), RESOURCE_NAME, MessagingExtension.class.getClassLoader(), true, useUnprefixedChildTypes);
}
@Override
public void initialize(ExtensionContext context) {
// Initialize the Netty logger factory
InternalLoggerFactory.setDefaultFactory(JdkLoggerFactory.INSTANCE);
final SubsystemRegistration subsystemRegistration = context.registerSubsystem(SUBSYSTEM_NAME, CURRENT_MODEL_VERSION);
subsystemRegistration.registerXMLElementWriter(CURRENT_PARSER);
boolean registerRuntimeOnly = context.isRuntimeOnlyRegistrationValid();
BiConsumer<OperationContext, String> broadcastCommandDispatcherFactoryInstaller = new BroadcastCommandDispatcherFactoryInstaller();
// Root resource
final ManagementResourceRegistration subsystem = subsystemRegistration.registerSubsystemModel(new MessagingSubsystemRootResourceDefinition(broadcastCommandDispatcherFactoryInstaller));
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 ExternalPooledConnectionFactoryDefinition(false));
subsystem.registerSubModel(new ExternalJMSQueueDefinition(registerRuntimeOnly));
subsystem.registerSubModel(new ExternalJMSTopicDefinition(registerRuntimeOnly));
// ActiveMQ Servers
final ManagementResourceRegistration server = subsystem.registerSubModel(new ServerDefinition(broadcastCommandDispatcherFactoryInstaller, registerRuntimeOnly));
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));
PathDefinition.registerResolveOperationHandler(context, pathRegistry);
}
subsystem.registerSubModel(new JMSBridgeDefinition());
if (registerRuntimeOnly) {
final ManagementResourceRegistration deployment = subsystemRegistration.registerDeploymentModel(new SimpleResourceDefinition(
new Parameters(SUBSYSTEM_PATH, getResourceDescriptionResolver("deployed")).setFeature(false).setRuntime()));
deployment.registerSubModel(new ExternalConnectionFactoryDefinition(registerRuntimeOnly));
deployment.registerSubModel(new ExternalPooledConnectionFactoryDefinition(true));
deployment.registerSubModel(new ExternalJMSQueueDefinition(registerRuntimeOnly));
deployment.registerSubModel(new ExternalJMSTopicDefinition(registerRuntimeOnly));
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));
}
}
@Override
public void initializeParsers(ExtensionParsingContext context) {
// use method references for legacay versions that may never be instantiated
// and use an instance for the current version that will be use if the extension is loaded.
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, MessagingSubsystemParser_1_0.NAMESPACE, MessagingSubsystemParser_1_0::new);
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, MessagingSubsystemParser_2_0.NAMESPACE, MessagingSubsystemParser_2_0::new);
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, MessagingSubsystemParser_3_0.NAMESPACE, MessagingSubsystemParser_3_0::new);
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, MessagingSubsystemParser_4_0.NAMESPACE, MessagingSubsystemParser_4_0::new);
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, MessagingSubsystemParser_5_0.NAMESPACE, MessagingSubsystemParser_5_0::new);
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, MessagingSubsystemParser_6_0.NAMESPACE, MessagingSubsystemParser_6_0::new);
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, MessagingSubsystemParser_7_0.NAMESPACE, MessagingSubsystemParser_7_0::new);
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, MessagingSubsystemParser_8_0.NAMESPACE, MessagingSubsystemParser_8_0::new);
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, MessagingSubsystemParser_9_0.NAMESPACE, MessagingSubsystemParser_9_0::new);
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, MessagingSubsystemParser_10_0.NAMESPACE, MessagingSubsystemParser_10_0::new);
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, MessagingSubsystemParser_11_0.NAMESPACE, MessagingSubsystemParser_11_0::new);
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, MessagingSubsystemParser_12_0.NAMESPACE, MessagingSubsystemParser_12_0::new);
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, MessagingSubsystemParser_13_0.NAMESPACE, MessagingSubsystemParser_13_0::new);
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, MessagingSubsystemParser_13_1.NAMESPACE, MessagingSubsystemParser_13_1::new);
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, MessagingSubsystemParser_14_0.NAMESPACE, MessagingSubsystemParser_14_0::new);
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, MessagingSubsystemParser_15_0.NAMESPACE, CURRENT_PARSER);
}
}
| 26,383
| 59.933025
| 243
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/JGroupsDiscoveryGroupRemove.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.ReloadRequiredRemoveStepHandler;
import org.jboss.as.controller.registry.Resource;
import org.jboss.dmr.ModelNode;
/**
* Removes a discovery group using JGroups.
* @author Emmanuel Hugonnet (c) 2019 Red Hat, Inc.
*/
public class JGroupsDiscoveryGroupRemove extends ReloadRequiredRemoveStepHandler {
public static final JGroupsDiscoveryGroupRemove INSTANCE = new JGroupsDiscoveryGroupRemove(true);
public static final JGroupsDiscoveryGroupRemove LEGACY_INSTANCE = new JGroupsDiscoveryGroupRemove(false);
private final boolean needLegacyCall;
private JGroupsDiscoveryGroupRemove(boolean needLegacyCall) {
super();
this.needLegacyCall = needLegacyCall;
}
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
if(needLegacyCall) {
PathAddress target = context.getCurrentAddress().getParent().append(CommonAttributes.DISCOVERY_GROUP, context.getCurrentAddressValue());
try {
context.readResourceFromRoot(target);
ModelNode op = operation.clone();
op.get(OP_ADDR).set(target.toModelNode());
// Fabricate a channel resource if it is missing
context.addStep(op, DiscoveryGroupRemove.LEGACY_INSTANCE, OperationContext.Stage.MODEL, true);
} catch( Resource.NoSuchResourceException ex) {
// Legacy resource doesn't exist
}
}
super.execute(context, operation);
}
}
| 2,876
| 42.590909
| 148
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/HTTPConnectorDefinition.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import static org.jboss.as.controller.SimpleAttributeDefinitionBuilder.create;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.PARAMS;
import javax.xml.stream.XMLStreamWriter;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.AttributeMarshaller;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
/**
* HTTP connector resource definition
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat Inc.
*/
public class HTTPConnectorDefinition extends AbstractTransportDefinition {
// for remote acceptor, the socket-binding is required
public static final SimpleAttributeDefinition SOCKET_BINDING = create(GenericTransportDefinition.SOCKET_BINDING)
.setRequired(true)
.setAllowExpression(false) // references another resource
.setAttributeMarshaller(new AttributeMarshaller() {
public void marshallAsAttribute(AttributeDefinition attribute, ModelNode resourceModel, boolean marshallDefault, XMLStreamWriter writer) throws javax.xml.stream.XMLStreamException {
if (isMarshallable(attribute, resourceModel)) {
writer.writeAttribute(attribute.getXmlName(), resourceModel.get(attribute.getName()).asString());
}
}
})
.addAccessConstraint(SensitiveTargetAccessConstraintDefinition.SOCKET_BINDING_REF)
.build();
// for remote acceptor, the socket-binding is required
public static final SimpleAttributeDefinition ENDPOINT = create("endpoint", ModelType.STRING)
.setRequired(true)
.setAllowExpression(false) // references another resource
.build();
public static final SimpleAttributeDefinition SERVER_NAME = create("server-name", ModelType.STRING)
.setRequired(false)
.setAllowExpression(false)
.build();
public HTTPConnectorDefinition(boolean registerRuntimeOnly) {
super(false, CommonAttributes.HTTP_CONNECTOR, registerRuntimeOnly, SOCKET_BINDING, ENDPOINT, SERVER_NAME, PARAMS, CommonAttributes.SSL_CONTEXT);
}
}
| 3,407
| 45.684932
| 197
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/MessagingSubsystemParser_3_0.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import static org.jboss.as.controller.PathElement.pathElement;
import static org.jboss.as.controller.PersistentResourceXMLDescription.builder;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.ACCEPTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.CONNECTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.IN_VM_ACCEPTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.IN_VM_CONNECTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.REMOTE_ACCEPTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.REMOTE_CONNECTOR;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.CONFIGURATION_MASTER_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.CONFIGURATION_SLAVE_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.REPLICATION_MASTER_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.SHARED_STORE_MASTER_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.SHARED_STORE_SLAVE_PATH;
import org.jboss.as.controller.PersistentResourceXMLDescription;
import org.jboss.as.controller.PersistentResourceXMLParser;
import org.wildfly.extension.messaging.activemq.ha.HAAttributes;
import org.wildfly.extension.messaging.activemq.ha.ScaleDownAttributes;
import org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes;
import org.wildfly.extension.messaging.activemq.jms.bridge.JMSBridgeDefinition;
import org.wildfly.extension.messaging.activemq.jms.legacy.LegacyConnectionFactoryDefinition;
/**
* Parser and Marshaller for messaging-activemq's {@link #NAMESPACE}.
*
* <em>All resources and attributes must be listed explicitly and not through any collections.</em>
* This ensures that if the resource definitions change in later version (e.g. a new attribute is added),
* this will have no impact on parsing this specific version of the subsystem.
*
* @author Paul Ferraro
*/
public class MessagingSubsystemParser_3_0 extends PersistentResourceXMLParser {
static final String NAMESPACE = "urn:jboss:domain:messaging-activemq:3.0";
@Override
public PersistentResourceXMLDescription getParserDescription(){
return builder(MessagingExtension.SUBSYSTEM_PATH, NAMESPACE)
.addAttributes(
MessagingSubsystemRootResourceDefinition.GLOBAL_CLIENT_THREAD_POOL_MAX_SIZE,
MessagingSubsystemRootResourceDefinition.GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_MAX_SIZE)
.addChild(builder(MessagingExtension.SERVER_PATH)
.addAttributes(
// no attribute groups
ServerDefinition.PERSISTENCE_ENABLED,
ServerDefinition.PERSIST_ID_CACHE,
ServerDefinition.PERSIST_DELIVERY_COUNT_BEFORE_DELIVERY,
ServerDefinition.ID_CACHE_SIZE,
ServerDefinition.PAGE_MAX_CONCURRENT_IO,
ServerDefinition.SCHEDULED_THREAD_POOL_MAX_SIZE,
ServerDefinition.THREAD_POOL_MAX_SIZE,
ServerDefinition.WILD_CARD_ROUTING_ENABLED,
ServerDefinition.CONNECTION_TTL_OVERRIDE,
ServerDefinition.ASYNC_CONNECTION_EXECUTION_ENABLED,
// security
ServerDefinition.SECURITY_ENABLED,
ServerDefinition.SECURITY_DOMAIN,
ServerDefinition.ELYTRON_DOMAIN,
ServerDefinition.SECURITY_INVALIDATION_INTERVAL,
ServerDefinition.OVERRIDE_IN_VM_SECURITY,
// cluster
ServerDefinition.CLUSTER_USER,
ServerDefinition.CLUSTER_PASSWORD,
ServerDefinition.CREDENTIAL_REFERENCE,
// management
ServerDefinition.MANAGEMENT_ADDRESS,
ServerDefinition.MANAGEMENT_NOTIFICATION_ADDRESS,
ServerDefinition.JMX_MANAGEMENT_ENABLED,
ServerDefinition.JMX_DOMAIN,
// journal
ServerDefinition.JOURNAL_TYPE,
ServerDefinition.JOURNAL_BUFFER_TIMEOUT,
ServerDefinition.JOURNAL_BUFFER_SIZE,
ServerDefinition.JOURNAL_SYNC_TRANSACTIONAL,
ServerDefinition.JOURNAL_SYNC_NON_TRANSACTIONAL,
ServerDefinition.LOG_JOURNAL_WRITE_RATE,
ServerDefinition.JOURNAL_FILE_SIZE,
ServerDefinition.JOURNAL_MIN_FILES,
ServerDefinition.JOURNAL_POOL_FILES,
ServerDefinition.JOURNAL_COMPACT_PERCENTAGE,
ServerDefinition.JOURNAL_COMPACT_MIN_FILES,
ServerDefinition.JOURNAL_MAX_IO,
ServerDefinition.CREATE_BINDINGS_DIR,
ServerDefinition.CREATE_JOURNAL_DIR,
ServerDefinition.JOURNAL_DATASOURCE,
ServerDefinition.JOURNAL_MESSAGES_TABLE,
ServerDefinition.JOURNAL_BINDINGS_TABLE,
ServerDefinition.JOURNAL_JMS_BINDINGS_TABLE,
ServerDefinition.JOURNAL_LARGE_MESSAGES_TABLE,
ServerDefinition.JOURNAL_PAGE_STORE_TABLE,
ServerDefinition.JOURNAL_DATABASE,
ServerDefinition.JOURNAL_JDBC_NETWORK_TIMEOUT,
// statistics
ServerDefinition.STATISTICS_ENABLED,
ServerDefinition.MESSAGE_COUNTER_SAMPLE_PERIOD,
ServerDefinition.MESSAGE_COUNTER_MAX_DAY_HISTORY,
// transaction
ServerDefinition.TRANSACTION_TIMEOUT,
ServerDefinition.TRANSACTION_TIMEOUT_SCAN_PERIOD,
// message expiry
ServerDefinition.MESSAGE_EXPIRY_SCAN_PERIOD,
ServerDefinition.MESSAGE_EXPIRY_THREAD_PRIORITY,
// debug
ServerDefinition.PERF_BLAST_PAGES,
ServerDefinition.RUN_SYNC_SPEED_TEST,
ServerDefinition.SERVER_DUMP_INTERVAL,
ServerDefinition.MEMORY_MEASURE_INTERVAL,
ServerDefinition.MEMORY_WARNING_THRESHOLD,
CommonAttributes.INCOMING_INTERCEPTORS,
CommonAttributes.OUTGOING_INTERCEPTORS)
.addChild(
builder(MessagingExtension.LIVE_ONLY_PATH)
.addAttributes(
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS))
.addChild(builder(REPLICATION_MASTER_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.CHECK_FOR_LIVE_SERVER,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT))
.addChild(builder(MessagingExtension.REPLICATION_SLAVE_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.ALLOW_FAILBACK,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT,
HAAttributes.MAX_SAVED_REPLICATED_JOURNAL_SIZE,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS))
.addChild(builder(MessagingExtension.REPLICATION_COLOCATED_PATH)
.addAttributes(
HAAttributes.REQUEST_BACKUP,
HAAttributes.BACKUP_REQUEST_RETRIES,
HAAttributes.BACKUP_REQUEST_RETRY_INTERVAL,
HAAttributes.MAX_BACKUPS,
HAAttributes.BACKUP_PORT_OFFSET,
HAAttributes.EXCLUDED_CONNECTORS)
.addChild(builder(MessagingExtension.CONFIGURATION_MASTER_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.CHECK_FOR_LIVE_SERVER,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT))
.addChild(builder(MessagingExtension.CONFIGURATION_SLAVE_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.ALLOW_FAILBACK,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT,
HAAttributes.MAX_SAVED_REPLICATED_JOURNAL_SIZE,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS)))
.addChild(builder(SHARED_STORE_MASTER_PATH)
.addAttributes(
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN))
.addChild(builder(SHARED_STORE_SLAVE_PATH)
.addAttributes(
HAAttributes.ALLOW_FAILBACK,
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS))
.addChild(builder(MessagingExtension.SHARED_STORE_COLOCATED_PATH)
.addAttributes(
HAAttributes.REQUEST_BACKUP,
HAAttributes.BACKUP_REQUEST_RETRIES,
HAAttributes.BACKUP_REQUEST_RETRY_INTERVAL,
HAAttributes.MAX_BACKUPS,
HAAttributes.BACKUP_PORT_OFFSET)
.addChild(builder(CONFIGURATION_MASTER_PATH)
.addAttributes(
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN))
.addChild(builder(CONFIGURATION_SLAVE_PATH)
.addAttributes(
HAAttributes.ALLOW_FAILBACK,
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS)))
.addChild(
builder(MessagingExtension.BINDINGS_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.BINDINGS_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.JOURNAL_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.JOURNAL_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.LARGE_MESSAGES_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.LARGE_MESSAGES_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.PAGING_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.PAGING_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.QUEUE_PATH)
.addAttributes(
QueueDefinition.ADDRESS,
CommonAttributes.DURABLE,
CommonAttributes.FILTER))
.addChild(
builder(MessagingExtension.SECURITY_SETTING_PATH)
.addChild(
builder(MessagingExtension.ROLE_PATH)
.addAttributes(
SecurityRoleDefinition.SEND,
SecurityRoleDefinition.CONSUME,
SecurityRoleDefinition.CREATE_DURABLE_QUEUE,
SecurityRoleDefinition.DELETE_DURABLE_QUEUE,
SecurityRoleDefinition.CREATE_NON_DURABLE_QUEUE,
SecurityRoleDefinition.DELETE_NON_DURABLE_QUEUE,
SecurityRoleDefinition.MANAGE)))
.addChild(
builder(MessagingExtension.ADDRESS_SETTING_PATH)
.addAttributes(
CommonAttributes.DEAD_LETTER_ADDRESS,
CommonAttributes.EXPIRY_ADDRESS,
AddressSettingDefinition.EXPIRY_DELAY,
AddressSettingDefinition.REDELIVERY_DELAY,
AddressSettingDefinition.REDELIVERY_MULTIPLIER,
AddressSettingDefinition.MAX_DELIVERY_ATTEMPTS,
AddressSettingDefinition.MAX_REDELIVERY_DELAY,
AddressSettingDefinition.MAX_SIZE_BYTES,
AddressSettingDefinition.PAGE_SIZE_BYTES,
AddressSettingDefinition.PAGE_MAX_CACHE_SIZE,
AddressSettingDefinition.ADDRESS_FULL_MESSAGE_POLICY,
AddressSettingDefinition.MESSAGE_COUNTER_HISTORY_DAY_LIMIT,
AddressSettingDefinition.LAST_VALUE_QUEUE,
AddressSettingDefinition.REDISTRIBUTION_DELAY,
AddressSettingDefinition.SEND_TO_DLA_ON_NO_ROUTE,
AddressSettingDefinition.SLOW_CONSUMER_CHECK_PERIOD,
AddressSettingDefinition.SLOW_CONSUMER_POLICY,
AddressSettingDefinition.SLOW_CONSUMER_THRESHOLD,
AddressSettingDefinition.AUTO_CREATE_JMS_QUEUES,
AddressSettingDefinition.AUTO_DELETE_JMS_QUEUES))
.addChild(
builder(MessagingExtension.HTTP_CONNECTOR_PATH)
.addAttributes(
HTTPConnectorDefinition.SOCKET_BINDING,
HTTPConnectorDefinition.ENDPOINT,
HTTPConnectorDefinition.SERVER_NAME,
CommonAttributes.PARAMS))
.addChild(
builder(pathElement(REMOTE_CONNECTOR))
.addAttributes(
RemoteTransportDefinition.SOCKET_BINDING,
CommonAttributes.PARAMS))
.addChild(
builder(pathElement(IN_VM_CONNECTOR))
.addAttributes(
InVMTransportDefinition.SERVER_ID,
CommonAttributes.PARAMS))
.addChild(
builder(pathElement(CONNECTOR))
.addAttributes(
GenericTransportDefinition.SOCKET_BINDING,
CommonAttributes.FACTORY_CLASS,
CommonAttributes.PARAMS))
.addChild(
builder(MessagingExtension.HTTP_ACCEPTOR_PATH)
.addAttributes(
HTTPAcceptorDefinition.HTTP_LISTENER,
HTTPAcceptorDefinition.UPGRADE_LEGACY,
CommonAttributes.PARAMS))
.addChild(
builder(pathElement(REMOTE_ACCEPTOR))
.addAttributes(
RemoteTransportDefinition.SOCKET_BINDING,
CommonAttributes.PARAMS))
.addChild(
builder(pathElement(IN_VM_ACCEPTOR))
.addAttributes(
InVMTransportDefinition.SERVER_ID,
CommonAttributes.PARAMS))
.addChild(
builder(pathElement(ACCEPTOR))
.addAttributes(
GenericTransportDefinition.SOCKET_BINDING,
CommonAttributes.FACTORY_CLASS,
CommonAttributes.PARAMS))
.addChild(
builder(MessagingExtension.BROADCAST_GROUP_PATH)
.addAttributes(
CommonAttributes.SOCKET_BINDING,
BroadcastGroupDefinition.JGROUPS_CHANNEL_FACTORY,
BroadcastGroupDefinition.JGROUPS_CHANNEL,
CommonAttributes.JGROUPS_CLUSTER,
BroadcastGroupDefinition.BROADCAST_PERIOD,
BroadcastGroupDefinition.CONNECTOR_REFS))
.addChild(
builder(DiscoveryGroupDefinition.PATH)
.addAttributes(
CommonAttributes.SOCKET_BINDING,
DiscoveryGroupDefinition.JGROUPS_CHANNEL_FACTORY,
DiscoveryGroupDefinition.JGROUPS_CHANNEL,
CommonAttributes.JGROUPS_CLUSTER,
DiscoveryGroupDefinition.REFRESH_TIMEOUT,
DiscoveryGroupDefinition.INITIAL_WAIT_TIMEOUT))
.addChild(
builder(MessagingExtension.CLUSTER_CONNECTION_PATH)
.addAttributes(
ClusterConnectionDefinition.ADDRESS,
ClusterConnectionDefinition.CONNECTOR_NAME,
ClusterConnectionDefinition.CHECK_PERIOD,
ClusterConnectionDefinition.CONNECTION_TTL,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CALL_TIMEOUT,
ClusterConnectionDefinition.CALL_FAILOVER_TIMEOUT,
ClusterConnectionDefinition.RETRY_INTERVAL,
ClusterConnectionDefinition.RETRY_INTERVAL_MULTIPLIER,
ClusterConnectionDefinition.MAX_RETRY_INTERVAL,
ClusterConnectionDefinition.INITIAL_CONNECT_ATTEMPTS,
ClusterConnectionDefinition.RECONNECT_ATTEMPTS,
ClusterConnectionDefinition.USE_DUPLICATE_DETECTION,
ClusterConnectionDefinition.MESSAGE_LOAD_BALANCING_TYPE,
ClusterConnectionDefinition.MAX_HOPS,
CommonAttributes.BRIDGE_CONFIRMATION_WINDOW_SIZE,
ClusterConnectionDefinition.PRODUCER_WINDOW_SIZE,
ClusterConnectionDefinition.NOTIFICATION_ATTEMPTS,
ClusterConnectionDefinition.NOTIFICATION_INTERVAL,
ClusterConnectionDefinition.CONNECTOR_REFS,
ClusterConnectionDefinition.ALLOW_DIRECT_CONNECTIONS_ONLY,
ClusterConnectionDefinition.DISCOVERY_GROUP_NAME))
.addChild(
builder(MessagingExtension.GROUPING_HANDLER_PATH)
.addAttributes(
GroupingHandlerDefinition.TYPE,
GroupingHandlerDefinition.GROUPING_HANDLER_ADDRESS,
GroupingHandlerDefinition.TIMEOUT,
GroupingHandlerDefinition.GROUP_TIMEOUT,
GroupingHandlerDefinition.REAPER_PERIOD))
.addChild(
builder(DivertDefinition.PATH)
.addAttributes(
DivertDefinition.ROUTING_NAME,
DivertDefinition.ADDRESS,
DivertDefinition.FORWARDING_ADDRESS,
CommonAttributes.FILTER,
CommonAttributes.TRANSFORMER_CLASS_NAME,
DivertDefinition.EXCLUSIVE))
.addChild(
builder(MessagingExtension.BRIDGE_PATH)
.addAttributes(
BridgeDefinition.QUEUE_NAME,
BridgeDefinition.FORWARDING_ADDRESS,
CommonAttributes.HA,
CommonAttributes.FILTER,
CommonAttributes.TRANSFORMER_CLASS_NAME,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CHECK_PERIOD,
CommonAttributes.CONNECTION_TTL,
CommonAttributes.RETRY_INTERVAL,
CommonAttributes.RETRY_INTERVAL_MULTIPLIER,
CommonAttributes.MAX_RETRY_INTERVAL,
BridgeDefinition.INITIAL_CONNECT_ATTEMPTS,
BridgeDefinition.RECONNECT_ATTEMPTS,
BridgeDefinition.RECONNECT_ATTEMPTS_ON_SAME_NODE,
BridgeDefinition.USE_DUPLICATE_DETECTION,
CommonAttributes.BRIDGE_CONFIRMATION_WINDOW_SIZE,
BridgeDefinition.PRODUCER_WINDOW_SIZE,
BridgeDefinition.USER,
BridgeDefinition.PASSWORD,
BridgeDefinition.CREDENTIAL_REFERENCE,
BridgeDefinition.CONNECTOR_REFS,
BridgeDefinition.DISCOVERY_GROUP_NAME))
.addChild(
builder(MessagingExtension.CONNECTOR_SERVICE_PATH)
.addAttributes(
CommonAttributes.FACTORY_CLASS,
CommonAttributes.PARAMS))
.addChild(
builder(MessagingExtension.JMS_QUEUE_PATH)
.addAttributes(
CommonAttributes.DESTINATION_ENTRIES,
CommonAttributes.SELECTOR,
CommonAttributes.DURABLE,
CommonAttributes.LEGACY_ENTRIES))
.addChild(
builder(MessagingExtension.JMS_TOPIC_PATH)
.addAttributes(
CommonAttributes.DESTINATION_ENTRIES,
CommonAttributes.LEGACY_ENTRIES))
.addChild(
builder(MessagingExtension.CONNECTION_FACTORY_PATH)
.addAttributes(
ConnectionFactoryAttributes.Common.ENTRIES,
// common
ConnectionFactoryAttributes.Common.DISCOVERY_GROUP,
ConnectionFactoryAttributes.Common.CONNECTORS,
CommonAttributes.HA,
ConnectionFactoryAttributes.Common.CLIENT_FAILURE_CHECK_PERIOD,
ConnectionFactoryAttributes.Common.CONNECTION_TTL,
CommonAttributes.CALL_TIMEOUT,
CommonAttributes.CALL_FAILOVER_TIMEOUT,
ConnectionFactoryAttributes.Common.CONSUMER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.CONSUMER_MAX_RATE,
ConnectionFactoryAttributes.Common.CONFIRMATION_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_MAX_RATE,
ConnectionFactoryAttributes.Common.PROTOCOL_MANAGER_FACTORY,
ConnectionFactoryAttributes.Common.COMPRESS_LARGE_MESSAGES,
ConnectionFactoryAttributes.Common.CACHE_LARGE_MESSAGE_CLIENT,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CLIENT_ID,
ConnectionFactoryAttributes.Common.DUPS_OK_BATCH_SIZE,
ConnectionFactoryAttributes.Common.TRANSACTION_BATCH_SIZE,
ConnectionFactoryAttributes.Common.BLOCK_ON_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.BLOCK_ON_NON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.BLOCK_ON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.AUTO_GROUP,
ConnectionFactoryAttributes.Common.PRE_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL_MULTIPLIER,
CommonAttributes.MAX_RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RECONNECT_ATTEMPTS,
ConnectionFactoryAttributes.Common.FAILOVER_ON_INITIAL_CONNECTION,
ConnectionFactoryAttributes.Common.CONNECTION_LOAD_BALANCING_CLASS_NAME,
ConnectionFactoryAttributes.Common.USE_GLOBAL_POOLS,
ConnectionFactoryAttributes.Common.SCHEDULED_THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.GROUP_ID,
ConnectionFactoryAttributes.Common.DESERIALIZATION_BLACKLIST,
ConnectionFactoryAttributes.Common.DESERIALIZATION_WHITELIST,
ConnectionFactoryAttributes.Common.INITIAL_MESSAGE_PACKET_SIZE,
// regular
ConnectionFactoryAttributes.Regular.FACTORY_TYPE))
.addChild(
builder(MessagingExtension.LEGACY_CONNECTION_FACTORY_PATH)
.addAttributes(
LegacyConnectionFactoryDefinition.ENTRIES,
LegacyConnectionFactoryDefinition.DISCOVERY_GROUP,
LegacyConnectionFactoryDefinition.CONNECTORS,
LegacyConnectionFactoryDefinition.AUTO_GROUP,
LegacyConnectionFactoryDefinition.BLOCK_ON_ACKNOWLEDGE,
LegacyConnectionFactoryDefinition.BLOCK_ON_DURABLE_SEND,
LegacyConnectionFactoryDefinition.BLOCK_ON_NON_DURABLE_SEND,
CommonAttributes.CALL_TIMEOUT,
CommonAttributes.CALL_FAILOVER_TIMEOUT,
LegacyConnectionFactoryDefinition.CACHE_LARGE_MESSAGE_CLIENT,
LegacyConnectionFactoryDefinition.CLIENT_FAILURE_CHECK_PERIOD,
CommonAttributes.CLIENT_ID,
LegacyConnectionFactoryDefinition.COMPRESS_LARGE_MESSAGES,
LegacyConnectionFactoryDefinition.CONFIRMATION_WINDOW_SIZE,
LegacyConnectionFactoryDefinition.CONNECTION_LOAD_BALANCING_CLASS_NAME,
LegacyConnectionFactoryDefinition.CONNECTION_TTL,
LegacyConnectionFactoryDefinition.CONSUMER_MAX_RATE,
LegacyConnectionFactoryDefinition.CONSUMER_WINDOW_SIZE,
LegacyConnectionFactoryDefinition.DUPS_OK_BATCH_SIZE,
LegacyConnectionFactoryDefinition.FACTORY_TYPE,
LegacyConnectionFactoryDefinition.FAILOVER_ON_INITIAL_CONNECTION,
LegacyConnectionFactoryDefinition.GROUP_ID,
LegacyConnectionFactoryDefinition.INITIAL_CONNECT_ATTEMPTS,
LegacyConnectionFactoryDefinition.INITIAL_MESSAGE_PACKET_SIZE,
LegacyConnectionFactoryDefinition.HA,
LegacyConnectionFactoryDefinition.MAX_RETRY_INTERVAL,
LegacyConnectionFactoryDefinition.MIN_LARGE_MESSAGE_SIZE,
LegacyConnectionFactoryDefinition.PRE_ACKNOWLEDGE,
LegacyConnectionFactoryDefinition.PRODUCER_MAX_RATE,
LegacyConnectionFactoryDefinition.PRODUCER_WINDOW_SIZE,
LegacyConnectionFactoryDefinition.RECONNECT_ATTEMPTS,
LegacyConnectionFactoryDefinition.RETRY_INTERVAL,
LegacyConnectionFactoryDefinition.RETRY_INTERVAL_MULTIPLIER,
LegacyConnectionFactoryDefinition.SCHEDULED_THREAD_POOL_MAX_SIZE,
LegacyConnectionFactoryDefinition.THREAD_POOL_MAX_SIZE,
LegacyConnectionFactoryDefinition.TRANSACTION_BATCH_SIZE,
LegacyConnectionFactoryDefinition.USE_GLOBAL_POOLS))
.addChild(
builder(MessagingExtension.POOLED_CONNECTION_FACTORY_PATH)
.addAttributes(
ConnectionFactoryAttributes.Common.ENTRIES,
// common
ConnectionFactoryAttributes.Common.DISCOVERY_GROUP,
ConnectionFactoryAttributes.Common.CONNECTORS,
CommonAttributes.HA,
ConnectionFactoryAttributes.Common.CLIENT_FAILURE_CHECK_PERIOD,
ConnectionFactoryAttributes.Common.CONNECTION_TTL,
CommonAttributes.CALL_TIMEOUT,
CommonAttributes.CALL_FAILOVER_TIMEOUT,
ConnectionFactoryAttributes.Common.CONSUMER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.CONSUMER_MAX_RATE,
ConnectionFactoryAttributes.Common.CONFIRMATION_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_MAX_RATE,
ConnectionFactoryAttributes.Common.PROTOCOL_MANAGER_FACTORY,
ConnectionFactoryAttributes.Common.COMPRESS_LARGE_MESSAGES,
ConnectionFactoryAttributes.Common.CACHE_LARGE_MESSAGE_CLIENT,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CLIENT_ID,
ConnectionFactoryAttributes.Common.DUPS_OK_BATCH_SIZE,
ConnectionFactoryAttributes.Common.TRANSACTION_BATCH_SIZE,
ConnectionFactoryAttributes.Common.BLOCK_ON_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.BLOCK_ON_NON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.BLOCK_ON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.AUTO_GROUP,
ConnectionFactoryAttributes.Common.PRE_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL_MULTIPLIER,
CommonAttributes.MAX_RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RECONNECT_ATTEMPTS,
ConnectionFactoryAttributes.Common.FAILOVER_ON_INITIAL_CONNECTION,
ConnectionFactoryAttributes.Common.CONNECTION_LOAD_BALANCING_CLASS_NAME,
ConnectionFactoryAttributes.Common.USE_GLOBAL_POOLS,
ConnectionFactoryAttributes.Common.SCHEDULED_THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.GROUP_ID,
ConnectionFactoryAttributes.Common.DESERIALIZATION_BLACKLIST,
ConnectionFactoryAttributes.Common.DESERIALIZATION_WHITELIST,
ConnectionFactoryAttributes.Common.INITIAL_MESSAGE_PACKET_SIZE,
// pooled
// inbound config
ConnectionFactoryAttributes.Pooled.USE_JNDI,
ConnectionFactoryAttributes.Pooled.JNDI_PARAMS,
ConnectionFactoryAttributes.Pooled.REBALANCE_CONNECTIONS,
ConnectionFactoryAttributes.Pooled.USE_LOCAL_TX,
ConnectionFactoryAttributes.Pooled.SETUP_ATTEMPTS,
ConnectionFactoryAttributes.Pooled.SETUP_INTERVAL,
// outbound config
ConnectionFactoryAttributes.Pooled.ALLOW_LOCAL_TRANSACTIONS,
ConnectionFactoryAttributes.Pooled.TRANSACTION,
ConnectionFactoryAttributes.Pooled.USER,
ConnectionFactoryAttributes.Pooled.PASSWORD,
ConnectionFactoryAttributes.Pooled.CREDENTIAL_REFERENCE,
ConnectionFactoryAttributes.Pooled.MIN_POOL_SIZE,
ConnectionFactoryAttributes.Pooled.USE_AUTO_RECOVERY,
ConnectionFactoryAttributes.Pooled.MAX_POOL_SIZE,
ConnectionFactoryAttributes.Pooled.MANAGED_CONNECTION_POOL,
ConnectionFactoryAttributes.Pooled.ENLISTMENT_TRACE,
ConnectionFactoryAttributes.Pooled.INITIAL_CONNECT_ATTEMPTS,
ConnectionFactoryAttributes.Pooled.STATISTICS_ENABLED)))
.addChild(
builder(MessagingExtension.JMS_BRIDGE_PATH)
.addAttributes(
JMSBridgeDefinition.MODULE,
JMSBridgeDefinition.QUALITY_OF_SERVICE,
JMSBridgeDefinition.FAILURE_RETRY_INTERVAL,
JMSBridgeDefinition.MAX_RETRIES,
JMSBridgeDefinition.MAX_BATCH_SIZE,
JMSBridgeDefinition.MAX_BATCH_TIME,
CommonAttributes.SELECTOR,
JMSBridgeDefinition.SUBSCRIPTION_NAME,
CommonAttributes.CLIENT_ID,
JMSBridgeDefinition.ADD_MESSAGE_ID_IN_HEADER,
JMSBridgeDefinition.SOURCE_CONNECTION_FACTORY,
JMSBridgeDefinition.SOURCE_DESTINATION,
JMSBridgeDefinition.SOURCE_USER,
JMSBridgeDefinition.SOURCE_PASSWORD,
JMSBridgeDefinition.SOURCE_CREDENTIAL_REFERENCE,
JMSBridgeDefinition.TARGET_CONNECTION_FACTORY,
JMSBridgeDefinition.TARGET_DESTINATION,
JMSBridgeDefinition.TARGET_USER,
JMSBridgeDefinition.TARGET_PASSWORD,
JMSBridgeDefinition.TARGET_CREDENTIAL_REFERENCE,
JMSBridgeDefinition.SOURCE_CONTEXT,
JMSBridgeDefinition.TARGET_CONTEXT))
.build();
}
}
| 52,231
| 85.049423
| 128
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/BridgeDefinition.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import static org.jboss.as.controller.SimpleAttributeDefinitionBuilder.create;
import static org.jboss.as.controller.client.helpers.MeasurementUnit.BYTES;
import static org.jboss.as.controller.client.helpers.MeasurementUnit.MILLISECONDS;
import static org.jboss.dmr.ModelType.BOOLEAN;
import static org.jboss.dmr.ModelType.INT;
import static org.jboss.dmr.ModelType.LONG;
import static org.jboss.dmr.ModelType.STRING;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.MESSAGING_SECURITY_SENSITIVE_TARGET;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.STATIC_CONNECTORS;
import java.util.Arrays;
import java.util.Collection;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.AttributeMarshaller;
import org.jboss.as.controller.AttributeParser;
import org.jboss.as.controller.CaseParameterCorrector;
import org.jboss.as.controller.ObjectTypeAttributeDefinition;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.PrimitiveListAttributeDefinition;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.StringListAttributeDefinition;
import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition;
import org.jboss.as.controller.operations.validation.EnumValidator;
import org.jboss.as.controller.operations.validation.StringLengthValidator;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.security.CredentialReference;
import org.jboss.as.controller.security.CredentialReferenceWriteAttributeHandler;
import org.jboss.dmr.ModelNode;
/**
* Bridge resource definition
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat Inc.
*/
public class BridgeDefinition extends PersistentResourceDefinition {
public static final PrimitiveListAttributeDefinition CONNECTOR_REFS = new StringListAttributeDefinition.Builder(CommonAttributes.STATIC_CONNECTORS)
.setRequired(true)
.setElementValidator(new StringLengthValidator(1))
.setAttributeParser(AttributeParser.STRING_LIST)
.setAttributeMarshaller(AttributeMarshaller.STRING_LIST)
.setAllowExpression(false)
.setAlternatives(CommonAttributes.DISCOVERY_GROUP)
.setRestartAllServices()
.build();
public static final SimpleAttributeDefinition DISCOVERY_GROUP_NAME = create(CommonAttributes.DISCOVERY_GROUP, STRING)
.setRequired(true)
.setAlternatives(STATIC_CONNECTORS)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultBridgeInitialConnectAttempts
*/
public static final SimpleAttributeDefinition INITIAL_CONNECT_ATTEMPTS = create("initial-connect-attempts", INT)
.setRequired(false)
.setDefaultValue(new ModelNode().set(-1))
.setAllowExpression(true)
.setCorrector(InfiniteOrPositiveValidators.NEGATIVE_VALUE_CORRECTOR)
.setValidator(InfiniteOrPositiveValidators.INT_INSTANCE)
.setRestartAllServices()
.build();
public static final SimpleAttributeDefinition QUEUE_NAME = create(CommonAttributes.QUEUE_NAME, STRING)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultBridgeProducerWindowSize
*/
public static final SimpleAttributeDefinition PRODUCER_WINDOW_SIZE = create("producer-window-size", INT)
.setDefaultValue(new ModelNode(-1))
.setMeasurementUnit(BYTES)
.setRequired(false)
.setAllowExpression(true)
.setCorrector(InfiniteOrPositiveValidators.NEGATIVE_VALUE_CORRECTOR)
.setValidator(InfiniteOrPositiveValidators.INT_INSTANCE)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultClusterPassword
*/
public static final SimpleAttributeDefinition PASSWORD = create("password", STRING, true)
.setAllowExpression(true)
.setDefaultValue(new ModelNode("CHANGE ME!!"))
.setRestartAllServices()
.addAccessConstraint(SensitiveTargetAccessConstraintDefinition.CREDENTIAL)
.addAccessConstraint(MESSAGING_SECURITY_SENSITIVE_TARGET)
.setAlternatives(CredentialReference.CREDENTIAL_REFERENCE)
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultClusterUser
*/
public static final SimpleAttributeDefinition USER = create("user", STRING)
.setRequired(false)
.setAllowExpression(true)
.setDefaultValue(new ModelNode("ACTIVEMQ.CLUSTER.ADMIN.USER"))
.setRestartAllServices()
.addAccessConstraint(SensitiveTargetAccessConstraintDefinition.CREDENTIAL)
.addAccessConstraint(MESSAGING_SECURITY_SENSITIVE_TARGET)
.build();
public static final ObjectTypeAttributeDefinition CREDENTIAL_REFERENCE =
CredentialReference.getAttributeBuilder(true, false)
.setRestartAllServices()
.addAccessConstraint(SensitiveTargetAccessConstraintDefinition.CREDENTIAL)
.addAccessConstraint(MESSAGING_SECURITY_SENSITIVE_TARGET)
.setAlternatives(PASSWORD.getName())
.build();
/**
* @see ActiveMQDefaultConfiguration#isDefaultBridgeDuplicateDetection
*/
public static final SimpleAttributeDefinition USE_DUPLICATE_DETECTION = create("use-duplicate-detection", BOOLEAN)
.setRequired(false)
.setDefaultValue(ModelNode.TRUE)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultBridgeReconnectAttempts
*/
public static final SimpleAttributeDefinition RECONNECT_ATTEMPTS = create("reconnect-attempts", INT)
.setRequired(false)
.setDefaultValue(new ModelNode(-1))
.setAllowExpression(true)
.setCorrector(InfiniteOrPositiveValidators.NEGATIVE_VALUE_CORRECTOR)
.setValidator(InfiniteOrPositiveValidators.INT_INSTANCE)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultBridgeConnectSameNode
*/
public static final SimpleAttributeDefinition RECONNECT_ATTEMPTS_ON_SAME_NODE = create("reconnect-attempts-on-same-node", INT)
.setRequired(false)
.setDefaultValue(new ModelNode(10))
.setAllowExpression(true)
.setRestartAllServices()
.build();
public static final SimpleAttributeDefinition FORWARDING_ADDRESS = create("forwarding-address", STRING)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see {@link org.apache.activemq.artemis.api.core.client.ActiveMQClient#DEFAULT_CALL_TIMEOUT}
*/
public static final SimpleAttributeDefinition CALL_TIMEOUT = create("call-timeout", LONG)
.setDefaultValue(new ModelNode(30000L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
public static final SimpleAttributeDefinition ROUTING_TYPE = create("routing-type", STRING)
.setRequired(false)
.setDefaultValue(new ModelNode("PASS"))
.setAllowExpression(true)
.setRestartAllServices()
.setCorrector(CaseParameterCorrector.TO_UPPER)
.setValidator(EnumValidator.create(RoutingType.class, RoutingType.values()))
.build();
public static final AttributeDefinition[] ATTRIBUTES = {
QUEUE_NAME, FORWARDING_ADDRESS, CommonAttributes.HA,
CommonAttributes.FILTER, CommonAttributes.TRANSFORMER_CLASS_NAME,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE, CommonAttributes.CHECK_PERIOD, CommonAttributes.CONNECTION_TTL,
CommonAttributes.RETRY_INTERVAL, CommonAttributes.RETRY_INTERVAL_MULTIPLIER, CommonAttributes.MAX_RETRY_INTERVAL,
INITIAL_CONNECT_ATTEMPTS,
RECONNECT_ATTEMPTS,
RECONNECT_ATTEMPTS_ON_SAME_NODE,
USE_DUPLICATE_DETECTION,
PRODUCER_WINDOW_SIZE,
CommonAttributes.BRIDGE_CONFIRMATION_WINDOW_SIZE,
USER, PASSWORD, CREDENTIAL_REFERENCE,
CONNECTOR_REFS, DISCOVERY_GROUP_NAME,
CALL_TIMEOUT, ROUTING_TYPE
};
private final boolean registerRuntimeOnly;
BridgeDefinition(boolean registerRuntimeOnly) {
super(MessagingExtension.BRIDGE_PATH,
MessagingExtension.getResourceDescriptionResolver(CommonAttributes.BRIDGE),
BridgeAdd.INSTANCE,
BridgeRemove.INSTANCE);
this.registerRuntimeOnly = registerRuntimeOnly;
}
@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(ATTRIBUTES);
}
@Override
public void registerAttributes(ManagementResourceRegistration registry) {
ReloadRequiredWriteAttributeHandler reloadRequiredWriteAttributeHandler = new ReloadRequiredWriteAttributeHandler(ATTRIBUTES);
CredentialReferenceWriteAttributeHandler credentialReferenceWriteAttributeHandler = new CredentialReferenceWriteAttributeHandler(CREDENTIAL_REFERENCE);
for (AttributeDefinition attr : ATTRIBUTES) {
if (!attr.getFlags().contains(AttributeAccess.Flag.STORAGE_RUNTIME)) {
if (attr.equals(CREDENTIAL_REFERENCE)) {
registry.registerReadWriteAttribute(attr, null, credentialReferenceWriteAttributeHandler);
} else {
registry.registerReadWriteAttribute(attr, null, reloadRequiredWriteAttributeHandler);
}
}
}
BridgeControlHandler.INSTANCE.registerAttributes(registry);
}
@Override
public void registerOperations(ManagementResourceRegistration registry) {
super.registerOperations(registry);
if (registerRuntimeOnly) {
BridgeControlHandler.INSTANCE.registerOperations(registry, getResourceDescriptionResolver());
}
}
private enum RoutingType {
STRIP, PASS;
}
}
| 11,842
| 44.375479
| 159
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/GroupingHandlerWriteAttributeHandler.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
/**
* Write attribute handler for attributes that update a broadcast group resource.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class GroupingHandlerWriteAttributeHandler extends ReloadRequiredWriteAttributeHandler {
public static final GroupingHandlerWriteAttributeHandler INSTANCE = new GroupingHandlerWriteAttributeHandler();
private GroupingHandlerWriteAttributeHandler() {
super(GroupingHandlerDefinition.ATTRIBUTES);
}
}
| 1,615
| 39.4
| 115
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/DivertDefinition.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import static org.jboss.as.controller.SimpleAttributeDefinitionBuilder.create;
import static org.jboss.dmr.ModelType.BOOLEAN;
import static org.jboss.dmr.ModelType.STRING;
import java.util.Arrays;
import java.util.Collection;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.dmr.ModelNode;
/**
* Divert resource definition
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat Inc.
*/
public class DivertDefinition extends PersistentResourceDefinition {
public static final PathElement PATH = PathElement.pathElement(CommonAttributes.DIVERT);
public static final SimpleAttributeDefinition ROUTING_NAME = create("routing-name", STRING)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
public static final SimpleAttributeDefinition ADDRESS = create("divert-address", STRING)
.setXmlName("address")
.setDefaultValue(null)
.setAllowExpression(true)
.setRestartAllServices()
.build();
public static final SimpleAttributeDefinition FORWARDING_ADDRESS = create("forwarding-address", STRING)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#isDefaultDivertExclusive
*/
public static final SimpleAttributeDefinition EXCLUSIVE = create("exclusive", BOOLEAN)
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
public static final AttributeDefinition[] ATTRIBUTES = { ROUTING_NAME, ADDRESS, FORWARDING_ADDRESS, CommonAttributes.FILTER,
CommonAttributes.TRANSFORMER_CLASS_NAME, EXCLUSIVE };
private final boolean registerRuntimeOnly;
public DivertDefinition(boolean registerRuntimeOnly) {
super(PATH,
MessagingExtension.getResourceDescriptionResolver(CommonAttributes.DIVERT),
DivertAdd.INSTANCE,
DivertRemove.INSTANCE);
this.registerRuntimeOnly = registerRuntimeOnly;
}
@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(ATTRIBUTES);
}
@Override
public void registerAttributes(ManagementResourceRegistration registry) {
for (AttributeDefinition attr : ATTRIBUTES) {
if (registerRuntimeOnly || !attr.getFlags().contains(AttributeAccess.Flag.STORAGE_RUNTIME)) {
registry.registerReadWriteAttribute(attr, null, DivertConfigurationWriteHandler.INSTANCE);
}
}
}
}
| 4,070
| 38.144231
| 128
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/ActiveMQActivationService.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import static org.jboss.as.controller.PathAddress.pathAddress;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.PathAddress;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceRegistry;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;
/**
* A service that can be dependent on to ensure the ActiveMQ server is active.
*
* ActiveMQ servers can be passive when they are configured as backup and wait for a live node to fail.
* In this passive state, the server does not accept connections or create resources.
*
* This service must be used by any service depending on an ActiveMQ server being active.
*
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2013 Red Hat inc.
*/
public class ActiveMQActivationService implements Service<Void> {
public static ServiceName getServiceName(ServiceName serverName) {
return serverName.append("activation");
}
public static boolean isActiveMQServerActive(OperationContext context, ModelNode operation) {
PathAddress address = pathAddress(operation.get(OP_ADDR));
return isActiveMQServerActive(context.getServiceRegistry(false), MessagingServices.getActiveMQServiceName(address));
}
public static boolean isActiveMQServerActive(ServiceRegistry serviceRegistry, ServiceName activeMQServerServiceName) {
ServiceController<?> service = serviceRegistry.getService(activeMQServerServiceName);
if (service != null) {
ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
if (server.isStarted() && server.isActive()) {
return true;
}
}
return false;
}
public static boolean rollbackOperationIfServerNotActive(OperationContext context, ModelNode operation) {
if (isActiveMQServerActive(context, operation)) {
return false;
}
context.getFailureDescription().set(MessagingLogger.ROOT_LOGGER.serverInBackupMode(pathAddress(operation.require(OP_ADDR))));
context.setRollbackOnly();
return true;
}
public static boolean ignoreOperationIfServerNotActive(OperationContext context, ModelNode operation) {
if (isActiveMQServerActive(context, operation)) {
return false;
}
// undefined result
context.getResult();
return true;
}
static ActiveMQServer getActiveMQServer(final OperationContext context, ModelNode operation) {
final ServiceName activMQServerServiceName = MessagingServices.getActiveMQServiceName(pathAddress(operation.get(OP_ADDR)));
final ServiceController<?> controller = context.getServiceRegistry(false).getService(activMQServerServiceName);
if(controller != null) {
return ActiveMQServer.class.cast(controller.getValue());
}
return null;
}
@Override
public void start(StartContext context) throws StartException {
}
@Override
public void stop(StopContext context) {
}
@Override
public Void getValue() throws IllegalStateException, IllegalArgumentException {
return null;
}
}
| 4,668
| 40.318584
| 133
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/GroupingHandlerDefinition.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import static org.jboss.as.controller.SimpleAttributeDefinitionBuilder.create;
import static org.jboss.as.controller.client.helpers.MeasurementUnit.MILLISECONDS;
import static org.jboss.as.controller.registry.AttributeAccess.Flag.STORAGE_RUNTIME;
import static org.jboss.dmr.ModelType.LONG;
import static org.jboss.dmr.ModelType.STRING;
import java.util.Arrays;
import java.util.Collection;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.operations.validation.EnumValidator;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.dmr.ModelNode;
/**
* Grouping handler resource definition
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat Inc.
*/
public class GroupingHandlerDefinition extends PersistentResourceDefinition {
public static final SimpleAttributeDefinition GROUPING_HANDLER_ADDRESS = create("grouping-handler-address", STRING)
.setXmlName(CommonAttributes.ADDRESS)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultGroupingHandlerTimeout
*/
public static final SimpleAttributeDefinition TIMEOUT = create("timeout", LONG)
.setDefaultValue(new ModelNode(5000L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultGroupingHandlerGroupTimeout
*/
public static final SimpleAttributeDefinition GROUP_TIMEOUT = create("group-timeout", LONG)
// FIXME Cast to a long until Artemis type is fixed
.setDefaultValue(new ModelNode(-1L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.setValidator(InfiniteOrPositiveValidators.LONG_INSTANCE)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultGroupingHandlerReaperPeriod
*/
public static final SimpleAttributeDefinition REAPER_PERIOD = create("reaper-period", LONG)
.setDefaultValue(new ModelNode(30000L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
public static final SimpleAttributeDefinition TYPE = create("type", STRING)
.setAllowExpression(true)
.setValidator(EnumValidator.create(Type.class))
.setRestartAllServices()
.build();
public static final AttributeDefinition[] ATTRIBUTES = { TYPE, GROUPING_HANDLER_ADDRESS, TIMEOUT, GROUP_TIMEOUT, REAPER_PERIOD };
GroupingHandlerDefinition() {
super(MessagingExtension.GROUPING_HANDLER_PATH,
MessagingExtension.getResourceDescriptionResolver(CommonAttributes.GROUPING_HANDLER),
GroupingHandlerAdd.INSTANCE,
GroupingHandlerRemove.INSTANCE);
}
@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(ATTRIBUTES);
}
@Override
public void registerAttributes(ManagementResourceRegistration registry) {
for (AttributeDefinition attr : ATTRIBUTES) {
if (!attr.getFlags().contains(STORAGE_RUNTIME)) {
registry.registerReadWriteAttribute(attr, null, GroupingHandlerWriteAttributeHandler.INSTANCE);
}
}
}
private enum Type {
LOCAL, REMOTE;
}
}
| 4,929
| 39.409836
| 133
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/AbstractActiveMQComponentControlHandler.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import static org.jboss.as.controller.SimpleAttributeDefinitionBuilder.create;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_ATTRIBUTE_OPERATION;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.START;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.STOP;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.NAME;
import static org.wildfly.extension.messaging.activemq.logging.MessagingLogger.ROOT_LOGGER;
import static org.jboss.dmr.ModelType.BOOLEAN;
import org.apache.activemq.artemis.api.core.management.ActiveMQComponentControl;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.jboss.as.controller.AbstractRuntimeOnlyHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationDefinition;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleOperationDefinitionBuilder;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.descriptions.ResourceDescriptionResolver;
import org.jboss.as.controller.operations.validation.ParametersValidator;
import org.jboss.as.controller.operations.validation.StringLengthValidator;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* Base class for {@link org.jboss.as.controller.OperationStepHandler} implementations for handlers that interact
* with an implementation of a {@link ActiveMQComponentControl} subinterface to perform their function. This base class
* handles a "start" and "stop" operation as well as a "read-attribute" call reading runtime attribute "started".
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public abstract class AbstractActiveMQComponentControlHandler<T extends ActiveMQComponentControl> extends AbstractRuntimeOnlyHandler {
private static final SimpleAttributeDefinition STARTED = create(CommonAttributes.STARTED, BOOLEAN)
.setFlags(AttributeAccess.Flag.STORAGE_RUNTIME)
.build();
private ParametersValidator readAttributeValidator = new ParametersValidator();
protected AbstractActiveMQComponentControlHandler() {
readAttributeValidator.registerValidator(NAME, new StringLengthValidator(1));
}
@Override
protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
final String operationName = operation.require(OP).asString();
if (READ_ATTRIBUTE_OPERATION.equals(operationName)) {
if (ActiveMQActivationService.ignoreOperationIfServerNotActive(context, operation)) {
return;
}
readAttributeValidator.validate(operation);
final String name = operation.require(NAME).asString();
if (STARTED.getName().equals(name)) {
ActiveMQComponentControl control = getActiveMQComponentControl(context, operation, false);
if(control != null) {
context.getResult().set(control.isStarted());
}
} else {
handleReadAttribute(name, context, operation);
}
return;
}
if (ActiveMQActivationService.rollbackOperationIfServerNotActive(context, operation)) {
return;
}
ActiveMQComponentControl control = null;
boolean appliedToRuntime = false;
Object handback = null;
if (START.equals(operationName)) {
control = getActiveMQComponentControl(context, operation, true);
try {
control.start();
appliedToRuntime = true;
context.getResult();
} catch (Exception e) {
context.getFailureDescription().set(e.getLocalizedMessage());
}
} else if (STOP.equals(operationName)) {
control = getActiveMQComponentControl(context, operation, true);
try {
control.stop();
appliedToRuntime = true;
context.getResult();
} catch (Exception e) {
context.getFailureDescription().set(e.getLocalizedMessage());
}
} else {
handback = handleOperation(operationName, context, operation);
appliedToRuntime = handback != null;
}
OperationContext.RollbackHandler rh;
if (appliedToRuntime) {
final ActiveMQComponentControl rhControl = control;
final Object rhHandback = handback;
rh = new OperationContext.RollbackHandler() {
@Override
public void handleRollback(OperationContext context, ModelNode operation) {
try {
if (START.equals(operationName)) {
rhControl.stop();
} else if (STOP.equals(operationName)) {
rhControl.start();
} else {
handleRevertOperation(operationName, context, operation, rhHandback);
}
} catch (Exception e) {
ROOT_LOGGER.revertOperationFailed(e, getClass().getSimpleName(),
operation.require(ModelDescriptionConstants.OP).asString(),
PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)));
}
}
};
} else {
rh = OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER;
}
context.completeStep(rh);
}
public void registerAttributes(final ManagementResourceRegistration registry) {
registry.registerReadOnlyAttribute(STARTED, this);
}
public void registerOperations(final ManagementResourceRegistration registry, final ResourceDescriptionResolver resolver) {
final OperationDefinition startOp = new SimpleOperationDefinitionBuilder(START, resolver)
.setRuntimeOnly()
.build();
registry.registerOperationHandler(startOp, this);
final OperationDefinition stopOp = new SimpleOperationDefinitionBuilder(STOP, resolver)
.setRuntimeOnly()
.build();
registry.registerOperationHandler(stopOp, this);
}
/**
* Gets the {@link ActiveMQComponentControl} implementation used by this handler.
*
* @param activeMQServer the ActiveMQ server installed in the runtime
* @param address the address being invoked
* @return the runtime ActiveMQ control object associated with the given address
*/
protected abstract T getActiveMQComponentControl(ActiveMQServer activeMQServer, PathAddress address);
protected abstract String getDescriptionPrefix();
/**
* Hook to allow subclasses to handle read-attribute requests for attributes other than {@link CommonAttributes#STARTED}.
* Implementations must not call any of the
* {@link OperationContext#completeStep(OperationContext.ResultHandler) context.completeStep variants}.
* <p>
* This default implementation just throws the exception returned by {@link #unsupportedAttribute(String)}.
* </p>
*
*
* @param attributeName the name of the attribute
* @param context the operation context
* @param operation
* @throws OperationFailedException
*/
protected void handleReadAttribute(String attributeName, OperationContext context, ModelNode operation) throws OperationFailedException {
unsupportedAttribute(attributeName);
}
/**
* Hook to allow subclasses to handle operations other than {@code read-attribute}, {@code start} and
* {@code stop}. Implementations must not call any of the
* {@link OperationContext#completeStep(OperationContext.ResultHandler) context.completeStep variants}.
* <p>
* This default implementation just throws the exception returned by {@link #unsupportedOperation(String)}.
* </p>
*
*
* @param operationName the name of the operation
* @param context the operation context
* @param operation the operation
*
* @return an object that can be passed back in {@link #handleRevertOperation(String, OperationContext, ModelNode, Object)}
* if the operation should be reverted. A value of {@code null} is an indication that no reversible
* modification was made
* @throws OperationFailedException
*/
protected Object handleOperation(String operationName, OperationContext context, ModelNode operation) throws OperationFailedException {
unsupportedOperation(operationName);
throw MessagingLogger.ROOT_LOGGER.unsupportedOperation(operationName);
}
/**
* Hook to allow subclasses to handle revert changes made in
* {@link #handleOperation(String, OperationContext, ModelNode)}.
* <p>
* This default implementation does nothing.
* </p>
*
*
* @param operationName the name of the operation
* @param context the operation context
* @param operation the operation
*/
protected void handleRevertOperation(String operationName, OperationContext context, ModelNode operation, Object handback) {
}
/**
* Return an ISE with a message saying support for the attribute was not properly implemented. This handler should
* only be called if for a "read-attribute" operation if {@link #registerOperations(ManagementResourceRegistration, ResourceDescriptionResolver)}
* registers the attribute, so a handler then not recognizing the attribute name would be a bug and this method
* returns an exception highlighting that bug.
*
* @param attributeName the name of the attribute
* @throws IllegalStateException an exception with a message indicating a bug in this handler
*/
protected final void unsupportedAttribute(final String attributeName) {
// Bug
throw MessagingLogger.ROOT_LOGGER.unsupportedAttribute(attributeName);
}
/**
* Return an ISE with a message saying support for the operation was not properly implemented. This handler should
* only be called if for a n operation if {@link #registerOperations(ManagementResourceRegistration, ResourceDescriptionResolver)}
* registers it as a handler, so a handler then not recognizing the operation name would be a bug and this method
* returns an exception highlighting that bug.
*
* @param operationName the name of the attribute
* @throws IllegalStateException an exception with a message indicating a bug in this handler
*/
protected final void unsupportedOperation(final String operationName) {
// Bug
throw MessagingLogger.ROOT_LOGGER.unsupportedOperation(operationName);
}
/**
* Gets the runtime ActiveMQ control object that can help service this request.
*
* @param context the operation context
* @param operation the operation
* @param forWrite {@code true} if this operation will modify the runtime; {@code false} if not.
* @return the control object
* @throws OperationFailedException
*/
protected final T getActiveMQComponentControl(final OperationContext context, final ModelNode operation, final boolean forWrite) throws OperationFailedException {
final ServiceName artemisServiceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
ServiceController<?> artemisService = context.getServiceRegistry(forWrite).getService(artemisServiceName);
ActiveMQServer server = ActiveMQServer.class.cast(artemisService.getValue());
PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
return getActiveMQComponentControl(server, address);
}
}
| 13,612
| 46.764912
| 166
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/SocketBroadcastGroupAdd.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SOCKET_BINDING;
import static org.jboss.as.server.services.net.SocketBindingResourceDefinition.SOCKET_BINDING_CAPABILITY;
import static org.wildfly.extension.messaging.activemq.BroadcastGroupDefinition.CONNECTOR_REFS;
import static org.wildfly.extension.messaging.activemq.BroadcastGroupDefinition.validateConnectors;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.apache.activemq.artemis.api.core.BroadcastEndpointFactory;
import org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration;
import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory;
import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.registry.Resource;
import org.jboss.as.network.SocketBinding;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.Property;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceRegistry;
import org.jboss.msc.service.ServiceTarget;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* Handler for adding a broadcast group using socket bindings.
* @author Emmanuel Hugonnet (c) 2019 Red Hat, Inc.
*/
public class SocketBroadcastGroupAdd extends AbstractAddStepHandler {
public static final SocketBroadcastGroupAdd INSTANCE = new SocketBroadcastGroupAdd(true);
public static final SocketBroadcastGroupAdd LEGACY_INSTANCE = new SocketBroadcastGroupAdd(false);
private final boolean needLegacyCall;
private SocketBroadcastGroupAdd(boolean needLegacyCall) {
super(SocketBroadcastGroupDefinition.ATTRIBUTES);
this.needLegacyCall= needLegacyCall;
}
@Override
protected void populateModel(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
super.populateModel(context, operation, resource);
final ModelNode connectorRefs = resource.getModel().require(CONNECTOR_REFS.getName());
if (connectorRefs.isDefined()) {
context.addStep(new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
validateConnectors(context, operation, connectorRefs);
}
}, OperationContext.Stage.MODEL);
}
}
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
if(needLegacyCall) {
PathAddress target = context.getCurrentAddress().getParent().append(CommonAttributes.BROADCAST_GROUP, context.getCurrentAddressValue());
ModelNode op = operation.clone();
op.get(OP_ADDR).set(target.toModelNode());
context.addStep(op, BroadcastGroupAdd.LEGACY_INSTANCE, OperationContext.Stage.MODEL, true);
}
super.execute(context, operation);
}
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
ServiceRegistry registry = context.getServiceRegistry(false);
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
ServiceController<?> service = registry.getService(serviceName);
if (service != null) {
context.reloadRequired();
} else {
final String name = context.getCurrentAddressValue();
final ServiceTarget target = context.getServiceTarget();
ServiceBuilder builder = target.addService(GroupBindingService.getBroadcastBaseServiceName(serviceName).append(name));
builder.setInstance(new GroupBindingService(builder.requires(SOCKET_BINDING_CAPABILITY.getCapabilityServiceName(model.get(SOCKET_BINDING).asString()))));
builder.install();
}
}
static void addBroadcastGroupConfigs(final OperationContext context, final List<BroadcastGroupConfiguration> configs, final Set<String> connectors, final ModelNode model) throws OperationFailedException {
if (model.hasDefined(CommonAttributes.SOCKET_BROADCAST_GROUP)) {
for (Property prop : model.get(CommonAttributes.SOCKET_BROADCAST_GROUP).asPropertyList()) {
configs.add(createBroadcastGroupConfiguration(context, connectors, prop.getName(), prop.getValue()));
}
}
}
static BroadcastGroupConfiguration createBroadcastGroupConfiguration(final OperationContext context, final Set<String> connectors, final String name, final ModelNode model) throws OperationFailedException {
final long broadcastPeriod = BroadcastGroupDefinition.BROADCAST_PERIOD.resolveModelAttribute(context, model).asLong();
final List<String> connectorRefs = new ArrayList<>();
if (model.hasDefined(CommonAttributes.CONNECTORS)) {
for (ModelNode ref : model.get(CommonAttributes.CONNECTORS).asList()) {
final String refName = ref.asString();
if(!connectors.contains(refName)){
throw MessagingLogger.ROOT_LOGGER.wrongConnectorRefInBroadCastGroup(name, refName, connectors);
}
connectorRefs.add(refName);
}
}
return new BroadcastGroupConfiguration()
.setName(name)
.setBroadcastPeriod(broadcastPeriod)
.setConnectorInfos(connectorRefs);
}
static BroadcastGroupConfiguration createBroadcastGroupConfiguration(final String name, final BroadcastGroupConfiguration config, final SocketBinding socketBinding) throws Exception {
final String localAddress = socketBinding.getAddress().getHostAddress();
if (socketBinding.getMulticastAddress() == null) {
throw MessagingLogger.ROOT_LOGGER.socketBindingMulticastNotSet("socket-broadcast-group", name, socketBinding.getName());
}
final String groupAddress = socketBinding.getMulticastAddress().getHostAddress();
final int localPort = socketBinding.getPort();
final int groupPort = socketBinding.getMulticastPort();
final long broadcastPeriod = config.getBroadcastPeriod();
final List<String> connectorRefs = config.getConnectorInfos();
final BroadcastEndpointFactory endpointFactory = new UDPBroadcastEndpointFactory()
.setGroupAddress(groupAddress)
.setGroupPort(groupPort)
.setLocalBindAddress(localAddress)
.setLocalBindPort(localPort);
return new BroadcastGroupConfiguration()
.setName(name)
.setBroadcastPeriod(broadcastPeriod)
.setConnectorInfos(connectorRefs)
.setEndpointFactory(endpointFactory);
}
}
| 8,442
| 50.797546
| 210
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/QueueRemove.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
/**
*
*/
package org.wildfly.extension.messaging.activemq;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.jboss.as.controller.AbstractRemoveStepHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* Removes a queue.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
class QueueRemove extends AbstractRemoveStepHandler {
static final QueueRemove INSTANCE = new QueueRemove();
private QueueRemove() {
}
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) {
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(context.getCurrentAddress());
final String name = context.getCurrentAddressValue();
final ServiceName queueServiceName = MessagingServices.getQueueBaseServiceName(serviceName).append(name);
if (context.getServiceRegistry(false).getService(queueServiceName) != null) {
context.removeService(queueServiceName);
} else {
ServiceController<?> serverService = context.getServiceRegistry(false).getService(serviceName);
try {
((ActiveMQServer) serverService.getValue()).destroyQueue(new SimpleString(name), null, false);
} catch (Exception ex) {
MessagingLogger.ROOT_LOGGER.failedToDestroy("queue", name);
}
}
}
@Override
protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) {
// TODO: RE-ADD SERVICES
}
}
| 2,837
| 38.416667
| 113
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/MessagingSubsystemParser_8_0.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import static org.jboss.as.controller.PathElement.pathElement;
import static org.jboss.as.controller.PersistentResourceXMLDescription.builder;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.ACCEPTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.CONNECTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.IN_VM_ACCEPTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.IN_VM_CONNECTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.REMOTE_ACCEPTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.REMOTE_CONNECTOR;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.CONFIGURATION_MASTER_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.CONFIGURATION_SLAVE_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.REPLICATION_MASTER_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.SHARED_STORE_MASTER_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.SHARED_STORE_SLAVE_PATH;
import org.jboss.as.controller.PersistentResourceXMLDescription;
import org.jboss.as.controller.PersistentResourceXMLDescription.PersistentResourceXMLBuilder;
import org.jboss.as.controller.PersistentResourceXMLParser;
import org.wildfly.extension.messaging.activemq.ha.HAAttributes;
import org.wildfly.extension.messaging.activemq.ha.ScaleDownAttributes;
import org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes;
import org.wildfly.extension.messaging.activemq.jms.bridge.JMSBridgeDefinition;
import org.wildfly.extension.messaging.activemq.jms.legacy.LegacyConnectionFactoryDefinition;
/**
* Parser and Marshaller for messaging-activemq's {@link #NAMESPACE}.
*
* <em>All resources and attributes must be listed explicitly and not through any collections.</em>
* This ensures that if the resource definitions change in later version (e.g. a new attribute is added),
* this will have no impact on parsing this specific version of the subsystem.
*
* @author Paul Ferraro
*/
public class MessagingSubsystemParser_8_0 extends PersistentResourceXMLParser {
static final String NAMESPACE = "urn:jboss:domain:messaging-activemq:8.0";
@Override
public PersistentResourceXMLDescription getParserDescription() {
final PersistentResourceXMLBuilder discoveryGroup = builder(DiscoveryGroupDefinition.PATH)
.addAttributes(
CommonAttributes.SOCKET_BINDING,
DiscoveryGroupDefinition.JGROUPS_CHANNEL_FACTORY,
DiscoveryGroupDefinition.JGROUPS_CHANNEL,
CommonAttributes.JGROUPS_CLUSTER,
DiscoveryGroupDefinition.REFRESH_TIMEOUT,
DiscoveryGroupDefinition.INITIAL_WAIT_TIMEOUT);
final PersistentResourceXMLBuilder remoteConnector = builder(pathElement(REMOTE_CONNECTOR))
.addAttributes(
RemoteTransportDefinition.SOCKET_BINDING,
CommonAttributes.PARAMS);
final PersistentResourceXMLBuilder httpConnector = builder(MessagingExtension.HTTP_CONNECTOR_PATH)
.addAttributes(
HTTPConnectorDefinition.SOCKET_BINDING,
HTTPConnectorDefinition.ENDPOINT,
HTTPConnectorDefinition.SERVER_NAME,
CommonAttributes.PARAMS);
final PersistentResourceXMLBuilder invmConnector = builder(pathElement(IN_VM_CONNECTOR))
.addAttributes(
InVMTransportDefinition.SERVER_ID,
CommonAttributes.PARAMS);
final PersistentResourceXMLBuilder connector = builder(pathElement(CONNECTOR))
.addAttributes(
GenericTransportDefinition.SOCKET_BINDING,
CommonAttributes.FACTORY_CLASS,
CommonAttributes.PARAMS);
return builder(MessagingExtension.SUBSYSTEM_PATH, NAMESPACE)
.addAttributes(
MessagingSubsystemRootResourceDefinition.GLOBAL_CLIENT_THREAD_POOL_MAX_SIZE,
MessagingSubsystemRootResourceDefinition.GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_MAX_SIZE)
.addChild(httpConnector)
.addChild(remoteConnector)
.addChild(invmConnector)
.addChild(connector)
.addChild(discoveryGroup)
.addChild(builder(MessagingExtension.CONNECTION_FACTORY_PATH)
.addAttributes(
CommonAttributes.HA,
ConnectionFactoryAttributes.Regular.FACTORY_TYPE,
ConnectionFactoryAttributes.Common.DISCOVERY_GROUP,
ConnectionFactoryAttributes.Common.CONNECTORS,
ConnectionFactoryAttributes.Common.ENTRIES,
ConnectionFactoryAttributes.External.ENABLE_AMQ1_PREFIX,
ConnectionFactoryAttributes.Common.USE_TOPOLOGY
))
.addChild(createPooledConnectionFactory(true))
.addChild(builder(MessagingExtension.EXTERNAL_JMS_QUEUE_PATH)
.addAttributes(
ConnectionFactoryAttributes.Common.ENTRIES
))
.addChild(builder(MessagingExtension.EXTERNAL_JMS_TOPIC_PATH)
.addAttributes(
ConnectionFactoryAttributes.Common.ENTRIES
))
.addChild(builder(MessagingExtension.SERVER_PATH)
.addAttributes(// no attribute groups
ServerDefinition.PERSISTENCE_ENABLED,
ServerDefinition.PERSIST_ID_CACHE,
ServerDefinition.PERSIST_DELIVERY_COUNT_BEFORE_DELIVERY,
ServerDefinition.ID_CACHE_SIZE,
ServerDefinition.PAGE_MAX_CONCURRENT_IO,
ServerDefinition.SCHEDULED_THREAD_POOL_MAX_SIZE,
ServerDefinition.THREAD_POOL_MAX_SIZE,
ServerDefinition.WILD_CARD_ROUTING_ENABLED,
ServerDefinition.CONNECTION_TTL_OVERRIDE,
ServerDefinition.ASYNC_CONNECTION_EXECUTION_ENABLED,
// security
ServerDefinition.SECURITY_ENABLED,
ServerDefinition.SECURITY_DOMAIN,
ServerDefinition.ELYTRON_DOMAIN,
ServerDefinition.SECURITY_INVALIDATION_INTERVAL,
ServerDefinition.OVERRIDE_IN_VM_SECURITY,
// cluster
ServerDefinition.CLUSTER_USER,
ServerDefinition.CLUSTER_PASSWORD,
ServerDefinition.CREDENTIAL_REFERENCE,
// management
ServerDefinition.MANAGEMENT_ADDRESS,
ServerDefinition.MANAGEMENT_NOTIFICATION_ADDRESS,
ServerDefinition.JMX_MANAGEMENT_ENABLED,
ServerDefinition.JMX_DOMAIN,
// journal
ServerDefinition.JOURNAL_TYPE,
ServerDefinition.JOURNAL_BUFFER_TIMEOUT,
ServerDefinition.JOURNAL_BUFFER_SIZE,
ServerDefinition.JOURNAL_SYNC_TRANSACTIONAL,
ServerDefinition.JOURNAL_SYNC_NON_TRANSACTIONAL,
ServerDefinition.LOG_JOURNAL_WRITE_RATE,
ServerDefinition.JOURNAL_FILE_SIZE,
ServerDefinition.JOURNAL_MIN_FILES,
ServerDefinition.JOURNAL_POOL_FILES,
ServerDefinition.JOURNAL_FILE_OPEN_TIMEOUT,
ServerDefinition.JOURNAL_COMPACT_PERCENTAGE,
ServerDefinition.JOURNAL_COMPACT_MIN_FILES,
ServerDefinition.JOURNAL_MAX_IO,
ServerDefinition.CREATE_BINDINGS_DIR,
ServerDefinition.CREATE_JOURNAL_DIR,
ServerDefinition.JOURNAL_DATASOURCE,
ServerDefinition.JOURNAL_MESSAGES_TABLE,
ServerDefinition.JOURNAL_BINDINGS_TABLE,
ServerDefinition.JOURNAL_JMS_BINDINGS_TABLE,
ServerDefinition.JOURNAL_LARGE_MESSAGES_TABLE,
ServerDefinition.JOURNAL_PAGE_STORE_TABLE,
ServerDefinition.JOURNAL_NODE_MANAGER_STORE_TABLE,
ServerDefinition.JOURNAL_DATABASE,
ServerDefinition.JOURNAL_JDBC_LOCK_EXPIRATION,
ServerDefinition.JOURNAL_JDBC_LOCK_RENEW_PERIOD,
ServerDefinition.JOURNAL_JDBC_NETWORK_TIMEOUT,
ServerDefinition.GLOBAL_MAX_DISK_USAGE,
ServerDefinition.DISK_SCAN_PERIOD,
ServerDefinition.GLOBAL_MAX_MEMORY_SIZE,
// statistics
ServerDefinition.STATISTICS_ENABLED,
ServerDefinition.MESSAGE_COUNTER_SAMPLE_PERIOD,
ServerDefinition.MESSAGE_COUNTER_MAX_DAY_HISTORY,
// transaction
ServerDefinition.TRANSACTION_TIMEOUT,
ServerDefinition.TRANSACTION_TIMEOUT_SCAN_PERIOD,
// message expiry
ServerDefinition.MESSAGE_EXPIRY_SCAN_PERIOD,
ServerDefinition.MESSAGE_EXPIRY_THREAD_PRIORITY,
// debug
ServerDefinition.PERF_BLAST_PAGES,
ServerDefinition.RUN_SYNC_SPEED_TEST,
ServerDefinition.SERVER_DUMP_INTERVAL,
ServerDefinition.MEMORY_MEASURE_INTERVAL,
ServerDefinition.MEMORY_WARNING_THRESHOLD,
CommonAttributes.INCOMING_INTERCEPTORS,
CommonAttributes.OUTGOING_INTERCEPTORS)
.addChild(
builder(MessagingExtension.LIVE_ONLY_PATH)
.addAttributes(
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS))
.addChild(builder(REPLICATION_MASTER_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.CHECK_FOR_LIVE_SERVER,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT))
.addChild(builder(MessagingExtension.REPLICATION_SLAVE_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.ALLOW_FAILBACK,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT,
HAAttributes.MAX_SAVED_REPLICATED_JOURNAL_SIZE,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS))
.addChild(builder(MessagingExtension.REPLICATION_COLOCATED_PATH)
.addAttributes(
HAAttributes.REQUEST_BACKUP,
HAAttributes.BACKUP_REQUEST_RETRIES,
HAAttributes.BACKUP_REQUEST_RETRY_INTERVAL,
HAAttributes.MAX_BACKUPS,
HAAttributes.BACKUP_PORT_OFFSET,
HAAttributes.EXCLUDED_CONNECTORS)
.addChild(builder(MessagingExtension.CONFIGURATION_MASTER_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.CHECK_FOR_LIVE_SERVER,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT))
.addChild(builder(MessagingExtension.CONFIGURATION_SLAVE_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.ALLOW_FAILBACK,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT,
HAAttributes.MAX_SAVED_REPLICATED_JOURNAL_SIZE,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS)))
.addChild(builder(SHARED_STORE_MASTER_PATH)
.addAttributes(
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN))
.addChild(builder(SHARED_STORE_SLAVE_PATH)
.addAttributes(
HAAttributes.ALLOW_FAILBACK,
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS))
.addChild(builder(MessagingExtension.SHARED_STORE_COLOCATED_PATH)
.addAttributes(
HAAttributes.REQUEST_BACKUP,
HAAttributes.BACKUP_REQUEST_RETRIES,
HAAttributes.BACKUP_REQUEST_RETRY_INTERVAL,
HAAttributes.MAX_BACKUPS,
HAAttributes.BACKUP_PORT_OFFSET)
.addChild(builder(CONFIGURATION_MASTER_PATH)
.addAttributes(
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN))
.addChild(builder(CONFIGURATION_SLAVE_PATH)
.addAttributes(
HAAttributes.ALLOW_FAILBACK,
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS)))
.addChild(
builder(MessagingExtension.BINDINGS_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.BINDINGS_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.JOURNAL_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.JOURNAL_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.LARGE_MESSAGES_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.LARGE_MESSAGES_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.PAGING_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.PAGING_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.QUEUE_PATH)
.addAttributes(QueueDefinition.ADDRESS,
CommonAttributes.DURABLE,
CommonAttributes.FILTER,
QueueDefinition.ROUTING_TYPE))
.addChild(
builder(MessagingExtension.SECURITY_SETTING_PATH)
.addChild(
builder(MessagingExtension.ROLE_PATH)
.addAttributes(
SecurityRoleDefinition.SEND,
SecurityRoleDefinition.CONSUME,
SecurityRoleDefinition.CREATE_DURABLE_QUEUE,
SecurityRoleDefinition.DELETE_DURABLE_QUEUE,
SecurityRoleDefinition.CREATE_NON_DURABLE_QUEUE,
SecurityRoleDefinition.DELETE_NON_DURABLE_QUEUE,
SecurityRoleDefinition.MANAGE)))
.addChild(
builder(MessagingExtension.ADDRESS_SETTING_PATH)
.addAttributes(
CommonAttributes.DEAD_LETTER_ADDRESS,
CommonAttributes.EXPIRY_ADDRESS,
AddressSettingDefinition.EXPIRY_DELAY,
AddressSettingDefinition.REDELIVERY_DELAY,
AddressSettingDefinition.REDELIVERY_MULTIPLIER,
AddressSettingDefinition.MAX_DELIVERY_ATTEMPTS,
AddressSettingDefinition.MAX_REDELIVERY_DELAY,
AddressSettingDefinition.MAX_SIZE_BYTES,
AddressSettingDefinition.PAGE_SIZE_BYTES,
AddressSettingDefinition.PAGE_MAX_CACHE_SIZE,
AddressSettingDefinition.ADDRESS_FULL_MESSAGE_POLICY,
AddressSettingDefinition.MESSAGE_COUNTER_HISTORY_DAY_LIMIT,
AddressSettingDefinition.LAST_VALUE_QUEUE,
AddressSettingDefinition.REDISTRIBUTION_DELAY,
AddressSettingDefinition.SEND_TO_DLA_ON_NO_ROUTE,
AddressSettingDefinition.SLOW_CONSUMER_CHECK_PERIOD,
AddressSettingDefinition.SLOW_CONSUMER_POLICY,
AddressSettingDefinition.SLOW_CONSUMER_THRESHOLD,
AddressSettingDefinition.AUTO_CREATE_JMS_QUEUES,
AddressSettingDefinition.AUTO_DELETE_JMS_QUEUES,
AddressSettingDefinition.AUTO_CREATE_QUEUES,
AddressSettingDefinition.AUTO_DELETE_QUEUES,
AddressSettingDefinition.AUTO_CREATE_ADDRESSES,
AddressSettingDefinition.AUTO_DELETE_ADDRESSES))
.addChild(httpConnector)
.addChild(remoteConnector)
.addChild(invmConnector)
.addChild(connector)
.addChild(
builder(MessagingExtension.HTTP_ACCEPTOR_PATH)
.addAttributes(
HTTPAcceptorDefinition.HTTP_LISTENER,
HTTPAcceptorDefinition.UPGRADE_LEGACY,
CommonAttributes.PARAMS))
.addChild(
builder(pathElement(REMOTE_ACCEPTOR))
.addAttributes(
RemoteTransportDefinition.SOCKET_BINDING,
CommonAttributes.PARAMS))
.addChild(
builder(pathElement(IN_VM_ACCEPTOR))
.addAttributes(
InVMTransportDefinition.SERVER_ID,
CommonAttributes.PARAMS))
.addChild(
builder(pathElement(ACCEPTOR))
.addAttributes(
GenericTransportDefinition.SOCKET_BINDING,
CommonAttributes.FACTORY_CLASS,
CommonAttributes.PARAMS))
.addChild(
builder(MessagingExtension.BROADCAST_GROUP_PATH)
.addAttributes(
CommonAttributes.SOCKET_BINDING,
BroadcastGroupDefinition.JGROUPS_CHANNEL_FACTORY,
BroadcastGroupDefinition.JGROUPS_CHANNEL,
CommonAttributes.JGROUPS_CLUSTER,
BroadcastGroupDefinition.BROADCAST_PERIOD,
BroadcastGroupDefinition.CONNECTOR_REFS))
.addChild(discoveryGroup)
.addChild(
builder(MessagingExtension.CLUSTER_CONNECTION_PATH)
.addAttributes(
ClusterConnectionDefinition.ADDRESS,
ClusterConnectionDefinition.CONNECTOR_NAME,
ClusterConnectionDefinition.CHECK_PERIOD,
ClusterConnectionDefinition.CONNECTION_TTL,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CALL_TIMEOUT,
ClusterConnectionDefinition.CALL_FAILOVER_TIMEOUT,
ClusterConnectionDefinition.RETRY_INTERVAL,
ClusterConnectionDefinition.RETRY_INTERVAL_MULTIPLIER,
ClusterConnectionDefinition.MAX_RETRY_INTERVAL,
ClusterConnectionDefinition.INITIAL_CONNECT_ATTEMPTS,
ClusterConnectionDefinition.RECONNECT_ATTEMPTS,
ClusterConnectionDefinition.USE_DUPLICATE_DETECTION,
ClusterConnectionDefinition.MESSAGE_LOAD_BALANCING_TYPE,
ClusterConnectionDefinition.MAX_HOPS,
CommonAttributes.BRIDGE_CONFIRMATION_WINDOW_SIZE,
ClusterConnectionDefinition.PRODUCER_WINDOW_SIZE,
ClusterConnectionDefinition.NOTIFICATION_ATTEMPTS,
ClusterConnectionDefinition.NOTIFICATION_INTERVAL,
ClusterConnectionDefinition.CONNECTOR_REFS,
ClusterConnectionDefinition.ALLOW_DIRECT_CONNECTIONS_ONLY,
ClusterConnectionDefinition.DISCOVERY_GROUP_NAME))
.addChild(
builder(MessagingExtension.GROUPING_HANDLER_PATH)
.addAttributes(
GroupingHandlerDefinition.TYPE,
GroupingHandlerDefinition.GROUPING_HANDLER_ADDRESS,
GroupingHandlerDefinition.TIMEOUT,
GroupingHandlerDefinition.GROUP_TIMEOUT,
GroupingHandlerDefinition.REAPER_PERIOD))
.addChild(
builder(DivertDefinition.PATH)
.addAttributes(
DivertDefinition.ROUTING_NAME,
DivertDefinition.ADDRESS,
DivertDefinition.FORWARDING_ADDRESS,
CommonAttributes.FILTER,
CommonAttributes.TRANSFORMER_CLASS_NAME,
DivertDefinition.EXCLUSIVE))
.addChild(
builder(MessagingExtension.BRIDGE_PATH)
.addAttributes(
BridgeDefinition.QUEUE_NAME,
BridgeDefinition.FORWARDING_ADDRESS,
CommonAttributes.HA,
CommonAttributes.FILTER,
CommonAttributes.TRANSFORMER_CLASS_NAME,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CHECK_PERIOD,
CommonAttributes.CONNECTION_TTL,
CommonAttributes.RETRY_INTERVAL,
CommonAttributes.RETRY_INTERVAL_MULTIPLIER,
CommonAttributes.MAX_RETRY_INTERVAL,
BridgeDefinition.INITIAL_CONNECT_ATTEMPTS,
BridgeDefinition.RECONNECT_ATTEMPTS,
BridgeDefinition.RECONNECT_ATTEMPTS_ON_SAME_NODE,
BridgeDefinition.USE_DUPLICATE_DETECTION,
CommonAttributes.BRIDGE_CONFIRMATION_WINDOW_SIZE,
BridgeDefinition.PRODUCER_WINDOW_SIZE,
BridgeDefinition.USER,
BridgeDefinition.PASSWORD,
BridgeDefinition.CREDENTIAL_REFERENCE,
BridgeDefinition.CONNECTOR_REFS,
BridgeDefinition.DISCOVERY_GROUP_NAME))
.addChild(
builder(MessagingExtension.CONNECTOR_SERVICE_PATH)
.addAttributes(
CommonAttributes.FACTORY_CLASS,
CommonAttributes.PARAMS))
.addChild(
builder(MessagingExtension.JMS_QUEUE_PATH)
.addAttributes(
CommonAttributes.DESTINATION_ENTRIES,
CommonAttributes.SELECTOR,
CommonAttributes.DURABLE,
CommonAttributes.LEGACY_ENTRIES))
.addChild(
builder(MessagingExtension.JMS_TOPIC_PATH)
.addAttributes(
CommonAttributes.DESTINATION_ENTRIES,
CommonAttributes.LEGACY_ENTRIES))
.addChild(
builder(MessagingExtension.CONNECTION_FACTORY_PATH)
.addAttributes(
ConnectionFactoryAttributes.Common.ENTRIES,
// common
ConnectionFactoryAttributes.Common.DISCOVERY_GROUP,
ConnectionFactoryAttributes.Common.CONNECTORS,
CommonAttributes.HA,
ConnectionFactoryAttributes.Common.CLIENT_FAILURE_CHECK_PERIOD,
ConnectionFactoryAttributes.Common.CONNECTION_TTL,
CommonAttributes.CALL_TIMEOUT,
CommonAttributes.CALL_FAILOVER_TIMEOUT,
ConnectionFactoryAttributes.Common.CONSUMER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.CONSUMER_MAX_RATE,
ConnectionFactoryAttributes.Common.CONFIRMATION_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_MAX_RATE,
ConnectionFactoryAttributes.Common.PROTOCOL_MANAGER_FACTORY,
ConnectionFactoryAttributes.Common.COMPRESS_LARGE_MESSAGES,
ConnectionFactoryAttributes.Common.CACHE_LARGE_MESSAGE_CLIENT,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CLIENT_ID,
ConnectionFactoryAttributes.Common.DUPS_OK_BATCH_SIZE,
ConnectionFactoryAttributes.Common.TRANSACTION_BATCH_SIZE,
ConnectionFactoryAttributes.Common.BLOCK_ON_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.BLOCK_ON_NON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.BLOCK_ON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.AUTO_GROUP,
ConnectionFactoryAttributes.Common.PRE_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL_MULTIPLIER,
CommonAttributes.MAX_RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RECONNECT_ATTEMPTS,
ConnectionFactoryAttributes.Common.FAILOVER_ON_INITIAL_CONNECTION,
ConnectionFactoryAttributes.Common.CONNECTION_LOAD_BALANCING_CLASS_NAME,
ConnectionFactoryAttributes.Common.USE_GLOBAL_POOLS,
ConnectionFactoryAttributes.Common.SCHEDULED_THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.GROUP_ID,
ConnectionFactoryAttributes.Common.DESERIALIZATION_BLACKLIST,
ConnectionFactoryAttributes.Common.DESERIALIZATION_WHITELIST,
ConnectionFactoryAttributes.Common.INITIAL_MESSAGE_PACKET_SIZE,
ConnectionFactoryAttributes.Regular.FACTORY_TYPE,
ConnectionFactoryAttributes.Common.USE_TOPOLOGY))
.addChild(
builder(MessagingExtension.LEGACY_CONNECTION_FACTORY_PATH)
.addAttributes(
LegacyConnectionFactoryDefinition.ENTRIES,
LegacyConnectionFactoryDefinition.DISCOVERY_GROUP,
LegacyConnectionFactoryDefinition.CONNECTORS,
LegacyConnectionFactoryDefinition.AUTO_GROUP,
LegacyConnectionFactoryDefinition.BLOCK_ON_ACKNOWLEDGE,
LegacyConnectionFactoryDefinition.BLOCK_ON_DURABLE_SEND,
LegacyConnectionFactoryDefinition.BLOCK_ON_NON_DURABLE_SEND,
CommonAttributes.CALL_TIMEOUT,
CommonAttributes.CALL_FAILOVER_TIMEOUT,
LegacyConnectionFactoryDefinition.CACHE_LARGE_MESSAGE_CLIENT,
LegacyConnectionFactoryDefinition.CLIENT_FAILURE_CHECK_PERIOD,
CommonAttributes.CLIENT_ID,
LegacyConnectionFactoryDefinition.COMPRESS_LARGE_MESSAGES,
LegacyConnectionFactoryDefinition.CONFIRMATION_WINDOW_SIZE,
LegacyConnectionFactoryDefinition.CONNECTION_LOAD_BALANCING_CLASS_NAME,
LegacyConnectionFactoryDefinition.CONNECTION_TTL,
LegacyConnectionFactoryDefinition.CONSUMER_MAX_RATE,
LegacyConnectionFactoryDefinition.CONSUMER_WINDOW_SIZE,
LegacyConnectionFactoryDefinition.DUPS_OK_BATCH_SIZE,
LegacyConnectionFactoryDefinition.FACTORY_TYPE,
LegacyConnectionFactoryDefinition.FAILOVER_ON_INITIAL_CONNECTION,
LegacyConnectionFactoryDefinition.GROUP_ID,
LegacyConnectionFactoryDefinition.INITIAL_CONNECT_ATTEMPTS,
LegacyConnectionFactoryDefinition.INITIAL_MESSAGE_PACKET_SIZE,
LegacyConnectionFactoryDefinition.HA,
LegacyConnectionFactoryDefinition.MAX_RETRY_INTERVAL,
LegacyConnectionFactoryDefinition.MIN_LARGE_MESSAGE_SIZE,
LegacyConnectionFactoryDefinition.PRE_ACKNOWLEDGE,
LegacyConnectionFactoryDefinition.PRODUCER_MAX_RATE,
LegacyConnectionFactoryDefinition.PRODUCER_WINDOW_SIZE,
LegacyConnectionFactoryDefinition.RECONNECT_ATTEMPTS,
LegacyConnectionFactoryDefinition.RETRY_INTERVAL,
LegacyConnectionFactoryDefinition.RETRY_INTERVAL_MULTIPLIER,
LegacyConnectionFactoryDefinition.SCHEDULED_THREAD_POOL_MAX_SIZE,
LegacyConnectionFactoryDefinition.THREAD_POOL_MAX_SIZE,
LegacyConnectionFactoryDefinition.TRANSACTION_BATCH_SIZE,
LegacyConnectionFactoryDefinition.USE_GLOBAL_POOLS))
.addChild(createPooledConnectionFactory(false)))
.addChild(
builder(MessagingExtension.JMS_BRIDGE_PATH)
.addAttributes(
JMSBridgeDefinition.MODULE,
JMSBridgeDefinition.QUALITY_OF_SERVICE,
JMSBridgeDefinition.FAILURE_RETRY_INTERVAL,
JMSBridgeDefinition.MAX_RETRIES,
JMSBridgeDefinition.MAX_BATCH_SIZE,
JMSBridgeDefinition.MAX_BATCH_TIME,
CommonAttributes.SELECTOR,
JMSBridgeDefinition.SUBSCRIPTION_NAME,
CommonAttributes.CLIENT_ID,
JMSBridgeDefinition.ADD_MESSAGE_ID_IN_HEADER,
JMSBridgeDefinition.SOURCE_CONNECTION_FACTORY,
JMSBridgeDefinition.SOURCE_DESTINATION,
JMSBridgeDefinition.SOURCE_USER,
JMSBridgeDefinition.SOURCE_PASSWORD,
JMSBridgeDefinition.SOURCE_CREDENTIAL_REFERENCE,
JMSBridgeDefinition.TARGET_CONNECTION_FACTORY,
JMSBridgeDefinition.TARGET_DESTINATION,
JMSBridgeDefinition.TARGET_USER,
JMSBridgeDefinition.TARGET_PASSWORD,
JMSBridgeDefinition.TARGET_CREDENTIAL_REFERENCE,
JMSBridgeDefinition.SOURCE_CONTEXT,
JMSBridgeDefinition.TARGET_CONTEXT))
.build();
}
private PersistentResourceXMLBuilder createPooledConnectionFactory(boolean external) {
PersistentResourceXMLBuilder builder = builder(MessagingExtension.POOLED_CONNECTION_FACTORY_PATH)
.addAttributes(
ConnectionFactoryAttributes.Common.ENTRIES,
// common
ConnectionFactoryAttributes.Common.DISCOVERY_GROUP,
ConnectionFactoryAttributes.Common.CONNECTORS,
CommonAttributes.HA,
ConnectionFactoryAttributes.Common.CLIENT_FAILURE_CHECK_PERIOD,
ConnectionFactoryAttributes.Common.CONNECTION_TTL,
CommonAttributes.CALL_TIMEOUT,
CommonAttributes.CALL_FAILOVER_TIMEOUT,
ConnectionFactoryAttributes.Common.CONSUMER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.CONSUMER_MAX_RATE,
ConnectionFactoryAttributes.Common.CONFIRMATION_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_MAX_RATE,
ConnectionFactoryAttributes.Common.PROTOCOL_MANAGER_FACTORY,
ConnectionFactoryAttributes.Common.COMPRESS_LARGE_MESSAGES,
ConnectionFactoryAttributes.Common.CACHE_LARGE_MESSAGE_CLIENT,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CLIENT_ID,
ConnectionFactoryAttributes.Common.DUPS_OK_BATCH_SIZE,
ConnectionFactoryAttributes.Common.TRANSACTION_BATCH_SIZE,
ConnectionFactoryAttributes.Common.BLOCK_ON_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.BLOCK_ON_NON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.BLOCK_ON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.AUTO_GROUP,
ConnectionFactoryAttributes.Common.PRE_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL_MULTIPLIER,
CommonAttributes.MAX_RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RECONNECT_ATTEMPTS,
ConnectionFactoryAttributes.Common.FAILOVER_ON_INITIAL_CONNECTION,
ConnectionFactoryAttributes.Common.CONNECTION_LOAD_BALANCING_CLASS_NAME,
ConnectionFactoryAttributes.Common.USE_GLOBAL_POOLS,
ConnectionFactoryAttributes.Common.SCHEDULED_THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.GROUP_ID,
ConnectionFactoryAttributes.Common.DESERIALIZATION_BLACKLIST,
ConnectionFactoryAttributes.Common.DESERIALIZATION_WHITELIST,
ConnectionFactoryAttributes.Common.USE_TOPOLOGY,
// pooled
// inbound config
ConnectionFactoryAttributes.Pooled.USE_JNDI,
ConnectionFactoryAttributes.Pooled.JNDI_PARAMS,
ConnectionFactoryAttributes.Pooled.REBALANCE_CONNECTIONS,
ConnectionFactoryAttributes.Pooled.USE_LOCAL_TX,
ConnectionFactoryAttributes.Pooled.SETUP_ATTEMPTS,
ConnectionFactoryAttributes.Pooled.SETUP_INTERVAL,
// outbound config
ConnectionFactoryAttributes.Pooled.ALLOW_LOCAL_TRANSACTIONS,
ConnectionFactoryAttributes.Pooled.TRANSACTION,
ConnectionFactoryAttributes.Pooled.USER,
ConnectionFactoryAttributes.Pooled.PASSWORD,
ConnectionFactoryAttributes.Pooled.CREDENTIAL_REFERENCE,
ConnectionFactoryAttributes.Pooled.MIN_POOL_SIZE,
ConnectionFactoryAttributes.Pooled.USE_AUTO_RECOVERY,
ConnectionFactoryAttributes.Pooled.MAX_POOL_SIZE,
ConnectionFactoryAttributes.Pooled.MANAGED_CONNECTION_POOL,
ConnectionFactoryAttributes.Pooled.ENLISTMENT_TRACE,
ConnectionFactoryAttributes.Common.INITIAL_MESSAGE_PACKET_SIZE,
ConnectionFactoryAttributes.Pooled.INITIAL_CONNECT_ATTEMPTS,
ConnectionFactoryAttributes.Pooled.STATISTICS_ENABLED);
if (external) {
builder.addAttributes(ConnectionFactoryAttributes.External.ENABLE_AMQ1_PREFIX);
}
return builder;
}
}
| 52,620
| 79.460245
| 128
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/MessagingSubsystemParser_9_0.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import static org.jboss.as.controller.PathElement.pathElement;
import static org.jboss.as.controller.PersistentResourceXMLDescription.builder;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.ACCEPTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.CONNECTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.IN_VM_ACCEPTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.IN_VM_CONNECTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.REMOTE_ACCEPTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.REMOTE_CONNECTOR;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.CONFIGURATION_MASTER_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.CONFIGURATION_SLAVE_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.REPLICATION_MASTER_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.SHARED_STORE_MASTER_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.SHARED_STORE_SLAVE_PATH;
import org.jboss.as.controller.PersistentResourceXMLDescription;
import org.jboss.as.controller.PersistentResourceXMLDescription.PersistentResourceXMLBuilder;
import org.jboss.as.controller.PersistentResourceXMLParser;
import org.wildfly.extension.messaging.activemq.ha.HAAttributes;
import org.wildfly.extension.messaging.activemq.ha.ScaleDownAttributes;
import org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes;
import org.wildfly.extension.messaging.activemq.jms.bridge.JMSBridgeDefinition;
import org.wildfly.extension.messaging.activemq.jms.legacy.LegacyConnectionFactoryDefinition;
/**
* Parser and Marshaller for messaging-activemq's {@link #NAMESPACE}.
*
* <em>All resources and attributes must be listed explicitly and not through any collections.</em>
* This ensures that if the resource definitions change in later version (e.g. a new attribute is added),
* this will have no impact on parsing this specific version of the subsystem.
*
* @author Paul Ferraro
*/
public class MessagingSubsystemParser_9_0 extends PersistentResourceXMLParser {
static final String NAMESPACE = "urn:jboss:domain:messaging-activemq:9.0";
@Override
public PersistentResourceXMLDescription getParserDescription() {
final PersistentResourceXMLBuilder jgroupDiscoveryGroup = builder(JGroupsDiscoveryGroupDefinition.PATH)
.addAttributes(
DiscoveryGroupDefinition.JGROUPS_CHANNEL_FACTORY,
DiscoveryGroupDefinition.JGROUPS_CHANNEL,
CommonAttributes.JGROUPS_CLUSTER,
DiscoveryGroupDefinition.REFRESH_TIMEOUT,
DiscoveryGroupDefinition.INITIAL_WAIT_TIMEOUT);
final PersistentResourceXMLBuilder socketDiscoveryGroup = builder(SocketDiscoveryGroupDefinition.PATH)
.addAttributes(
CommonAttributes.SOCKET_BINDING,
DiscoveryGroupDefinition.REFRESH_TIMEOUT,
DiscoveryGroupDefinition.INITIAL_WAIT_TIMEOUT);
final PersistentResourceXMLBuilder remoteConnector = builder(pathElement(REMOTE_CONNECTOR))
.addAttributes(
RemoteTransportDefinition.SOCKET_BINDING,
CommonAttributes.PARAMS);
final PersistentResourceXMLBuilder httpConnector = builder(MessagingExtension.HTTP_CONNECTOR_PATH)
.addAttributes(
HTTPConnectorDefinition.SOCKET_BINDING,
HTTPConnectorDefinition.ENDPOINT,
HTTPConnectorDefinition.SERVER_NAME,
CommonAttributes.PARAMS);
final PersistentResourceXMLBuilder invmConnector = builder(pathElement(IN_VM_CONNECTOR))
.addAttributes(
InVMTransportDefinition.SERVER_ID,
CommonAttributes.PARAMS);
final PersistentResourceXMLBuilder connector = builder(pathElement(CONNECTOR))
.addAttributes(
GenericTransportDefinition.SOCKET_BINDING,
CommonAttributes.FACTORY_CLASS,
CommonAttributes.PARAMS);
return builder(MessagingExtension.SUBSYSTEM_PATH, NAMESPACE)
.addAttributes(
MessagingSubsystemRootResourceDefinition.GLOBAL_CLIENT_THREAD_POOL_MAX_SIZE,
MessagingSubsystemRootResourceDefinition.GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_MAX_SIZE)
.addChild(httpConnector)
.addChild(remoteConnector)
.addChild(invmConnector)
.addChild(connector)
.addChild(jgroupDiscoveryGroup)
.addChild(socketDiscoveryGroup)
.addChild(builder(MessagingExtension.CONNECTION_FACTORY_PATH)
.addAttributes(
CommonAttributes.HA,
ConnectionFactoryAttributes.Regular.FACTORY_TYPE,
ConnectionFactoryAttributes.Common.DISCOVERY_GROUP,
ConnectionFactoryAttributes.Common.CONNECTORS,
ConnectionFactoryAttributes.Common.ENTRIES,
ConnectionFactoryAttributes.External.ENABLE_AMQ1_PREFIX,
ConnectionFactoryAttributes.Common.USE_TOPOLOGY
))
.addChild(createPooledConnectionFactory(true))
.addChild(builder(MessagingExtension.EXTERNAL_JMS_QUEUE_PATH)
.addAttributes(
ConnectionFactoryAttributes.Common.ENTRIES
))
.addChild(builder(MessagingExtension.EXTERNAL_JMS_TOPIC_PATH)
.addAttributes(
ConnectionFactoryAttributes.Common.ENTRIES
))
.addChild(builder(MessagingExtension.SERVER_PATH)
.addAttributes(// no attribute groups
ServerDefinition.PERSISTENCE_ENABLED,
ServerDefinition.PERSIST_ID_CACHE,
ServerDefinition.PERSIST_DELIVERY_COUNT_BEFORE_DELIVERY,
ServerDefinition.ID_CACHE_SIZE,
ServerDefinition.PAGE_MAX_CONCURRENT_IO,
ServerDefinition.SCHEDULED_THREAD_POOL_MAX_SIZE,
ServerDefinition.THREAD_POOL_MAX_SIZE,
ServerDefinition.WILD_CARD_ROUTING_ENABLED,
ServerDefinition.CONNECTION_TTL_OVERRIDE,
ServerDefinition.ASYNC_CONNECTION_EXECUTION_ENABLED,
// security
ServerDefinition.SECURITY_ENABLED,
ServerDefinition.SECURITY_DOMAIN,
ServerDefinition.ELYTRON_DOMAIN,
ServerDefinition.SECURITY_INVALIDATION_INTERVAL,
ServerDefinition.OVERRIDE_IN_VM_SECURITY,
// cluster
ServerDefinition.CLUSTER_USER,
ServerDefinition.CLUSTER_PASSWORD,
ServerDefinition.CREDENTIAL_REFERENCE,
// management
ServerDefinition.MANAGEMENT_ADDRESS,
ServerDefinition.MANAGEMENT_NOTIFICATION_ADDRESS,
ServerDefinition.JMX_MANAGEMENT_ENABLED,
ServerDefinition.JMX_DOMAIN,
// journal
ServerDefinition.JOURNAL_TYPE,
ServerDefinition.JOURNAL_BUFFER_TIMEOUT,
ServerDefinition.JOURNAL_BUFFER_SIZE,
ServerDefinition.JOURNAL_SYNC_TRANSACTIONAL,
ServerDefinition.JOURNAL_SYNC_NON_TRANSACTIONAL,
ServerDefinition.LOG_JOURNAL_WRITE_RATE,
ServerDefinition.JOURNAL_FILE_SIZE,
ServerDefinition.JOURNAL_MIN_FILES,
ServerDefinition.JOURNAL_POOL_FILES,
ServerDefinition.JOURNAL_FILE_OPEN_TIMEOUT,
ServerDefinition.JOURNAL_COMPACT_PERCENTAGE,
ServerDefinition.JOURNAL_COMPACT_MIN_FILES,
ServerDefinition.JOURNAL_MAX_IO,
ServerDefinition.CREATE_BINDINGS_DIR,
ServerDefinition.CREATE_JOURNAL_DIR,
ServerDefinition.JOURNAL_DATASOURCE,
ServerDefinition.JOURNAL_MESSAGES_TABLE,
ServerDefinition.JOURNAL_BINDINGS_TABLE,
ServerDefinition.JOURNAL_JMS_BINDINGS_TABLE,
ServerDefinition.JOURNAL_LARGE_MESSAGES_TABLE,
ServerDefinition.JOURNAL_PAGE_STORE_TABLE,
ServerDefinition.JOURNAL_NODE_MANAGER_STORE_TABLE,
ServerDefinition.JOURNAL_DATABASE,
ServerDefinition.JOURNAL_JDBC_LOCK_EXPIRATION,
ServerDefinition.JOURNAL_JDBC_LOCK_RENEW_PERIOD,
ServerDefinition.JOURNAL_JDBC_NETWORK_TIMEOUT,
ServerDefinition.GLOBAL_MAX_DISK_USAGE,
ServerDefinition.DISK_SCAN_PERIOD,
ServerDefinition.GLOBAL_MAX_MEMORY_SIZE,
// statistics
ServerDefinition.STATISTICS_ENABLED,
ServerDefinition.MESSAGE_COUNTER_SAMPLE_PERIOD,
ServerDefinition.MESSAGE_COUNTER_MAX_DAY_HISTORY,
// transaction
ServerDefinition.TRANSACTION_TIMEOUT,
ServerDefinition.TRANSACTION_TIMEOUT_SCAN_PERIOD,
// message expiry
ServerDefinition.MESSAGE_EXPIRY_SCAN_PERIOD,
ServerDefinition.MESSAGE_EXPIRY_THREAD_PRIORITY,
// debug
ServerDefinition.PERF_BLAST_PAGES,
ServerDefinition.RUN_SYNC_SPEED_TEST,
ServerDefinition.SERVER_DUMP_INTERVAL,
ServerDefinition.MEMORY_MEASURE_INTERVAL,
ServerDefinition.MEMORY_WARNING_THRESHOLD,
CommonAttributes.INCOMING_INTERCEPTORS,
CommonAttributes.OUTGOING_INTERCEPTORS)
.addChild(
builder(MessagingExtension.LIVE_ONLY_PATH)
.addAttributes(
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS))
.addChild(builder(REPLICATION_MASTER_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.CHECK_FOR_LIVE_SERVER,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT))
.addChild(builder(MessagingExtension.REPLICATION_SLAVE_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.ALLOW_FAILBACK,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT,
HAAttributes.MAX_SAVED_REPLICATED_JOURNAL_SIZE,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS))
.addChild(builder(MessagingExtension.REPLICATION_COLOCATED_PATH)
.addAttributes(
HAAttributes.REQUEST_BACKUP,
HAAttributes.BACKUP_REQUEST_RETRIES,
HAAttributes.BACKUP_REQUEST_RETRY_INTERVAL,
HAAttributes.MAX_BACKUPS,
HAAttributes.BACKUP_PORT_OFFSET,
HAAttributes.EXCLUDED_CONNECTORS)
.addChild(builder(MessagingExtension.CONFIGURATION_MASTER_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.CHECK_FOR_LIVE_SERVER,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT))
.addChild(builder(MessagingExtension.CONFIGURATION_SLAVE_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.ALLOW_FAILBACK,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT,
HAAttributes.MAX_SAVED_REPLICATED_JOURNAL_SIZE,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS)))
.addChild(builder(SHARED_STORE_MASTER_PATH)
.addAttributes(
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN))
.addChild(builder(SHARED_STORE_SLAVE_PATH)
.addAttributes(
HAAttributes.ALLOW_FAILBACK,
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS))
.addChild(builder(MessagingExtension.SHARED_STORE_COLOCATED_PATH)
.addAttributes(
HAAttributes.REQUEST_BACKUP,
HAAttributes.BACKUP_REQUEST_RETRIES,
HAAttributes.BACKUP_REQUEST_RETRY_INTERVAL,
HAAttributes.MAX_BACKUPS,
HAAttributes.BACKUP_PORT_OFFSET)
.addChild(builder(CONFIGURATION_MASTER_PATH)
.addAttributes(
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN))
.addChild(builder(CONFIGURATION_SLAVE_PATH)
.addAttributes(
HAAttributes.ALLOW_FAILBACK,
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS)))
.addChild(
builder(MessagingExtension.BINDINGS_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.BINDINGS_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.JOURNAL_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.JOURNAL_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.LARGE_MESSAGES_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.LARGE_MESSAGES_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.PAGING_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.PAGING_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.QUEUE_PATH)
.addAttributes(QueueDefinition.ADDRESS,
CommonAttributes.DURABLE,
CommonAttributes.FILTER,
QueueDefinition.ROUTING_TYPE))
.addChild(
builder(MessagingExtension.SECURITY_SETTING_PATH)
.addChild(
builder(MessagingExtension.ROLE_PATH)
.addAttributes(
SecurityRoleDefinition.SEND,
SecurityRoleDefinition.CONSUME,
SecurityRoleDefinition.CREATE_DURABLE_QUEUE,
SecurityRoleDefinition.DELETE_DURABLE_QUEUE,
SecurityRoleDefinition.CREATE_NON_DURABLE_QUEUE,
SecurityRoleDefinition.DELETE_NON_DURABLE_QUEUE,
SecurityRoleDefinition.MANAGE)))
.addChild(
builder(MessagingExtension.ADDRESS_SETTING_PATH)
.addAttributes(
CommonAttributes.DEAD_LETTER_ADDRESS,
CommonAttributes.EXPIRY_ADDRESS,
AddressSettingDefinition.EXPIRY_DELAY,
AddressSettingDefinition.REDELIVERY_DELAY,
AddressSettingDefinition.REDELIVERY_MULTIPLIER,
AddressSettingDefinition.MAX_DELIVERY_ATTEMPTS,
AddressSettingDefinition.MAX_REDELIVERY_DELAY,
AddressSettingDefinition.MAX_SIZE_BYTES,
AddressSettingDefinition.PAGE_SIZE_BYTES,
AddressSettingDefinition.PAGE_MAX_CACHE_SIZE,
AddressSettingDefinition.ADDRESS_FULL_MESSAGE_POLICY,
AddressSettingDefinition.MESSAGE_COUNTER_HISTORY_DAY_LIMIT,
AddressSettingDefinition.LAST_VALUE_QUEUE,
AddressSettingDefinition.REDISTRIBUTION_DELAY,
AddressSettingDefinition.SEND_TO_DLA_ON_NO_ROUTE,
AddressSettingDefinition.SLOW_CONSUMER_CHECK_PERIOD,
AddressSettingDefinition.SLOW_CONSUMER_POLICY,
AddressSettingDefinition.SLOW_CONSUMER_THRESHOLD,
AddressSettingDefinition.AUTO_CREATE_JMS_QUEUES,
AddressSettingDefinition.AUTO_DELETE_JMS_QUEUES,
AddressSettingDefinition.AUTO_CREATE_QUEUES,
AddressSettingDefinition.AUTO_DELETE_QUEUES,
AddressSettingDefinition.AUTO_CREATE_ADDRESSES,
AddressSettingDefinition.AUTO_DELETE_ADDRESSES))
.addChild(httpConnector)
.addChild(remoteConnector)
.addChild(invmConnector)
.addChild(connector)
.addChild(
builder(MessagingExtension.HTTP_ACCEPTOR_PATH)
.addAttributes(
HTTPAcceptorDefinition.HTTP_LISTENER,
HTTPAcceptorDefinition.UPGRADE_LEGACY,
CommonAttributes.PARAMS))
.addChild(
builder(pathElement(REMOTE_ACCEPTOR))
.addAttributes(
RemoteTransportDefinition.SOCKET_BINDING,
CommonAttributes.PARAMS))
.addChild(
builder(pathElement(IN_VM_ACCEPTOR))
.addAttributes(
InVMTransportDefinition.SERVER_ID,
CommonAttributes.PARAMS))
.addChild(
builder(pathElement(ACCEPTOR))
.addAttributes(
GenericTransportDefinition.SOCKET_BINDING,
CommonAttributes.FACTORY_CLASS,
CommonAttributes.PARAMS))
.addChild(
builder(MessagingExtension.JGROUPS_BROADCAST_GROUP_PATH)
.addAttributes(
BroadcastGroupDefinition.JGROUPS_CHANNEL_FACTORY,
BroadcastGroupDefinition.JGROUPS_CHANNEL,
CommonAttributes.JGROUPS_CLUSTER,
BroadcastGroupDefinition.BROADCAST_PERIOD,
BroadcastGroupDefinition.CONNECTOR_REFS))
.addChild(
builder(MessagingExtension.SOCKET_BROADCAST_GROUP_PATH)
.addAttributes(
CommonAttributes.SOCKET_BINDING,
BroadcastGroupDefinition.BROADCAST_PERIOD,
BroadcastGroupDefinition.CONNECTOR_REFS))
.addChild(jgroupDiscoveryGroup)
.addChild(socketDiscoveryGroup)
.addChild(
builder(MessagingExtension.CLUSTER_CONNECTION_PATH)
.addAttributes(
ClusterConnectionDefinition.ADDRESS,
ClusterConnectionDefinition.CONNECTOR_NAME,
ClusterConnectionDefinition.CHECK_PERIOD,
ClusterConnectionDefinition.CONNECTION_TTL,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CALL_TIMEOUT,
ClusterConnectionDefinition.CALL_FAILOVER_TIMEOUT,
ClusterConnectionDefinition.RETRY_INTERVAL,
ClusterConnectionDefinition.RETRY_INTERVAL_MULTIPLIER,
ClusterConnectionDefinition.MAX_RETRY_INTERVAL,
ClusterConnectionDefinition.INITIAL_CONNECT_ATTEMPTS,
ClusterConnectionDefinition.RECONNECT_ATTEMPTS,
ClusterConnectionDefinition.USE_DUPLICATE_DETECTION,
ClusterConnectionDefinition.MESSAGE_LOAD_BALANCING_TYPE,
ClusterConnectionDefinition.MAX_HOPS,
CommonAttributes.BRIDGE_CONFIRMATION_WINDOW_SIZE,
ClusterConnectionDefinition.PRODUCER_WINDOW_SIZE,
ClusterConnectionDefinition.NOTIFICATION_ATTEMPTS,
ClusterConnectionDefinition.NOTIFICATION_INTERVAL,
ClusterConnectionDefinition.CONNECTOR_REFS,
ClusterConnectionDefinition.ALLOW_DIRECT_CONNECTIONS_ONLY,
ClusterConnectionDefinition.DISCOVERY_GROUP_NAME))
.addChild(
builder(MessagingExtension.GROUPING_HANDLER_PATH)
.addAttributes(
GroupingHandlerDefinition.TYPE,
GroupingHandlerDefinition.GROUPING_HANDLER_ADDRESS,
GroupingHandlerDefinition.TIMEOUT,
GroupingHandlerDefinition.GROUP_TIMEOUT,
GroupingHandlerDefinition.REAPER_PERIOD))
.addChild(
builder(DivertDefinition.PATH)
.addAttributes(
DivertDefinition.ROUTING_NAME,
DivertDefinition.ADDRESS,
DivertDefinition.FORWARDING_ADDRESS,
CommonAttributes.FILTER,
CommonAttributes.TRANSFORMER_CLASS_NAME,
DivertDefinition.EXCLUSIVE))
.addChild(
builder(MessagingExtension.BRIDGE_PATH)
.addAttributes(
BridgeDefinition.QUEUE_NAME,
BridgeDefinition.FORWARDING_ADDRESS,
CommonAttributes.HA,
CommonAttributes.FILTER,
CommonAttributes.TRANSFORMER_CLASS_NAME,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CHECK_PERIOD,
CommonAttributes.CONNECTION_TTL,
CommonAttributes.RETRY_INTERVAL,
CommonAttributes.RETRY_INTERVAL_MULTIPLIER,
CommonAttributes.MAX_RETRY_INTERVAL,
BridgeDefinition.INITIAL_CONNECT_ATTEMPTS,
BridgeDefinition.RECONNECT_ATTEMPTS,
BridgeDefinition.RECONNECT_ATTEMPTS_ON_SAME_NODE,
BridgeDefinition.USE_DUPLICATE_DETECTION,
CommonAttributes.BRIDGE_CONFIRMATION_WINDOW_SIZE,
BridgeDefinition.PRODUCER_WINDOW_SIZE,
BridgeDefinition.USER,
BridgeDefinition.PASSWORD,
BridgeDefinition.CREDENTIAL_REFERENCE,
BridgeDefinition.CONNECTOR_REFS,
BridgeDefinition.DISCOVERY_GROUP_NAME))
.addChild(
builder(MessagingExtension.CONNECTOR_SERVICE_PATH)
.addAttributes(
CommonAttributes.FACTORY_CLASS,
CommonAttributes.PARAMS))
.addChild(
builder(MessagingExtension.JMS_QUEUE_PATH)
.addAttributes(
CommonAttributes.DESTINATION_ENTRIES,
CommonAttributes.SELECTOR,
CommonAttributes.DURABLE,
CommonAttributes.LEGACY_ENTRIES))
.addChild(
builder(MessagingExtension.JMS_TOPIC_PATH)
.addAttributes(
CommonAttributes.DESTINATION_ENTRIES,
CommonAttributes.LEGACY_ENTRIES))
.addChild(
builder(MessagingExtension.CONNECTION_FACTORY_PATH)
.addAttributes(
ConnectionFactoryAttributes.Common.ENTRIES,
// common
ConnectionFactoryAttributes.Common.DISCOVERY_GROUP,
ConnectionFactoryAttributes.Common.CONNECTORS,
CommonAttributes.HA,
ConnectionFactoryAttributes.Common.CLIENT_FAILURE_CHECK_PERIOD,
ConnectionFactoryAttributes.Common.CONNECTION_TTL,
CommonAttributes.CALL_TIMEOUT,
CommonAttributes.CALL_FAILOVER_TIMEOUT,
ConnectionFactoryAttributes.Common.CONSUMER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.CONSUMER_MAX_RATE,
ConnectionFactoryAttributes.Common.CONFIRMATION_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_MAX_RATE,
ConnectionFactoryAttributes.Common.PROTOCOL_MANAGER_FACTORY,
ConnectionFactoryAttributes.Common.COMPRESS_LARGE_MESSAGES,
ConnectionFactoryAttributes.Common.CACHE_LARGE_MESSAGE_CLIENT,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CLIENT_ID,
ConnectionFactoryAttributes.Common.DUPS_OK_BATCH_SIZE,
ConnectionFactoryAttributes.Common.TRANSACTION_BATCH_SIZE,
ConnectionFactoryAttributes.Common.BLOCK_ON_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.BLOCK_ON_NON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.BLOCK_ON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.AUTO_GROUP,
ConnectionFactoryAttributes.Common.PRE_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL_MULTIPLIER,
CommonAttributes.MAX_RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RECONNECT_ATTEMPTS,
ConnectionFactoryAttributes.Common.FAILOVER_ON_INITIAL_CONNECTION,
ConnectionFactoryAttributes.Common.CONNECTION_LOAD_BALANCING_CLASS_NAME,
ConnectionFactoryAttributes.Common.USE_GLOBAL_POOLS,
ConnectionFactoryAttributes.Common.SCHEDULED_THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.GROUP_ID,
ConnectionFactoryAttributes.Common.DESERIALIZATION_BLACKLIST,
ConnectionFactoryAttributes.Common.DESERIALIZATION_WHITELIST,
ConnectionFactoryAttributes.Common.INITIAL_MESSAGE_PACKET_SIZE,
ConnectionFactoryAttributes.Regular.FACTORY_TYPE,
ConnectionFactoryAttributes.Common.USE_TOPOLOGY))
.addChild(
builder(MessagingExtension.LEGACY_CONNECTION_FACTORY_PATH)
.addAttributes(
LegacyConnectionFactoryDefinition.ENTRIES,
LegacyConnectionFactoryDefinition.DISCOVERY_GROUP,
LegacyConnectionFactoryDefinition.CONNECTORS,
LegacyConnectionFactoryDefinition.AUTO_GROUP,
LegacyConnectionFactoryDefinition.BLOCK_ON_ACKNOWLEDGE,
LegacyConnectionFactoryDefinition.BLOCK_ON_DURABLE_SEND,
LegacyConnectionFactoryDefinition.BLOCK_ON_NON_DURABLE_SEND,
CommonAttributes.CALL_TIMEOUT,
CommonAttributes.CALL_FAILOVER_TIMEOUT,
LegacyConnectionFactoryDefinition.CACHE_LARGE_MESSAGE_CLIENT,
LegacyConnectionFactoryDefinition.CLIENT_FAILURE_CHECK_PERIOD,
CommonAttributes.CLIENT_ID,
LegacyConnectionFactoryDefinition.COMPRESS_LARGE_MESSAGES,
LegacyConnectionFactoryDefinition.CONFIRMATION_WINDOW_SIZE,
LegacyConnectionFactoryDefinition.CONNECTION_LOAD_BALANCING_CLASS_NAME,
LegacyConnectionFactoryDefinition.CONNECTION_TTL,
LegacyConnectionFactoryDefinition.CONSUMER_MAX_RATE,
LegacyConnectionFactoryDefinition.CONSUMER_WINDOW_SIZE,
LegacyConnectionFactoryDefinition.DUPS_OK_BATCH_SIZE,
LegacyConnectionFactoryDefinition.FACTORY_TYPE,
LegacyConnectionFactoryDefinition.FAILOVER_ON_INITIAL_CONNECTION,
LegacyConnectionFactoryDefinition.GROUP_ID,
LegacyConnectionFactoryDefinition.INITIAL_CONNECT_ATTEMPTS,
LegacyConnectionFactoryDefinition.INITIAL_MESSAGE_PACKET_SIZE,
LegacyConnectionFactoryDefinition.HA,
LegacyConnectionFactoryDefinition.MAX_RETRY_INTERVAL,
LegacyConnectionFactoryDefinition.MIN_LARGE_MESSAGE_SIZE,
LegacyConnectionFactoryDefinition.PRE_ACKNOWLEDGE,
LegacyConnectionFactoryDefinition.PRODUCER_MAX_RATE,
LegacyConnectionFactoryDefinition.PRODUCER_WINDOW_SIZE,
LegacyConnectionFactoryDefinition.RECONNECT_ATTEMPTS,
LegacyConnectionFactoryDefinition.RETRY_INTERVAL,
LegacyConnectionFactoryDefinition.RETRY_INTERVAL_MULTIPLIER,
LegacyConnectionFactoryDefinition.SCHEDULED_THREAD_POOL_MAX_SIZE,
LegacyConnectionFactoryDefinition.THREAD_POOL_MAX_SIZE,
LegacyConnectionFactoryDefinition.TRANSACTION_BATCH_SIZE,
LegacyConnectionFactoryDefinition.USE_GLOBAL_POOLS))
.addChild(createPooledConnectionFactory(false)))
.addChild(
builder(MessagingExtension.JMS_BRIDGE_PATH)
.addAttributes(
JMSBridgeDefinition.MODULE,
JMSBridgeDefinition.QUALITY_OF_SERVICE,
JMSBridgeDefinition.FAILURE_RETRY_INTERVAL,
JMSBridgeDefinition.MAX_RETRIES,
JMSBridgeDefinition.MAX_BATCH_SIZE,
JMSBridgeDefinition.MAX_BATCH_TIME,
CommonAttributes.SELECTOR,
JMSBridgeDefinition.SUBSCRIPTION_NAME,
CommonAttributes.CLIENT_ID,
JMSBridgeDefinition.ADD_MESSAGE_ID_IN_HEADER,
JMSBridgeDefinition.SOURCE_CONNECTION_FACTORY,
JMSBridgeDefinition.SOURCE_DESTINATION,
JMSBridgeDefinition.SOURCE_USER,
JMSBridgeDefinition.SOURCE_PASSWORD,
JMSBridgeDefinition.SOURCE_CREDENTIAL_REFERENCE,
JMSBridgeDefinition.TARGET_CONNECTION_FACTORY,
JMSBridgeDefinition.TARGET_DESTINATION,
JMSBridgeDefinition.TARGET_USER,
JMSBridgeDefinition.TARGET_PASSWORD,
JMSBridgeDefinition.TARGET_CREDENTIAL_REFERENCE,
JMSBridgeDefinition.SOURCE_CONTEXT,
JMSBridgeDefinition.TARGET_CONTEXT))
.build();
}
private PersistentResourceXMLBuilder createPooledConnectionFactory(boolean external) {
PersistentResourceXMLBuilder builder = builder(MessagingExtension.POOLED_CONNECTION_FACTORY_PATH)
.addAttributes(
ConnectionFactoryAttributes.Common.ENTRIES,
// common
ConnectionFactoryAttributes.Common.DISCOVERY_GROUP,
ConnectionFactoryAttributes.Common.CONNECTORS,
CommonAttributes.HA,
ConnectionFactoryAttributes.Common.CLIENT_FAILURE_CHECK_PERIOD,
ConnectionFactoryAttributes.Common.CONNECTION_TTL,
CommonAttributes.CALL_TIMEOUT,
CommonAttributes.CALL_FAILOVER_TIMEOUT,
ConnectionFactoryAttributes.Common.CONSUMER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.CONSUMER_MAX_RATE,
ConnectionFactoryAttributes.Common.CONFIRMATION_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_MAX_RATE,
ConnectionFactoryAttributes.Common.PROTOCOL_MANAGER_FACTORY,
ConnectionFactoryAttributes.Common.COMPRESS_LARGE_MESSAGES,
ConnectionFactoryAttributes.Common.CACHE_LARGE_MESSAGE_CLIENT,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CLIENT_ID,
ConnectionFactoryAttributes.Common.DUPS_OK_BATCH_SIZE,
ConnectionFactoryAttributes.Common.TRANSACTION_BATCH_SIZE,
ConnectionFactoryAttributes.Common.BLOCK_ON_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.BLOCK_ON_NON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.BLOCK_ON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.AUTO_GROUP,
ConnectionFactoryAttributes.Common.PRE_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL_MULTIPLIER,
CommonAttributes.MAX_RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RECONNECT_ATTEMPTS,
ConnectionFactoryAttributes.Common.FAILOVER_ON_INITIAL_CONNECTION,
ConnectionFactoryAttributes.Common.CONNECTION_LOAD_BALANCING_CLASS_NAME,
ConnectionFactoryAttributes.Common.USE_GLOBAL_POOLS,
ConnectionFactoryAttributes.Common.SCHEDULED_THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.GROUP_ID,
ConnectionFactoryAttributes.Common.DESERIALIZATION_BLACKLIST,
ConnectionFactoryAttributes.Common.DESERIALIZATION_WHITELIST,
ConnectionFactoryAttributes.Common.USE_TOPOLOGY,
// pooled
// inbound config
ConnectionFactoryAttributes.Pooled.USE_JNDI,
ConnectionFactoryAttributes.Pooled.JNDI_PARAMS,
ConnectionFactoryAttributes.Pooled.REBALANCE_CONNECTIONS,
ConnectionFactoryAttributes.Pooled.USE_LOCAL_TX,
ConnectionFactoryAttributes.Pooled.SETUP_ATTEMPTS,
ConnectionFactoryAttributes.Pooled.SETUP_INTERVAL,
// outbound config
ConnectionFactoryAttributes.Pooled.ALLOW_LOCAL_TRANSACTIONS,
ConnectionFactoryAttributes.Pooled.TRANSACTION,
ConnectionFactoryAttributes.Pooled.USER,
ConnectionFactoryAttributes.Pooled.PASSWORD,
ConnectionFactoryAttributes.Pooled.CREDENTIAL_REFERENCE,
ConnectionFactoryAttributes.Pooled.MIN_POOL_SIZE,
ConnectionFactoryAttributes.Pooled.USE_AUTO_RECOVERY,
ConnectionFactoryAttributes.Pooled.MAX_POOL_SIZE,
ConnectionFactoryAttributes.Pooled.MANAGED_CONNECTION_POOL,
ConnectionFactoryAttributes.Pooled.ENLISTMENT_TRACE,
ConnectionFactoryAttributes.Common.INITIAL_MESSAGE_PACKET_SIZE,
ConnectionFactoryAttributes.Pooled.INITIAL_CONNECT_ATTEMPTS,
ConnectionFactoryAttributes.Pooled.STATISTICS_ENABLED);
if (external) {
builder.addAttributes(ConnectionFactoryAttributes.External.ENABLE_AMQ1_PREFIX);
}
return builder;
}
}
| 53,447
| 79.252252
| 128
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/BridgeRemove.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import org.apache.activemq.artemis.core.config.BridgeConfiguration;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.jboss.as.controller.AbstractRemoveStepHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceRegistry;
/**
* Removes a bridge.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class BridgeRemove extends AbstractRemoveStepHandler {
public static final BridgeRemove INSTANCE = new BridgeRemove();
private BridgeRemove() {
super();
}
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final String name = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
final ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
final ServiceController<?> service = registry.getService(serviceName);
if (service != null && service.getState() == ServiceController.State.UP) {
ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
try {
server.getActiveMQServerControl().destroyBridge(name);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
// TODO should this be an OFE instead?
throw new RuntimeException(e);
}
}
}
@Override
protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
final ServiceController<?> service = registry.getService(serviceName);
if (service != null && service.getState() == ServiceController.State.UP) {
final String name = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
final BridgeConfiguration bridgeConfiguration = BridgeAdd.createBridgeConfiguration(context, name, model);
ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
BridgeAdd.createBridge(bridgeConfiguration, server);
}
}
}
| 3,974
| 45.22093
| 156
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/AcceptorControlHandler.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import org.apache.activemq.artemis.api.core.management.AcceptorControl;
import org.apache.activemq.artemis.api.core.management.ResourceNames;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.jboss.as.controller.PathAddress;
/**
* Handler for runtime operations that interact with a ActiveMQ {@link AcceptorControl}.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class AcceptorControlHandler extends AbstractActiveMQComponentControlHandler<AcceptorControl> {
public static final AcceptorControlHandler INSTANCE = new AcceptorControlHandler();
@Override
protected AcceptorControl getActiveMQComponentControl(ActiveMQServer activeMQServer, PathAddress address) {
final String resourceName = address.getLastElement().getValue();
return AcceptorControl.class.cast(activeMQServer.getManagementService().getResource(ResourceNames.ACCEPTOR + resourceName));
}
@Override
protected String getDescriptionPrefix() {
return CommonAttributes.ACCEPTOR;
}
}
| 2,117
| 41.36
| 132
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/SecurityRoleReadAttributeHandler.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.NAME;
import org.apache.activemq.artemis.api.core.management.AddressControl;
import org.apache.activemq.artemis.api.core.management.ResourceNames;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.jboss.as.controller.AbstractRuntimeOnlyHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.logging.ControllerLogger;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
*/
public class SecurityRoleReadAttributeHandler extends AbstractRuntimeOnlyHandler {
public static final SecurityRoleReadAttributeHandler INSTANCE = new SecurityRoleReadAttributeHandler();
private SecurityRoleReadAttributeHandler() {
}
@Override
protected boolean resourceMustExist(OperationContext context, ModelNode operation) {
return false;
}
@Override
public void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
final String attributeName = operation.require(ModelDescriptionConstants.NAME).asString();
PathAddress pathAddress = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
String addressName = pathAddress.getElement(pathAddress.size() - 2).getValue();
String roleName = pathAddress.getLastElement().getValue();
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
ServiceController<?> service = context.getServiceRegistry(false).getService(serviceName);
ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
AddressControl control = AddressControl.class.cast(server.getManagementService().getResource(ResourceNames.ADDRESS + addressName));
if (control == null) {
PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
throw ControllerLogger.ROOT_LOGGER.managementResourceNotFound(address);
}
try {
ModelNode roles = ManagementUtil.convertRoles(control.getRoles());
ModelNode matchedRole = findRole(roleName, roles);
if (matchedRole == null || !matchedRole.hasDefined(attributeName)) {
throw MessagingLogger.ROOT_LOGGER.unsupportedAttribute(attributeName);
}
boolean value = matchedRole.get(attributeName).asBoolean();
context.getResult().set(value);
} catch (Exception e) {
context.getFailureDescription().set(e.getLocalizedMessage());
}
}
private ModelNode findRole(String roleName, ModelNode roles) {
for (ModelNode role : roles.asList()) {
if (role.get(NAME).asString().equals(roleName)) {
return role;
}
}
return null;
}
}
| 4,389
| 44.729167
| 156
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/AbstractQueueControlHandler.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.jboss.dmr.ModelType.BOOLEAN;
import static org.jboss.dmr.ModelType.INT;
import static org.jboss.dmr.ModelType.LIST;
import static org.jboss.dmr.ModelType.LONG;
import static org.jboss.dmr.ModelType.STRING;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.FILTER;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.QUEUE;
import static org.wildfly.extension.messaging.activemq.ActiveMQActivationService.rollbackOperationIfServerNotActive;
import static org.wildfly.extension.messaging.activemq.OperationDefinitionHelper.createNonEmptyStringAttribute;
import static org.wildfly.extension.messaging.activemq.OperationDefinitionHelper.resolveFilter;
import static org.wildfly.extension.messaging.activemq.OperationDefinitionHelper.runtimeOnlyOperation;
import static org.wildfly.extension.messaging.activemq.OperationDefinitionHelper.runtimeReadOnlyOperation;
import static org.wildfly.extension.messaging.activemq.logging.MessagingLogger.ROOT_LOGGER;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.jboss.as.controller.AbstractRuntimeOnlyHandler;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.ObjectListAttributeDefinition;
import org.jboss.as.controller.ObjectTypeAttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.descriptions.ResourceDescriptionResolver;
import org.jboss.as.controller.logging.ControllerLogger;
import org.jboss.as.controller.operations.validation.IntRangeValidator;
import org.jboss.as.controller.operations.validation.ParameterValidator;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.registry.OperationEntry;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* Base class for handlers that interact with either a ActiveMQ {@link org.apache.activemq.artemis.api.core.management.QueueControl}
* or a {@link org.apache.activemq.artemis.api.jms.management.JMSQueueControl}.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2014 Red Hat Inc.
*/
public abstract class AbstractQueueControlHandler<T> extends AbstractRuntimeOnlyHandler {
private static ResourceDescriptionResolver RESOLVER = MessagingExtension.getResourceDescriptionResolver(QUEUE);
public static final String LIST_MESSAGES = "list-messages";
public static final String LIST_MESSAGES_AS_JSON = "list-messages-as-json";
public static final String COUNT_MESSAGES = "count-messages";
public static final String REMOVE_MESSAGE = "remove-message";
public static final String REMOVE_MESSAGES = "remove-messages";
public static final String EXPIRE_MESSAGES = "expire-messages";
public static final String EXPIRE_MESSAGE = "expire-message";
public static final String SEND_MESSAGE_TO_DEAD_LETTER_ADDRESS = "send-message-to-dead-letter-address";
public static final String SEND_MESSAGES_TO_DEAD_LETTER_ADDRESS = "send-messages-to-dead-letter-address";
public static final String CHANGE_MESSAGE_PRIORITY = "change-message-priority";
public static final String CHANGE_MESSAGES_PRIORITY = "change-messages-priority";
public static final String MOVE_MESSAGE = "move-message";
public static final String MOVE_MESSAGES = "move-messages";
public static final String LIST_MESSAGE_COUNTER = "list-message-counter";
public static final String LIST_MESSAGE_COUNTER_AS_JSON = "list-message-counter-as-json";
public static final String LIST_MESSAGE_COUNTER_AS_HTML = "list-message-counter-as-html";
public static final String RESET_MESSAGE_COUNTER = "reset-message-counter";
public static final String LIST_MESSAGE_COUNTER_HISTORY = "list-message-counter-history";
public static final String LIST_MESSAGE_COUNTER_HISTORY_AS_JSON = "list-message-counter-history-as-json";
public static final String LIST_MESSAGE_COUNTER_HISTORY_AS_HTML = "list-message-counter-history-as-html";
public static final String PAUSE = "pause";
public static final String RESUME = "resume";
public static final String LIST_CONSUMERS = "list-consumers";
public static final String LIST_CONSUMERS_AS_JSON = "list-consumers-as-json";
public static final String LIST_SCHEDULED_MESSAGES = "list-scheduled-messages";
public static final String LIST_SCHEDULED_MESSAGES_AS_JSON = LIST_SCHEDULED_MESSAGES + "-as-json";
public static final String LIST_DELIVERING_MESSAGES = "list-delivering-messages";
public static final String LIST_DELIVERING_MESSAGES_AS_JSON = LIST_DELIVERING_MESSAGES + "-as-json";
public static final ParameterValidator PRIORITY_VALIDATOR = new IntRangeValidator(0, 9, false, false);
private static final AttributeDefinition OTHER_QUEUE_NAME = createNonEmptyStringAttribute("other-queue-name");
private static final AttributeDefinition REJECT_DUPLICATES = SimpleAttributeDefinitionBuilder.create("reject-duplicates", BOOLEAN)
.setRequired(false)
.build();
private static final AttributeDefinition NEW_PRIORITY = SimpleAttributeDefinitionBuilder.create("new-priority", INT)
.setValidator(PRIORITY_VALIDATOR)
.build();
protected abstract AttributeDefinition getMessageIDAttributeDefinition();
protected abstract AttributeDefinition[] getReplyMessageParameterDefinitions();
public void registerOperations(final ManagementResourceRegistration registry, ResourceDescriptionResolver resolver) {
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_MESSAGES, resolver)
.setParameters(FILTER)
.setReplyType(LIST)
.setReplyParameters(getReplyMessageParameterDefinitions())
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_MESSAGES_AS_JSON, RESOLVER)
.setParameters(FILTER)
.setReplyType(STRING)
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(COUNT_MESSAGES, RESOLVER)
.setParameters(FILTER)
.setReplyType(LONG)
.build(),
this);
registry.registerOperationHandler(runtimeOnlyOperation(REMOVE_MESSAGE, RESOLVER)
.setParameters(getMessageIDAttributeDefinition())
.setReplyType(BOOLEAN)
.build(),
this);
registry.registerOperationHandler(runtimeOnlyOperation(REMOVE_MESSAGES, RESOLVER)
.setParameters(CommonAttributes.FILTER)
.setReplyType(INT)
.build(),
this);
registry.registerOperationHandler(runtimeOnlyOperation(EXPIRE_MESSAGE, RESOLVER)
.setParameters(getMessageIDAttributeDefinition())
.setReplyType(BOOLEAN)
.build(),
this);
registry.registerOperationHandler(runtimeOnlyOperation(EXPIRE_MESSAGES, RESOLVER)
.setParameters(FILTER)
.setReplyType(INT)
.build(),
this);
registry.registerOperationHandler(runtimeOnlyOperation(SEND_MESSAGE_TO_DEAD_LETTER_ADDRESS, RESOLVER)
.setParameters(getMessageIDAttributeDefinition())
.setReplyType(BOOLEAN)
.build(),
this);
registry.registerOperationHandler(runtimeOnlyOperation(SEND_MESSAGES_TO_DEAD_LETTER_ADDRESS, RESOLVER)
.setParameters(FILTER)
.setReplyType(INT)
.build(),
this);
registry.registerOperationHandler(runtimeOnlyOperation(CHANGE_MESSAGE_PRIORITY, RESOLVER)
.setParameters(getMessageIDAttributeDefinition(), NEW_PRIORITY)
.setReplyType(BOOLEAN)
.build(),
this);
registry.registerOperationHandler(runtimeOnlyOperation(CHANGE_MESSAGES_PRIORITY, RESOLVER)
.setParameters(FILTER, NEW_PRIORITY)
.setReplyType(INT)
.build(),
this);
registry.registerOperationHandler(runtimeOnlyOperation(MOVE_MESSAGE, RESOLVER)
.setParameters(getMessageIDAttributeDefinition(), OTHER_QUEUE_NAME, REJECT_DUPLICATES)
.setReplyType(INT)
.build(),
this);
registry.registerOperationHandler(runtimeOnlyOperation(MOVE_MESSAGES, RESOLVER)
.setParameters(FILTER, OTHER_QUEUE_NAME, REJECT_DUPLICATES)
.setReplyType(INT)
.build(),
this);
// TODO dmr-based LIST_MESSAGE_COUNTER
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_MESSAGE_COUNTER_AS_JSON, RESOLVER)
.setReplyType(STRING)
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_MESSAGE_COUNTER_AS_HTML, RESOLVER)
.setReplyType(STRING)
.build(),
this);
registry.registerOperationHandler(runtimeOnlyOperation(RESET_MESSAGE_COUNTER, RESOLVER)
.build(),
this);
// TODO dmr-based LIST_MESSAGE_COUNTER_HISTORY
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_MESSAGE_COUNTER_HISTORY_AS_JSON, RESOLVER)
.setReplyType(STRING)
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_MESSAGE_COUNTER_HISTORY_AS_HTML, RESOLVER)
.setReplyType(STRING)
.build(),
this);
registry.registerOperationHandler(runtimeOnlyOperation(PAUSE, RESOLVER)
.build(),
this);
registry.registerOperationHandler(runtimeOnlyOperation(RESUME, RESOLVER)
.build(),
this);
// TODO LIST_CONSUMERS
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_CONSUMERS_AS_JSON, RESOLVER)
.setReplyType(STRING)
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_DELIVERING_MESSAGES, resolver)
.setReplyType(LIST)
.setReplyParameters(getReplyMapConsumerMessageParameterDefinition())
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_DELIVERING_MESSAGES_AS_JSON, resolver)
.setReplyType(STRING)
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_SCHEDULED_MESSAGES, resolver)
.setReplyType(LIST)
.setReplyParameters(getReplyMessageParameterDefinitions())
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_SCHEDULED_MESSAGES_AS_JSON, resolver)
.setReplyType(STRING)
.build(),
this);
}
@Override
protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
if (rollbackOperationIfServerNotActive(context, operation)) {
return;
}
final String operationName = operation.require(ModelDescriptionConstants.OP).asString();
final String queueName = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
final ServiceName activeMQServiceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
boolean readOnly = context.getResourceRegistration().getOperationFlags(PathAddress.EMPTY_ADDRESS, operationName).contains(OperationEntry.Flag.READ_ONLY);
ServiceController<?> activeMQService = context.getServiceRegistry(!readOnly).getService(activeMQServiceName);
ActiveMQServer server = ActiveMQServer.class.cast(activeMQService.getValue());
final DelegatingQueueControl<T> control = getQueueControl(server, queueName);
if (control == null) {
PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
throw ControllerLogger.ROOT_LOGGER.managementResourceNotFound(address);
}
boolean reversible = false;
Object handback = null;
try {
if (LIST_MESSAGES.equals(operationName)) {
String filter = resolveFilter(context, operation);
String json = control.listMessagesAsJSON(filter);
context.getResult().set(ModelNode.fromJSONString(json));
} else if (LIST_MESSAGES_AS_JSON.equals(operationName)) {
String filter = resolveFilter(context, operation);
context.getResult().set(control.listMessagesAsJSON(filter));
} else if (LIST_DELIVERING_MESSAGES.equals(operationName)) {
String json = control.listDeliveringMessagesAsJSON();
context.getResult().set(ModelNode.fromJSONString(json));
} else if (LIST_DELIVERING_MESSAGES_AS_JSON.equals(operationName)) {
context.getResult().set(control.listDeliveringMessagesAsJSON());
} else if (LIST_SCHEDULED_MESSAGES.equals(operationName)) {
String json = control.listScheduledMessagesAsJSON();
context.getResult().set(ModelNode.fromJSONString(json));
} else if (LIST_SCHEDULED_MESSAGES_AS_JSON.equals(operationName)) {
context.getResult().set(control.listScheduledMessagesAsJSON());
} else if (COUNT_MESSAGES.equals(operationName)) {
String filter = resolveFilter(context, operation);
context.getResult().set(control.countMessages(filter));
} else if (REMOVE_MESSAGE.equals(operationName)) {
ModelNode id = getMessageIDAttributeDefinition().resolveModelAttribute(context, operation);
context.getResult().set(control.removeMessage(id));
} else if (REMOVE_MESSAGES.equals(operationName)) {
String filter = resolveFilter(context, operation);
context.getResult().set(control.removeMessages(filter));
} else if (EXPIRE_MESSAGES.equals(operationName)) {
String filter = resolveFilter(context, operation);
context.getResult().set(control.expireMessages(filter));
} else if (EXPIRE_MESSAGE.equals(operationName)) {
ModelNode id = getMessageIDAttributeDefinition().resolveModelAttribute(context, operation);
context.getResult().set(control.expireMessage(id));
} else if (SEND_MESSAGE_TO_DEAD_LETTER_ADDRESS.equals(operationName)) {
ModelNode id = getMessageIDAttributeDefinition().resolveModelAttribute(context, operation);
context.getResult().set(control.sendMessageToDeadLetterAddress(id));
} else if (SEND_MESSAGES_TO_DEAD_LETTER_ADDRESS.equals(operationName)) {
String filter = resolveFilter(context, operation);
context.getResult().set(control.sendMessagesToDeadLetterAddress(filter));
} else if (CHANGE_MESSAGE_PRIORITY.equals(operationName)) {
ModelNode id = getMessageIDAttributeDefinition().resolveModelAttribute(context, operation);
int priority = NEW_PRIORITY.resolveModelAttribute(context, operation).asInt();
context.getResult().set(control.changeMessagePriority(id, priority));
} else if (CHANGE_MESSAGES_PRIORITY.equals(operationName)) {
String filter = resolveFilter(context, operation);
int priority = NEW_PRIORITY.resolveModelAttribute(context, operation).asInt();
context.getResult().set(control.changeMessagesPriority(filter, priority));
} else if (MOVE_MESSAGE.equals(operationName)) {
ModelNode id = getMessageIDAttributeDefinition().resolveModelAttribute(context, operation);
String otherQueue = OTHER_QUEUE_NAME.resolveModelAttribute(context, operation).asString();
ModelNode rejectDuplicates = REJECT_DUPLICATES.resolveModelAttribute(context, operation);
if (rejectDuplicates.isDefined()) {
context.getResult().set(control.moveMessage(id, otherQueue, rejectDuplicates.asBoolean()));
} else {
context.getResult().set(control.moveMessage(id, otherQueue));
}
} else if (MOVE_MESSAGES.equals(operationName)) {
String filter = resolveFilter(context, operation);
String otherQueue = OTHER_QUEUE_NAME.resolveModelAttribute(context, operation).asString();
ModelNode rejectDuplicates = REJECT_DUPLICATES.resolveModelAttribute(context, operation);
if (rejectDuplicates.isDefined()) {
context.getResult().set(control.moveMessages(filter, otherQueue, rejectDuplicates.asBoolean()));
} else {
context.getResult().set(control.moveMessages(filter, otherQueue));
}
} else if (LIST_MESSAGE_COUNTER_AS_JSON.equals(operationName)) {
context.getResult().set(control.listMessageCounter());
} else if (LIST_MESSAGE_COUNTER_AS_HTML.equals(operationName)) {
context.getResult().set(control.listMessageCounterAsHTML());
} else if (LIST_MESSAGE_COUNTER_HISTORY_AS_JSON.equals(operationName)) {
context.getResult().set(control.listMessageCounterHistory());
} else if (LIST_MESSAGE_COUNTER_HISTORY_AS_HTML.equals(operationName)) {
context.getResult().set(control.listMessageCounterHistoryAsHTML());
} else if (RESET_MESSAGE_COUNTER.equals(operationName)) {
control.resetMessageCounter();
context.getResult(); // undefined
} else if (PAUSE.equals(operationName)) {
control.pause();
reversible = true;
context.getResult(); // undefined
} else if (RESUME.equals(operationName)) {
control.resume();
reversible = true;
context.getResult(); // undefined
} else if (LIST_CONSUMERS_AS_JSON.equals(operationName)) {
context.getResult().set(control.listConsumersAsJSON());
} else {
// TODO dmr-based LIST_MESSAGE_COUNTER, LIST_MESSAGE_COUNTER_HISTORY, LIST_CONSUMERS
handback = handleAdditionalOperation(operationName, operation, context, control.getDelegate());
reversible = handback == null;
}
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
context.getFailureDescription().set(e.getLocalizedMessage());
}
OperationContext.RollbackHandler rh;
if (reversible) {
final Object rhHandback = handback;
rh = new OperationContext.RollbackHandler() {
@Override
public void handleRollback(OperationContext context, ModelNode operation) {
try {
if (PAUSE.equals(operationName)) {
control.resume();
} else if (RESUME.equals(operationName)) {
control.pause();
} else {
revertAdditionalOperation(operationName, operation, context, control.getDelegate(), rhHandback);
}
} catch (Exception e) {
ROOT_LOGGER.revertOperationFailed(e, getClass().getSimpleName(),
operation.require(ModelDescriptionConstants.OP).asString(),
PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)));
}
}
};
} else {
rh = OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER;
}
context.completeStep(rh);
}
protected AttributeDefinition[] getReplyMapConsumerMessageParameterDefinition() {
return new AttributeDefinition[]{
createNonEmptyStringAttribute("consumerName"),
new ObjectListAttributeDefinition.Builder("elements",
new ObjectTypeAttributeDefinition.Builder("element", getReplyMessageParameterDefinitions()).build())
.build()
};
}
protected abstract DelegatingQueueControl<T> getQueueControl(ActiveMQServer server, String queueName);
protected abstract Object handleAdditionalOperation(final String operationName, final ModelNode operation,
final OperationContext context, T queueControl) throws OperationFailedException;
protected abstract void revertAdditionalOperation(final String operationName, final ModelNode operation,
final OperationContext context, T queueControl, Object handback);
protected final void throwUnimplementedOperationException(final String operationName) {
// Bug
throw MessagingLogger.ROOT_LOGGER.unsupportedOperation(operationName);
}
/**
* Exposes the method signatures that are common between {@link org.apache.activemq.api.core.management.QueueControl}
* and {@link org.apache.activemq.api.jms.management.JMSQueueControl}.
*/
public interface DelegatingQueueControl<T> {
T getDelegate();
String listMessagesAsJSON(String filter) throws Exception;
long countMessages(String filter) throws Exception;
boolean removeMessage(ModelNode id) throws Exception;
int removeMessages(String filter) throws Exception;
int expireMessages(String filter) throws Exception;
boolean expireMessage(ModelNode id) throws Exception;
boolean sendMessageToDeadLetterAddress(ModelNode id) throws Exception;
int sendMessagesToDeadLetterAddress(String filter) throws Exception;
boolean changeMessagePriority(ModelNode id, int priority) throws Exception;
int changeMessagesPriority(String filter, int priority) throws Exception;
boolean moveMessage(ModelNode id, String otherQueue) throws Exception;
boolean moveMessage(ModelNode id, String otherQueue, boolean rejectDuplicates) throws Exception;
int moveMessages(String filter, String otherQueue) throws Exception;
int moveMessages(String filter, String otherQueue, boolean rejectDuplicates) throws Exception;
String listMessageCounter() throws Exception;
void resetMessageCounter() throws Exception;
String listMessageCounterAsHTML() throws Exception;
String listMessageCounterHistory() throws Exception;
String listMessageCounterHistoryAsHTML() throws Exception;
void pause() throws Exception;
void resume() throws Exception;
String listConsumersAsJSON() throws Exception;
String listScheduledMessagesAsJSON() throws Exception;
String listDeliveringMessagesAsJSON() throws Exception;
}
}
| 25,115
| 52.666667
| 164
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/MessagingSubsystemParser_5_0.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import static org.jboss.as.controller.PathElement.pathElement;
import static org.jboss.as.controller.PersistentResourceXMLDescription.builder;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.ACCEPTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.CONNECTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.IN_VM_ACCEPTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.IN_VM_CONNECTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.REMOTE_ACCEPTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.REMOTE_CONNECTOR;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.CONFIGURATION_MASTER_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.CONFIGURATION_SLAVE_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.REPLICATION_MASTER_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.SHARED_STORE_MASTER_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.SHARED_STORE_SLAVE_PATH;
import org.jboss.as.controller.PersistentResourceXMLDescription;
import org.jboss.as.controller.PersistentResourceXMLDescription.PersistentResourceXMLBuilder;
import org.jboss.as.controller.PersistentResourceXMLParser;
import org.wildfly.extension.messaging.activemq.ha.HAAttributes;
import org.wildfly.extension.messaging.activemq.ha.ScaleDownAttributes;
import org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes;
import org.wildfly.extension.messaging.activemq.jms.bridge.JMSBridgeDefinition;
import org.wildfly.extension.messaging.activemq.jms.legacy.LegacyConnectionFactoryDefinition;
/**
* Parser and Marshaller for messaging-activemq's {@link #NAMESPACE}.
*
* <em>All resources and attributes must be listed explicitly and not through any collections.</em>
* This ensures that if the resource definitions change in later version (e.g. a new attribute is added),
* this will have no impact on parsing this specific version of the subsystem.
*
* @author Paul Ferraro
*/
public class MessagingSubsystemParser_5_0 extends PersistentResourceXMLParser {
static final String NAMESPACE = "urn:jboss:domain:messaging-activemq:5.0";
@Override
public PersistentResourceXMLDescription getParserDescription(){
final PersistentResourceXMLBuilder discoveryGroup = builder(DiscoveryGroupDefinition.PATH)
.addAttributes(
CommonAttributes.SOCKET_BINDING,
DiscoveryGroupDefinition.JGROUPS_CHANNEL_FACTORY,
DiscoveryGroupDefinition.JGROUPS_CHANNEL,
CommonAttributes.JGROUPS_CLUSTER,
DiscoveryGroupDefinition.REFRESH_TIMEOUT,
DiscoveryGroupDefinition.INITIAL_WAIT_TIMEOUT);
final PersistentResourceXMLBuilder remoteConnector = builder(pathElement(REMOTE_CONNECTOR))
.addAttributes(
RemoteTransportDefinition.SOCKET_BINDING,
CommonAttributes.PARAMS);
final PersistentResourceXMLBuilder httpConnector = builder(MessagingExtension.HTTP_CONNECTOR_PATH)
.addAttributes(
HTTPConnectorDefinition.SOCKET_BINDING,
HTTPConnectorDefinition.ENDPOINT,
HTTPConnectorDefinition.SERVER_NAME,
CommonAttributes.PARAMS);
final PersistentResourceXMLBuilder invmConnector = builder(pathElement(IN_VM_CONNECTOR))
.addAttributes(
InVMTransportDefinition.SERVER_ID,
CommonAttributes.PARAMS);
final PersistentResourceXMLBuilder connector = builder(pathElement(CONNECTOR))
.addAttributes(
GenericTransportDefinition.SOCKET_BINDING,
CommonAttributes.FACTORY_CLASS,
CommonAttributes.PARAMS);
final PersistentResourceXMLBuilder pooledConnectionFactory =
builder(MessagingExtension.POOLED_CONNECTION_FACTORY_PATH)
.addAttributes(
ConnectionFactoryAttributes.Common.ENTRIES,
// common
ConnectionFactoryAttributes.Common.DISCOVERY_GROUP,
ConnectionFactoryAttributes.Common.CONNECTORS,
CommonAttributes.HA,
ConnectionFactoryAttributes.Common.CLIENT_FAILURE_CHECK_PERIOD,
ConnectionFactoryAttributes.Common.CONNECTION_TTL,
CommonAttributes.CALL_TIMEOUT,
CommonAttributes.CALL_FAILOVER_TIMEOUT,
ConnectionFactoryAttributes.Common.CONSUMER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.CONSUMER_MAX_RATE,
ConnectionFactoryAttributes.Common.CONFIRMATION_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_MAX_RATE,
ConnectionFactoryAttributes.Common.PROTOCOL_MANAGER_FACTORY,
ConnectionFactoryAttributes.Common.COMPRESS_LARGE_MESSAGES,
ConnectionFactoryAttributes.Common.CACHE_LARGE_MESSAGE_CLIENT,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CLIENT_ID,
ConnectionFactoryAttributes.Common.DUPS_OK_BATCH_SIZE,
ConnectionFactoryAttributes.Common.TRANSACTION_BATCH_SIZE,
ConnectionFactoryAttributes.Common.BLOCK_ON_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.BLOCK_ON_NON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.BLOCK_ON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.AUTO_GROUP,
ConnectionFactoryAttributes.Common.PRE_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL_MULTIPLIER,
CommonAttributes.MAX_RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RECONNECT_ATTEMPTS,
ConnectionFactoryAttributes.Common.FAILOVER_ON_INITIAL_CONNECTION,
ConnectionFactoryAttributes.Common.CONNECTION_LOAD_BALANCING_CLASS_NAME,
ConnectionFactoryAttributes.Common.USE_GLOBAL_POOLS,
ConnectionFactoryAttributes.Common.SCHEDULED_THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.GROUP_ID,
ConnectionFactoryAttributes.Common.DESERIALIZATION_BLACKLIST,
ConnectionFactoryAttributes.Common.DESERIALIZATION_WHITELIST,
// pooled
// inbound config
ConnectionFactoryAttributes.Pooled.USE_JNDI,
ConnectionFactoryAttributes.Pooled.JNDI_PARAMS,
ConnectionFactoryAttributes.Pooled.REBALANCE_CONNECTIONS,
ConnectionFactoryAttributes.Pooled.USE_LOCAL_TX,
ConnectionFactoryAttributes.Pooled.SETUP_ATTEMPTS,
ConnectionFactoryAttributes.Pooled.SETUP_INTERVAL,
// outbound config
ConnectionFactoryAttributes.Pooled.ALLOW_LOCAL_TRANSACTIONS,
ConnectionFactoryAttributes.Pooled.TRANSACTION,
ConnectionFactoryAttributes.Pooled.USER,
ConnectionFactoryAttributes.Pooled.PASSWORD,
ConnectionFactoryAttributes.Pooled.CREDENTIAL_REFERENCE,
ConnectionFactoryAttributes.Pooled.MIN_POOL_SIZE,
ConnectionFactoryAttributes.Pooled.USE_AUTO_RECOVERY,
ConnectionFactoryAttributes.Pooled.MAX_POOL_SIZE,
ConnectionFactoryAttributes.Pooled.MANAGED_CONNECTION_POOL,
ConnectionFactoryAttributes.Pooled.ENLISTMENT_TRACE,
ConnectionFactoryAttributes.Common.INITIAL_MESSAGE_PACKET_SIZE,
ConnectionFactoryAttributes.Pooled.INITIAL_CONNECT_ATTEMPTS,
ConnectionFactoryAttributes.Pooled.STATISTICS_ENABLED);
return builder(MessagingExtension.SUBSYSTEM_PATH, NAMESPACE)
.addAttributes(
MessagingSubsystemRootResourceDefinition.GLOBAL_CLIENT_THREAD_POOL_MAX_SIZE,
MessagingSubsystemRootResourceDefinition.GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_MAX_SIZE)
.addChild(httpConnector)
.addChild(remoteConnector)
.addChild(invmConnector)
.addChild(connector)
.addChild(discoveryGroup)
.addChild(builder(MessagingExtension.CONNECTION_FACTORY_PATH)
.addAttributes(
CommonAttributes.HA,
ConnectionFactoryAttributes.Regular.FACTORY_TYPE,
ConnectionFactoryAttributes.Common.DISCOVERY_GROUP,
ConnectionFactoryAttributes.Common.CONNECTORS,
ConnectionFactoryAttributes.Common.ENTRIES
))
.addChild(pooledConnectionFactory)
.addChild(builder(MessagingExtension.EXTERNAL_JMS_QUEUE_PATH)
.addAttributes(
ConnectionFactoryAttributes.Common.ENTRIES
))
.addChild(builder(MessagingExtension.EXTERNAL_JMS_TOPIC_PATH)
.addAttributes(
ConnectionFactoryAttributes.Common.ENTRIES
))
.addChild(builder(MessagingExtension.SERVER_PATH)
.addAttributes(// no attribute groups
ServerDefinition.PERSISTENCE_ENABLED,
ServerDefinition.PERSIST_ID_CACHE,
ServerDefinition.PERSIST_DELIVERY_COUNT_BEFORE_DELIVERY,
ServerDefinition.ID_CACHE_SIZE,
ServerDefinition.PAGE_MAX_CONCURRENT_IO,
ServerDefinition.SCHEDULED_THREAD_POOL_MAX_SIZE,
ServerDefinition.THREAD_POOL_MAX_SIZE,
ServerDefinition.WILD_CARD_ROUTING_ENABLED,
ServerDefinition.CONNECTION_TTL_OVERRIDE,
ServerDefinition.ASYNC_CONNECTION_EXECUTION_ENABLED,
// security
ServerDefinition.SECURITY_ENABLED,
ServerDefinition.SECURITY_DOMAIN,
ServerDefinition.ELYTRON_DOMAIN,
ServerDefinition.SECURITY_INVALIDATION_INTERVAL,
ServerDefinition.OVERRIDE_IN_VM_SECURITY,
// cluster
ServerDefinition.CLUSTER_USER,
ServerDefinition.CLUSTER_PASSWORD,
ServerDefinition.CREDENTIAL_REFERENCE,
// management
ServerDefinition.MANAGEMENT_ADDRESS,
ServerDefinition.MANAGEMENT_NOTIFICATION_ADDRESS,
ServerDefinition.JMX_MANAGEMENT_ENABLED,
ServerDefinition.JMX_DOMAIN,
// journal
ServerDefinition.JOURNAL_TYPE,
ServerDefinition.JOURNAL_BUFFER_TIMEOUT,
ServerDefinition.JOURNAL_BUFFER_SIZE,
ServerDefinition.JOURNAL_SYNC_TRANSACTIONAL,
ServerDefinition.JOURNAL_SYNC_NON_TRANSACTIONAL,
ServerDefinition.LOG_JOURNAL_WRITE_RATE,
ServerDefinition.JOURNAL_FILE_SIZE,
ServerDefinition.JOURNAL_MIN_FILES,
ServerDefinition.JOURNAL_POOL_FILES,
ServerDefinition.JOURNAL_COMPACT_PERCENTAGE,
ServerDefinition.JOURNAL_COMPACT_MIN_FILES,
ServerDefinition.JOURNAL_MAX_IO,
ServerDefinition.CREATE_BINDINGS_DIR,
ServerDefinition.CREATE_JOURNAL_DIR,
ServerDefinition.JOURNAL_DATASOURCE,
ServerDefinition.JOURNAL_MESSAGES_TABLE,
ServerDefinition.JOURNAL_BINDINGS_TABLE,
ServerDefinition.JOURNAL_JMS_BINDINGS_TABLE,
ServerDefinition.JOURNAL_LARGE_MESSAGES_TABLE,
ServerDefinition.JOURNAL_PAGE_STORE_TABLE,
ServerDefinition.JOURNAL_NODE_MANAGER_STORE_TABLE,
ServerDefinition.JOURNAL_DATABASE,
ServerDefinition.JOURNAL_JDBC_LOCK_EXPIRATION,
ServerDefinition.JOURNAL_JDBC_LOCK_RENEW_PERIOD,
ServerDefinition.JOURNAL_JDBC_NETWORK_TIMEOUT,
ServerDefinition.GLOBAL_MAX_DISK_USAGE,
ServerDefinition.DISK_SCAN_PERIOD,
ServerDefinition.GLOBAL_MAX_MEMORY_SIZE,
// statistics
ServerDefinition.STATISTICS_ENABLED,
ServerDefinition.MESSAGE_COUNTER_SAMPLE_PERIOD,
ServerDefinition.MESSAGE_COUNTER_MAX_DAY_HISTORY,
// transaction
ServerDefinition.TRANSACTION_TIMEOUT,
ServerDefinition.TRANSACTION_TIMEOUT_SCAN_PERIOD,
// message expiry
ServerDefinition.MESSAGE_EXPIRY_SCAN_PERIOD,
ServerDefinition.MESSAGE_EXPIRY_THREAD_PRIORITY,
// debug
ServerDefinition.PERF_BLAST_PAGES,
ServerDefinition.RUN_SYNC_SPEED_TEST,
ServerDefinition.SERVER_DUMP_INTERVAL,
ServerDefinition.MEMORY_MEASURE_INTERVAL,
ServerDefinition.MEMORY_WARNING_THRESHOLD,
CommonAttributes.INCOMING_INTERCEPTORS,
CommonAttributes.OUTGOING_INTERCEPTORS)
.addChild(
builder(MessagingExtension.LIVE_ONLY_PATH)
.addAttributes(
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS))
.addChild(builder(REPLICATION_MASTER_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.CHECK_FOR_LIVE_SERVER,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT))
.addChild(builder(MessagingExtension.REPLICATION_SLAVE_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.ALLOW_FAILBACK,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT,
HAAttributes.MAX_SAVED_REPLICATED_JOURNAL_SIZE,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS))
.addChild(builder(MessagingExtension.REPLICATION_COLOCATED_PATH)
.addAttributes(
HAAttributes.REQUEST_BACKUP,
HAAttributes.BACKUP_REQUEST_RETRIES,
HAAttributes.BACKUP_REQUEST_RETRY_INTERVAL,
HAAttributes.MAX_BACKUPS,
HAAttributes.BACKUP_PORT_OFFSET,
HAAttributes.EXCLUDED_CONNECTORS)
.addChild(builder(MessagingExtension.CONFIGURATION_MASTER_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.CHECK_FOR_LIVE_SERVER,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT))
.addChild(builder(MessagingExtension.CONFIGURATION_SLAVE_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.ALLOW_FAILBACK,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT,
HAAttributes.MAX_SAVED_REPLICATED_JOURNAL_SIZE,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS)))
.addChild(builder(SHARED_STORE_MASTER_PATH)
.addAttributes(
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN))
.addChild(builder(SHARED_STORE_SLAVE_PATH)
.addAttributes(
HAAttributes.ALLOW_FAILBACK,
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS))
.addChild(builder(MessagingExtension.SHARED_STORE_COLOCATED_PATH)
.addAttributes(
HAAttributes.REQUEST_BACKUP,
HAAttributes.BACKUP_REQUEST_RETRIES,
HAAttributes.BACKUP_REQUEST_RETRY_INTERVAL,
HAAttributes.MAX_BACKUPS,
HAAttributes.BACKUP_PORT_OFFSET)
.addChild(builder(CONFIGURATION_MASTER_PATH)
.addAttributes(
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN))
.addChild(builder(CONFIGURATION_SLAVE_PATH)
.addAttributes(
HAAttributes.ALLOW_FAILBACK,
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS)))
.addChild(
builder(MessagingExtension.BINDINGS_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.BINDINGS_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.JOURNAL_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.JOURNAL_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.LARGE_MESSAGES_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.LARGE_MESSAGES_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.PAGING_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.PAGING_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.QUEUE_PATH)
.addAttributes(
QueueDefinition.ADDRESS,
CommonAttributes.DURABLE,
CommonAttributes.FILTER))
.addChild(
builder(MessagingExtension.SECURITY_SETTING_PATH)
.addChild(
builder(MessagingExtension.ROLE_PATH)
.addAttributes(
SecurityRoleDefinition.SEND,
SecurityRoleDefinition.CONSUME,
SecurityRoleDefinition.CREATE_DURABLE_QUEUE,
SecurityRoleDefinition.DELETE_DURABLE_QUEUE,
SecurityRoleDefinition.CREATE_NON_DURABLE_QUEUE,
SecurityRoleDefinition.DELETE_NON_DURABLE_QUEUE,
SecurityRoleDefinition.MANAGE)))
.addChild(
builder(MessagingExtension.ADDRESS_SETTING_PATH)
.addAttributes(
CommonAttributes.DEAD_LETTER_ADDRESS,
CommonAttributes.EXPIRY_ADDRESS,
AddressSettingDefinition.EXPIRY_DELAY,
AddressSettingDefinition.REDELIVERY_DELAY,
AddressSettingDefinition.REDELIVERY_MULTIPLIER,
AddressSettingDefinition.MAX_DELIVERY_ATTEMPTS,
AddressSettingDefinition.MAX_REDELIVERY_DELAY,
AddressSettingDefinition.MAX_SIZE_BYTES,
AddressSettingDefinition.PAGE_SIZE_BYTES,
AddressSettingDefinition.PAGE_MAX_CACHE_SIZE,
AddressSettingDefinition.ADDRESS_FULL_MESSAGE_POLICY,
AddressSettingDefinition.MESSAGE_COUNTER_HISTORY_DAY_LIMIT,
AddressSettingDefinition.LAST_VALUE_QUEUE,
AddressSettingDefinition.REDISTRIBUTION_DELAY,
AddressSettingDefinition.SEND_TO_DLA_ON_NO_ROUTE,
AddressSettingDefinition.SLOW_CONSUMER_CHECK_PERIOD,
AddressSettingDefinition.SLOW_CONSUMER_POLICY,
AddressSettingDefinition.SLOW_CONSUMER_THRESHOLD,
AddressSettingDefinition.AUTO_CREATE_JMS_QUEUES,
AddressSettingDefinition.AUTO_DELETE_JMS_QUEUES,
AddressSettingDefinition.AUTO_CREATE_QUEUES,
AddressSettingDefinition.AUTO_DELETE_QUEUES,
AddressSettingDefinition.AUTO_CREATE_ADDRESSES,
AddressSettingDefinition.AUTO_DELETE_ADDRESSES))
.addChild(httpConnector)
.addChild(remoteConnector)
.addChild(invmConnector)
.addChild(connector)
.addChild(
builder(MessagingExtension.HTTP_ACCEPTOR_PATH)
.addAttributes(
HTTPAcceptorDefinition.HTTP_LISTENER,
HTTPAcceptorDefinition.UPGRADE_LEGACY,
CommonAttributes.PARAMS))
.addChild(
builder(pathElement(REMOTE_ACCEPTOR))
.addAttributes(
RemoteTransportDefinition.SOCKET_BINDING,
CommonAttributes.PARAMS))
.addChild(
builder(pathElement(IN_VM_ACCEPTOR))
.addAttributes(
InVMTransportDefinition.SERVER_ID,
CommonAttributes.PARAMS))
.addChild(
builder(pathElement(ACCEPTOR))
.addAttributes(
GenericTransportDefinition.SOCKET_BINDING,
CommonAttributes.FACTORY_CLASS,
CommonAttributes.PARAMS))
.addChild(
builder(MessagingExtension.BROADCAST_GROUP_PATH)
.addAttributes(
CommonAttributes.SOCKET_BINDING,
BroadcastGroupDefinition.JGROUPS_CHANNEL_FACTORY,
BroadcastGroupDefinition.JGROUPS_CHANNEL,
CommonAttributes.JGROUPS_CLUSTER,
BroadcastGroupDefinition.BROADCAST_PERIOD,
BroadcastGroupDefinition.CONNECTOR_REFS))
.addChild(discoveryGroup)
.addChild(
builder(MessagingExtension.CLUSTER_CONNECTION_PATH)
.addAttributes(
ClusterConnectionDefinition.ADDRESS,
ClusterConnectionDefinition.CONNECTOR_NAME,
ClusterConnectionDefinition.CHECK_PERIOD,
ClusterConnectionDefinition.CONNECTION_TTL,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CALL_TIMEOUT,
ClusterConnectionDefinition.CALL_FAILOVER_TIMEOUT,
ClusterConnectionDefinition.RETRY_INTERVAL,
ClusterConnectionDefinition.RETRY_INTERVAL_MULTIPLIER,
ClusterConnectionDefinition.MAX_RETRY_INTERVAL,
ClusterConnectionDefinition.INITIAL_CONNECT_ATTEMPTS,
ClusterConnectionDefinition.RECONNECT_ATTEMPTS,
ClusterConnectionDefinition.USE_DUPLICATE_DETECTION,
ClusterConnectionDefinition.MESSAGE_LOAD_BALANCING_TYPE,
ClusterConnectionDefinition.MAX_HOPS,
CommonAttributes.BRIDGE_CONFIRMATION_WINDOW_SIZE,
ClusterConnectionDefinition.PRODUCER_WINDOW_SIZE,
ClusterConnectionDefinition.NOTIFICATION_ATTEMPTS,
ClusterConnectionDefinition.NOTIFICATION_INTERVAL,
ClusterConnectionDefinition.CONNECTOR_REFS,
ClusterConnectionDefinition.ALLOW_DIRECT_CONNECTIONS_ONLY,
ClusterConnectionDefinition.DISCOVERY_GROUP_NAME))
.addChild(
builder(MessagingExtension.GROUPING_HANDLER_PATH)
.addAttributes(
GroupingHandlerDefinition.TYPE,
GroupingHandlerDefinition.GROUPING_HANDLER_ADDRESS,
GroupingHandlerDefinition.TIMEOUT,
GroupingHandlerDefinition.GROUP_TIMEOUT,
GroupingHandlerDefinition.REAPER_PERIOD))
.addChild(
builder(DivertDefinition.PATH)
.addAttributes(
DivertDefinition.ROUTING_NAME,
DivertDefinition.ADDRESS,
DivertDefinition.FORWARDING_ADDRESS,
CommonAttributes.FILTER,
CommonAttributes.TRANSFORMER_CLASS_NAME,
DivertDefinition.EXCLUSIVE))
.addChild(
builder(MessagingExtension.BRIDGE_PATH)
.addAttributes(
BridgeDefinition.QUEUE_NAME,
BridgeDefinition.FORWARDING_ADDRESS,
CommonAttributes.HA,
CommonAttributes.FILTER,
CommonAttributes.TRANSFORMER_CLASS_NAME,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CHECK_PERIOD,
CommonAttributes.CONNECTION_TTL,
CommonAttributes.RETRY_INTERVAL,
CommonAttributes.RETRY_INTERVAL_MULTIPLIER,
CommonAttributes.MAX_RETRY_INTERVAL,
BridgeDefinition.INITIAL_CONNECT_ATTEMPTS,
BridgeDefinition.RECONNECT_ATTEMPTS,
BridgeDefinition.RECONNECT_ATTEMPTS_ON_SAME_NODE,
BridgeDefinition.USE_DUPLICATE_DETECTION,
CommonAttributes.BRIDGE_CONFIRMATION_WINDOW_SIZE,
BridgeDefinition.PRODUCER_WINDOW_SIZE,
BridgeDefinition.USER,
BridgeDefinition.PASSWORD,
BridgeDefinition.CREDENTIAL_REFERENCE,
BridgeDefinition.CONNECTOR_REFS,
BridgeDefinition.DISCOVERY_GROUP_NAME))
.addChild(
builder(MessagingExtension.CONNECTOR_SERVICE_PATH)
.addAttributes(
CommonAttributes.FACTORY_CLASS,
CommonAttributes.PARAMS))
.addChild(
builder(MessagingExtension.JMS_QUEUE_PATH)
.addAttributes(
CommonAttributes.DESTINATION_ENTRIES,
CommonAttributes.SELECTOR,
CommonAttributes.DURABLE,
CommonAttributes.LEGACY_ENTRIES))
.addChild(
builder(MessagingExtension.JMS_TOPIC_PATH)
.addAttributes(
CommonAttributes.DESTINATION_ENTRIES,
CommonAttributes.LEGACY_ENTRIES))
.addChild(
builder(MessagingExtension.CONNECTION_FACTORY_PATH)
.addAttributes(
ConnectionFactoryAttributes.Common.ENTRIES,
// common
ConnectionFactoryAttributes.Common.DISCOVERY_GROUP,
ConnectionFactoryAttributes.Common.CONNECTORS,
CommonAttributes.HA,
ConnectionFactoryAttributes.Common.CLIENT_FAILURE_CHECK_PERIOD,
ConnectionFactoryAttributes.Common.CONNECTION_TTL,
CommonAttributes.CALL_TIMEOUT,
CommonAttributes.CALL_FAILOVER_TIMEOUT,
ConnectionFactoryAttributes.Common.CONSUMER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.CONSUMER_MAX_RATE,
ConnectionFactoryAttributes.Common.CONFIRMATION_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_MAX_RATE,
ConnectionFactoryAttributes.Common.PROTOCOL_MANAGER_FACTORY,
ConnectionFactoryAttributes.Common.COMPRESS_LARGE_MESSAGES,
ConnectionFactoryAttributes.Common.CACHE_LARGE_MESSAGE_CLIENT,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CLIENT_ID,
ConnectionFactoryAttributes.Common.DUPS_OK_BATCH_SIZE,
ConnectionFactoryAttributes.Common.TRANSACTION_BATCH_SIZE,
ConnectionFactoryAttributes.Common.BLOCK_ON_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.BLOCK_ON_NON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.BLOCK_ON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.AUTO_GROUP,
ConnectionFactoryAttributes.Common.PRE_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL_MULTIPLIER,
CommonAttributes.MAX_RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RECONNECT_ATTEMPTS,
ConnectionFactoryAttributes.Common.FAILOVER_ON_INITIAL_CONNECTION,
ConnectionFactoryAttributes.Common.CONNECTION_LOAD_BALANCING_CLASS_NAME,
ConnectionFactoryAttributes.Common.USE_GLOBAL_POOLS,
ConnectionFactoryAttributes.Common.SCHEDULED_THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.GROUP_ID,
ConnectionFactoryAttributes.Common.DESERIALIZATION_BLACKLIST,
ConnectionFactoryAttributes.Common.DESERIALIZATION_WHITELIST,
ConnectionFactoryAttributes.Common.INITIAL_MESSAGE_PACKET_SIZE,
// regular
ConnectionFactoryAttributes.Regular.FACTORY_TYPE))
.addChild(
builder(MessagingExtension.LEGACY_CONNECTION_FACTORY_PATH)
.addAttributes(
LegacyConnectionFactoryDefinition.ENTRIES,
LegacyConnectionFactoryDefinition.DISCOVERY_GROUP,
LegacyConnectionFactoryDefinition.CONNECTORS,
LegacyConnectionFactoryDefinition.AUTO_GROUP,
LegacyConnectionFactoryDefinition.BLOCK_ON_ACKNOWLEDGE,
LegacyConnectionFactoryDefinition.BLOCK_ON_DURABLE_SEND,
LegacyConnectionFactoryDefinition.BLOCK_ON_NON_DURABLE_SEND,
CommonAttributes.CALL_TIMEOUT,
CommonAttributes.CALL_FAILOVER_TIMEOUT,
LegacyConnectionFactoryDefinition.CACHE_LARGE_MESSAGE_CLIENT,
LegacyConnectionFactoryDefinition.CLIENT_FAILURE_CHECK_PERIOD,
CommonAttributes.CLIENT_ID,
LegacyConnectionFactoryDefinition.COMPRESS_LARGE_MESSAGES,
LegacyConnectionFactoryDefinition.CONFIRMATION_WINDOW_SIZE,
LegacyConnectionFactoryDefinition.CONNECTION_LOAD_BALANCING_CLASS_NAME,
LegacyConnectionFactoryDefinition.CONNECTION_TTL,
LegacyConnectionFactoryDefinition.CONSUMER_MAX_RATE,
LegacyConnectionFactoryDefinition.CONSUMER_WINDOW_SIZE,
LegacyConnectionFactoryDefinition.DUPS_OK_BATCH_SIZE,
LegacyConnectionFactoryDefinition.FACTORY_TYPE,
LegacyConnectionFactoryDefinition.FAILOVER_ON_INITIAL_CONNECTION,
LegacyConnectionFactoryDefinition.GROUP_ID,
LegacyConnectionFactoryDefinition.INITIAL_CONNECT_ATTEMPTS,
LegacyConnectionFactoryDefinition.INITIAL_MESSAGE_PACKET_SIZE,
LegacyConnectionFactoryDefinition.HA,
LegacyConnectionFactoryDefinition.MAX_RETRY_INTERVAL,
LegacyConnectionFactoryDefinition.MIN_LARGE_MESSAGE_SIZE,
LegacyConnectionFactoryDefinition.PRE_ACKNOWLEDGE,
LegacyConnectionFactoryDefinition.PRODUCER_MAX_RATE,
LegacyConnectionFactoryDefinition.PRODUCER_WINDOW_SIZE,
LegacyConnectionFactoryDefinition.RECONNECT_ATTEMPTS,
LegacyConnectionFactoryDefinition.RETRY_INTERVAL,
LegacyConnectionFactoryDefinition.RETRY_INTERVAL_MULTIPLIER,
LegacyConnectionFactoryDefinition.SCHEDULED_THREAD_POOL_MAX_SIZE,
LegacyConnectionFactoryDefinition.THREAD_POOL_MAX_SIZE,
LegacyConnectionFactoryDefinition.TRANSACTION_BATCH_SIZE,
LegacyConnectionFactoryDefinition.USE_GLOBAL_POOLS))
.addChild(pooledConnectionFactory))
.addChild(
builder(MessagingExtension.JMS_BRIDGE_PATH)
.addAttributes(
JMSBridgeDefinition.MODULE,
JMSBridgeDefinition.QUALITY_OF_SERVICE,
JMSBridgeDefinition.FAILURE_RETRY_INTERVAL,
JMSBridgeDefinition.MAX_RETRIES,
JMSBridgeDefinition.MAX_BATCH_SIZE,
JMSBridgeDefinition.MAX_BATCH_TIME,
CommonAttributes.SELECTOR,
JMSBridgeDefinition.SUBSCRIPTION_NAME,
CommonAttributes.CLIENT_ID,
JMSBridgeDefinition.ADD_MESSAGE_ID_IN_HEADER,
JMSBridgeDefinition.SOURCE_CONNECTION_FACTORY,
JMSBridgeDefinition.SOURCE_DESTINATION,
JMSBridgeDefinition.SOURCE_USER,
JMSBridgeDefinition.SOURCE_PASSWORD,
JMSBridgeDefinition.SOURCE_CREDENTIAL_REFERENCE,
JMSBridgeDefinition.TARGET_CONNECTION_FACTORY,
JMSBridgeDefinition.TARGET_DESTINATION,
JMSBridgeDefinition.TARGET_USER,
JMSBridgeDefinition.TARGET_PASSWORD,
JMSBridgeDefinition.TARGET_CREDENTIAL_REFERENCE,
JMSBridgeDefinition.SOURCE_CONTEXT,
JMSBridgeDefinition.TARGET_CONTEXT))
.build();
}
}
| 53,993
| 82.452859
| 128
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/SecurityRoleAdd.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import static org.wildfly.extension.messaging.activemq.ActiveMQActivationService.getActiveMQServer;
import java.util.Set;
import org.apache.activemq.artemis.core.security.Role;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.registry.Resource;
import org.jboss.dmr.ModelNode;
/**
* {@code OperationStepHandler} for adding a new security role.
*
* @author Emanuel Muckenhuber
*/
class SecurityRoleAdd extends AbstractAddStepHandler {
static final SecurityRoleAdd INSTANCE = new SecurityRoleAdd(SecurityRoleDefinition.ATTRIBUTES);
private SecurityRoleAdd(AttributeDefinition... attributes) {
super(attributes);
}
@Override
protected boolean requiresRuntime(OperationContext context) {
return context.isDefaultRequiresRuntime() && !context.isBooting();
}
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model)
throws OperationFailedException {
if(context.isNormalServer()) {
final PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
final ActiveMQServer server = getActiveMQServer(context, operation);
final String match = address.getElement(address.size() - 2).getValue();
final String roleName = address.getLastElement().getValue();
if(server != null) {
final Role role = SecurityRoleDefinition.transform(context, roleName, model);
final Set<Role> roles = server.getSecurityRepository().getMatch(match);
roles.add(role);
server.getSecurityRepository().addMatch(match, roles);
}
}
}
@Override
protected void rollbackRuntime(OperationContext context, ModelNode operation, Resource resource) {
final PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
final ActiveMQServer server = getActiveMQServer(context, operation);
final String match = address.getElement(address.size() - 2).getValue();
final String roleName = address.getLastElement().getValue();
SecurityRoleRemove.removeRole(server, match, roleName);
}
}
| 3,695
| 42.482353
| 118
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/ClusterConnectionAdd.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceRegistry;
/**
* Handler for adding a cluster connection.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class ClusterConnectionAdd extends AbstractAddStepHandler {
public static final ClusterConnectionAdd INSTANCE = new ClusterConnectionAdd();
private ClusterConnectionAdd() {
super(ClusterConnectionDefinition.ATTRIBUTES);
}
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
ServiceRegistry registry = context.getServiceRegistry(false);
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
ServiceController<?> service = registry.getService(serviceName);
if (service != null) {
context.reloadRequired();
}
// else MessagingSubsystemAdd will add a handler that calls addBroadcastGroupConfigs
}
}
| 2,504
| 40.75
| 156
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/MessagingSubsystemParser_14_0.java
|
/*
* Copyright 2020 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.extension.messaging.activemq;
import static org.jboss.as.controller.PathElement.pathElement;
import static org.jboss.as.controller.PersistentResourceXMLDescription.builder;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.ACCEPTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.CONNECTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.IN_VM_ACCEPTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.IN_VM_CONNECTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.REMOTE_ACCEPTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.REMOTE_CONNECTOR;
import org.jboss.as.controller.PersistentResourceXMLDescription;
import org.jboss.as.controller.PersistentResourceXMLParser;
import org.jboss.as.controller.PersistentResourceXMLDescription.PersistentResourceXMLBuilder;
import org.wildfly.extension.messaging.activemq.ha.HAAttributes;
import org.wildfly.extension.messaging.activemq.ha.ScaleDownAttributes;
import org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes;
import org.wildfly.extension.messaging.activemq.jms.bridge.JMSBridgeDefinition;
import org.wildfly.extension.messaging.activemq.jms.legacy.LegacyConnectionFactoryDefinition;
/**
* @author wangc
*
*/
public class MessagingSubsystemParser_14_0 extends PersistentResourceXMLParser {
static final String NAMESPACE = "urn:jboss:domain:messaging-activemq:14.0";
@Override
public PersistentResourceXMLDescription getParserDescription() {
final PersistentResourceXMLBuilder jgroupDiscoveryGroup = builder(JGroupsDiscoveryGroupDefinition.PATH)
.addAttributes(
DiscoveryGroupDefinition.JGROUPS_CHANNEL_FACTORY,
DiscoveryGroupDefinition.JGROUPS_CHANNEL,
CommonAttributes.JGROUPS_CLUSTER,
DiscoveryGroupDefinition.REFRESH_TIMEOUT,
DiscoveryGroupDefinition.INITIAL_WAIT_TIMEOUT);
final PersistentResourceXMLBuilder socketDiscoveryGroup = builder(SocketDiscoveryGroupDefinition.PATH)
.addAttributes(
CommonAttributes.SOCKET_BINDING,
DiscoveryGroupDefinition.REFRESH_TIMEOUT,
DiscoveryGroupDefinition.INITIAL_WAIT_TIMEOUT);
final PersistentResourceXMLBuilder remoteConnector = builder(pathElement(REMOTE_CONNECTOR))
.addAttributes(
RemoteTransportDefinition.SOCKET_BINDING,
CommonAttributes.PARAMS);
final PersistentResourceXMLBuilder httpConnector = builder(MessagingExtension.HTTP_CONNECTOR_PATH)
.addAttributes(
HTTPConnectorDefinition.SOCKET_BINDING,
HTTPConnectorDefinition.ENDPOINT,
HTTPConnectorDefinition.SERVER_NAME,
CommonAttributes.PARAMS);
final PersistentResourceXMLBuilder invmConnector = builder(pathElement(IN_VM_CONNECTOR))
.addAttributes(
InVMTransportDefinition.SERVER_ID,
CommonAttributes.PARAMS);
final PersistentResourceXMLBuilder connector = builder(pathElement(CONNECTOR))
.addAttributes(
GenericTransportDefinition.SOCKET_BINDING,
CommonAttributes.FACTORY_CLASS,
CommonAttributes.PARAMS);
return builder(MessagingExtension.SUBSYSTEM_PATH, NAMESPACE)
.addAttributes(
MessagingSubsystemRootResourceDefinition.GLOBAL_CLIENT_THREAD_POOL_MAX_SIZE,
MessagingSubsystemRootResourceDefinition.GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_MAX_SIZE)
.addChild(httpConnector)
.addChild(remoteConnector)
.addChild(invmConnector)
.addChild(connector)
.addChild(jgroupDiscoveryGroup)
.addChild(socketDiscoveryGroup)
.addChild(builder(MessagingExtension.CONNECTION_FACTORY_PATH)
.addAttributes(
CommonAttributes.HA,
ConnectionFactoryAttributes.Regular.FACTORY_TYPE,
ConnectionFactoryAttributes.Common.DISCOVERY_GROUP,
ConnectionFactoryAttributes.Common.CONNECTORS,
ConnectionFactoryAttributes.Common.ENTRIES,
ConnectionFactoryAttributes.External.ENABLE_AMQ1_PREFIX,
ConnectionFactoryAttributes.Common.USE_TOPOLOGY,
// common
ConnectionFactoryAttributes.Common.CLIENT_FAILURE_CHECK_PERIOD,
ConnectionFactoryAttributes.Common.CONNECTION_TTL,
CommonAttributes.CALL_TIMEOUT,
CommonAttributes.CALL_FAILOVER_TIMEOUT,
ConnectionFactoryAttributes.Common.CONSUMER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.CONSUMER_MAX_RATE,
ConnectionFactoryAttributes.Common.CONFIRMATION_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_MAX_RATE,
ConnectionFactoryAttributes.Common.PROTOCOL_MANAGER_FACTORY,
ConnectionFactoryAttributes.Common.COMPRESS_LARGE_MESSAGES,
ConnectionFactoryAttributes.Common.CACHE_LARGE_MESSAGE_CLIENT,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CLIENT_ID,
ConnectionFactoryAttributes.Common.DUPS_OK_BATCH_SIZE,
ConnectionFactoryAttributes.Common.TRANSACTION_BATCH_SIZE,
ConnectionFactoryAttributes.Common.BLOCK_ON_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.BLOCK_ON_NON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.BLOCK_ON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.AUTO_GROUP,
ConnectionFactoryAttributes.Common.PRE_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL_MULTIPLIER,
CommonAttributes.MAX_RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RECONNECT_ATTEMPTS,
ConnectionFactoryAttributes.Common.FAILOVER_ON_INITIAL_CONNECTION,
ConnectionFactoryAttributes.Common.CONNECTION_LOAD_BALANCING_CLASS_NAME,
ConnectionFactoryAttributes.Common.USE_GLOBAL_POOLS,
ConnectionFactoryAttributes.Common.SCHEDULED_THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.GROUP_ID,
ConnectionFactoryAttributes.Common.DESERIALIZATION_BLOCKLIST,
ConnectionFactoryAttributes.Common.DESERIALIZATION_ALLOWLIST,
ConnectionFactoryAttributes.Common.INITIAL_MESSAGE_PACKET_SIZE
))
.addChild(createPooledConnectionFactory(true))
.addChild(builder(MessagingExtension.EXTERNAL_JMS_QUEUE_PATH)
.addAttributes(
ConnectionFactoryAttributes.Common.ENTRIES,
ConnectionFactoryAttributes.External.ENABLE_AMQ1_PREFIX
))
.addChild(builder(MessagingExtension.EXTERNAL_JMS_TOPIC_PATH)
.addAttributes(
ConnectionFactoryAttributes.Common.ENTRIES,
ConnectionFactoryAttributes.External.ENABLE_AMQ1_PREFIX
))
.addChild(builder(MessagingExtension.SERVER_PATH)
.addAttributes(// no attribute groups
ServerDefinition.PERSISTENCE_ENABLED,
ServerDefinition.PERSIST_ID_CACHE,
ServerDefinition.PERSIST_DELIVERY_COUNT_BEFORE_DELIVERY,
ServerDefinition.ID_CACHE_SIZE,
ServerDefinition.PAGE_MAX_CONCURRENT_IO,
ServerDefinition.SCHEDULED_THREAD_POOL_MAX_SIZE,
ServerDefinition.THREAD_POOL_MAX_SIZE,
ServerDefinition.WILD_CARD_ROUTING_ENABLED,
ServerDefinition.CONNECTION_TTL_OVERRIDE,
ServerDefinition.ASYNC_CONNECTION_EXECUTION_ENABLED,
ServerDefinition.ADDRESS_QUEUE_SCAN_PERIOD,
// security
ServerDefinition.SECURITY_ENABLED,
ServerDefinition.SECURITY_DOMAIN,
ServerDefinition.ELYTRON_DOMAIN,
ServerDefinition.SECURITY_INVALIDATION_INTERVAL,
ServerDefinition.OVERRIDE_IN_VM_SECURITY,
// cluster
ServerDefinition.CLUSTER_USER,
ServerDefinition.CLUSTER_PASSWORD,
ServerDefinition.CREDENTIAL_REFERENCE,
// management
ServerDefinition.MANAGEMENT_ADDRESS,
ServerDefinition.MANAGEMENT_NOTIFICATION_ADDRESS,
ServerDefinition.JMX_MANAGEMENT_ENABLED,
ServerDefinition.JMX_DOMAIN,
// journal
ServerDefinition.JOURNAL_TYPE,
ServerDefinition.JOURNAL_BUFFER_TIMEOUT,
ServerDefinition.JOURNAL_BUFFER_SIZE,
ServerDefinition.JOURNAL_SYNC_TRANSACTIONAL,
ServerDefinition.JOURNAL_SYNC_NON_TRANSACTIONAL,
ServerDefinition.LOG_JOURNAL_WRITE_RATE,
ServerDefinition.JOURNAL_FILE_SIZE,
ServerDefinition.JOURNAL_MIN_FILES,
ServerDefinition.JOURNAL_POOL_FILES,
ServerDefinition.JOURNAL_FILE_OPEN_TIMEOUT,
ServerDefinition.JOURNAL_COMPACT_PERCENTAGE,
ServerDefinition.JOURNAL_COMPACT_MIN_FILES,
ServerDefinition.JOURNAL_MAX_IO,
ServerDefinition.JOURNAL_MAX_ATTIC_FILES,
ServerDefinition.CREATE_BINDINGS_DIR,
ServerDefinition.CREATE_JOURNAL_DIR,
ServerDefinition.JOURNAL_DATASOURCE,
ServerDefinition.JOURNAL_MESSAGES_TABLE,
ServerDefinition.JOURNAL_BINDINGS_TABLE,
ServerDefinition.JOURNAL_JMS_BINDINGS_TABLE,
ServerDefinition.JOURNAL_LARGE_MESSAGES_TABLE,
ServerDefinition.JOURNAL_PAGE_STORE_TABLE,
ServerDefinition.JOURNAL_NODE_MANAGER_STORE_TABLE,
ServerDefinition.JOURNAL_DATABASE,
ServerDefinition.JOURNAL_JDBC_LOCK_EXPIRATION,
ServerDefinition.JOURNAL_JDBC_LOCK_RENEW_PERIOD,
ServerDefinition.JOURNAL_JDBC_NETWORK_TIMEOUT,
ServerDefinition.GLOBAL_MAX_DISK_USAGE,
ServerDefinition.DISK_SCAN_PERIOD,
ServerDefinition.GLOBAL_MAX_MEMORY_SIZE,
// statistics
ServerDefinition.STATISTICS_ENABLED,
ServerDefinition.MESSAGE_COUNTER_SAMPLE_PERIOD,
ServerDefinition.MESSAGE_COUNTER_MAX_DAY_HISTORY,
// transaction
ServerDefinition.TRANSACTION_TIMEOUT,
ServerDefinition.TRANSACTION_TIMEOUT_SCAN_PERIOD,
// message expiry
ServerDefinition.MESSAGE_EXPIRY_SCAN_PERIOD,
ServerDefinition.MESSAGE_EXPIRY_THREAD_PRIORITY,
// debug
ServerDefinition.PERF_BLAST_PAGES,
ServerDefinition.RUN_SYNC_SPEED_TEST,
ServerDefinition.SERVER_DUMP_INTERVAL,
ServerDefinition.MEMORY_MEASURE_INTERVAL,
ServerDefinition.MEMORY_WARNING_THRESHOLD,
CommonAttributes.INCOMING_INTERCEPTORS,
CommonAttributes.OUTGOING_INTERCEPTORS,
//Network Isolation
ServerDefinition.NETWORK_CHECK_LIST,
ServerDefinition.NETWORK_CHECK_NIC,
ServerDefinition.NETWORK_CHECK_PERIOD,
ServerDefinition.NETWORK_CHECK_PING6_COMMAND,
ServerDefinition.NETWORK_CHECK_PING_COMMAND,
ServerDefinition.NETWORK_CHECK_TIMEOUT,
ServerDefinition.NETWORK_CHECK_URL_LIST,
ServerDefinition.CRITICAL_ANALYZER_ENABLED,
ServerDefinition.CRITICAL_ANALYZER_CHECK_PERIOD,
ServerDefinition.CRITICAL_ANALYZER_POLICY,
ServerDefinition.CRITICAL_ANALYZER_TIMEOUT)
.addChild(
builder(MessagingExtension.LIVE_ONLY_PATH)
.addAttributes(
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS))
.addChild(builder(MessagingExtension.REPLICATION_PRIMARY_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.CHECK_FOR_LIVE_SERVER,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT))
.addChild(builder(MessagingExtension.REPLICATION_SECONDARY_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.ALLOW_FAILBACK,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT,
HAAttributes.MAX_SAVED_REPLICATED_JOURNAL_SIZE,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS))
.addChild(builder(MessagingExtension.REPLICATION_COLOCATED_PATH)
.addAttributes(
HAAttributes.REQUEST_BACKUP,
HAAttributes.BACKUP_REQUEST_RETRIES,
HAAttributes.BACKUP_REQUEST_RETRY_INTERVAL,
HAAttributes.MAX_BACKUPS,
HAAttributes.BACKUP_PORT_OFFSET,
HAAttributes.EXCLUDED_CONNECTORS)
.addChild(builder(MessagingExtension.CONFIGURATION_PRIMARY_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.CHECK_FOR_LIVE_SERVER,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT))
.addChild(builder(MessagingExtension.CONFIGURATION_SECONDARY_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.ALLOW_FAILBACK,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT,
HAAttributes.MAX_SAVED_REPLICATED_JOURNAL_SIZE,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS)))
.addChild(builder(MessagingExtension.SHARED_STORE_PRIMARY_PATH)
.addAttributes(
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN))
.addChild(builder(MessagingExtension.SHARED_STORE_SECONDARY_PATH)
.addAttributes(
HAAttributes.ALLOW_FAILBACK,
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS))
.addChild(builder(MessagingExtension.SHARED_STORE_COLOCATED_PATH)
.addAttributes(
HAAttributes.REQUEST_BACKUP,
HAAttributes.BACKUP_REQUEST_RETRIES,
HAAttributes.BACKUP_REQUEST_RETRY_INTERVAL,
HAAttributes.MAX_BACKUPS,
HAAttributes.BACKUP_PORT_OFFSET)
.addChild(builder(MessagingExtension.CONFIGURATION_PRIMARY_PATH)
.addAttributes(
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN))
.addChild(builder(MessagingExtension.CONFIGURATION_SECONDARY_PATH)
.addAttributes(
HAAttributes.ALLOW_FAILBACK,
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS)))
.addChild(
builder(MessagingExtension.BINDINGS_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.BINDINGS_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.JOURNAL_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.JOURNAL_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.LARGE_MESSAGES_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.LARGE_MESSAGES_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.PAGING_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.PAGING_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.QUEUE_PATH)
.addAttributes(QueueDefinition.ADDRESS,
CommonAttributes.DURABLE,
CommonAttributes.FILTER,
QueueDefinition.ROUTING_TYPE))
.addChild(
builder(MessagingExtension.SECURITY_SETTING_PATH)
.addChild(
builder(MessagingExtension.ROLE_PATH)
.addAttributes(
SecurityRoleDefinition.SEND,
SecurityRoleDefinition.CONSUME,
SecurityRoleDefinition.CREATE_DURABLE_QUEUE,
SecurityRoleDefinition.DELETE_DURABLE_QUEUE,
SecurityRoleDefinition.CREATE_NON_DURABLE_QUEUE,
SecurityRoleDefinition.DELETE_NON_DURABLE_QUEUE,
SecurityRoleDefinition.MANAGE)))
.addChild(
builder(MessagingExtension.ADDRESS_SETTING_PATH)
.addAttributes(
CommonAttributes.DEAD_LETTER_ADDRESS,
CommonAttributes.EXPIRY_ADDRESS,
AddressSettingDefinition.EXPIRY_DELAY,
AddressSettingDefinition.REDELIVERY_DELAY,
AddressSettingDefinition.REDELIVERY_MULTIPLIER,
AddressSettingDefinition.MAX_DELIVERY_ATTEMPTS,
AddressSettingDefinition.MAX_REDELIVERY_DELAY,
AddressSettingDefinition.MAX_SIZE_BYTES,
AddressSettingDefinition.PAGE_SIZE_BYTES,
AddressSettingDefinition.PAGE_MAX_CACHE_SIZE,
AddressSettingDefinition.ADDRESS_FULL_MESSAGE_POLICY,
AddressSettingDefinition.MESSAGE_COUNTER_HISTORY_DAY_LIMIT,
AddressSettingDefinition.LAST_VALUE_QUEUE,
AddressSettingDefinition.REDISTRIBUTION_DELAY,
AddressSettingDefinition.SEND_TO_DLA_ON_NO_ROUTE,
AddressSettingDefinition.SLOW_CONSUMER_CHECK_PERIOD,
AddressSettingDefinition.SLOW_CONSUMER_POLICY,
AddressSettingDefinition.SLOW_CONSUMER_THRESHOLD,
AddressSettingDefinition.AUTO_CREATE_JMS_QUEUES,
AddressSettingDefinition.AUTO_DELETE_JMS_QUEUES,
AddressSettingDefinition.AUTO_CREATE_QUEUES,
AddressSettingDefinition.AUTO_DELETE_QUEUES,
AddressSettingDefinition.AUTO_CREATE_ADDRESSES,
AddressSettingDefinition.AUTO_DELETE_ADDRESSES,
AddressSettingDefinition.AUTO_DELETE_CREATED_QUEUES))
.addChild(httpConnector)
.addChild(remoteConnector)
.addChild(invmConnector)
.addChild(connector)
.addChild(
builder(MessagingExtension.HTTP_ACCEPTOR_PATH)
.addAttributes(
HTTPAcceptorDefinition.HTTP_LISTENER,
HTTPAcceptorDefinition.UPGRADE_LEGACY,
CommonAttributes.PARAMS))
.addChild(
builder(pathElement(REMOTE_ACCEPTOR))
.addAttributes(
RemoteTransportDefinition.SOCKET_BINDING,
CommonAttributes.PARAMS))
.addChild(
builder(pathElement(IN_VM_ACCEPTOR))
.addAttributes(
InVMTransportDefinition.SERVER_ID,
CommonAttributes.PARAMS))
.addChild(
builder(pathElement(ACCEPTOR))
.addAttributes(
GenericTransportDefinition.SOCKET_BINDING,
CommonAttributes.FACTORY_CLASS,
CommonAttributes.PARAMS))
.addChild(
builder(MessagingExtension.JGROUPS_BROADCAST_GROUP_PATH)
.addAttributes(
BroadcastGroupDefinition.JGROUPS_CHANNEL_FACTORY,
BroadcastGroupDefinition.JGROUPS_CHANNEL,
CommonAttributes.JGROUPS_CLUSTER,
BroadcastGroupDefinition.BROADCAST_PERIOD,
BroadcastGroupDefinition.CONNECTOR_REFS))
.addChild(
builder(MessagingExtension.SOCKET_BROADCAST_GROUP_PATH)
.addAttributes(
CommonAttributes.SOCKET_BINDING,
BroadcastGroupDefinition.BROADCAST_PERIOD,
BroadcastGroupDefinition.CONNECTOR_REFS))
.addChild(jgroupDiscoveryGroup)
.addChild(socketDiscoveryGroup)
.addChild(
builder(MessagingExtension.CLUSTER_CONNECTION_PATH)
.addAttributes(
ClusterConnectionDefinition.ADDRESS,
ClusterConnectionDefinition.CONNECTOR_NAME,
ClusterConnectionDefinition.CHECK_PERIOD,
ClusterConnectionDefinition.CONNECTION_TTL,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CALL_TIMEOUT,
ClusterConnectionDefinition.CALL_FAILOVER_TIMEOUT,
ClusterConnectionDefinition.RETRY_INTERVAL,
ClusterConnectionDefinition.RETRY_INTERVAL_MULTIPLIER,
ClusterConnectionDefinition.MAX_RETRY_INTERVAL,
ClusterConnectionDefinition.INITIAL_CONNECT_ATTEMPTS,
ClusterConnectionDefinition.RECONNECT_ATTEMPTS,
ClusterConnectionDefinition.USE_DUPLICATE_DETECTION,
ClusterConnectionDefinition.MESSAGE_LOAD_BALANCING_TYPE,
ClusterConnectionDefinition.MAX_HOPS,
CommonAttributes.BRIDGE_CONFIRMATION_WINDOW_SIZE,
ClusterConnectionDefinition.PRODUCER_WINDOW_SIZE,
ClusterConnectionDefinition.NOTIFICATION_ATTEMPTS,
ClusterConnectionDefinition.NOTIFICATION_INTERVAL,
ClusterConnectionDefinition.CONNECTOR_REFS,
ClusterConnectionDefinition.ALLOW_DIRECT_CONNECTIONS_ONLY,
ClusterConnectionDefinition.DISCOVERY_GROUP_NAME))
.addChild(
builder(MessagingExtension.GROUPING_HANDLER_PATH)
.addAttributes(
GroupingHandlerDefinition.TYPE,
GroupingHandlerDefinition.GROUPING_HANDLER_ADDRESS,
GroupingHandlerDefinition.TIMEOUT,
GroupingHandlerDefinition.GROUP_TIMEOUT,
GroupingHandlerDefinition.REAPER_PERIOD))
.addChild(
builder(DivertDefinition.PATH)
.addAttributes(
DivertDefinition.ROUTING_NAME,
DivertDefinition.ADDRESS,
DivertDefinition.FORWARDING_ADDRESS,
CommonAttributes.FILTER,
CommonAttributes.TRANSFORMER_CLASS_NAME,
DivertDefinition.EXCLUSIVE))
.addChild(
builder(MessagingExtension.BRIDGE_PATH)
.addAttributes(
BridgeDefinition.ATTRIBUTES
))
.addChild(
builder(MessagingExtension.CONNECTOR_SERVICE_PATH)
.addAttributes(
CommonAttributes.FACTORY_CLASS,
CommonAttributes.PARAMS))
.addChild(
builder(MessagingExtension.JMS_QUEUE_PATH)
.addAttributes(
CommonAttributes.DESTINATION_ENTRIES,
CommonAttributes.SELECTOR,
CommonAttributes.DURABLE,
CommonAttributes.LEGACY_ENTRIES))
.addChild(
builder(MessagingExtension.JMS_TOPIC_PATH)
.addAttributes(
CommonAttributes.DESTINATION_ENTRIES,
CommonAttributes.LEGACY_ENTRIES))
.addChild(
builder(MessagingExtension.CONNECTION_FACTORY_PATH)
.addAttributes(
ConnectionFactoryAttributes.Common.ENTRIES,
// common
ConnectionFactoryAttributes.Common.DISCOVERY_GROUP,
ConnectionFactoryAttributes.Common.CONNECTORS,
CommonAttributes.HA,
ConnectionFactoryAttributes.Common.CLIENT_FAILURE_CHECK_PERIOD,
ConnectionFactoryAttributes.Common.CONNECTION_TTL,
CommonAttributes.CALL_TIMEOUT,
CommonAttributes.CALL_FAILOVER_TIMEOUT,
ConnectionFactoryAttributes.Common.CONSUMER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.CONSUMER_MAX_RATE,
ConnectionFactoryAttributes.Common.CONFIRMATION_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_MAX_RATE,
ConnectionFactoryAttributes.Common.PROTOCOL_MANAGER_FACTORY,
ConnectionFactoryAttributes.Common.COMPRESS_LARGE_MESSAGES,
ConnectionFactoryAttributes.Common.CACHE_LARGE_MESSAGE_CLIENT,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CLIENT_ID,
ConnectionFactoryAttributes.Common.DUPS_OK_BATCH_SIZE,
ConnectionFactoryAttributes.Common.TRANSACTION_BATCH_SIZE,
ConnectionFactoryAttributes.Common.BLOCK_ON_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.BLOCK_ON_NON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.BLOCK_ON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.AUTO_GROUP,
ConnectionFactoryAttributes.Common.PRE_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL_MULTIPLIER,
CommonAttributes.MAX_RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RECONNECT_ATTEMPTS,
ConnectionFactoryAttributes.Common.FAILOVER_ON_INITIAL_CONNECTION,
ConnectionFactoryAttributes.Common.CONNECTION_LOAD_BALANCING_CLASS_NAME,
ConnectionFactoryAttributes.Common.USE_GLOBAL_POOLS,
ConnectionFactoryAttributes.Common.SCHEDULED_THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.GROUP_ID,
ConnectionFactoryAttributes.Common.DESERIALIZATION_BLOCKLIST,
ConnectionFactoryAttributes.Common.DESERIALIZATION_ALLOWLIST,
ConnectionFactoryAttributes.Common.INITIAL_MESSAGE_PACKET_SIZE,
ConnectionFactoryAttributes.Regular.FACTORY_TYPE,
ConnectionFactoryAttributes.Common.USE_TOPOLOGY))
.addChild(
builder(MessagingExtension.LEGACY_CONNECTION_FACTORY_PATH)
.addAttributes(
LegacyConnectionFactoryDefinition.ENTRIES,
LegacyConnectionFactoryDefinition.DISCOVERY_GROUP,
LegacyConnectionFactoryDefinition.CONNECTORS,
LegacyConnectionFactoryDefinition.AUTO_GROUP,
LegacyConnectionFactoryDefinition.BLOCK_ON_ACKNOWLEDGE,
LegacyConnectionFactoryDefinition.BLOCK_ON_DURABLE_SEND,
LegacyConnectionFactoryDefinition.BLOCK_ON_NON_DURABLE_SEND,
CommonAttributes.CALL_TIMEOUT,
CommonAttributes.CALL_FAILOVER_TIMEOUT,
LegacyConnectionFactoryDefinition.CACHE_LARGE_MESSAGE_CLIENT,
LegacyConnectionFactoryDefinition.CLIENT_FAILURE_CHECK_PERIOD,
CommonAttributes.CLIENT_ID,
LegacyConnectionFactoryDefinition.COMPRESS_LARGE_MESSAGES,
LegacyConnectionFactoryDefinition.CONFIRMATION_WINDOW_SIZE,
LegacyConnectionFactoryDefinition.CONNECTION_LOAD_BALANCING_CLASS_NAME,
LegacyConnectionFactoryDefinition.CONNECTION_TTL,
LegacyConnectionFactoryDefinition.CONSUMER_MAX_RATE,
LegacyConnectionFactoryDefinition.CONSUMER_WINDOW_SIZE,
LegacyConnectionFactoryDefinition.DUPS_OK_BATCH_SIZE,
LegacyConnectionFactoryDefinition.FACTORY_TYPE,
LegacyConnectionFactoryDefinition.FAILOVER_ON_INITIAL_CONNECTION,
LegacyConnectionFactoryDefinition.GROUP_ID,
LegacyConnectionFactoryDefinition.INITIAL_CONNECT_ATTEMPTS,
LegacyConnectionFactoryDefinition.INITIAL_MESSAGE_PACKET_SIZE,
LegacyConnectionFactoryDefinition.HA,
LegacyConnectionFactoryDefinition.MAX_RETRY_INTERVAL,
LegacyConnectionFactoryDefinition.MIN_LARGE_MESSAGE_SIZE,
LegacyConnectionFactoryDefinition.PRE_ACKNOWLEDGE,
LegacyConnectionFactoryDefinition.PRODUCER_MAX_RATE,
LegacyConnectionFactoryDefinition.PRODUCER_WINDOW_SIZE,
LegacyConnectionFactoryDefinition.RECONNECT_ATTEMPTS,
LegacyConnectionFactoryDefinition.RETRY_INTERVAL,
LegacyConnectionFactoryDefinition.RETRY_INTERVAL_MULTIPLIER,
LegacyConnectionFactoryDefinition.SCHEDULED_THREAD_POOL_MAX_SIZE,
LegacyConnectionFactoryDefinition.THREAD_POOL_MAX_SIZE,
LegacyConnectionFactoryDefinition.TRANSACTION_BATCH_SIZE,
LegacyConnectionFactoryDefinition.USE_GLOBAL_POOLS))
.addChild(createPooledConnectionFactory(false)))
.addChild(
builder(MessagingExtension.JMS_BRIDGE_PATH)
.addAttributes(
JMSBridgeDefinition.MODULE,
JMSBridgeDefinition.QUALITY_OF_SERVICE,
JMSBridgeDefinition.FAILURE_RETRY_INTERVAL,
JMSBridgeDefinition.MAX_RETRIES,
JMSBridgeDefinition.MAX_BATCH_SIZE,
JMSBridgeDefinition.MAX_BATCH_TIME,
CommonAttributes.SELECTOR,
JMSBridgeDefinition.SUBSCRIPTION_NAME,
CommonAttributes.CLIENT_ID,
JMSBridgeDefinition.ADD_MESSAGE_ID_IN_HEADER,
JMSBridgeDefinition.SOURCE_CONNECTION_FACTORY,
JMSBridgeDefinition.SOURCE_DESTINATION,
JMSBridgeDefinition.SOURCE_USER,
JMSBridgeDefinition.SOURCE_PASSWORD,
JMSBridgeDefinition.SOURCE_CREDENTIAL_REFERENCE,
JMSBridgeDefinition.TARGET_CONNECTION_FACTORY,
JMSBridgeDefinition.TARGET_DESTINATION,
JMSBridgeDefinition.TARGET_USER,
JMSBridgeDefinition.TARGET_PASSWORD,
JMSBridgeDefinition.TARGET_CREDENTIAL_REFERENCE,
JMSBridgeDefinition.SOURCE_CONTEXT,
JMSBridgeDefinition.TARGET_CONTEXT))
.build();
}
private PersistentResourceXMLBuilder createPooledConnectionFactory(boolean external) {
PersistentResourceXMLBuilder builder = builder(MessagingExtension.POOLED_CONNECTION_FACTORY_PATH)
.addAttributes(
ConnectionFactoryAttributes.Common.ENTRIES,
// common
ConnectionFactoryAttributes.Common.DISCOVERY_GROUP,
ConnectionFactoryAttributes.Common.CONNECTORS,
CommonAttributes.HA,
ConnectionFactoryAttributes.Common.CLIENT_FAILURE_CHECK_PERIOD,
ConnectionFactoryAttributes.Common.CONNECTION_TTL,
CommonAttributes.CALL_TIMEOUT,
CommonAttributes.CALL_FAILOVER_TIMEOUT,
ConnectionFactoryAttributes.Common.CONSUMER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.CONSUMER_MAX_RATE,
ConnectionFactoryAttributes.Common.CONFIRMATION_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_MAX_RATE,
ConnectionFactoryAttributes.Common.PROTOCOL_MANAGER_FACTORY,
ConnectionFactoryAttributes.Common.COMPRESS_LARGE_MESSAGES,
ConnectionFactoryAttributes.Common.CACHE_LARGE_MESSAGE_CLIENT,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CLIENT_ID,
ConnectionFactoryAttributes.Common.DUPS_OK_BATCH_SIZE,
ConnectionFactoryAttributes.Common.TRANSACTION_BATCH_SIZE,
ConnectionFactoryAttributes.Common.BLOCK_ON_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.BLOCK_ON_NON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.BLOCK_ON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.AUTO_GROUP,
ConnectionFactoryAttributes.Common.PRE_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL_MULTIPLIER,
CommonAttributes.MAX_RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RECONNECT_ATTEMPTS,
ConnectionFactoryAttributes.Common.FAILOVER_ON_INITIAL_CONNECTION,
ConnectionFactoryAttributes.Common.CONNECTION_LOAD_BALANCING_CLASS_NAME,
ConnectionFactoryAttributes.Common.USE_GLOBAL_POOLS,
ConnectionFactoryAttributes.Common.SCHEDULED_THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.GROUP_ID,
ConnectionFactoryAttributes.Common.DESERIALIZATION_BLOCKLIST,
ConnectionFactoryAttributes.Common.DESERIALIZATION_ALLOWLIST,
ConnectionFactoryAttributes.Common.USE_TOPOLOGY,
// pooled
// inbound config
ConnectionFactoryAttributes.Pooled.USE_JNDI,
ConnectionFactoryAttributes.Pooled.JNDI_PARAMS,
ConnectionFactoryAttributes.Pooled.REBALANCE_CONNECTIONS,
ConnectionFactoryAttributes.Pooled.USE_LOCAL_TX,
ConnectionFactoryAttributes.Pooled.SETUP_ATTEMPTS,
ConnectionFactoryAttributes.Pooled.SETUP_INTERVAL,
// outbound config
ConnectionFactoryAttributes.Pooled.ALLOW_LOCAL_TRANSACTIONS,
ConnectionFactoryAttributes.Pooled.TRANSACTION,
ConnectionFactoryAttributes.Pooled.USER,
ConnectionFactoryAttributes.Pooled.PASSWORD,
ConnectionFactoryAttributes.Pooled.CREDENTIAL_REFERENCE,
ConnectionFactoryAttributes.Pooled.MIN_POOL_SIZE,
ConnectionFactoryAttributes.Pooled.USE_AUTO_RECOVERY,
ConnectionFactoryAttributes.Pooled.MAX_POOL_SIZE,
ConnectionFactoryAttributes.Pooled.MANAGED_CONNECTION_POOL,
ConnectionFactoryAttributes.Pooled.ENLISTMENT_TRACE,
ConnectionFactoryAttributes.Common.INITIAL_MESSAGE_PACKET_SIZE,
ConnectionFactoryAttributes.Pooled.INITIAL_CONNECT_ATTEMPTS,
ConnectionFactoryAttributes.Pooled.STATISTICS_ENABLED);
if (external) {
builder.addAttributes(ConnectionFactoryAttributes.External.ENABLE_AMQ1_PREFIX);
}
return builder;
}
}
| 54,803
| 79.240117
| 128
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/HTTPAcceptorRemove.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import org.jboss.as.controller.AbstractRemoveStepHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.dmr.ModelNode;
/**
* The remove operation for the messaging subsystem's http-acceptor resource.
*
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2013 Red Hat inc.
*/
public class HTTPAcceptorRemove extends AbstractRemoveStepHandler {
static final HTTPAcceptorRemove INSTANCE = new HTTPAcceptorRemove();
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final String acceptorName = context.getCurrentAddressValue();
final String serverName = context.getCurrentAddress().getParent().getLastElement().getValue();
context.removeService(MessagingServices.getHttpUpgradeServiceName(serverName, acceptorName));
boolean upgradeLegacy = HTTPAcceptorDefinition.UPGRADE_LEGACY.resolveModelAttribute(context, model).asBoolean();
if (upgradeLegacy) {
context.removeService(MessagingServices.getLegacyHttpUpgradeServiceName(serverName, acceptorName));
}
}
protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final String acceptorName = context.getCurrentAddressValue();
final String serverName = context.getCurrentAddress().getParent().getLastElement().getValue();
HTTPAcceptorAdd.INSTANCE.launchServices(context, serverName, acceptorName, model);
}
}
| 2,675
| 46.785714
| 132
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/MessagingSubsystemParser_11_0.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import static org.jboss.as.controller.PathElement.pathElement;
import static org.jboss.as.controller.PersistentResourceXMLDescription.builder;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.ACCEPTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.CONNECTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.IN_VM_ACCEPTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.IN_VM_CONNECTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.REMOTE_ACCEPTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.REMOTE_CONNECTOR;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.CONFIGURATION_MASTER_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.CONFIGURATION_SLAVE_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.REPLICATION_MASTER_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.SHARED_STORE_COLOCATED_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.SHARED_STORE_MASTER_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.SHARED_STORE_SLAVE_PATH;
import org.jboss.as.controller.PersistentResourceXMLDescription;
import org.jboss.as.controller.PersistentResourceXMLDescription.PersistentResourceXMLBuilder;
import org.jboss.as.controller.PersistentResourceXMLParser;
import org.wildfly.extension.messaging.activemq.ha.HAAttributes;
import org.wildfly.extension.messaging.activemq.ha.ScaleDownAttributes;
import org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes;
import org.wildfly.extension.messaging.activemq.jms.bridge.JMSBridgeDefinition;
import org.wildfly.extension.messaging.activemq.jms.legacy.LegacyConnectionFactoryDefinition;
/**
* Parser and Marshaller for messaging-activemq's {@link #NAMESPACE}.
*
* <em>All resources and attributes must be listed explicitly and not through any collections.</em>
* This ensures that if the resource definitions change in later version (e.g. a new attribute is added),
* this will have no impact on parsing this specific version of the subsystem.
*
* @author Paul Ferraro
*/
public class MessagingSubsystemParser_11_0 extends PersistentResourceXMLParser {
static final String NAMESPACE = "urn:jboss:domain:messaging-activemq:11.0";
@Override
public PersistentResourceXMLDescription getParserDescription() {
final PersistentResourceXMLBuilder jgroupDiscoveryGroup = builder(JGroupsDiscoveryGroupDefinition.PATH)
.addAttributes(
DiscoveryGroupDefinition.JGROUPS_CHANNEL_FACTORY,
DiscoveryGroupDefinition.JGROUPS_CHANNEL,
CommonAttributes.JGROUPS_CLUSTER,
DiscoveryGroupDefinition.REFRESH_TIMEOUT,
DiscoveryGroupDefinition.INITIAL_WAIT_TIMEOUT);
final PersistentResourceXMLBuilder socketDiscoveryGroup = builder(SocketDiscoveryGroupDefinition.PATH)
.addAttributes(
CommonAttributes.SOCKET_BINDING,
DiscoveryGroupDefinition.REFRESH_TIMEOUT,
DiscoveryGroupDefinition.INITIAL_WAIT_TIMEOUT);
final PersistentResourceXMLBuilder remoteConnector = builder(pathElement(REMOTE_CONNECTOR))
.addAttributes(
RemoteTransportDefinition.SOCKET_BINDING,
CommonAttributes.PARAMS);
final PersistentResourceXMLBuilder httpConnector = builder(MessagingExtension.HTTP_CONNECTOR_PATH)
.addAttributes(
HTTPConnectorDefinition.SOCKET_BINDING,
HTTPConnectorDefinition.ENDPOINT,
HTTPConnectorDefinition.SERVER_NAME,
CommonAttributes.PARAMS);
final PersistentResourceXMLBuilder invmConnector = builder(pathElement(IN_VM_CONNECTOR))
.addAttributes(
InVMTransportDefinition.SERVER_ID,
CommonAttributes.PARAMS);
final PersistentResourceXMLBuilder connector = builder(pathElement(CONNECTOR))
.addAttributes(
GenericTransportDefinition.SOCKET_BINDING,
CommonAttributes.FACTORY_CLASS,
CommonAttributes.PARAMS);
return builder(MessagingExtension.SUBSYSTEM_PATH, NAMESPACE)
.addAttributes(
MessagingSubsystemRootResourceDefinition.GLOBAL_CLIENT_THREAD_POOL_MAX_SIZE,
MessagingSubsystemRootResourceDefinition.GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_MAX_SIZE)
.addChild(httpConnector)
.addChild(remoteConnector)
.addChild(invmConnector)
.addChild(connector)
.addChild(jgroupDiscoveryGroup)
.addChild(socketDiscoveryGroup)
.addChild(builder(MessagingExtension.CONNECTION_FACTORY_PATH)
.addAttributes(
CommonAttributes.HA,
ConnectionFactoryAttributes.Regular.FACTORY_TYPE,
ConnectionFactoryAttributes.Common.DISCOVERY_GROUP,
ConnectionFactoryAttributes.Common.CONNECTORS,
ConnectionFactoryAttributes.Common.ENTRIES,
ConnectionFactoryAttributes.External.ENABLE_AMQ1_PREFIX,
ConnectionFactoryAttributes.Common.USE_TOPOLOGY,
// common
ConnectionFactoryAttributes.Common.CLIENT_FAILURE_CHECK_PERIOD,
ConnectionFactoryAttributes.Common.CONNECTION_TTL,
CommonAttributes.CALL_TIMEOUT,
CommonAttributes.CALL_FAILOVER_TIMEOUT,
ConnectionFactoryAttributes.Common.CONSUMER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.CONSUMER_MAX_RATE,
ConnectionFactoryAttributes.Common.CONFIRMATION_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_MAX_RATE,
ConnectionFactoryAttributes.Common.PROTOCOL_MANAGER_FACTORY,
ConnectionFactoryAttributes.Common.COMPRESS_LARGE_MESSAGES,
ConnectionFactoryAttributes.Common.CACHE_LARGE_MESSAGE_CLIENT,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CLIENT_ID,
ConnectionFactoryAttributes.Common.DUPS_OK_BATCH_SIZE,
ConnectionFactoryAttributes.Common.TRANSACTION_BATCH_SIZE,
ConnectionFactoryAttributes.Common.BLOCK_ON_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.BLOCK_ON_NON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.BLOCK_ON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.AUTO_GROUP,
ConnectionFactoryAttributes.Common.PRE_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL_MULTIPLIER,
CommonAttributes.MAX_RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RECONNECT_ATTEMPTS,
ConnectionFactoryAttributes.Common.FAILOVER_ON_INITIAL_CONNECTION,
ConnectionFactoryAttributes.Common.CONNECTION_LOAD_BALANCING_CLASS_NAME,
ConnectionFactoryAttributes.Common.USE_GLOBAL_POOLS,
ConnectionFactoryAttributes.Common.SCHEDULED_THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.GROUP_ID,
ConnectionFactoryAttributes.Common.DESERIALIZATION_BLACKLIST,
ConnectionFactoryAttributes.Common.DESERIALIZATION_WHITELIST,
ConnectionFactoryAttributes.Common.INITIAL_MESSAGE_PACKET_SIZE
))
.addChild(createPooledConnectionFactory(true))
.addChild(builder(MessagingExtension.EXTERNAL_JMS_QUEUE_PATH)
.addAttributes(
ConnectionFactoryAttributes.Common.ENTRIES
))
.addChild(builder(MessagingExtension.EXTERNAL_JMS_TOPIC_PATH)
.addAttributes(
ConnectionFactoryAttributes.Common.ENTRIES
))
.addChild(builder(MessagingExtension.SERVER_PATH)
.addAttributes(// no attribute groups
ServerDefinition.PERSISTENCE_ENABLED,
ServerDefinition.PERSIST_ID_CACHE,
ServerDefinition.PERSIST_DELIVERY_COUNT_BEFORE_DELIVERY,
ServerDefinition.ID_CACHE_SIZE,
ServerDefinition.PAGE_MAX_CONCURRENT_IO,
ServerDefinition.SCHEDULED_THREAD_POOL_MAX_SIZE,
ServerDefinition.THREAD_POOL_MAX_SIZE,
ServerDefinition.WILD_CARD_ROUTING_ENABLED,
ServerDefinition.CONNECTION_TTL_OVERRIDE,
ServerDefinition.ASYNC_CONNECTION_EXECUTION_ENABLED,
// security
ServerDefinition.SECURITY_ENABLED,
ServerDefinition.SECURITY_DOMAIN,
ServerDefinition.ELYTRON_DOMAIN,
ServerDefinition.SECURITY_INVALIDATION_INTERVAL,
ServerDefinition.OVERRIDE_IN_VM_SECURITY,
// cluster
ServerDefinition.CLUSTER_USER,
ServerDefinition.CLUSTER_PASSWORD,
ServerDefinition.CREDENTIAL_REFERENCE,
// management
ServerDefinition.MANAGEMENT_ADDRESS,
ServerDefinition.MANAGEMENT_NOTIFICATION_ADDRESS,
ServerDefinition.JMX_MANAGEMENT_ENABLED,
ServerDefinition.JMX_DOMAIN,
// journal
ServerDefinition.JOURNAL_TYPE,
ServerDefinition.JOURNAL_BUFFER_TIMEOUT,
ServerDefinition.JOURNAL_BUFFER_SIZE,
ServerDefinition.JOURNAL_SYNC_TRANSACTIONAL,
ServerDefinition.JOURNAL_SYNC_NON_TRANSACTIONAL,
ServerDefinition.LOG_JOURNAL_WRITE_RATE,
ServerDefinition.JOURNAL_FILE_SIZE,
ServerDefinition.JOURNAL_MIN_FILES,
ServerDefinition.JOURNAL_POOL_FILES,
ServerDefinition.JOURNAL_FILE_OPEN_TIMEOUT,
ServerDefinition.JOURNAL_COMPACT_PERCENTAGE,
ServerDefinition.JOURNAL_COMPACT_MIN_FILES,
ServerDefinition.JOURNAL_MAX_IO,
ServerDefinition.CREATE_BINDINGS_DIR,
ServerDefinition.CREATE_JOURNAL_DIR,
ServerDefinition.JOURNAL_DATASOURCE,
ServerDefinition.JOURNAL_MESSAGES_TABLE,
ServerDefinition.JOURNAL_BINDINGS_TABLE,
ServerDefinition.JOURNAL_JMS_BINDINGS_TABLE,
ServerDefinition.JOURNAL_LARGE_MESSAGES_TABLE,
ServerDefinition.JOURNAL_PAGE_STORE_TABLE,
ServerDefinition.JOURNAL_NODE_MANAGER_STORE_TABLE,
ServerDefinition.JOURNAL_DATABASE,
ServerDefinition.JOURNAL_JDBC_LOCK_EXPIRATION,
ServerDefinition.JOURNAL_JDBC_LOCK_RENEW_PERIOD,
ServerDefinition.JOURNAL_JDBC_NETWORK_TIMEOUT,
ServerDefinition.GLOBAL_MAX_DISK_USAGE,
ServerDefinition.DISK_SCAN_PERIOD,
ServerDefinition.GLOBAL_MAX_MEMORY_SIZE,
// statistics
ServerDefinition.STATISTICS_ENABLED,
ServerDefinition.MESSAGE_COUNTER_SAMPLE_PERIOD,
ServerDefinition.MESSAGE_COUNTER_MAX_DAY_HISTORY,
// transaction
ServerDefinition.TRANSACTION_TIMEOUT,
ServerDefinition.TRANSACTION_TIMEOUT_SCAN_PERIOD,
// message expiry
ServerDefinition.MESSAGE_EXPIRY_SCAN_PERIOD,
ServerDefinition.MESSAGE_EXPIRY_THREAD_PRIORITY,
// debug
ServerDefinition.PERF_BLAST_PAGES,
ServerDefinition.RUN_SYNC_SPEED_TEST,
ServerDefinition.SERVER_DUMP_INTERVAL,
ServerDefinition.MEMORY_MEASURE_INTERVAL,
ServerDefinition.MEMORY_WARNING_THRESHOLD,
CommonAttributes.INCOMING_INTERCEPTORS,
CommonAttributes.OUTGOING_INTERCEPTORS)
.addChild(
builder(MessagingExtension.LIVE_ONLY_PATH)
.addAttributes(
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS))
.addChild(builder(REPLICATION_MASTER_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.CHECK_FOR_LIVE_SERVER,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT))
.addChild(builder(MessagingExtension.REPLICATION_SLAVE_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.ALLOW_FAILBACK,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT,
HAAttributes.MAX_SAVED_REPLICATED_JOURNAL_SIZE,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS))
.addChild(builder(MessagingExtension.REPLICATION_COLOCATED_PATH)
.addAttributes(
HAAttributes.REQUEST_BACKUP,
HAAttributes.BACKUP_REQUEST_RETRIES,
HAAttributes.BACKUP_REQUEST_RETRY_INTERVAL,
HAAttributes.MAX_BACKUPS,
HAAttributes.BACKUP_PORT_OFFSET,
HAAttributes.EXCLUDED_CONNECTORS)
.addChild(builder(MessagingExtension.CONFIGURATION_MASTER_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.CHECK_FOR_LIVE_SERVER,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT))
.addChild(builder(MessagingExtension.CONFIGURATION_SLAVE_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.ALLOW_FAILBACK,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT,
HAAttributes.MAX_SAVED_REPLICATED_JOURNAL_SIZE,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS)))
.addChild(builder(SHARED_STORE_MASTER_PATH)
.addAttributes(
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN))
.addChild(builder(SHARED_STORE_SLAVE_PATH)
.addAttributes(
HAAttributes.ALLOW_FAILBACK,
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS))
.addChild(builder(SHARED_STORE_COLOCATED_PATH)
.addAttributes(
HAAttributes.REQUEST_BACKUP,
HAAttributes.BACKUP_REQUEST_RETRIES,
HAAttributes.BACKUP_REQUEST_RETRY_INTERVAL,
HAAttributes.MAX_BACKUPS,
HAAttributes.BACKUP_PORT_OFFSET)
.addChild(builder(CONFIGURATION_MASTER_PATH)
.addAttributes(
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN))
.addChild(builder(CONFIGURATION_SLAVE_PATH)
.addAttributes(
HAAttributes.ALLOW_FAILBACK,
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS)))
.addChild(
builder(MessagingExtension.BINDINGS_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.BINDINGS_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.JOURNAL_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.JOURNAL_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.LARGE_MESSAGES_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.LARGE_MESSAGES_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.PAGING_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.PAGING_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.QUEUE_PATH)
.addAttributes(QueueDefinition.ADDRESS,
CommonAttributes.DURABLE,
CommonAttributes.FILTER,
QueueDefinition.ROUTING_TYPE))
.addChild(
builder(MessagingExtension.SECURITY_SETTING_PATH)
.addChild(
builder(MessagingExtension.ROLE_PATH)
.addAttributes(
SecurityRoleDefinition.SEND,
SecurityRoleDefinition.CONSUME,
SecurityRoleDefinition.CREATE_DURABLE_QUEUE,
SecurityRoleDefinition.DELETE_DURABLE_QUEUE,
SecurityRoleDefinition.CREATE_NON_DURABLE_QUEUE,
SecurityRoleDefinition.DELETE_NON_DURABLE_QUEUE,
SecurityRoleDefinition.MANAGE)))
.addChild(
builder(MessagingExtension.ADDRESS_SETTING_PATH)
.addAttributes(
CommonAttributes.DEAD_LETTER_ADDRESS,
CommonAttributes.EXPIRY_ADDRESS,
AddressSettingDefinition.EXPIRY_DELAY,
AddressSettingDefinition.REDELIVERY_DELAY,
AddressSettingDefinition.REDELIVERY_MULTIPLIER,
AddressSettingDefinition.MAX_DELIVERY_ATTEMPTS,
AddressSettingDefinition.MAX_REDELIVERY_DELAY,
AddressSettingDefinition.MAX_SIZE_BYTES,
AddressSettingDefinition.PAGE_SIZE_BYTES,
AddressSettingDefinition.PAGE_MAX_CACHE_SIZE,
AddressSettingDefinition.ADDRESS_FULL_MESSAGE_POLICY,
AddressSettingDefinition.MESSAGE_COUNTER_HISTORY_DAY_LIMIT,
AddressSettingDefinition.LAST_VALUE_QUEUE,
AddressSettingDefinition.REDISTRIBUTION_DELAY,
AddressSettingDefinition.SEND_TO_DLA_ON_NO_ROUTE,
AddressSettingDefinition.SLOW_CONSUMER_CHECK_PERIOD,
AddressSettingDefinition.SLOW_CONSUMER_POLICY,
AddressSettingDefinition.SLOW_CONSUMER_THRESHOLD,
AddressSettingDefinition.AUTO_CREATE_JMS_QUEUES,
AddressSettingDefinition.AUTO_DELETE_JMS_QUEUES,
AddressSettingDefinition.AUTO_CREATE_QUEUES,
AddressSettingDefinition.AUTO_DELETE_QUEUES,
AddressSettingDefinition.AUTO_CREATE_ADDRESSES,
AddressSettingDefinition.AUTO_DELETE_ADDRESSES))
.addChild(httpConnector)
.addChild(remoteConnector)
.addChild(invmConnector)
.addChild(connector)
.addChild(
builder(MessagingExtension.HTTP_ACCEPTOR_PATH)
.addAttributes(
HTTPAcceptorDefinition.HTTP_LISTENER,
HTTPAcceptorDefinition.UPGRADE_LEGACY,
CommonAttributes.PARAMS))
.addChild(
builder(pathElement(REMOTE_ACCEPTOR))
.addAttributes(
RemoteTransportDefinition.SOCKET_BINDING,
CommonAttributes.PARAMS))
.addChild(
builder(pathElement(IN_VM_ACCEPTOR))
.addAttributes(
InVMTransportDefinition.SERVER_ID,
CommonAttributes.PARAMS))
.addChild(
builder(pathElement(ACCEPTOR))
.addAttributes(
GenericTransportDefinition.SOCKET_BINDING,
CommonAttributes.FACTORY_CLASS,
CommonAttributes.PARAMS))
.addChild(
builder(MessagingExtension.JGROUPS_BROADCAST_GROUP_PATH)
.addAttributes(
BroadcastGroupDefinition.JGROUPS_CHANNEL_FACTORY,
BroadcastGroupDefinition.JGROUPS_CHANNEL,
CommonAttributes.JGROUPS_CLUSTER,
BroadcastGroupDefinition.BROADCAST_PERIOD,
BroadcastGroupDefinition.CONNECTOR_REFS))
.addChild(
builder(MessagingExtension.SOCKET_BROADCAST_GROUP_PATH)
.addAttributes(
CommonAttributes.SOCKET_BINDING,
BroadcastGroupDefinition.BROADCAST_PERIOD,
BroadcastGroupDefinition.CONNECTOR_REFS))
.addChild(jgroupDiscoveryGroup)
.addChild(socketDiscoveryGroup)
.addChild(
builder(MessagingExtension.CLUSTER_CONNECTION_PATH)
.addAttributes(
ClusterConnectionDefinition.ADDRESS,
ClusterConnectionDefinition.CONNECTOR_NAME,
ClusterConnectionDefinition.CHECK_PERIOD,
ClusterConnectionDefinition.CONNECTION_TTL,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CALL_TIMEOUT,
ClusterConnectionDefinition.CALL_FAILOVER_TIMEOUT,
ClusterConnectionDefinition.RETRY_INTERVAL,
ClusterConnectionDefinition.RETRY_INTERVAL_MULTIPLIER,
ClusterConnectionDefinition.MAX_RETRY_INTERVAL,
ClusterConnectionDefinition.INITIAL_CONNECT_ATTEMPTS,
ClusterConnectionDefinition.RECONNECT_ATTEMPTS,
ClusterConnectionDefinition.USE_DUPLICATE_DETECTION,
ClusterConnectionDefinition.MESSAGE_LOAD_BALANCING_TYPE,
ClusterConnectionDefinition.MAX_HOPS,
CommonAttributes.BRIDGE_CONFIRMATION_WINDOW_SIZE,
ClusterConnectionDefinition.PRODUCER_WINDOW_SIZE,
ClusterConnectionDefinition.NOTIFICATION_ATTEMPTS,
ClusterConnectionDefinition.NOTIFICATION_INTERVAL,
ClusterConnectionDefinition.CONNECTOR_REFS,
ClusterConnectionDefinition.ALLOW_DIRECT_CONNECTIONS_ONLY,
ClusterConnectionDefinition.DISCOVERY_GROUP_NAME))
.addChild(
builder(MessagingExtension.GROUPING_HANDLER_PATH)
.addAttributes(
GroupingHandlerDefinition.TYPE,
GroupingHandlerDefinition.GROUPING_HANDLER_ADDRESS,
GroupingHandlerDefinition.TIMEOUT,
GroupingHandlerDefinition.GROUP_TIMEOUT,
GroupingHandlerDefinition.REAPER_PERIOD))
.addChild(
builder(DivertDefinition.PATH)
.addAttributes(
DivertDefinition.ROUTING_NAME,
DivertDefinition.ADDRESS,
DivertDefinition.FORWARDING_ADDRESS,
CommonAttributes.FILTER,
CommonAttributes.TRANSFORMER_CLASS_NAME,
DivertDefinition.EXCLUSIVE))
.addChild(
builder(MessagingExtension.BRIDGE_PATH)
.addAttributes(
BridgeDefinition.QUEUE_NAME,
BridgeDefinition.FORWARDING_ADDRESS,
CommonAttributes.HA,
CommonAttributes.FILTER,
CommonAttributes.TRANSFORMER_CLASS_NAME,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CHECK_PERIOD,
CommonAttributes.CONNECTION_TTL,
CommonAttributes.RETRY_INTERVAL,
CommonAttributes.RETRY_INTERVAL_MULTIPLIER,
CommonAttributes.MAX_RETRY_INTERVAL,
BridgeDefinition.INITIAL_CONNECT_ATTEMPTS,
BridgeDefinition.RECONNECT_ATTEMPTS,
BridgeDefinition.RECONNECT_ATTEMPTS_ON_SAME_NODE,
BridgeDefinition.USE_DUPLICATE_DETECTION,
CommonAttributes.BRIDGE_CONFIRMATION_WINDOW_SIZE,
BridgeDefinition.PRODUCER_WINDOW_SIZE,
BridgeDefinition.USER,
BridgeDefinition.PASSWORD,
BridgeDefinition.CREDENTIAL_REFERENCE,
BridgeDefinition.CONNECTOR_REFS,
BridgeDefinition.DISCOVERY_GROUP_NAME))
.addChild(
builder(MessagingExtension.CONNECTOR_SERVICE_PATH)
.addAttributes(
CommonAttributes.FACTORY_CLASS,
CommonAttributes.PARAMS))
.addChild(
builder(MessagingExtension.JMS_QUEUE_PATH)
.addAttributes(
CommonAttributes.DESTINATION_ENTRIES,
CommonAttributes.SELECTOR,
CommonAttributes.DURABLE,
CommonAttributes.LEGACY_ENTRIES))
.addChild(
builder(MessagingExtension.JMS_TOPIC_PATH)
.addAttributes(
CommonAttributes.DESTINATION_ENTRIES,
CommonAttributes.LEGACY_ENTRIES))
.addChild(
builder(MessagingExtension.CONNECTION_FACTORY_PATH)
.addAttributes(
ConnectionFactoryAttributes.Common.ENTRIES,
// common
ConnectionFactoryAttributes.Common.DISCOVERY_GROUP,
ConnectionFactoryAttributes.Common.CONNECTORS,
CommonAttributes.HA,
ConnectionFactoryAttributes.Common.CLIENT_FAILURE_CHECK_PERIOD,
ConnectionFactoryAttributes.Common.CONNECTION_TTL,
CommonAttributes.CALL_TIMEOUT,
CommonAttributes.CALL_FAILOVER_TIMEOUT,
ConnectionFactoryAttributes.Common.CONSUMER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.CONSUMER_MAX_RATE,
ConnectionFactoryAttributes.Common.CONFIRMATION_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_MAX_RATE,
ConnectionFactoryAttributes.Common.PROTOCOL_MANAGER_FACTORY,
ConnectionFactoryAttributes.Common.COMPRESS_LARGE_MESSAGES,
ConnectionFactoryAttributes.Common.CACHE_LARGE_MESSAGE_CLIENT,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CLIENT_ID,
ConnectionFactoryAttributes.Common.DUPS_OK_BATCH_SIZE,
ConnectionFactoryAttributes.Common.TRANSACTION_BATCH_SIZE,
ConnectionFactoryAttributes.Common.BLOCK_ON_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.BLOCK_ON_NON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.BLOCK_ON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.AUTO_GROUP,
ConnectionFactoryAttributes.Common.PRE_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL_MULTIPLIER,
CommonAttributes.MAX_RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RECONNECT_ATTEMPTS,
ConnectionFactoryAttributes.Common.FAILOVER_ON_INITIAL_CONNECTION,
ConnectionFactoryAttributes.Common.CONNECTION_LOAD_BALANCING_CLASS_NAME,
ConnectionFactoryAttributes.Common.USE_GLOBAL_POOLS,
ConnectionFactoryAttributes.Common.SCHEDULED_THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.GROUP_ID,
ConnectionFactoryAttributes.Common.DESERIALIZATION_BLACKLIST,
ConnectionFactoryAttributes.Common.DESERIALIZATION_WHITELIST,
ConnectionFactoryAttributes.Common.INITIAL_MESSAGE_PACKET_SIZE,
ConnectionFactoryAttributes.Regular.FACTORY_TYPE,
ConnectionFactoryAttributes.Common.USE_TOPOLOGY))
.addChild(
builder(MessagingExtension.LEGACY_CONNECTION_FACTORY_PATH)
.addAttributes(
LegacyConnectionFactoryDefinition.ENTRIES,
LegacyConnectionFactoryDefinition.DISCOVERY_GROUP,
LegacyConnectionFactoryDefinition.CONNECTORS,
LegacyConnectionFactoryDefinition.AUTO_GROUP,
LegacyConnectionFactoryDefinition.BLOCK_ON_ACKNOWLEDGE,
LegacyConnectionFactoryDefinition.BLOCK_ON_DURABLE_SEND,
LegacyConnectionFactoryDefinition.BLOCK_ON_NON_DURABLE_SEND,
CommonAttributes.CALL_TIMEOUT,
CommonAttributes.CALL_FAILOVER_TIMEOUT,
LegacyConnectionFactoryDefinition.CACHE_LARGE_MESSAGE_CLIENT,
LegacyConnectionFactoryDefinition.CLIENT_FAILURE_CHECK_PERIOD,
CommonAttributes.CLIENT_ID,
LegacyConnectionFactoryDefinition.COMPRESS_LARGE_MESSAGES,
LegacyConnectionFactoryDefinition.CONFIRMATION_WINDOW_SIZE,
LegacyConnectionFactoryDefinition.CONNECTION_LOAD_BALANCING_CLASS_NAME,
LegacyConnectionFactoryDefinition.CONNECTION_TTL,
LegacyConnectionFactoryDefinition.CONSUMER_MAX_RATE,
LegacyConnectionFactoryDefinition.CONSUMER_WINDOW_SIZE,
LegacyConnectionFactoryDefinition.DUPS_OK_BATCH_SIZE,
LegacyConnectionFactoryDefinition.FACTORY_TYPE,
LegacyConnectionFactoryDefinition.FAILOVER_ON_INITIAL_CONNECTION,
LegacyConnectionFactoryDefinition.GROUP_ID,
LegacyConnectionFactoryDefinition.INITIAL_CONNECT_ATTEMPTS,
LegacyConnectionFactoryDefinition.INITIAL_MESSAGE_PACKET_SIZE,
LegacyConnectionFactoryDefinition.HA,
LegacyConnectionFactoryDefinition.MAX_RETRY_INTERVAL,
LegacyConnectionFactoryDefinition.MIN_LARGE_MESSAGE_SIZE,
LegacyConnectionFactoryDefinition.PRE_ACKNOWLEDGE,
LegacyConnectionFactoryDefinition.PRODUCER_MAX_RATE,
LegacyConnectionFactoryDefinition.PRODUCER_WINDOW_SIZE,
LegacyConnectionFactoryDefinition.RECONNECT_ATTEMPTS,
LegacyConnectionFactoryDefinition.RETRY_INTERVAL,
LegacyConnectionFactoryDefinition.RETRY_INTERVAL_MULTIPLIER,
LegacyConnectionFactoryDefinition.SCHEDULED_THREAD_POOL_MAX_SIZE,
LegacyConnectionFactoryDefinition.THREAD_POOL_MAX_SIZE,
LegacyConnectionFactoryDefinition.TRANSACTION_BATCH_SIZE,
LegacyConnectionFactoryDefinition.USE_GLOBAL_POOLS))
.addChild(createPooledConnectionFactory(false)))
.addChild(
builder(MessagingExtension.JMS_BRIDGE_PATH)
.addAttributes(
JMSBridgeDefinition.MODULE,
JMSBridgeDefinition.QUALITY_OF_SERVICE,
JMSBridgeDefinition.FAILURE_RETRY_INTERVAL,
JMSBridgeDefinition.MAX_RETRIES,
JMSBridgeDefinition.MAX_BATCH_SIZE,
JMSBridgeDefinition.MAX_BATCH_TIME,
CommonAttributes.SELECTOR,
JMSBridgeDefinition.SUBSCRIPTION_NAME,
CommonAttributes.CLIENT_ID,
JMSBridgeDefinition.ADD_MESSAGE_ID_IN_HEADER,
JMSBridgeDefinition.SOURCE_CONNECTION_FACTORY,
JMSBridgeDefinition.SOURCE_DESTINATION,
JMSBridgeDefinition.SOURCE_USER,
JMSBridgeDefinition.SOURCE_PASSWORD,
JMSBridgeDefinition.SOURCE_CREDENTIAL_REFERENCE,
JMSBridgeDefinition.TARGET_CONNECTION_FACTORY,
JMSBridgeDefinition.TARGET_DESTINATION,
JMSBridgeDefinition.TARGET_USER,
JMSBridgeDefinition.TARGET_PASSWORD,
JMSBridgeDefinition.TARGET_CREDENTIAL_REFERENCE,
JMSBridgeDefinition.SOURCE_CONTEXT,
JMSBridgeDefinition.TARGET_CONTEXT))
.build();
}
private PersistentResourceXMLBuilder createPooledConnectionFactory(boolean external) {
PersistentResourceXMLBuilder builder = builder(MessagingExtension.POOLED_CONNECTION_FACTORY_PATH)
.addAttributes(
ConnectionFactoryAttributes.Common.ENTRIES,
// common
ConnectionFactoryAttributes.Common.DISCOVERY_GROUP,
ConnectionFactoryAttributes.Common.CONNECTORS,
CommonAttributes.HA,
ConnectionFactoryAttributes.Common.CLIENT_FAILURE_CHECK_PERIOD,
ConnectionFactoryAttributes.Common.CONNECTION_TTL,
CommonAttributes.CALL_TIMEOUT,
CommonAttributes.CALL_FAILOVER_TIMEOUT,
ConnectionFactoryAttributes.Common.CONSUMER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.CONSUMER_MAX_RATE,
ConnectionFactoryAttributes.Common.CONFIRMATION_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_MAX_RATE,
ConnectionFactoryAttributes.Common.PROTOCOL_MANAGER_FACTORY,
ConnectionFactoryAttributes.Common.COMPRESS_LARGE_MESSAGES,
ConnectionFactoryAttributes.Common.CACHE_LARGE_MESSAGE_CLIENT,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CLIENT_ID,
ConnectionFactoryAttributes.Common.DUPS_OK_BATCH_SIZE,
ConnectionFactoryAttributes.Common.TRANSACTION_BATCH_SIZE,
ConnectionFactoryAttributes.Common.BLOCK_ON_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.BLOCK_ON_NON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.BLOCK_ON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.AUTO_GROUP,
ConnectionFactoryAttributes.Common.PRE_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL_MULTIPLIER,
CommonAttributes.MAX_RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RECONNECT_ATTEMPTS,
ConnectionFactoryAttributes.Common.FAILOVER_ON_INITIAL_CONNECTION,
ConnectionFactoryAttributes.Common.CONNECTION_LOAD_BALANCING_CLASS_NAME,
ConnectionFactoryAttributes.Common.USE_GLOBAL_POOLS,
ConnectionFactoryAttributes.Common.SCHEDULED_THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.GROUP_ID,
ConnectionFactoryAttributes.Common.DESERIALIZATION_BLACKLIST,
ConnectionFactoryAttributes.Common.DESERIALIZATION_WHITELIST,
ConnectionFactoryAttributes.Common.USE_TOPOLOGY,
// pooled
// inbound config
ConnectionFactoryAttributes.Pooled.USE_JNDI,
ConnectionFactoryAttributes.Pooled.JNDI_PARAMS,
ConnectionFactoryAttributes.Pooled.REBALANCE_CONNECTIONS,
ConnectionFactoryAttributes.Pooled.USE_LOCAL_TX,
ConnectionFactoryAttributes.Pooled.SETUP_ATTEMPTS,
ConnectionFactoryAttributes.Pooled.SETUP_INTERVAL,
// outbound config
ConnectionFactoryAttributes.Pooled.ALLOW_LOCAL_TRANSACTIONS,
ConnectionFactoryAttributes.Pooled.TRANSACTION,
ConnectionFactoryAttributes.Pooled.USER,
ConnectionFactoryAttributes.Pooled.PASSWORD,
ConnectionFactoryAttributes.Pooled.CREDENTIAL_REFERENCE,
ConnectionFactoryAttributes.Pooled.MIN_POOL_SIZE,
ConnectionFactoryAttributes.Pooled.USE_AUTO_RECOVERY,
ConnectionFactoryAttributes.Pooled.MAX_POOL_SIZE,
ConnectionFactoryAttributes.Pooled.MANAGED_CONNECTION_POOL,
ConnectionFactoryAttributes.Pooled.ENLISTMENT_TRACE,
ConnectionFactoryAttributes.Common.INITIAL_MESSAGE_PACKET_SIZE,
ConnectionFactoryAttributes.Pooled.INITIAL_CONNECT_ATTEMPTS,
ConnectionFactoryAttributes.Pooled.STATISTICS_ENABLED);
if (external) {
builder.addAttributes(ConnectionFactoryAttributes.External.ENABLE_AMQ1_PREFIX);
}
return builder;
}
}
| 56,530
| 79.52849
| 128
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/AddressSettingDefinition.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import static org.jboss.as.controller.SimpleAttributeDefinitionBuilder.create;
import static org.jboss.as.controller.client.helpers.MeasurementUnit.BYTES;
import static org.jboss.as.controller.client.helpers.MeasurementUnit.DAYS;
import static org.jboss.as.controller.client.helpers.MeasurementUnit.MILLISECONDS;
import static org.jboss.as.controller.client.helpers.MeasurementUnit.SECONDS;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.DEAD_LETTER_ADDRESS;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.EXPIRY_ADDRESS;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.VERSION_3_0_0;
import java.util.Arrays;
import java.util.Collection;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.operations.validation.EnumValidator;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
/**
* Address setting resource definition
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat Inc.
*/
public class AddressSettingDefinition extends PersistentResourceDefinition {
public static final SimpleAttributeDefinition AUTO_CREATE_ADDRESSES = create("auto-create-addresses", ModelType.BOOLEAN)
.setDefaultValue(ModelNode.TRUE)
.setRequired(false)
.setAllowExpression(true)
.build();
public static final SimpleAttributeDefinition AUTO_DELETE_ADDRESSES = create("auto-delete-addresses", ModelType.BOOLEAN)
.setDefaultValue(ModelNode.TRUE)
.setRequired(false)
.setAllowExpression(true)
.build();
// Property exists in Artemis 2 but is no longer honoured
@Deprecated
public static final SimpleAttributeDefinition AUTO_CREATE_JMS_QUEUES = create("auto-create-jms-queues", ModelType.BOOLEAN)
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setAllowExpression(true)
.setDeprecated(VERSION_3_0_0)
.build();
// Property exists in Artemis 2 but is no longer honoured
@Deprecated
public static final SimpleAttributeDefinition AUTO_DELETE_JMS_QUEUES = create("auto-delete-jms-queues", ModelType.BOOLEAN)
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setAllowExpression(true)
.setDeprecated(VERSION_3_0_0)
.build();
public static final SimpleAttributeDefinition AUTO_CREATE_QUEUES = create("auto-create-queues", ModelType.BOOLEAN)
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setAllowExpression(true)
.build();
public static final SimpleAttributeDefinition AUTO_DELETE_CREATED_QUEUES = create("auto-delete-created-queues", ModelType.BOOLEAN)
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setAllowExpression(true)
.build();
public static final SimpleAttributeDefinition AUTO_DELETE_QUEUES = create("auto-delete-queues", ModelType.BOOLEAN)
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setAllowExpression(true)
.build();
public static final SimpleAttributeDefinition ADDRESS_FULL_MESSAGE_POLICY = create("address-full-policy", ModelType.STRING)
.setDefaultValue(new ModelNode(AddressFullMessagePolicy.PAGE.toString()))
.setValidator(EnumValidator.create(AddressFullMessagePolicy.class))
.setRequired(false)
.setAllowExpression(true)
.build();
public static final SimpleAttributeDefinition EXPIRY_DELAY = create("expiry-delay", ModelType.LONG)
.setDefaultValue(new ModelNode(-1L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.build();
public static final SimpleAttributeDefinition LAST_VALUE_QUEUE = create("last-value-queue", ModelType.BOOLEAN)
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setAllowExpression(true)
.build();
public static final SimpleAttributeDefinition MAX_DELIVERY_ATTEMPTS = create("max-delivery-attempts", ModelType.INT)
.setDefaultValue(new ModelNode(10))
.setRequired(false)
.setAllowExpression(true)
.build();
public static final SimpleAttributeDefinition MAX_REDELIVERY_DELAY = create("max-redelivery-delay", ModelType.LONG)
.setDefaultValue(ModelNode.ZERO_LONG)
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.build();
public static final SimpleAttributeDefinition MAX_SIZE_BYTES = create("max-size-bytes", ModelType.LONG)
.setDefaultValue(new ModelNode(-1L))
.setMeasurementUnit(BYTES)
.setRequired(false)
.setAllowExpression(true)
.build();
public static final SimpleAttributeDefinition MESSAGE_COUNTER_HISTORY_DAY_LIMIT = create("message-counter-history-day-limit", ModelType.INT)
.setDefaultValue(ModelNode.ZERO)
.setMeasurementUnit(DAYS)
.setRequired(false)
.setAllowExpression(true)
.build();
public static final SimpleAttributeDefinition PAGE_MAX_CACHE_SIZE = create("page-max-cache-size", ModelType.INT)
.setDefaultValue(new ModelNode(5))
.setRequired(false)
.setAllowExpression(true)
.build();
public static final SimpleAttributeDefinition PAGE_SIZE_BYTES = create("page-size-bytes", ModelType.INT)
.setDefaultValue(new ModelNode(10 * 1024 * 1024))
.setMeasurementUnit(BYTES)
.setRequired(false)
.setAllowExpression(true)
.build();
public static final SimpleAttributeDefinition REDELIVERY_DELAY = create("redelivery-delay", ModelType.LONG)
.setDefaultValue(ModelNode.ZERO_LONG)
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.build();
public static final SimpleAttributeDefinition REDELIVERY_MULTIPLIER = create("redelivery-multiplier", ModelType.DOUBLE)
.setDefaultValue(new ModelNode(1.0d))
.setRequired(false)
.setAllowExpression(true)
.build();
public static final SimpleAttributeDefinition REDISTRIBUTION_DELAY = create("redistribution-delay", ModelType.LONG)
.setDefaultValue(new ModelNode(-1L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.build();
public static final SimpleAttributeDefinition SEND_TO_DLA_ON_NO_ROUTE = create("send-to-dla-on-no-route", ModelType.BOOLEAN)
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setAllowExpression(true)
.build();
public static final SimpleAttributeDefinition SLOW_CONSUMER_CHECK_PERIOD = create("slow-consumer-check-period", ModelType.LONG)
.setDefaultValue(new ModelNode(5L))
.setMeasurementUnit(SECONDS)
.setRequired(false)
.setAllowExpression(true)
.build();
public static final SimpleAttributeDefinition SLOW_CONSUMER_POLICY = create("slow-consumer-policy", ModelType.STRING)
.setDefaultValue(new ModelNode(SlowConsumerPolicy.NOTIFY.toString()))
.setValidator(EnumValidator.create(SlowConsumerPolicy.class))
.setRequired(false)
.setAllowExpression(true)
.build();
public static final SimpleAttributeDefinition SLOW_CONSUMER_THRESHOLD = create("slow-consumer-threshold", ModelType.LONG)
.setDefaultValue(new ModelNode(-1L))
.setRequired(false)
.setAllowExpression(true)
.build();
/**
* Attributes are defined in the <em>same order than in the XSD schema</em>
*/
static final AttributeDefinition[] ATTRIBUTES = new SimpleAttributeDefinition[] {
DEAD_LETTER_ADDRESS,
EXPIRY_ADDRESS,
EXPIRY_DELAY,
REDELIVERY_DELAY,
REDELIVERY_MULTIPLIER,
MAX_DELIVERY_ATTEMPTS,
MAX_REDELIVERY_DELAY,
MAX_SIZE_BYTES,
PAGE_SIZE_BYTES,
PAGE_MAX_CACHE_SIZE,
ADDRESS_FULL_MESSAGE_POLICY,
MESSAGE_COUNTER_HISTORY_DAY_LIMIT,
LAST_VALUE_QUEUE,
REDISTRIBUTION_DELAY,
SEND_TO_DLA_ON_NO_ROUTE,
SLOW_CONSUMER_CHECK_PERIOD,
SLOW_CONSUMER_POLICY,
SLOW_CONSUMER_THRESHOLD,
AUTO_CREATE_JMS_QUEUES,
AUTO_DELETE_JMS_QUEUES,
AUTO_CREATE_ADDRESSES,
AUTO_DELETE_ADDRESSES,
AUTO_CREATE_QUEUES,
AUTO_DELETE_QUEUES,
AUTO_DELETE_CREATED_QUEUES
};
AddressSettingDefinition() {
super(MessagingExtension.ADDRESS_SETTING_PATH,
MessagingExtension.getResourceDescriptionResolver(CommonAttributes.ADDRESS_SETTING),
AddressSettingAdd.INSTANCE,
AddressSettingRemove.INSTANCE);
}
@Override
public void registerAttributes(ManagementResourceRegistration registry) {
for (AttributeDefinition attr : ATTRIBUTES) {
if (!attr.getFlags().contains(AttributeAccess.Flag.STORAGE_RUNTIME)) {
registry.registerReadWriteAttribute(attr, null, AddressSettingsWriteHandler.INSTANCE);
}
}
}
@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(ATTRIBUTES);
}
private enum AddressFullMessagePolicy {
DROP, PAGE, BLOCK, FAIL;
}
private enum SlowConsumerPolicy {
KILL, NOTIFY;
}
}
| 11,266
| 40.72963
| 144
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/MessagingSubsystemParser_15_0.java
|
/*
* Copyright 2020 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.extension.messaging.activemq;
import static org.jboss.as.controller.PathElement.pathElement;
import static org.jboss.as.controller.PersistentResourceXMLDescription.builder;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.ACCEPTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.CONNECTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.IN_VM_ACCEPTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.IN_VM_CONNECTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.REMOTE_ACCEPTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.REMOTE_CONNECTOR;
import org.jboss.as.controller.PersistentResourceXMLDescription;
import org.jboss.as.controller.PersistentResourceXMLParser;
import org.jboss.as.controller.PersistentResourceXMLDescription.PersistentResourceXMLBuilder;
import org.wildfly.extension.messaging.activemq.ha.HAAttributes;
import org.wildfly.extension.messaging.activemq.ha.ScaleDownAttributes;
import org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes;
import org.wildfly.extension.messaging.activemq.jms.bridge.JMSBridgeDefinition;
import org.wildfly.extension.messaging.activemq.jms.legacy.LegacyConnectionFactoryDefinition;
public class MessagingSubsystemParser_15_0 extends PersistentResourceXMLParser {
static final String NAMESPACE = "urn:jboss:domain:messaging-activemq:15.0";
@Override
public PersistentResourceXMLDescription getParserDescription() {
final PersistentResourceXMLBuilder jgroupDiscoveryGroup = builder(JGroupsDiscoveryGroupDefinition.PATH)
.addAttributes(
DiscoveryGroupDefinition.JGROUPS_CHANNEL_FACTORY,
DiscoveryGroupDefinition.JGROUPS_CHANNEL,
CommonAttributes.JGROUPS_CLUSTER,
DiscoveryGroupDefinition.REFRESH_TIMEOUT,
DiscoveryGroupDefinition.INITIAL_WAIT_TIMEOUT);
final PersistentResourceXMLBuilder socketDiscoveryGroup = builder(SocketDiscoveryGroupDefinition.PATH)
.addAttributes(
CommonAttributes.SOCKET_BINDING,
DiscoveryGroupDefinition.REFRESH_TIMEOUT,
DiscoveryGroupDefinition.INITIAL_WAIT_TIMEOUT);
final PersistentResourceXMLBuilder remoteConnector = builder(pathElement(REMOTE_CONNECTOR))
.addAttributes(
RemoteTransportDefinition.SOCKET_BINDING,
CommonAttributes.PARAMS,
CommonAttributes.SSL_CONTEXT);
final PersistentResourceXMLBuilder httpConnector = builder(MessagingExtension.HTTP_CONNECTOR_PATH)
.addAttributes(
HTTPConnectorDefinition.SOCKET_BINDING,
HTTPConnectorDefinition.ENDPOINT,
HTTPConnectorDefinition.SERVER_NAME,
CommonAttributes.PARAMS,
CommonAttributes.SSL_CONTEXT);
final PersistentResourceXMLBuilder invmConnector = builder(pathElement(IN_VM_CONNECTOR))
.addAttributes(
InVMTransportDefinition.SERVER_ID,
CommonAttributes.PARAMS);
final PersistentResourceXMLBuilder connector = builder(pathElement(CONNECTOR))
.addAttributes(
GenericTransportDefinition.SOCKET_BINDING,
CommonAttributes.FACTORY_CLASS,
CommonAttributes.PARAMS);
return builder(MessagingExtension.SUBSYSTEM_PATH, NAMESPACE)
.addAttributes(
MessagingSubsystemRootResourceDefinition.GLOBAL_CLIENT_THREAD_POOL_MAX_SIZE,
MessagingSubsystemRootResourceDefinition.GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_MAX_SIZE)
.addChild(httpConnector)
.addChild(remoteConnector)
.addChild(invmConnector)
.addChild(connector)
.addChild(jgroupDiscoveryGroup)
.addChild(socketDiscoveryGroup)
.addChild(builder(MessagingExtension.CONNECTION_FACTORY_PATH)
.addAttributes(
CommonAttributes.HA,
ConnectionFactoryAttributes.Regular.FACTORY_TYPE,
ConnectionFactoryAttributes.Common.DISCOVERY_GROUP,
ConnectionFactoryAttributes.Common.CONNECTORS,
ConnectionFactoryAttributes.Common.ENTRIES,
ConnectionFactoryAttributes.External.ENABLE_AMQ1_PREFIX,
ConnectionFactoryAttributes.Common.USE_TOPOLOGY,
// common
ConnectionFactoryAttributes.Common.CLIENT_FAILURE_CHECK_PERIOD,
ConnectionFactoryAttributes.Common.CONNECTION_TTL,
CommonAttributes.CALL_TIMEOUT,
CommonAttributes.CALL_FAILOVER_TIMEOUT,
ConnectionFactoryAttributes.Common.CONSUMER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.CONSUMER_MAX_RATE,
ConnectionFactoryAttributes.Common.CONFIRMATION_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_MAX_RATE,
ConnectionFactoryAttributes.Common.PROTOCOL_MANAGER_FACTORY,
ConnectionFactoryAttributes.Common.COMPRESS_LARGE_MESSAGES,
ConnectionFactoryAttributes.Common.CACHE_LARGE_MESSAGE_CLIENT,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CLIENT_ID,
ConnectionFactoryAttributes.Common.DUPS_OK_BATCH_SIZE,
ConnectionFactoryAttributes.Common.TRANSACTION_BATCH_SIZE,
ConnectionFactoryAttributes.Common.BLOCK_ON_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.BLOCK_ON_NON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.BLOCK_ON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.AUTO_GROUP,
ConnectionFactoryAttributes.Common.PRE_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL_MULTIPLIER,
CommonAttributes.MAX_RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RECONNECT_ATTEMPTS,
ConnectionFactoryAttributes.Common.FAILOVER_ON_INITIAL_CONNECTION,
ConnectionFactoryAttributes.Common.CONNECTION_LOAD_BALANCING_CLASS_NAME,
ConnectionFactoryAttributes.Common.USE_GLOBAL_POOLS,
ConnectionFactoryAttributes.Common.SCHEDULED_THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.GROUP_ID,
ConnectionFactoryAttributes.Common.DESERIALIZATION_BLOCKLIST,
ConnectionFactoryAttributes.Common.DESERIALIZATION_ALLOWLIST,
ConnectionFactoryAttributes.Common.INITIAL_MESSAGE_PACKET_SIZE
))
.addChild(createPooledConnectionFactory(true))
.addChild(builder(MessagingExtension.EXTERNAL_JMS_QUEUE_PATH)
.addAttributes(
ConnectionFactoryAttributes.Common.ENTRIES,
ConnectionFactoryAttributes.External.ENABLE_AMQ1_PREFIX
))
.addChild(builder(MessagingExtension.EXTERNAL_JMS_TOPIC_PATH)
.addAttributes(
ConnectionFactoryAttributes.Common.ENTRIES,
ConnectionFactoryAttributes.External.ENABLE_AMQ1_PREFIX
))
.addChild(builder(MessagingExtension.SERVER_PATH)
.addAttributes(// no attribute groups
ServerDefinition.PERSISTENCE_ENABLED,
ServerDefinition.PERSIST_ID_CACHE,
ServerDefinition.PERSIST_DELIVERY_COUNT_BEFORE_DELIVERY,
ServerDefinition.ID_CACHE_SIZE,
ServerDefinition.PAGE_MAX_CONCURRENT_IO,
ServerDefinition.SCHEDULED_THREAD_POOL_MAX_SIZE,
ServerDefinition.THREAD_POOL_MAX_SIZE,
ServerDefinition.WILD_CARD_ROUTING_ENABLED,
ServerDefinition.CONNECTION_TTL_OVERRIDE,
ServerDefinition.ASYNC_CONNECTION_EXECUTION_ENABLED,
ServerDefinition.ADDRESS_QUEUE_SCAN_PERIOD,
// security
ServerDefinition.SECURITY_ENABLED,
ServerDefinition.SECURITY_DOMAIN,
ServerDefinition.ELYTRON_DOMAIN,
ServerDefinition.SECURITY_INVALIDATION_INTERVAL,
ServerDefinition.OVERRIDE_IN_VM_SECURITY,
// cluster
ServerDefinition.CLUSTER_USER,
ServerDefinition.CLUSTER_PASSWORD,
ServerDefinition.CREDENTIAL_REFERENCE,
// management
ServerDefinition.MANAGEMENT_ADDRESS,
ServerDefinition.MANAGEMENT_NOTIFICATION_ADDRESS,
ServerDefinition.JMX_MANAGEMENT_ENABLED,
ServerDefinition.JMX_DOMAIN,
// journal
ServerDefinition.JOURNAL_TYPE,
ServerDefinition.JOURNAL_BUFFER_TIMEOUT,
ServerDefinition.JOURNAL_BUFFER_SIZE,
ServerDefinition.JOURNAL_SYNC_TRANSACTIONAL,
ServerDefinition.JOURNAL_SYNC_NON_TRANSACTIONAL,
ServerDefinition.LOG_JOURNAL_WRITE_RATE,
ServerDefinition.JOURNAL_FILE_SIZE,
ServerDefinition.JOURNAL_MIN_FILES,
ServerDefinition.JOURNAL_POOL_FILES,
ServerDefinition.JOURNAL_FILE_OPEN_TIMEOUT,
ServerDefinition.JOURNAL_COMPACT_PERCENTAGE,
ServerDefinition.JOURNAL_COMPACT_MIN_FILES,
ServerDefinition.JOURNAL_MAX_IO,
ServerDefinition.JOURNAL_MAX_ATTIC_FILES,
ServerDefinition.CREATE_BINDINGS_DIR,
ServerDefinition.CREATE_JOURNAL_DIR,
ServerDefinition.JOURNAL_DATASOURCE,
ServerDefinition.JOURNAL_MESSAGES_TABLE,
ServerDefinition.JOURNAL_BINDINGS_TABLE,
ServerDefinition.JOURNAL_JMS_BINDINGS_TABLE,
ServerDefinition.JOURNAL_LARGE_MESSAGES_TABLE,
ServerDefinition.JOURNAL_PAGE_STORE_TABLE,
ServerDefinition.JOURNAL_NODE_MANAGER_STORE_TABLE,
ServerDefinition.JOURNAL_DATABASE,
ServerDefinition.JOURNAL_JDBC_LOCK_EXPIRATION,
ServerDefinition.JOURNAL_JDBC_LOCK_RENEW_PERIOD,
ServerDefinition.JOURNAL_JDBC_NETWORK_TIMEOUT,
ServerDefinition.GLOBAL_MAX_DISK_USAGE,
ServerDefinition.DISK_SCAN_PERIOD,
ServerDefinition.GLOBAL_MAX_MEMORY_SIZE,
// statistics
ServerDefinition.STATISTICS_ENABLED,
ServerDefinition.MESSAGE_COUNTER_SAMPLE_PERIOD,
ServerDefinition.MESSAGE_COUNTER_MAX_DAY_HISTORY,
// transaction
ServerDefinition.TRANSACTION_TIMEOUT,
ServerDefinition.TRANSACTION_TIMEOUT_SCAN_PERIOD,
// message expiry
ServerDefinition.MESSAGE_EXPIRY_SCAN_PERIOD,
ServerDefinition.MESSAGE_EXPIRY_THREAD_PRIORITY,
// debug
ServerDefinition.PERF_BLAST_PAGES,
ServerDefinition.RUN_SYNC_SPEED_TEST,
ServerDefinition.SERVER_DUMP_INTERVAL,
ServerDefinition.MEMORY_MEASURE_INTERVAL,
ServerDefinition.MEMORY_WARNING_THRESHOLD,
CommonAttributes.INCOMING_INTERCEPTORS,
CommonAttributes.OUTGOING_INTERCEPTORS,
//Network Isolation
ServerDefinition.NETWORK_CHECK_LIST,
ServerDefinition.NETWORK_CHECK_NIC,
ServerDefinition.NETWORK_CHECK_PERIOD,
ServerDefinition.NETWORK_CHECK_PING6_COMMAND,
ServerDefinition.NETWORK_CHECK_PING_COMMAND,
ServerDefinition.NETWORK_CHECK_TIMEOUT,
ServerDefinition.NETWORK_CHECK_URL_LIST,
ServerDefinition.CRITICAL_ANALYZER_ENABLED,
ServerDefinition.CRITICAL_ANALYZER_CHECK_PERIOD,
ServerDefinition.CRITICAL_ANALYZER_POLICY,
ServerDefinition.CRITICAL_ANALYZER_TIMEOUT)
.addChild(
builder(MessagingExtension.LIVE_ONLY_PATH)
.addAttributes(
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS))
.addChild(builder(MessagingExtension.REPLICATION_PRIMARY_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.CHECK_FOR_LIVE_SERVER,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT))
.addChild(builder(MessagingExtension.REPLICATION_SECONDARY_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.ALLOW_FAILBACK,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT,
HAAttributes.MAX_SAVED_REPLICATED_JOURNAL_SIZE,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS))
.addChild(builder(MessagingExtension.REPLICATION_COLOCATED_PATH)
.addAttributes(
HAAttributes.REQUEST_BACKUP,
HAAttributes.BACKUP_REQUEST_RETRIES,
HAAttributes.BACKUP_REQUEST_RETRY_INTERVAL,
HAAttributes.MAX_BACKUPS,
HAAttributes.BACKUP_PORT_OFFSET,
HAAttributes.EXCLUDED_CONNECTORS)
.addChild(builder(MessagingExtension.CONFIGURATION_PRIMARY_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.CHECK_FOR_LIVE_SERVER,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT))
.addChild(builder(MessagingExtension.CONFIGURATION_SECONDARY_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.ALLOW_FAILBACK,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT,
HAAttributes.MAX_SAVED_REPLICATED_JOURNAL_SIZE,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS)))
.addChild(builder(MessagingExtension.SHARED_STORE_PRIMARY_PATH)
.addAttributes(
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN))
.addChild(builder(MessagingExtension.SHARED_STORE_SECONDARY_PATH)
.addAttributes(
HAAttributes.ALLOW_FAILBACK,
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS))
.addChild(builder(MessagingExtension.SHARED_STORE_COLOCATED_PATH)
.addAttributes(
HAAttributes.REQUEST_BACKUP,
HAAttributes.BACKUP_REQUEST_RETRIES,
HAAttributes.BACKUP_REQUEST_RETRY_INTERVAL,
HAAttributes.MAX_BACKUPS,
HAAttributes.BACKUP_PORT_OFFSET)
.addChild(builder(MessagingExtension.CONFIGURATION_PRIMARY_PATH)
.addAttributes(
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN))
.addChild(builder(MessagingExtension.CONFIGURATION_SECONDARY_PATH)
.addAttributes(
HAAttributes.ALLOW_FAILBACK,
HAAttributes.FAILOVER_ON_SERVER_SHUTDOWN,
HAAttributes.RESTART_BACKUP,
ScaleDownAttributes.SCALE_DOWN,
ScaleDownAttributes.SCALE_DOWN_CLUSTER_NAME,
ScaleDownAttributes.SCALE_DOWN_GROUP_NAME,
ScaleDownAttributes.SCALE_DOWN_DISCOVERY_GROUP,
ScaleDownAttributes.SCALE_DOWN_CONNECTORS)))
.addChild(
builder(MessagingExtension.BINDINGS_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.BINDINGS_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.JOURNAL_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.JOURNAL_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.LARGE_MESSAGES_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.LARGE_MESSAGES_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.PAGING_DIRECTORY_PATH)
.addAttributes(
PathDefinition.PATHS.get(CommonAttributes.PAGING_DIRECTORY),
PathDefinition.RELATIVE_TO))
.addChild(
builder(MessagingExtension.QUEUE_PATH)
.addAttributes(QueueDefinition.ADDRESS,
CommonAttributes.DURABLE,
CommonAttributes.FILTER,
QueueDefinition.ROUTING_TYPE))
.addChild(
builder(MessagingExtension.SECURITY_SETTING_PATH)
.addChild(
builder(MessagingExtension.ROLE_PATH)
.addAttributes(
SecurityRoleDefinition.SEND,
SecurityRoleDefinition.CONSUME,
SecurityRoleDefinition.CREATE_DURABLE_QUEUE,
SecurityRoleDefinition.DELETE_DURABLE_QUEUE,
SecurityRoleDefinition.CREATE_NON_DURABLE_QUEUE,
SecurityRoleDefinition.DELETE_NON_DURABLE_QUEUE,
SecurityRoleDefinition.MANAGE)))
.addChild(
builder(MessagingExtension.ADDRESS_SETTING_PATH)
.addAttributes(
CommonAttributes.DEAD_LETTER_ADDRESS,
CommonAttributes.EXPIRY_ADDRESS,
AddressSettingDefinition.EXPIRY_DELAY,
AddressSettingDefinition.REDELIVERY_DELAY,
AddressSettingDefinition.REDELIVERY_MULTIPLIER,
AddressSettingDefinition.MAX_DELIVERY_ATTEMPTS,
AddressSettingDefinition.MAX_REDELIVERY_DELAY,
AddressSettingDefinition.MAX_SIZE_BYTES,
AddressSettingDefinition.PAGE_SIZE_BYTES,
AddressSettingDefinition.PAGE_MAX_CACHE_SIZE,
AddressSettingDefinition.ADDRESS_FULL_MESSAGE_POLICY,
AddressSettingDefinition.MESSAGE_COUNTER_HISTORY_DAY_LIMIT,
AddressSettingDefinition.LAST_VALUE_QUEUE,
AddressSettingDefinition.REDISTRIBUTION_DELAY,
AddressSettingDefinition.SEND_TO_DLA_ON_NO_ROUTE,
AddressSettingDefinition.SLOW_CONSUMER_CHECK_PERIOD,
AddressSettingDefinition.SLOW_CONSUMER_POLICY,
AddressSettingDefinition.SLOW_CONSUMER_THRESHOLD,
AddressSettingDefinition.AUTO_CREATE_JMS_QUEUES,
AddressSettingDefinition.AUTO_DELETE_JMS_QUEUES,
AddressSettingDefinition.AUTO_CREATE_QUEUES,
AddressSettingDefinition.AUTO_DELETE_QUEUES,
AddressSettingDefinition.AUTO_CREATE_ADDRESSES,
AddressSettingDefinition.AUTO_DELETE_ADDRESSES,
AddressSettingDefinition.AUTO_DELETE_CREATED_QUEUES))
.addChild(httpConnector)
.addChild(remoteConnector)
.addChild(invmConnector)
.addChild(connector)
.addChild(
builder(MessagingExtension.HTTP_ACCEPTOR_PATH)
.addAttributes(
HTTPAcceptorDefinition.HTTP_LISTENER,
HTTPAcceptorDefinition.UPGRADE_LEGACY,
CommonAttributes.PARAMS,
CommonAttributes.SSL_CONTEXT))
.addChild(
builder(pathElement(REMOTE_ACCEPTOR))
.addAttributes(
RemoteTransportDefinition.SOCKET_BINDING,
CommonAttributes.PARAMS,
CommonAttributes.SSL_CONTEXT))
.addChild(
builder(pathElement(IN_VM_ACCEPTOR))
.addAttributes(
InVMTransportDefinition.SERVER_ID,
CommonAttributes.PARAMS))
.addChild(
builder(pathElement(ACCEPTOR))
.addAttributes(
GenericTransportDefinition.SOCKET_BINDING,
CommonAttributes.FACTORY_CLASS,
CommonAttributes.PARAMS))
.addChild(
builder(MessagingExtension.JGROUPS_BROADCAST_GROUP_PATH)
.addAttributes(
BroadcastGroupDefinition.JGROUPS_CHANNEL_FACTORY,
BroadcastGroupDefinition.JGROUPS_CHANNEL,
CommonAttributes.JGROUPS_CLUSTER,
BroadcastGroupDefinition.BROADCAST_PERIOD,
BroadcastGroupDefinition.CONNECTOR_REFS))
.addChild(
builder(MessagingExtension.SOCKET_BROADCAST_GROUP_PATH)
.addAttributes(
CommonAttributes.SOCKET_BINDING,
BroadcastGroupDefinition.BROADCAST_PERIOD,
BroadcastGroupDefinition.CONNECTOR_REFS))
.addChild(jgroupDiscoveryGroup)
.addChild(socketDiscoveryGroup)
.addChild(
builder(MessagingExtension.CLUSTER_CONNECTION_PATH)
.addAttributes(
ClusterConnectionDefinition.ADDRESS,
ClusterConnectionDefinition.CONNECTOR_NAME,
ClusterConnectionDefinition.CHECK_PERIOD,
ClusterConnectionDefinition.CONNECTION_TTL,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CALL_TIMEOUT,
ClusterConnectionDefinition.CALL_FAILOVER_TIMEOUT,
ClusterConnectionDefinition.RETRY_INTERVAL,
ClusterConnectionDefinition.RETRY_INTERVAL_MULTIPLIER,
ClusterConnectionDefinition.MAX_RETRY_INTERVAL,
ClusterConnectionDefinition.INITIAL_CONNECT_ATTEMPTS,
ClusterConnectionDefinition.RECONNECT_ATTEMPTS,
ClusterConnectionDefinition.USE_DUPLICATE_DETECTION,
ClusterConnectionDefinition.MESSAGE_LOAD_BALANCING_TYPE,
ClusterConnectionDefinition.MAX_HOPS,
CommonAttributes.BRIDGE_CONFIRMATION_WINDOW_SIZE,
ClusterConnectionDefinition.PRODUCER_WINDOW_SIZE,
ClusterConnectionDefinition.NOTIFICATION_ATTEMPTS,
ClusterConnectionDefinition.NOTIFICATION_INTERVAL,
ClusterConnectionDefinition.CONNECTOR_REFS,
ClusterConnectionDefinition.ALLOW_DIRECT_CONNECTIONS_ONLY,
ClusterConnectionDefinition.DISCOVERY_GROUP_NAME))
.addChild(
builder(MessagingExtension.GROUPING_HANDLER_PATH)
.addAttributes(
GroupingHandlerDefinition.TYPE,
GroupingHandlerDefinition.GROUPING_HANDLER_ADDRESS,
GroupingHandlerDefinition.TIMEOUT,
GroupingHandlerDefinition.GROUP_TIMEOUT,
GroupingHandlerDefinition.REAPER_PERIOD))
.addChild(
builder(DivertDefinition.PATH)
.addAttributes(
DivertDefinition.ROUTING_NAME,
DivertDefinition.ADDRESS,
DivertDefinition.FORWARDING_ADDRESS,
CommonAttributes.FILTER,
CommonAttributes.TRANSFORMER_CLASS_NAME,
DivertDefinition.EXCLUSIVE))
.addChild(
builder(MessagingExtension.BRIDGE_PATH)
.addAttributes(
BridgeDefinition.ATTRIBUTES
))
.addChild(
builder(MessagingExtension.CONNECTOR_SERVICE_PATH)
.addAttributes(
CommonAttributes.FACTORY_CLASS,
CommonAttributes.PARAMS))
.addChild(
builder(MessagingExtension.JMS_QUEUE_PATH)
.addAttributes(
CommonAttributes.DESTINATION_ENTRIES,
CommonAttributes.SELECTOR,
CommonAttributes.DURABLE,
CommonAttributes.LEGACY_ENTRIES))
.addChild(
builder(MessagingExtension.JMS_TOPIC_PATH)
.addAttributes(
CommonAttributes.DESTINATION_ENTRIES,
CommonAttributes.LEGACY_ENTRIES))
.addChild(
builder(MessagingExtension.CONNECTION_FACTORY_PATH)
.addAttributes(
ConnectionFactoryAttributes.Common.ENTRIES,
// common
ConnectionFactoryAttributes.Common.DISCOVERY_GROUP,
ConnectionFactoryAttributes.Common.CONNECTORS,
CommonAttributes.HA,
ConnectionFactoryAttributes.Common.CLIENT_FAILURE_CHECK_PERIOD,
ConnectionFactoryAttributes.Common.CONNECTION_TTL,
CommonAttributes.CALL_TIMEOUT,
CommonAttributes.CALL_FAILOVER_TIMEOUT,
ConnectionFactoryAttributes.Common.CONSUMER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.CONSUMER_MAX_RATE,
ConnectionFactoryAttributes.Common.CONFIRMATION_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_MAX_RATE,
ConnectionFactoryAttributes.Common.PROTOCOL_MANAGER_FACTORY,
ConnectionFactoryAttributes.Common.COMPRESS_LARGE_MESSAGES,
ConnectionFactoryAttributes.Common.CACHE_LARGE_MESSAGE_CLIENT,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CLIENT_ID,
ConnectionFactoryAttributes.Common.DUPS_OK_BATCH_SIZE,
ConnectionFactoryAttributes.Common.TRANSACTION_BATCH_SIZE,
ConnectionFactoryAttributes.Common.BLOCK_ON_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.BLOCK_ON_NON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.BLOCK_ON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.AUTO_GROUP,
ConnectionFactoryAttributes.Common.PRE_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL_MULTIPLIER,
CommonAttributes.MAX_RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RECONNECT_ATTEMPTS,
ConnectionFactoryAttributes.Common.FAILOVER_ON_INITIAL_CONNECTION,
ConnectionFactoryAttributes.Common.CONNECTION_LOAD_BALANCING_CLASS_NAME,
ConnectionFactoryAttributes.Common.USE_GLOBAL_POOLS,
ConnectionFactoryAttributes.Common.SCHEDULED_THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.GROUP_ID,
ConnectionFactoryAttributes.Common.DESERIALIZATION_BLOCKLIST,
ConnectionFactoryAttributes.Common.DESERIALIZATION_ALLOWLIST,
ConnectionFactoryAttributes.Common.INITIAL_MESSAGE_PACKET_SIZE,
ConnectionFactoryAttributes.Regular.FACTORY_TYPE,
ConnectionFactoryAttributes.Common.USE_TOPOLOGY))
.addChild(
builder(MessagingExtension.LEGACY_CONNECTION_FACTORY_PATH)
.addAttributes(
LegacyConnectionFactoryDefinition.ENTRIES,
LegacyConnectionFactoryDefinition.DISCOVERY_GROUP,
LegacyConnectionFactoryDefinition.CONNECTORS,
LegacyConnectionFactoryDefinition.AUTO_GROUP,
LegacyConnectionFactoryDefinition.BLOCK_ON_ACKNOWLEDGE,
LegacyConnectionFactoryDefinition.BLOCK_ON_DURABLE_SEND,
LegacyConnectionFactoryDefinition.BLOCK_ON_NON_DURABLE_SEND,
CommonAttributes.CALL_TIMEOUT,
CommonAttributes.CALL_FAILOVER_TIMEOUT,
LegacyConnectionFactoryDefinition.CACHE_LARGE_MESSAGE_CLIENT,
LegacyConnectionFactoryDefinition.CLIENT_FAILURE_CHECK_PERIOD,
CommonAttributes.CLIENT_ID,
LegacyConnectionFactoryDefinition.COMPRESS_LARGE_MESSAGES,
LegacyConnectionFactoryDefinition.CONFIRMATION_WINDOW_SIZE,
LegacyConnectionFactoryDefinition.CONNECTION_LOAD_BALANCING_CLASS_NAME,
LegacyConnectionFactoryDefinition.CONNECTION_TTL,
LegacyConnectionFactoryDefinition.CONSUMER_MAX_RATE,
LegacyConnectionFactoryDefinition.CONSUMER_WINDOW_SIZE,
LegacyConnectionFactoryDefinition.DUPS_OK_BATCH_SIZE,
LegacyConnectionFactoryDefinition.FACTORY_TYPE,
LegacyConnectionFactoryDefinition.FAILOVER_ON_INITIAL_CONNECTION,
LegacyConnectionFactoryDefinition.GROUP_ID,
LegacyConnectionFactoryDefinition.INITIAL_CONNECT_ATTEMPTS,
LegacyConnectionFactoryDefinition.INITIAL_MESSAGE_PACKET_SIZE,
LegacyConnectionFactoryDefinition.HA,
LegacyConnectionFactoryDefinition.MAX_RETRY_INTERVAL,
LegacyConnectionFactoryDefinition.MIN_LARGE_MESSAGE_SIZE,
LegacyConnectionFactoryDefinition.PRE_ACKNOWLEDGE,
LegacyConnectionFactoryDefinition.PRODUCER_MAX_RATE,
LegacyConnectionFactoryDefinition.PRODUCER_WINDOW_SIZE,
LegacyConnectionFactoryDefinition.RECONNECT_ATTEMPTS,
LegacyConnectionFactoryDefinition.RETRY_INTERVAL,
LegacyConnectionFactoryDefinition.RETRY_INTERVAL_MULTIPLIER,
LegacyConnectionFactoryDefinition.SCHEDULED_THREAD_POOL_MAX_SIZE,
LegacyConnectionFactoryDefinition.THREAD_POOL_MAX_SIZE,
LegacyConnectionFactoryDefinition.TRANSACTION_BATCH_SIZE,
LegacyConnectionFactoryDefinition.USE_GLOBAL_POOLS))
.addChild(createPooledConnectionFactory(false)))
.addChild(
builder(MessagingExtension.JMS_BRIDGE_PATH)
.addAttributes(
JMSBridgeDefinition.MODULE,
JMSBridgeDefinition.QUALITY_OF_SERVICE,
JMSBridgeDefinition.FAILURE_RETRY_INTERVAL,
JMSBridgeDefinition.MAX_RETRIES,
JMSBridgeDefinition.MAX_BATCH_SIZE,
JMSBridgeDefinition.MAX_BATCH_TIME,
CommonAttributes.SELECTOR,
JMSBridgeDefinition.SUBSCRIPTION_NAME,
CommonAttributes.CLIENT_ID,
JMSBridgeDefinition.ADD_MESSAGE_ID_IN_HEADER,
JMSBridgeDefinition.SOURCE_CONNECTION_FACTORY,
JMSBridgeDefinition.SOURCE_DESTINATION,
JMSBridgeDefinition.SOURCE_USER,
JMSBridgeDefinition.SOURCE_PASSWORD,
JMSBridgeDefinition.SOURCE_CREDENTIAL_REFERENCE,
JMSBridgeDefinition.TARGET_CONNECTION_FACTORY,
JMSBridgeDefinition.TARGET_DESTINATION,
JMSBridgeDefinition.TARGET_USER,
JMSBridgeDefinition.TARGET_PASSWORD,
JMSBridgeDefinition.TARGET_CREDENTIAL_REFERENCE,
JMSBridgeDefinition.SOURCE_CONTEXT,
JMSBridgeDefinition.TARGET_CONTEXT))
.build();
}
private PersistentResourceXMLBuilder createPooledConnectionFactory(boolean external) {
PersistentResourceXMLBuilder builder = builder(MessagingExtension.POOLED_CONNECTION_FACTORY_PATH)
.addAttributes(
ConnectionFactoryAttributes.Common.ENTRIES,
// common
ConnectionFactoryAttributes.Common.DISCOVERY_GROUP,
ConnectionFactoryAttributes.Common.CONNECTORS,
CommonAttributes.HA,
ConnectionFactoryAttributes.Common.CLIENT_FAILURE_CHECK_PERIOD,
ConnectionFactoryAttributes.Common.CONNECTION_TTL,
CommonAttributes.CALL_TIMEOUT,
CommonAttributes.CALL_FAILOVER_TIMEOUT,
ConnectionFactoryAttributes.Common.CONSUMER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.CONSUMER_MAX_RATE,
ConnectionFactoryAttributes.Common.CONFIRMATION_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_WINDOW_SIZE,
ConnectionFactoryAttributes.Common.PRODUCER_MAX_RATE,
ConnectionFactoryAttributes.Common.PROTOCOL_MANAGER_FACTORY,
ConnectionFactoryAttributes.Common.COMPRESS_LARGE_MESSAGES,
ConnectionFactoryAttributes.Common.CACHE_LARGE_MESSAGE_CLIENT,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CLIENT_ID,
ConnectionFactoryAttributes.Common.DUPS_OK_BATCH_SIZE,
ConnectionFactoryAttributes.Common.TRANSACTION_BATCH_SIZE,
ConnectionFactoryAttributes.Common.BLOCK_ON_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.BLOCK_ON_NON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.BLOCK_ON_DURABLE_SEND,
ConnectionFactoryAttributes.Common.AUTO_GROUP,
ConnectionFactoryAttributes.Common.PRE_ACKNOWLEDGE,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RETRY_INTERVAL_MULTIPLIER,
CommonAttributes.MAX_RETRY_INTERVAL,
ConnectionFactoryAttributes.Common.RECONNECT_ATTEMPTS,
ConnectionFactoryAttributes.Common.FAILOVER_ON_INITIAL_CONNECTION,
ConnectionFactoryAttributes.Common.CONNECTION_LOAD_BALANCING_CLASS_NAME,
ConnectionFactoryAttributes.Common.USE_GLOBAL_POOLS,
ConnectionFactoryAttributes.Common.SCHEDULED_THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.THREAD_POOL_MAX_SIZE,
ConnectionFactoryAttributes.Common.GROUP_ID,
ConnectionFactoryAttributes.Common.DESERIALIZATION_BLOCKLIST,
ConnectionFactoryAttributes.Common.DESERIALIZATION_ALLOWLIST,
ConnectionFactoryAttributes.Common.USE_TOPOLOGY,
// pooled
// inbound config
ConnectionFactoryAttributes.Pooled.USE_JNDI,
ConnectionFactoryAttributes.Pooled.JNDI_PARAMS,
ConnectionFactoryAttributes.Pooled.REBALANCE_CONNECTIONS,
ConnectionFactoryAttributes.Pooled.USE_LOCAL_TX,
ConnectionFactoryAttributes.Pooled.SETUP_ATTEMPTS,
ConnectionFactoryAttributes.Pooled.SETUP_INTERVAL,
// outbound config
ConnectionFactoryAttributes.Pooled.ALLOW_LOCAL_TRANSACTIONS,
ConnectionFactoryAttributes.Pooled.TRANSACTION,
ConnectionFactoryAttributes.Pooled.USER,
ConnectionFactoryAttributes.Pooled.PASSWORD,
ConnectionFactoryAttributes.Pooled.CREDENTIAL_REFERENCE,
ConnectionFactoryAttributes.Pooled.MIN_POOL_SIZE,
ConnectionFactoryAttributes.Pooled.USE_AUTO_RECOVERY,
ConnectionFactoryAttributes.Pooled.MAX_POOL_SIZE,
ConnectionFactoryAttributes.Pooled.MANAGED_CONNECTION_POOL,
ConnectionFactoryAttributes.Pooled.ENLISTMENT_TRACE,
ConnectionFactoryAttributes.Common.INITIAL_MESSAGE_PACKET_SIZE,
ConnectionFactoryAttributes.Pooled.INITIAL_CONNECT_ATTEMPTS,
ConnectionFactoryAttributes.Pooled.STATISTICS_ENABLED);
if (external) {
builder.addAttributes(ConnectionFactoryAttributes.External.ENABLE_AMQ1_PREFIX);
}
return builder;
}
}
| 55,055
| 79.609078
| 128
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/JGroupsBroadcastGroupDefinition.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import static org.jboss.as.controller.SimpleAttributeDefinitionBuilder.create;
import static org.jboss.as.controller.client.helpers.MeasurementUnit.MILLISECONDS;
import static org.jboss.as.controller.registry.AttributeAccess.Flag.STORAGE_RUNTIME;
import static org.jboss.dmr.ModelType.LONG;
import static org.jboss.dmr.ModelType.STRING;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.CONNECTORS;
import java.util.Arrays;
import java.util.Collection;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.AttributeMarshaller;
import org.jboss.as.controller.AttributeParser;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.PrimitiveListAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleOperationDefinition;
import org.jboss.as.controller.SimpleOperationDefinitionBuilder;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.StringListAttributeDefinition;
import org.jboss.as.controller.capability.DynamicNameMappers;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.controller.operations.validation.StringLengthValidator;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.dmr.ModelNode;
import org.wildfly.clustering.server.service.ClusteringDefaultRequirement;
import org.wildfly.clustering.server.service.ClusteringRequirement;
/**
* Broadcast group definition using Jgroups.
*
* @author Emmanuel Hugonnet (c) 2019 Red Hat, Inc.
*/
public class JGroupsBroadcastGroupDefinition extends PersistentResourceDefinition {
public static final RuntimeCapability<Void> CAPABILITY = RuntimeCapability.Builder.of("org.wildfly.messaging.activemq.jgroups-broadcast-group", true)
.setDynamicNameMapper(DynamicNameMappers.PARENT)
.addRequirements(ClusteringDefaultRequirement.COMMAND_DISPATCHER_FACTORY.getName())
.build();
public static final PrimitiveListAttributeDefinition CONNECTOR_REFS = new StringListAttributeDefinition.Builder(CONNECTORS)
.setRequired(true)
.setMinSize(1)
.setElementValidator(new StringLengthValidator(1))
.setAttributeParser(AttributeParser.STRING_LIST)
.setAttributeMarshaller(AttributeMarshaller.STRING_LIST)
.setAllowExpression(false)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultBroadcastPeriod
*/
public static final SimpleAttributeDefinition BROADCAST_PERIOD = create("broadcast-period", LONG)
.setDefaultValue(new ModelNode(2000L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
@Deprecated
public static final SimpleAttributeDefinition JGROUPS_CHANNEL_FACTORY = create(CommonAttributes.JGROUPS_CHANNEL_FACTORY)
.setCapabilityReference("org.wildfly.clustering.jgroups.channel-factory")
.build();
public static final SimpleAttributeDefinition JGROUPS_CLUSTER = create(CommonAttributes.JGROUPS_CLUSTER)
.setRequired(true)
.setAlternatives(new String[0])
.build();
public static final SimpleAttributeDefinition JGROUPS_CHANNEL = create(CommonAttributes.JGROUPS_CHANNEL)
.setCapabilityReference(ClusteringRequirement.COMMAND_DISPATCHER_FACTORY.getName())
.build();
public static final AttributeDefinition[] ATTRIBUTES = {JGROUPS_CHANNEL_FACTORY, JGROUPS_CHANNEL, JGROUPS_CLUSTER,
BROADCAST_PERIOD, CONNECTOR_REFS};
public static final String GET_CONNECTOR_PAIRS_AS_JSON = "get-connector-pairs-as-json";
private final boolean registerRuntimeOnly;
JGroupsBroadcastGroupDefinition(boolean registerRuntimeOnly) {
super(new SimpleResourceDefinition.Parameters(
MessagingExtension.JGROUPS_BROADCAST_GROUP_PATH,
MessagingExtension.getResourceDescriptionResolver(CommonAttributes.BROADCAST_GROUP))
.setAddHandler(JGroupsBroadcastGroupAdd.INSTANCE)
.setRemoveHandler(JGroupsBroadcastGroupRemove.INSTANCE)
.addCapabilities(CAPABILITY));
this.registerRuntimeOnly = registerRuntimeOnly;
}
@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(ATTRIBUTES);
}
@Override
public void registerAttributes(ManagementResourceRegistration registry) {
for (AttributeDefinition attr : ATTRIBUTES) {
if (!attr.getFlags().contains(STORAGE_RUNTIME)) {
registry.registerReadWriteAttribute(attr, null, BroadcastGroupWriteAttributeHandler.JGROUP_INSTANCE);
}
}
BroadcastGroupControlHandler.INSTANCE.registerAttributes(registry);
}
@Override
public void registerOperations(ManagementResourceRegistration registry) {
super.registerOperations(registry);
if (registerRuntimeOnly) {
BroadcastGroupControlHandler.INSTANCE.registerOperations(registry, getResourceDescriptionResolver());
SimpleOperationDefinition op = new SimpleOperationDefinitionBuilder(GET_CONNECTOR_PAIRS_AS_JSON, getResourceDescriptionResolver())
.setReadOnly()
.setRuntimeOnly()
.setReplyType(STRING)
.build();
registry.registerOperationHandler(op, BroadcastGroupControlHandler.INSTANCE);
}
}
}
| 6,847
| 44.959732
| 153
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/BridgeControlHandler.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import org.apache.activemq.artemis.api.core.management.BridgeControl;
import org.apache.activemq.artemis.api.core.management.ResourceNames;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.jboss.as.controller.PathAddress;
/**
* Handler for runtime operations that interact with a ActiveMQ {@link BridgeControl}.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class BridgeControlHandler extends AbstractActiveMQComponentControlHandler<BridgeControl> {
public static final BridgeControlHandler INSTANCE = new BridgeControlHandler();
@Override
protected BridgeControl getActiveMQComponentControl(ActiveMQServer activeMQServer, PathAddress address) {
final String resourceName = address.getLastElement().getValue();
return BridgeControl.class.cast(activeMQServer.getManagementService().getResource(ResourceNames.BRIDGE + resourceName));
}
@Override
protected String getDescriptionPrefix() {
return CommonAttributes.BRIDGE;
}
}
| 2,097
| 40.96
| 128
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/AddressSettingsResolveHandler.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2014, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.wildfly.extension.messaging.activemq.ActiveMQActivationService.ignoreOperationIfServerNotActive;
import static org.wildfly.extension.messaging.activemq.AddressSettingDefinition.ADDRESS_FULL_MESSAGE_POLICY;
import static org.wildfly.extension.messaging.activemq.AddressSettingDefinition.AUTO_CREATE_ADDRESSES;
import static org.wildfly.extension.messaging.activemq.AddressSettingDefinition.AUTO_CREATE_JMS_QUEUES;
import static org.wildfly.extension.messaging.activemq.AddressSettingDefinition.AUTO_CREATE_QUEUES;
import static org.wildfly.extension.messaging.activemq.AddressSettingDefinition.AUTO_DELETE_ADDRESSES;
import static org.wildfly.extension.messaging.activemq.AddressSettingDefinition.AUTO_DELETE_CREATED_QUEUES;
import static org.wildfly.extension.messaging.activemq.AddressSettingDefinition.AUTO_DELETE_JMS_QUEUES;
import static org.wildfly.extension.messaging.activemq.AddressSettingDefinition.AUTO_DELETE_QUEUES;
import static org.wildfly.extension.messaging.activemq.AddressSettingDefinition.EXPIRY_DELAY;
import static org.wildfly.extension.messaging.activemq.AddressSettingDefinition.LAST_VALUE_QUEUE;
import static org.wildfly.extension.messaging.activemq.AddressSettingDefinition.MAX_DELIVERY_ATTEMPTS;
import static org.wildfly.extension.messaging.activemq.AddressSettingDefinition.MAX_REDELIVERY_DELAY;
import static org.wildfly.extension.messaging.activemq.AddressSettingDefinition.MAX_SIZE_BYTES;
import static org.wildfly.extension.messaging.activemq.AddressSettingDefinition.MESSAGE_COUNTER_HISTORY_DAY_LIMIT;
import static org.wildfly.extension.messaging.activemq.AddressSettingDefinition.PAGE_MAX_CACHE_SIZE;
import static org.wildfly.extension.messaging.activemq.AddressSettingDefinition.PAGE_SIZE_BYTES;
import static org.wildfly.extension.messaging.activemq.AddressSettingDefinition.REDELIVERY_DELAY;
import static org.wildfly.extension.messaging.activemq.AddressSettingDefinition.REDELIVERY_MULTIPLIER;
import static org.wildfly.extension.messaging.activemq.AddressSettingDefinition.REDISTRIBUTION_DELAY;
import static org.wildfly.extension.messaging.activemq.AddressSettingDefinition.SEND_TO_DLA_ON_NO_ROUTE;
import static org.wildfly.extension.messaging.activemq.AddressSettingDefinition.SLOW_CONSUMER_CHECK_PERIOD;
import static org.wildfly.extension.messaging.activemq.AddressSettingDefinition.SLOW_CONSUMER_POLICY;
import static org.wildfly.extension.messaging.activemq.AddressSettingDefinition.SLOW_CONSUMER_THRESHOLD;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.DEAD_LETTER_ADDRESS;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.EXPIRY_ADDRESS;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.RESOLVE_ADDRESS_SETTING;
import static org.wildfly.extension.messaging.activemq.OperationDefinitionHelper.createNonEmptyStringAttribute;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.jboss.as.controller.AbstractRuntimeOnlyHandler;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.SimpleOperationDefinition;
import org.jboss.as.controller.SimpleOperationDefinitionBuilder;
import org.jboss.as.controller.descriptions.ResourceDescriptionResolver;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
/**
* Operation handler to resolve address settings.
*
* WildFly address-setting resource represents a setting for a given address (which can be a wildcard address).
* ActiveMQ uses a hierarchy of address-settings (based on address wildcards) and "merges" the hierarchy of settings
* to obtain the settings for a specific address.
*
* This handler resolves the address settings values for the specified address (even though there may not be an
* address-setting that exists at that address).
*
* For example, the user adds an address-settings for '#' (the most generic wildcard address) and specifies its settings.
*
* It can then call the operation /subsystem=messaging-activemq/server=default/resolve-address-setting(activemq-address=jms.queue.myQueue)
* to retrieve the *resolved* settings for the jms.queue.myQueue address (which will be inherited from #).
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2014 Red Hat Inc.
*/
public class AddressSettingsResolveHandler extends AbstractRuntimeOnlyHandler {
static final AddressSettingsResolveHandler INSTANCE = new AddressSettingsResolveHandler();
private static final AttributeDefinition ACTIVEMQ_ADDRESS = createNonEmptyStringAttribute(CommonAttributes.ACTIVEMQ_ADDRESS);
protected AddressSettingsResolveHandler() { }
@Override
protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
if (ignoreOperationIfServerNotActive(context, operation)) {
return;
}
final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(address);
ServiceController<?> service = context.getServiceRegistry(false).getService(serviceName);
ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
final String activeMQAddress = ACTIVEMQ_ADDRESS.resolveModelAttribute(context, operation).asString();
AddressSettings settings = server.getAddressSettingsRepository().getMatch(activeMQAddress);
ModelNode result = context.getResult();
result.get(ADDRESS_FULL_MESSAGE_POLICY.getName()).set(settings.getAddressFullMessagePolicy().toString());
ModelNode deadLetterAddress = result.get(DEAD_LETTER_ADDRESS.getName());
if (settings.getDeadLetterAddress() != null) {
deadLetterAddress.set(settings.getDeadLetterAddress().toString());
}
ModelNode expiryAddress = result.get(EXPIRY_ADDRESS.getName());
if (settings.getExpiryAddress() != null) {
expiryAddress.set(settings.getExpiryAddress().toString());
}
result.get(EXPIRY_DELAY.getName()).set(settings.getExpiryDelay());
result.get(LAST_VALUE_QUEUE.getName()).set(settings.isDefaultLastValueQueue());
result.get(MAX_DELIVERY_ATTEMPTS.getName()).set(settings.getMaxDeliveryAttempts());
result.get(MAX_REDELIVERY_DELAY.getName()).set(settings.getMaxRedeliveryDelay());
result.get(MAX_SIZE_BYTES.getName()).set(settings.getMaxSizeBytes());
result.get(MESSAGE_COUNTER_HISTORY_DAY_LIMIT.getName()).set(settings.getMessageCounterHistoryDayLimit());
result.get(PAGE_MAX_CACHE_SIZE.getName()).set(settings.getPageCacheMaxSize());
result.get(PAGE_SIZE_BYTES.getName()).set(settings.getPageSizeBytes());
result.get(REDELIVERY_DELAY.getName()).set(settings.getRedeliveryDelay());
result.get(REDELIVERY_MULTIPLIER.getName()).set(settings.getRedeliveryMultiplier());
result.get(REDISTRIBUTION_DELAY.getName()).set(settings.getRedistributionDelay());
result.get(SEND_TO_DLA_ON_NO_ROUTE.getName()).set(settings.isSendToDLAOnNoRoute());
result.get(SLOW_CONSUMER_CHECK_PERIOD.getName()).set(settings.getSlowConsumerCheckPeriod());
result.get(SLOW_CONSUMER_POLICY.getName()).set(settings.getSlowConsumerPolicy().toString());
result.get(SLOW_CONSUMER_THRESHOLD.getName()).set(settings.getSlowConsumerThreshold());
result.get(AUTO_CREATE_JMS_QUEUES.getName()).set(settings.isAutoCreateJmsQueues());
result.get(AUTO_DELETE_JMS_QUEUES.getName()).set(settings.isAutoDeleteJmsQueues());
result.get(AUTO_CREATE_ADDRESSES.getName()).set(settings.isAutoCreateAddresses());
result.get(AUTO_DELETE_ADDRESSES.getName()).set(settings.isAutoDeleteAddresses());
result.get(AUTO_CREATE_QUEUES.getName()).set(settings.isAutoCreateQueues());
result.get(AUTO_DELETE_QUEUES.getName()).set(settings.isAutoDeleteQueues());
result.get(AUTO_DELETE_CREATED_QUEUES.getName()).set(settings.isAutoDeleteCreatedQueues());
}
public static void registerOperationHandler(ManagementResourceRegistration registry, ResourceDescriptionResolver resolver) {
SimpleOperationDefinition op = new SimpleOperationDefinitionBuilder(RESOLVE_ADDRESS_SETTING, resolver)
.setReadOnly()
.setRuntimeOnly()
.addParameter(ACTIVEMQ_ADDRESS)
.setReplyType(ModelType.LIST)
.setReplyParameters(AddressSettingDefinition.ATTRIBUTES)
.build();
registry.registerOperationHandler(op, AddressSettingsResolveHandler.INSTANCE);
}
}
| 10,150
| 63.656051
| 138
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/BroadcastGroupAdd.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.JGROUPS_CLUSTER;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.SOCKET_BINDING;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathAddress;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.Property;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
import org.wildfly.extension.messaging.activemq.shallow.ShallowResourceAdd;
/**
* Handler for adding a broadcast group.
* This is now a ShallowResourceAdd.
*
* @deprecated please use JgroupsBroadcastGroupAdd or SocketBroadcastGroupAdd
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class BroadcastGroupAdd extends ShallowResourceAdd {
public static final BroadcastGroupAdd INSTANCE = new BroadcastGroupAdd(false);
public static final BroadcastGroupAdd LEGACY_INSTANCE = new BroadcastGroupAdd(true);
private final boolean isLegacyCall;
private BroadcastGroupAdd(boolean isLegacyCall) {
super(BroadcastGroupDefinition.ATTRIBUTES);
this.isLegacyCall = isLegacyCall;
}
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
CommonAttributes.renameChannelToCluster(operation);
if (!isLegacyCall) {
ModelNode op = operation.clone();
PathAddress target = context.getCurrentAddress().getParent();
OperationStepHandler addHandler;
if (operation.hasDefined(JGROUPS_CLUSTER.getName())) {
target = target.append(CommonAttributes.JGROUPS_BROADCAST_GROUP, context.getCurrentAddressValue());
addHandler = JGroupsBroadcastGroupAdd.LEGACY_INSTANCE;
} else if (operation.hasDefined(SOCKET_BINDING.getName())) {
target = target.append(CommonAttributes.SOCKET_BROADCAST_GROUP, context.getCurrentAddressValue());
addHandler = SocketBroadcastGroupAdd.LEGACY_INSTANCE;
} else {
throw MessagingLogger.ROOT_LOGGER.socketBindingOrJGroupsClusterRequired();
}
op.get(OP_ADDR).set(target.toModelNode());
context.addStep(op, addHandler, OperationContext.Stage.MODEL, true);
}
super.execute(context, operation);
}
static void addBroadcastGroupConfigs(final OperationContext context, final List<BroadcastGroupConfiguration> configs, final Set<String> connectors, final ModelNode model) throws OperationFailedException {
if (model.hasDefined(CommonAttributes.JGROUPS_BROADCAST_GROUP)) {
for (Property prop : model.get(CommonAttributes.JGROUPS_BROADCAST_GROUP).asPropertyList()) {
configs.add(createBroadcastGroupConfiguration(context, connectors, prop.getName(), prop.getValue()));
}
}
if (model.hasDefined(CommonAttributes.SOCKET_BROADCAST_GROUP)) {
for (Property prop : model.get(CommonAttributes.SOCKET_BROADCAST_GROUP).asPropertyList()) {
configs.add(createBroadcastGroupConfiguration(context, connectors, prop.getName(), prop.getValue()));
}
}
}
static BroadcastGroupConfiguration createBroadcastGroupConfiguration(final OperationContext context, final Set<String> connectors, final String name, final ModelNode model) throws OperationFailedException {
final long broadcastPeriod = BroadcastGroupDefinition.BROADCAST_PERIOD.resolveModelAttribute(context, model).asLong();
final List<String> connectorRefs = new ArrayList<String>();
if (model.hasDefined(CommonAttributes.CONNECTORS)) {
for (ModelNode ref : model.get(CommonAttributes.CONNECTORS).asList()) {
final String refName = ref.asString();
if(!connectors.contains(refName)){
throw MessagingLogger.ROOT_LOGGER.wrongConnectorRefInBroadCastGroup(name, refName, connectors);
}
connectorRefs.add(refName);
}
}
return new BroadcastGroupConfiguration()
.setName(name)
.setBroadcastPeriod(broadcastPeriod)
.setConnectorInfos(connectorRefs);
}
}
| 5,662
| 48.243478
| 210
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/deployment/MessagingDependencyProcessor.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.deployment;
import static org.jboss.as.weld.Capabilities.WELD_CAPABILITY_NAME;
import org.jboss.as.controller.capability.CapabilityServiceSupport;
import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
import org.jboss.as.server.deployment.module.ModuleDependency;
import org.jboss.as.server.deployment.module.ModuleSpecification;
import org.jboss.as.weld.WeldCapability;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleLoader;
/**
* Processor that add module dependencies for Jakarta Messaging deployments.
*
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2013 Red Hat inc.
*/
public class MessagingDependencyProcessor implements DeploymentUnitProcessor {
/**
* We include this module so that the CDI producer method for JMSContext is available for the deployment unit.
*/
public static final String AS_MESSAGING = "org.wildfly.extension.messaging-activemq.injection";
public static final String JMS_API = "jakarta.jms.api";
public static final String JTS = "org.jboss.jts";
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
final ModuleLoader moduleLoader = Module.getBootModuleLoader();
addDependency(moduleSpecification, moduleLoader, JMS_API);
final CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
if (support.hasCapability(WELD_CAPABILITY_NAME)) {
final WeldCapability api = support.getOptionalCapabilityRuntimeAPI(WELD_CAPABILITY_NAME, WeldCapability.class).get();
if (api.isPartOfWeldDeployment(deploymentUnit)) {
addDependency(moduleSpecification, moduleLoader, AS_MESSAGING);
// The messaging-activemq subsystem provides support for injected JMSContext.
// one of the beans has a @TransactionScoped scope which requires the CDI context
// provided by Narayana in the org.jboss.jts module.
// @see CDIDeploymentProcessor
addDependency(moduleSpecification, moduleLoader, JTS);
}
}
}
private void addDependency(ModuleSpecification moduleSpecification, ModuleLoader moduleLoader,
String moduleIdentifier) {
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, moduleIdentifier, false, false, true, false));
}
}
| 3,961
| 48.525
| 129
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/deployment/JMSDestinationDefinitionAnnotationProcessor.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2014, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.deployment;
import jakarta.jms.JMSDestinationDefinition;
import jakarta.jms.JMSDestinationDefinitions;
import org.jboss.as.ee.resource.definition.ResourceDefinitionAnnotationProcessor;
import org.jboss.as.ee.resource.definition.ResourceDefinitionInjectionSource;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.DotName;
import org.jboss.metadata.property.PropertyReplacer;
/**
* {@link JMSDestinationDefinition}(s) resource config annotation processor.
*
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a>
* @author Eduardo Martins
*/
public class JMSDestinationDefinitionAnnotationProcessor extends ResourceDefinitionAnnotationProcessor {
private static final DotName JMS_DESTINATION_DEFINITION = DotName.createSimple(JMSDestinationDefinition.class.getName());
private static final DotName JMS_DESTINATION_DEFINITIONS = DotName.createSimple(JMSDestinationDefinitions.class.getName());
@Override
protected DotName getAnnotationDotName() {
return JMS_DESTINATION_DEFINITION;
}
@Override
protected DotName getAnnotationCollectionDotName() {
return JMS_DESTINATION_DEFINITIONS;
}
@Override
protected ResourceDefinitionInjectionSource processAnnotation(AnnotationInstance annotationInstance, PropertyReplacer propertyReplacer) throws DeploymentUnitProcessingException {
final String jndiName = AnnotationElement.asRequiredString(annotationInstance, AnnotationElement.NAME);
final String interfaceName = AnnotationElement.asRequiredString(annotationInstance, "interfaceName");
final JMSDestinationDefinitionInjectionSource directJMSDestinationInjectionSource = new JMSDestinationDefinitionInjectionSource(jndiName, interfaceName);
directJMSDestinationInjectionSource.setClassName(AnnotationElement.asOptionalString(annotationInstance, "className"));
directJMSDestinationInjectionSource.setResourceAdapter(AnnotationElement.asOptionalString(annotationInstance, "resourceAdapter"));
directJMSDestinationInjectionSource.setDestinationName(AnnotationElement.asOptionalString(annotationInstance, "destinationName", propertyReplacer));
directJMSDestinationInjectionSource.addProperties(AnnotationElement.asOptionalStringArray(annotationInstance, AnnotationElement.PROPERTIES), propertyReplacer);
return directJMSDestinationInjectionSource;
}
}
| 3,541
| 50.333333
| 182
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/deployment/JMSDestinationDefinitionInjectionSource.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.deployment;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.DURABLE;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.ENTRIES;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.EXTERNAL_JMS_QUEUE;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.EXTERNAL_JMS_TOPIC;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.JMS_QUEUE;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.JMS_TOPIC;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.NAME;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.SELECTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.SERVER;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.MANAGEMENT_ADDRESS;
import static org.wildfly.extension.messaging.activemq.deployment.JMSConnectionFactoryDefinitionInjectionSource.getActiveMQServerName;
import static org.wildfly.extension.messaging.activemq.deployment.JMSConnectionFactoryDefinitionInjectionSource.getDefaulResourceAdapter;
import static org.wildfly.extension.messaging.activemq.deployment.JMSConnectionFactoryDefinitionInjectionSource.targetsExternalPooledConnectionFactory;
import static org.wildfly.extension.messaging.activemq.deployment.JMSConnectionFactoryDefinitionInjectionSource.targetsPooledConnectionFactory;
import static org.wildfly.extension.messaging.activemq.logging.MessagingLogger.ROOT_LOGGER;
import java.util.Map;
import jakarta.jms.Destination;
import jakarta.jms.Queue;
import jakarta.jms.Topic;
import org.jboss.as.connector.deployers.ra.AdministeredObjectDefinitionInjectionSource;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
import org.jboss.as.ee.resource.definition.ResourceDefinitionInjectionSource;
import org.jboss.as.naming.ContextListAndJndiViewManagedReferenceFactory;
import org.jboss.as.naming.ManagedReferenceFactory;
import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentResourceSupport;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.inject.Injector;
import org.jboss.msc.service.LifecycleEvent;
import org.jboss.msc.service.LifecycleListener;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceTarget;
import org.wildfly.extension.messaging.activemq.MessagingExtension;
import org.wildfly.extension.messaging.activemq.MessagingServices;
import org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.External;
import org.wildfly.extension.messaging.activemq.jms.DestinationConfiguration;
import org.wildfly.extension.messaging.activemq.jms.ExternalJMSQueueService;
import org.wildfly.extension.messaging.activemq.jms.ExternalJMSTopicService;
import org.wildfly.extension.messaging.activemq.jms.JMSQueueConfigurationRuntimeHandler;
import org.wildfly.extension.messaging.activemq.jms.JMSQueueService;
import org.wildfly.extension.messaging.activemq.jms.JMSServices;
import org.wildfly.extension.messaging.activemq.jms.JMSTopicConfigurationRuntimeHandler;
import org.wildfly.extension.messaging.activemq.jms.JMSTopicService;
import org.wildfly.extension.messaging.activemq.jms.WildFlyBindingRegistry;
/**
* A binding description for Jakarta Messaging Destination definitions.
*
* The referenced Jakarta Messaging definition must be directly visible to the
* component declaring the annotation.
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2013 Red Hat inc.
* @author Eduardo Martins
*/
public class JMSDestinationDefinitionInjectionSource extends ResourceDefinitionInjectionSource {
private final String interfaceName;
// optional attributes
private String description;
private String className;
private String resourceAdapter;
private String destinationName;
public JMSDestinationDefinitionInjectionSource(final String jndiName, String interfaceName) {
super(jndiName);
this.interfaceName = interfaceName;
}
void setDescription(String description) {
this.description = description;
}
void setClassName(String className) {
this.className = className;
}
void setResourceAdapter(String resourceAdapter) {
this.resourceAdapter = resourceAdapter;
}
void setDestinationName(String destinationName) {
this.destinationName = destinationName;
}
protected String uniqueName(ResolutionContext context) {
if (destinationName != null && !destinationName.isEmpty()) {
return destinationName;
}
return super.uniqueName(context);
}
@Override
public void getResourceValue(final ResolutionContext context, final ServiceBuilder<?> serviceBuilder, final DeploymentPhaseContext phaseContext, final Injector<ManagedReferenceFactory> injector) throws DeploymentUnitProcessingException {
if(resourceAdapter == null || resourceAdapter.isEmpty()) {
resourceAdapter = getDefaulResourceAdapter(phaseContext.getDeploymentUnit());
}
boolean external = targetsExternalPooledConnectionFactory(resourceAdapter, phaseContext.getServiceRegistry());
if (external || targetsPooledConnectionFactory(getActiveMQServerName(properties), resourceAdapter, phaseContext.getServiceRegistry())) {
startActiveMQDestination(context, serviceBuilder, phaseContext, injector, external);
} else {
// delegate to the resource-adapter subsystem to create a generic Jakarta Connectors admin object.
AdministeredObjectDefinitionInjectionSource aodis = new AdministeredObjectDefinitionInjectionSource(jndiName, className, resourceAdapter);
aodis.setInterface(interfaceName);
aodis.setDescription(description);
// transfer all the generic properties
for (Map.Entry<String, String> property : properties.entrySet()) {
aodis.addProperty(property.getKey(), property.getValue());
}
aodis.getResourceValue(context, serviceBuilder, phaseContext, injector);
}
}
private void startActiveMQDestination(ResolutionContext context, ServiceBuilder<?> serviceBuilder, DeploymentPhaseContext phaseContext, Injector<ManagedReferenceFactory> injector, boolean external) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final String uniqueName = uniqueName(context);
try {
ServiceName serviceName;
if(external) {
serviceName = MessagingServices.getActiveMQServiceName();
} else {
serviceName = MessagingServices.getActiveMQServiceName(getActiveMQServerName(properties));
}
if (interfaceName.equals(Queue.class.getName())) {
startQueue(uniqueName, phaseContext.getServiceTarget(), serviceName, serviceBuilder, deploymentUnit, injector, external);
} else {
startTopic(uniqueName, phaseContext.getServiceTarget(), serviceName, serviceBuilder, deploymentUnit, injector, external);
}
} catch (Exception e) {
throw new DeploymentUnitProcessingException(e);
}
}
/**
* To workaround ActiveMQ's BindingRegistry limitation in {@link WildFlyBindingRegistry}
* that does not allow to build a BindingInfo with the ResolutionContext info, the Jakarta Messaging queue is created *without* any
* JNDI bindings and handle the JNDI bindings directly by getting the service's Jakarta Messaging queue.
*/
private void startQueue(final String queueName,
final ServiceTarget serviceTarget,
final ServiceName serverServiceName,
final ServiceBuilder<?> serviceBuilder,
final DeploymentUnit deploymentUnit,
final Injector<ManagedReferenceFactory> injector,
final boolean external) {
final String selector = properties.containsKey(SELECTOR.getName()) ? properties.get(SELECTOR.getName()) : null;
final boolean durable = properties.containsKey(DURABLE.getName()) ? Boolean.valueOf(properties.get(DURABLE.getName())) : DURABLE.getDefaultValue().asBoolean();
final String managementAddress = properties.containsKey(MANAGEMENT_ADDRESS.getName()) ? properties.get(MANAGEMENT_ADDRESS.getName()) : MANAGEMENT_ADDRESS.getDefaultValue().asString();
final String user = properties.containsKey("management-user") ? properties.get("management-user") : null;
final String password = properties.containsKey("management-password") ? properties.get("management-password") : null;
ModelNode destination = new ModelNode();
destination.get(NAME).set(queueName);
destination.get(DURABLE.getName()).set(durable);
if (selector != null) {
destination.get(SELECTOR.getName()).set(selector);
}
destination.get(ENTRIES).add(jndiName);
Service<Queue> queueService;
if(external) {
// check @JMSDestinationDefinitions boolean property named enable-amq1-prefix for runtime queue
final boolean enabledAMQ1Prefix = properties.containsKey(External.ENABLE_AMQ1_PREFIX.getName()) ? Boolean.valueOf(properties.get(External.ENABLE_AMQ1_PREFIX.getName())) : External.ENABLE_AMQ1_PREFIX.getDefaultValue().asBoolean();
ServiceName pcfName= JMSServices.getPooledConnectionFactoryBaseServiceName(serverServiceName).append(resourceAdapter);
final ServiceName jmsQueueServiceName = JMSServices.getJmsQueueBaseServiceName(serverServiceName).append(queueName);
queueService = ExternalJMSQueueService.installRuntimeQueueService(
DestinationConfiguration.Builder.getInstance()
.setResourceAdapter(resourceAdapter)
.setName(queueName)
.setManagementQueueAddress(managementAddress)
.setDestinationServiceName(jmsQueueServiceName)
.setDurable(durable)
.setSelector(selector)
.setManagementUsername(user)
.setManagementPassword(password)
.build(),
serviceTarget,
pcfName,
enabledAMQ1Prefix);
} else {
queueService = JMSQueueService.installService(queueName, serviceTarget, serverServiceName, selector, durable);
}
inject(serviceBuilder, injector, queueService);
//create the management registration
String serverName = null;
final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT);
PathAddress registration;
if (external) {
final PathElement dest = PathElement.pathElement(EXTERNAL_JMS_QUEUE, queueName);
deploymentResourceSupport.getDeploymentSubsystemModel(MessagingExtension.SUBSYSTEM_NAME);
registration = PathAddress.pathAddress(dest);
} else {
serverName = getActiveMQServerName(properties);
final PathElement dest = PathElement.pathElement(JMS_QUEUE, queueName);
final PathElement serverElement = PathElement.pathElement(SERVER, serverName);
deploymentResourceSupport.getDeploymentSubModel(MessagingExtension.SUBSYSTEM_NAME, serverElement);
registration = PathAddress.pathAddress(serverElement, dest);
}
MessagingXmlInstallDeploymentUnitProcessor.createDeploymentSubModel(registration, deploymentUnit);
JMSQueueConfigurationRuntimeHandler.INSTANCE.registerResource(serverName, queueName, destination);
}
private void startTopic(String topicName,
ServiceTarget serviceTarget,
ServiceName serverServiceName,
ServiceBuilder<?> serviceBuilder,
DeploymentUnit deploymentUnit,
Injector<ManagedReferenceFactory> injector,
final boolean external) {
final String managementAddress = properties.containsKey(MANAGEMENT_ADDRESS.getName()) ? properties.get(MANAGEMENT_ADDRESS.getName()) : MANAGEMENT_ADDRESS.getDefaultValue().asString();
final String user = properties.containsKey("management-user") ? properties.get("management-user") : null;
final String password = properties.containsKey("management-password") ? properties.get("management-password") : null;
ModelNode destination = new ModelNode();
destination.get(NAME).set(topicName);
destination.get(ENTRIES).add(jndiName);
Service<Topic> topicService;
if(external) {
// check @JMSDestinationDefinitions boolean property named enable-amq1-prefix for runtime topic
final boolean enabledAMQ1Prefix = properties.containsKey(External.ENABLE_AMQ1_PREFIX.getName()) ? Boolean.valueOf(properties.get(External.ENABLE_AMQ1_PREFIX.getName())) : External.ENABLE_AMQ1_PREFIX.getDefaultValue().asBoolean();
ServiceName pcfName = JMSServices.getPooledConnectionFactoryBaseServiceName(serverServiceName).append(resourceAdapter);
final ServiceName jmsTopicServiceName = JMSServices.getJmsTopicBaseServiceName(serverServiceName).append(topicName);
topicService = ExternalJMSTopicService.installRuntimeTopicService(
DestinationConfiguration.Builder.getInstance()
.setResourceAdapter(resourceAdapter)
.setName(topicName)
.setManagementQueueAddress(managementAddress)
.setManagementUsername(user)
.setManagementPassword(password)
.setDestinationServiceName(jmsTopicServiceName)
.build(),
serviceTarget,
pcfName,
enabledAMQ1Prefix);
} else {
topicService = JMSTopicService.installService(topicName, serverServiceName, serviceTarget);
}
inject(serviceBuilder, injector, topicService);
//create the management registration
String serverName = null;
final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT);
PathAddress registration;
if (external) {
final PathElement dest = PathElement.pathElement(EXTERNAL_JMS_TOPIC, topicName);
deploymentResourceSupport.getDeploymentSubsystemModel(MessagingExtension.SUBSYSTEM_NAME);
registration = PathAddress.pathAddress(dest);
} else {
serverName = getActiveMQServerName(properties);
final PathElement dest = PathElement.pathElement(JMS_TOPIC, topicName);
final PathElement serverElement = PathElement.pathElement(SERVER, serverName);
deploymentResourceSupport.getDeploymentSubModel(MessagingExtension.SUBSYSTEM_NAME, serverElement);
registration = PathAddress.pathAddress(serverElement, dest);
}
MessagingXmlInstallDeploymentUnitProcessor.createDeploymentSubModel(registration, deploymentUnit);
JMSTopicConfigurationRuntimeHandler.INSTANCE.registerResource(serverName, topicName, destination);
}
private <D extends Destination> void inject(ServiceBuilder<?> serviceBuilder, Injector<ManagedReferenceFactory> injector, Service<D> destinationService) {
final ContextListAndJndiViewManagedReferenceFactory referenceFactoryService = new MessagingJMSDestinationManagedReferenceFactory(destinationService);
injector.inject(referenceFactoryService);
serviceBuilder.addListener(new LifecycleListener() {
private volatile boolean bound;
public void handleEvent(final ServiceController<?> controller, final LifecycleEvent event) {
switch (event) {
case UP: {
ROOT_LOGGER.boundJndiName(jndiName);
bound = true;
break;
}
case DOWN: {
if (bound) {
ROOT_LOGGER.unboundJndiName(jndiName);
}
break;
}
case REMOVED: {
ROOT_LOGGER.debugf("Removed messaging object [%s]", jndiName);
break;
}
}
}
});
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
JMSDestinationDefinitionInjectionSource that = (JMSDestinationDefinitionInjectionSource) o;
if (className != null ? !className.equals(that.className) : that.className != null) return false;
if (description != null ? !description.equals(that.description) : that.description != null) return false;
if (destinationName != null ? !destinationName.equals(that.destinationName) : that.destinationName != null)
return false;
if (interfaceName != null ? !interfaceName.equals(that.interfaceName) : that.interfaceName != null)
return false;
if (resourceAdapter != null ? !resourceAdapter.equals(that.resourceAdapter) : that.resourceAdapter != null)
return false;
return true;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (interfaceName != null ? interfaceName.hashCode() : 0);
result = 31 * result + (description != null ? description.hashCode() : 0);
result = 31 * result + (className != null ? className.hashCode() : 0);
result = 31 * result + (resourceAdapter != null ? resourceAdapter.hashCode() : 0);
result = 31 * result + (destinationName != null ? destinationName.hashCode() : 0);
return result;
}
}
| 20,017
| 55.548023
| 244
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/deployment/MessagingDeploymentParser_1_0.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.deployment;
import static org.jboss.as.controller.parsing.ParseUtils.readStringAttributeElement;
import static org.jboss.as.controller.parsing.ParseUtils.requireSingleAttribute;
import static org.jboss.as.controller.parsing.ParseUtils.unexpectedElement;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.DURABLE;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.ENTRY;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.JMS_DESTINATIONS;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.JMS_QUEUE;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.JMS_TOPIC;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.SELECTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.SERVER;
import java.util.Collections;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.parsing.ParseUtils;
import org.jboss.dmr.ModelNode;
import org.jboss.metadata.property.PropertyReplacer;
import org.jboss.staxmapper.XMLElementReader;
import org.jboss.staxmapper.XMLExtendedStreamReader;
import org.wildfly.extension.messaging.activemq.CommonAttributes;
/**
* The messaging subsystem domain parser
*
* @author scott.stark@jboss.org
* @author Emanuel Muckenhuber
* @author <a href="mailto:andy.taylor@jboss.com">Andy Taylor</a>
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
class MessagingDeploymentParser_1_0 implements XMLStreamConstants, XMLElementReader<ParseResult> {
private final PropertyReplacer propertyReplacer;
MessagingDeploymentParser_1_0(final PropertyReplacer propertyReplacer) {
//
this.propertyReplacer = propertyReplacer;
}
@Override
public void readElement(final XMLExtendedStreamReader reader, final ParseResult result) throws XMLStreamException {
final Namespace schemaVer = Namespace.forUri(reader.getNamespaceURI());
switch (schemaVer) {
case MESSAGING_DEPLOYMENT_1_0:
processDeployment(reader, result);
break;
default:
throw unexpectedElement(reader);
}
}
private void processDeployment(final XMLExtendedStreamReader reader, final ParseResult result) throws XMLStreamException {
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
switch (reader.getLocalName()) {
case SERVER:
processServer(reader, result);
break;
default:
throw ParseUtils.unexpectedElement(reader);
}
}
}
private void processServer(final XMLExtendedStreamReader reader, final ParseResult result) throws XMLStreamException {
String serverName = null;
final int count = reader.getAttributeCount();
if (count > 0) {
requireSingleAttribute(reader, CommonAttributes.NAME);
serverName = propertyReplacer.replaceProperties(reader.getAttributeValue(0).trim());
}
if (serverName == null || serverName.length() == 0) {
serverName = "default";
}
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
switch (reader.getLocalName()) {
case JMS_DESTINATIONS:
processJmsDestinations(reader, result, serverName);
break;
default:
throw ParseUtils.unexpectedElement(reader);
}
}
}
private void processJmsDestinations(final XMLExtendedStreamReader reader, final ParseResult result, final String serverName) throws XMLStreamException {
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
switch (reader.getLocalName()) {
case JMS_QUEUE:
processJMSQueue(reader, serverName, result);
break;
case JMS_TOPIC:
processJMSTopic(reader, serverName, result);
break;
default:
throw ParseUtils.unexpectedElement(reader);
}
}
}
private void processJMSTopic(final XMLExtendedStreamReader reader, String serverName, ParseResult result) throws XMLStreamException {
final String name = propertyReplacer.replaceProperties(reader.getAttributeValue(0));
if (name == null) {
throw ParseUtils.missingRequired(reader, Collections.singleton("name"));
}
final ModelNode topic = new ModelNode();
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
switch (reader.getLocalName()) {
case ENTRY: {
final String entry = propertyReplacer.replaceProperties(readStringAttributeElement(reader, CommonAttributes.NAME));
parseAndAddParameter(CommonAttributes.DESTINATION_ENTRIES, entry, topic, reader);
break;
}
default: {
throw ParseUtils.unexpectedElement(reader);
}
}
}
result.getTopics().add(new JmsDestination(topic, serverName, name));
}
private void processJMSQueue(final XMLExtendedStreamReader reader, String serverName, ParseResult result) throws XMLStreamException {
requireSingleAttribute(reader, CommonAttributes.NAME);
final String name = propertyReplacer.replaceProperties(reader.getAttributeValue(0));
if (name == null) {
throw ParseUtils.missingRequired(reader, Collections.singleton("name"));
}
final ModelNode queue = new ModelNode();
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
switch (reader.getLocalName()) {
case ENTRY: {
final String entry = propertyReplacer.replaceProperties(readStringAttributeElement(reader, CommonAttributes.NAME));
parseAndAddParameter(CommonAttributes.DESTINATION_ENTRIES, entry, queue, reader);
break;
}
case "selector": {
if (queue.has(SELECTOR.getName())) {
throw ParseUtils.duplicateNamedElement(reader, reader.getLocalName());
}
requireSingleAttribute(reader, CommonAttributes.STRING);
final String selector = propertyReplacer.replaceProperties(readStringAttributeElement(reader, CommonAttributes.STRING));
SELECTOR.parseAndSetParameter(selector, queue, reader);
break;
}
case "durable": {
if (queue.has(DURABLE.getName())) {
throw ParseUtils.duplicateNamedElement(reader, reader.getLocalName());
}
DURABLE.parseAndSetParameter(propertyReplacer.replaceProperties(reader.getElementText()), queue, reader);
break;
}
default: {
throw ParseUtils.unexpectedElement(reader);
}
}
}
result.getQueues().add(new JmsDestination(queue, serverName, name));
}
protected static void parseAndAddParameter(AttributeDefinition ad, String value, ModelNode operation, XMLStreamReader reader) throws XMLStreamException {
ModelNode attValue = ad.getParser().parse(ad, value, reader);
operation.get(ad.getName()).add(attValue);
}
}
| 8,787
| 41.660194
| 157
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/deployment/JMSDestinationDefinitionDescriptorProcessor.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.deployment;
import org.jboss.as.ee.resource.definition.ResourceDefinitionDescriptorProcessor;
import org.jboss.as.ee.resource.definition.ResourceDefinitionInjectionSource;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.metadata.javaee.spec.JMSDestinationMetaData;
import org.jboss.metadata.javaee.spec.JMSDestinationsMetaData;
import org.jboss.metadata.javaee.spec.RemoteEnvironment;
/**
* Process jms-destination from deployment descriptor.
*
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2013 Red Hat inc.
* @author Eduardo Martins
*/
public class JMSDestinationDefinitionDescriptorProcessor extends ResourceDefinitionDescriptorProcessor {
@Override
protected void processEnvironment(RemoteEnvironment environment, ResourceDefinitionInjectionSources injectionSources) throws DeploymentUnitProcessingException {
final JMSDestinationsMetaData metaDatas = environment.getJmsDestinations();
if (metaDatas != null) {
for(JMSDestinationMetaData metaData : metaDatas) {
injectionSources.addResourceDefinitionInjectionSource(getResourceDefinitionInjectionSource(metaData));
}
}
}
private ResourceDefinitionInjectionSource getResourceDefinitionInjectionSource(JMSDestinationMetaData metadata) {
final JMSDestinationDefinitionInjectionSource source = new JMSDestinationDefinitionInjectionSource(metadata.getName(), metadata.getInterfaceName());
source.setDestinationName(metadata.getDestinationName());
source.setResourceAdapter(metadata.getResourceAdapter());
source.setClassName(metadata.getClassName());
source.addProperties(metadata.getProperties());
return source;
}
}
| 2,838
| 46.316667
| 164
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/deployment/MessagingXmlParsingDeploymentUnitProcessor.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.deployment;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Collections;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import org.jboss.as.ee.structure.JBossDescriptorPropertyReplacement;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
import org.jboss.staxmapper.XMLMapper;
import org.jboss.vfs.VFSUtils;
import org.jboss.vfs.VirtualFile;
/**
* Processor that handles the messaging subsystems deployable XML
*
* @author Stuart Douglas
*/
public class MessagingXmlParsingDeploymentUnitProcessor implements DeploymentUnitProcessor {
private static final XMLInputFactory INPUT_FACTORY = XMLInputFactory.newInstance();
private static final String[] LOCATIONS = {"WEB-INF", "META-INF"};
private static final QName ROOT_1_0 = new QName(Namespace.MESSAGING_DEPLOYMENT_1_0.getUriString(), "messaging-deployment");
private static final QName ROOT_NO_NAMESPACE = new QName("messaging-deployment");
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final Set<VirtualFile> files = messageDestinations(deploymentUnit);
final XMLMapper mapper = XMLMapper.Factory.create();
final MessagingDeploymentParser_1_0 messagingDeploymentParser_1_0 = new MessagingDeploymentParser_1_0(JBossDescriptorPropertyReplacement.propertyReplacer(deploymentUnit));
mapper.registerRootElement(ROOT_1_0, messagingDeploymentParser_1_0);
mapper.registerRootElement(ROOT_NO_NAMESPACE, messagingDeploymentParser_1_0);
for (final VirtualFile file : files) {
InputStream xmlStream = null;
try {
final File f = file.getPhysicalFile();
xmlStream = new FileInputStream(f);
try {
final XMLInputFactory inputFactory = INPUT_FACTORY;
setIfSupported(inputFactory, XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
setIfSupported(inputFactory, XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
final XMLStreamReader streamReader = inputFactory.createXMLStreamReader(xmlStream);
final ParseResult result = new ParseResult();
try {
mapper.parseDocument(result, streamReader);
deploymentUnit.addToAttachmentList(MessagingAttachments.PARSE_RESULT, result);
} finally {
safeClose(streamReader, f.getAbsolutePath());
}
} catch (XMLStreamException e) {
throw MessagingLogger.ROOT_LOGGER.couldNotParseDeployment(f.getPath(), e);
}
} catch (Exception e) {
throw new DeploymentUnitProcessingException(e.getMessage(), e);
} finally {
VFSUtils.safeClose(xmlStream);
}
}
}
private void setIfSupported(final XMLInputFactory inputFactory, final String property, final Object value) {
if (inputFactory.isPropertySupported(property)) {
inputFactory.setProperty(property, value);
}
}
private Set<VirtualFile> messageDestinations(final DeploymentUnit deploymentUnit) {
final VirtualFile deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot();
if (deploymentRoot == null || !deploymentRoot.exists()) {
return Collections.emptySet();
}
final String deploymentRootName = deploymentRoot.getName().toLowerCase(Locale.ENGLISH);
if (deploymentRootName.endsWith("-jms.xml")) {
return Collections.singleton(deploymentRoot);
}
final Set<VirtualFile> ret = new HashSet<VirtualFile>();
for (String location : LOCATIONS) {
final VirtualFile loc = deploymentRoot.getChild(location);
if (loc.exists()) {
for (final VirtualFile file : loc.getChildren()) {
if (file.getName().endsWith("-jms.xml")) {
ret.add(file);
}
}
}
}
return ret;
}
private static void safeClose(final XMLStreamReader closeable, final String file) {
if (closeable != null) {
try {
closeable.close();
} catch (XMLStreamException e) {
MessagingLogger.ROOT_LOGGER.couldNotCloseFile(file, e);
}
}
}
}
| 6,191
| 41.410959
| 179
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/deployment/JMSConnectionFactoryDefinitionAnnotationProcessor.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2014, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.deployment;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Pooled.MAX_POOL_SIZE;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Pooled.MIN_POOL_SIZE;
import jakarta.jms.JMSConnectionFactoryDefinition;
import jakarta.jms.JMSConnectionFactoryDefinitions;
import org.jboss.as.ee.resource.definition.ResourceDefinitionAnnotationProcessor;
import org.jboss.as.ee.resource.definition.ResourceDefinitionInjectionSource;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.DotName;
import org.jboss.metadata.property.PropertyReplacer;
/**
* {@link jakarta.jms.JMSConnectionFactoryDefinition}(s) resource config annotation processor.
*
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a>
* @author Eduardo Martins
*/
public class JMSConnectionFactoryDefinitionAnnotationProcessor extends ResourceDefinitionAnnotationProcessor {
private static final DotName JMS_CONNECTION_FACTORY_DEFINITION = DotName.createSimple(JMSConnectionFactoryDefinition.class.getName());
private static final DotName JMS_CONNECTION_FACTORY_DEFINITIONS = DotName.createSimple(JMSConnectionFactoryDefinitions.class.getName());
private final boolean legacySecurityAvailable;
public JMSConnectionFactoryDefinitionAnnotationProcessor(boolean legacySecurityAvailable) {
this.legacySecurityAvailable = legacySecurityAvailable;
}
@Override
protected DotName getAnnotationDotName() {
return JMS_CONNECTION_FACTORY_DEFINITION;
}
@Override
protected DotName getAnnotationCollectionDotName() {
return JMS_CONNECTION_FACTORY_DEFINITIONS;
}
@Override
protected ResourceDefinitionInjectionSource processAnnotation(AnnotationInstance annotationInstance, PropertyReplacer propertyReplacer) throws DeploymentUnitProcessingException {
final JMSConnectionFactoryDefinitionInjectionSource directJMSConnectionFactoryInjectionSource = new JMSConnectionFactoryDefinitionInjectionSource(AnnotationElement.asRequiredString(annotationInstance, AnnotationElement.NAME));
directJMSConnectionFactoryInjectionSource.setResourceAdapter(AnnotationElement.asOptionalString(annotationInstance, "resourceAdapter"));
directJMSConnectionFactoryInjectionSource.setInterfaceName(AnnotationElement.asOptionalString(annotationInstance, "interfaceName", "jakarta.jms.ConnectionFactory", propertyReplacer));
directJMSConnectionFactoryInjectionSource.setUser(AnnotationElement.asOptionalString(annotationInstance, "user", propertyReplacer));
directJMSConnectionFactoryInjectionSource.setPassword(AnnotationElement.asOptionalString(annotationInstance, "password", propertyReplacer));
directJMSConnectionFactoryInjectionSource.setClientId(AnnotationElement.asOptionalString(annotationInstance, "clientId", propertyReplacer));
directJMSConnectionFactoryInjectionSource.setTransactional(AnnotationElement.asOptionalBoolean(annotationInstance, "transactional"));
directJMSConnectionFactoryInjectionSource.setMaxPoolSize(AnnotationElement.asOptionalInt(annotationInstance, "maxPoolSize", MAX_POOL_SIZE.getDefaultValue().asInt()));
directJMSConnectionFactoryInjectionSource.setMinPoolSize(AnnotationElement.asOptionalInt(annotationInstance, "minPoolSize", MIN_POOL_SIZE.getDefaultValue().asInt()));
directJMSConnectionFactoryInjectionSource.setLegacySecurityAvailable(legacySecurityAvailable);
directJMSConnectionFactoryInjectionSource.addProperties(AnnotationElement.asOptionalStringArray(annotationInstance, AnnotationElement.PROPERTIES), propertyReplacer);
return directJMSConnectionFactoryInjectionSource;
}
}
| 4,866
| 58.353659
| 234
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/deployment/JmsDestination.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.deployment;
import org.jboss.dmr.ModelNode;
/**
* @author Stuart Douglas
*/
class JmsDestination {
private final String server;
private final String name;
private final ModelNode destination;
JmsDestination(final ModelNode destination, final String server, final String name) {
this.destination = destination;
this.server = server;
this.name = name;
}
public String getServer() {
return server;
}
public ModelNode getDestination() {
return destination;
}
public String getName() {
return name;
}
}
| 1,674
| 28.910714
| 89
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/deployment/MessagingXmlInstallDeploymentUnitProcessor.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.deployment;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.DURABLE;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.JMS_QUEUE;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.JMS_TOPIC;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.SELECTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.SERVER;
import java.util.List;
import java.util.Set;
import jakarta.jms.Queue;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.registry.Resource;
import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentModelUtils;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentResourceSupport;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceName;
import org.wildfly.extension.messaging.activemq.BinderServiceUtil;
import org.wildfly.extension.messaging.activemq.CommonAttributes;
import org.wildfly.extension.messaging.activemq.MessagingExtension;
import org.wildfly.extension.messaging.activemq.MessagingServices;
import org.wildfly.extension.messaging.activemq.jms.JMSQueueConfigurationRuntimeHandler;
import org.wildfly.extension.messaging.activemq.jms.JMSQueueService;
import org.wildfly.extension.messaging.activemq.jms.JMSServices;
import org.wildfly.extension.messaging.activemq.jms.JMSTopicConfigurationRuntimeHandler;
import org.wildfly.extension.messaging.activemq.jms.JMSTopicService;
/**
* Processor that handles the installation of the messaging subsystems deployable XML
*
* @author Stuart Douglas
*/
public class MessagingXmlInstallDeploymentUnitProcessor implements DeploymentUnitProcessor {
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final List<ParseResult> parseResults = deploymentUnit.getAttachmentList(MessagingAttachments.PARSE_RESULT);
final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT);
for (final ParseResult parseResult : parseResults) {
for (final JmsDestination topic : parseResult.getTopics()) {
final ServiceName serverServiceName = MessagingServices.getActiveMQServiceName(topic.getServer());
String[] jndiBindings = null;
if (topic.getDestination().hasDefined(CommonAttributes.DESTINATION_ENTRIES.getName())) {
final ModelNode entries = topic.getDestination().resolve().get(CommonAttributes.DESTINATION_ENTRIES.getName());
jndiBindings = JMSServices.getJndiBindings(entries);
}
JMSTopicService topicService = JMSTopicService.installService(topic.getName(), serverServiceName, phaseContext.getServiceTarget());
final ServiceName topicServiceName = JMSServices.getJmsTopicBaseServiceName(serverServiceName).append(topic.getName());
for (String binding : jndiBindings) {
BinderServiceUtil.installBinderService(phaseContext.getServiceTarget(), binding, topicService, topicServiceName);
}
//create the management registration
final PathElement serverElement = PathElement.pathElement(SERVER, topic.getServer());
final PathElement destination = PathElement.pathElement(JMS_TOPIC, topic.getName());
deploymentResourceSupport.getDeploymentSubModel(MessagingExtension.SUBSYSTEM_NAME, serverElement);
PathAddress registration = PathAddress.pathAddress(serverElement, destination);
createDeploymentSubModel(registration, deploymentUnit);
JMSTopicConfigurationRuntimeHandler.INSTANCE.registerResource(topic.getServer(), topic.getName(), topic.getDestination());
}
for (final JmsDestination queue : parseResult.getQueues()) {
final ServiceName serverServiceName = MessagingServices.getActiveMQServiceName(queue.getServer());
String[] jndiBindings = null;
final ModelNode destination = queue.getDestination();
if (destination.hasDefined(CommonAttributes.DESTINATION_ENTRIES.getName())) {
final ModelNode entries = destination.resolve().get(CommonAttributes.DESTINATION_ENTRIES.getName());
jndiBindings = JMSServices.getJndiBindings(entries);
}
final String selector = destination.hasDefined(SELECTOR.getName()) ? destination.get(SELECTOR.getName()).resolve().asString() : null;
final boolean durable = destination.hasDefined(DURABLE.getName()) ? destination.get(DURABLE.getName()).resolve().asBoolean() : false;
Service<Queue> queueService = JMSQueueService.installService(queue.getName(), phaseContext.getServiceTarget(), serverServiceName, selector, durable);
final ServiceName queueServiceName = JMSServices.getJmsQueueBaseServiceName(serverServiceName).append(queue.getName());
for (String binding : jndiBindings) {
BinderServiceUtil.installBinderService(phaseContext.getServiceTarget(), binding, queueService, queueServiceName);
}
//create the management registration
final PathElement serverElement = PathElement.pathElement(SERVER, queue.getServer());
final PathElement dest = PathElement.pathElement(JMS_QUEUE, queue.getName());
deploymentResourceSupport.getDeploymentSubModel(MessagingExtension.SUBSYSTEM_NAME, serverElement);
PathAddress registration = PathAddress.pathAddress(serverElement, dest);
createDeploymentSubModel(registration, deploymentUnit);
JMSQueueConfigurationRuntimeHandler.INSTANCE.registerResource(queue.getServer(), queue.getName(), destination);
}
}
}
@Override
public void undeploy(final DeploymentUnit context) {
final List<ParseResult> parseResults = context.getAttachmentList(MessagingAttachments.PARSE_RESULT);
for (ParseResult parseResult : parseResults) {
for (final JmsDestination topic : parseResult.getTopics()) {
JMSTopicConfigurationRuntimeHandler.INSTANCE.unregisterResource(topic.getServer(), topic.getName());
}
for (final JmsDestination queue : parseResult.getQueues()) {
JMSQueueConfigurationRuntimeHandler.INSTANCE.unregisterResource(queue.getServer(), queue.getName());
}
}
}
static ManagementResourceRegistration createDeploymentSubModel(final PathAddress address, final DeploymentUnit unit) {
final Resource root = unit.getAttachment(DeploymentModelUtils.DEPLOYMENT_RESOURCE);
synchronized (root) {
final ManagementResourceRegistration registration = unit.getAttachment(DeploymentModelUtils.MUTABLE_REGISTRATION_ATTACHMENT);
final PathAddress subsystemAddress = PathAddress.pathAddress(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, MessagingExtension.SUBSYSTEM_NAME));
final Resource subsystem = getOrCreate(root, subsystemAddress);
Set<String> childTypes = subsystem.getChildTypes();
final ManagementResourceRegistration subModel = registration.getSubModel(subsystemAddress.append(address));
if (subModel == null) {
throw new IllegalStateException(address.toString());
}
getOrCreate(subsystem, address);
return subModel;
}
}
static Resource getOrCreate(final Resource parent, final PathAddress address) {
Resource current = parent;
for (final PathElement element : address) {
synchronized (current) {
if (current.hasChild(element)) {
current = current.requireChild(element);
} else {
final Resource resource = Resource.Factory.create();
current.registerChild(element, resource);
current = resource;
}
}
}
return current;
}
}
| 9,910
| 54.99435
| 170
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/deployment/DefaultJMSConnectionFactoryBindingProcessor.java
|
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.deployment;
import static org.wildfly.extension.messaging.activemq.deployment.DefaultJMSConnectionFactoryBinding.DEFAULT_JMS_CONNECTION_FACTORY;
import org.jboss.as.ee.component.EEModuleDescription;
import org.jboss.as.ee.component.deployers.AbstractPlatformBindingProcessor;
import org.jboss.as.server.deployment.DeploymentUnit;
/**
* Processor responsible for binding the default Jakarta Messaging connection factory to the naming context of EE modules/components.
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2013 Red Hat Inc.
* @author Eduardo Martins
*/
public class DefaultJMSConnectionFactoryBindingProcessor extends AbstractPlatformBindingProcessor {
@Override
protected void addBindings(DeploymentUnit deploymentUnit, EEModuleDescription moduleDescription) {
final String defaultJMSConnectionFactory = moduleDescription.getDefaultResourceJndiNames().getJmsConnectionFactory();
if(defaultJMSConnectionFactory != null) {
addBinding(defaultJMSConnectionFactory, DEFAULT_JMS_CONNECTION_FACTORY, deploymentUnit, moduleDescription);
}
}
}
| 2,180
| 46.413043
| 133
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/deployment/DefaultJMSConnectionFactoryResourceReferenceProcessor.java
|
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.deployment;
import static org.wildfly.extension.messaging.activemq.deployment.DefaultJMSConnectionFactoryBinding.COMP_DEFAULT_JMS_CONNECTION_FACTORY;
import jakarta.jms.ConnectionFactory;
import org.jboss.as.ee.component.Attachments;
import org.jboss.as.ee.component.EEModuleDescription;
import org.jboss.as.ee.component.InjectionSource;
import org.jboss.as.ee.component.LookupInjectionSource;
import org.jboss.as.ee.component.deployers.EEResourceReferenceProcessor;
import org.jboss.as.ee.component.deployers.EEResourceReferenceProcessorRegistry;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
/**
* Processor responsible for adding an EEResourceReferenceProcessor, which defaults @resource ConnectionFactory injection to the default Jakarta Messaging Connection Factory.
*
* @author Eduardo Martins
*/
public class DefaultJMSConnectionFactoryResourceReferenceProcessor implements DeploymentUnitProcessor {
private static final JMSConnectionFactoryResourceReferenceProcessor RESOURCE_REFERENCE_PROCESSOR = new JMSConnectionFactoryResourceReferenceProcessor();
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if(deploymentUnit.getParent() == null) {
final EEResourceReferenceProcessorRegistry eeResourceReferenceProcessorRegistry = deploymentUnit.getAttachment(Attachments.RESOURCE_REFERENCE_PROCESSOR_REGISTRY);
if (eeResourceReferenceProcessorRegistry != null) {
final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
if (eeModuleDescription != null && eeModuleDescription.getDefaultResourceJndiNames().getJmsConnectionFactory() != null) {
eeResourceReferenceProcessorRegistry.registerResourceReferenceProcessor(RESOURCE_REFERENCE_PROCESSOR);
}
}
}
}
private static class JMSConnectionFactoryResourceReferenceProcessor implements EEResourceReferenceProcessor {
private static final String TYPE = ConnectionFactory.class.getName();
private static final InjectionSource INJECTION_SOURCE = new LookupInjectionSource(COMP_DEFAULT_JMS_CONNECTION_FACTORY);
@Override
public String getResourceReferenceType() {
return TYPE;
}
@Override
public InjectionSource getResourceReferenceBindingSource() throws DeploymentUnitProcessingException {
return INJECTION_SOURCE;
}
}
}
| 3,880
| 48.126582
| 174
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/deployment/ParseResult.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.deployment;
import java.util.ArrayList;
import java.util.List;
/**
* @author Stuart Douglas
*/
class ParseResult {
private final List<JmsDestination> queues = new ArrayList<>();
private final List<JmsDestination> topics = new ArrayList<>();
public List<JmsDestination> getQueues() {
return queues;
}
public List<JmsDestination> getTopics() {
return topics;
}
}
| 1,482
| 31.955556
| 70
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/deployment/JMSConnectionFactoryDefinitionDescriptorProcessor.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.deployment;
import org.jboss.as.ee.resource.definition.ResourceDefinitionDescriptorProcessor;
import org.jboss.as.ee.resource.definition.ResourceDefinitionInjectionSource;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.metadata.javaee.spec.JMSConnectionFactoriesMetaData;
import org.jboss.metadata.javaee.spec.JMSConnectionFactoryMetaData;
import org.jboss.metadata.javaee.spec.RemoteEnvironment;
/**
* Process jms-connection-factory from deployment descriptor.
*
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2013 Red Hat inc.
* @author Eduardo Martins
*/
public class JMSConnectionFactoryDefinitionDescriptorProcessor extends ResourceDefinitionDescriptorProcessor {
@Override
protected void processEnvironment(RemoteEnvironment environment, ResourceDefinitionInjectionSources injectionSources) throws DeploymentUnitProcessingException {
final JMSConnectionFactoriesMetaData metaDatas = environment.getJmsConnectionFactories();
if (metaDatas != null) {
for(JMSConnectionFactoryMetaData metaData : metaDatas) {
injectionSources.addResourceDefinitionInjectionSource(getResourceDefinitionInjectionSource(metaData));
}
}
}
private ResourceDefinitionInjectionSource getResourceDefinitionInjectionSource(JMSConnectionFactoryMetaData metadata) {
final JMSConnectionFactoryDefinitionInjectionSource source = new JMSConnectionFactoryDefinitionInjectionSource(metadata.getName());
source.setInterfaceName(metadata.getInterfaceName());
source.setClassName(metadata.getClassName());
source.setResourceAdapter(metadata.getResourceAdapter());
source.setUser(metadata.getUser());
source.setPassword(metadata.getPassword());
source.setClientId(metadata.getClientId());
source.addProperties(metadata.getProperties());
source.setTransactional(metadata.isTransactional());
source.setMaxPoolSize(metadata.getMaxPoolSize());
source.setMinPoolSize(metadata.getMinPoolSize());
return source;
}
}
| 3,193
| 48.138462
| 164
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/deployment/MessagingAttachments.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.deployment;
import org.jboss.as.server.deployment.AttachmentKey;
import org.jboss.as.server.deployment.AttachmentList;
/**
*
*
* @author Stuart Douglas
*/
public class MessagingAttachments {
static final AttachmentKey<AttachmentList<ParseResult>> PARSE_RESULT = AttachmentKey.createList(ParseResult.class);
}
| 1,395
| 34.794872
| 119
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/deployment/Namespace.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.deployment;
import java.util.HashMap;
import java.util.Map;
/**
* An enumeration of the supported Messaging deployment namespaces
*
* @author Stuart Douglas
*/
public enum Namespace {
// must be first
UNKNOWN(null),
MESSAGING_DEPLOYMENT_1_0("urn:jboss:messaging-activemq-deployment:1.0"),
;
private final String name;
Namespace(final String name) {
this.name = name;
}
/**
* Get the URI of this namespace.
*
* @return the URI
*/
public String getUriString() {
return name;
}
private static final Map<String, Namespace> MAP;
static {
final Map<String, Namespace> map = new HashMap<String, Namespace>();
for (Namespace namespace : values()) {
final String name = namespace.getUriString();
if (name != null) map.put(name, namespace);
}
MAP = map;
}
public static Namespace forUri(String uri) {
final Namespace element = MAP.get(uri);
return element == null ? UNKNOWN : element;
}
}
| 2,093
| 28.083333
| 75
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/deployment/JMSConnectionFactoryDefinitionInjectionSource.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.deployment;
import static org.jboss.as.server.deployment.Attachments.CAPABILITY_SERVICE_SUPPORT;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.CONNECTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.CONNECTORS;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.DEFAULT;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.JGROUPS_CLUSTER;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.NO_TX;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.POOLED_CONNECTION_FACTORY;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.SERVER;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.XA_TX;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Common.DISCOVERY_GROUP;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Pooled.ENLISTMENT_TRACE;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Pooled.MANAGED_CONNECTION_POOL;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Pooled.MAX_POOL_SIZE;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Pooled.MIN_POOL_SIZE;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import jakarta.resource.spi.TransactionSupport;
import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
import org.apache.activemq.artemis.api.core.TransportConfiguration;
import org.apache.activemq.artemis.ra.ActiveMQRAConnectionFactoryImpl;
import org.jboss.as.connector.deployers.ra.ConnectionFactoryDefinitionInjectionSource;
import org.jboss.as.connector.services.resourceadapters.ConnectionFactoryReferenceFactoryService;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.ee.component.EEModuleDescription;
import org.jboss.as.ee.resource.definition.ResourceDefinitionInjectionSource;
import org.jboss.as.naming.ContextListAndJndiViewManagedReferenceFactory;
import org.jboss.as.naming.ManagedReference;
import org.jboss.as.naming.ManagedReferenceFactory;
import org.jboss.as.naming.deployment.ContextNames;
import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentResourceSupport;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.Property;
import org.jboss.msc.inject.Injector;
import org.jboss.msc.service.LifecycleEvent;
import org.jboss.msc.service.LifecycleListener;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceRegistry;
import org.jboss.msc.service.ServiceTarget;
import org.wildfly.extension.messaging.activemq.CommonAttributes;
import org.wildfly.extension.messaging.activemq.ExternalBrokerConfigurationService;
import org.wildfly.extension.messaging.activemq.MessagingExtension;
import org.wildfly.extension.messaging.activemq.MessagingServices;
import org.wildfly.extension.messaging.activemq.MessagingSubsystemRootResourceDefinition;
import org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttribute;
import org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes;
import org.wildfly.extension.messaging.activemq.jms.ExternalPooledConnectionFactoryService;
import org.wildfly.extension.messaging.activemq.jms.JMSServices;
import org.wildfly.extension.messaging.activemq.jms.PooledConnectionFactoryConfigProperties;
import org.wildfly.extension.messaging.activemq.jms.PooledConnectionFactoryConfigurationRuntimeHandler;
import org.wildfly.extension.messaging.activemq.jms.PooledConnectionFactoryDefinition;
import org.wildfly.extension.messaging.activemq.jms.PooledConnectionFactoryService;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2013 Red Hat inc.
* @author Eduardo Martins
*/
public class JMSConnectionFactoryDefinitionInjectionSource extends ResourceDefinitionInjectionSource {
/*
String description() default "";
String name();
String interfaceName() default "jakarta.jms.ConnectionFactory";
String className() default "";
String resourceAdapter() default "";
String user() default "";
String password() default "";
String clientId() default "";
String[] properties() default {};
boolean transactional() default true;
int maxPoolSize() default -1;
int minPoolSize() default -1;
*/
// not used: ActiveMQ CF implements all Jakarta Messaging CF interfaces
private String interfaceName;
// not used
private String className;
private String resourceAdapter;
private String user;
private String password;
private String clientId;
private boolean transactional;
private int maxPoolSize;
private int minPoolSize;
private boolean legacySecurityAvailable;
public JMSConnectionFactoryDefinitionInjectionSource(String jndiName) {
super(jndiName);
}
void setInterfaceName(String interfaceName) {
this.interfaceName = interfaceName;
}
void setClassName(String className) {
this.className = className;
}
void setResourceAdapter(String resourceAdapter) {
this.resourceAdapter = resourceAdapter;
}
void setUser(String user) {
this.user = user;
}
void setPassword(String password) {
this.password = password;
}
void setClientId(String clientId) {
this.clientId = clientId;
}
void setTransactional(boolean transactional) {
this.transactional = transactional;
}
void setMaxPoolSize(int maxPoolSize) {
this.maxPoolSize = maxPoolSize;
}
void setMinPoolSize(int minPoolSize) {
this.minPoolSize = minPoolSize;
}
public void setLegacySecurityAvailable(boolean legacySecurityAvailable) {
this.legacySecurityAvailable = legacySecurityAvailable;
}
@Override
public void getResourceValue(ResolutionContext context, ServiceBuilder<?> serviceBuilder, DeploymentPhaseContext phaseContext, Injector<ManagedReferenceFactory> injector) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if(resourceAdapter == null || resourceAdapter.isEmpty()) {
resourceAdapter = getDefaulResourceAdapter(deploymentUnit);
}
boolean external = targetsExternalPooledConnectionFactory(resourceAdapter, phaseContext.getServiceRegistry());
if (external || targetsPooledConnectionFactory(getActiveMQServerName(properties), resourceAdapter, phaseContext.getServiceRegistry())) {
try {
startedPooledConnectionFactory(context, jndiName, serviceBuilder, phaseContext.getServiceTarget(), deploymentUnit, injector, external);
} catch (OperationFailedException e) {
throw new DeploymentUnitProcessingException(e);
}
} else {
// delegate to the resource-adapter subsystem to create a generic Jakarta Connectors connection factory.
ConnectionFactoryDefinitionInjectionSource cfdis = new ConnectionFactoryDefinitionInjectionSource(jndiName, interfaceName, resourceAdapter);
cfdis.setMaxPoolSize(maxPoolSize);
cfdis.setMinPoolSize(minPoolSize);
cfdis.setTransactionSupportLevel(transactional ? TransactionSupport.TransactionSupportLevel.XATransaction : TransactionSupport.TransactionSupportLevel.NoTransaction);
cfdis.setLegacySecurityAvailable(legacySecurityAvailable);
// transfer all the generic properties + the additional properties specific to the JMSConnectionFactoryDefinition
for (Map.Entry<String, String> property : properties.entrySet()) {
cfdis.addProperty(property.getKey(), property.getValue());
}
if (!user.isEmpty()) {
cfdis.addProperty("user", user);
}
if (!password.isEmpty()) {
cfdis.addProperty("password", password);
}
if (!clientId.isEmpty()) {
cfdis.addProperty("clientId", clientId);
}
cfdis.getResourceValue(context, serviceBuilder, phaseContext, injector);
}
}
private void startedPooledConnectionFactory(ResolutionContext context, String name, ServiceBuilder<?> serviceBuilder,
ServiceTarget serviceTarget, DeploymentUnit deploymentUnit, Injector<ManagedReferenceFactory> injector,
boolean external) throws DeploymentUnitProcessingException, OperationFailedException {
Map<String, String> props = new HashMap<>(properties);
List<String> connectors = getConnectors(props);
clearUnknownProperties(properties);
ModelNode model = new ModelNode();
for (String connector : connectors) {
model.get(CONNECTORS).add(connector);
}
for (Map.Entry<String, String> entry : properties.entrySet()) {
model.get(entry.getKey()).set(entry.getValue());
}
model.get(MIN_POOL_SIZE.getName()).set(minPoolSize);
model.get(MAX_POOL_SIZE.getName()).set(maxPoolSize);
if (user != null && !user.isEmpty()) {
model.get(ConnectionFactoryAttributes.Pooled.USER.getName()).set(user);
}
if (password != null && !password.isEmpty()) {
model.get(ConnectionFactoryAttributes.Pooled.PASSWORD.getName()).set(password);
}
if (clientId != null && !clientId.isEmpty()) {
model.get(CommonAttributes.CLIENT_ID.getName()).set(clientId);
}
final String discoveryGroupName = properties.containsKey(DISCOVERY_GROUP.getName()) ? properties.get(DISCOVERY_GROUP.getName()) : null;
if (discoveryGroupName != null) {
model.get(DISCOVERY_GROUP.getName()).set(discoveryGroupName);
}
final String jgroupsChannelName = properties.containsKey(JGROUPS_CLUSTER.getName()) ? properties.get(JGROUPS_CLUSTER.getName()) : null;
if (jgroupsChannelName != null) {
model.get(JGROUPS_CLUSTER.getName()).set(jgroupsChannelName);
}
final String managedConnectionPoolClassName = properties.containsKey(MANAGED_CONNECTION_POOL.getName()) ? properties.get(MANAGED_CONNECTION_POOL.getName()) : null;
if (managedConnectionPoolClassName != null) {
model.get(MANAGED_CONNECTION_POOL.getName()).set(managedConnectionPoolClassName);
}
final Boolean enlistmentTrace = properties.containsKey(ENLISTMENT_TRACE.getName()) ? Boolean.valueOf(properties.get(ENLISTMENT_TRACE.getName())) : null;
List<PooledConnectionFactoryConfigProperties> adapterParams = getAdapterParams(model);
String txSupport = transactional ? XA_TX : NO_TX;
final String serverName;
final String pcfName = uniqueName(context, name);
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoForEnvEntry(context.getApplicationName(), context.getModuleName(), context.getComponentName(), !context.isCompUsesModule(), name);
if(external) {
serverName = null;
Set<String> connectorsSocketBindings = new HashSet<>();
Set<String> sslContextNames = new HashSet<>();
ExternalBrokerConfigurationService configuration = (ExternalBrokerConfigurationService)deploymentUnit.getServiceRegistry().getRequiredService(MessagingSubsystemRootResourceDefinition.CONFIGURATION_CAPABILITY.getCapabilityServiceName()).getService().getValue();
TransportConfiguration[] tcs = new TransportConfiguration[connectors.size()];
for (int i = 0; i < tcs.length; i++) {
tcs[i] = configuration.getConnectors().get(connectors.get(i));
if (tcs[i].getParams().containsKey(ModelDescriptionConstants.SOCKET_BINDING)) {
connectorsSocketBindings.add(tcs[i].getParams().get(ModelDescriptionConstants.SOCKET_BINDING).toString());
}
if (tcs[i].getParams().containsKey(ModelDescriptionConstants.SSL_CONTEXT)) {
sslContextNames.add(tcs[i].getParams().get(ModelDescriptionConstants.SSL_CONTEXT).toString());
}
}
DiscoveryGroupConfiguration discoveryGroupConfiguration = null;
if(discoveryGroupName != null) {
discoveryGroupConfiguration = configuration.getDiscoveryGroupConfigurations().get(discoveryGroupName);
}
if (connectors.isEmpty() && discoveryGroupConfiguration == null) {
tcs = getExternalPooledConnectionFactory(resourceAdapter, deploymentUnit.getServiceRegistry()).getConnectors();
for (int i = 0; i < tcs.length; i++) {
if (tcs[i].getParams().containsKey(ModelDescriptionConstants.SOCKET_BINDING)) {
connectorsSocketBindings.add(tcs[i].getParams().get(ModelDescriptionConstants.SOCKET_BINDING).toString());
}
if (tcs[i].getParams().containsKey(ModelDescriptionConstants.SSL_CONTEXT)) {
sslContextNames.add(tcs[i].getParams().get(ModelDescriptionConstants.SSL_CONTEXT).toString());
}
}
}
ExternalPooledConnectionFactoryService.installService(serviceTarget, configuration, pcfName, tcs, discoveryGroupConfiguration,
connectorsSocketBindings, sslContextNames, null, jgroupsChannelName, adapterParams, bindInfo, Collections.emptyList(),
txSupport, minPoolSize, maxPoolSize, managedConnectionPoolClassName, enlistmentTrace, deploymentUnit.getAttachment(CAPABILITY_SERVICE_SUPPORT));
} else {
serverName = getActiveMQServerName(properties);
PooledConnectionFactoryService.installService(serviceTarget, pcfName, serverName, connectors,
discoveryGroupName, jgroupsChannelName, adapterParams, bindInfo, txSupport, minPoolSize,
maxPoolSize, managedConnectionPoolClassName, enlistmentTrace, true);
}
final ServiceName referenceFactoryServiceName = ConnectionFactoryReferenceFactoryService.SERVICE_NAME_BASE
.append(bindInfo.getBinderServiceName());
serviceBuilder.addDependency(referenceFactoryServiceName, ManagedReferenceFactory.class, injector);
//create the management registration
String managementName = managementName(context, name);
final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT);
final PathElement pcfPath = PathElement.pathElement(POOLED_CONNECTION_FACTORY, managementName);
PathAddress registration;
if (external) {
deploymentResourceSupport.getDeploymentSubsystemModel(MessagingExtension.SUBSYSTEM_NAME);
registration = PathAddress.pathAddress(pcfPath);
} else {
final PathElement serverElement = PathElement.pathElement(SERVER, serverName);
deploymentResourceSupport.getDeploymentSubModel(MessagingExtension.SUBSYSTEM_NAME, serverElement);
registration = PathAddress.pathAddress(serverElement, pcfPath);
}
MessagingXmlInstallDeploymentUnitProcessor.createDeploymentSubModel(registration, deploymentUnit);
if(external) {
PooledConnectionFactoryConfigurationRuntimeHandler.EXTERNAL_INSTANCE.registerResource(serverName, managementName, model);
} else {
PooledConnectionFactoryConfigurationRuntimeHandler.INSTANCE.registerResource(serverName, managementName, model);
}
}
private List<String> getConnectors(Map<String, String> props) {
List<String> connectors = new ArrayList<>();
if (props.containsKey(CONNECTORS)) {
String connectorsStr = properties.remove(CONNECTORS);
for (String s : connectorsStr.split(",")) {
String connector = s.trim();
if (!connector.isEmpty()) {
connectors.add(connector);
}
}
}
if (props.containsKey(CONNECTOR)) {
String connector = properties.remove(CONNECTOR).trim();
if (!connector.isEmpty()) {
connectors.add(connector);
}
}
return connectors;
}
void clearUnknownProperties(final Map<String, String> props) {
Map<String, ConnectionFactoryAttribute> attributesMap = PooledConnectionFactoryDefinition.getAttributesMap();
final Iterator<Map.Entry<String, String>> it = props.entrySet().iterator();
while (it.hasNext()) {
final Map.Entry<String, String> entry = it.next();
String value = entry.getKey();
if (value == null || "".equals(value)) {
it.remove();
} else if (!attributesMap.containsKey(entry.getKey())) {
MessagingLogger.ROOT_LOGGER.unknownPooledConnectionFactoryAttribute(entry.getKey());
it.remove();
}
}
}
private static String uniqueName(ResolutionContext context, final String jndiName) {
StringBuilder uniqueName = new StringBuilder();
return uniqueName.append(context.getApplicationName()).append("_")
.append(managementName(context, jndiName))
.toString();
}
private static String managementName(ResolutionContext context, final String jndiName) {
StringBuilder uniqueName = new StringBuilder();
uniqueName.append(context.getModuleName()).append("_");
if (context.getComponentName() != null) {
uniqueName.append(context.getComponentName()).append("_");
}
return uniqueName
.append(jndiName.replace(':', '_'))
.toString();
}
private List<PooledConnectionFactoryConfigProperties> getAdapterParams(ModelNode model) {
Map<String, ConnectionFactoryAttribute> attributes = PooledConnectionFactoryDefinition.getAttributesMap();
List<PooledConnectionFactoryConfigProperties> props = new ArrayList<>();
for (Property property : model.asPropertyList()) {
ConnectionFactoryAttribute attribute = attributes.get(property.getName());
if (attribute.getPropertyName() == null) {
// not a RA property
continue;
}
props.add(new PooledConnectionFactoryConfigProperties(attribute.getPropertyName(), property.getValue().asString(), attribute.getClassType(), attribute.getConfigType()));
}
return props;
}
/**
* Return whether the definition targets an existing pooled connection factory or use a Jakarta Connectors-based ConnectionFactory.
*
* Checks the service registry for a PooledConnectionFactoryService with the ServiceName
* created by the {@code server} property (or {@code "default") and the {@code resourceAdapter} property.
*/
static boolean targetsPooledConnectionFactory(String server, String resourceAdapter, ServiceRegistry serviceRegistry) {
// if the resourceAdapter is not defined, the default behaviour is to create a pooled-connection-factory.
if (resourceAdapter == null || resourceAdapter.isEmpty()) {
return true;
}
ServiceName activeMQServiceName = MessagingServices.getActiveMQServiceName(server);
ServiceName pcfName = JMSServices.getPooledConnectionFactoryBaseServiceName(activeMQServiceName).append(resourceAdapter);
return serviceRegistry.getServiceNames().contains(pcfName);
}
/**
* Return whether the definition targets an existing external pooled connection factory.
*
* Checks the service registry for a PooledConnectionFactoryService with the ServiceName
* created by the {@code server} property (or {@code "default") and the {@code resourceAdapter} property.
*/
static boolean targetsExternalPooledConnectionFactory(String resourceAdapter, ServiceRegistry serviceRegistry) {
// if the resourceAdapter is not defined, the default behaviour is to create a pooled-connection-factory.
if (resourceAdapter == null || resourceAdapter.isEmpty()) {
return false;
}
//let's look into the external-pooled-connection-factory
ServiceName pcfName = JMSServices.getPooledConnectionFactoryBaseServiceName(MessagingServices.getActiveMQServiceName()).append(resourceAdapter);
return serviceRegistry.getServiceNames().contains(pcfName);
}
private static ExternalPooledConnectionFactoryService getExternalPooledConnectionFactory(String resourceAdapter, ServiceRegistry serviceRegistry) {
//let's look into the external-pooled-connection-factory
ServiceName pcfName = JMSServices.getPooledConnectionFactoryBaseServiceName(MessagingServices.getActiveMQServiceName()).append(resourceAdapter);
return (ExternalPooledConnectionFactoryService) serviceRegistry.getService(pcfName).getValue();
}
static String getDefaulResourceAdapter(DeploymentUnit deploymentUnit) {
EEModuleDescription eeDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
if (eeDescription != null) {
String defaultJndiName = eeDescription.getDefaultResourceJndiNames().getJmsConnectionFactory();
ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(defaultJndiName);
ServiceController binder = deploymentUnit.getServiceRegistry().getService(bindInfo.getBinderServiceName());
if (binder != null) {
Object pcf = binder.getService().getValue();
ServiceController.State currentState = binder.getState();
CountDownLatch latch = new CountDownLatch(1);
if(currentState != ServiceController.State.UP) {
LifecycleListener lifecycleListener = new LifecycleListener() {
@Override
public void handleEvent(ServiceController<?> controller, LifecycleEvent event) {
latch.countDown();
}
};
try {
binder.addListener(lifecycleListener);
latch.await();
} catch (InterruptedException ex) {
return null;
} finally {
binder.removeListener(lifecycleListener);
}
}
if(currentState != ServiceController.State.UP) {
return null;
}
//In case of multiple JNDI entries only the 1st is properly bound
if (pcf != null && pcf instanceof ContextListAndJndiViewManagedReferenceFactory) {
ManagedReference ref = ((ContextListAndJndiViewManagedReferenceFactory) pcf).getReference();
Object ra = ref.getInstance();
if (ra instanceof ActiveMQRAConnectionFactoryImpl) {
bindInfo = ContextNames.bindInfoFor(((ActiveMQRAConnectionFactoryImpl) ra).getReference().getClassName());
binder = deploymentUnit.getServiceRegistry().getService(bindInfo.getBinderServiceName());
if (binder != null) {
pcf = binder.getService().getValue();
}
}
}
if (pcf != null && pcf instanceof ConnectionFactoryReferenceFactoryService) {
return ((ConnectionFactoryReferenceFactoryService) pcf).getName();
}
}
}
return null;
}
/**
* The Jakarta Messaging connection factory can specify another server to deploy its destinations
* by passing a property server=<name of the server>. Otherwise, "default" is used by default.
*/
static String getActiveMQServerName(Map<String, String> properties) {
return properties.getOrDefault(SERVER, DEFAULT);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
JMSConnectionFactoryDefinitionInjectionSource that = (JMSConnectionFactoryDefinitionInjectionSource) o;
if (maxPoolSize != that.maxPoolSize) return false;
if (minPoolSize != that.minPoolSize) return false;
if (transactional != that.transactional) return false;
if (className != null ? !className.equals(that.className) : that.className != null) return false;
if (clientId != null ? !clientId.equals(that.clientId) : that.clientId != null) return false;
if (interfaceName != null ? !interfaceName.equals(that.interfaceName) : that.interfaceName != null)
return false;
if (password != null ? !password.equals(that.password) : that.password != null) return false;
if (resourceAdapter != null ? !resourceAdapter.equals(that.resourceAdapter) : that.resourceAdapter != null)
return false;
if (user != null ? !user.equals(that.user) : that.user != null) return false;
return true;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (interfaceName != null ? interfaceName.hashCode() : 0);
result = 31 * result + (className != null ? className.hashCode() : 0);
result = 31 * result + (resourceAdapter != null ? resourceAdapter.hashCode() : 0);
result = 31 * result + (user != null ? user.hashCode() : 0);
result = 31 * result + (password != null ? password.hashCode() : 0);
result = 31 * result + (clientId != null ? clientId.hashCode() : 0);
result = 31 * result + (transactional ? 1 : 0);
result = 31 * result + maxPoolSize;
result = 31 * result + minPoolSize;
return result;
}
}
| 27,963
| 51.862004
| 272
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/deployment/MessagingJMSDestinationManagedReferenceFactory.java
|
/*
*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
* /
*/
package org.wildfly.extension.messaging.activemq.deployment;
import jakarta.jms.Destination;
import org.jboss.as.naming.ContextListAndJndiViewManagedReferenceFactory;
import org.jboss.as.naming.ContextListManagedReferenceFactory;
import org.jboss.as.naming.ManagedReference;
import org.jboss.as.naming.ValueManagedReference;
import org.jboss.msc.service.Service;
/**
* @author <a href="mailto:tomaz.cerar@redhat.com">Tomaz Cerar</a> (c) 2013 Red Hat Inc.
*/
class MessagingJMSDestinationManagedReferenceFactory<D extends Destination> implements ContextListAndJndiViewManagedReferenceFactory {
private final Service<D> service;
public MessagingJMSDestinationManagedReferenceFactory(Service<D> service) {
this.service = service;
}
@Override
public String getJndiViewInstanceValue() {
return String.valueOf(getReference().getInstance());
}
@Override
public String getInstanceClassName() {
final Object value = getReference().getInstance();
return value != null ? value.getClass().getName() : ContextListManagedReferenceFactory.DEFAULT_INSTANCE_CLASS_NAME;
}
@Override
public ManagedReference getReference() {
return new ValueManagedReference(service.getValue());
}
}
| 2,308
| 36.241935
| 134
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/broadcast/CommandDispatcherBroadcastEndpointClassTableContributor.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2017, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.broadcast;
import java.util.Arrays;
import java.util.List;
import org.kohsuke.MetaInfServices;
import org.wildfly.clustering.marshalling.jboss.ClassTableContributor;
/**
* {@link ClassTableContributor} for a {@link CommandDispatcherBroadcastEndpoint}.
* @author Paul Ferraro
*/
@MetaInfServices(ClassTableContributor.class)
public class CommandDispatcherBroadcastEndpointClassTableContributor implements ClassTableContributor {
@Override
public List<Class<?>> getKnownClasses() {
return Arrays.asList(BroadcastCommand.class);
}
}
| 1,630
| 36.930233
| 103
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/broadcast/BroadcastCommandDispatcherFactoryInstaller.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2021, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.broadcast;
import java.util.Collections;
import java.util.Set;
import java.util.TreeSet;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Supplier;
import org.jboss.as.controller.OperationContext;
import org.jboss.msc.Service;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.wildfly.clustering.server.dispatcher.CommandDispatcherFactory;
import org.wildfly.clustering.server.service.ClusteringRequirement;
import org.wildfly.clustering.service.FunctionalService;
import org.wildfly.extension.messaging.activemq.MessagingServices;
/**
* Installs a distinct {@link BroadcastCommandDispatcherFactory} service per channel.
* @author Paul Ferraro
*/
public class BroadcastCommandDispatcherFactoryInstaller implements BiConsumer<OperationContext, String> {
private final Set<ServiceName> names = Collections.synchronizedSet(new TreeSet<>());
@Override
public void accept(OperationContext context, String channelName) {
ServiceName name = MessagingServices.getBroadcastCommandDispatcherFactoryServiceName(channelName);
// N.B. BroadcastCommandDispatcherFactory implementations are shared across multiple server resources
if (this.names.add(name)) {
ServiceBuilder<?> builder = context.getServiceTarget().addService(name);
Consumer<BroadcastCommandDispatcherFactory> injector = builder.provides(name);
Supplier<CommandDispatcherFactory> factory = builder.requires(ClusteringRequirement.COMMAND_DISPATCHER_FACTORY.getServiceName(context, channelName));
Service service = new FunctionalService<>(injector, ConcurrentBroadcastCommandDispatcherFactory::new, factory);
builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
}
}
}
| 2,989
| 46.460317
| 161
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/broadcast/ConcurrentBroadcastCommandDispatcherFactory.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2021, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.broadcast;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;
import java.util.function.Function;
import org.wildfly.clustering.Registration;
import org.wildfly.clustering.dispatcher.Command;
import org.wildfly.clustering.dispatcher.CommandDispatcher;
import org.wildfly.clustering.dispatcher.CommandDispatcherException;
import org.wildfly.clustering.ee.Manager;
import org.wildfly.clustering.ee.cache.ConcurrentManager;
import org.wildfly.clustering.group.Group;
import org.wildfly.clustering.group.Node;
import org.wildfly.clustering.server.dispatcher.CommandDispatcherFactory;
import org.wildfly.common.function.Functions;
import org.wildfly.security.manager.WildFlySecurityManager;
/**
* A {@link BroadcastCommandDispatcherFactory} that returns the same {@link CommandDispatcher} instance for a given identifier.
* @author Paul Ferraro
*/
public class ConcurrentBroadcastCommandDispatcherFactory implements BroadcastCommandDispatcherFactory {
private final Set<BroadcastReceiver> receivers = ConcurrentHashMap.newKeySet();
private final Manager<Object, CommandDispatcher<?>> dispatchers = new ConcurrentManager<>(Functions.discardingConsumer(), new Consumer<CommandDispatcher<?>>() {
@Override
public void accept(CommandDispatcher<?> dispatcher) {
((ConcurrentCommandDispatcher<?>) dispatcher).closeDispatcher();
}
});
private final CommandDispatcherFactory factory;
public ConcurrentBroadcastCommandDispatcherFactory(CommandDispatcherFactory factory) {
this.factory = factory;
}
@Override
public void receive(byte[] data) {
for (BroadcastReceiver receiver : this.receivers) {
receiver.receive(data);
}
}
@Override
public Registration register(BroadcastReceiver receiver) {
this.receivers.add(receiver);
return () -> this.receivers.remove(receiver);
}
@Override
public Group getGroup() {
return this.factory.getGroup();
}
@SuppressWarnings("unchecked")
@Override
public <C> CommandDispatcher<C> createCommandDispatcher(Object id, C context) {
CommandDispatcherFactory dispatcherFactory = this.factory;
Function<Runnable, CommandDispatcher<?>> factory = new Function<Runnable, CommandDispatcher<?>>() {
@Override
public CommandDispatcher<C> apply(Runnable closeTask) {
CommandDispatcher<C> dispatcher = dispatcherFactory.createCommandDispatcher(id, context, WildFlySecurityManager.getClassLoaderPrivileged(this.getClass()));
return new ConcurrentCommandDispatcher<>(dispatcher, closeTask);
}
};
return (CommandDispatcher<C>) this.dispatchers.apply(id, factory);
}
private static class ConcurrentCommandDispatcher<C> implements CommandDispatcher<C> {
private final CommandDispatcher<C> dispatcher;
private final Runnable closeTask;
ConcurrentCommandDispatcher(CommandDispatcher<C> dispatcher, Runnable closeTask) {
this.dispatcher = dispatcher;
this.closeTask = closeTask;
}
void closeDispatcher() {
this.dispatcher.close();
}
@Override
public C getContext() {
return this.dispatcher.getContext();
}
@Override
public <R> CompletionStage<R> executeOnMember(Command<R, ? super C> command, Node member) throws CommandDispatcherException {
return this.dispatcher.executeOnMember(command, member);
}
@Override
public <R> Map<Node, CompletionStage<R>> executeOnGroup(Command<R, ? super C> command, Node... excludedMembers) throws CommandDispatcherException {
return this.dispatcher.executeOnGroup(command, excludedMembers);
}
@Override
public void close() {
this.closeTask.run();
}
}
}
| 5,104
| 38.269231
| 171
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/broadcast/BroadcastReceiverRegistrar.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2021, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.broadcast;
import org.wildfly.clustering.Registrar;
/**
* A {@link BroadcastReceiver} that notifies a set of registered {@link BroadcastReceiver} instances.
* @author Paul Ferraro
*/
public interface BroadcastReceiverRegistrar extends BroadcastReceiver, Registrar<BroadcastReceiver> {
}
| 1,365
| 40.393939
| 101
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/broadcast/CommandDispatcherBroadcastEndpoint.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2017, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.broadcast;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import org.apache.activemq.artemis.api.core.BroadcastEndpoint;
import org.wildfly.clustering.Registration;
import org.wildfly.clustering.dispatcher.CommandDispatcher;
import org.wildfly.clustering.dispatcher.CommandDispatcherFactory;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* A {@link BroadcastEndpoint} based on a {@link CommandDispatcher}.
* @author Paul Ferraro
*/
public class CommandDispatcherBroadcastEndpoint implements BroadcastEndpoint {
private enum Mode {
BROADCASTER, RECEIVER, CLOSED;
}
private final CommandDispatcherFactory factory;
private final String name;
private final BroadcastReceiverRegistrar registrar;
private final Function<String, BroadcastManager> managerFactory;
private final AtomicReference<Mode> mode = new AtomicReference<>(Mode.CLOSED);
private volatile BroadcastManager manager = null;
private volatile Registration registration = null;
private volatile CommandDispatcher<BroadcastReceiver> dispatcher;
public CommandDispatcherBroadcastEndpoint(CommandDispatcherFactory factory, String name, BroadcastReceiverRegistrar registrar, Function<String, BroadcastManager> managerFactory) {
this.factory = factory;
this.name = name;
this.registrar = registrar;
this.managerFactory = managerFactory;
}
@Override
public void openClient() throws Exception {
if (this.mode.compareAndSet(Mode.CLOSED, Mode.RECEIVER)) {
this.manager = this.managerFactory.apply(this.name);
this.registration = this.registrar.register(this.manager);
this.open();
}
}
@Override
public void openBroadcaster() throws Exception {
if (this.mode.compareAndSet(Mode.CLOSED, Mode.BROADCASTER)) {
this.open();
}
}
private void open() throws Exception {
this.dispatcher = this.factory.createCommandDispatcher(this.name, this.registrar);
}
@Override
public void close(boolean isBroadcast) throws Exception {
if (this.mode.getAndSet(Mode.CLOSED) != Mode.CLOSED) {
if (this.dispatcher != null) {
this.dispatcher.close();
}
if (this.registration != null) {
this.registration.close();
}
if (this.manager != null) {
this.manager.clear();
}
}
}
@Override
public void broadcast(byte[] data) throws Exception {
if (this.mode.get() == Mode.BROADCASTER) {
if (MessagingLogger.ROOT_LOGGER.isDebugEnabled()) {
MessagingLogger.ROOT_LOGGER.debugf("Broadcasting to group %s: %s", this.name, Arrays.toString(data));
}
this.dispatcher.executeOnGroup(new BroadcastCommand(data));
}
}
@Override
public byte[] receiveBroadcast() throws Exception {
return (this.mode.get() == Mode.RECEIVER) ? this.manager.getBroadcast() : null;
}
@Override
public byte[] receiveBroadcast(long time, TimeUnit unit) throws Exception {
return (this.mode.get() == Mode.RECEIVER) ? this.manager.getBroadcast(time, unit) : null;
}
}
| 4,447
| 36.694915
| 183
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/broadcast/BroadcastCommandDispatcherFactory.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2021, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.broadcast;
import org.wildfly.clustering.dispatcher.CommandDispatcherFactory;
/**
* A {@link CommandDispatcherFactory} that is also a registry of {@link BroadcastReceiver}s.
* @author Paul Ferraro
*/
public interface BroadcastCommandDispatcherFactory extends CommandDispatcherFactory, BroadcastReceiverRegistrar {
}
| 1,395
| 40.058824
| 113
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/broadcast/BroadcastManager.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2017, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.broadcast;
import java.util.concurrent.TimeUnit;
/**
* @author Paul Ferraro
*/
public interface BroadcastManager extends BroadcastReceiver {
byte[] getBroadcast() throws InterruptedException;
byte[] getBroadcast(long timeout, TimeUnit unit) throws InterruptedException;
void clear();
}
| 1,378
| 35.289474
| 81
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/broadcast/CommandDispatcherBroadcastEndpointFactory.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2017, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.broadcast;
import org.apache.activemq.artemis.api.core.BroadcastEndpoint;
import org.apache.activemq.artemis.api.core.BroadcastEndpointFactory;
import org.wildfly.clustering.dispatcher.CommandDispatcherFactory;
/**
* A {@link BroadcastEndpointFactory} based on a {@link CommandDispatcherFactory}.
* @author Paul Ferraro
*/
@SuppressWarnings("serial")
public class CommandDispatcherBroadcastEndpointFactory implements BroadcastEndpointFactory {
private final BroadcastCommandDispatcherFactory factory;
private final String name;
public CommandDispatcherBroadcastEndpointFactory(BroadcastCommandDispatcherFactory factory, String name) {
this.factory = factory;
this.name = name;
}
@Override
public BroadcastEndpoint createBroadcastEndpoint() throws Exception {
return new CommandDispatcherBroadcastEndpoint(this.factory, this.name, this.factory, QueueBroadcastManager::new);
}
}
| 2,010
| 40.040816
| 121
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/broadcast/QueueBroadcastManager.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2017, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.broadcast;
import java.util.Arrays;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.TimeUnit;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* @author Paul Ferraro
*/
public class QueueBroadcastManager implements BroadcastManager {
private final BlockingQueue<byte[]> broadcasts = new LinkedBlockingDeque<>();
private final String name;
public QueueBroadcastManager(String name) {
this.name = name;
}
@Override
public void receive(byte[] broadcast) {
if (MessagingLogger.ROOT_LOGGER.isDebugEnabled()) {
MessagingLogger.ROOT_LOGGER.debugf("Received broadcast from group %s: %s", this.name, Arrays.toString(broadcast));
}
this.broadcasts.add(broadcast);
}
@Override
public byte[] getBroadcast() throws InterruptedException {
return this.broadcasts.take();
}
@Override
public byte[] getBroadcast(long timeout, TimeUnit unit) throws InterruptedException {
return this.broadcasts.poll(timeout, unit);
}
@Override
public void clear() {
this.broadcasts.clear();
}
}
| 2,276
| 33.5
| 126
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/broadcast/BroadcastReceiver.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.broadcast;
/**
* A receiver of a broadcast.
* @author Paul Ferraro
*/
public interface BroadcastReceiver {
/**
* Receives the specified broadcast data.
* @param data broadcast data
*/
void receive(byte[] data);
}
| 1,313
| 35.5
| 70
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/broadcast/BroadcastCommand.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2017, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.broadcast;
import org.wildfly.clustering.dispatcher.Command;
/**
* A {@link Command} that receives a broadcast.
* @author Paul Ferraro
*/
public class BroadcastCommand implements Command<Void, BroadcastReceiver> {
private static final long serialVersionUID = 4354035602902924182L;
private final byte[] data;
public BroadcastCommand(byte[] data) {
this.data = data;
}
@Override
public Void execute(BroadcastReceiver receiver) {
receiver.receive(this.data);
return null;
}
}
| 1,606
| 33.934783
| 75
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/shallow/OperationAddressConverter.java
|
/*
* Copyright 2019 JBoss by Red Hat.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.extension.messaging.activemq.shallow;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.PathAddress;
import org.jboss.dmr.ModelNode;
/**
*
* @author Emmanuel Hugonnet (c) 2019 Red Hat, Inc.
*/
public interface OperationAddressConverter {
PathAddress convert(OperationContext context, ModelNode operation);
}
| 971
| 30.354839
| 75
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/shallow/TranslatedReadAttributeHandler.java
|
/*
* Copyright 2019 JBoss by Red Hat.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.extension.messaging.activemq.shallow;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import java.util.Set;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.operations.global.ReadAttributeHandler;
import org.jboss.dmr.ModelNode;
/**
*
* @author Emmanuel Hugonnet (c) 2019 Red Hat, Inc.
*/
public class TranslatedReadAttributeHandler implements OperationStepHandler {
private final OperationAddressConverter converter;
private final IgnoredAttributeProvider provider;
public TranslatedReadAttributeHandler(OperationAddressConverter converter, IgnoredAttributeProvider provider) {
this.converter = converter;
this.provider = provider;
}
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
PathAddress targetAddress = converter.convert(context, operation);
Set<String> ignoredAttributes = provider.getIgnoredAttributes(context, operation);
ModelNode op = operation.clone();
String attribute = op.require(ModelDescriptionConstants.NAME).asString();
if (ignoredAttributes.contains(attribute)) {
return;
}
op.get(OP_ADDR).set(targetAddress.toModelNode());
OperationStepHandler readAttributeHandler = context.getRootResourceRegistration().getAttributeAccess(targetAddress, attribute).getReadHandler();
if (readAttributeHandler == null) {
readAttributeHandler = ReadAttributeHandler.INSTANCE;
}
context.addStep(op, readAttributeHandler, context.getCurrentStage(), true);
}
}
| 2,507
| 40.8
| 152
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/shallow/ShallowResourceAdd.java
|
/*
* Copyright 2019 JBoss by Red Hat.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.extension.messaging.activemq.shallow;
import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.registry.Resource;
import org.jboss.dmr.ModelNode;
/**
* Abstract class to Add a ShallowResource.
* @author Emmanuel Hugonnet (c) 2019 Red Hat, Inc.
*/
public abstract class ShallowResourceAdd extends AbstractAddStepHandler {
protected ShallowResourceAdd(AttributeDefinition... attributes) {
super(attributes);
}
@Override
protected void populateModel(final ModelNode operation, final ModelNode model) throws OperationFailedException {
//do nothing
}
@Override
protected Resource createResource(OperationContext context) {
final Resource toAdd = Resource.Factory.create(true);
context.addResource(PathAddress.EMPTY_ADDRESS, toAdd);
return toAdd;
}
}
| 1,679
| 33.285714
| 116
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/shallow/TranslatedOperationHandler.java
|
/*
* Copyright 2019 JBoss by Red Hat.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.extension.messaging.activemq.shallow;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathAddress;
import org.jboss.dmr.ModelNode;
/**
*
* @author Emmanuel Hugonnet (c) 2019 Red Hat, Inc.
*/
public class TranslatedOperationHandler implements OperationStepHandler {
private final OperationAddressConverter converter;
public TranslatedOperationHandler(OperationAddressConverter converter) {
this.converter = converter;
}
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
PathAddress targetAddress = converter.convert(context, operation);
ModelNode op = operation.clone();
op.get(OP_ADDR).set(targetAddress.toModelNode());
String operationName = op.require(OP).asString();
OperationStepHandler operationHandler = context.getRootResourceRegistration().getOperationHandler(targetAddress, operationName);
context.addStep(op, operationHandler, context.getCurrentStage(), true);
}
}
| 1,956
| 38.938776
| 136
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/shallow/IgnoredAttributeProvider.java
|
/*
* Copyright 2019 JBoss by Red Hat.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.extension.messaging.activemq.shallow;
import java.util.Set;
import org.jboss.as.controller.OperationContext;
import org.jboss.dmr.ModelNode;
/**
*
* @author Emmanuel Hugonnet (c) 2019 Red Hat, Inc.
*/
public interface IgnoredAttributeProvider {
Set<String> getIgnoredAttributes(OperationContext context, ModelNode operation);
}
| 959
| 32.103448
| 84
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/shallow/ShallowResourceDefinition.java
|
/*
* Copyright 2019 JBoss by Red Hat.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.extension.messaging.activemq.shallow;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.logging.ControllerLogger;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.dmr.ModelNode;
import org.wildfly.extension.messaging.activemq.CommonAttributes;
/**
*
* @author Emmanuel Hugonnet (c) 2019 Red Hat, Inc.
*/
public abstract class ShallowResourceDefinition extends PersistentResourceDefinition implements OperationAddressConverter, IgnoredAttributeProvider {
protected final boolean registerRuntimeOnly;
public ShallowResourceDefinition(SimpleResourceDefinition.Parameters parameters, boolean registerRuntimeOnly) {
super(parameters);
this.registerRuntimeOnly = registerRuntimeOnly;
}
@Override
public void registerOperations(ManagementResourceRegistration resourceRegistration) {
TranslatedOperationHandler handler = new TranslatedOperationHandler(this);
// Override global operations with transformed operations, if necessary
resourceRegistration.registerOperationHandler(org.jboss.as.controller.operations.global.MapOperations.MAP_CLEAR_DEFINITION, handler);
resourceRegistration.registerOperationHandler(org.jboss.as.controller.operations.global.MapOperations.MAP_PUT_DEFINITION, handler);
resourceRegistration.registerOperationHandler(org.jboss.as.controller.operations.global.MapOperations.MAP_GET_DEFINITION, handler);
resourceRegistration.registerOperationHandler(org.jboss.as.controller.operations.global.MapOperations.MAP_REMOVE_DEFINITION, handler);
resourceRegistration.registerOperationHandler(org.jboss.as.controller.operations.global.ListOperations.LIST_ADD_DEFINITION, handler);
resourceRegistration.registerOperationHandler(org.jboss.as.controller.operations.global.ListOperations.LIST_GET_DEFINITION, handler);
resourceRegistration.registerOperationHandler(org.jboss.as.controller.operations.global.ListOperations.LIST_REMOVE_DEFINITION, handler);
resourceRegistration.registerOperationHandler(org.jboss.as.controller.operations.global.ListOperations.LIST_CLEAR_DEFINITION, handler);
super.registerOperations(resourceRegistration);
}
@Override
public void registerAttributes(ManagementResourceRegistration registry) {
for (AttributeDefinition attr : getAttributes()) {
if (registerRuntimeOnly || !attr.getFlags().contains(AttributeAccess.Flag.STORAGE_RUNTIME)) {
registry.registerReadWriteAttribute(attr, new TranslatedReadAttributeHandler(this, this), new TranslatedWriteAttributeHandler(this));
} else {
registry.registerReadOnlyAttribute(attr, new TranslatedReadAttributeHandler(this, this));
}
}
}
/**
* This provides more informative message when a user tries to undefine attribute that is required by the
* jgroups-discovery-group or socket-discovery-group resources (while it hasn't been required on the original
* discovery-group resource).
* @param context
* @param targetAddress
* @param translatedOperation
* @throws org.jboss.as.controller.OperationFailedException
*/
protected void validateOperation(OperationContext context, PathAddress targetAddress, ModelNode translatedOperation)
throws OperationFailedException {
String attributeName = translatedOperation.get(ModelDescriptionConstants.NAME).asString();
String operationName = translatedOperation.get(ModelDescriptionConstants.OP).asString();
boolean isUsingSocketBinding = isUsingSocketBinding(targetAddress);
// if undefining an attribute
if ((ModelDescriptionConstants.UNDEFINE_ATTRIBUTE_OPERATION.equals(operationName)
|| ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION.equals(operationName))
&& !translatedOperation.hasDefined(ModelDescriptionConstants.VALUE)) {
// and the attribute is socket-binding on a socket-discovery-group,
// or jgroups-cluster on a jgroups-discovery-group, throw an error
if ((isUsingSocketBinding && CommonAttributes.SOCKET_BINDING.getName().equals(attributeName))
|| (!isUsingSocketBinding && CommonAttributes.JGROUPS_CLUSTER.getName().equals(attributeName))) {
throw ControllerLogger.ROOT_LOGGER.validationFailedRequiredParameterNotPresent(attributeName, translatedOperation.toString());
}
}
}
protected abstract boolean isUsingSocketBinding(PathAddress targetAddress);
}
| 5,651
| 54.960396
| 149
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/shallow/TranslatedWriteAttributeHandler.java
|
/*
* Copyright 2019 JBoss by Red Hat.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.extension.messaging.activemq.shallow;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.dmr.ModelNode;
import org.jboss.logging.Logger;
/**
*
* @author Emmanuel Hugonnet (c) 2019 Red Hat, Inc.
*/
public class TranslatedWriteAttributeHandler implements OperationStepHandler {
private static final Logger LOG = Logger.getLogger(TranslatedWriteAttributeHandler.class);
private final ShallowResourceDefinition shallowResource;
public TranslatedWriteAttributeHandler(ShallowResourceDefinition shallowResource) {
this.shallowResource = shallowResource;
}
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
PathAddress targetAddress = shallowResource.convert(context, operation);
ModelNode op = operation.clone();
op.get(OP_ADDR).set(targetAddress.toModelNode());
String attributeName = op.get(ModelDescriptionConstants.NAME).asString();
if (!shallowResource.getIgnoredAttributes(context, op).contains(attributeName)) {
shallowResource.validateOperation(context, targetAddress, op);
OperationStepHandler writeAttributeHandler = context.getRootResourceRegistration()
.getAttributeAccess(targetAddress, attributeName).getWriteHandler();
context.addStep(op, writeAttributeHandler, context.getCurrentStage(), true);
} else {
LOG.debugf("Ignoring write operation on resource %s, attribute %s. The attribute is ignored.",
targetAddress.toString(), attributeName);
}
}
}
| 2,555
| 43.068966
| 106
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/ExternalJMSTopicRemove.java
|
/*
* Copyright 2018 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.extension.messaging.activemq.jms;
import org.jboss.as.controller.AbstractRemoveStepHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.naming.deployment.ContextNames;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceName;
import org.wildfly.extension.messaging.activemq.CommonAttributes;
import org.wildfly.extension.messaging.activemq.MessagingServices;
/**
* Update handler removing a topic from the JMS subsystem. The
* runtime action will remove the corresponding {@link JMSTopicService}.
*
* @author Emmanuel Hugonnet (c) 2018 Red Hat, inc.
*/
public class ExternalJMSTopicRemove extends AbstractRemoveStepHandler {
public static final ExternalJMSTopicRemove INSTANCE = new ExternalJMSTopicRemove();
private ExternalJMSTopicRemove() {
}
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final String name = context.getCurrentAddressValue();
context.removeService(JMSServices.getJmsTopicBaseServiceName(MessagingServices.getActiveMQServiceName((String) null)).append(name));
for (String entry : CommonAttributes.DESTINATION_ENTRIES.unwrap(context, model)) {
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(entry);
ServiceName binderServiceName = bindInfo.getBinderServiceName();
context.removeService(binderServiceName);
}
}
@Override
protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
ExternalJMSTopicAdd.INSTANCE.performRuntime(context, operation, model);
}
}
| 2,391
| 41.714286
| 140
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/AbstractUpdateJndiHandler.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.jms;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.wildfly.extension.messaging.activemq.ActiveMQActivationService.rollbackOperationIfServerNotActive;
import static org.wildfly.extension.messaging.activemq.logging.MessagingLogger.ROOT_LOGGER;
import org.apache.activemq.artemis.jms.server.JMSServerManager;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.SimpleOperationDefinition;
import org.jboss.as.controller.SimpleOperationDefinitionBuilder;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.descriptions.ResourceDescriptionResolver;
import org.jboss.as.controller.logging.ControllerLogger;
import org.jboss.as.controller.operations.validation.StringLengthValidator;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.wildfly.extension.messaging.activemq.CommonAttributes;
import org.wildfly.extension.messaging.activemq.MessagingServices;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* Base class for handlers that handle "add-jndi" and "remove-jndi" operations.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public abstract class AbstractUpdateJndiHandler implements OperationStepHandler {
private static final String ADD_JNDI = "add-jndi";
private static final String REMOVE_JNDI = "remove-jndi";
private static final SimpleAttributeDefinition JNDI_BINDING = new SimpleAttributeDefinitionBuilder(CommonAttributes.JNDI_BINDING, ModelType.STRING)
.setRequired(true)
.setValidator(new StringLengthValidator(1))
.build();
/**
* {@code true} if the handler is for the add operation, {@code false} if it is for the remove operation.
*/
private final boolean addOperation;
protected void registerOperation(ManagementResourceRegistration registry, ResourceDescriptionResolver resolver) {
SimpleOperationDefinition operation = new SimpleOperationDefinitionBuilder(addOperation ? ADD_JNDI : REMOVE_JNDI,
resolver).setParameters(JNDI_BINDING).build();
registry.registerOperationHandler(operation, this);
}
protected AbstractUpdateJndiHandler(boolean addOperation) {
this.addOperation = addOperation;
}
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
JNDI_BINDING.validateOperation(operation);
final String jndiName = JNDI_BINDING.resolveModelAttribute(context, operation).asString();
final ModelNode entries = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS).getModel().get(CommonAttributes.DESTINATION_ENTRIES.getName());
if (addOperation) {
for (ModelNode entry : entries.asList()) {
if (jndiName.equals(entry.asString())) {
throw new OperationFailedException(ROOT_LOGGER.jndiNameAlreadyRegistered(jndiName));
}
}
entries.add(jndiName);
} else {
ModelNode updatedEntries = new ModelNode();
boolean updated = false;
for (ModelNode entry : entries.asList()) {
if (jndiName.equals(entry.asString())) {
if (entries.asList().size() == 1) {
throw new OperationFailedException(
ROOT_LOGGER.canNotRemoveLastJNDIName(jndiName));
}
updated = true;
} else {
updatedEntries.add(entry);
}
}
if (!updated) {
throw MessagingLogger.ROOT_LOGGER.canNotRemoveUnknownEntry(jndiName);
}
context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS).getModel().get(CommonAttributes.DESTINATION_ENTRIES.getName()).set(updatedEntries);
}
if (context.isNormalServer()) {
if (rollbackOperationIfServerNotActive(context, operation)) {
return;
}
context.addStep(new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
final String resourceName = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
final ServiceName jmsManagerServiceName = JMSServices.getJmsManagerBaseServiceName(serviceName);
final ServiceController<?> jmsServerService = context.getServiceRegistry(false).getService(jmsManagerServiceName);
if (jmsServerService != null) {
JMSServerManager jmsServerManager = JMSServerManager.class.cast(jmsServerService.getValue());
if (jmsServerManager == null) {
PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
throw ControllerLogger.ROOT_LOGGER.managementResourceNotFound(address);
}
try {
if (addOperation) {
addJndiName(jmsServerManager, resourceName, jndiName);
} else {
removeJndiName(jmsServerManager, resourceName, jndiName);
}
} catch (Exception e) {
context.getFailureDescription().set(e.getLocalizedMessage());
}
} // else the subsystem isn't started yet
if (!context.hasFailureDescription()) {
context.getResult();
}
context.completeStep(new OperationContext.RollbackHandler() {
@Override
public void handleRollback(OperationContext context, ModelNode operation) {
if (jmsServerService != null) {
JMSServerManager jmsServerManager = JMSServerManager.class.cast(jmsServerService.getValue());
try {
if (addOperation) {
removeJndiName(jmsServerManager, resourceName, jndiName);
} else {
addJndiName(jmsServerManager, resourceName, jndiName);
}
} catch (Exception e) {
context.getFailureDescription().set(e.getLocalizedMessage());
}
}
}
});
}
}, OperationContext.Stage.RUNTIME);
}
}
protected abstract void addJndiName(JMSServerManager jmsServerManager, String resourceName, String jndiName) throws Exception;
protected abstract void removeJndiName(JMSServerManager jmsServerManager, String resourceName, String jndiName) throws Exception;
}
| 8,922
| 48.027473
| 168
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/JMSQueueRemove.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.jms;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.wildfly.extension.messaging.activemq.jms.JMSQueueService.JMS_QUEUE_PREFIX;
import org.apache.activemq.artemis.jms.server.JMSServerManager;
import org.jboss.as.controller.AbstractRemoveStepHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.naming.deployment.ContextNames;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.wildfly.extension.messaging.activemq.CommonAttributes;
import org.wildfly.extension.messaging.activemq.MessagingServices;
/**
* Update handler removing a queue from the Jakarta Messaging subsystem. The
* runtime action will remove the corresponding {@link JMSQueueService}.
*
* @author Emanuel Muckenhuber
* @author <a href="mailto:andy.taylor@jboss.com">Andy Taylor</a>
*/
public class JMSQueueRemove extends AbstractRemoveStepHandler {
static final JMSQueueRemove INSTANCE = new JMSQueueRemove();
private JMSQueueRemove() {
}
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
final ServiceName jmsServiceName = JMSServices.getJmsManagerBaseServiceName(serviceName);
final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
final String name = address.getLastElement().getValue();
ServiceController<?> service = context.getServiceRegistry(true).getService(jmsServiceName);
JMSServerManager server = JMSServerManager.class.cast(service.getValue());
try {
server.destroyQueue(JMS_QUEUE_PREFIX + name, true);
} catch (Exception e) {
throw new OperationFailedException(e);
}
context.removeService(JMSServices.getJmsQueueBaseServiceName(serviceName).append(name));
for (String entry : CommonAttributes.DESTINATION_ENTRIES.unwrap(context, model)) {
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(entry);
ServiceName binderServiceName = bindInfo.getBinderServiceName();
context.removeService(binderServiceName);
}
for (String legacyEntry: CommonAttributes.LEGACY_ENTRIES.unwrap(context, model)) {
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(legacyEntry);
ServiceName binderServiceName = bindInfo.getBinderServiceName();
context.removeService(binderServiceName);
}
}
protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
JMSQueueAdd.INSTANCE.performRuntime(context, operation, model);
}
}
| 4,192
| 46.11236
| 156
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/ConnectionFactoryType.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.jms;
import static org.apache.activemq.artemis.api.jms.JMSFactoryType.CF;
import static org.apache.activemq.artemis.api.jms.JMSFactoryType.QUEUE_CF;
import static org.apache.activemq.artemis.api.jms.JMSFactoryType.QUEUE_XA_CF;
import static org.apache.activemq.artemis.api.jms.JMSFactoryType.TOPIC_CF;
import static org.apache.activemq.artemis.api.jms.JMSFactoryType.TOPIC_XA_CF;
import static org.apache.activemq.artemis.api.jms.JMSFactoryType.XA_CF;
import org.apache.activemq.artemis.api.jms.JMSFactoryType;
import org.jboss.as.controller.operations.validation.EnumValidator;
import org.jboss.as.controller.operations.validation.ParameterValidator;
/**
* Connection factory type enumeration and their respective value in ActiveMQ Artemis Jakarta Messaging API
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat Inc.
*/
public enum ConnectionFactoryType {
GENERIC(CF),
TOPIC(TOPIC_CF),
QUEUE(QUEUE_CF),
XA_GENERIC(XA_CF),
XA_QUEUE(QUEUE_XA_CF),
XA_TOPIC(TOPIC_XA_CF);
private final JMSFactoryType type;
ConnectionFactoryType(JMSFactoryType type) {
this.type = type;
}
public JMSFactoryType getType() {
return type;
}
public static final ParameterValidator VALIDATOR = EnumValidator.create(ConnectionFactoryType.class);
}
| 2,394
| 38.262295
| 107
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/ExternalConnectionFactoryService.java
|
/*
* Copyright 2018 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.extension.messaging.activemq.jms;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import java.util.function.Supplier;
import jakarta.jms.ConnectionFactory;
import javax.net.ssl.SSLContext;
import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
import org.apache.activemq.artemis.api.core.TransportConfiguration;
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
import org.apache.activemq.artemis.api.jms.JMSFactoryType;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration;
import org.jboss.as.network.ManagedBinding;
import org.jboss.as.network.OutboundSocketBinding;
import org.jboss.as.network.SocketBinding;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;
import org.wildfly.extension.messaging.activemq.JGroupsDiscoveryGroupAdd;
import org.wildfly.extension.messaging.activemq.SocketDiscoveryGroupAdd;
import org.wildfly.extension.messaging.activemq.TransportConfigOperationHandlers;
import org.wildfly.extension.messaging.activemq.broadcast.BroadcastCommandDispatcherFactory;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
*
* @author Emmanuel Hugonnet (c) 2018 Red Hat, inc.
*/
public class ExternalConnectionFactoryService implements Service<ConnectionFactory> {
private final boolean ha;
private final boolean enable1Prefixes;
private final DiscoveryGroupConfiguration groupConfiguration;
private final TransportConfiguration[] connectors;
private final JMSFactoryType type;
private final Map<String, Supplier<SocketBinding>> socketBindings;
private final Map<String, Supplier<OutboundSocketBinding>> outboundSocketBindings;
private final Map<String, Supplier<SSLContext>> sslContexts;
private final Map<String, Supplier<SocketBinding>> groupBindings;
// mapping between the {discovery}-groups and the cluster names they use
private final Map<String, String> clusterNames;
// mapping between the {discovery}-groups and the command dispatcher factory they use
private final Map<String, Supplier<BroadcastCommandDispatcherFactory>> commandDispatcherFactories;
private ActiveMQConnectionFactory factory;
private final ConnectionFactoryConfiguration config;
ExternalConnectionFactoryService(DiscoveryGroupConfiguration groupConfiguration,
Map<String, Supplier<BroadcastCommandDispatcherFactory>> commandDispatcherFactories,
Map<String, Supplier<SocketBinding>> groupBindings, Map<String, String> clusterNames, JMSFactoryType type, boolean ha, boolean enable1Prefixes, ConnectionFactoryConfiguration config) {
this(ha, enable1Prefixes, type, groupConfiguration, Collections.emptyMap(), Collections.emptyMap(),commandDispatcherFactories, groupBindings, Collections.emptyMap(), clusterNames, null, config);
}
ExternalConnectionFactoryService(TransportConfiguration[] connectors, Map<String, Supplier<SocketBinding>> socketBindings,
Map<String, Supplier<OutboundSocketBinding>> outboundSocketBindings, Map<String, Supplier<SSLContext>> sslContexts, JMSFactoryType type, boolean ha, boolean enable1Prefixes, ConnectionFactoryConfiguration config) {
this(ha, enable1Prefixes, type, null, socketBindings, outboundSocketBindings, Collections.emptyMap(), Collections.emptyMap(), sslContexts, Collections.emptyMap(), connectors, config);
}
private ExternalConnectionFactoryService(boolean ha,
boolean enable1Prefixes,
JMSFactoryType type,
DiscoveryGroupConfiguration groupConfiguration,
Map<String, Supplier<SocketBinding>> socketBindings,
Map<String, Supplier<OutboundSocketBinding>> outboundSocketBindings,
Map<String, Supplier<BroadcastCommandDispatcherFactory>> commandDispatcherFactories,
Map<String, Supplier<SocketBinding>> groupBindings,
Map<String, Supplier<SSLContext>> sslContexts,
Map<String, String> clusterNames,
TransportConfiguration[] connectors,
ConnectionFactoryConfiguration config) {
assert (connectors != null && connectors.length > 0) || groupConfiguration != null;
this.ha = ha;
this.enable1Prefixes = enable1Prefixes;
this.type = type;
this.groupConfiguration = groupConfiguration;
this.connectors = connectors;
this.socketBindings = socketBindings;
this.outboundSocketBindings = outboundSocketBindings;
this.clusterNames = clusterNames;
this.commandDispatcherFactories = commandDispatcherFactories;
this.groupBindings = groupBindings;
this.sslContexts = sslContexts;
this.config = config;
}
@Override
public void start(StartContext context) throws StartException {
try {
if (connectors != null && connectors.length > 0) {
TransportConfigOperationHandlers.processConnectorBindings(Arrays.asList(connectors), socketBindings, outboundSocketBindings);
if (ha) {
factory = ActiveMQJMSClient.createConnectionFactoryWithHA(type, connectors);
} else {
factory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(type, connectors);
}
} else {
final String name = groupConfiguration.getName();
final String key = "discovery" + name;
final DiscoveryGroupConfiguration config;
if (commandDispatcherFactories.containsKey(key)) {
BroadcastCommandDispatcherFactory commandDispatcherFactory = commandDispatcherFactories.get(key).get();
String clusterName = clusterNames.get(key);
config = JGroupsDiscoveryGroupAdd.createDiscoveryGroupConfiguration(name, groupConfiguration, commandDispatcherFactory, clusterName);
} else {
final SocketBinding binding = groupBindings.get(key).get();
if (binding == null) {
throw MessagingLogger.ROOT_LOGGER.failedToFindDiscoverySocketBinding(name);
}
config = SocketDiscoveryGroupAdd.createDiscoveryGroupConfiguration(name, groupConfiguration, binding);
binding.getSocketBindings().getNamedRegistry().registerBinding(ManagedBinding.Factory.createSimpleManagedBinding(binding));
}
if (ha) {
factory = ActiveMQJMSClient.createConnectionFactoryWithHA(config, type);
} else {
factory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(config, type);
}
}
if(config != null) {
factory.setAutoGroup(config.isAutoGroup());
factory.setBlockOnAcknowledge(config.isBlockOnAcknowledge());
factory.setBlockOnDurableSend(config.isBlockOnDurableSend());
factory.setBlockOnNonDurableSend(config.isBlockOnNonDurableSend());
factory.setCacheLargeMessagesClient(config.isCacheLargeMessagesClient());
factory.setCallFailoverTimeout(config.getCallFailoverTimeout());
factory.setCallTimeout(config.getCallTimeout());
factory.setClientID(config.getClientID());
factory.setClientFailureCheckPeriod(config.getClientFailureCheckPeriod());
factory.setCompressLargeMessage(config.isCompressLargeMessages());
factory.setConfirmationWindowSize(config.getConfirmationWindowSize());
factory.setConnectionTTL(config.getConnectionTTL());
factory.setConsumerMaxRate(config.getConsumerMaxRate());
factory.setConsumerWindowSize(config.getConsumerWindowSize());
factory.setDeserializationBlackList(config.getDeserializationBlackList());
factory.setDeserializationWhiteList(config.getDeserializationWhiteList());
factory.setDupsOKBatchSize(config.getDupsOKBatchSize());
factory.setEnableSharedClientID(config.isEnableSharedClientID());
factory.setFailoverOnInitialConnection(config.isFailoverOnInitialConnection());
factory.setGroupID(config.getGroupID());
factory.setInitialMessagePacketSize(config.getInitialMessagePacketSize());
factory.setMaxRetryInterval(config.getMaxRetryInterval());
factory.setMinLargeMessageSize(config.getMinLargeMessageSize());
factory.setPreAcknowledge(config.isPreAcknowledge());
factory.setProducerMaxRate(config.getProducerMaxRate());
factory.setProducerWindowSize(config.getProducerWindowSize());
factory.setProtocolManagerFactoryStr(config.getProtocolManagerFactoryStr());
factory.setConnectionLoadBalancingPolicyClassName(config.getLoadBalancingPolicyClassName());
factory.setReconnectAttempts(config.getReconnectAttempts());
factory.setRetryInterval(config.getRetryInterval());
factory.setRetryIntervalMultiplier(config.getRetryIntervalMultiplier());
factory.setScheduledThreadPoolMaxSize(config.getScheduledThreadPoolMaxSize());
factory.setThreadPoolMaxSize(config.getThreadPoolMaxSize());
factory.setTransactionBatchSize(config.getTransactionBatchSize());
factory.setUseGlobalPools(config.isUseGlobalPools());
factory.setUseTopologyForLoadBalancing(config.getUseTopologyForLoadBalancing());
}
factory.setEnable1xPrefixes(enable1Prefixes);
} catch (Throwable e) {
throw MessagingLogger.ROOT_LOGGER.failedToCreate(e, "connection-factory");
}
}
@Override
public void stop(StopContext context) {
try {
factory.close();
} catch (Throwable e) {
MessagingLogger.ROOT_LOGGER.failedToDestroy("connection-factory", "");
}
}
@Override
public ConnectionFactory getValue() throws IllegalStateException, IllegalArgumentException {
return factory;
}
}
| 11,042
| 55.92268
| 226
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/ExternalJMSTopicAdd.java
|
/*
* Copyright 2018 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.extension.messaging.activemq.jms;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.External.ENABLE_AMQ1_PREFIX;
import static org.wildfly.extension.messaging.activemq.logging.MessagingLogger.ROOT_LOGGER;
import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceTarget;
import org.wildfly.extension.messaging.activemq.BinderServiceUtil;
import org.wildfly.extension.messaging.activemq.CommonAttributes;
import org.wildfly.extension.messaging.activemq.MessagingServices;
/**
* Update handler adding a topic to the Jakarta Messaging subsystem. The
* runtime action, will create the {@link JMSTopicService}.
*
* @author Emmanuel Hugonnet (c) 2018 Red Hat, inc.
*/
public class ExternalJMSTopicAdd extends AbstractAddStepHandler {
public static final ExternalJMSTopicAdd INSTANCE = new ExternalJMSTopicAdd();
private ExternalJMSTopicAdd() {
super(ExternalJMSTopicDefinition.ATTRIBUTES);
}
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final String name = context.getCurrentAddressValue();
final ServiceTarget serviceTarget = context.getServiceTarget();
// Do not pass the JNDI bindings to ActiveMQ but install them directly instead so that the
// dependencies from the BinderServices to the JMSQueueService are not broken
final ServiceName jmsTopicServiceName = JMSServices.getJmsTopicBaseServiceName(MessagingServices.getActiveMQServiceName((String) null)).append(name);
final boolean enabledAMQ1Prefix = ENABLE_AMQ1_PREFIX.resolveModelAttribute(context, model).asBoolean();
ExternalJMSTopicService jmsTopicService = ExternalJMSTopicService.installService(name, jmsTopicServiceName, serviceTarget, enabledAMQ1Prefix);
for (String entry : CommonAttributes.DESTINATION_ENTRIES.unwrap(context, model)) {
ROOT_LOGGER.boundJndiName(entry);
BinderServiceUtil.installBinderService(serviceTarget, entry, jmsTopicService, jmsTopicServiceName);
}
}
}
| 2,940
| 46.435484
| 157
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/JMSTopicConfigurationWriteHandler.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.jms;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
import org.wildfly.extension.messaging.activemq.CommonAttributes;
/**
* Write attribute handler for attributes that update the persistent configuration of a Jakarta Messaging topic resource.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class JMSTopicConfigurationWriteHandler extends ReloadRequiredWriteAttributeHandler {
public static final JMSTopicConfigurationWriteHandler INSTANCE = new JMSTopicConfigurationWriteHandler();
private JMSTopicConfigurationWriteHandler() {
super(CommonAttributes.DESTINATION_ENTRIES);
}
}
| 1,713
| 40.804878
| 121
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/ConnectionFactoryAttribute.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.jms;
import org.jboss.as.controller.AttributeDefinition;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* A wrapper for pooled CF attributes with additional parameters required
* to setup the ActiveMQ RA.
*
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2012 Red Hat Inc.
*/
public class ConnectionFactoryAttribute {
enum ConfigType {
INBOUND, OUTBOUND;
}
private final AttributeDefinition attributeDefinition;
private String propertyName;
private final boolean resourceAdapterProperty;
private ConfigType configType;
public static ConnectionFactoryAttribute create(final AttributeDefinition attributeDefinition, final String propertyName, boolean resourceAdapterProperty) {
return new ConnectionFactoryAttribute(attributeDefinition, propertyName, resourceAdapterProperty, null);
}
public static ConnectionFactoryAttribute create(final AttributeDefinition attributeDefinition, final String propertyName, boolean resourceAdapterProperty, ConfigType inboundConfig) {
return new ConnectionFactoryAttribute(attributeDefinition, propertyName, resourceAdapterProperty, inboundConfig);
}
public static AttributeDefinition[] getDefinitions(final ConnectionFactoryAttribute... attrs) {
AttributeDefinition[] definitions = new AttributeDefinition[attrs.length];
for (int i = 0; i < attrs.length; i++) {
ConnectionFactoryAttribute attr = attrs[i];
definitions[i] = attr.getDefinition();
}
return definitions;
}
private ConnectionFactoryAttribute(final AttributeDefinition attributeDefinition, final String propertyName, boolean resourceAdapterProperty, ConfigType configType) {
this.attributeDefinition = attributeDefinition;
this.propertyName = propertyName;
this.resourceAdapterProperty = resourceAdapterProperty;
this.configType = configType;
}
public String getClassType() {
switch (attributeDefinition.getType()) {
case BOOLEAN:
return Boolean.class.getName();
case DOUBLE:
case BIG_DECIMAL:
return Double.class.getName();
case LONG:
return Long.class.getName();
case INT:
return Integer.class.getName();
case STRING:
case LIST:
return String.class.getName();
default:
throw MessagingLogger.ROOT_LOGGER.invalidAttributeType(attributeDefinition.getName(), attributeDefinition.getType());
}
}
public String getPropertyName() {
return propertyName;
}
public AttributeDefinition getDefinition() {
return attributeDefinition;
}
public boolean isResourceAdapterProperty() {
return resourceAdapterProperty;
}
public ConfigType getConfigType() {
return configType;
}
}
| 4,037
| 38.203883
| 186
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/JMSTopicUpdateJndiHandler.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.jms;
import static org.wildfly.extension.messaging.activemq.jms.JMSTopicService.JMS_TOPIC_PREFIX;
import org.apache.activemq.artemis.jms.server.JMSServerManager;
import org.jboss.as.controller.descriptions.ResourceDescriptionResolver;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
/**
* Handler for "add-jndi" and "remove-jndi" operations on a Jakarta Messaging topic resource.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class JMSTopicUpdateJndiHandler extends AbstractUpdateJndiHandler {
private JMSTopicUpdateJndiHandler(boolean addOperation) {
super(addOperation);
}
@Override
protected void addJndiName(JMSServerManager jmsServerManager, String resourceName, String jndiName) throws Exception {
jmsServerManager.addTopicToBindingRegistry(JMS_TOPIC_PREFIX + resourceName, jndiName);
}
@Override
protected void removeJndiName(JMSServerManager jmsServerManager, String resourceName, String jndiName) throws Exception {
jmsServerManager.removeTopicFromBindingRegistry(JMS_TOPIC_PREFIX + resourceName, jndiName);
}
static void registerOperations(ManagementResourceRegistration registry, ResourceDescriptionResolver resolver) {
JMSTopicUpdateJndiHandler add = new JMSTopicUpdateJndiHandler(true);
add.registerOperation(registry, resolver);
JMSTopicUpdateJndiHandler remove = new JMSTopicUpdateJndiHandler(false);
remove.registerOperation(registry, resolver);
}
}
| 2,586
| 42.116667
| 125
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/DestinationConfiguration.java
|
/*
* Copyright 2018 JBoss by Red Hat.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.extension.messaging.activemq.jms;
import static org.wildfly.extension.messaging.activemq.logging.MessagingLogger.ROOT_LOGGER;
import jakarta.jms.Connection;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import jakarta.jms.Queue;
import jakarta.jms.QueueRequestor;
import jakarta.jms.QueueSession;
import jakarta.jms.Session;
import org.apache.activemq.artemis.api.core.RoutingType;
import org.apache.activemq.artemis.api.core.management.ResourceNames;
import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.StartException;
/**
*
* @author Emmanuel Hugonnet (c) 2018 Red Hat, inc.
*/
public class DestinationConfiguration {
private final boolean durable;
private final String selector;
private final String name;
private final String managementQueueAddress;
private final String managementUsername;
private final String managementPassword;
private final String resourceAdapter;
private final ServiceName destinationServiceName;
public DestinationConfiguration(boolean durable, String selector, String name, String managementQueueAddress,
String managementUsername, String managementPassword, String resourceAdapter, ServiceName destinationServiceName) {
this.durable = durable;
this.selector = selector;
this.name = name;
this.managementQueueAddress = managementQueueAddress;
this.managementUsername = managementUsername;
this.managementPassword = managementPassword;
this.resourceAdapter = resourceAdapter;
this.destinationServiceName = destinationServiceName;
}
public boolean isDurable() {
return durable;
}
public String getSelector() {
return selector;
}
public String getName() {
return name;
}
public ServiceName getDestinationServiceName() {
return destinationServiceName;
}
public String getResourceAdapter() {
return resourceAdapter;
}
public Queue getManagementQueue() {
return ActiveMQDestination.createQueue(this.managementQueueAddress);
}
private Connection createQueueConnection(ConnectionFactory cf) throws JMSException {
if(this.managementUsername != null && !this.managementUsername.isEmpty()) {
return cf.createConnection(managementUsername, managementPassword);
}
return cf.createConnection();
}
public void createQueue(ConnectionFactory cf, Queue managementQueue, String queueName) throws JMSException, StartException {
try (Connection connection = createQueueConnection(cf);
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE)) {
connection.start();
QueueRequestor requestor = new QueueRequestor((QueueSession) session, managementQueue);
Message m = session.createMessage();
if (getSelector() != null && !getSelector().isEmpty()) {
org.apache.activemq.artemis.api.jms.management.JMSManagementHelper.putOperationInvocation(m, ResourceNames.BROKER, "createQueue", queueName, queueName, getSelector(), isDurable(), RoutingType.ANYCAST.name());
} else {
org.apache.activemq.artemis.api.jms.management.JMSManagementHelper.putOperationInvocation(m, ResourceNames.BROKER, "createQueue", queueName, queueName, isDurable(), RoutingType.ANYCAST.name());
}
Message reply = requestor.request(m);
ROOT_LOGGER.infof("Creating queue %s returned %s", queueName, reply);
requestor.close();
if (!reply.getBooleanProperty("_AMQ_OperationSucceeded")) {
String body = reply.getBody(String.class);
if (!destinationAlreadyExist(body)) {
throw ROOT_LOGGER.remoteDestinationCreationFailed(queueName, body);
}
}
ROOT_LOGGER.infof("Queue %s has been created", queueName);
}
}
private boolean destinationAlreadyExist(String body) {
return body.contains("AMQ119019") || body.contains("AMQ119018") || body.contains("AMQ229019") || body.contains("AMQ229018") || body.contains("AMQ229204");
}
public void destroyQueue(ConnectionFactory cf, Queue managementQueue, String queueName) throws JMSException {
try (Connection connection = createQueueConnection(cf);
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE)) {
connection.start();
QueueRequestor requestor = new QueueRequestor((QueueSession) session, managementQueue);
Message m = session.createMessage();
org.apache.activemq.artemis.api.jms.management.JMSManagementHelper.putOperationInvocation(m, ResourceNames.BROKER, "destroyQueue", queueName, true, true);
Message reply = requestor.request(m);
ROOT_LOGGER.debugf("Deleting queue %s returned %s", queueName, reply);
requestor.close();
if (!reply.getBooleanProperty("_AMQ_OperationSucceeded")) {
throw ROOT_LOGGER.remoteDestinationDeletionFailed(queueName, reply.getBody(String.class));
}
ROOT_LOGGER.debugf("Queue %s has been deleted", queueName);
}
}
public void createTopic(ConnectionFactory cf, Queue managementQueue, String topicName) throws JMSException, StartException {
try (Connection connection = createQueueConnection(cf);
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE)) {
connection.start();
QueueRequestor requestor = new QueueRequestor((QueueSession) session, managementQueue);
Message m = session.createMessage();
org.apache.activemq.artemis.api.jms.management.JMSManagementHelper.putOperationInvocation(m, ResourceNames.BROKER, "createAddress", topicName, RoutingType.MULTICAST.name());
Message reply = requestor.request(m);
ROOT_LOGGER.infof("Creating topic %s returned %s", topicName, reply);
requestor.close();
if (!reply.getBooleanProperty("_AMQ_OperationSucceeded")) {
String body = reply.getBody(String.class);
if (!destinationAlreadyExist(body)) {
throw ROOT_LOGGER.remoteDestinationCreationFailed(topicName, body);
}
}
ROOT_LOGGER.infof("Topic %s has been created", topicName);
}
}
public void destroyTopic(ConnectionFactory cf, Queue managementQueue, String topicName) throws JMSException {
try (Connection connection = createQueueConnection(cf);
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE)) {
connection.start();
QueueRequestor requestor = new QueueRequestor((QueueSession) session, managementQueue);
Message m = session.createMessage();
org.apache.activemq.artemis.api.jms.management.JMSManagementHelper.putOperationInvocation(m, ResourceNames.BROKER, "deleteAddress", topicName, true);
Message reply = requestor.request(m);
requestor.close();
ROOT_LOGGER.debugf("Deleting topic " + topicName + " returned " + reply);
if (!reply.getBooleanProperty("_AMQ_OperationSucceeded")) {
throw ROOT_LOGGER.remoteDestinationDeletionFailed(topicName, reply.getBody(String.class));
}
ROOT_LOGGER.debugf("Topic %s has been deleted", topicName);
}
}
public static class Builder {
private boolean durable = false;
private String selector = null;
private String name;
private String managementQueueAddress = "activemq.management";
private String managementUsername = null;
private String managementPassword = null;
private String resourceAdapter;
private ServiceName destinationServiceName;
private Builder() {
}
public static Builder getInstance() {
return new Builder();
}
public Builder setDurable(boolean durable) {
this.durable = durable;
return this;
}
public Builder setSelector(String selector) {
this.selector = selector;
return this;
}
public Builder setName(String name) {
this.name = name;
return this;
}
public Builder setDestinationServiceName(ServiceName destinationServiceName) {
this.destinationServiceName = destinationServiceName;
return this;
}
public Builder setResourceAdapter(String resourceAdapter) {
this.resourceAdapter = resourceAdapter;
return this;
}
public Builder setManagementQueueAddress(String managementQueueAddress) {
this.managementQueueAddress = managementQueueAddress;
return this;
}
public Builder setManagementUsername(String managementUsername) {
this.managementUsername = managementUsername;
return this;
}
public Builder setManagementPassword(String managementPassword) {
this.managementPassword = managementPassword;
return this;
}
public DestinationConfiguration build() {
return new DestinationConfiguration(durable, selector, name, managementQueueAddress, managementUsername,
managementPassword,resourceAdapter, destinationServiceName);
}
}
}
| 10,300
| 42.281513
| 224
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/ConnectionFactoryUpdateJndiHandler.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.jms;
import org.apache.activemq.artemis.jms.server.JMSServerManager;
import org.jboss.as.controller.descriptions.ResourceDescriptionResolver;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
/**
* Handler for "add-jndi" and "remove-jndi" operations on a connection factory resource.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class ConnectionFactoryUpdateJndiHandler extends AbstractUpdateJndiHandler {
private ConnectionFactoryUpdateJndiHandler(boolean addOperation) {
super(addOperation);
}
@Override
protected void addJndiName(JMSServerManager jmsServerManager, String resourceName, String jndiName) throws Exception {
jmsServerManager.addConnectionFactoryToBindingRegistry(resourceName, jndiName);
}
@Override
protected void removeJndiName(JMSServerManager jmsServerManager, String resourceName, String jndiName) throws Exception {
jmsServerManager.removeConnectionFactoryFromBindingRegistry(resourceName, jndiName);
}
static void registerOperations(ManagementResourceRegistration registry, ResourceDescriptionResolver resolver) {
ConnectionFactoryUpdateJndiHandler add = new ConnectionFactoryUpdateJndiHandler(true);
add.registerOperation(registry, resolver);
ConnectionFactoryUpdateJndiHandler remove = new ConnectionFactoryUpdateJndiHandler(false);
remove.registerOperation(registry, resolver);
}
}
| 2,527
| 42.586207
| 125
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/Validators.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2014, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.jms;
import java.util.HashSet;
import java.util.Set;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.operations.validation.ListValidator;
import org.jboss.as.controller.operations.validation.ParameterValidator;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
import org.jboss.dmr.ModelNode;
/**
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2014 Red Hat inc.
*/
public class Validators {
public static ListValidator noDuplicateElements(ParameterValidator elementValidator) {
return new ListValidator(elementValidator, false, 1, Integer.MAX_VALUE) {
@Override
public void validateParameter(String parameterName, ModelNode value) throws OperationFailedException {
super.validateParameter(parameterName, value);
int elementsSize = value.asList().size();
// use a set to check whether the list contains duplicate elements
Set<ModelNode> set = new HashSet<>(value.asList());
if (set.size() != elementsSize) {
throw MessagingLogger.ROOT_LOGGER.duplicateElements(parameterName, value);
}
}
};
}
}
| 2,327
| 39.842105
| 114
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/WildFlyBindingRegistry.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.jms;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.wildfly.extension.messaging.activemq.BinderServiceUtil.installBinderService;
import static org.wildfly.extension.messaging.activemq.logging.MessagingLogger.ROOT_LOGGER;
import java.util.concurrent.CountDownLatch;
import java.util.Locale;
import org.apache.activemq.artemis.spi.core.naming.BindingRegistry;
import org.jboss.msc.service.LifecycleEvent;
import org.jboss.msc.service.LifecycleListener;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
import org.jboss.as.naming.ManagedReferenceFactory;
import org.jboss.as.naming.deployment.ContextNames;
import org.jboss.msc.service.ServiceContainer;
import org.jboss.msc.service.ServiceController;
/**
* A {@link BindingRegistry} implementation for WildFly.
*
* @author Jason T. Greene
* @author Jaikiran Pai
* @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
*/
public class WildFlyBindingRegistry implements BindingRegistry {
private final ServiceContainer container;
public WildFlyBindingRegistry(ServiceContainer container) {
this.container = container;
}
// This method is called by ActiveMQ when JNDI entries for its resources
// are updated using its own management API. We advise against using it in
// WildFly (and use WildFly own management API) but we must still respect the
// SPI contract for this method
@Override
public Object lookup(String name) {
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(name);
ServiceController<?> bindingService = container.getService(bindInfo.getBinderServiceName());
if (bindingService == null) {
return null;
}
ManagedReferenceFactory managedReferenceFactory = ManagedReferenceFactory.class.cast(bindingService.getValue());
return managedReferenceFactory.getReference().getInstance();
}
@Override
public boolean bind(String name, Object obj) {
if (name == null || name.isEmpty()) {
throw MessagingLogger.ROOT_LOGGER.cannotBindJndiName();
}
installBinderService(container, name, obj);
ROOT_LOGGER.boundJndiName(name);
return true;
}
/**
* Unbind the resource and wait until the corresponding binding service is effectively removed.
*/
@Override
public void unbind(String name) {
if (name == null || name.isEmpty()) {
throw MessagingLogger.ROOT_LOGGER.cannotUnbindJndiName();
}
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(name);
ServiceController<?> bindingService = container.getService(bindInfo.getBinderServiceName());
if (bindingService == null) {
ROOT_LOGGER.debugf("Cannot unbind %s since no binding exists with that name", name);
return;
}
// remove the binding service
final CountDownLatch latch = new CountDownLatch(1);
bindingService.addListener(new LifecycleListener() {
@Override
public void handleEvent(final ServiceController<?> controller, final LifecycleEvent event) {
if (event == LifecycleEvent.REMOVED) {
ROOT_LOGGER.unboundJndiName(bindInfo.getAbsoluteJndiName());
latch.countDown();
}
}
});
try {
bindingService.setMode(ServiceController.Mode.REMOVE);
} finally {
try {
latch.await();
} catch (InterruptedException ie) {
ROOT_LOGGER.failedToUnbindJndiName(name, 5, SECONDS.toString().toLowerCase(Locale.US));
}
}
}
@Override
public void close() {
// NOOP
}
}
| 4,858
| 38.827869
| 120
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/PooledConnectionFactoryRemove.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.jms;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Common.ENTRIES;
import java.util.List;
import org.jboss.as.controller.AbstractRemoveStepHandler;
import org.jboss.as.controller.OperationContext;
import org.wildfly.extension.messaging.activemq.MessagingServices;
import org.jboss.as.naming.deployment.ContextNames;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceName;
/**
* @author <a href="mailto:andy.taylor@jboss.com">Andy Taylor</a>
* Date: 5/13/11
* Time: 3:30 PM
*/
public class PooledConnectionFactoryRemove extends AbstractRemoveStepHandler {
public static final PooledConnectionFactoryRemove INSTANCE = new PooledConnectionFactoryRemove();
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) {
ServiceName serviceName = MessagingServices.getActiveMQServiceName(context.getCurrentAddress());
context.removeService(JMSServices.getPooledConnectionFactoryBaseServiceName(serviceName).append(context.getCurrentAddressValue()));
removeJNDIAliases(context, model.require(ENTRIES.getName()).asList());
}
@Override
protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) {
// TODO: RE-ADD SERVICES
}
/**
* Remove JNDI alias' binder services.
*
* The 1st JNDI entry is not removed by this method as it is already handled when removing
* the pooled-connection-factory service
*/
protected void removeJNDIAliases(OperationContext context, List<ModelNode> entries) {
if (entries.size() > 1) {
for (int i = 1; i < entries.size() ; i++) {
ContextNames.BindInfo aliasBindInfo = ContextNames.bindInfoFor(entries.get(i).asString());
context.removeService(aliasBindInfo.getBinderServiceName());
}
}
}
}
| 3,018
| 40.930556
| 139
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/ConnectionFactoryDefinition.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.jms;
import static java.lang.System.arraycopy;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttribute.getDefinitions;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Common.DESERIALIZATION_ALLOWLIST;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Common.DESERIALIZATION_BLACKLIST;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Common.DESERIALIZATION_BLOCKLIST;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Common.DESERIALIZATION_WHITELIST;
import java.util.Arrays;
import java.util.Collection;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.capability.DynamicNameMappers;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.wildfly.extension.messaging.activemq.CommonAttributes;
import org.wildfly.extension.messaging.activemq.MessagingExtension;
import org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Common;
import org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Regular;
/**
* Jakarta Messaging Connection Factory resource definition
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat Inc.
*/
public class ConnectionFactoryDefinition extends PersistentResourceDefinition {
static final String CAPABILITY_NAME = "org.wildfly.messaging.activemq.server.connection-factory";
static final RuntimeCapability<Void> CAPABILITY = RuntimeCapability.Builder.of(CAPABILITY_NAME, true, ConnectionFactoryService.class)
.setDynamicNameMapper(DynamicNameMappers.PARENT)
.build();
static final AttributeDefinition[] concat(AttributeDefinition[] common, AttributeDefinition... specific) {
int size = common.length + specific.length;
AttributeDefinition[] result = new AttributeDefinition[size];
arraycopy(common, 0, result, 0, common.length);
arraycopy(specific, 0, result, common.length, specific.length);
return result;
}
public static final AttributeDefinition[] ATTRIBUTES = concat(Regular.ATTRIBUTES, getDefinitions(Common.ATTRIBUTES));
private final boolean registerRuntimeOnly;
public ConnectionFactoryDefinition(final boolean registerRuntimeOnly) {
super(new SimpleResourceDefinition.Parameters(MessagingExtension.CONNECTION_FACTORY_PATH,
MessagingExtension.getResourceDescriptionResolver(CommonAttributes.CONNECTION_FACTORY))
.setCapabilities(CAPABILITY)
.setAddHandler(ConnectionFactoryAdd.INSTANCE)
.setRemoveHandler(ConnectionFactoryRemove.INSTANCE));
this.registerRuntimeOnly = registerRuntimeOnly;
}
@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(ATTRIBUTES);
}
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
super.registerAttributes(resourceRegistration);
ConnectionFactoryAttributes.registerAliasAttribute(resourceRegistration, false, DESERIALIZATION_WHITELIST, DESERIALIZATION_ALLOWLIST.getName());
ConnectionFactoryAttributes.registerAliasAttribute(resourceRegistration, false, DESERIALIZATION_BLACKLIST, DESERIALIZATION_BLOCKLIST.getName());
}
@Override
public void registerOperations(ManagementResourceRegistration registry) {
super.registerOperations(registry);
if (registerRuntimeOnly) {
ConnectionFactoryUpdateJndiHandler.registerOperations(registry, getResourceDescriptionResolver());
}
}
}
| 4,971
| 48.72
| 152
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/JMSManagementHelper.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2014, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.jms;
import static org.jboss.as.controller.SimpleAttributeDefinitionBuilder.create;
import static org.wildfly.extension.messaging.activemq.AbstractQueueControlHandler.PRIORITY_VALIDATOR;
import static org.wildfly.extension.messaging.activemq.OperationDefinitionHelper.createNonEmptyStringAttribute;
import static org.jboss.dmr.ModelType.INT;
import static org.jboss.dmr.ModelType.LONG;
import static org.jboss.dmr.ModelType.STRING;
import java.util.ArrayList;
import java.util.List;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.operations.validation.AllowedValuesValidator;
import org.jboss.as.controller.operations.validation.StringLengthValidator;
import org.jboss.dmr.ModelNode;
/**
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2014 Red Hat inc.
*/
public class JMSManagementHelper {
private static class DeliveryModeValidator extends StringLengthValidator implements AllowedValuesValidator {
public DeliveryModeValidator() {
super(1);
}
@Override
public List<ModelNode> getAllowedValues() {
List<ModelNode> values = new ArrayList<>();
values.add(new ModelNode("PERSISTENT"));
values.add(new ModelNode("NON_PERSISTENT"));
return values;
}
}
protected static final AttributeDefinition[] JMS_MESSAGE_PARAMETERS = new AttributeDefinition[] {
createNonEmptyStringAttribute("JMSMessageID"),
create("JMSPriority", INT)
.setValidator(PRIORITY_VALIDATOR)
.build(),
create("JMSTimestamp", LONG)
.build(),
create("JMSExpiration", LONG)
.build(),
create("JMSDeliveryMode", STRING)
.build(),
create("JMSDeliveryMode", STRING)
.setValidator(new DeliveryModeValidator())
.build()
};
}
| 3,082
| 39.565789
| 112
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/ExternalPooledConnectionFactoryService.java
|
/*
* Copyright 2018 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.extension.messaging.activemq.jms;
import static org.jboss.as.naming.deployment.ContextNames.BindInfo;
import static org.wildfly.extension.messaging.activemq.Capabilities.ELYTRON_SSL_CONTEXT_CAPABILITY;
import static org.wildfly.extension.messaging.activemq.Capabilities.OUTBOUND_SOCKET_BINDING_CAPABILITY;
import static org.wildfly.extension.messaging.activemq.Capabilities.SOCKET_BINDING_CAPABILITY;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Pooled.REBALANCE_CONNECTIONS_PROP_NAME;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Supplier;
import javax.net.ssl.SSLContext;
import org.apache.activemq.artemis.api.core.BroadcastEndpointFactory;
import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
import org.apache.activemq.artemis.api.core.TransportConfiguration;
import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory;
import org.jboss.as.connector.metadata.common.CredentialImpl;
import org.jboss.as.connector.metadata.common.SecurityImpl;
import org.jboss.as.connector.services.mdr.AS7MetadataRepository;
import org.jboss.as.connector.services.resourceadapters.ResourceAdapterActivatorService;
import org.jboss.as.connector.services.resourceadapters.deployment.registry.ResourceAdapterDeploymentRegistry;
import org.jboss.as.connector.subsystems.jca.JcaSubsystemConfiguration;
import org.jboss.as.connector.util.ConnectorServices;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.capability.CapabilityServiceSupport;
import org.jboss.as.controller.security.CredentialReference;
import org.jboss.as.naming.service.NamingService;
import org.jboss.as.network.ManagedBinding;
import org.jboss.as.network.OutboundSocketBinding;
import org.jboss.as.network.SocketBinding;
import org.jboss.as.server.Services;
import org.jboss.dmr.ModelNode;
import org.jboss.jca.common.api.metadata.Defaults;
import org.jboss.jca.common.api.metadata.common.FlushStrategy;
import org.jboss.jca.common.api.metadata.common.Pool;
import org.jboss.jca.common.api.metadata.common.Recovery;
import org.jboss.jca.common.api.metadata.common.Security;
import org.jboss.jca.common.api.metadata.common.TimeOut;
import org.jboss.jca.common.api.metadata.common.TransactionSupportEnum;
import org.jboss.jca.common.api.metadata.common.Validation;
import org.jboss.jca.common.api.metadata.resourceadapter.Activation;
import org.jboss.jca.common.api.metadata.resourceadapter.AdminObject;
import org.jboss.jca.common.api.metadata.resourceadapter.ConnectionDefinition;
import org.jboss.jca.common.api.metadata.spec.Activationspec;
import org.jboss.jca.common.api.metadata.spec.AuthenticationMechanism;
import org.jboss.jca.common.api.metadata.spec.ConfigProperty;
import org.jboss.jca.common.api.metadata.spec.Connector;
import org.jboss.jca.common.api.metadata.spec.CredentialInterfaceEnum;
import org.jboss.jca.common.api.metadata.spec.Icon;
import org.jboss.jca.common.api.metadata.spec.InboundResourceAdapter;
import org.jboss.jca.common.api.metadata.spec.LocalizedXsdString;
import org.jboss.jca.common.api.metadata.spec.MessageListener;
import org.jboss.jca.common.api.metadata.spec.Messageadapter;
import org.jboss.jca.common.api.metadata.spec.OutboundResourceAdapter;
import org.jboss.jca.common.api.metadata.spec.RequiredConfigProperty;
import org.jboss.jca.common.api.metadata.spec.ResourceAdapter;
import org.jboss.jca.common.api.metadata.spec.SecurityPermission;
import org.jboss.jca.common.api.metadata.spec.XsdString;
import org.jboss.jca.common.api.validator.ValidateException;
import org.jboss.jca.common.metadata.common.PoolImpl;
import org.jboss.jca.common.metadata.common.TimeOutImpl;
import org.jboss.jca.common.metadata.common.ValidationImpl;
import org.jboss.jca.common.metadata.common.XaPoolImpl;
import org.jboss.jca.common.metadata.resourceadapter.ActivationImpl;
import org.jboss.jca.common.metadata.resourceadapter.ConnectionDefinitionImpl;
import org.jboss.jca.common.metadata.spec.ActivationSpecImpl;
import org.jboss.jca.common.metadata.spec.AuthenticationMechanismImpl;
import org.jboss.jca.common.metadata.spec.ConfigPropertyImpl;
import org.jboss.jca.common.metadata.spec.ConnectorImpl;
import org.jboss.jca.common.metadata.spec.InboundResourceAdapterImpl;
import org.jboss.jca.common.metadata.spec.MessageAdapterImpl;
import org.jboss.jca.common.metadata.spec.MessageListenerImpl;
import org.jboss.jca.common.metadata.spec.OutboundResourceAdapterImpl;
import org.jboss.jca.common.metadata.spec.RequiredConfigPropertyImpl;
import org.jboss.jca.common.metadata.spec.ResourceAdapterImpl;
import org.jboss.jca.core.api.connectionmanager.ccm.CachedConnectionManager;
import org.jboss.jca.core.api.management.ManagementRepository;
import org.jboss.jca.core.spi.rar.ResourceAdapterRepository;
import org.jboss.jca.core.spi.transaction.TransactionIntegration;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceContainer;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceTarget;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;
import org.wildfly.common.function.ExceptionSupplier;
import org.wildfly.extension.messaging.activemq.ExternalBrokerConfigurationService;
import org.wildfly.extension.messaging.activemq.GroupBindingService;
import org.wildfly.extension.messaging.activemq.JGroupsDiscoveryGroupAdd;
import org.wildfly.extension.messaging.activemq.MessagingServices;
import org.wildfly.extension.messaging.activemq.SocketDiscoveryGroupAdd;
import org.wildfly.extension.messaging.activemq.TransportConfigOperationHandlers;
import org.wildfly.extension.messaging.activemq.broadcast.BroadcastCommandDispatcherFactory;
import org.wildfly.extension.messaging.activemq.broadcast.CommandDispatcherBroadcastEndpointFactory;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
import org.wildfly.security.credential.PasswordCredential;
import org.wildfly.security.credential.source.CredentialSource;
import org.wildfly.security.password.interfaces.ClearPassword;
/**
* A service which translates a pooled connection factory into a resource adapter driven connection pool
*
* @author Emmanuel Hugonnet (c) 2018 Red Hat, inc.
*/
public class ExternalPooledConnectionFactoryService implements Service<ExternalPooledConnectionFactoryService> {
private static final List<LocalizedXsdString> EMPTY_LOCL = Collections.emptyList();
public static final String CONNECTOR_CLASSNAME = "connectorClassName";
public static final String CONNECTION_PARAMETERS = "connectionParameters";
private static final String ACTIVEMQ_ACTIVATION = "org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec";
private static final String ACTIVEMQ_CONN_DEF = "ActiveMQConnectionDefinition";
private static final String ACTIVEMQ_RESOURCE_ADAPTER = "org.wildfly.extension.messaging.activemq.ActiveMQResourceAdapter";
private static final String RAMANAGED_CONN_FACTORY = "org.apache.activemq.artemis.ra.ActiveMQRAManagedConnectionFactory";
private static final String RA_CONN_FACTORY = "org.apache.activemq.artemis.ra.ActiveMQRAConnectionFactory";
private static final String RA_CONN_FACTORY_IMPL = "org.apache.activemq.artemis.ra.ActiveMQRAConnectionFactoryImpl";
private static final String JMS_SESSION = "jakarta.jms.Session";
private static final String ACTIVEMQ_RA_SESSION = "org.apache.activemq.artemis.ra.ActiveMQRASession";
private static final String BASIC_PASS = "BasicPassword";
private static final String JMS_QUEUE = "jakarta.jms.Queue";
private static final String STRING_TYPE = "java.lang.String";
private static final String INTEGER_TYPE = "java.lang.Integer";
private static final String LONG_TYPE = "java.lang.Long";
private static final String SESSION_DEFAULT_TYPE = "SessionDefaultType";
private static final String TRY_LOCK = "UseTryLock";
private static final String JMS_MESSAGE_LISTENER = "jakarta.jms.MessageListener";
private static final String DEFAULT_MAX_RECONNECTS = "5";
public static final String GROUP_ADDRESS = "discoveryAddress";
public static final String DISCOVERY_INITIAL_WAIT_TIMEOUT = "discoveryInitialWaitTimeout";
public static final String GROUP_PORT = "discoveryPort";
public static final String REFRESH_TIMEOUT = "discoveryRefreshTimeout";
public static final String DISCOVERY_LOCAL_BIND_ADDRESS = "discoveryLocalBindAddress";
public static final String JGROUPS_CHANNEL_LOCATOR_CLASS = "jgroupsChannelLocatorClass";
public static final String JGROUPS_CHANNEL_NAME = "jgroupsChannelName";
public static final String JGROUPS_CHANNEL_REF_NAME = "jgroupsChannelRefName";
private final DiscoveryGroupConfiguration discoveryGroupConfiguration;
private final TransportConfiguration[] connectors;
private List<PooledConnectionFactoryConfigProperties> adapterParams;
private String name;
private final Map<String, Supplier<SocketBinding>> socketBindings = new HashMap<>();
private final Map<String, Supplier<OutboundSocketBinding>> outboundSocketBindings = new HashMap<>();
private Map<String, Supplier<SocketBinding>> groupBindings = new HashMap<>();
// mapping between the {discovery}-groups and the cluster names they use
private final Map<String, String> clusterNames = new HashMap<>();
private final Map<String, Supplier<SSLContext>> sslContexts = new HashMap<>();
private Set<String> sslContextNames = new HashSet<>();
// mapping between the {discovery}-groups and the command dispatcher factory they use
private final Map<String, Supplier<BroadcastCommandDispatcherFactory>> commandDispatcherFactories = new HashMap<>();
private BindInfo bindInfo;
private List<String> jndiAliases;
private String txSupport;
private int minPoolSize;
private int maxPoolSize;
private final String jgroupsClusterName;
private final String jgroupsChannelName;
private final String managedConnectionPoolClassName;
// can be null. In that case the behaviour is depending on the IronJacamar container setting.
private final Boolean enlistmentTrace;
private ExceptionSupplier<CredentialSource, Exception> credentialSourceSupplier;
private final boolean createBinderService;
private final CapabilityServiceSupport capabilityServiceSupport;
public ExternalPooledConnectionFactoryService(String name, TransportConfiguration[] connectors, DiscoveryGroupConfiguration groupConfiguration, String jgroupsClusterName,
String jgroupsChannelName, List<PooledConnectionFactoryConfigProperties> adapterParams, BindInfo bindInfo, List<String> jndiAliases, String txSupport,
int minPoolSize, int maxPoolSize, String managedConnectionPoolClassName, Boolean enlistmentTrace, CapabilityServiceSupport capabilityServiceSupport, boolean createBinderService) {
this.name = name;
this.connectors = connectors;
this.discoveryGroupConfiguration = groupConfiguration;
this.jgroupsClusterName = jgroupsClusterName;
this.jgroupsChannelName = jgroupsChannelName;
this.adapterParams = adapterParams;
this.bindInfo = bindInfo;
this.jndiAliases = new ArrayList<>(jndiAliases);
this.createBinderService = createBinderService;
this.txSupport = txSupport;
this.minPoolSize = minPoolSize;
this.maxPoolSize = maxPoolSize;
this.managedConnectionPoolClassName = managedConnectionPoolClassName;
this.enlistmentTrace = enlistmentTrace;
this.capabilityServiceSupport = capabilityServiceSupport;
}
public TransportConfiguration[] getConnectors() {
return Arrays.copyOf(connectors, connectors.length);
}
public BindInfo getBindInfo() {
return bindInfo;
}
static ServiceName getResourceAdapterActivatorsServiceName(String name) {
return ConnectorServices.RESOURCE_ADAPTER_ACTIVATOR_SERVICE.append(name);
}
public static ExternalPooledConnectionFactoryService installService(ServiceTarget serviceTarget,
ExternalBrokerConfigurationService configuration,
String name,
TransportConfiguration[] connectors,
DiscoveryGroupConfiguration groupConfiguration,
Set<String> connectorsSocketBindings,
Set<String> sslContextNames,
String jgroupClusterName,
String jgroupChannelName,
List<PooledConnectionFactoryConfigProperties> adapterParams,
BindInfo bindInfo,
List<String> jndiAliases,
String txSupport,
int minPoolSize,
int maxPoolSize,
String managedConnectionPoolClassName,
Boolean enlistmentTrace,
CapabilityServiceSupport capabilityServiceSupport)
throws OperationFailedException {
ServiceName serviceName = JMSServices.getPooledConnectionFactoryBaseServiceName(MessagingServices.getActiveMQServiceName()).append(name);
ExternalPooledConnectionFactoryService service = new ExternalPooledConnectionFactoryService(name,
connectors, groupConfiguration, jgroupClusterName, jgroupChannelName, adapterParams,
bindInfo, jndiAliases, txSupport, minPoolSize, maxPoolSize, managedConnectionPoolClassName, enlistmentTrace,
capabilityServiceSupport, false);
ServiceBuilder<?> serviceBuilder = serviceTarget.addService(serviceName);
installService0(serviceBuilder, configuration, service, groupConfiguration, connectorsSocketBindings, sslContextNames, capabilityServiceSupport);
return service;
}
public static ExternalPooledConnectionFactoryService installService(OperationContext context,
String name,
TransportConfiguration[] connectors,
DiscoveryGroupConfiguration groupConfiguration,
Set<String> connectorsSocketBindings,
Set<String> sslContextNames,
String jgroupClusterName,
String jgroupChannelName,
List<PooledConnectionFactoryConfigProperties> adapterParams,
BindInfo bindInfo,
List<String> jndiAliases,
String txSupport,
int minPoolSize,
int maxPoolSize,
String managedConnectionPoolClassName,
Boolean enlistmentTrace,
ModelNode model) throws OperationFailedException {
ServiceName serviceName = JMSServices.getPooledConnectionFactoryBaseServiceName(MessagingServices.getActiveMQServiceName()).append(name);
ExternalPooledConnectionFactoryService service = new ExternalPooledConnectionFactoryService(name,
connectors, groupConfiguration, jgroupClusterName, jgroupChannelName, adapterParams,
bindInfo, jndiAliases, txSupport, minPoolSize, maxPoolSize, managedConnectionPoolClassName, enlistmentTrace, context.getCapabilityServiceSupport(), true);
installService0(context, serviceName, service, groupConfiguration, connectorsSocketBindings, sslContextNames, model);
return service;
}
private static void installService0(OperationContext context,
ServiceName serviceName,
ExternalPooledConnectionFactoryService service,
DiscoveryGroupConfiguration groupConfiguration,
Set<String> connectorsSocketBindings,
Set<String> sslContextNames,
ModelNode model) throws OperationFailedException {
ServiceBuilder<?> serviceBuilder = context.getServiceTarget().addService(serviceName);
serviceBuilder.requires(context.getCapabilityServiceName(MessagingServices.LOCAL_TRANSACTION_PROVIDER_CAPABILITY, null));
// ensures that Artemis client thread pools are not stopped before any deployment depending on a pooled-connection-factory
serviceBuilder.requires(MessagingServices.ACTIVEMQ_CLIENT_THREAD_POOL);
ModelNode credentialReference = ConnectionFactoryAttributes.Pooled.CREDENTIAL_REFERENCE.resolveModelAttribute(context, model);
if (credentialReference.isDefined()) {
service.credentialSourceSupplier = CredentialReference.getCredentialSourceSupplier(context, ConnectionFactoryAttributes.Pooled.CREDENTIAL_REFERENCE, model, serviceBuilder);
}
for (final String entry : sslContextNames) {
Supplier<SSLContext> sslContext = serviceBuilder.requires(ELYTRON_SSL_CONTEXT_CAPABILITY.getCapabilityServiceName(entry));
service.sslContexts.put(entry, sslContext);
}
service.sslContextNames.addAll(sslContextNames);
Map<String, Boolean> outbounds = TransportConfigOperationHandlers.listOutBoundSocketBinding(context, connectorsSocketBindings);
for (final String connectorSocketBinding : connectorsSocketBindings) {
// find whether the connectorSocketBinding references a SocketBinding or an OutboundSocketBinding
if (outbounds.get(connectorSocketBinding)) {
final ServiceName outboundSocketName = OUTBOUND_SOCKET_BINDING_CAPABILITY.getCapabilityServiceName(connectorSocketBinding);
Supplier<OutboundSocketBinding> outboundSocketBindingSupplier = serviceBuilder.requires(outboundSocketName);
service.outboundSocketBindings.put(connectorSocketBinding, outboundSocketBindingSupplier);
} else {
final ServiceName socketName = SOCKET_BINDING_CAPABILITY.getCapabilityServiceName(connectorSocketBinding);
Supplier<SocketBinding> socketBindingSupplier = serviceBuilder.requires(socketName);
service.socketBindings.put(connectorSocketBinding, socketBindingSupplier);
}
}
if (groupConfiguration != null) {
final String key = "discovery" + groupConfiguration.getName();
if (service.jgroupsClusterName != null) {
Supplier<BroadcastCommandDispatcherFactory> commandDispatcherFactorySupplier = serviceBuilder.requires(MessagingServices.getBroadcastCommandDispatcherFactoryServiceName(service.jgroupsChannelName));
service.commandDispatcherFactories.put(key, commandDispatcherFactorySupplier);
service.clusterNames.put(key, service.jgroupsClusterName);
} else {
final ServiceName groupBinding = GroupBindingService.getDiscoveryBaseServiceName(MessagingServices.getActiveMQServiceName()).append(groupConfiguration.getName());
Supplier<SocketBinding> socketBindingSupplier = serviceBuilder.requires(groupBinding);
service.groupBindings.put(key, socketBindingSupplier);
}
}
serviceBuilder.setInstance(service);
serviceBuilder.install();
}
private static void installService0(ServiceBuilder<?> serviceBuilder,
ExternalBrokerConfigurationService configuration,
ExternalPooledConnectionFactoryService service,
DiscoveryGroupConfiguration groupConfiguration,
Set<String> connectorsSocketBindings,
Set<String> sslContextNames,
CapabilityServiceSupport capabilityServiceSupport) throws OperationFailedException {
serviceBuilder.requires(capabilityServiceSupport.getCapabilityServiceName(MessagingServices.LOCAL_TRANSACTION_PROVIDER_CAPABILITY));
// ensures that Artemis client thread pools are not stopped before any deployment depending on a pooled-connection-factory
serviceBuilder.requires(MessagingServices.ACTIVEMQ_CLIENT_THREAD_POOL);
for (final String entry : sslContextNames) {
Supplier<SSLContext> sslContext = serviceBuilder.requires(ELYTRON_SSL_CONTEXT_CAPABILITY.getCapabilityServiceName(entry));
service.sslContexts.put(entry, sslContext);
}
service.sslContextNames.addAll(sslContextNames);
Map<String, ServiceName> outbounds = configuration.getOutboundSocketBindings();
for (final String connectorSocketBinding : connectorsSocketBindings) {
// find whether the connectorSocketBinding references a SocketBinding or an OutboundSocketBinding
if (outbounds.containsKey(connectorSocketBinding)) {
Supplier<OutboundSocketBinding> outboundSocketBindingSupplier = serviceBuilder.requires(configuration.getOutboundSocketBindings().get(connectorSocketBinding));
service.outboundSocketBindings.put(connectorSocketBinding, outboundSocketBindingSupplier);
} else {
Supplier<SocketBinding> socketBindingSupplier = serviceBuilder.requires(configuration.getSocketBindings().get(connectorSocketBinding));
service.socketBindings.put(connectorSocketBinding, socketBindingSupplier);
}
}
if (groupConfiguration != null) {
final String key = "discovery" + groupConfiguration.getName();
if (service.jgroupsClusterName != null) {
Supplier<BroadcastCommandDispatcherFactory> commandDispatcherFactorySupplier = serviceBuilder.requires(configuration.getCommandDispatcherFactories().get(key));
service.commandDispatcherFactories.put(key, commandDispatcherFactorySupplier);
service.clusterNames.put(key, service.jgroupsClusterName);
} else {
Supplier<SocketBinding> socketBindingSupplier = serviceBuilder.requires(configuration.getGroupBindings().get(key));
service.groupBindings.put(key, socketBindingSupplier);
}
}
serviceBuilder.setInstance(service);
serviceBuilder.install();
}
@Override
public ExternalPooledConnectionFactoryService getValue() throws IllegalStateException, IllegalArgumentException {
return this;
}
@Override
public void start(StartContext context) throws StartException {
ServiceTarget serviceTarget = context.getChildTarget();
try {
createService(serviceTarget, context.getController().getServiceContainer());
} catch (Exception e) {
throw MessagingLogger.ROOT_LOGGER.failedToCreate(e, "resource adapter");
}
}
private void createService(ServiceTarget serviceTarget, ServiceContainer container) throws Exception {
InputStream is = null;
InputStream isIj = null;
// Properties for the resource adapter
List<ConfigProperty> properties = new ArrayList<ConfigProperty>();
try {
StringBuilder connectorClassname = new StringBuilder();
StringBuilder connectorParams = new StringBuilder();
TransportConfigOperationHandlers.processConnectorBindings(Arrays.asList(connectors), socketBindings, outboundSocketBindings);
for (TransportConfiguration tc : connectors) {
if (tc == null) {
throw MessagingLogger.ROOT_LOGGER.connectorNotDefined("null");
}
if (connectorClassname.length() > 0) {
connectorClassname.append(",");
connectorParams.append(",");
}
connectorClassname.append(tc.getFactoryClassName());
Map<String, Object> params = tc.getParams();
boolean multiple = false;
for (Map.Entry<String, Object> entry : params.entrySet()) {
if (multiple) {
connectorParams.append(";");
}
connectorParams.append(entry.getKey()).append("=").append(entry.getValue());
multiple = true;
}
}
if (connectorClassname.length() > 0) {
properties.add(simpleProperty15(CONNECTOR_CLASSNAME, STRING_TYPE, connectorClassname.toString()));
}
if (connectorParams.length() > 0) {
properties.add(simpleProperty15(CONNECTION_PARAMETERS, STRING_TYPE, connectorParams.toString()));
}
if (discoveryGroupConfiguration != null) {
final String dgName = discoveryGroupConfiguration.getName();
final String key = "discovery" + dgName;
final DiscoveryGroupConfiguration config;
if (commandDispatcherFactories.containsKey(key)) {
BroadcastCommandDispatcherFactory commandDispatcherFactory = commandDispatcherFactories.get(key).get();
String clusterName = clusterNames.get(key);
config = JGroupsDiscoveryGroupAdd.createDiscoveryGroupConfiguration(name, discoveryGroupConfiguration, commandDispatcherFactory, clusterName);
} else {
final SocketBinding binding = groupBindings.get(key).get();
if (binding == null) {
throw MessagingLogger.ROOT_LOGGER.failedToFindDiscoverySocketBinding(dgName);
}
config = SocketDiscoveryGroupAdd.createDiscoveryGroupConfiguration(name, discoveryGroupConfiguration, binding);
binding.getSocketBindings().getNamedRegistry().registerBinding(ManagedBinding.Factory.createSimpleManagedBinding(binding));
}
BroadcastEndpointFactory bgCfg = config.getBroadcastEndpointFactory();
if (bgCfg instanceof UDPBroadcastEndpointFactory) {
UDPBroadcastEndpointFactory udpCfg = (UDPBroadcastEndpointFactory) bgCfg;
properties.add(simpleProperty15(GROUP_ADDRESS, STRING_TYPE, udpCfg.getGroupAddress()));
properties.add(simpleProperty15(GROUP_PORT, INTEGER_TYPE, "" + udpCfg.getGroupPort()));
properties.add(simpleProperty15(DISCOVERY_LOCAL_BIND_ADDRESS, STRING_TYPE, "" + udpCfg.getLocalBindAddress()));
} else if (bgCfg instanceof CommandDispatcherBroadcastEndpointFactory) {
String external = "/" + name + ":discovery" + dgName;
properties.add(simpleProperty15(JGROUPS_CHANNEL_NAME, STRING_TYPE, jgroupsClusterName));
properties.add(simpleProperty15(JGROUPS_CHANNEL_REF_NAME, STRING_TYPE, external));
}
properties.add(simpleProperty15(DISCOVERY_INITIAL_WAIT_TIMEOUT, LONG_TYPE, "" + config.getDiscoveryInitialWaitTimeout()));
properties.add(simpleProperty15(REFRESH_TIMEOUT, LONG_TYPE, "" + config.getRefreshTimeout()));
}
boolean hasReconnect = false;
final List<ConfigProperty> inboundProperties = new ArrayList<>();
final List<ConfigProperty> outboundProperties = new ArrayList<>();
final String reconnectName = ConnectionFactoryAttributes.Pooled.RECONNECT_ATTEMPTS_PROP_NAME;
for (PooledConnectionFactoryConfigProperties adapterParam : adapterParams) {
hasReconnect |= reconnectName.equals(adapterParam.getName());
ConfigProperty p = simpleProperty15(adapterParam.getName(), adapterParam.getType(), adapterParam.getValue());
if (adapterParam.getName().equals(REBALANCE_CONNECTIONS_PROP_NAME)) {
boolean rebalanceConnections = Boolean.parseBoolean(adapterParam.getValue());
if (rebalanceConnections) {
inboundProperties.add(p);
}
} else {
if (null == adapterParam.getConfigType()) {
properties.add(p);
} else {
switch (adapterParam.getConfigType()) {
case INBOUND:
inboundProperties.add(p);
break;
case OUTBOUND:
outboundProperties.add(p);
break;
default:
properties.add(p);
break;
}
}
}
}
// The default -1, which will hang forever until a server appears
if (!hasReconnect) {
properties.add(simpleProperty15(reconnectName, Integer.class.getName(), DEFAULT_MAX_RECONNECTS));
}
configureCredential(properties);
WildFlyRecoveryRegistry.container = container;
OutboundResourceAdapter outbound = createOutbound(outboundProperties);
InboundResourceAdapter inbound = createInbound(inboundProperties);
ResourceAdapter ra = createResourceAdapter15(properties, outbound, inbound);
Connector cmd = createConnector15(ra);
TransactionSupportEnum transactionSupport = getTransactionSupport(txSupport);
ConnectionDefinition common = createConnDef(transactionSupport, bindInfo.getBindName(), minPoolSize, maxPoolSize, managedConnectionPoolClassName, enlistmentTrace);
Activation activation = createActivation(common, transactionSupport);
ResourceAdapterActivatorService activator = new ResourceAdapterActivatorService(cmd, activation,
ExternalPooledConnectionFactoryService.class.getClassLoader(), name);
activator.setBindInfo(bindInfo);
activator.setCreateBinderService(createBinderService);
activator.addJndiAliases(jndiAliases);
final ServiceBuilder sb
= Services.addServerExecutorDependency(
serviceTarget.addService(getResourceAdapterActivatorsServiceName(name), activator),
activator.getExecutorServiceInjector())
.addDependency(ConnectorServices.IRONJACAMAR_MDR, AS7MetadataRepository.class,
activator.getMdrInjector())
.addDependency(ConnectorServices.RA_REPOSITORY_SERVICE, ResourceAdapterRepository.class,
activator.getRaRepositoryInjector())
.addDependency(ConnectorServices.MANAGEMENT_REPOSITORY_SERVICE, ManagementRepository.class,
activator.getManagementRepositoryInjector())
.addDependency(ConnectorServices.RESOURCE_ADAPTER_REGISTRY_SERVICE,
ResourceAdapterDeploymentRegistry.class, activator.getRegistryInjector())
.addDependency(ConnectorServices.TRANSACTION_INTEGRATION_SERVICE, TransactionIntegration.class,
activator.getTxIntegrationInjector())
.addDependency(ConnectorServices.CONNECTOR_CONFIG_SERVICE,
JcaSubsystemConfiguration.class, activator.getConfigInjector())
.addDependency(ConnectorServices.CCM_SERVICE, CachedConnectionManager.class,
activator.getCcmInjector());
sb.requires(NamingService.SERVICE_NAME);
sb.requires(capabilityServiceSupport.getCapabilityServiceName(MessagingServices.LOCAL_TRANSACTION_PROVIDER_CAPABILITY));
sb.requires(ConnectorServices.BOOTSTRAP_CONTEXT_SERVICE.append("default"));
sb.setInitialMode(ServiceController.Mode.PASSIVE).install();
// Mock the deployment service to allow it to start
serviceTarget.addService(ConnectorServices.RESOURCE_ADAPTER_DEPLOYER_SERVICE_PREFIX.append(name), Service.NULL).install();
} finally {
if (is != null) {
is.close();
}
if (isIj != null) {
isIj.close();
}
}
}
/**
* Configure password from a credential-reference (as an alternative to the password attribute)
* and add it to the RA properties.
*/
private void configureCredential(List<ConfigProperty> properties) {
// if a credential-reference has been defined, get the password property from it
if (credentialSourceSupplier != null) {
try {
CredentialSource credentialSource = credentialSourceSupplier.get();
if (credentialSource != null) {
char[] password = credentialSource.getCredential(PasswordCredential.class).getPassword(ClearPassword.class).getPassword();
if (password != null) {
// add the password property
properties.add(simpleProperty15("password", String.class.getName(), new String(password)));
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
private static TransactionSupportEnum getTransactionSupport(String txSupport) {
try {
return TransactionSupportEnum.valueOf(txSupport);
} catch (RuntimeException e) {
return TransactionSupportEnum.LocalTransaction;
}
}
private static Activation createActivation(ConnectionDefinition common, TransactionSupportEnum transactionSupport) {
List<ConnectionDefinition> definitions = Collections.singletonList(common);
return new ActivationImpl(null, null, transactionSupport, definitions, Collections.<AdminObject>emptyList(), Collections.<String, String>emptyMap(), Collections.<String>emptyList(), null, null);
}
private static ConnectionDefinition createConnDef(TransactionSupportEnum transactionSupport, String jndiName, int minPoolSize, int maxPoolSize, String managedConnectionPoolClassName, Boolean enlistmentTrace) throws ValidateException {
Integer minSize = (minPoolSize == -1) ? null : minPoolSize;
Integer maxSize = (maxPoolSize == -1) ? null : maxPoolSize;
boolean prefill = false;
boolean useStrictMin = false;
FlushStrategy flushStrategy = FlushStrategy.FAILING_CONNECTION_ONLY;
Boolean isXA = Boolean.FALSE;
final Pool pool;
if (transactionSupport == TransactionSupportEnum.XATransaction) {
pool = new XaPoolImpl(minSize, Defaults.INITIAL_POOL_SIZE, maxSize, prefill, useStrictMin, flushStrategy, null, Defaults.FAIR,
Defaults.IS_SAME_RM_OVERRIDE, Defaults.INTERLEAVING, Defaults.PAD_XID, Defaults.WRAP_XA_RESOURCE, Defaults.NO_TX_SEPARATE_POOL);
isXA = Boolean.TRUE;
} else {
pool = new PoolImpl(minSize, Defaults.INITIAL_POOL_SIZE, maxSize, prefill, useStrictMin, flushStrategy, null, Defaults.FAIR);
}
TimeOut timeOut = new TimeOutImpl(null, null, null, null, null) {
};
// <security>
// <application />
// </security>
// => PoolStrategy.POOL_BY_CRI
Security security = new SecurityImpl(null, null, true);
// register the XA Connection *without* recovery. ActiveMQ already takes care of the registration with the correct credentials
// when its ResourceAdapter is started
Recovery recovery = new Recovery(new CredentialImpl(null, null, null, null), null, Boolean.TRUE);
Validation validation = new ValidationImpl(Defaults.VALIDATE_ON_MATCH, null, null, false);
// do no track
return new ConnectionDefinitionImpl(Collections.<String, String>emptyMap(), RAMANAGED_CONN_FACTORY, jndiName, ACTIVEMQ_CONN_DEF, true, true, true, Defaults.SHARABLE, Defaults.ENLISTMENT, Defaults.CONNECTABLE, false, managedConnectionPoolClassName, enlistmentTrace, pool, timeOut, validation, security, recovery, isXA);
}
private static Connector createConnector15(ResourceAdapter ra) {
return new ConnectorImpl(Connector.Version.V_15, null, str("Red Hat"), str("JMS 1.1 Server"), str("1.0"), null, ra, null, false, EMPTY_LOCL, EMPTY_LOCL, Collections.<Icon>emptyList(), null);
}
private ResourceAdapter createResourceAdapter15(List<ConfigProperty> properties, OutboundResourceAdapter outbound, InboundResourceAdapter inbound) {
return new ResourceAdapterImpl(str(ACTIVEMQ_RESOURCE_ADAPTER), properties, outbound, inbound, Collections.<org.jboss.jca.common.api.metadata.spec.AdminObject>emptyList(), Collections.<SecurityPermission>emptyList(), null);
}
private InboundResourceAdapter createInbound(List<ConfigProperty> inboundProps) {
List<RequiredConfigProperty> destination = Collections.<RequiredConfigProperty>singletonList(new RequiredConfigPropertyImpl(EMPTY_LOCL, str("destination"), null));
Activationspec activation15 = new ActivationSpecImpl(str(ACTIVEMQ_ACTIVATION), destination, inboundProps, null);
List<MessageListener> messageListeners = Collections.<MessageListener>singletonList(new MessageListenerImpl(str(JMS_MESSAGE_LISTENER), activation15, null));
Messageadapter message = new MessageAdapterImpl(messageListeners, null);
return new InboundResourceAdapterImpl(message, null);
}
private static OutboundResourceAdapter createOutbound(List<ConfigProperty> outboundProperties) {
List<org.jboss.jca.common.api.metadata.spec.ConnectionDefinition> definitions = new ArrayList<>();
List<ConfigProperty> props = new ArrayList<>(outboundProperties);
props.add(simpleProperty15(SESSION_DEFAULT_TYPE, STRING_TYPE, JMS_QUEUE));
props.add(simpleProperty15(TRY_LOCK, INTEGER_TYPE, "0"));
definitions.add(new org.jboss.jca.common.metadata.spec.ConnectionDefinitionImpl(str(RAMANAGED_CONN_FACTORY), props, str(RA_CONN_FACTORY), str(RA_CONN_FACTORY_IMPL), str(JMS_SESSION), str(ACTIVEMQ_RA_SESSION), null));
AuthenticationMechanism basicPassword = new AuthenticationMechanismImpl(Collections.<LocalizedXsdString>emptyList(), str(BASIC_PASS), CredentialInterfaceEnum.PasswordCredential, null, null);
return new OutboundResourceAdapterImpl(definitions, TransactionSupportEnum.XATransaction, Collections.singletonList(basicPassword), false, null, null, null);
}
private static XsdString str(String str) {
return new XsdString(str, null);
}
private static ConfigProperty simpleProperty15(String name, String type, String value) {
return new ConfigPropertyImpl(EMPTY_LOCL, str(name), str(type), str(value), null, null, null, null, false, null, null, null, null);
}
@Override
public void stop(StopContext context) {
// Service context takes care of this
}
public BroadcastCommandDispatcherFactory getCommandDispatcherFactory(String name) {
return this.commandDispatcherFactories.get(name).get();
}
}
| 39,717
| 59.638168
| 326
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/PooledConnectionFactoryService.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.jms;
import static org.jboss.as.naming.deployment.ContextNames.BindInfo;
import static org.wildfly.extension.messaging.activemq.MessagingServices.getActiveMQServiceName;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Pooled.REBALANCE_CONNECTIONS_PROP_NAME;
import static org.wildfly.extension.messaging.activemq.jms.JMSQueueService.JMS_QUEUE_PREFIX;
import static org.wildfly.extension.messaging.activemq.jms.JMSTopicService.JMS_TOPIC_PREFIX;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.activemq.artemis.api.core.BroadcastEndpointFactory;
import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
import org.apache.activemq.artemis.api.core.TransportConfiguration;
import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.jboss.as.connector.metadata.common.CredentialImpl;
import org.jboss.as.connector.metadata.common.SecurityImpl;
import org.jboss.as.connector.services.mdr.AS7MetadataRepository;
import org.jboss.as.connector.services.resourceadapters.ResourceAdapterActivatorService;
import org.jboss.as.connector.services.resourceadapters.deployment.registry.ResourceAdapterDeploymentRegistry;
import org.jboss.as.connector.subsystems.jca.JcaSubsystemConfiguration;
import org.jboss.as.connector.util.ConnectorServices;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.security.CredentialReference;
import org.jboss.as.naming.service.NamingService;
import org.jboss.as.network.SocketBinding;
import org.jboss.as.server.Services;
import org.jboss.dmr.ModelNode;
import org.jboss.jca.common.api.metadata.Defaults;
import org.jboss.jca.common.api.metadata.common.FlushStrategy;
import org.jboss.jca.common.api.metadata.common.Pool;
import org.jboss.jca.common.api.metadata.common.Recovery;
import org.jboss.jca.common.api.metadata.common.Security;
import org.jboss.jca.common.api.metadata.common.TimeOut;
import org.jboss.jca.common.api.metadata.common.TransactionSupportEnum;
import org.jboss.jca.common.api.metadata.common.Validation;
import org.jboss.jca.common.api.metadata.resourceadapter.Activation;
import org.jboss.jca.common.api.metadata.resourceadapter.AdminObject;
import org.jboss.jca.common.api.metadata.resourceadapter.ConnectionDefinition;
import org.jboss.jca.common.api.metadata.spec.Activationspec;
import org.jboss.jca.common.api.metadata.spec.AuthenticationMechanism;
import org.jboss.jca.common.api.metadata.spec.ConfigProperty;
import org.jboss.jca.common.api.metadata.spec.Connector;
import org.jboss.jca.common.api.metadata.spec.CredentialInterfaceEnum;
import org.jboss.jca.common.api.metadata.spec.Icon;
import org.jboss.jca.common.api.metadata.spec.InboundResourceAdapter;
import org.jboss.jca.common.api.metadata.spec.LocalizedXsdString;
import org.jboss.jca.common.api.metadata.spec.MessageListener;
import org.jboss.jca.common.api.metadata.spec.Messageadapter;
import org.jboss.jca.common.api.metadata.spec.OutboundResourceAdapter;
import org.jboss.jca.common.api.metadata.spec.RequiredConfigProperty;
import org.jboss.jca.common.api.metadata.spec.ResourceAdapter;
import org.jboss.jca.common.api.metadata.spec.SecurityPermission;
import org.jboss.jca.common.api.metadata.spec.XsdString;
import org.jboss.jca.common.api.validator.ValidateException;
import org.jboss.jca.common.metadata.common.PoolImpl;
import org.jboss.jca.common.metadata.common.TimeOutImpl;
import org.jboss.jca.common.metadata.common.ValidationImpl;
import org.jboss.jca.common.metadata.common.XaPoolImpl;
import org.jboss.jca.common.metadata.resourceadapter.ActivationImpl;
import org.jboss.jca.common.metadata.resourceadapter.ConnectionDefinitionImpl;
import org.jboss.jca.common.metadata.spec.ActivationSpecImpl;
import org.jboss.jca.common.metadata.spec.AuthenticationMechanismImpl;
import org.jboss.jca.common.metadata.spec.ConfigPropertyImpl;
import org.jboss.jca.common.metadata.spec.ConnectorImpl;
import org.jboss.jca.common.metadata.spec.InboundResourceAdapterImpl;
import org.jboss.jca.common.metadata.spec.MessageAdapterImpl;
import org.jboss.jca.common.metadata.spec.MessageListenerImpl;
import org.jboss.jca.common.metadata.spec.OutboundResourceAdapterImpl;
import org.jboss.jca.common.metadata.spec.RequiredConfigPropertyImpl;
import org.jboss.jca.common.metadata.spec.ResourceAdapterImpl;
import org.jboss.jca.core.api.connectionmanager.ccm.CachedConnectionManager;
import org.jboss.jca.core.api.management.ManagementRepository;
import org.jboss.jca.core.spi.rar.ResourceAdapterRepository;
import org.jboss.jca.core.spi.transaction.TransactionIntegration;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceContainer;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceTarget;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;
import org.jboss.msc.value.InjectedValue;
import org.wildfly.common.function.ExceptionSupplier;
import org.wildfly.extension.messaging.activemq.ActiveMQActivationService;
import org.wildfly.extension.messaging.activemq.MessagingServices;
import org.wildfly.extension.messaging.activemq.broadcast.CommandDispatcherBroadcastEndpointFactory;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
import org.wildfly.security.credential.PasswordCredential;
import org.wildfly.security.credential.source.CredentialSource;
import org.wildfly.security.password.interfaces.ClearPassword;
/**
* A service which translates a pooled connection factory into a resource adapter driven connection pool
*
* @author <a href="mailto:andy.taylor@jboss.com">Andy Taylor</a>
* @author <a href="mailto:jbertram@redhat.com">Justin Bertram</a>
* @author Jason T. Greene
* Date: 5/13/11
* Time: 2:21 PM
*/
public class PooledConnectionFactoryService implements Service<Void> {
private static final List<LocalizedXsdString> EMPTY_LOCL = Collections.emptyList();
public static final String CONNECTOR_CLASSNAME = "connectorClassName";
public static final String CONNECTION_PARAMETERS = "connectionParameters";
private static final String ACTIVEMQ_ACTIVATION = "org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec";
private static final String ACTIVEMQ_CONN_DEF = "ActiveMQConnectionDefinition";
private static final String ACTIVEMQ_RESOURCE_ADAPTER = "org.wildfly.extension.messaging.activemq.ActiveMQResourceAdapter";
private static final String RAMANAGED_CONN_FACTORY = "org.apache.activemq.artemis.ra.ActiveMQRAManagedConnectionFactory";
private static final String RA_CONN_FACTORY = "org.apache.activemq.artemis.ra.ActiveMQRAConnectionFactory";
private static final String RA_CONN_FACTORY_IMPL = "org.apache.activemq.artemis.ra.ActiveMQRAConnectionFactoryImpl";
private static final String JMS_SESSION = "jakarta.jms.Session";
private static final String ACTIVEMQ_RA_SESSION = "org.apache.activemq.artemis.ra.ActiveMQRASession";
private static final String BASIC_PASS = "BasicPassword";
private static final String JMS_QUEUE = "jakarta.jms.Queue";
private static final String STRING_TYPE = "java.lang.String";
private static final String INTEGER_TYPE = "java.lang.Integer";
private static final String LONG_TYPE = "java.lang.Long";
private static final String SESSION_DEFAULT_TYPE = "SessionDefaultType";
private static final String TRY_LOCK = "UseTryLock";
private static final String JMS_MESSAGE_LISTENER = "jakarta.jms.MessageListener";
private static final String DEFAULT_MAX_RECONNECTS = "5";
public static final String GROUP_ADDRESS = "discoveryAddress";
public static final String DISCOVERY_INITIAL_WAIT_TIMEOUT = "discoveryInitialWaitTimeout";
public static final String GROUP_PORT = "discoveryPort";
public static final String REFRESH_TIMEOUT = "discoveryRefreshTimeout";
public static final String DISCOVERY_LOCAL_BIND_ADDRESS = "discoveryLocalBindAddress";
public static final String JGROUPS_CHANNEL_LOCATOR_CLASS = "jgroupsChannelLocatorClass";
public static final String JGROUPS_CHANNEL_NAME = "jgroupsChannelName";
public static final String JGROUPS_CHANNEL_REF_NAME = "jgroupsChannelRefName";
public static final String IGNORE_JTA = "ignoreJTA";
private List<String> connectors;
private String discoveryGroupName;
private List<PooledConnectionFactoryConfigProperties> adapterParams;
private String name;
private Map<String, SocketBinding> socketBindings = new HashMap<String, SocketBinding>();
private InjectedValue<ActiveMQServer> activeMQServer = new InjectedValue<>();
private BindInfo bindInfo;
private List<String> jndiAliases;
private final boolean pickAnyConnectors;
private String txSupport;
private int minPoolSize;
private int maxPoolSize;
private String serverName;
private final String jgroupsChannelName;
private final boolean createBinderService;
private final String managedConnectionPoolClassName;
// can be null. In that case the behaviour is depending on the IronJacamar container setting.
private final Boolean enlistmentTrace;
private InjectedValue<ExceptionSupplier<CredentialSource, Exception>> credentialSourceSupplier = new InjectedValue<>();
public PooledConnectionFactoryService(String name, List<String> connectors, String discoveryGroupName, String serverName, String jgroupsChannelName, List<PooledConnectionFactoryConfigProperties> adapterParams, BindInfo bindInfo, List<String> jndiAliases, String txSupport, int minPoolSize, int maxPoolSize, String managedConnectionPoolClassName, Boolean enlistmentTrace) {
this.name = name;
this.connectors = connectors;
this.discoveryGroupName = discoveryGroupName;
this.serverName = serverName;
this.jgroupsChannelName = jgroupsChannelName;
this.adapterParams = adapterParams;
this.bindInfo = bindInfo;
this.jndiAliases = new ArrayList<>(jndiAliases);
createBinderService = true;
this.txSupport = txSupport;
this.minPoolSize = minPoolSize;
this.maxPoolSize = maxPoolSize;
this.managedConnectionPoolClassName = managedConnectionPoolClassName;
this.enlistmentTrace = enlistmentTrace;
this.pickAnyConnectors = false;
}
public PooledConnectionFactoryService(String name, List<String> connectors, String discoveryGroupName, String serverName, String jgroupsChannelName, List<PooledConnectionFactoryConfigProperties> adapterParams, BindInfo bindInfo, String txSupport, int minPoolSize, int maxPoolSize, String managedConnectionPoolClassName, Boolean enlistmentTrace, boolean pickAnyConnectors) {
this.name = name;
this.connectors = connectors;
this.discoveryGroupName = discoveryGroupName;
this.serverName = serverName;
this.jgroupsChannelName = jgroupsChannelName;
this.adapterParams = adapterParams;
this.bindInfo = bindInfo;
this.jndiAliases = Collections.emptyList();
this.createBinderService = false;
this.txSupport = txSupport;
this.minPoolSize = minPoolSize;
this.maxPoolSize = maxPoolSize;
this.managedConnectionPoolClassName = managedConnectionPoolClassName;
this.enlistmentTrace = enlistmentTrace;
this.pickAnyConnectors = pickAnyConnectors;
}
static ServiceName getResourceAdapterActivatorsServiceName(String name) {
return ConnectorServices.RESOURCE_ADAPTER_ACTIVATOR_SERVICE.append(name);
}
InjectedValue<ExceptionSupplier<CredentialSource, Exception>> getCredentialSourceSupplierInjector() {
return credentialSourceSupplier;
}
public static PooledConnectionFactoryService installService(ServiceTarget serviceTarget,
String name,
String serverName,
List<String> connectors,
String discoveryGroupName,
String jgroupsChannelName,
List<PooledConnectionFactoryConfigProperties> adapterParams,
BindInfo bindInfo,
String txSupport,
int minPoolSize,
int maxPoolSize,
String managedConnectionPoolClassName,
Boolean enlistmentTrace,
boolean pickAnyConnectors) {
ServiceName serverServiceName = MessagingServices.getActiveMQServiceName(serverName);
ServiceName serviceName = JMSServices.getPooledConnectionFactoryBaseServiceName(serverServiceName).append(name);
PooledConnectionFactoryService service = new PooledConnectionFactoryService(name,
connectors, discoveryGroupName, serverName, jgroupsChannelName, adapterParams,
bindInfo, txSupport, minPoolSize, maxPoolSize, managedConnectionPoolClassName, enlistmentTrace, pickAnyConnectors);
installService0(serviceTarget, serverServiceName, serviceName, service);
return service;
}
public static PooledConnectionFactoryService installService(OperationContext context,
String name,
String serverName,
List<String> connectors,
String discoveryGroupName,
String jgroupsChannelName,
List<PooledConnectionFactoryConfigProperties> adapterParams,
BindInfo bindInfo,
List<String> jndiAliases,
String txSupport,
int minPoolSize,
int maxPoolSize,
String managedConnectionPoolClassName,
Boolean enlistmentTrace,
ModelNode model) throws OperationFailedException {
ServiceName serverServiceName = MessagingServices.getActiveMQServiceName(serverName);
ServiceName serviceName = JMSServices.getPooledConnectionFactoryBaseServiceName(serverServiceName).append(name);
PooledConnectionFactoryService service = new PooledConnectionFactoryService(name,
connectors, discoveryGroupName, serverName, jgroupsChannelName, adapterParams,
bindInfo, jndiAliases, txSupport, minPoolSize, maxPoolSize, managedConnectionPoolClassName, enlistmentTrace);
installService0(context, serverServiceName, serviceName, service, model);
return service;
}
private static void installService0(ServiceTarget serviceTarget, ServiceName serverServiceName, ServiceName serviceName, PooledConnectionFactoryService service) {
ServiceBuilder serviceBuilder = createServiceBuilder(serviceTarget, serverServiceName, serviceName, service);
serviceBuilder.install();
}
private static void installService0(OperationContext context,
ServiceName serverServiceName,
ServiceName serviceName,
PooledConnectionFactoryService service,
ModelNode model) throws OperationFailedException {
ServiceBuilder serviceBuilder = createServiceBuilder(context.getServiceTarget(), serverServiceName, serviceName, service);
ModelNode credentialReference = ConnectionFactoryAttributes.Pooled.CREDENTIAL_REFERENCE.resolveModelAttribute(context, model);
if (credentialReference.isDefined()) {
service.getCredentialSourceSupplierInjector().inject(CredentialReference.getCredentialSourceSupplier(context, ConnectionFactoryAttributes.Pooled.CREDENTIAL_REFERENCE, model, serviceBuilder));
}
serviceBuilder.install();
}
private static ServiceBuilder createServiceBuilder(ServiceTarget serviceTarget, ServiceName serverServiceName, ServiceName serviceName, PooledConnectionFactoryService service) {
ServiceBuilder serviceBuilder = serviceTarget.addService(serviceName, service);
serviceBuilder.requires(MessagingServices.getCapabilityServiceName(MessagingServices.LOCAL_TRANSACTION_PROVIDER_CAPABILITY));
serviceBuilder.addDependency(serverServiceName, ActiveMQServer.class, service.activeMQServer);
serviceBuilder.requires(ActiveMQActivationService.getServiceName(serverServiceName));
serviceBuilder.requires(JMSServices.getJmsManagerBaseServiceName(serverServiceName));
// ensures that Artemis client thread pools are not stopped before any deployment depending on a pooled-connection-factory
serviceBuilder.requires(MessagingServices.ACTIVEMQ_CLIENT_THREAD_POOL);
serviceBuilder.setInitialMode(ServiceController.Mode.PASSIVE);
return serviceBuilder;
}
@Override
public Void getValue() throws IllegalStateException, IllegalArgumentException {
return null;
}
@Override
public void start(StartContext context) throws StartException {
ServiceTarget serviceTarget = context.getChildTarget();
try {
createService(serviceTarget, context.getController().getServiceContainer());
}
catch (Exception e) {
throw MessagingLogger.ROOT_LOGGER.failedToCreate(e, "resource adapter");
}
}
private void createService(ServiceTarget serviceTarget, ServiceContainer container) throws Exception {
InputStream is = null;
InputStream isIj = null;
// Properties for the resource adapter
List<ConfigProperty> properties = new ArrayList<ConfigProperty>();
try {
StringBuilder connectorClassname = new StringBuilder();
StringBuilder connectorParams = new StringBuilder();
// if there is no discovery-group and the connector list is empty,
// pick the first connector available if pickAnyConnectors is true
if (discoveryGroupName == null && connectors.isEmpty() && pickAnyConnectors) {
Set<String> connectorNames = activeMQServer.getValue().getConfiguration().getConnectorConfigurations().keySet();
if (!connectorNames.isEmpty()) {
String connectorName = connectorNames.iterator().next();
MessagingLogger.ROOT_LOGGER.connectorForPooledConnectionFactory(name, connectorName);
connectors.add(connectorName);
}
}
for (String connector : connectors) {
TransportConfiguration tc = activeMQServer.getValue().getConfiguration().getConnectorConfigurations().get(connector);
if(tc == null) {
throw MessagingLogger.ROOT_LOGGER.connectorNotDefined(connector);
}
if (connectorClassname.length() > 0) {
connectorClassname.append(",");
connectorParams.append(",");
}
connectorClassname.append(tc.getFactoryClassName());
Map<String, Object> params = tc.getParams();
boolean multiple = false;
for (Map.Entry<String, Object> entry : params.entrySet()) {
if (multiple) {
connectorParams.append(";");
}
connectorParams.append(entry.getKey()).append("=").append(entry.getValue());
multiple = true;
}
}
if (connectorClassname.length() > 0) {
properties.add(simpleProperty15(CONNECTOR_CLASSNAME, STRING_TYPE, connectorClassname.toString()));
}
if (connectorParams.length() > 0) {
properties.add(simpleProperty15(CONNECTION_PARAMETERS, STRING_TYPE, connectorParams.toString()));
}
if(discoveryGroupName != null) {
DiscoveryGroupConfiguration discoveryGroupConfiguration = activeMQServer.getValue().getConfiguration().getDiscoveryGroupConfigurations().get(discoveryGroupName);
BroadcastEndpointFactory bgCfg = discoveryGroupConfiguration.getBroadcastEndpointFactory();
if (bgCfg instanceof UDPBroadcastEndpointFactory) {
UDPBroadcastEndpointFactory udpCfg = (UDPBroadcastEndpointFactory) bgCfg;
properties.add(simpleProperty15(GROUP_ADDRESS, STRING_TYPE, udpCfg.getGroupAddress()));
properties.add(simpleProperty15(GROUP_PORT, INTEGER_TYPE, "" + udpCfg.getGroupPort()));
properties.add(simpleProperty15(DISCOVERY_LOCAL_BIND_ADDRESS, STRING_TYPE, "" + udpCfg.getLocalBindAddress()));
} else if (bgCfg instanceof CommandDispatcherBroadcastEndpointFactory) {
properties.add(simpleProperty15(JGROUPS_CHANNEL_NAME, STRING_TYPE, jgroupsChannelName));
properties.add(simpleProperty15(JGROUPS_CHANNEL_REF_NAME, STRING_TYPE, serverName + "/discovery" + discoveryGroupConfiguration.getName()));
}
properties.add(simpleProperty15(DISCOVERY_INITIAL_WAIT_TIMEOUT, LONG_TYPE, "" + discoveryGroupConfiguration.getDiscoveryInitialWaitTimeout()));
properties.add(simpleProperty15(REFRESH_TIMEOUT, LONG_TYPE, "" + discoveryGroupConfiguration.getRefreshTimeout()));
}
boolean hasReconnect = false;
final List<ConfigProperty> inboundProperties = new ArrayList<>();
final List<ConfigProperty> outboundProperties = new ArrayList<>();
final String reconnectName = ConnectionFactoryAttributes.Pooled.RECONNECT_ATTEMPTS_PROP_NAME;
for (PooledConnectionFactoryConfigProperties adapterParam : adapterParams) {
hasReconnect |= reconnectName.equals(adapterParam.getName());
ConfigProperty p = simpleProperty15(adapterParam.getName(), adapterParam.getType(), adapterParam.getValue());
if (adapterParam.getName().equals(REBALANCE_CONNECTIONS_PROP_NAME)) {
boolean rebalanceConnections = Boolean.parseBoolean(adapterParam.getValue());
if (rebalanceConnections) {
inboundProperties.add(p);
}
} else {
if (null == adapterParam.getConfigType()) {
properties.add(p);
} else switch (adapterParam.getConfigType()) {
case INBOUND:
inboundProperties.add(p);
break;
case OUTBOUND:
outboundProperties.add(p);
break;
default:
properties.add(p);
break;
}
}
}
// The default -1, which will hang forever until a server appears
if (!hasReconnect) {
properties.add(simpleProperty15(reconnectName, Integer.class.getName(), DEFAULT_MAX_RECONNECTS));
}
configureCredential(properties);
// for backwards compatibility, the RA inbound is configured to prefix the Jakarta Messaging resources if JNDI lookups fail
// and the destination are inferred from the JNDI name.
inboundProperties.add(simpleProperty15("queuePrefix", String.class.getName(), JMS_QUEUE_PREFIX));
inboundProperties.add(simpleProperty15("topicPrefix", String.class.getName(), JMS_TOPIC_PREFIX));
WildFlyRecoveryRegistry.container = container;
OutboundResourceAdapter outbound = createOutbound(outboundProperties);
InboundResourceAdapter inbound = createInbound(inboundProperties);
ResourceAdapter ra = createResourceAdapter15(properties, outbound, inbound);
Connector cmd = createConnector15(ra);
TransactionSupportEnum transactionSupport = getTransactionSupport(txSupport);
ConnectionDefinition common = createConnDef(transactionSupport, bindInfo.getBindName(), minPoolSize, maxPoolSize, managedConnectionPoolClassName, enlistmentTrace);
Activation activation = createActivation(common, transactionSupport);
ResourceAdapterActivatorService activator = new ResourceAdapterActivatorService(cmd, activation,
PooledConnectionFactoryService.class.getClassLoader(), name);
activator.setBindInfo(bindInfo);
activator.setCreateBinderService(createBinderService);
activator.addJndiAliases(jndiAliases);
final ServiceBuilder sb =
Services.addServerExecutorDependency(
serviceTarget.addService(getResourceAdapterActivatorsServiceName(name), activator),
activator.getExecutorServiceInjector())
.addDependency(ConnectorServices.IRONJACAMAR_MDR, AS7MetadataRepository.class,
activator.getMdrInjector())
.addDependency(ConnectorServices.RA_REPOSITORY_SERVICE, ResourceAdapterRepository.class,
activator.getRaRepositoryInjector())
.addDependency(ConnectorServices.MANAGEMENT_REPOSITORY_SERVICE, ManagementRepository.class,
activator.getManagementRepositoryInjector())
.addDependency(ConnectorServices.RESOURCE_ADAPTER_REGISTRY_SERVICE,
ResourceAdapterDeploymentRegistry.class, activator.getRegistryInjector())
.addDependency(ConnectorServices.TRANSACTION_INTEGRATION_SERVICE, TransactionIntegration.class,
activator.getTxIntegrationInjector())
.addDependency(ConnectorServices.CONNECTOR_CONFIG_SERVICE,
JcaSubsystemConfiguration.class, activator.getConfigInjector())
.addDependency(ConnectorServices.CCM_SERVICE, CachedConnectionManager.class,
activator.getCcmInjector());
sb.requires(ActiveMQActivationService.getServiceName(getActiveMQServiceName(serverName)));
sb.requires(NamingService.SERVICE_NAME);
sb.requires(MessagingServices.getCapabilityServiceName(MessagingServices.LOCAL_TRANSACTION_PROVIDER_CAPABILITY));
sb.requires(ConnectorServices.BOOTSTRAP_CONTEXT_SERVICE.append("default"));
sb.setInitialMode(ServiceController.Mode.PASSIVE).install();
// Mock the deployment service to allow it to start
serviceTarget.addService(ConnectorServices.RESOURCE_ADAPTER_DEPLOYER_SERVICE_PREFIX.append(name), Service.NULL).install();
} finally {
if (is != null)
is.close();
if (isIj != null)
isIj.close();
}
}
/**
* Configure password from a credential-reference (as an alternative to the password attribute)
* and add it to the RA properties.
*/
private void configureCredential(List<ConfigProperty> properties) {
// if a credential-reference has been defined, get the password property from it
if (credentialSourceSupplier.getOptionalValue() != null) {
try {
CredentialSource credentialSource = credentialSourceSupplier.getValue().get();
if (credentialSource != null) {
char[] password = credentialSource.getCredential(PasswordCredential.class).getPassword(ClearPassword.class).getPassword();
if (password != null) {
// add the password property
properties.add(simpleProperty15("password", String.class.getName(), new String(password)));
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
private static TransactionSupportEnum getTransactionSupport(String txSupport) {
try {
return TransactionSupportEnum.valueOf(txSupport);
} catch (RuntimeException e) {
return TransactionSupportEnum.LocalTransaction;
}
}
private static Activation createActivation(ConnectionDefinition common, TransactionSupportEnum transactionSupport) {
List<ConnectionDefinition> definitions = Collections.singletonList(common);
//fix of WFLY-9762 - JMSConnectionFactoryDefinition annotation with the transactional attribute set to false results in TransactionSupportEnum.NoTransaction -> it has to be propagated
boolean ignoreJTA = transactionSupport == TransactionSupportEnum.NoTransaction;
//attribute is propagated only if it means to ignore JTA transaction; in case of not ignoring, default behavior is used
Map<String, String> configProperties = ignoreJTA ? Collections.<String, String>singletonMap(IGNORE_JTA, String.valueOf(ignoreJTA)) : Collections.emptyMap();
return new ActivationImpl(null, null, transactionSupport, definitions, Collections.<AdminObject>emptyList(), configProperties, Collections.<String>emptyList(), null, null);
}
private static ConnectionDefinition createConnDef(TransactionSupportEnum transactionSupport, String jndiName, int minPoolSize, int maxPoolSize, String managedConnectionPoolClassName, Boolean enlistmentTrace) throws ValidateException {
Integer minSize = (minPoolSize == -1) ? null : minPoolSize;
Integer maxSize = (maxPoolSize == -1) ? null : maxPoolSize;
boolean prefill = false;
boolean useStrictMin = false;
FlushStrategy flushStrategy = FlushStrategy.FAILING_CONNECTION_ONLY;
Boolean isXA = Boolean.FALSE;
final Pool pool;
if (transactionSupport == TransactionSupportEnum.XATransaction) {
pool = new XaPoolImpl(minSize, Defaults.INITIAL_POOL_SIZE, maxSize, prefill, useStrictMin, flushStrategy, null, Defaults.FAIR,
Defaults.IS_SAME_RM_OVERRIDE, Defaults.INTERLEAVING, Defaults.PAD_XID, Defaults.WRAP_XA_RESOURCE, Defaults.NO_TX_SEPARATE_POOL);
isXA = Boolean.TRUE;
} else {
pool = new PoolImpl(minSize, Defaults.INITIAL_POOL_SIZE, maxSize, prefill, useStrictMin, flushStrategy, null, Defaults.FAIR);
}
TimeOut timeOut = new TimeOutImpl(null, null, null, null, null) {
};
// <security>
// <application />
// </security>
// => PoolStrategy.POOL_BY_CRI
Security security = new SecurityImpl(null, null, true);
// register the XA Connection *without* recovery. ActiveMQ already takes care of the registration with the correct credentials
// when its ResourceAdapter is started
Recovery recovery = new Recovery(new CredentialImpl(null, null, null, null), null, Boolean.TRUE);
Validation validation = new ValidationImpl(Defaults.VALIDATE_ON_MATCH, null, null, false);
// do no track
return new ConnectionDefinitionImpl(Collections.<String, String>emptyMap(), RAMANAGED_CONN_FACTORY, jndiName, ACTIVEMQ_CONN_DEF, true, true, true, Defaults.SHARABLE, Defaults.ENLISTMENT, Defaults.CONNECTABLE, false, managedConnectionPoolClassName, enlistmentTrace, pool, timeOut, validation, security, recovery, isXA);
}
private static Connector createConnector15(ResourceAdapter ra) {
return new ConnectorImpl(Connector.Version.V_15, null, str("Red Hat"), str("JMS 1.1 Server"), str("1.0"), null, ra, null, false, EMPTY_LOCL, EMPTY_LOCL, Collections.<Icon>emptyList(), null);
}
private ResourceAdapter createResourceAdapter15(List<ConfigProperty> properties, OutboundResourceAdapter outbound, InboundResourceAdapter inbound) {
return new ResourceAdapterImpl(str(ACTIVEMQ_RESOURCE_ADAPTER), properties, outbound, inbound, Collections.<org.jboss.jca.common.api.metadata.spec.AdminObject>emptyList(), Collections.<SecurityPermission>emptyList(), null);
}
private InboundResourceAdapter createInbound(List<ConfigProperty> inboundProps) {
List<RequiredConfigProperty> destination = Collections.<RequiredConfigProperty>singletonList(new RequiredConfigPropertyImpl(EMPTY_LOCL, str("destination"), null));
Activationspec activation15 = new ActivationSpecImpl(str(ACTIVEMQ_ACTIVATION), destination, inboundProps, null);
List<MessageListener> messageListeners = Collections.<MessageListener>singletonList(new MessageListenerImpl(str(JMS_MESSAGE_LISTENER), activation15, null));
Messageadapter message = new MessageAdapterImpl(messageListeners, null);
return new InboundResourceAdapterImpl(message, null);
}
private static OutboundResourceAdapter createOutbound(List<ConfigProperty> outboundProperties) {
List<org.jboss.jca.common.api.metadata.spec.ConnectionDefinition> definitions = new ArrayList();
List<ConfigProperty> props = new ArrayList(outboundProperties);
props.add(simpleProperty15(SESSION_DEFAULT_TYPE, STRING_TYPE, JMS_QUEUE));
props.add(simpleProperty15(TRY_LOCK, INTEGER_TYPE, "0"));
definitions.add(new org.jboss.jca.common.metadata.spec.ConnectionDefinitionImpl(str(RAMANAGED_CONN_FACTORY), props, str(RA_CONN_FACTORY), str(RA_CONN_FACTORY_IMPL), str(JMS_SESSION), str(ACTIVEMQ_RA_SESSION), null));
AuthenticationMechanism basicPassword = new AuthenticationMechanismImpl(Collections.<LocalizedXsdString>emptyList(), str(BASIC_PASS), CredentialInterfaceEnum.PasswordCredential, null, null);
return new OutboundResourceAdapterImpl(definitions, TransactionSupportEnum.XATransaction, Collections.singletonList(basicPassword), false, null, null, null);
}
private static XsdString str(String str) {
return new XsdString(str, null);
}
private static ConfigProperty simpleProperty15(String name, String type, String value) {
return new ConfigPropertyImpl(EMPTY_LOCL, str(name), str(type), str(value), null, null, null, null, false, null, null, null, null);
}
public void stop(StopContext context) {
// Service context takes care of this
}
}
| 36,076
| 59.430486
| 377
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/JMSQueueUpdateJndiHandler.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.jms;
import static org.wildfly.extension.messaging.activemq.jms.JMSQueueService.JMS_QUEUE_PREFIX;
import org.apache.activemq.artemis.jms.server.JMSServerManager;
import org.jboss.as.controller.descriptions.ResourceDescriptionResolver;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
/**
* Handler for "add-jndi" and "remove-jndi" operations on a Jakarta Messaging queue resource.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class JMSQueueUpdateJndiHandler extends AbstractUpdateJndiHandler {
private JMSQueueUpdateJndiHandler(boolean addOperation) {
super(addOperation);
}
@Override
protected void addJndiName(JMSServerManager jmsServerManager, String resourceName, String jndiName) throws Exception {
jmsServerManager.addQueueToBindingRegistry(JMS_QUEUE_PREFIX + resourceName, jndiName);
}
@Override
protected void removeJndiName(JMSServerManager jmsServerManager, String resourceName, String jndiName) throws Exception {
jmsServerManager.removeQueueFromBindingRegistry(JMS_QUEUE_PREFIX + resourceName, jndiName);
}
static void registerOperations(ManagementResourceRegistration registry, ResourceDescriptionResolver resolver) {
JMSQueueUpdateJndiHandler add = new JMSQueueUpdateJndiHandler(true);
add.registerOperation(registry, resolver);
JMSQueueUpdateJndiHandler remove = new JMSQueueUpdateJndiHandler(false);
remove.registerOperation(registry, resolver);
}
}
| 2,586
| 42.116667
| 125
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/JMSTopicService.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.jms;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionException;
import jakarta.jms.Topic;
import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
import org.apache.activemq.artemis.jms.server.JMSServerManager;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceTarget;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;
import org.jboss.msc.value.InjectedValue;
import org.wildfly.extension.messaging.activemq.ActiveMQActivationService;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* Service responsible for creating and destroying a {@code jakarta.jms.Topic}.
*
* @author Emanuel Muckenhuber
*/
public class JMSTopicService implements Service<Topic> {
static final String JMS_TOPIC_PREFIX = "jms.topic.";
private final InjectedValue<JMSServerManager> jmsServer = new InjectedValue<JMSServerManager>();
private final InjectedValue<ExecutorService> executorInjector = new InjectedValue<ExecutorService>();
private final String name;
private Topic topic;
public JMSTopicService(String name) {
if (name.startsWith(JMS_TOPIC_PREFIX)) {
this.name = name.substring(JMS_TOPIC_PREFIX.length());
} else {
this.name = name;
}
}
@Override
public synchronized void start(final StartContext context) throws StartException {
final JMSServerManager jmsManager = jmsServer.getValue();
final Runnable task = new Runnable() {
@Override
public void run() {
try {
// add back the jms.topic. prefix to be consistent with ActiveMQ Artemis 1.x addressing scheme
jmsManager.createTopic(JMS_TOPIC_PREFIX + name, false, name);
topic = ActiveMQDestination.createTopic(JMS_TOPIC_PREFIX + name, name);
context.complete();
} catch (Throwable e) {
context.failed(MessagingLogger.ROOT_LOGGER.failedToCreate(e, "JMS Topic"));
}
}
};
try {
executorInjector.getValue().execute(task);
} catch (RejectedExecutionException e) {
task.run();
} finally {
context.asynchronous();
}
}
@Override
public synchronized void stop(final StopContext context) {
}
@Override
public Topic getValue() throws IllegalStateException {
return topic;
}
public static JMSTopicService installService(final String name, final ServiceName serverServiceName, final ServiceTarget serviceTarget) {
final JMSTopicService service = new JMSTopicService(name);
final ServiceName serviceName = JMSServices.getJmsTopicBaseServiceName(serverServiceName).append(name);
final ServiceBuilder<Topic> serviceBuilder = serviceTarget.addService(serviceName, service);
serviceBuilder.requires(ActiveMQActivationService.getServiceName(serverServiceName));
serviceBuilder.addDependency(JMSServices.getJmsManagerBaseServiceName(serverServiceName), JMSServerManager.class, service.jmsServer);
serviceBuilder.setInitialMode(ServiceController.Mode.PASSIVE);
org.jboss.as.server.Services.addServerExecutorDependency(serviceBuilder, service.executorInjector);
serviceBuilder.install();
return service;
}
}
| 4,705
| 40.280702
| 141
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/JMSTopicDefinition.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.jms;
import static org.jboss.as.controller.SimpleAttributeDefinitionBuilder.create;
import static org.jboss.as.controller.registry.AttributeAccess.Flag.GAUGE_METRIC;
import static org.jboss.dmr.ModelType.INT;
import static org.jboss.dmr.ModelType.STRING;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
import org.jboss.as.controller.StringListAttributeDefinition;
import org.jboss.as.controller.access.management.AccessConstraintDefinition;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.dmr.ModelNode;
import org.wildfly.extension.messaging.activemq.CommonAttributes;
import org.wildfly.extension.messaging.activemq.MessagingExtension;
/**
* Jakarta Messaging Topic resource definition
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat Inc.
*/
public class JMSTopicDefinition extends PersistentResourceDefinition {
public static final AttributeDefinition[] ATTRIBUTES = {
CommonAttributes.DESTINATION_ENTRIES,
CommonAttributes.LEGACY_ENTRIES
};
/**
* Attributes for deployed Jakarta Messaging topic are stored in runtime
*/
private static AttributeDefinition[] DEPLOYMENT_ATTRIBUTES = {
new StringListAttributeDefinition.Builder(CommonAttributes.DESTINATION_ENTRIES)
.setStorageRuntime()
.build(),
new StringListAttributeDefinition.Builder(CommonAttributes.LEGACY_ENTRIES)
.setStorageRuntime()
.build()
};
static final AttributeDefinition TOPIC_ADDRESS = create(CommonAttributes.TOPIC_ADDRESS, STRING)
.setStorageRuntime()
.build();
static final AttributeDefinition[] READONLY_ATTRIBUTES = { TOPIC_ADDRESS,
CommonAttributes.TEMPORARY, CommonAttributes.PAUSED };
static final AttributeDefinition DURABLE_MESSAGE_COUNT = create(CommonAttributes.DURABLE_MESSAGE_COUNT, INT)
.setStorageRuntime()
.setUndefinedMetricValue(ModelNode.ZERO)
.addFlag(GAUGE_METRIC)
.build();
static final AttributeDefinition NON_DURABLE_MESSAGE_COUNT = create(CommonAttributes.NON_DURABLE_MESSAGE_COUNT, INT)
.setStorageRuntime()
.setUndefinedMetricValue(ModelNode.ZERO)
.addFlag(GAUGE_METRIC)
.build();
static final AttributeDefinition SUBSCRIPTION_COUNT = create(CommonAttributes.SUBSCRIPTION_COUNT, INT)
.setStorageRuntime()
.setUndefinedMetricValue(ModelNode.ZERO)
.addFlag(GAUGE_METRIC)
.build();
static final AttributeDefinition DURABLE_SUBSCRIPTION_COUNT = create(CommonAttributes.DURABLE_SUBSCRIPTION_COUNT, INT)
.setStorageRuntime()
.setUndefinedMetricValue(ModelNode.ZERO)
.addFlag(GAUGE_METRIC)
.build();
static final AttributeDefinition NON_DURABLE_SUBSCRIPTION_COUNT = create(CommonAttributes.NON_DURABLE_SUBSCRIPTION_COUNT, INT)
.setStorageRuntime()
.setUndefinedMetricValue(ModelNode.ZERO)
.addFlag(GAUGE_METRIC)
.build();
static final AttributeDefinition[] METRICS = { CommonAttributes.DELIVERING_COUNT,
CommonAttributes.MESSAGES_ADDED,
CommonAttributes.MESSAGE_COUNT,
DURABLE_MESSAGE_COUNT,
NON_DURABLE_MESSAGE_COUNT,
SUBSCRIPTION_COUNT,
DURABLE_SUBSCRIPTION_COUNT,
NON_DURABLE_SUBSCRIPTION_COUNT
};
private final boolean deployed;
private final boolean registerRuntimeOnly;
public JMSTopicDefinition(final boolean deployed,
final boolean registerRuntimeOnly) {
super(MessagingExtension.JMS_TOPIC_PATH,
MessagingExtension.getResourceDescriptionResolver(CommonAttributes.JMS_TOPIC),
deployed ? null : JMSTopicAdd.INSTANCE,
deployed ? null : JMSTopicRemove.INSTANCE);
this.deployed = deployed;
this.registerRuntimeOnly = registerRuntimeOnly;
}
@Override
public Collection<AttributeDefinition> getAttributes() {
if (deployed) {
return Arrays.asList(DEPLOYMENT_ATTRIBUTES);
} else {
return Arrays.asList(ATTRIBUTES);
}
}
@Override
public void registerAttributes(ManagementResourceRegistration registry) {
ReloadRequiredWriteAttributeHandler handler = new ReloadRequiredWriteAttributeHandler(getAttributes());
for (AttributeDefinition attr : getAttributes()) {
if (deployed) {
registry.registerReadOnlyAttribute(attr, JMSTopicConfigurationRuntimeHandler.INSTANCE);
} else {
if (attr == CommonAttributes.DESTINATION_ENTRIES ||
attr == CommonAttributes.LEGACY_ENTRIES) {
registry.registerReadWriteAttribute(attr, null, handler);
} else {
registry.registerReadOnlyAttribute(attr, null);
}
}
}
for (AttributeDefinition attr : READONLY_ATTRIBUTES) {
registry.registerReadOnlyAttribute(attr, JMSTopicReadAttributeHandler.INSTANCE);
}
for (AttributeDefinition metric : METRICS) {
registry.registerMetric(metric, JMSTopicReadAttributeHandler.INSTANCE);
}
}
@Override
public void registerOperations(ManagementResourceRegistration registry) {
super.registerOperations(registry);
if (registerRuntimeOnly) {
JMSTopicControlHandler.INSTANCE.registerOperations(registry, getResourceDescriptionResolver());
if (!deployed) {
JMSTopicUpdateJndiHandler.registerOperations(registry, getResourceDescriptionResolver());
}
}
}
@Override
public List<AccessConstraintDefinition> getAccessConstraints() {
return Arrays.asList(MessagingExtension.JMS_TOPIC_ACCESS_CONSTRAINT);
}
}
| 7,317
| 39.430939
| 130
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/ExternalConnectionFactoryDefinition.java
|
/*
* Copyright 2018 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.extension.messaging.activemq.jms;
import static org.wildfly.extension.messaging.activemq.AbstractTransportDefinition.CONNECTOR_CAPABILITY_NAME;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Common.DESERIALIZATION_ALLOWLIST;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Common.DESERIALIZATION_BLACKLIST;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Common.DESERIALIZATION_BLOCKLIST;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Common.DESERIALIZATION_WHITELIST;
import java.util.Arrays;
import java.util.Collection;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.StringListAttributeDefinition;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.wildfly.extension.messaging.activemq.AbstractTransportDefinition;
import org.wildfly.extension.messaging.activemq.CommonAttributes;
import org.wildfly.extension.messaging.activemq.MessagingExtension;
import org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Common;
import org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.External;
import org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Regular;
/**
* Jakarta Messaging Connection Factory resource definition without a broker.
*
* @author Emmanuel Hugonnet (c) 2018 Red Hat, inc.
*/
public class ExternalConnectionFactoryDefinition extends PersistentResourceDefinition {
private static StringListAttributeDefinition CONNECTORS = new StringListAttributeDefinition.Builder(Common.CONNECTORS)
.setCapabilityReference(new AbstractTransportDefinition.TransportCapabilityReferenceRecorder("org.wildfly.messaging.activemq.external.connection-factory", CONNECTOR_CAPABILITY_NAME, true))
.build();
static final RuntimeCapability<Void> CAPABILITY = RuntimeCapability.Builder.of("org.wildfly.messaging.activemq.external.connection-factory", true, ExternalConnectionFactoryService.class).
build();
public static final AttributeDefinition[] ATTRIBUTES = new AttributeDefinition[]{
CommonAttributes.HA, Regular.FACTORY_TYPE, Common.DISCOVERY_GROUP, CONNECTORS, Common.ENTRIES, External.ENABLE_AMQ1_PREFIX,
Common.CLIENT_FAILURE_CHECK_PERIOD,
Common.CONNECTION_TTL,
CommonAttributes.CALL_TIMEOUT,
CommonAttributes.CALL_FAILOVER_TIMEOUT,
Common.CONSUMER_WINDOW_SIZE,
Common.CONSUMER_MAX_RATE,
Common.CONFIRMATION_WINDOW_SIZE,
Common.PRODUCER_WINDOW_SIZE,
Common.PRODUCER_MAX_RATE,
Common.PROTOCOL_MANAGER_FACTORY,
Common.COMPRESS_LARGE_MESSAGES,
Common.CACHE_LARGE_MESSAGE_CLIENT,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CLIENT_ID,
Common.DUPS_OK_BATCH_SIZE,
Common.TRANSACTION_BATCH_SIZE,
Common.BLOCK_ON_ACKNOWLEDGE,
Common.BLOCK_ON_NON_DURABLE_SEND,
Common.BLOCK_ON_DURABLE_SEND,
Common.AUTO_GROUP,
Common.PRE_ACKNOWLEDGE,
Common.RETRY_INTERVAL,
Common.RETRY_INTERVAL_MULTIPLIER,
CommonAttributes.MAX_RETRY_INTERVAL,
Common.RECONNECT_ATTEMPTS,
Common.FAILOVER_ON_INITIAL_CONNECTION,
Common.CONNECTION_LOAD_BALANCING_CLASS_NAME,
Common.USE_GLOBAL_POOLS,
Common.SCHEDULED_THREAD_POOL_MAX_SIZE,
Common.THREAD_POOL_MAX_SIZE,
Common.GROUP_ID,
Common.DESERIALIZATION_BLOCKLIST,
Common.DESERIALIZATION_ALLOWLIST,
Common.INITIAL_MESSAGE_PACKET_SIZE,
Common.USE_TOPOLOGY};
private final boolean registerRuntimeOnly;
public ExternalConnectionFactoryDefinition(final boolean registerRuntimeOnly) {
super(new SimpleResourceDefinition.Parameters(MessagingExtension.CONNECTION_FACTORY_PATH, MessagingExtension.getResourceDescriptionResolver(CommonAttributes.CONNECTION_FACTORY))
.setCapabilities(CAPABILITY)
.setAddHandler(ExternalConnectionFactoryAdd.INSTANCE)
.setRemoveHandler(ExternalConnectionFactoryRemove.INSTANCE));
this.registerRuntimeOnly = registerRuntimeOnly;
}
@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(ATTRIBUTES);
}
@Override
public void registerOperations(ManagementResourceRegistration registry) {
super.registerOperations(registry);
if (registerRuntimeOnly) {
ConnectionFactoryUpdateJndiHandler.registerOperations(registry, getResourceDescriptionResolver());
}
}
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
super.registerAttributes(resourceRegistration);
ConnectionFactoryAttributes.registerAliasAttribute(resourceRegistration, false, DESERIALIZATION_WHITELIST, DESERIALIZATION_ALLOWLIST.getName());
ConnectionFactoryAttributes.registerAliasAttribute(resourceRegistration, false, DESERIALIZATION_BLACKLIST, DESERIALIZATION_BLOCKLIST.getName());
}
}
| 5,984
| 48.46281
| 200
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/ExternalPooledConnectionFactoryAdd.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.jms;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.JGROUPS_CLUSTER;
import static org.wildfly.extension.messaging.activemq.MessagingServices.isSubsystemResource;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttribute.getDefinitions;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Common.DESERIALIZATION_ALLOWLIST;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Common.DESERIALIZATION_BLACKLIST;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Common.DESERIALIZATION_BLOCKLIST;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Common.DESERIALIZATION_WHITELIST;
import static org.wildfly.extension.messaging.activemq.jms.PooledConnectionFactoryAdd.getTxSupport;
import static org.wildfly.extension.messaging.activemq.jms.PooledConnectionFactoryAdd.installStatistics;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
import org.apache.activemq.artemis.api.core.TransportConfiguration;
import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.registry.Resource;
import org.jboss.as.naming.deployment.ContextNames;
import org.jboss.as.naming.deployment.ContextNames.BindInfo;
import org.jboss.dmr.ModelNode;
import org.wildfly.extension.messaging.activemq.CommonAttributes;
import org.wildfly.extension.messaging.activemq.DiscoveryGroupDefinition;
import org.wildfly.extension.messaging.activemq.MessagingServices;
import org.wildfly.extension.messaging.activemq.TransportConfigOperationHandlers;
import org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Common;
/**
* Operation Handler to add a Jakarta Messaging external pooled Connection Factory.
* @author Emmanuel Hugonnet (c) 2018 Red Hat, inc.
*/
public class ExternalPooledConnectionFactoryAdd extends AbstractAddStepHandler {
public static final ExternalPooledConnectionFactoryAdd INSTANCE = new ExternalPooledConnectionFactoryAdd();
private ExternalPooledConnectionFactoryAdd() {
super(getDefinitions(ExternalPooledConnectionFactoryDefinition.ATTRIBUTES));
}
@Override
protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
ModelNode model = resource.getModel();
PathAddress address = context.getCurrentAddress();
final String name = context.getCurrentAddressValue();
final ModelNode resolvedModel = model.clone();
for(final AttributeDefinition attribute : attributes) {
resolvedModel.get(attribute.getName()).set(attribute.resolveModelAttribute(context, resolvedModel ));
}
// We validated that jndiName part of the model in populateModel
final List<String> jndiNames = new ArrayList<>();
for (ModelNode node : resolvedModel.get(Common.ENTRIES.getName()).asList()) {
jndiNames.add(node.asString());
}
final BindInfo bindInfo = ContextNames.bindInfoFor(jndiNames.get(0));
List<String> jndiAliases;
if(jndiNames.size() > 1) {
jndiAliases = new ArrayList<>(jndiNames.subList(1, jndiNames.size()));
} else {
jndiAliases = Collections.emptyList();
}
String managedConnectionPoolClassName = resolvedModel.get(ConnectionFactoryAttributes.Pooled.MANAGED_CONNECTION_POOL.getName()).asStringOrNull();
final int minPoolSize = resolvedModel.get(ConnectionFactoryAttributes.Pooled.MIN_POOL_SIZE.getName()).asInt();
final int maxPoolSize = resolvedModel.get(ConnectionFactoryAttributes.Pooled.MAX_POOL_SIZE.getName()).asInt();
Boolean enlistmentTrace = resolvedModel.get(ConnectionFactoryAttributes.Pooled.ENLISTMENT_TRACE.getName()).asBooleanOrNull();
String txSupport = getTxSupport(resolvedModel);
List<String> connectors = Common.CONNECTORS.unwrap(context, model);
String discoveryGroupName = getDiscoveryGroup(resolvedModel);
String jgroupClusterName = null;
String jgroupsChannelName = null;
final PathAddress serverAddress = MessagingServices.getActiveMQServerPathAddress(address);
if (discoveryGroupName != null) {
Resource dgResource;
if(isSubsystemResource(context)) {
PathAddress dgAddress = address.getParent().append(CommonAttributes.SOCKET_DISCOVERY_GROUP, discoveryGroupName);
try {
dgResource = context.readResourceFromRoot(dgAddress, false);
} catch(Resource.NoSuchResourceException ex) {
dgAddress = address.getParent().append(CommonAttributes.JGROUPS_DISCOVERY_GROUP, discoveryGroupName);
dgResource = context.readResourceFromRoot(dgAddress, false);
}
} else {
PathAddress dgAddress = serverAddress.append(CommonAttributes.SOCKET_DISCOVERY_GROUP, discoveryGroupName);
try {
dgResource = context.readResourceFromRoot(dgAddress, false);
} catch(Resource.NoSuchResourceException ex) {
dgAddress = address.getParent().append(CommonAttributes.JGROUPS_DISCOVERY_GROUP, discoveryGroupName);
dgResource = context.readResourceFromRoot(dgAddress, false);
}
}
ModelNode dgModel = dgResource.getModel();
ModelNode jgroupCluster = JGROUPS_CLUSTER.resolveModelAttribute(context, dgModel);
if(jgroupCluster.isDefined()) {
jgroupClusterName = jgroupCluster.asString();
ModelNode channel = DiscoveryGroupDefinition.JGROUPS_CHANNEL.resolveModelAttribute(context, dgModel);
if(channel.isDefined()) {
jgroupsChannelName = channel.asString();
}
}
}
List<PooledConnectionFactoryConfigProperties> adapterParams = PooledConnectionFactoryAdd.getAdapterParams(resolvedModel, context, ExternalPooledConnectionFactoryDefinition.ATTRIBUTES);
DiscoveryGroupConfiguration discoveryGroupConfiguration = null;
if (discoveryGroupName != null) {
discoveryGroupConfiguration = ExternalConnectionFactoryAdd.getDiscoveryGroup(context, discoveryGroupName);
}
Set<String> connectorsSocketBindings = new HashSet<>();
final Set<String> sslContextNames = new HashSet<>();
TransportConfiguration[] transportConfigurations = TransportConfigOperationHandlers.processConnectors(context, connectors, connectorsSocketBindings, sslContextNames);
ExternalPooledConnectionFactoryService.installService(context, name, transportConfigurations, discoveryGroupConfiguration, connectorsSocketBindings, sslContextNames,
jgroupClusterName, jgroupsChannelName, adapterParams, bindInfo, jndiAliases, txSupport, minPoolSize, maxPoolSize, managedConnectionPoolClassName, enlistmentTrace, model);
boolean statsEnabled = ConnectionFactoryAttributes.Pooled.STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean();
if (statsEnabled) {
// Add the stats resource. This is kind of a hack as we are modifying the resource
// in runtime, but oh well. We don't use readResourceForUpdate for this reason.
// This only runs in this add op anyway, and because it's an add we know readResource
// is going to be returning the current write snapshot of the model, i.e. the one we want
PooledConnectionFactoryStatisticsService.registerStatisticsResources(resource);
installStatistics(context, name);
}
}
static String getDiscoveryGroup(final ModelNode model) {
if(model.hasDefined(Common.DISCOVERY_GROUP.getName())) {
return model.get(Common.DISCOVERY_GROUP.getName()).asString();
}
return null;
}
@Override
protected void populateModel(final ModelNode operation, final ModelNode model) throws OperationFailedException {
for (AttributeDefinition attr : attributes) {
if (DESERIALIZATION_BLACKLIST.equals(attr)) {
if (operation.hasDefined(DESERIALIZATION_BLACKLIST.getName())) {
DESERIALIZATION_BLOCKLIST.validateAndSet(operation, model);
}
} else if (DESERIALIZATION_WHITELIST.equals(attr)) {
if (operation.hasDefined(DESERIALIZATION_WHITELIST.getName())) {
DESERIALIZATION_ALLOWLIST.validateAndSet(operation, model);
}
} else {
attr.validateAndSet(operation, model);
}
}
}
}
| 10,211
| 54.803279
| 192
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/ExternalConnectionFactoryRemove.java
|
/*
* Copyright 2018 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.extension.messaging.activemq.jms;
import org.jboss.as.controller.AbstractRemoveStepHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.dmr.ModelNode;
import org.wildfly.extension.messaging.activemq.MessagingServices;
/**
* Update handler removing a connection factory from the Jakarta Messaging subsystem. The
* runtime action will remove the corresponding {@link ConnectionFactoryService}.
*
* @author Emanuel Muckenhuber
* @author <a href="mailto:andy.taylor@jboss.com">Andy Taylor</a>
*/
public class ExternalConnectionFactoryRemove extends AbstractRemoveStepHandler {
public static final ExternalConnectionFactoryRemove INSTANCE = new ExternalConnectionFactoryRemove();
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final String name = context.getCurrentAddressValue();
context.removeService(MessagingServices.getActiveMQServiceName(name));
}
@Override
protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
ConnectionFactoryAdd.INSTANCE.performRuntime(context, operation, model);
}
}
| 1,916
| 40.673913
| 132
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/ExternalJMSQueueDefinition.java
|
/*
* Copyright 2018 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.extension.messaging.activemq.jms;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
import org.jboss.as.controller.access.management.AccessConstraintDefinition;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.wildfly.extension.messaging.activemq.CommonAttributes;
import org.wildfly.extension.messaging.activemq.MessagingExtension;
import org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.External;
/**
* Jakarta Messaging Queue resource definition
* @author Emmanuel Hugonnet (c) 2018 Red Hat, inc.
*/
public class ExternalJMSQueueDefinition extends PersistentResourceDefinition {
public static final AttributeDefinition[] ATTRIBUTES = {CommonAttributes.DESTINATION_ENTRIES, External.ENABLE_AMQ1_PREFIX};
private final boolean registerRuntimeOnly;
public ExternalJMSQueueDefinition(boolean registerRuntimeOnly) {
super(MessagingExtension.EXTERNAL_JMS_QUEUE_PATH,
MessagingExtension.getResourceDescriptionResolver(CommonAttributes.EXTERNAL_JMS_QUEUE),
ExternalJMSQueueAdd.INSTANCE,
ExternalJMSQueueRemove.INSTANCE);
this.registerRuntimeOnly = registerRuntimeOnly;
}
@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(CommonAttributes.DESTINATION_ENTRIES, External.ENABLE_AMQ1_PREFIX);
}
@Override
public void registerAttributes(ManagementResourceRegistration registry) {
if (registerRuntimeOnly) {
registry.registerReadOnlyAttribute(CommonAttributes.DESTINATION_ENTRIES, null);
// Should this be read only as entries ?
registry.registerReadOnlyAttribute(External.ENABLE_AMQ1_PREFIX, null);
} else {
registry.registerReadWriteAttribute(CommonAttributes.DESTINATION_ENTRIES, null, new ReloadRequiredWriteAttributeHandler(CommonAttributes.DESTINATION_ENTRIES));
registry.registerReadWriteAttribute(External.ENABLE_AMQ1_PREFIX, null, new ReloadRequiredWriteAttributeHandler(External.ENABLE_AMQ1_PREFIX));
}
}
@Override
public List<AccessConstraintDefinition> getAccessConstraints() {
return Collections.singletonList(MessagingExtension.JMS_QUEUE_ACCESS_CONSTRAINT);
}
}
| 3,144
| 43.295775
| 171
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/ExternalPooledConnectionFactoryRemove.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.jms;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Common.ENTRIES;
import org.jboss.as.controller.OperationContext;
import org.wildfly.extension.messaging.activemq.MessagingServices;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceName;
/**
* Operation Handler to remove a Jakarta Messaging external pooled Connection Factory.
* @author Emmanuel Hugonnet (c) 2018 Red Hat, inc.
*/
public class ExternalPooledConnectionFactoryRemove extends PooledConnectionFactoryRemove {
public static final ExternalPooledConnectionFactoryRemove INSTANCE = new ExternalPooledConnectionFactoryRemove();
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) {
ServiceName serviceName = MessagingServices.getActiveMQServiceName();
context.removeService(JMSServices.getPooledConnectionFactoryBaseServiceName(serviceName).append(context.getCurrentAddressValue()));
removeJNDIAliases(context, model.require(ENTRIES.getName()).asList());
}
@Override
protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) {
// TODO: RE-ADD SERVICES
}
}
| 2,307
| 43.384615
| 139
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/ConnectionFactoryAttributes.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.jms;
import static org.jboss.as.controller.SimpleAttributeDefinitionBuilder.create;
import static org.jboss.as.controller.client.helpers.MeasurementUnit.BYTES;
import static org.jboss.as.controller.client.helpers.MeasurementUnit.MILLISECONDS;
import static org.jboss.as.controller.client.helpers.MeasurementUnit.PER_SECOND;
import static org.jboss.dmr.ModelType.BOOLEAN;
import static org.jboss.dmr.ModelType.DOUBLE;
import static org.jboss.dmr.ModelType.INT;
import static org.jboss.dmr.ModelType.LONG;
import static org.jboss.dmr.ModelType.STRING;
import static org.wildfly.extension.messaging.activemq.AbstractTransportDefinition.CONNECTOR_CAPABILITY_NAME;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.MESSAGING_SECURITY_SENSITIVE_TARGET;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttribute.ConfigType.INBOUND;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttribute.ConfigType.OUTBOUND;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttribute.create;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryDefinition.CAPABILITY_NAME;
import java.util.Arrays;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
import org.apache.activemq.artemis.api.core.client.loadbalance.RoundRobinConnectionLoadBalancingPolicy;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.AttributeMarshaller;
import org.jboss.as.controller.AttributeParser;
import org.jboss.as.controller.ModelVersion;
import org.jboss.as.controller.ObjectTypeAttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.ParameterCorrector;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.StringListAttributeDefinition;
import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.operations.validation.StringAllowedValuesValidator;
import org.jboss.as.controller.operations.validation.StringLengthValidator;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.security.CredentialReference;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
import org.wildfly.extension.messaging.activemq.AbstractTransportDefinition;
import org.wildfly.extension.messaging.activemq.CommonAttributes;
import org.wildfly.extension.messaging.activemq.InfiniteOrPositiveValidators;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
public interface ConnectionFactoryAttributes {
interface Common {
/**
* @see ActiveMQClient.DEFAULT_AUTO_GROUP
*/
AttributeDefinition AUTO_GROUP = SimpleAttributeDefinitionBuilder.create("auto-group", BOOLEAN)
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_BLOCK_ON_ACKNOWLEDGE
*/
AttributeDefinition BLOCK_ON_ACKNOWLEDGE = SimpleAttributeDefinitionBuilder.create("block-on-acknowledge", BOOLEAN)
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_BLOCK_ON_DURABLE_SEND
*/
AttributeDefinition BLOCK_ON_DURABLE_SEND = SimpleAttributeDefinitionBuilder.create("block-on-durable-send", BOOLEAN)
.setDefaultValue(ModelNode.TRUE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_BLOCK_ON_NON_DURABLE_SEND
*/
AttributeDefinition BLOCK_ON_NON_DURABLE_SEND = SimpleAttributeDefinitionBuilder.create("block-on-non-durable-send", BOOLEAN)
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_CACHE_LARGE_MESSAGE_CLIENT
*/
AttributeDefinition CACHE_LARGE_MESSAGE_CLIENT = SimpleAttributeDefinitionBuilder.create("cache-large-message-client", BOOLEAN)
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD
*/
AttributeDefinition CLIENT_FAILURE_CHECK_PERIOD =SimpleAttributeDefinitionBuilder.create("client-failure-check-period", LONG)
.setDefaultValue(new ModelNode(30000L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.setValidator(InfiniteOrPositiveValidators.LONG_INSTANCE)
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_COMPRESS_LARGE_MESSAGES
*/
AttributeDefinition COMPRESS_LARGE_MESSAGES = SimpleAttributeDefinitionBuilder.create("compress-large-messages", BOOLEAN)
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE
*/
AttributeDefinition CONFIRMATION_WINDOW_SIZE = SimpleAttributeDefinitionBuilder.create("confirmation-window-size", INT)
.setDefaultValue(new ModelNode(-1))
.setMeasurementUnit(BYTES)
.setRequired(false)
.setAllowExpression(true)
.setCorrector(InfiniteOrPositiveValidators.NEGATIVE_VALUE_CORRECTOR)
.setValidator(InfiniteOrPositiveValidators.INT_INSTANCE)
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME
*/
AttributeDefinition CONNECTION_LOAD_BALANCING_CLASS_NAME = SimpleAttributeDefinitionBuilder.create("connection-load-balancing-policy-class-name", STRING)
.setDefaultValue(new ModelNode(RoundRobinConnectionLoadBalancingPolicy.class.getCanonicalName()))
.setRequired(false)
.setAllowExpression(false)
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_CONNECTION_TTL
*/
AttributeDefinition CONNECTION_TTL = new SimpleAttributeDefinitionBuilder("connection-ttl", LONG)
.setDefaultValue(new ModelNode(60000L))
.setRequired(false)
.setAllowExpression(true)
.setValidator(InfiniteOrPositiveValidators.LONG_INSTANCE)
.setMeasurementUnit(MILLISECONDS)
.setRestartAllServices()
.build();
StringListAttributeDefinition CONNECTORS = new StringListAttributeDefinition.Builder(CommonAttributes.CONNECTORS)
.setAlternatives(CommonAttributes.DISCOVERY_GROUP)
.setRequired(true)
.setAttributeParser(AttributeParser.STRING_LIST)
.setAttributeMarshaller(AttributeMarshaller.STRING_LIST)
.setCapabilityReference(new AbstractTransportDefinition.TransportCapabilityReferenceRecorder(CAPABILITY_NAME, CONNECTOR_CAPABILITY_NAME, false))
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_CONSUMER_MAX_RATE
*/
AttributeDefinition CONSUMER_MAX_RATE = SimpleAttributeDefinitionBuilder.create("consumer-max-rate", INT)
.setDefaultValue(new ModelNode(-1))
.setMeasurementUnit(PER_SECOND)
.setRequired(false)
.setAllowExpression(true)
.setCorrector(InfiniteOrPositiveValidators.NEGATIVE_VALUE_CORRECTOR)
.setValidator(InfiniteOrPositiveValidators.INT_INSTANCE)
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_CONSUMER_WINDOW_SIZE
*/
AttributeDefinition CONSUMER_WINDOW_SIZE = SimpleAttributeDefinitionBuilder.create("consumer-window-size", INT)
.setDefaultValue(new ModelNode(1024 * 1024))
.setMeasurementUnit(BYTES)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
StringListAttributeDefinition DESERIALIZATION_WHITELIST = new StringListAttributeDefinition.Builder("deserialization-white-list")
.setRequired(false)
.setAllowExpression(true)
.setListValidator(Validators.noDuplicateElements(new StringLengthValidator(1, true, true)))
.setAttributeParser(AttributeParser.STRING_LIST)
.setAttributeMarshaller(AttributeMarshaller.STRING_LIST)
.setDeprecated(ModelVersion.create(13, 0, 0), false)
.setAlternatives("deserialization-allow-list")
.setRestartAllServices()
.build();
StringListAttributeDefinition DESERIALIZATION_ALLOWLIST = new StringListAttributeDefinition.Builder("deserialization-allow-list")
.setRequired(false)
.setAllowExpression(true)
.setListValidator(Validators.noDuplicateElements(new StringLengthValidator(1, true, true)))
.setAttributeParser(AttributeParser.STRING_LIST)
.setAttributeMarshaller(AttributeMarshaller.STRING_LIST)
.setRestartAllServices()
.build();
StringListAttributeDefinition DESERIALIZATION_BLACKLIST = new StringListAttributeDefinition.Builder("deserialization-black-list")
.setRequired(false)
.setAllowExpression(true)
.setListValidator(Validators.noDuplicateElements(new StringLengthValidator(1, true, true)))
.setAttributeParser(AttributeParser.STRING_LIST)
.setAttributeMarshaller(AttributeMarshaller.STRING_LIST)
.setDeprecated(ModelVersion.create(13, 0, 0), false)
.setAlternatives("deserialization-block-list")
.setRestartAllServices()
.build();
StringListAttributeDefinition DESERIALIZATION_BLOCKLIST = new StringListAttributeDefinition.Builder("deserialization-block-list")
.setRequired(false)
.setAllowExpression(true)
.setListValidator(Validators.noDuplicateElements(new StringLengthValidator(1, true, true)))
.setAttributeParser(AttributeParser.STRING_LIST)
.setAttributeMarshaller(AttributeMarshaller.STRING_LIST)
.setRestartAllServices()
.build();
SimpleAttributeDefinition DISCOVERY_GROUP = SimpleAttributeDefinitionBuilder.create(CommonAttributes.DISCOVERY_GROUP, STRING)
.setRequired(true)
.setAlternatives(CommonAttributes.CONNECTORS)
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_ACK_BATCH_SIZE
*/
AttributeDefinition DUPS_OK_BATCH_SIZE = SimpleAttributeDefinitionBuilder.create("dups-ok-batch-size", INT)
.setDefaultValue(new ModelNode(1024 * 1024))
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
StringListAttributeDefinition ENTRIES = new StringListAttributeDefinition.Builder(CommonAttributes.ENTRIES)
.setRequired(true)
.setAllowExpression(true)
.setListValidator(Validators.noDuplicateElements(new StringLengthValidator(1, false, true)))
.setAttributeParser(AttributeParser.STRING_LIST)
.setAttributeMarshaller(AttributeMarshaller.STRING_LIST)
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_FAILOVER_ON_INITIAL_CONNECTION
*/
AttributeDefinition FAILOVER_ON_INITIAL_CONNECTION = SimpleAttributeDefinitionBuilder.create("failover-on-initial-connection", BOOLEAN)
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
AttributeDefinition GROUP_ID = SimpleAttributeDefinitionBuilder.create("group-id", STRING)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
AttributeDefinition INITIAL_MESSAGE_PACKET_SIZE = create("initial-message-packet-size", INT)
.setAllowExpression(true)
.setRestartAllServices()
.setRequired(false)
.setDefaultValue(new ModelNode(1500))
.setMeasurementUnit(BYTES)
.build();
/**
* @see ActiveMQClient.DEFAULT_MAX_RETRY_INTERVAL
*/
AttributeDefinition MAX_RETRY_INTERVAL = SimpleAttributeDefinitionBuilder.create("max-retry-interval", LONG)
.setDefaultValue(new ModelNode(2000L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE
*/
AttributeDefinition MIN_LARGE_MESSAGE_SIZE = SimpleAttributeDefinitionBuilder.create("min-large-message-size", INT)
.setDefaultValue(new ModelNode().set(100 * 1024))
.setMeasurementUnit(BYTES)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_PRE_ACKNOWLEDGE
*/
AttributeDefinition PRE_ACKNOWLEDGE = SimpleAttributeDefinitionBuilder.create("pre-acknowledge", BOOLEAN)
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_PRODUCER_MAX_RATE
*/
AttributeDefinition PRODUCER_MAX_RATE = SimpleAttributeDefinitionBuilder.create("producer-max-rate", INT)
.setDefaultValue(new ModelNode(-1))
.setMeasurementUnit(PER_SECOND)
.setRequired(false)
.setAllowExpression(true)
.setCorrector(InfiniteOrPositiveValidators.NEGATIVE_VALUE_CORRECTOR)
.setValidator(InfiniteOrPositiveValidators.INT_INSTANCE)
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_PRODUCER_WINDOW_SIZE
*/
AttributeDefinition PRODUCER_WINDOW_SIZE = SimpleAttributeDefinitionBuilder.create("producer-window-size", INT)
.setDefaultValue(new ModelNode(64 * 1024))
.setMeasurementUnit(BYTES)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
AttributeDefinition PROTOCOL_MANAGER_FACTORY = SimpleAttributeDefinitionBuilder.create("protocol-manager-factory", STRING)
.setRequired(false)
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_RECONNECT_ATTEMPTS
*/
SimpleAttributeDefinition RECONNECT_ATTEMPTS = create("reconnect-attempts", INT)
.setDefaultValue(ModelNode.ZERO)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_RETRY_INTERVAL
*/
AttributeDefinition RETRY_INTERVAL = SimpleAttributeDefinitionBuilder.create("retry-interval", LONG)
.setDefaultValue(new ModelNode(2000L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_RETRY_INTERVAL_MULTIPLIER
*/
AttributeDefinition RETRY_INTERVAL_MULTIPLIER = create("retry-interval-multiplier", DOUBLE)
.setDefaultValue(new ModelNode(1.0d))
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultScheduledThreadPoolMaxSize
*/
AttributeDefinition SCHEDULED_THREAD_POOL_MAX_SIZE = SimpleAttributeDefinitionBuilder.create("scheduled-thread-pool-max-size", INT)
.setDefaultValue(new ModelNode(5))
.setRequired(false)
.setAllowExpression(true)
.setCorrector(InfiniteOrPositiveValidators.NEGATIVE_VALUE_CORRECTOR)
.setValidator(InfiniteOrPositiveValidators.INT_INSTANCE)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultThreadPoolMaxSize
*/
AttributeDefinition THREAD_POOL_MAX_SIZE = SimpleAttributeDefinitionBuilder.create("thread-pool-max-size", INT)
.setDefaultValue(new ModelNode(30))
.setRequired(false)
.setAllowExpression(true)
.setCorrector(InfiniteOrPositiveValidators.NEGATIVE_VALUE_CORRECTOR)
.setValidator(InfiniteOrPositiveValidators.INT_INSTANCE)
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_ACK_BATCH_SIZE
*/
AttributeDefinition TRANSACTION_BATCH_SIZE = SimpleAttributeDefinitionBuilder.create("transaction-batch-size", INT)
.setDefaultValue(new ModelNode(1024 * 1024))
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_USE_GLOBAL_POOLS
*/
AttributeDefinition USE_GLOBAL_POOLS = SimpleAttributeDefinitionBuilder.create("use-global-pools", BOOLEAN)
.setDefaultValue(ModelNode.TRUE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_USE_TOPOLOGY_FOR_LOADBALANCING
*/
AttributeDefinition USE_TOPOLOGY = create("use-topology-for-load-balancing", BOOLEAN)
.setDefaultValue(ModelNode.TRUE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* Attributes are defined in the <em>same order than in the XSD schema</em>
*/
ConnectionFactoryAttribute[] ATTRIBUTES = {
create(DISCOVERY_GROUP, null, false),
create(CONNECTORS, null, false),
create(ENTRIES, "entries", true),
create(CommonAttributes.HA, "HA", true),
create(CLIENT_FAILURE_CHECK_PERIOD, "clientFailureCheckPeriod", true),
create(CONNECTION_TTL, "connectionTTL", true),
create(CommonAttributes.CALL_TIMEOUT, "callTimeout", true),
create(CommonAttributes.CALL_FAILOVER_TIMEOUT, "callFailoverTimeout", true),
create(CONSUMER_WINDOW_SIZE, "consumerWindowSize", true),
create(CONSUMER_MAX_RATE, "consumerMaxRate", true),
create(CONFIRMATION_WINDOW_SIZE, "confirmationWindowSize", true),
create(PRODUCER_WINDOW_SIZE, "producerWindowSize", true),
create(PRODUCER_MAX_RATE, "producerMaxRate", true),
create(PROTOCOL_MANAGER_FACTORY, "protocolManagerFactoryStr", true),
create(COMPRESS_LARGE_MESSAGES, "compressLargeMessage", true),
create(CACHE_LARGE_MESSAGE_CLIENT, "cacheLargeMessagesClient", true),
create(CommonAttributes.MIN_LARGE_MESSAGE_SIZE, "minLargeMessageSize", true),
create(CommonAttributes.CLIENT_ID, "clientID", true),
create(DUPS_OK_BATCH_SIZE, "dupsOKBatchSize", true),
create(TRANSACTION_BATCH_SIZE, "transactionBatchSize", true),
create(BLOCK_ON_ACKNOWLEDGE, "blockOnAcknowledge", true),
create(BLOCK_ON_NON_DURABLE_SEND, "blockOnNonDurableSend", true),
create(BLOCK_ON_DURABLE_SEND, "blockOnDurableSend", true),
create(AUTO_GROUP, "autoGroup", true),
create(PRE_ACKNOWLEDGE, "preAcknowledge", true),
create(RETRY_INTERVAL, "retryInterval", true),
create(RETRY_INTERVAL_MULTIPLIER, "retryIntervalMultiplier", true),
create(CommonAttributes.MAX_RETRY_INTERVAL, "maxRetryInterval", true),
// the pooled CF has a different default value for the reconnect-attempts attribute.
// the specific attribute is replaced when PooledConnectionFactoryDefinition#ATTRIBUTES is defined
create(RECONNECT_ATTEMPTS, null, false),
create(FAILOVER_ON_INITIAL_CONNECTION, "failoverOnInitialConnection", true),
create(CONNECTION_LOAD_BALANCING_CLASS_NAME, "connectionLoadBalancingPolicyClassName", true),
create(USE_GLOBAL_POOLS, "useGlobalPools", true),
create(SCHEDULED_THREAD_POOL_MAX_SIZE, "scheduledThreadPoolMaxSize", true),
create(THREAD_POOL_MAX_SIZE, "threadPoolMaxSize", true),
create(GROUP_ID, "groupID", true),
create(DESERIALIZATION_ALLOWLIST, "deserializationWhiteList", true),
create(DESERIALIZATION_BLOCKLIST, "deserializationBlackList", true),
create(DESERIALIZATION_BLACKLIST, "deserializationBlackList", true),
create(DESERIALIZATION_WHITELIST, "deserializationWhiteList", true),
create(INITIAL_MESSAGE_PACKET_SIZE, "initialMessagePacketSize", true),
create(USE_TOPOLOGY, "useTopologyForLoadBalancing", true)
};
}
interface Regular {
AttributeDefinition FACTORY_TYPE = create("factory-type", STRING)
.setDefaultValue(new ModelNode().set(ConnectionFactoryType.GENERIC.toString()))
.setValidator(ConnectionFactoryType.VALIDATOR)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
AttributeDefinition[] ATTRIBUTES = { FACTORY_TYPE } ;
}
interface Pooled {
String ALLOW_LOCAL_TRANSACTIONS_PROP_NAME = "allowLocalTransactions";
String USE_JNDI_PROP_NAME = "useJNDI";
String SETUP_ATTEMPTS_PROP_NAME = "setupAttempts";
String SETUP_INTERVAL_PROP_NAME = "setupInterval";
String REBALANCE_CONNECTIONS_PROP_NAME = "rebalanceConnections";
String RECONNECT_ATTEMPTS_PROP_NAME = "reconnectAttempts";
String PASSWORD_PROP_NAME = "password";
SimpleAttributeDefinition ALLOW_LOCAL_TRANSACTIONS = SimpleAttributeDefinitionBuilder.create("allow-local-transactions", BOOLEAN)
.setAttributeGroup("outbound-config")
.setRequired(false)
.setAllowExpression(true)
.setDefaultValue(ModelNode.FALSE)
.setRestartAllServices()
.build();
ObjectTypeAttributeDefinition CREDENTIAL_REFERENCE =
CredentialReference.getAttributeBuilder(true, false)
.setRestartAllServices()
.addAccessConstraint(MESSAGING_SECURITY_SENSITIVE_TARGET)
.setAlternatives(PASSWORD_PROP_NAME)
.build();
SimpleAttributeDefinition ENLISTMENT_TRACE = SimpleAttributeDefinitionBuilder.create("enlistment-trace", BOOLEAN)
.setRequired(false)
.setAllowExpression(true)
// no default value, this boolean is undefined
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.INITIAL_CONNECT_ATTEMPTS
*/
SimpleAttributeDefinition INITIAL_CONNECT_ATTEMPTS = SimpleAttributeDefinitionBuilder.create("initial-connect-attempts", INT)
.setRequired(false)
.setAllowExpression(true)
.setDefaultValue(new ModelNode(1))
.setRestartAllServices()
.build();
SimpleAttributeDefinition JNDI_PARAMS = SimpleAttributeDefinitionBuilder.create("jndi-params", STRING)
.setAttributeGroup("inbound-config")
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
SimpleAttributeDefinition MANAGED_CONNECTION_POOL = SimpleAttributeDefinitionBuilder.create("managed-connection-pool", STRING)
.setAllowExpression(true)
.setRequired(false)
.setRestartAllServices()
.build();
SimpleAttributeDefinition MAX_POOL_SIZE = SimpleAttributeDefinitionBuilder.create("max-pool-size", INT)
.setDefaultValue(new ModelNode().set(20))
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
SimpleAttributeDefinition MIN_POOL_SIZE = SimpleAttributeDefinitionBuilder.create("min-pool-size", INT)
.setDefaultValue(ModelNode.ZERO)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
SimpleAttributeDefinition PASSWORD = SimpleAttributeDefinitionBuilder.create(PASSWORD_PROP_NAME, STRING)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.addAccessConstraint(SensitiveTargetAccessConstraintDefinition.CREDENTIAL)
.addAccessConstraint(MESSAGING_SECURITY_SENSITIVE_TARGET)
.addAlternatives(CREDENTIAL_REFERENCE.getName())
.build();
SimpleAttributeDefinition REBALANCE_CONNECTIONS = SimpleAttributeDefinitionBuilder.create("rebalance-connections", BOOLEAN)
.setRequired(false)
.setAllowExpression(true)
.setDefaultValue(ModelNode.FALSE)
.setAttributeGroup("inbound-config")
.setRestartAllServices()
.build();
/**
* By default, the resource adapter must reconnect infinitely (see {@link org.apache.activemq.artemis.ra.ActiveMQResourceAdapter#setParams})
*/
AttributeDefinition RECONNECT_ATTEMPTS = create("reconnect-attempts", INT)
.setDefaultValue(new ModelNode().set(-1))
.setRequired(false)
.setAllowExpression(true)
.build();
SimpleAttributeDefinition SETUP_ATTEMPTS = SimpleAttributeDefinitionBuilder.create("setup-attempts", INT)
.setAttributeGroup("inbound-config")
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
SimpleAttributeDefinition SETUP_INTERVAL = SimpleAttributeDefinitionBuilder.create("setup-interval", LONG)
.setMeasurementUnit(MILLISECONDS)
.setAttributeGroup("inbound-config")
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
SimpleAttributeDefinition TRANSACTION = SimpleAttributeDefinitionBuilder.create("transaction", STRING)
.setDefaultValue(new ModelNode().set(CommonAttributes.XA))
.setCorrector(new ParameterCorrector() {
@Override
public ModelNode correct(ModelNode newValue, ModelNode currentValue) {
if (newValue.isDefined() && newValue.getType() != ModelType.EXPRESSION) {
switch (newValue.asString()) {
case CommonAttributes.LOCAL:
return new ModelNode(CommonAttributes.LOCAL);
case CommonAttributes.NONE:
return new ModelNode(CommonAttributes.NONE);
case CommonAttributes.XA:
return new ModelNode(CommonAttributes.XA);
default:
MessagingLogger.ROOT_LOGGER.invalidTransactionNameValue(newValue.asString(), "transaction", Arrays.asList(CommonAttributes.LOCAL, CommonAttributes.NONE, CommonAttributes.XA));
return new ModelNode(CommonAttributes.XA);
}
}
return newValue;
}
})
.setValidator(new TransactionNameAllowedValuesValidator(CommonAttributes.LOCAL, CommonAttributes.NONE, CommonAttributes.XA))
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
AttributeDefinition USE_AUTO_RECOVERY = SimpleAttributeDefinitionBuilder.create("use-auto-recovery", BOOLEAN)
.setDefaultValue(ModelNode.TRUE) // ActiveMQQResourceAdapter.useAutoRecovery = true but is not exposed publicly
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
AttributeDefinition USE_JNDI = SimpleAttributeDefinitionBuilder.create("use-jndi", BOOLEAN)
.setAttributeGroup("inbound-config")
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
AttributeDefinition USE_LOCAL_TX = SimpleAttributeDefinitionBuilder.create("use-local-tx", BOOLEAN)
.setAttributeGroup("inbound-config")
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
SimpleAttributeDefinition USER = SimpleAttributeDefinitionBuilder.create("user", STRING)
.setRequired(false)
.setAllowExpression(true)
.addAccessConstraint(SensitiveTargetAccessConstraintDefinition.CREDENTIAL)
.addAccessConstraint(MESSAGING_SECURITY_SENSITIVE_TARGET)
.build();
SimpleAttributeDefinition STATISTICS_ENABLED = SimpleAttributeDefinitionBuilder.create(ModelDescriptionConstants.STATISTICS_ENABLED, BOOLEAN)
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setAllowExpression(true)
.build();
/**
* Attributes are defined in the <em>same order than in the XSD schema</em>
*/
ConnectionFactoryAttribute[] ATTRIBUTES = {
/* inbound config */
create(USE_JNDI, USE_JNDI_PROP_NAME, true, INBOUND),
create(JNDI_PARAMS, "jndiParams", true, INBOUND),
create(REBALANCE_CONNECTIONS, REBALANCE_CONNECTIONS_PROP_NAME, true, INBOUND),
create(USE_LOCAL_TX, "useLocalTx", true, INBOUND),
create(SETUP_ATTEMPTS, SETUP_ATTEMPTS_PROP_NAME, true, INBOUND),
create(SETUP_INTERVAL, SETUP_INTERVAL_PROP_NAME, true, INBOUND),
/* outbound config */
create(ALLOW_LOCAL_TRANSACTIONS, ALLOW_LOCAL_TRANSACTIONS_PROP_NAME, true, OUTBOUND),
create(STATISTICS_ENABLED, null, false),
create(TRANSACTION, null, false),
create(USER, "userName", true),
create(PASSWORD, "password", true),
create(CREDENTIAL_REFERENCE, null, false),
create(MANAGED_CONNECTION_POOL, null, false),
create(ENLISTMENT_TRACE, null, false),
create(MIN_POOL_SIZE, null, false),
create(MAX_POOL_SIZE, null, false),
create(USE_AUTO_RECOVERY, "useAutoRecovery", true),
create(INITIAL_CONNECT_ATTEMPTS, "initialConnectAttempts", true),
};
}
interface External {
AttributeDefinition ENABLE_AMQ1_PREFIX = create("enable-amq1-prefix", BOOLEAN)
.setDefaultValue(ModelNode.TRUE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
AttributeDefinition[] ATTRIBUTES = { ENABLE_AMQ1_PREFIX } ;
}
static class TransactionNameAllowedValuesValidator extends StringAllowedValuesValidator {
public TransactionNameAllowedValuesValidator(String... values) {
super(values);
}
@Override
public void validateParameter(String parameterName, ModelNode value) throws OperationFailedException {
if (value.isDefined()
&& !getAllowedValues().contains(value)) {
MessagingLogger.ROOT_LOGGER.invalidTransactionNameValue(value.asString(), parameterName, getAllowedValues());
}
}
}
static class AliasReadAttributeHandler implements OperationStepHandler {
private final String oldAttributeName;
private final String newAttributeName;
public AliasReadAttributeHandler(String oldAttributeName, String newAttributeName) {
this.oldAttributeName = oldAttributeName;
this.newAttributeName = newAttributeName;
}
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
ModelNode op = operation.clone();
op.get(newAttributeName).set(operation.get(oldAttributeName));
AttributeAccess access = context.getResourceRegistration().getAttributeAccess(PathAddress.EMPTY_ADDRESS, newAttributeName);
if(access != null && access.getReadHandler() != null) {
access.getReadHandler().execute(context, op);
}
}
}
static class AliasWriteAttributeHandler implements OperationStepHandler {
private final String oldAttributeName;
private final String newAttributeName;
public AliasWriteAttributeHandler(String oldAttributeName, String newAttributeName) {
this.oldAttributeName = oldAttributeName;
this.newAttributeName = newAttributeName;
}
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
ModelNode op = operation.clone();
op.get(newAttributeName).set(operation.get(oldAttributeName));
AttributeAccess access = context.getResourceRegistration().getAttributeAccess(PathAddress.EMPTY_ADDRESS, newAttributeName);
if(access != null && access.getWriteHandler() != null) {
access.getWriteHandler().execute(context, op);
}
}
}
public static void registerAliasAttribute(ManagementResourceRegistration resourceRegistration, boolean readOnly, StringListAttributeDefinition alias, String attribute) {
if (resourceRegistration.getAttributeNames(PathAddress.EMPTY_ADDRESS).contains(alias.getName())) {
resourceRegistration.unregisterAttribute(alias.getName());
}
StringListAttributeDefinition aliasedAttributeDefinition = new StringListAttributeDefinition.Builder(alias)
.setFlags(AttributeAccess.Flag.ALIAS).build();
if (readOnly) {
resourceRegistration.registerReadOnlyAttribute(aliasedAttributeDefinition, new AliasReadAttributeHandler(alias.getName(), attribute));
} else {
resourceRegistration.registerReadWriteAttribute(aliasedAttributeDefinition, new AliasReadAttributeHandler(alias.getName(), attribute),
new AliasWriteAttributeHandler(alias.getName(), attribute));
}
}
}
| 38,689
| 47.72796
| 211
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/ExternalJMSTopicDefinition.java
|
/*
* Copyright 2018 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.extension.messaging.activemq.jms;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
import org.jboss.as.controller.access.management.AccessConstraintDefinition;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.wildfly.extension.messaging.activemq.CommonAttributes;
import org.wildfly.extension.messaging.activemq.MessagingExtension;
import org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.External;
/**
* Jakarta Messaging Topic resource definition
*
* @author Emmanuel Hugonnet (c) 2018 Red Hat, inc.
*/
public class ExternalJMSTopicDefinition extends PersistentResourceDefinition {
public static final AttributeDefinition[] ATTRIBUTES = {
CommonAttributes.DESTINATION_ENTRIES, External.ENABLE_AMQ1_PREFIX
};
private final boolean registerRuntimeOnly;
public ExternalJMSTopicDefinition(final boolean registerRuntimeOnly) {
super(MessagingExtension.EXTERNAL_JMS_TOPIC_PATH,
MessagingExtension.getResourceDescriptionResolver(CommonAttributes.EXTERNAL_JMS_TOPIC),
ExternalJMSTopicAdd.INSTANCE,
ExternalJMSTopicRemove.INSTANCE);
this.registerRuntimeOnly = registerRuntimeOnly;
}
@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(CommonAttributes.DESTINATION_ENTRIES, External.ENABLE_AMQ1_PREFIX);
}
@Override
public void registerAttributes(ManagementResourceRegistration registry) {
if (registerRuntimeOnly) {
registry.registerReadOnlyAttribute(CommonAttributes.DESTINATION_ENTRIES, null);
// Should this be read only as entries ?
registry.registerReadOnlyAttribute(External.ENABLE_AMQ1_PREFIX, null);
} else {
registry.registerReadWriteAttribute(CommonAttributes.DESTINATION_ENTRIES, null, new ReloadRequiredWriteAttributeHandler(CommonAttributes.DESTINATION_ENTRIES));
registry.registerReadWriteAttribute(External.ENABLE_AMQ1_PREFIX, null, new ReloadRequiredWriteAttributeHandler(External.ENABLE_AMQ1_PREFIX));
}
}
@Override
public List<AccessConstraintDefinition> getAccessConstraints() {
return Collections.singletonList(MessagingExtension.JMS_TOPIC_ACCESS_CONSTRAINT);
}
}
| 3,168
| 41.253333
| 171
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/JMSQueueConfigurationWriteHandler.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.jms;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
/**
* Write attribute handler for attributes that update the persistent configuration of a Jakarta Messaging queue resource.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class JMSQueueConfigurationWriteHandler extends ReloadRequiredWriteAttributeHandler {
public static final JMSQueueConfigurationWriteHandler INSTANCE = new JMSQueueConfigurationWriteHandler();
private JMSQueueConfigurationWriteHandler() {
super(JMSQueueDefinition.ATTRIBUTES);
}
}
| 1,640
| 40.025
| 121
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/JMSServerControlHandler.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.jms;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.jboss.dmr.ModelType.LIST;
import static org.jboss.dmr.ModelType.STRING;
import static org.wildfly.extension.messaging.activemq.ActiveMQActivationService.rollbackOperationIfServerNotActive;
import static org.wildfly.extension.messaging.activemq.ManagementUtil.reportListOfStrings;
import static org.wildfly.extension.messaging.activemq.OperationDefinitionHelper.createNonEmptyStringAttribute;
import static org.wildfly.extension.messaging.activemq.OperationDefinitionHelper.runtimeReadOnlyOperation;
import static org.wildfly.extension.messaging.activemq.jms.JMSQueueService.JMS_QUEUE_PREFIX;
import static org.wildfly.extension.messaging.activemq.jms.JMSTopicService.JMS_TOPIC_PREFIX;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jakarta.json.Json;
import jakarta.json.JsonArray;
import jakarta.json.JsonArrayBuilder;
import jakarta.json.JsonObject;
import jakarta.json.JsonObjectBuilder;
import jakarta.json.JsonReader;
import jakarta.json.JsonValue;
import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl;
import org.apache.activemq.artemis.api.core.management.QueueControl;
import org.apache.activemq.artemis.api.core.management.ResourceNames;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ServerSession;
import org.jboss.as.controller.AbstractRuntimeOnlyHandler;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.descriptions.ResourceDescriptionResolver;
import org.jboss.as.controller.logging.ControllerLogger;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.wildfly.extension.messaging.activemq.MessagingServices;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* Handles operations and attribute reads supported by a ActiveMQ {@link ActiveMQServerControl}.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class JMSServerControlHandler extends AbstractRuntimeOnlyHandler {
private static final AttributeDefinition ADDRESS_NAME = createNonEmptyStringAttribute("address-name");
private static final AttributeDefinition SESSION_ID = createNonEmptyStringAttribute("session-id");
private static final AttributeDefinition CONNECTION_ID = createNonEmptyStringAttribute("connection-id");
public static final String LIST_CONNECTIONS_AS_JSON = "list-connections-as-json";
public static final String LIST_CONSUMERS_AS_JSON = "list-consumers-as-json";
public static final String LIST_ALL_CONSUMERS_AS_JSON = "list-all-consumers-as-json";
public static final String LIST_TARGET_DESTINATIONS = "list-target-destinations";
public static final String GET_LAST_SENT_MESSAGE_ID = "get-last-sent-message-id";
public static final String GET_SESSION_CREATION_TIME = "get-session-creation-time";
public static final String LIST_SESSIONS_AS_JSON = "list-sessions-as-json";
public static final String LIST_PREPARED_TRANSACTION_JMS_DETAILS_AS_JSON = "list-prepared-transaction-jms-details-as-json";
public static final String LIST_PREPARED_TRANSACTION_JMS_DETAILS_AS_HTML = "list-prepared-transaction-jms-details-as-html";
public static final JMSServerControlHandler INSTANCE = new JMSServerControlHandler();
private JMSServerControlHandler() {
}
public JsonObject enrich(JsonObject source, String key, String value) {
JsonObjectBuilder builder = Json.createObjectBuilder();
builder.add(key, value);
source.entrySet().
forEach(e -> builder.add(e.getKey(), e.getValue()));
return builder.build();
}
@Override
protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
if (rollbackOperationIfServerNotActive(context, operation)) {
return;
}
final String operationName = operation.require(OP).asString();
final ActiveMQServer server = getServer(context, operation);
if (server == null) {
PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
throw ControllerLogger.ROOT_LOGGER.managementResourceNotFound(address);
}
final ActiveMQServerControl serverControl = server.getActiveMQServerControl();
try {
if (LIST_CONNECTIONS_AS_JSON.equals(operationName)) {
String json = serverControl.listConnectionsAsJSON();
context.getResult().set(json);
final JsonArrayBuilder enrichedConnections = Json.createArrayBuilder();
try (
JsonReader reader = Json.createReader(new StringReader(json));
) {
final JsonArray connections = reader.readArray();
for (int i = 0; i < connections.size(); i++) {
final JsonObject originalConnection = connections.getJsonObject(i);
final JsonObject enrichedConnection = enrichConnection(originalConnection, serverControl);
enrichedConnections.add(enrichedConnection);
}
}
String enrichedJSON = enrichedConnections.build().toString();
context.getResult().set(enrichedJSON);
} else if (LIST_CONSUMERS_AS_JSON.equals(operationName)) {
String connectionID = CONNECTION_ID.resolveModelAttribute(context, operation).asString();
String json = serverControl.listConsumersAsJSON(connectionID);
final JsonArrayBuilder enrichedConsumers = Json.createArrayBuilder();
try (
JsonReader reader = Json.createReader(new StringReader(json));
) {
final JsonArray consumers = reader.readArray();
for (int i = 0; i < consumers.size(); i++) {
final JsonObject originalConsumer = consumers.getJsonObject(i);
final JsonObject enrichedConsumer = enrichConsumer(originalConsumer, server);
enrichedConsumers.add(enrichedConsumer);
}
}
String enrichedJSON = enrichedConsumers.build().toString();
context.getResult().set(enrichedJSON);
} else if (LIST_ALL_CONSUMERS_AS_JSON.equals(operationName)) {
String json = serverControl.listAllConsumersAsJSON();
final JsonArrayBuilder enrichedConsumers = Json.createArrayBuilder();
try (
JsonReader reader = Json.createReader(new StringReader(json));
) {
final JsonArray consumers = reader.readArray();
for (int i = 0; i < consumers.size(); i++) {
final JsonObject originalConsumer = consumers.getJsonObject(i);
final JsonObject enrichedConsumer = enrichConsumer(originalConsumer, server);
enrichedConsumers.add(enrichedConsumer);
}
}
String enrichedJSON = enrichedConsumers.build().toString();
context.getResult().set(enrichedJSON);
} else if (LIST_TARGET_DESTINATIONS.equals(operationName)) {
String sessionID = SESSION_ID.resolveModelAttribute(context, operation).asString();
// Artemis no longer defines the method. Its implementation from Artemis 1.5 has been inlined:
String[] list = listTargetDestinations(server, sessionID);
reportListOfStrings(context, list);
} else if (GET_LAST_SENT_MESSAGE_ID.equals(operationName)) {
String sessionID = SESSION_ID.resolveModelAttribute(context, operation).asString();
String addressName = ADDRESS_NAME.resolveModelAttribute(context, operation).asString();
// Artemis no longer defines the method. Its implementation from Artemis 1.5 has been inlined:
ServerSession session = server.getSessionByID(sessionID);
if (session != null) {
String messageID = session.getLastSentMessageID(addressName);
context.getResult().set(messageID);
}
} else if (GET_SESSION_CREATION_TIME.equals(operationName)) {
String sessionID = SESSION_ID.resolveModelAttribute(context, operation).asString();
// Artemis no longer defines the method. Its implementation from Artemis 1.5 has been inlined:
ServerSession session = server.getSessionByID(sessionID);
if (session != null) {
String time = String.valueOf(session.getCreationTime());
context.getResult().set(time);
}
} else if (LIST_SESSIONS_AS_JSON.equals(operationName)) {
String connectionID = CONNECTION_ID.resolveModelAttribute(context, operation).asString();
String json = serverControl.listSessionsAsJSON(connectionID);
context.getResult().set(json);
} else if (LIST_PREPARED_TRANSACTION_JMS_DETAILS_AS_JSON.equals(operationName)) {
String json = serverControl.listPreparedTransactionDetailsAsJSON();
context.getResult().set(json);
} else if (LIST_PREPARED_TRANSACTION_JMS_DETAILS_AS_HTML.equals(operationName)) {
String html = serverControl.listPreparedTransactionDetailsAsHTML();
context.getResult().set(html);
} else {
// Bug
throw MessagingLogger.ROOT_LOGGER.unsupportedOperation(operationName);
}
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
context.getFailureDescription().set(e.getLocalizedMessage());
}
}
private JsonObject enrichConsumer(JsonObject originalConsumer, ActiveMQServer server) {
JsonObjectBuilder enrichedConsumer = Json.createObjectBuilder();
for (Map.Entry<String, JsonValue> entry : originalConsumer.entrySet()) {
enrichedConsumer.add(entry.getKey(), entry.getValue());
}
String queueName = originalConsumer.getString("queueName");
final QueueControl queueControl = QueueControl.class.cast(server.getManagementService().getResource(ResourceNames.QUEUE + queueName));
if (queueControl == null) {
return originalConsumer;
}
enrichedConsumer.add("durable", queueControl.isDurable());
String routingType = queueControl.getRoutingType();
String destinationType = routingType.equals("ANYCAST") ? "queue" : "topic";
enrichedConsumer.add("destinationType", destinationType);
String address = queueControl.getAddress();
String destinationName = inferDestinationName(address);
enrichedConsumer.add("destinationName", destinationName);
return enrichedConsumer.build();
}
private JsonObject enrichConnection(JsonObject originalConnection, ActiveMQServerControl serverControl) throws Exception {
JsonObjectBuilder enrichedConnection = Json.createObjectBuilder();
for (Map.Entry<String, JsonValue> entry : originalConnection.entrySet()) {
enrichedConnection.add(entry.getKey(), entry.getValue());
}
final String connectionID = originalConnection.getString("connectionID");
final String sessionsAsJSON = serverControl.listSessionsAsJSON(connectionID);
try (JsonReader sessionsReader = Json.createReader(new StringReader(sessionsAsJSON))) {
final JsonArray sessions = sessionsReader.readArray();
for (int j = 0; j < sessions.size(); j++) {
final JsonObject session = sessions.getJsonObject(j);
if (session.containsKey("metadata")) {
final JsonObject metadata = session.getJsonObject("metadata");
if (metadata.containsKey("jms-client-id")) {
String clientID = metadata.getString("jms-client-id");
enrichedConnection.add("clientID", clientID);
break;
}
}
}
}
return enrichedConnection.build();
}
/**
* Infer the name of the JMS destination based on the queue's address.
*/
private String inferDestinationName(String address) {
if (address.startsWith(JMS_QUEUE_PREFIX)) {
return address.substring(JMS_QUEUE_PREFIX.length());
} else if (address.startsWith(JMS_TOPIC_PREFIX)) {
return address.substring(JMS_TOPIC_PREFIX.length());
} else {
return address;
}
}
public void registerOperations(final ManagementResourceRegistration registry, ResourceDescriptionResolver resolver) {
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_CONNECTIONS_AS_JSON, resolver)
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_CONSUMERS_AS_JSON, resolver)
.setParameters(CONNECTION_ID)
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_ALL_CONSUMERS_AS_JSON, resolver)
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_TARGET_DESTINATIONS, resolver)
.setParameters(SESSION_ID)
.setReplyType(LIST)
.setReplyValueType(STRING)
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(GET_LAST_SENT_MESSAGE_ID, resolver)
.setParameters(SESSION_ID, ADDRESS_NAME)
.setReplyType(STRING)
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(GET_SESSION_CREATION_TIME, resolver)
.setParameters(SESSION_ID)
.setReplyType(STRING)
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_SESSIONS_AS_JSON, resolver)
.setParameters(CONNECTION_ID)
.setReplyType(STRING)
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_PREPARED_TRANSACTION_JMS_DETAILS_AS_JSON, resolver)
.setReplyType(STRING)
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_PREPARED_TRANSACTION_JMS_DETAILS_AS_HTML, resolver)
.setReplyType(STRING)
.build(),
this);
}
private ActiveMQServer getServer(final OperationContext context, final ModelNode operation) {
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
ServiceController<?> service = context.getServiceRegistry(false).getService(serviceName);
ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
return server;
}
public String[] listTargetDestinations(ActiveMQServer server, String sessionID) throws Exception {
ServerSession session = server.getSessionByID(sessionID);
if (session == null) {
return new String[0];
}
String[] addresses = session.getTargetAddresses();
Map<String, QueueControl> allDests = new HashMap<>();
Object[] queueControls = server.getManagementService().getResources(QueueControl.class);
for (Object queue : queueControls) {
QueueControl queueControl = (QueueControl)queue;
allDests.put(queueControl.getAddress(), queueControl);
}
List<String> destinations = new ArrayList<>();
for (String addresse : addresses) {
QueueControl control = allDests.get(addresse);
if (control != null) {
destinations.add(control.getAddress());
}
}
return destinations.toArray(String[]::new);
}
}
| 18,011
| 49.453782
| 156
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/ExternalPooledConnectionFactoryDefinition.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.jms;
import static org.wildfly.extension.messaging.activemq.AbstractTransportDefinition.CONNECTOR_CAPABILITY_NAME;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttribute.getDefinitions;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Common.DESERIALIZATION_ALLOWLIST;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Common.DESERIALIZATION_BLACKLIST;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Common.DESERIALIZATION_BLOCKLIST;
import static org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Common.DESERIALIZATION_WHITELIST;
import java.util.Arrays;
import java.util.Collection;
import org.jboss.as.controller.AbstractAttributeDefinitionBuilder;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.AttributeMarshaller;
import org.jboss.as.controller.AttributeParser;
import org.jboss.as.controller.PrimitiveListAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.SimpleListAttributeDefinition;
import org.jboss.as.controller.SimpleMapAttributeDefinition;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.StringListAttributeDefinition;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.dmr.ModelNode;
import org.wildfly.extension.messaging.activemq.AbstractTransportDefinition;
import org.wildfly.extension.messaging.activemq.CommonAttributes;
import org.wildfly.extension.messaging.activemq.MessagingExtension;
import org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Common;
import org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.External;
import org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Pooled;
/**
* Jakarta Messaging external pooled Connection Factory resource definition.
* By 'external' it means that this PCF is targeting an external broker.
* @author Emmanuel Hugonnet (c) 2019 Red Hat, Inc.
*/
public class ExternalPooledConnectionFactoryDefinition extends PooledConnectionFactoryDefinition {
static final String CAPABILITY_NAME = "org.wildfly.messaging.activemq.external.connection-factory";
static final RuntimeCapability<Void> CAPABILITY = RuntimeCapability.Builder.of(CAPABILITY_NAME, true, ExternalConnectionFactoryService.class).
build();
// the generation of the Pooled CF attributes is a bit ugly but it is with purpose:
// * factorize the attributes which are common between the regular CF and the pooled CF
// * keep in a single place the subtle differences (e.g. different default values for reconnect-attempts between
// the regular and pooled CF
private static ConnectionFactoryAttribute[] define(ConnectionFactoryAttribute[] specific, ConnectionFactoryAttribute... common) {
int size = common.length + specific.length + 1;
ConnectionFactoryAttribute[] result = new ConnectionFactoryAttribute[size];
for (int i = 0; i < specific.length; i++) {
ConnectionFactoryAttribute attr = specific[i];
AttributeDefinition definition = attr.getDefinition();
if (definition == Pooled.INITIAL_CONNECT_ATTEMPTS) {
result[i] = ConnectionFactoryAttribute.create(
SimpleAttributeDefinitionBuilder
.create(Pooled.INITIAL_CONNECT_ATTEMPTS)
.setDefaultValue(new ModelNode(-1))
.build(),
attr.getPropertyName(),
true);
} else {
result[i] = attr;
}
}
for (int i = 0; i < common.length; i++) {
ConnectionFactoryAttribute attr = common[i];
AttributeDefinition definition = attr.getDefinition();
ConnectionFactoryAttribute newAttr;
// replace the reconnect-attempts attribute to use a different default value for pooled CF
if (definition == Common.RECONNECT_ATTEMPTS) {
AttributeDefinition copy = copy(Pooled.RECONNECT_ATTEMPTS, AttributeAccess.Flag.RESTART_ALL_SERVICES);
newAttr = ConnectionFactoryAttribute.create(copy, Pooled.RECONNECT_ATTEMPTS_PROP_NAME, true);
} else if (definition == CommonAttributes.HA) {
newAttr = ConnectionFactoryAttribute.create(
SimpleAttributeDefinitionBuilder
.create(CommonAttributes.HA)
.setDefaultValue(ModelNode.TRUE)
.setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES)
.build(),
attr.getPropertyName(),
true);
} else if (definition == Common.CONNECTORS) {
StringListAttributeDefinition copy = new StringListAttributeDefinition.Builder(Common.CONNECTORS)
.setAlternatives(CommonAttributes.DISCOVERY_GROUP)
.setRequired(true)
.setAttributeParser(AttributeParser.STRING_LIST)
.setAttributeMarshaller(AttributeMarshaller.STRING_LIST)
.setCapabilityReference(new AbstractTransportDefinition.TransportCapabilityReferenceRecorder(CAPABILITY_NAME, CONNECTOR_CAPABILITY_NAME, true))
.setRestartAllServices()
.build();
newAttr = ConnectionFactoryAttribute.create(copy, attr.getPropertyName(), attr.isResourceAdapterProperty(), attr.getConfigType());
} else {
AttributeDefinition copy = copy(definition, AttributeAccess.Flag.RESTART_ALL_SERVICES);
newAttr = ConnectionFactoryAttribute.create(copy, attr.getPropertyName(), attr.isResourceAdapterProperty(), attr.getConfigType());
}
result[specific.length + i] = newAttr;
}
result[size -1] = ConnectionFactoryAttribute.create(External.ENABLE_AMQ1_PREFIX, "enable1xPrefixes", true);
return result;
}
private static AttributeDefinition copy(AttributeDefinition attribute, AttributeAccess.Flag flag) {
AbstractAttributeDefinitionBuilder builder;
if (attribute instanceof SimpleListAttributeDefinition) {
builder = new SimpleListAttributeDefinition.Builder((SimpleListAttributeDefinition) attribute);
} else if (attribute instanceof SimpleMapAttributeDefinition) {
builder = new SimpleMapAttributeDefinition.Builder((SimpleMapAttributeDefinition) attribute);
} else if (attribute instanceof PrimitiveListAttributeDefinition) {
builder = new PrimitiveListAttributeDefinition.Builder((PrimitiveListAttributeDefinition) attribute);
} else {
builder = new SimpleAttributeDefinitionBuilder((SimpleAttributeDefinition) attribute);
}
builder.setFlags(flag);
return builder.build();
}
public static final ConnectionFactoryAttribute[] ATTRIBUTES = define(Pooled.ATTRIBUTES, Common.ATTRIBUTES);
public ExternalPooledConnectionFactoryDefinition(final boolean deployed) {
super(new SimpleResourceDefinition.Parameters(MessagingExtension.POOLED_CONNECTION_FACTORY_PATH, MessagingExtension.getResourceDescriptionResolver(CommonAttributes.POOLED_CONNECTION_FACTORY))
.setAddHandler(ExternalPooledConnectionFactoryAdd.INSTANCE)
.setRemoveHandler(ExternalPooledConnectionFactoryRemove.INSTANCE)
.setCapabilities(CAPABILITY), deployed, true);
}
@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(getDefinitions(ATTRIBUTES));
}
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
super.registerAttributes(resourceRegistration);
ConnectionFactoryAttributes.registerAliasAttribute(resourceRegistration, false, DESERIALIZATION_WHITELIST, DESERIALIZATION_ALLOWLIST.getName());
ConnectionFactoryAttributes.registerAliasAttribute(resourceRegistration, false, DESERIALIZATION_BLACKLIST, DESERIALIZATION_BLOCKLIST.getName());
}
}
| 9,659
| 58.62963
| 199
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/jms/JMSTopicConfigurationRuntimeHandler.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.wildfly.extension.messaging.activemq.jms;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.PathAddress;
import org.jboss.dmr.ModelNode;
/**
* Read handler for XML deployed Jakarta Messaging queues
*
* @author Stuart Douglas
*/
public class JMSTopicConfigurationRuntimeHandler extends AbstractJMSRuntimeHandler<ModelNode> {
public static final JMSTopicConfigurationRuntimeHandler INSTANCE = new JMSTopicConfigurationRuntimeHandler();
private JMSTopicConfigurationRuntimeHandler() {
}
@Override
protected void executeReadAttribute(final String attributeName, final OperationContext context, final ModelNode destination, final PathAddress address, final boolean includeDefault) {
if (destination.hasDefined(attributeName)) {
context.getResult().set(destination.get(attributeName));
}
}
}
| 1,914
| 38.081633
| 187
|
java
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.