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/test/java/org/wildfly/extension/messaging/activemq/ChangeToTrueConfig.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;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.NAME;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.model.test.FailedOperationTransformationConfig;
import org.jboss.dmr.ModelNode;
/**
*
* @author Emmanuel Hugonnet (c) 2019 Red Hat, Inc.
*/
class ChangeToTrueConfig extends FailedOperationTransformationConfig.AttributesPathAddressConfig<ChangeToTrueConfig> {
private final String attribute;
ChangeToTrueConfig(String attribute) {
super(attribute);
this.attribute = attribute;
}
@Override
protected boolean isAttributeWritable(String attributeName) {
return true;
}
@Override
protected boolean checkValue(ModelNode operation, String attrName, ModelNode attribute, boolean isGeneratedWriteAttribute) {
if (!isGeneratedWriteAttribute && operation.get(ModelDescriptionConstants.OP).asString().equals(WRITE_ATTRIBUTE_OPERATION) && operation.hasDefined(NAME) && operation.get(NAME).asString().equals(this.attribute)) {
// The attribute won't be defined in the :write-attribute(name=<attribute name>,.. boot operation so don't reject in that case
return false;
}
return !attribute.equals(ModelNode.TRUE);
}
@Override
protected boolean checkValue(String attrName, ModelNode attribute, boolean isWriteAttribute) {
throw new IllegalStateException();
}
@Override
protected ModelNode correctValue(ModelNode toResolve, boolean isWriteAttribute) {
return ModelNode.TRUE;
}
}
| 2,351
| 36.935484
| 220
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/test/java/org/wildfly/extension/messaging/activemq/MessagingDependencies.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 java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.jboss.as.model.test.ModelTestControllerVersion;
/**
*
* @author <a href="kabir.khan@jboss.com">Kabir Khan</a>
*/
public class MessagingDependencies {
private static final Map<ModelTestControllerVersion, String[]> ACTIVEMQ_DEPENDENCIES;
static {
Map<ModelTestControllerVersion, String[]> map = new HashMap<>();
map.put(ModelTestControllerVersion.EAP_7_4_0, new String[]{
"org.apache.activemq:artemis-commons:2.16.0.redhat-00022",
"org.apache.activemq:artemis-journal:2.16.0.redhat-00022",
"org.apache.activemq:artemis-server:2.16.0.redhat-00022",
"org.apache.activemq:artemis-jms-server:2.16.0.redhat-00022",
"org.apache.activemq:artemis-core-client:2.16.0.redhat-00022",
"org.apache.activemq:artemis-jms-client:2.16.0.redhat-00022",
"org.apache.activemq:artemis-ra:2.16.0.redhat-00022",
"org.jboss.spec.javax.jms:jboss-jms-api_2.0_spec:2.0.0.Final"
});
ACTIVEMQ_DEPENDENCIES = Collections.unmodifiableMap(map);
}
static String[] getActiveMQDependencies(ModelTestControllerVersion controllerVersion) {
return ACTIVEMQ_DEPENDENCIES.get(controllerVersion);
}
static String getMessagingActiveMQGAV(ModelTestControllerVersion version) {
if (version.isEap()) {
return "org.jboss.eap:wildfly-messaging-activemq:" + version.getMavenGavVersion();
}
return "org.wildfly:wildfly-messaging-activemq:" + version.getMavenGavVersion();
}
static String[] getJGroupsDependencies(ModelTestControllerVersion version) {
String groupId = version.isEap() ? "org.jboss.eap" : "org.wildfly";
return new String[]{
String.format("%s:wildfly-clustering-common:%s", groupId, version.getMavenGavVersion()),
String.format("%s:wildfly-clustering-jgroups-api:%s", groupId, version.getMavenGavVersion()),
String.format("%s:wildfly-clustering-jgroups-extension:%s", groupId, version.getMavenGavVersion()),
String.format("%s:wildfly-clustering-jgroups-spi:%s", groupId, version.getMavenGavVersion()),
String.format("%s:wildfly-clustering-service:%s", groupId, version.getMavenGavVersion()),
String.format("%s:wildfly-clustering-api:%s", groupId, version.getMavenGavVersion()),
String.format("%s:wildfly-clustering-spi:%s", groupId, version.getMavenGavVersion()),
"org.jgroups:jgroups:3.6.12.Final-redhat-1",};
}
}
| 3,672
| 46.701299
| 111
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/test/java/org/wildfly/extension/messaging/activemq/ShallowResourcesTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2022, 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.PathAddress;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.operations.common.Util;
import org.jboss.as.controller.security.CredentialReference;
import org.jboss.as.subsystem.test.AbstractSubsystemTest;
import org.jboss.as.subsystem.test.AdditionalInitialization;
import org.jboss.as.subsystem.test.KernelServices;
import org.jboss.dmr.ModelNode;
import org.junit.Assert;
import org.junit.Test;
import org.wildfly.clustering.jgroups.spi.JGroupsDefaultRequirement;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADDRESS;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.FAILED;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.FAILURE_DESCRIPTION;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OUTCOME;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUCCESS;
import org.wildfly.clustering.server.service.ClusteringDefaultRequirement;
import org.wildfly.clustering.server.service.ClusteringRequirement;
/**
* Verifies that an attempt to undefine socket-binding attr on the socket-discovery-group resource, when performed via
* the original discovery-group shallow resource, fails with informative error message.
*
* The same is tested for the jgroups-cluster attr on the jgroups-discovery-group, and similarly for the *-broadcast-group resources.
*/
public class ShallowResourcesTestCase extends AbstractSubsystemTest {
private static final PathAddress SUBSYSTEM_ADDRESS = PathAddress.pathAddress(ModelDescriptionConstants.SUBSYSTEM, MessagingExtension.SUBSYSTEM_NAME);
private static final PathAddress SERVER_ADDRESS = SUBSYSTEM_ADDRESS.append(CommonAttributes.SERVER, CommonAttributes.DEFAULT);
private static PathAddress discoveryGroupAddress(String name) {
return SUBSYSTEM_ADDRESS.append(CommonAttributes.DISCOVERY_GROUP, name);
}
private static PathAddress broadcastGroupAddress(String name) {
return SERVER_ADDRESS.append(CommonAttributes.BROADCAST_GROUP, name);
}
public ShallowResourcesTestCase() {
super(MessagingExtension.SUBSYSTEM_NAME, new MessagingExtension());
}
@Test
public void testDiscoveryGroupRequiresSocketBindingOrJGroupsCluster() throws Exception {
ModelNode operationTemplate = Util.createAddOperation(discoveryGroupAddress("dg"));
testRequiresSocketBindingOrJGroupsCluster(operationTemplate);
}
@Test
public void testBroadcastGroupRequiresSocketBindingOrJGroupsCluster() throws Exception {
ModelNode operationTemplate = Util.createAddOperation(broadcastGroupAddress("bg"));
operationTemplate.get(CommonAttributes.CONNECTORS).setEmptyList().add("in-vm");
testRequiresSocketBindingOrJGroupsCluster(operationTemplate);
}
private void testRequiresSocketBindingOrJGroupsCluster(ModelNode addOperationTemplate) throws Exception {
KernelServices kernelServices = createKernelServices();
// try to add discovery or broadcast group with no socket-binding and no jgroups-cluster attrs -> should fail
// with a message saying that one of the two attributes must be set
ModelNode op = addOperationTemplate.clone();
ModelNode result = kernelServices.executeOperation(op);
Assert.assertEquals(FAILED, result.get(OUTCOME).asString());
Assert.assertTrue(result.get(FAILURE_DESCRIPTION).asString().contains("WFLYMSGAMQ0108:"));
// try to add discovery or broadcast group with jgroups-cluster set -> should succeed
op = addOperationTemplate.clone();
op.get(CommonAttributes.JGROUPS_CLUSTER.getName()).set("default-cluster");
result = kernelServices.executeOperation(op);
Assert.assertEquals(result.get(FAILURE_DESCRIPTION).asString(),
SUCCESS, result.get(OUTCOME).asString());
removeResource(kernelServices, addOperationTemplate.get(ADDRESS));
// try to add discovery or broadcast group with socket-binding set -> should succeed
op = addOperationTemplate.clone();
op.get(CommonAttributes.SOCKET_BINDING.getName()).set("http");
result = kernelServices.executeOperation(op);
Assert.assertEquals(result.get(FAILURE_DESCRIPTION).asString(),
SUCCESS, result.get(OUTCOME).asString());
removeResource(kernelServices, addOperationTemplate.get(ADDRESS));
}
@Test
public void testUndefineDiscoveryGroupAttrs() throws Exception {
ModelNode addSocketDiscoveryGroup = Util.createAddOperation(discoveryGroupAddress("socket-group"));
addSocketDiscoveryGroup.get(CommonAttributes.SOCKET_BINDING.getName()).set("http");
ModelNode addJGroupsDiscoveryGroup = Util.createAddOperation(discoveryGroupAddress("jgroups-group"));
addJGroupsDiscoveryGroup.get(CommonAttributes.JGROUPS_CLUSTER.getName()).set("default");
testUndefineAttrs(addSocketDiscoveryGroup, addJGroupsDiscoveryGroup);
}
@Test
public void testUndefineBroadcastGroupAttrs() throws Exception {
ModelNode addSocketBroadcastGroup = Util.createAddOperation(broadcastGroupAddress("socket-group"));
addSocketBroadcastGroup.get(CommonAttributes.CONNECTORS).setEmptyList().add("in-vm");
addSocketBroadcastGroup.get(CommonAttributes.SOCKET_BINDING.getName()).set("http");
ModelNode addJGroupsBroadcastGroup = Util.createAddOperation(broadcastGroupAddress("jgroups-group"));
addJGroupsBroadcastGroup.get(CommonAttributes.CONNECTORS).setEmptyList().add("in-vm");
addJGroupsBroadcastGroup.get(CommonAttributes.JGROUPS_CLUSTER.getName()).set("default");
testUndefineAttrs(addSocketBroadcastGroup, addJGroupsBroadcastGroup);
}
private void testUndefineAttrs(ModelNode addSocketGroupTemplate, ModelNode addJGroupsGroupTemplate) throws Exception {
KernelServices kernelServices = createKernelServices();
// create socket-*-group to work with
ModelNode result = kernelServices.executeOperation(addSocketGroupTemplate);
Assert.assertEquals(result.get(FAILURE_DESCRIPTION).asString(), SUCCESS, result.get(OUTCOME).asString());
// create jgroups-*-group to work with
result = kernelServices.executeOperation(addJGroupsGroupTemplate);
Assert.assertEquals(result.get(FAILURE_DESCRIPTION).asString(), SUCCESS, result.get(OUTCOME).asString());
// try to undefine socket-binding from socket-*-group
PathAddress socketGroupAddress = PathAddress.pathAddress(addSocketGroupTemplate.get(ADDRESS));
ModelNode op = Util.getUndefineAttributeOperation(socketGroupAddress, CommonAttributes.SOCKET_BINDING.getName());
result = kernelServices.executeOperation(op);
Assert.assertEquals(FAILED, result.get(OUTCOME).asString());
Assert.assertTrue("Failure description doesn't match: " + result.get(FAILURE_DESCRIPTION).asString(),
result.get(FAILURE_DESCRIPTION).asString().contains("WFLYCTL0231"));
Assert.assertTrue("Failure description doesn't match: " + result.get(FAILURE_DESCRIPTION).asString(),
result.get(FAILURE_DESCRIPTION).asString().contains(CommonAttributes.SOCKET_BINDING.getName()));
Assert.assertFalse("Failure description doesn't match: " + result.get(FAILURE_DESCRIPTION).asString(),
result.get(FAILURE_DESCRIPTION).asString().contains(CommonAttributes.JGROUPS_CLUSTER.getName()));
// try to undefine jgroups-cluster from jgroups-*-group
PathAddress jgroupsGroupAddress = PathAddress.pathAddress(addJGroupsGroupTemplate.get(ADDRESS));
op = Util.getUndefineAttributeOperation(jgroupsGroupAddress, CommonAttributes.JGROUPS_CLUSTER.getName());
result = kernelServices.executeOperation(op);
Assert.assertEquals(FAILED, result.get(OUTCOME).asString());
Assert.assertTrue("Failure description doesn't match: " + result.get(FAILURE_DESCRIPTION).asString(),
result.get(FAILURE_DESCRIPTION).asString().contains("WFLYCTL0231:"));
Assert.assertFalse("Failure description doesn't match: " + result.get(FAILURE_DESCRIPTION).asString(),
result.get(FAILURE_DESCRIPTION).asString().contains(CommonAttributes.SOCKET_BINDING.getName()));
Assert.assertTrue("Failure description doesn't match: " + result.get(FAILURE_DESCRIPTION).asString(),
result.get(FAILURE_DESCRIPTION).asString().contains(CommonAttributes.JGROUPS_CLUSTER.getName()));
// try to undefine jgroups-cluster attribute in socket-*-group, operation should succeed (it should be ignored)
op = Util.getUndefineAttributeOperation(socketGroupAddress, CommonAttributes.JGROUPS_CLUSTER.getName());
result = kernelServices.executeOperation(op);
Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
// try to undefine socket-binding attribute in jgroups-*-group, operation should succeed (it should be ignored)
op = Util.getUndefineAttributeOperation(jgroupsGroupAddress, CommonAttributes.SOCKET_BINDING.getName());
result = kernelServices.executeOperation(op);
Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
}
private KernelServices createKernelServices() throws Exception {
KernelServices kernelServices = createKernelServicesBuilder(createAdditionalInitialization())
.setSubsystemXml(readResource("subsystem_15_0.xml"))
.build();
Assert.assertTrue("Subsystem boot failed!", kernelServices.isSuccessfulBoot());
return kernelServices;
}
private static void removeResource(KernelServices kernelServices, ModelNode address) {
ModelNode op = Util.createRemoveOperation(PathAddress.pathAddress(address));
ModelNode result = kernelServices.executeOperation(op);
Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
}
private AdditionalInitialization createAdditionalInitialization() {
return AdditionalInitialization.withCapabilities(ClusteringRequirement.COMMAND_DISPATCHER_FACTORY.resolve("ee"),
ClusteringDefaultRequirement.COMMAND_DISPATCHER_FACTORY.getName(),
JGroupsDefaultRequirement.CHANNEL_FACTORY.getName(),
Capabilities.ELYTRON_DOMAIN_CAPABILITY,
Capabilities.ELYTRON_DOMAIN_CAPABILITY + ".elytronDomain",
CredentialReference.CREDENTIAL_STORE_CAPABILITY + ".cs1",
Capabilities.DATA_SOURCE_CAPABILITY + ".fooDS",
"org.wildfly.messaging.activemq.connector.external.in-vm",
"org.wildfly.messaging.activemq.connector.external.client",
"org.wildfly.remoting.http-listener-registry",
Capabilities.HTTP_UPGRADE_REGISTRY_CAPABILITY_NAME + ".default");
}
}
| 12,052
| 57.227053
| 153
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/test/java/org/wildfly/extension/messaging/activemq/broadcast/ConcurrentBroadcastCommandDispatcherFactoryTestCase.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 static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.same;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import org.junit.Assert;
import org.junit.Test;
import org.wildfly.clustering.Registration;
import org.wildfly.clustering.dispatcher.CommandDispatcher;
import org.wildfly.clustering.dispatcher.CommandDispatcherFactory;
import org.wildfly.clustering.group.Group;
/**
* @author Paul Ferraro
*/
public class ConcurrentBroadcastCommandDispatcherFactoryTestCase {
private final org.wildfly.clustering.server.dispatcher.CommandDispatcherFactory factory = mock(org.wildfly.clustering.server.dispatcher.CommandDispatcherFactory.class);
@Test
public void registration() {
BroadcastReceiver receiver1 = mock(BroadcastReceiver.class);
BroadcastReceiver receiver2 = mock(BroadcastReceiver.class);
BroadcastReceiverRegistrar registrar = new ConcurrentBroadcastCommandDispatcherFactory(this.factory);
byte[] data1 = new byte[] { 1 };
byte[] data2 = new byte[] { 2 };
byte[] data3 = new byte[] { 3 };
try (Registration registration1 = registrar.register(receiver1)) {
try (Registration registration2 = registrar.register(receiver2)) {
registrar.receive(data1);
verify(receiver1).receive(data1);
verify(receiver2).receive(data1);
}
registrar.receive(data2);
verify(receiver1).receive(data2);
verifyNoMoreInteractions(receiver2);
}
registrar.receive(data3);
verifyNoMoreInteractions(receiver1);
verifyNoMoreInteractions(receiver2);
}
@Test
public void getGroup() {
Group group = mock(Group.class);
CommandDispatcherFactory factory = new ConcurrentBroadcastCommandDispatcherFactory(this.factory);
when(this.factory.getGroup()).thenReturn(group);
Group result = factory.getGroup();
Assert.assertSame(group, result);
}
@Test
public void createCommandDispatcher() {
CommandDispatcher<Object> dispatcher = mock(CommandDispatcher.class);
Object id = new Object();
Object context = new Object();
CommandDispatcherFactory factory = new ConcurrentBroadcastCommandDispatcherFactory(this.factory);
when(this.factory.createCommandDispatcher(same(id), any(), any())).thenReturn(dispatcher);
when(dispatcher.getContext()).thenReturn(context);
// Verify that dispatcher does not close until all created dispatchers are closed
try (CommandDispatcher<Object> dispatcher1 = factory.createCommandDispatcher(id, new Object())) {
Assert.assertSame(context, dispatcher1.getContext());
try (CommandDispatcher<Object> dispatcher2 = factory.createCommandDispatcher(id, new Object())) {
Assert.assertSame(context, dispatcher2.getContext());
}
verify(dispatcher, never()).close();
}
verify(dispatcher).close();
}
}
| 4,318
| 37.5625
| 172
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/test/java/org/wildfly/extension/messaging/activemq/jms/AttributesTestBase.java
|
package org.wildfly.extension.messaging.activemq.jms;
import static java.beans.Introspector.getBeanInfo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.beans.PropertyDescriptor;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
public class AttributesTestBase {
protected static void compare(String name1, SortedSet<String> set1,
String name2, SortedSet<String> set2) {
Set<String> onlyInSet1 = new TreeSet<String>(set1);
onlyInSet1.removeAll(set2);
Set<String> onlyInSet2 = new TreeSet<String>(set2);
onlyInSet2.removeAll(set1);
if (!onlyInSet1.isEmpty() || !onlyInSet2.isEmpty()) {
fail(String.format("in %s only: %s\nin %s only: %s", name1, onlyInSet1, name2, onlyInSet2));
}
assertEquals(set2, set1);
}
protected SortedSet<String> findAllPropertyNames(Class<?> clazz) throws Exception {
SortedSet<String> names = new TreeSet<String>();
for (PropertyDescriptor propDesc : getBeanInfo(clazz).getPropertyDescriptors()) {
if (propDesc == null
|| propDesc.getWriteMethod() == null) {
continue;
}
names.add(propDesc.getDisplayName());
}
return names;
}
}
| 1,336
| 30.093023
| 104
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/test/java/org/wildfly/extension/messaging/activemq/jms/PooledConnectionFactoryAttributesTestCase.java
|
package org.wildfly.extension.messaging.activemq.jms;
import java.util.SortedSet;
import java.util.TreeSet;
import org.apache.activemq.artemis.ra.ActiveMQResourceAdapter;
import org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes.Pooled;
import org.junit.Test;
public class PooledConnectionFactoryAttributesTestCase extends AttributesTestBase{
private static final SortedSet<String> UNSUPPORTED_ACTIVEMQ_RA_PROPERTIES;
private static final SortedSet<String> KNOWN_ATTRIBUTES;
static {
UNSUPPORTED_ACTIVEMQ_RA_PROPERTIES = new TreeSet<String>();
// we configure discovery group using discoveryGroupName instead of individual params:
UNSUPPORTED_ACTIVEMQ_RA_PROPERTIES.add(PooledConnectionFactoryService.GROUP_ADDRESS);
UNSUPPORTED_ACTIVEMQ_RA_PROPERTIES.add(PooledConnectionFactoryService.GROUP_PORT);
UNSUPPORTED_ACTIVEMQ_RA_PROPERTIES.add(PooledConnectionFactoryService.REFRESH_TIMEOUT);
UNSUPPORTED_ACTIVEMQ_RA_PROPERTIES.add(PooledConnectionFactoryService.DISCOVERY_LOCAL_BIND_ADDRESS);
UNSUPPORTED_ACTIVEMQ_RA_PROPERTIES.add(PooledConnectionFactoryService.DISCOVERY_INITIAL_WAIT_TIMEOUT);
// these properties must not be exposed by the AS7 messaging subsystem
UNSUPPORTED_ACTIVEMQ_RA_PROPERTIES.add(PooledConnectionFactoryService.CONNECTION_PARAMETERS);
UNSUPPORTED_ACTIVEMQ_RA_PROPERTIES.add(PooledConnectionFactoryService.CONNECTOR_CLASSNAME);
UNSUPPORTED_ACTIVEMQ_RA_PROPERTIES.add("managedConnectionFactory");
UNSUPPORTED_ACTIVEMQ_RA_PROPERTIES.add(PooledConnectionFactoryService.JGROUPS_CHANNEL_LOCATOR_CLASS);
UNSUPPORTED_ACTIVEMQ_RA_PROPERTIES.add(PooledConnectionFactoryService.JGROUPS_CHANNEL_REF_NAME);
UNSUPPORTED_ACTIVEMQ_RA_PROPERTIES.add(PooledConnectionFactoryService.JGROUPS_CHANNEL_NAME);
UNSUPPORTED_ACTIVEMQ_RA_PROPERTIES.add(PooledConnectionFactoryService.IGNORE_JTA);
UNSUPPORTED_ACTIVEMQ_RA_PROPERTIES.add("jgroupsFile");
// these 2 props will *not* be supported since AS7 relies on vaulted passwords + expressions instead
UNSUPPORTED_ACTIVEMQ_RA_PROPERTIES.add("passwordCodec");
UNSUPPORTED_ACTIVEMQ_RA_PROPERTIES.add("useMaskedPassword");
UNSUPPORTED_ACTIVEMQ_RA_PROPERTIES.add("connectionPoolName");
UNSUPPORTED_ACTIVEMQ_RA_PROPERTIES.add("cacheDestinations");
UNSUPPORTED_ACTIVEMQ_RA_PROPERTIES.add("ignoreJTA");
UNSUPPORTED_ACTIVEMQ_RA_PROPERTIES.add("enable1xPrefixes");
KNOWN_ATTRIBUTES = new TreeSet<String>();
// these are supported but it is not found by JavaBeans introspector because of the type
// difference b/w the getter and the setters (Long vs long)
KNOWN_ATTRIBUTES.add(Pooled.SETUP_ATTEMPTS_PROP_NAME);
KNOWN_ATTRIBUTES.add(Pooled.SETUP_INTERVAL_PROP_NAME);
KNOWN_ATTRIBUTES.add(Pooled.USE_JNDI_PROP_NAME);
KNOWN_ATTRIBUTES.add(Pooled.REBALANCE_CONNECTIONS_PROP_NAME);
KNOWN_ATTRIBUTES.add(Pooled.ALLOW_LOCAL_TRANSACTIONS_PROP_NAME);
}
@Test
public void compareWildFlyPooledConnectionFactoryAndActiveMQConnectionFactoryProperties() throws Exception {
SortedSet<String> pooledConnectionFactoryAttributes = findAllResourceAdapterProperties(PooledConnectionFactoryDefinition.ATTRIBUTES);
pooledConnectionFactoryAttributes.removeAll(KNOWN_ATTRIBUTES);
SortedSet<String> activemqRAProperties = findAllPropertyNames(ActiveMQResourceAdapter.class);
activemqRAProperties.removeAll(UNSUPPORTED_ACTIVEMQ_RA_PROPERTIES);
compare("AS7 PooledConnectionFactoryAttributes", pooledConnectionFactoryAttributes,
"ActiveMQ Resource Adapter", activemqRAProperties);
}
private static SortedSet<String> findAllResourceAdapterProperties(ConnectionFactoryAttribute... attrs) {
SortedSet<String> names = new TreeSet<String>();
for (ConnectionFactoryAttribute attr : attrs) {
if (attr.isResourceAdapterProperty()) {
names.add(attr.getPropertyName());
}
}
return names;
}
}
| 4,138
| 54.932432
| 141
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/JGroupsBroadcastGroupAdd.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.BroadcastGroupDefinition.CONNECTOR_REFS;
import static org.wildfly.extension.messaging.activemq.BroadcastGroupDefinition.JGROUPS_CHANNEL;
import static org.wildfly.extension.messaging.activemq.BroadcastGroupDefinition.JGROUPS_CHANNEL_FACTORY;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.JGROUPS_CLUSTER;
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.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.ReloadRequiredAddStepHandler;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.operations.common.Util;
import org.jboss.as.controller.registry.Resource;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.Property;
import org.wildfly.extension.messaging.activemq.broadcast.BroadcastCommandDispatcherFactory;
import org.wildfly.extension.messaging.activemq.broadcast.CommandDispatcherBroadcastEndpointFactory;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* Handler for adding a broadcast group using JGroups.
* @author Emmanuel Hugonnet (c) 2019 Red Hat, Inc.
*/
public class JGroupsBroadcastGroupAdd extends ReloadRequiredAddStepHandler {
public static final JGroupsBroadcastGroupAdd INSTANCE = new JGroupsBroadcastGroupAdd(true);
public static final JGroupsBroadcastGroupAdd LEGACY_INSTANCE = new JGroupsBroadcastGroupAdd(false);
private final boolean needLegacyCall;
private JGroupsBroadcastGroupAdd(boolean needLegacyCall) {
super(JGroupsBroadcastGroupDefinition.ATTRIBUTES);
this.needLegacyCall= needLegacyCall;
}
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
CommonAttributes.renameChannelToCluster(operation);
if (operation.hasDefined(JGROUPS_CLUSTER.getName())
&& operation.hasDefined(JGROUPS_CHANNEL_FACTORY.getName())
&& !operation.hasDefined(JGROUPS_CHANNEL.getName())) {
// Handle legacy behavior
String channel = operation.get(JGROUPS_CLUSTER.getName()).asString();
operation.get(JGROUPS_CHANNEL.getName()).set(channel);
PathAddress channelAddress = context.getCurrentAddress().getParent().getParent().getParent()
.append(ModelDescriptionConstants.SUBSYSTEM, "jgroups").append("channel", channel);
ModelNode addChannelOperation = Util.createAddOperation(channelAddress);
addChannelOperation.get("stack").set(operation.get(JGROUPS_CHANNEL_FACTORY.getName()));
// Fabricate a channel resource if it is missing
context.addStep(addChannelOperation, AddIfAbsentStepHandler.INSTANCE, OperationContext.Stage.MODEL);
}
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 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 {
BroadcastGroupWriteAttributeHandler.JGROUP_INSTANCE.validateConnectors(context, operation, connectorRefs);
}
}, OperationContext.Stage.MODEL);
}
}
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()));
}
}
}
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 BroadcastCommandDispatcherFactory commandDispatcherFactory, final String channelName) throws Exception {
final long broadcastPeriod = config.getBroadcastPeriod();
final List<String> connectorRefs = config.getConnectorInfos();
final BroadcastEndpointFactory endpointFactory = new CommandDispatcherBroadcastEndpointFactory(commandDispatcherFactory, channelName);
return new BroadcastGroupConfiguration()
.setName(name)
.setBroadcastPeriod(broadcastPeriod)
.setConnectorInfos(connectorRefs)
.setEndpointFactory(endpointFactory);
}
}
| 7,847
| 52.387755
| 244
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/AddressSettingRemove.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.jboss.as.controller.AbstractRemoveStepHandler;
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;
/**
* {@code OperationStepHandler} removing an existing address setting.
*
* @author Emanuel Muckenhuber
*/
class AddressSettingRemove extends AbstractRemoveStepHandler {
static final OperationStepHandler INSTANCE = new AddressSettingRemove();
@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
final ActiveMQServer server = getActiveMQServer(context, operation);
if (server != null) {
final PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
server.getAddressSettingsRepository().removeMatch(address.getLastElement().getValue());
}
}
}
| 2,367
| 42.054545
| 149
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/ActiveMQServerService.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.wildfly.extension.messaging.activemq.logging.MessagingLogger.ROOT_LOGGER;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Supplier;
import javax.management.MBeanServer;
import javax.net.ssl.SSLContext;
import javax.sql.DataSource;
import org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration;
import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
import org.apache.activemq.artemis.api.core.Interceptor;
import org.apache.activemq.artemis.api.core.TransportConfiguration;
import org.apache.activemq.artemis.core.config.BridgeConfiguration;
import org.apache.activemq.artemis.core.config.Configuration;
import org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration;
import org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.JournalType;
import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
import org.apache.activemq.artemis.jdbc.store.sql.PropertySQLProvider;
import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
import org.jboss.as.controller.services.path.AbsolutePathService;
import org.jboss.as.controller.services.path.PathManager;
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.jboss.msc.value.InjectedValue;
import org.wildfly.common.function.ExceptionSupplier;
import org.wildfly.extension.messaging.activemq.broadcast.BroadcastCommandDispatcherFactory;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
import org.wildfly.security.auth.server.SecurityDomain;
import org.wildfly.security.credential.PasswordCredential;
import org.wildfly.security.credential.source.CredentialSource;
import org.wildfly.security.password.interfaces.ClearPassword;
/**
* Service configuring and starting the {@code ActiveMQServerService}.
*
* @author scott.stark@jboss.org
* @author Emanuel Muckenhuber
*/
class ActiveMQServerService implements Service<ActiveMQServer> {
/** */
private static final String HOST = "host";
private static final String PORT = "port";
/**
* The name of the SocketBinding reference to use for HOST/PORT
* configuration
*/
private static final String SOCKET_REF = RemoteTransportDefinition.SOCKET_BINDING.getName();
private Configuration configuration;
private ActiveMQServer server;
private final PathConfig pathConfig;
private final List<Interceptor> incomingInterceptors;
private final List<Interceptor> outgoingInterceptors;
private final Map<String, Supplier<SocketBinding>> socketBindings;
private final Map<String, Supplier<OutboundSocketBinding>> outboundSocketBindings;
private final Map<String, Supplier<SocketBinding>> groupBindings;
// Supplier for PathManagerService
private final Supplier<PathManager> pathManager;
// Supplier for JMX MBeanServer
private final Optional<Supplier<MBeanServer>> mbeanServer;
// Supplier for DataSource for JDBC store
private final Optional<Supplier<DataSource>> dataSource;
// mapping between the {broadcast|discovery}-groups and the cluster names they use
private final Map<String, String> clusterNames;
// mapping between the {broadcast|discovery}-groups and the command dispatcher factory they use
private final Map<String, Supplier<BroadcastCommandDispatcherFactory>> commandDispatcherFactories;
// Supplier for Elytron SecurityDomain
private final Optional<Supplier<SecurityDomain>> elytronSecurityDomain;
// Supplier for Elytron SSLContext
private final Map<String, Supplier<SSLContext>> sslContexts;
// credential source injectors
private Map<String, InjectedValue<ExceptionSupplier<CredentialSource, Exception>>> bridgeCredentialSource = new HashMap<>();
private InjectedValue<ExceptionSupplier<CredentialSource, Exception>> clusterCredentialSource = new InjectedValue<>();
public ActiveMQServerService(Configuration configuration,
PathConfig pathConfig,
Supplier<PathManager> pathManager,
List<Interceptor> incomingInterceptors,
List<Interceptor> outgoingInterceptors,
Map<String, Supplier<SocketBinding>> socketBindings,
Map<String, Supplier<OutboundSocketBinding>> outboundSocketBindings,
Map<String, Supplier<SocketBinding>> groupBindings,
Map<String, Supplier<BroadcastCommandDispatcherFactory>> commandDispatcherFactories,
Map<String, String> clusterNames,
Optional<Supplier<SecurityDomain>> elytronSecurityDomain,
Optional<Supplier<MBeanServer>> mbeanServer,
Optional<Supplier<DataSource>> dataSource,
Map<String, Supplier<SSLContext>> sslContexts) {
this.configuration = configuration;
this.pathConfig = pathConfig;
this.dataSource = dataSource;
this.mbeanServer = mbeanServer;
this.pathManager = pathManager;
this.elytronSecurityDomain = elytronSecurityDomain;
this.incomingInterceptors = incomingInterceptors;
this.outgoingInterceptors = outgoingInterceptors;
this.socketBindings = socketBindings;
this.outboundSocketBindings = outboundSocketBindings;
this.groupBindings = groupBindings;
this.commandDispatcherFactories = commandDispatcherFactories;
this.clusterNames = clusterNames;
if (configuration != null) {
for (BridgeConfiguration bridgeConfiguration : configuration.getBridgeConfigurations()) {
bridgeCredentialSource.put(bridgeConfiguration.getName(), new InjectedValue<>());
}
}
this.sslContexts = sslContexts;
}
@Override
public synchronized void start(final StartContext context) throws StartException {
ClassLoader origTCCL = org.wildfly.security.manager.WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
// Validate whether the AIO native layer can be used
JournalType jtype = configuration.getJournalType();
if (jtype == JournalType.ASYNCIO) {
boolean supportsAIO = AIOSequentialFileFactory.isSupported();
if (supportsAIO == false) {
String osName = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
if (osName.contains("nux")){
ROOT_LOGGER.aioInfoLinux();
} else {
ROOT_LOGGER.aioInfo();
}
configuration.setJournalType(JournalType.NIO);
}
}
// Setup paths
configuration.setBindingsDirectory(pathConfig.resolveBindingsPath(pathManager.get()));
configuration.setLargeMessagesDirectory(pathConfig.resolveLargeMessagePath(pathManager.get()));
configuration.setJournalDirectory(pathConfig.resolveJournalPath(pathManager.get()));
configuration.setPagingDirectory(pathConfig.resolvePagingPath(pathManager.get()));
pathConfig.registerCallbacks(pathManager.get());
for (Map.Entry<String, Supplier<SSLContext>> entry : sslContexts.entrySet()) {
org.jboss.activemq.artemis.wildfly.integration.WildFlySSLContextFactory.registerSSLContext(entry.getKey(), entry.getValue().get());
}
try {
// Update the acceptor/connector port/host values from the
// Map the socket bindings onto the connectors/acceptors
Collection<TransportConfiguration> acceptors = configuration.getAcceptorConfigurations();
Collection<TransportConfiguration> connectors = configuration.getConnectorConfigurations().values();
Collection<BroadcastGroupConfiguration> broadcastGroups = configuration.getBroadcastGroupConfigurations();
Map<String, DiscoveryGroupConfiguration> discoveryGroups = configuration.getDiscoveryGroupConfigurations();
TransportConfigOperationHandlers.processConnectorBindings(connectors, socketBindings, outboundSocketBindings);
if (acceptors != null) {
for (TransportConfiguration tc : acceptors) {
// If there is a socket binding set the HOST/PORT values
Object socketRef = tc.getParams().remove(SOCKET_REF);
if (socketRef != null) {
String name = socketRef.toString();
SocketBinding binding = socketBindings.get(name).get();
if (binding == null) {
throw MessagingLogger.ROOT_LOGGER.failedToFindConnectorSocketBinding(tc.getName());
}
binding.getSocketBindings().getNamedRegistry().registerBinding(ManagedBinding.Factory.createSimpleManagedBinding(binding));
InetSocketAddress socketAddress = binding.getSocketAddress();
tc.getParams().put(HOST, socketAddress.getAddress().getHostAddress());
tc.getParams().put(PORT, socketAddress.getPort());
}
}
}
if(broadcastGroups != null) {
final List<BroadcastGroupConfiguration> newConfigs = new ArrayList<>();
for(final BroadcastGroupConfiguration config : broadcastGroups) {
final String name = config.getName();
final String key = "broadcast" + name;
if (commandDispatcherFactories.containsKey(key)) {
BroadcastCommandDispatcherFactory commandDispatcherFactory = commandDispatcherFactories.get(key).get();
String clusterName = clusterNames.get(key);
newConfigs.add(JGroupsBroadcastGroupAdd.createBroadcastGroupConfiguration(name, config, commandDispatcherFactory, clusterName));
} else {
final Supplier<SocketBinding> bindingSupplier = groupBindings.get(key);
if (bindingSupplier == null) {
throw MessagingLogger.ROOT_LOGGER.failedToFindBroadcastSocketBinding(name);
}
final SocketBinding binding = bindingSupplier.get();
binding.getSocketBindings().getNamedRegistry().registerBinding(ManagedBinding.Factory.createSimpleManagedBinding(binding));
newConfigs.add(SocketBroadcastGroupAdd.createBroadcastGroupConfiguration(name, config, binding));
}
}
configuration.getBroadcastGroupConfigurations().clear();
configuration.getBroadcastGroupConfigurations().addAll(newConfigs);
}
if(discoveryGroups != null) {
configuration.setDiscoveryGroupConfigurations(new HashMap<>());
for(final Map.Entry<String, DiscoveryGroupConfiguration> entry : discoveryGroups.entrySet()) {
final String name = entry.getKey();
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, entry.getValue(), commandDispatcherFactory, clusterName);
} else {
final Supplier<SocketBinding> binding = groupBindings.get(key);
if (binding == null) {
throw MessagingLogger.ROOT_LOGGER.failedToFindDiscoverySocketBinding(name);
}
config = SocketDiscoveryGroupAdd.createDiscoveryGroupConfiguration(name, entry.getValue(), binding.get());
binding.get().getSocketBindings().getNamedRegistry().registerBinding(ManagedBinding.Factory.createSimpleManagedBinding(binding.get()));
}
configuration.getDiscoveryGroupConfigurations().put(name, config);
}
}
// security - if an Elytron domain has been defined we delegate security checks to the Elytron based security manager.
final ActiveMQSecurityManager securityManager ;
if (configuration.isSecurityEnabled()) {
if (elytronSecurityDomain.isPresent()) {
securityManager = new ElytronSecurityManager(elytronSecurityDomain.get().get());
} else {
securityManager = new WildFlySecurityManager();
}
} else {
securityManager = null;
}
// insert possible credential source hold passwords
setBridgePasswordsFromCredentialSource();
setClusterPasswordFromCredentialSource();
if (dataSource.isPresent()) {
final DataSource ds = dataSource.get().get();
DatabaseStorageConfiguration dbConfiguration = (DatabaseStorageConfiguration) configuration.getStoreConfiguration();
dbConfiguration.setDataSource(ds);
// inject the datasource into the PropertySQLProviderFactory to be able to determine the
// type of database for the datasource metadata
PropertySQLProvider.Factory sqlProviderFactory = new PropertySQLProvider.Factory(ds);
dbConfiguration.setSqlProvider(sqlProviderFactory);
configuration.setStoreConfiguration(dbConfiguration);
ROOT_LOGGER.infof("use JDBC store for Artemis server, bindingsTable:%s",
dbConfiguration.getBindingsTableName());
}
final MBeanServer mbs = mbeanServer.isPresent() ? mbeanServer.get().get() : null;
// Now start the server
server = new ActiveMQServerImpl(configuration,
mbs,
securityManager);
if (ServerDefinition.CLUSTER_PASSWORD.getDefaultValue().asString().equals(server.getConfiguration().getClusterPassword())) {
server.getConfiguration().setClusterPassword(java.util.UUID.randomUUID().toString());
}
for (Interceptor incomingInterceptor : incomingInterceptors) {
server.getServiceRegistry().addIncomingInterceptor(incomingInterceptor);
}
for (Interceptor outgoingInterceptor : outgoingInterceptors) {
server.getServiceRegistry().addOutgoingInterceptor(outgoingInterceptor);
}
// the server is actually started by the Jakarta Messaging Service.
} catch (Exception e) {
throw MessagingLogger.ROOT_LOGGER.failedToStartService(e);
} finally {
org.wildfly.security.manager.WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(origTCCL);
}
}
public synchronized void stop(final StopContext context) {
try {
if (server != null) {
for (Supplier<SocketBinding> binding : socketBindings.values()) {
if (binding != null) {
binding.get().getSocketBindings().getNamedRegistry().unregisterBinding(binding.get().getName());
}
}
for (Supplier<SocketBinding> binding : groupBindings.values()) {
if (binding != null) {
binding.get().getSocketBindings().getNamedRegistry().unregisterBinding(binding.get().getName());
}
}
// the server is actually stopped by the Jakarta Messaging Service
}
pathConfig.closeCallbacks(pathManager.get());
} catch (Exception e) {
throw MessagingLogger.ROOT_LOGGER.failedToShutdownServer(e, "Artemis");
}
}
@Override
public synchronized ActiveMQServer getValue() throws IllegalStateException {
final ActiveMQServer server = this.server;
if (server == null) {
throw new IllegalStateException();
}
return server;
}
BroadcastCommandDispatcherFactory getCommandDispatcherFactory(String key) {
return commandDispatcherFactories.get(key).get();
}
static class PathConfig {
private final String bindingsPath;
private final String bindingsRelativeToPath;
private final String journalPath;
private final String journalRelativeToPath;
private final String largeMessagePath;
private final String largeMessageRelativeToPath;
private final String pagingPath;
private final String pagingRelativeToPath;
private final List<PathManager.Callback.Handle> callbackHandles = new ArrayList<PathManager.Callback.Handle>();
public PathConfig(String bindingsPath, String bindingsRelativeToPath, String journalPath, String journalRelativeToPath,
String largeMessagePath, String largeMessageRelativeToPath, String pagingPath, String pagingRelativeToPath) {
this.bindingsPath = bindingsPath;
this.bindingsRelativeToPath = bindingsRelativeToPath;
this.journalPath = journalPath;
this.journalRelativeToPath = journalRelativeToPath;
this.largeMessagePath = largeMessagePath;
this.largeMessageRelativeToPath = largeMessageRelativeToPath;
this.pagingPath = pagingPath;
this.pagingRelativeToPath = pagingRelativeToPath;
}
String resolveBindingsPath(PathManager pathManager) {
return resolve(pathManager, bindingsPath, bindingsRelativeToPath);
}
String resolveJournalPath(PathManager pathManager) {
return resolve(pathManager, journalPath, journalRelativeToPath);
}
String resolveLargeMessagePath(PathManager pathManager) {
return resolve(pathManager, largeMessagePath, largeMessageRelativeToPath);
}
String resolvePagingPath(PathManager pathManager) {
return resolve(pathManager, pagingPath, pagingRelativeToPath);
}
String resolve(PathManager pathManager, String path, String relativeToPath) {
// discard the relativeToPath if the path is absolute and must not be resolved according
// to the default relativeToPath value
String relativeTo = AbsolutePathService.isAbsoluteUnixOrWindowsPath(path) ? null : relativeToPath;
return pathManager.resolveRelativePathEntry(path, relativeTo);
}
synchronized void registerCallbacks(PathManager pathManager) {
if (bindingsRelativeToPath != null) {
callbackHandles.add(pathManager.registerCallback(bindingsRelativeToPath, PathManager.ReloadServerCallback.create(), PathManager.Event.UPDATED, PathManager.Event.REMOVED));
}
if (journalRelativeToPath != null) {
callbackHandles.add(pathManager.registerCallback(journalRelativeToPath, PathManager.ReloadServerCallback.create(), PathManager.Event.UPDATED, PathManager.Event.REMOVED));
}
if (largeMessageRelativeToPath != null) {
callbackHandles.add(pathManager.registerCallback(largeMessageRelativeToPath, PathManager.ReloadServerCallback.create(), PathManager.Event.UPDATED, PathManager.Event.REMOVED));
}
if (pagingRelativeToPath != null) {
callbackHandles.add(pathManager.registerCallback(pagingRelativeToPath, PathManager.ReloadServerCallback.create(), PathManager.Event.UPDATED, PathManager.Event.REMOVED));
}
}
synchronized void closeCallbacks(PathManager pathManager) {
for (PathManager.Callback.Handle callbackHandle : callbackHandles) {
callbackHandle.remove();
}
callbackHandles.clear();
}
}
/**
* Get {@link CredentialSource} injector based on name of the bridge.
* If name was not used create new injector.
* @param name the bridge name
* @return injector
*/
public InjectedValue<ExceptionSupplier<CredentialSource, Exception>> getBridgeCredentialSourceSupplierInjector(String name) {
if (bridgeCredentialSource.containsKey(name)) {
return bridgeCredentialSource.get(name);
} else {
InjectedValue<ExceptionSupplier<CredentialSource, Exception>> injector = new InjectedValue<>();
bridgeCredentialSource.put(name, injector);
return injector;
}
}
/**
* Get {@link CredentialSource} injector based on name of the cluster credential.
* @return injector
*/
public InjectedValue<ExceptionSupplier<CredentialSource, Exception>> getClusterCredentialSourceSupplierInjector() {
return clusterCredentialSource;
}
private void setBridgePasswordsFromCredentialSource() {
if (configuration != null) {
for (BridgeConfiguration bridgeConfiguration : configuration.getBridgeConfigurations()) {
setNewPassword(getBridgeCredentialSourceSupplierInjector(bridgeConfiguration.getName()).getOptionalValue(), bridgeConfiguration::setPassword);
}
}
}
private void setClusterPasswordFromCredentialSource() {
if (configuration != null)
setNewPassword(getClusterCredentialSourceSupplierInjector().getOptionalValue(), configuration::setClusterPassword);
}
private void setNewPassword(ExceptionSupplier<CredentialSource, Exception> credentialSourceSupplier, Consumer<String> passwordConsumer) {
if (credentialSourceSupplier != null) {
try {
CredentialSource credentialSource = credentialSourceSupplier.get();
if (credentialSource != null) {
char[] password = credentialSource.getCredential(PasswordCredential.class).getPassword(ClearPassword.class).getPassword();
if (password != null) {
passwordConsumer.accept(new String(password));
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
}
| 24,334
| 51.446121
| 191
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/ActiveMQReloadRequiredHandlers.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 java.util.Collection;
import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.AbstractRemoveStepHandler;
import org.jboss.as.controller.AbstractWriteAttributeHandler;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.registry.Resource;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
/**
* Requires a reload only if the {@link ActiveMQServerService} service is up and running.
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat, inc
*/
public interface ActiveMQReloadRequiredHandlers {
static class AddStepHandler extends AbstractAddStepHandler {
private boolean reloadRequired = false;
public AddStepHandler(Collection<? extends AttributeDefinition> attributes) {
super(attributes);
}
public AddStepHandler(AttributeDefinition... attributes) {
super(attributes);
}
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
if (isServiceInstalled(context)) {
context.reloadRequired();
reloadRequired = true;
}
}
@Override
protected void rollbackRuntime(OperationContext context, ModelNode operation, Resource resource) {
if (reloadRequired && isServiceInstalled(context)) {
context.revertReloadRequired();
}
}
}
final class RemoveStepHandler extends AbstractRemoveStepHandler {
private boolean reloadRequired = false;
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
if (isServiceInstalled(context)) {
context.reloadRequired();
reloadRequired = true;
}
}
@Override
protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
if (reloadRequired && isServiceInstalled(context)) {
context.revertReloadRequired();
}
}
}
static class WriteAttributeHandler extends AbstractWriteAttributeHandler<Void> {
public WriteAttributeHandler(Collection<? extends AttributeDefinition> definitions) {
super(definitions.toArray(new AttributeDefinition[definitions.size()]));
}
public WriteAttributeHandler(AttributeDefinition... definitions) {
super(definitions);
}
@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName,
ModelNode resolvedValue, ModelNode currentValue,
HandbackHolder<Void> handbackHolder)
throws OperationFailedException {
return isServiceInstalled(context);
}
@Override
protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName,
ModelNode valueToRestore, ModelNode valueToRevert, Void handback) throws OperationFailedException {
if (isServiceInstalled(context)) {
context.revertReloadRequired();
}
}
}
/**
* Returns true if a {@link ServiceController} for this service has been {@link org.jboss.msc.service.ServiceBuilder#install() installed}
* in MSC under the
* {@link MessagingServices#getActiveMQServiceName(org.jboss.as.controller.PathAddress) service name appropriate to the given operation}.
*
* @param context the operation context
* @return {@code true} if a {@link ServiceController} is installed
*/
static boolean isServiceInstalled(final OperationContext context) {
if (context.isNormalServer()) {
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(context.getCurrentAddress());
if (serviceName != null) {
return context.getServiceRegistry(false).getService(serviceName) != null;
}
}
return false;
}
}
| 5,479
| 39.294118
| 141
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/RemoteTransportDefinition.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 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;
/**
* remote transports resource definition
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat Inc.
*/
public class RemoteTransportDefinition extends AbstractTransportDefinition {
// for remote acceptor, the socket-binding is required
public static final SimpleAttributeDefinition SOCKET_BINDING = create(GenericTransportDefinition.SOCKET_BINDING)
.setRequired(true)
.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();
static AttributeDefinition[] ATTRIBUTES = {SOCKET_BINDING, CommonAttributes.PARAMS, CommonAttributes.SSL_CONTEXT};
static RemoteTransportDefinition createAcceptorDefinition(boolean registerRuntimeOnly) {
return new RemoteTransportDefinition(true, CommonAttributes.REMOTE_ACCEPTOR, registerRuntimeOnly);
}
static RemoteTransportDefinition createConnectorDefinition(boolean registerRuntimeOnly) {
return new RemoteTransportDefinition(false, CommonAttributes.REMOTE_CONNECTOR, registerRuntimeOnly);
}
private RemoteTransportDefinition(boolean isAcceptor, String specificType, boolean registerRuntimeOnly) {
super(isAcceptor, specificType, registerRuntimeOnly, ATTRIBUTES);
}
}
| 3,253
| 46.15942
| 197
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/MessagingTransformerRegistration.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2018, 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.transform.description.RejectAttributeChecker.DEFINED;
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.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_PRIMARY_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.CONFIGURATION_SECONDARY_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.CONFIGURATION_SLAVE_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.SERVER_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.REPLICATION_COLOCATED_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.REPLICATION_MASTER_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.REPLICATION_PRIMARY_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.REPLICATION_SECONDARY_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.REPLICATION_SLAVE_PATH;
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.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_PRIMARY_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.SHARED_STORE_SECONDARY_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.SHARED_STORE_SLAVE_PATH;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.ModelVersion;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.transform.ExtensionTransformerRegistration;
import org.jboss.as.controller.transform.SubsystemTransformerRegistration;
import org.jboss.as.controller.transform.description.ChainedTransformationDescriptionBuilder;
import org.jboss.as.controller.transform.description.DiscardAttributeChecker;
import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder;
import org.jboss.as.controller.transform.description.TransformationDescriptionBuilder;
import org.kohsuke.MetaInfServices;
import org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryAttributes;
/**
* {@link ExtensionTransformerRegistration} for the messaging-activemq subsystem.
*
* @author Paul Ferraro
*/
@MetaInfServices
public class MessagingTransformerRegistration implements ExtensionTransformerRegistration {
@Override
public String getSubsystemName() {
return MessagingExtension.SUBSYSTEM_NAME;
}
@Override
public void registerTransformers(SubsystemTransformerRegistration registration) {
ChainedTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createChainedSubystemInstance(registration.getCurrentSubsystemVersion());
registerTransformers_WF_28(builder.createBuilder(MessagingExtension.VERSION_15_0_0, MessagingExtension.VERSION_14_0_0));
registerTransformers_WF_27(builder.createBuilder(MessagingExtension.VERSION_14_0_0, MessagingExtension.VERSION_13_1_0));
registerTransformers_WF_26_1(builder.createBuilder(MessagingExtension.VERSION_13_1_0, MessagingExtension.VERSION_13_0_0));
builder.buildAndRegister(registration, new ModelVersion[]{MessagingExtension.VERSION_13_0_0, MessagingExtension.VERSION_13_1_0,
MessagingExtension.VERSION_14_0_0, MessagingExtension.VERSION_15_0_0});
}
private static void registerTransformers_WF_28(ResourceTransformationDescriptionBuilder subsystem) {
ResourceTransformationDescriptionBuilder server = subsystem.addChildResource(SERVER_PATH);
server.addChildResource(PathElement.pathElement(REMOTE_ACCEPTOR)).getAttributeBuilder()
.addRejectCheck(DEFINED, CommonAttributes.SSL_CONTEXT)
.setDiscard(DiscardAttributeChecker.UNDEFINED, CommonAttributes.SSL_CONTEXT);
server.addChildResource(PathElement.pathElement(HTTP_ACCEPTOR)).getAttributeBuilder()
.addRejectCheck(DEFINED, CommonAttributes.SSL_CONTEXT)
.setDiscard(DiscardAttributeChecker.UNDEFINED, CommonAttributes.SSL_CONTEXT);
server.addChildResource(PathElement.pathElement(REMOTE_CONNECTOR)).getAttributeBuilder()
.addRejectCheck(DEFINED, CommonAttributes.SSL_CONTEXT)
.setDiscard(DiscardAttributeChecker.UNDEFINED, CommonAttributes.SSL_CONTEXT);
server.addChildResource(PathElement.pathElement(HTTP_CONNECTOR)).getAttributeBuilder()
.addRejectCheck(DEFINED, CommonAttributes.SSL_CONTEXT)
.setDiscard(DiscardAttributeChecker.UNDEFINED, CommonAttributes.SSL_CONTEXT);
}
private static void registerTransformers_WF_27(ResourceTransformationDescriptionBuilder subsystem) {
ResourceTransformationDescriptionBuilder externaljmsqueue = subsystem.addChildResource(MessagingExtension.EXTERNAL_JMS_QUEUE_PATH);
rejectDefinedAttributeWithDefaultValue(externaljmsqueue, ConnectionFactoryAttributes.External.ENABLE_AMQ1_PREFIX);
ResourceTransformationDescriptionBuilder externaljmstopic = subsystem.addChildResource(MessagingExtension.EXTERNAL_JMS_TOPIC_PATH);
rejectDefinedAttributeWithDefaultValue(externaljmstopic, ConnectionFactoryAttributes.External.ENABLE_AMQ1_PREFIX);
ResourceTransformationDescriptionBuilder externalConnectionFactory = subsystem.addChildResource(MessagingExtension.CONNECTION_FACTORY_PATH);
renameAttribute(externalConnectionFactory, DESERIALIZATION_BLACKLIST, DESERIALIZATION_BLOCKLIST);
renameAttribute(externalConnectionFactory, DESERIALIZATION_WHITELIST, DESERIALIZATION_ALLOWLIST);
ResourceTransformationDescriptionBuilder pooledExternalConnectionFactory = subsystem.addChildResource(MessagingExtension.POOLED_CONNECTION_FACTORY_PATH);
renameAttribute(pooledExternalConnectionFactory, DESERIALIZATION_BLACKLIST, DESERIALIZATION_BLOCKLIST);
renameAttribute(pooledExternalConnectionFactory, DESERIALIZATION_WHITELIST, DESERIALIZATION_ALLOWLIST);
ResourceTransformationDescriptionBuilder server = subsystem.addChildResource(MessagingExtension.SERVER_PATH);
ResourceTransformationDescriptionBuilder bridge = server.addChildResource(MessagingExtension.BRIDGE_PATH);
rejectDefinedAttributeWithDefaultValue(bridge, BridgeDefinition.ROUTING_TYPE);
ResourceTransformationDescriptionBuilder connectionFactory = server.addChildResource(MessagingExtension.CONNECTION_FACTORY_PATH);
renameAttribute(connectionFactory, DESERIALIZATION_BLACKLIST, DESERIALIZATION_BLOCKLIST);
renameAttribute(connectionFactory, DESERIALIZATION_WHITELIST, DESERIALIZATION_ALLOWLIST);
ResourceTransformationDescriptionBuilder pooledConnectionFactory = server.addChildResource(MessagingExtension.POOLED_CONNECTION_FACTORY_PATH);
renameAttribute(pooledConnectionFactory, DESERIALIZATION_BLACKLIST, DESERIALIZATION_BLOCKLIST);
renameAttribute(pooledConnectionFactory, DESERIALIZATION_WHITELIST, DESERIALIZATION_ALLOWLIST);
server.addChildRedirection(REPLICATION_PRIMARY_PATH, REPLICATION_MASTER_PATH);
server.addChildRedirection(REPLICATION_SECONDARY_PATH, REPLICATION_SLAVE_PATH);
server.addChildRedirection(SHARED_STORE_PRIMARY_PATH, SHARED_STORE_MASTER_PATH);
server.addChildRedirection(SHARED_STORE_SECONDARY_PATH, SHARED_STORE_SLAVE_PATH);
ResourceTransformationDescriptionBuilder colocatedSharedStore = server.addChildResource(SHARED_STORE_COLOCATED_PATH);
colocatedSharedStore.addChildRedirection(CONFIGURATION_PRIMARY_PATH, CONFIGURATION_MASTER_PATH);
colocatedSharedStore.addChildRedirection(CONFIGURATION_SECONDARY_PATH, CONFIGURATION_SLAVE_PATH);
ResourceTransformationDescriptionBuilder colocatedReplication = server.addChildResource(REPLICATION_COLOCATED_PATH);
colocatedReplication.addChildRedirection(CONFIGURATION_PRIMARY_PATH, CONFIGURATION_MASTER_PATH);
colocatedReplication.addChildRedirection(CONFIGURATION_SECONDARY_PATH, CONFIGURATION_SLAVE_PATH);
ResourceTransformationDescriptionBuilder addressSetting = server.addChildResource(MessagingExtension.ADDRESS_SETTING_PATH);
rejectDefinedAttributeWithDefaultValue(addressSetting,
AddressSettingDefinition.AUTO_DELETE_CREATED_QUEUES);
}
private static void registerTransformers_WF_26_1(ResourceTransformationDescriptionBuilder subsystem) {
ResourceTransformationDescriptionBuilder server = subsystem
.addChildResource(MessagingExtension.SERVER_PATH);
rejectDefinedAttributeWithDefaultValue(server, ServerDefinition.ADDRESS_QUEUE_SCAN_PERIOD);
}
/**
* Reject the attributes if they are defined or discard them if they are undefined or set to their default value.
*/
private static void rejectDefinedAttributeWithDefaultValue(ResourceTransformationDescriptionBuilder builder, AttributeDefinition... attrs) {
builder.getAttributeBuilder()
.setDiscard(DiscardAttributeChecker.DEFAULT_VALUE, attrs)
.addRejectCheck(DEFINED, attrs);
}
private static void renameAttribute(ResourceTransformationDescriptionBuilder resourceRegistry, AttributeDefinition attribute, AttributeDefinition newAttribute) {
resourceRegistry.getAttributeBuilder()
.setDiscard(DiscardAttributeChecker.UNDEFINED, newAttribute)
.addRename(newAttribute, attribute.getName());
}
}
| 11,611
| 69.804878
| 172
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/SecurityRoleResource.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.wildfly.extension.messaging.activemq.CommonAttributes.ROLE;
import java.util.Collections;
import java.util.Set;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.registry.Resource;
import org.jboss.dmr.ModelNode;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* Custom {@link Resource} that represents a messaging security role.
*/
public class SecurityRoleResource implements Resource {
public static final SecurityRoleResource INSTANCE = new SecurityRoleResource();
private SecurityRoleResource() {
}
@Override
public ModelNode getModel() {
return new ModelNode();
}
@Override
public void writeModel(ModelNode newModel) {
throw MessagingLogger.ROOT_LOGGER.immutableResource();
}
@Override
public boolean isModelDefined() {
return false;
}
@Override
public boolean hasChild(PathElement element) {
return false;
}
@Override
public Resource getChild(PathElement element) {
return null;
}
@Override
public Resource requireChild(PathElement element) {
throw new NoSuchResourceException(element);
}
@Override
public boolean hasChildren(String childType) {
return false;
}
@Override
public Resource navigate(PathAddress address) {
return Tools.navigate(this, address);
}
@Override
public Set<String> getChildTypes() {
return Collections.emptySet();
}
@Override
public Set<String> getOrderedChildTypes() {
return Collections.emptySet();
}
@Override
public Set<String> getChildrenNames(String childType) {
return Collections.emptySet();
}
@Override
public Set<ResourceEntry> getChildren(String childType) {
return Collections.emptySet();
}
@Override
public void registerChild(PathElement address, Resource resource) {
throw MessagingLogger.ROOT_LOGGER.immutableResource();
}
@Override
public void registerChild(PathElement pathElement, int i, Resource resource) {
throw MessagingLogger.ROOT_LOGGER.immutableResource();
}
@Override
public Resource removeChild(PathElement address) {
throw MessagingLogger.ROOT_LOGGER.immutableResource();
}
@Override
public boolean isRuntime() {
return true;
}
@Override
public boolean isProxy() {
return false;
}
@Override
public Resource clone() {
return new SecurityRoleResource();
}
public static class SecurityRoleResourceEntry extends SecurityRoleResource implements ResourceEntry {
final PathElement path;
public SecurityRoleResourceEntry(String name) {
path = PathElement.pathElement(ROLE, name);
}
@Override
public String getName() {
return path.getValue();
}
@Override
public PathElement getPathElement() {
return path;
}
@Override
public SecurityRoleResourceEntry clone() {
return new SecurityRoleResourceEntry(path.getValue());
}
}
}
| 4,318
| 25.99375
| 105
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/MessagingSubsystemAdd.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.apache.activemq.artemis.api.core.client.ActiveMQClient.SCHEDULED_THREAD_POOL_SIZE_PROPERTY_KEY;
import static org.apache.activemq.artemis.api.core.client.ActiveMQClient.THREAD_POOL_MAX_SIZE_PROPERTY_KEY;
import static org.jboss.as.server.services.net.SocketBindingResourceDefinition.SOCKET_BINDING_CAPABILITY;
import static org.jboss.as.weld.Capabilities.WELD_CAPABILITY_NAME;
import static org.wildfly.extension.messaging.activemq.Capabilities.OUTBOUND_SOCKET_BINDING_CAPABILITY;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.JGROUPS_BROADCAST_GROUP;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.JGROUPS_DISCOVERY_GROUP;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.JGROUPS_CLUSTER;
import static org.wildfly.extension.messaging.activemq.MessagingSubsystemRootResourceDefinition.CONFIGURATION_CAPABILITY;
import static org.wildfly.extension.messaging.activemq.MessagingSubsystemRootResourceDefinition.GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_MAX_SIZE;
import static org.wildfly.extension.messaging.activemq.MessagingSubsystemRootResourceDefinition.GLOBAL_CLIENT_THREAD_POOL_MAX_SIZE;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.function.BiConsumer;
import org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration;
import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
import org.apache.activemq.artemis.api.core.TransportConfiguration;
import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
import org.jboss.as.controller.AbstractBoottimeAddStepHandler;
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.registry.Resource;
import org.jboss.as.server.AbstractDeploymentChainStep;
import org.jboss.as.server.DeploymentProcessorTarget;
import org.jboss.as.server.deployment.Phase;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceBuilder;
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.extension.messaging.activemq.deployment.DefaultJMSConnectionFactoryBindingProcessor;
import org.wildfly.extension.messaging.activemq.deployment.DefaultJMSConnectionFactoryResourceReferenceProcessor;
import org.wildfly.extension.messaging.activemq.deployment.JMSConnectionFactoryDefinitionAnnotationProcessor;
import org.wildfly.extension.messaging.activemq.deployment.JMSConnectionFactoryDefinitionDescriptorProcessor;
import org.wildfly.extension.messaging.activemq.deployment.JMSDestinationDefinitionAnnotationProcessor;
import org.wildfly.extension.messaging.activemq.deployment.JMSDestinationDefinitionDescriptorProcessor;
import org.wildfly.extension.messaging.activemq.deployment.MessagingDependencyProcessor;
import org.wildfly.extension.messaging.activemq.deployment.MessagingXmlInstallDeploymentUnitProcessor;
import org.wildfly.extension.messaging.activemq.deployment.MessagingXmlParsingDeploymentUnitProcessor;
import org.wildfly.extension.messaging.activemq.deployment.injection.CDIDeploymentProcessor;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* Add handler for the messaging subsystem.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
class MessagingSubsystemAdd extends AbstractBoottimeAddStepHandler {
final BiConsumer<OperationContext, String> broadcastCommandDispatcherFactoryInstaller;
MessagingSubsystemAdd(BiConsumer<OperationContext, String> broadcastCommandDispatcherFactoryInstaller) {
super(MessagingSubsystemRootResourceDefinition.ATTRIBUTES);
this.broadcastCommandDispatcherFactoryInstaller = broadcastCommandDispatcherFactoryInstaller;
}
@Override
protected void performBoottime(final OperationContext context, ModelNode operation, final ModelNode model) throws OperationFailedException {
// Cache support for capability service name lookups by our services
MessagingServices.capabilityServiceSupport = context.getCapabilityServiceSupport();
context.addStep(new AbstractDeploymentChainStep() {
@Override
protected void execute(DeploymentProcessorTarget processorTarget) {
// keep the statements ordered by phase + priority
processorTarget.addDeploymentProcessor(MessagingExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_JMS_CONNECTION_FACTORY_RESOURCE_INJECTION, new DefaultJMSConnectionFactoryResourceReferenceProcessor());
processorTarget.addDeploymentProcessor(MessagingExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_RESOURCE_DEF_ANNOTATION_JMS_DESTINATION, new JMSDestinationDefinitionAnnotationProcessor());
processorTarget.addDeploymentProcessor(MessagingExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_RESOURCE_DEF_ANNOTATION_JMS_CONNECTION_FACTORY, new JMSConnectionFactoryDefinitionAnnotationProcessor(MessagingServices.capabilityServiceSupport.hasCapability("org.wildfly.legacy-security")));
processorTarget.addDeploymentProcessor(MessagingExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_MESSAGING_XML_RESOURCES, new MessagingXmlParsingDeploymentUnitProcessor());
processorTarget.addDeploymentProcessor(MessagingExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_JMS, new MessagingDependencyProcessor());
if (MessagingServices.capabilityServiceSupport.hasCapability(WELD_CAPABILITY_NAME)) {
processorTarget.addDeploymentProcessor(MessagingExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_JMS_CDI_EXTENSIONS, new CDIDeploymentProcessor());
}
processorTarget.addDeploymentProcessor(MessagingExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_RESOURCE_DEF_XML_JMS_CONNECTION_FACTORY, new JMSConnectionFactoryDefinitionDescriptorProcessor());
processorTarget.addDeploymentProcessor(MessagingExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_RESOURCE_DEF_XML_JMS_DESTINATION, new JMSDestinationDefinitionDescriptorProcessor());
processorTarget.addDeploymentProcessor(MessagingExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_DEFAULT_BINDINGS_JMS_CONNECTION_FACTORY, new DefaultJMSConnectionFactoryBindingProcessor());
processorTarget.addDeploymentProcessor(MessagingExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_MESSAGING_XML_RESOURCES, new MessagingXmlInstallDeploymentUnitProcessor());
}
}, OperationContext.Stage.RUNTIME);
ModelNode threadPoolMaxSize = operation.get(GLOBAL_CLIENT_THREAD_POOL_MAX_SIZE.getName());
ModelNode scheduledThreadPoolMaxSize = operation.get(GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_MAX_SIZE.getName());
Integer threadPoolMaxSizeValue;
Integer scheduledThreadPoolMaxSizeValue;
// if the attributes are defined, their value is used (and the system properties are ignored)
Properties sysprops = System.getProperties();
if (threadPoolMaxSize.isDefined()) {
threadPoolMaxSizeValue = GLOBAL_CLIENT_THREAD_POOL_MAX_SIZE.resolveModelAttribute(context, operation).asInt();
} else if (sysprops.containsKey(THREAD_POOL_MAX_SIZE_PROPERTY_KEY)) {
threadPoolMaxSizeValue = Integer.parseInt(sysprops.getProperty(THREAD_POOL_MAX_SIZE_PROPERTY_KEY));
} else {
// property is not configured using sysprop or explicit attribute
threadPoolMaxSizeValue = null;
}
if (scheduledThreadPoolMaxSize.isDefined()) {
scheduledThreadPoolMaxSizeValue = GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_MAX_SIZE.resolveModelAttribute(context, operation).asInt();
} else if (sysprops.containsKey(SCHEDULED_THREAD_POOL_SIZE_PROPERTY_KEY)) {
scheduledThreadPoolMaxSizeValue = Integer.parseInt(sysprops.getProperty(SCHEDULED_THREAD_POOL_SIZE_PROPERTY_KEY));
} else {
// property is not configured using sysprop or explicit attribute
scheduledThreadPoolMaxSizeValue = null;
}
if (threadPoolMaxSizeValue != null || scheduledThreadPoolMaxSizeValue != null) {
ActiveMQClient.initializeGlobalThreadPoolProperties();
if(threadPoolMaxSizeValue == null) {
threadPoolMaxSizeValue = ActiveMQClient.getGlobalThreadPoolSize();
}
if(scheduledThreadPoolMaxSizeValue == null) {
scheduledThreadPoolMaxSizeValue = ActiveMQClient.getGlobalScheduledThreadPoolSize();
}
MessagingLogger.ROOT_LOGGER.debugf("Setting global client thread pool size to: regular=%s, scheduled=%s", threadPoolMaxSizeValue, scheduledThreadPoolMaxSizeValue);
ActiveMQClient.setGlobalThreadPoolProperties(threadPoolMaxSizeValue, scheduledThreadPoolMaxSizeValue);
}
context.getServiceTarget().addService(MessagingServices.ACTIVEMQ_CLIENT_THREAD_POOL)
.setInstance( new ThreadPoolService())
.install();
context.addStep(new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
final ServiceTarget serviceTarget = context.getServiceTarget();
final ServiceBuilder serviceBuilder = serviceTarget.addService(CONFIGURATION_CAPABILITY.getCapabilityServiceName());
// Transform the configuration based on the recursive model
final ModelNode model = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS));
// Process connectors
final Set<String> connectorsSocketBindings = new HashSet<>();
final Map<String, String> sslContextNames = new HashMap<>();
final Map<String, TransportConfiguration> connectors = TransportConfigOperationHandlers.processConnectors(context, "localhost", model, connectorsSocketBindings, sslContextNames);
Map<String, ServiceName> outboundSocketBindings = new HashMap<>();
Map<String, Boolean> outbounds = TransportConfigOperationHandlers.listOutBoundSocketBinding(context, connectorsSocketBindings);
Map<String, ServiceName> socketBindings = new HashMap<>();
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);
outboundSocketBindings.put(connectorSocketBinding, outboundSocketName);
} else {
// check if the socket binding has not already been added by the acceptors
if (!socketBindings.containsKey(connectorSocketBinding)) {
socketBindings.put(connectorSocketBinding, SOCKET_BINDING_CAPABILITY.getCapabilityServiceName(connectorSocketBinding));
}
}
}
final List<BroadcastGroupConfiguration> broadcastGroupConfigurations =new ArrayList<>();
//this requires connectors
BroadcastGroupAdd.addBroadcastGroupConfigs(context, broadcastGroupConfigurations, connectors.keySet(), model);
final Map<String, DiscoveryGroupConfiguration> discoveryGroupConfigurations = ConfigurationHelper.addDiscoveryGroupConfigurations(context, model);
final Map<String, String> clusterNames = new HashMap<>();
final Map<String, ServiceName> commandDispatcherFactories = new HashMap<>();
final Map<String, ServiceName> groupBindings = new HashMap<>();
final Set<ServiceName> groupBindingServices = new HashSet<>();
for (final BroadcastGroupConfiguration config : broadcastGroupConfigurations) {
final String name = config.getName();
final String key = "broadcast" + name;
if (model.hasDefined(JGROUPS_BROADCAST_GROUP, name)) {
ModelNode broadcastGroupModel = model.get(JGROUPS_BROADCAST_GROUP, name);
String channelName = JGroupsBroadcastGroupDefinition.JGROUPS_CHANNEL.resolveModelAttribute(context, broadcastGroupModel).asStringOrNull();
MessagingSubsystemAdd.this.broadcastCommandDispatcherFactoryInstaller.accept(context, channelName);
commandDispatcherFactories.put(key, MessagingServices.getBroadcastCommandDispatcherFactoryServiceName(channelName));
String clusterName = JGROUPS_CLUSTER.resolveModelAttribute(context, broadcastGroupModel).asString();
clusterNames.put(key, clusterName);
} else {
final ServiceName groupBindingServiceName = GroupBindingService.getBroadcastBaseServiceName(MessagingServices.getActiveMQServiceName()).append(name);
if (!groupBindingServices.contains(groupBindingServiceName)) {
groupBindingServices.add(groupBindingServiceName);
}
groupBindings.put(key, groupBindingServiceName);
}
}
for (final DiscoveryGroupConfiguration config : discoveryGroupConfigurations.values()) {
final String name = config.getName();
final String key = "discovery" + name;
if (model.hasDefined(JGROUPS_DISCOVERY_GROUP, name)) {
ModelNode discoveryGroupModel = model.get(JGROUPS_DISCOVERY_GROUP, name);
String channelName = JGroupsDiscoveryGroupDefinition.JGROUPS_CHANNEL.resolveModelAttribute(context, discoveryGroupModel).asStringOrNull();
MessagingSubsystemAdd.this.broadcastCommandDispatcherFactoryInstaller.accept(context, channelName);
commandDispatcherFactories.put(key, MessagingServices.getBroadcastCommandDispatcherFactoryServiceName(channelName));
String clusterName = JGROUPS_CLUSTER.resolveModelAttribute(context, discoveryGroupModel).asString();
clusterNames.put(key, clusterName);
} else {
final ServiceName groupBindingServiceName = GroupBindingService.getDiscoveryBaseServiceName(MessagingServices.getActiveMQServiceName()).append(name);
if (!groupBindingServices.contains(groupBindingServiceName)) {
groupBindingServices.add(groupBindingServiceName);
}
groupBindings.put(key, groupBindingServiceName);
}
}
serviceBuilder.setInstance(new ExternalBrokerConfigurationService(
connectors,
discoveryGroupConfigurations,
socketBindings,
outboundSocketBindings,
groupBindings,
commandDispatcherFactories,
clusterNames,
sslContextNames))
.install();
}
}, OperationContext.Stage.RUNTIME);
}
/**
* Service to ensure that Artemis global client thread pools have the opportunity to shutdown when the server is
* stopped (or the subsystem is removed).
*/
private static class ThreadPoolService implements Service<Void> {
public ThreadPoolService() {
}
@Override
public void start(StartContext startContext) throws StartException {
}
@Override
public void stop(StopContext stopContext) {
ActiveMQClient.clearThreadPools();
}
@Override
public Void getValue() throws IllegalStateException, IllegalArgumentException {
return null;
}
}
}
| 17,801
| 64.448529
| 307
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/InfiniteOrPositiveValidators.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.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.ParameterCorrector;
import org.jboss.as.controller.operations.validation.ModelTypeValidator;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* Validates a given parameter is a legal value (-1 or > 0) where -1 means "forever".
*
* The validation is done in 2 steps:
* 1. a ParameterCorrector will correct any negative value to -1
* 2. a ParameterValidator will check that negative values and > 0 are valid.
*
* Note that the ParameterValidator will validate any negative value until WFCORE-3651 is fixed to preserve
* backwards compatibility (as the parameter correction is not apply before the validator is called during
* XML parsing).
*
* @author Jeff Mesnil (c) 2012 Red Hat Inc.
*/
public interface InfiniteOrPositiveValidators {
ModelTypeValidator LONG_INSTANCE = new ModelTypeValidator(ModelType.LONG) {
@Override
public void validateParameter(String parameterName, ModelNode value) throws OperationFailedException {
super.validateParameter(parameterName, value);
long val = value.asLong();
if (!(val <= -1 || (val > 0 && val < Long.MAX_VALUE))) {
throw new OperationFailedException(MessagingLogger.ROOT_LOGGER.illegalValue(value, parameterName));
}
}
};
ModelTypeValidator INT_INSTANCE = new ModelTypeValidator(ModelType.INT) {
@Override
public void validateParameter(String parameterName, ModelNode value) throws OperationFailedException {
super.validateParameter(parameterName, value);
int val = value.asInt();
if (!(val <= -1 || (val > 0 && val < Integer.MAX_VALUE))) {
throw new OperationFailedException(MessagingLogger.ROOT_LOGGER.illegalValue(value, parameterName));
}
}
};
/**
* Correct any negative value to use -1 (interpreted by Artemis as infinite).
*/
ParameterCorrector NEGATIVE_VALUE_CORRECTOR = new ParameterCorrector() {
@Override
public ModelNode correct(ModelNode newValue, ModelNode currentValue) {
if (newValue.isDefined() && newValue.getType() != ModelType.EXPRESSION) {
try {
if (newValue.asLong() < -1) {
return new ModelNode(-1);
}
} catch (Exception e) {
// not convertible; let the validator that the caller will invoke later deal with this
}
}
return newValue;
}
};
}
| 3,780
| 41.965909
| 115
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/QueueDefinition.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 java.lang.System.getProperty;
import static java.lang.System.getSecurityManager;
import static java.security.AccessController.doPrivileged;
import static org.jboss.as.controller.SimpleAttributeDefinitionBuilder.create;
import static org.jboss.dmr.ModelType.LONG;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.RUNTIME_QUEUE;
import java.security.PrivilegedAction;
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.CaseParameterCorrector;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.access.management.AccessConstraintDefinition;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
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;
/**
* Queue resource definition
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat Inc.
*/
public class QueueDefinition extends PersistentResourceDefinition {
private static final String DEFAULT_ROUTING_TYPE_PROPERTY = "org.wildfly.messaging.core.queue.default.routing-type";
public static final String DEFAULT_ROUTING_TYPE = getSecurityManager() == null ? getProperty(DEFAULT_ROUTING_TYPE_PROPERTY) : doPrivileged((PrivilegedAction<String>) () -> getProperty(DEFAULT_ROUTING_TYPE_PROPERTY));
public static final SimpleAttributeDefinition ADDRESS = create("queue-address", ModelType.STRING)
.setXmlName(CommonAttributes.ADDRESS)
.setAllowExpression(true)
.setRestartAllServices()
.build();
static final SimpleAttributeDefinition ROUTING_TYPE = create("routing-type", ModelType.STRING)
.setDefaultValue(new ModelNode(RoutingType.MULTICAST.toString()))
.setRequired(false)
.setAllowExpression(true)
.setCorrector(CaseParameterCorrector.TO_UPPER)
.setValidator(EnumValidator.create(RoutingType.class, RoutingType.values()))
.build();
static final SimpleAttributeDefinition[] ATTRIBUTES = { ADDRESS, CommonAttributes.FILTER, CommonAttributes.DURABLE, ROUTING_TYPE};
public static final SimpleAttributeDefinition EXPIRY_ADDRESS = create(CommonAttributes.EXPIRY_ADDRESS)
.setStorageRuntime()
.build();
public static final SimpleAttributeDefinition DEAD_LETTER_ADDRESS = create(CommonAttributes.DEAD_LETTER_ADDRESS)
.setStorageRuntime()
.build();
static final AttributeDefinition ID= create("id", LONG)
.setStorageRuntime()
.build();
static final AttributeDefinition[] READONLY_ATTRIBUTES = { CommonAttributes.PAUSED, CommonAttributes.TEMPORARY, ID, DEAD_LETTER_ADDRESS, EXPIRY_ADDRESS };
static final AttributeDefinition[] METRICS = { CommonAttributes.MESSAGE_COUNT, CommonAttributes.DELIVERING_COUNT, CommonAttributes.MESSAGES_ADDED,
CommonAttributes.SCHEDULED_COUNT, CommonAttributes.CONSUMER_COUNT
};
private final boolean registerRuntimeOnly;
QueueDefinition(final boolean registerRuntimeOnly,
final PathElement path) {
super(path,
MessagingExtension.getResourceDescriptionResolver(CommonAttributes.QUEUE),
path == MessagingExtension.RUNTIME_QUEUE_PATH ? null : QueueAdd.INSTANCE,
path == MessagingExtension.RUNTIME_QUEUE_PATH ? null : QueueRemove.INSTANCE,
path == MessagingExtension.RUNTIME_QUEUE_PATH);
this.registerRuntimeOnly = registerRuntimeOnly;
}
@Override
public boolean isRuntime() {
return getPathElement() == MessagingExtension.RUNTIME_QUEUE_PATH;
}
@Override
public void registerAttributes(ManagementResourceRegistration registry) {
super.registerAttributes(registry);
for (SimpleAttributeDefinition attr : ATTRIBUTES) {
if (!attr.getFlags().contains(AttributeAccess.Flag.STORAGE_RUNTIME)) {
if (isRuntime()) {
AttributeDefinition readOnlyRuntimeAttr = create(attr)
.setStorageRuntime()
.build();
registry.registerReadOnlyAttribute(readOnlyRuntimeAttr, QueueReadAttributeHandler.RUNTIME_INSTANCE);
} else {
registry.registerReadOnlyAttribute(attr, null);
}
}
}
for (AttributeDefinition attr : READONLY_ATTRIBUTES) {
registry.registerReadOnlyAttribute(attr, QueueReadAttributeHandler.INSTANCE);
}
for (AttributeDefinition metric : METRICS) {
registry.registerMetric(metric, QueueReadAttributeHandler.INSTANCE);
}
}
@Override
public Collection<AttributeDefinition> getAttributes() {
return Collections.emptyList();
}
@Override
public void registerOperations(ManagementResourceRegistration registry) {
super.registerOperations(registry);
if (registerRuntimeOnly) {
QueueControlHandler.INSTANCE.registerOperations(registry, getResourceDescriptionResolver());
}
}
@Override
public List<AccessConstraintDefinition> getAccessConstraints() {
if (isRuntime()) {
return Collections.emptyList();
} else {
return Arrays.asList(MessagingExtension.QUEUE_ACCESS_CONSTRAINT);
}
}
/**
* [AS7-5850] Core queues created with ActiveMQ API does not create WildFly resources
*
* For backwards compatibility if an operation is invoked on a queue that has no corresponding resources,
* we forward the operation to the corresponding runtime-queue resource (which *does* exist).
*
* @return true if the operation is forwarded to the corresponding runtime-queue resource, false else.
*/
static boolean forwardToRuntimeQueue(OperationContext context, ModelNode operation, OperationStepHandler handler) {
PathAddress address = context.getCurrentAddress();
// do not forward if the current operation is for a runtime-queue already:
if (RUNTIME_QUEUE.equals(address.getLastElement().getKey())) {
return false;
}
String queueName = address.getLastElement().getValue();
PathAddress activeMQPathAddress = MessagingServices.getActiveMQServerPathAddress(address);
if (context.readResourceFromRoot(activeMQPathAddress, false).hasChild(address.getLastElement())) {
return false;
} else {
// there is no registered queue resource, forward to the runtime-queue address instead
ModelNode forwardOperation = operation.clone();
forwardOperation.get(ModelDescriptionConstants.OP_ADDR).set(activeMQPathAddress.append(RUNTIME_QUEUE, queueName).toModelNode());
context.addStep(forwardOperation, handler, OperationContext.Stage.RUNTIME, true);
return true;
}
}
private enum RoutingType {
MULTICAST, ANYCAST;
}
}
| 8,648
| 42.462312
| 220
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/SocketBroadcastGroupRemove.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.dmr.ModelNode;
/**
* Removes a broadcast group using socket bindings.
* @author Emmanuel Hugonnet (c) 2019 Red Hat, Inc.
*/
public class SocketBroadcastGroupRemove extends ReloadRequiredRemoveStepHandler {
public static final SocketBroadcastGroupRemove INSTANCE = new SocketBroadcastGroupRemove(true);
public static final SocketBroadcastGroupRemove LEGACY_INSTANCE = new SocketBroadcastGroupRemove(false);
private final boolean needLegacyCall;
private SocketBroadcastGroupRemove(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.BROADCAST_GROUP, context.getCurrentAddressValue());
ModelNode op = operation.clone();
op.get(OP_ADDR).set(target.toModelNode());
context.addStep(op, BroadcastGroupRemove.LEGACY_INSTANCE, OperationContext.Stage.MODEL, true);
}
super.execute(context, operation);
}
}
| 2,556
| 42.338983
| 148
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/MessagingSubsystemParser_13_1.java
|
/*
* Copyright 2022 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 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_COLOCATED_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.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_13_1 extends PersistentResourceXMLParser {
static final String NAMESPACE = "urn:jboss:domain:messaging-activemq:13.1";
@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,
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(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(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,
BridgeDefinition.CALL_TIMEOUT))
.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;
}
}
| 57,038
| 79.563559
| 128
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/QueueAdd.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 java.util.function.Supplier;
import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
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.dmr.ModelNode;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceController.Mode;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceRegistry;
/**
* Core queue add update.
*
* @author Emanuel Muckenhuber
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class QueueAdd extends AbstractAddStepHandler {
public static final QueueAdd INSTANCE = new QueueAdd(QueueDefinition.ATTRIBUTES);
private QueueAdd(AttributeDefinition... attributes) {
super(attributes);
}
@Override
protected boolean requiresRuntime(OperationContext context) {
return context.isDefaultRequiresRuntime() && !context.isBooting();
}
@Override
protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException {
for (final AttributeDefinition attributeDefinition : QueueDefinition.ATTRIBUTES) {
attributeDefinition.validateAndSet(operation, model);
}
}
@Override
@SuppressWarnings("unchecked")
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(context.getCurrentAddress());
ServiceController<?> serverService = registry.getService(serviceName);
if (serverService != null) {
final String queueName = context.getCurrentAddressValue();
final CoreQueueConfiguration queueConfiguration = ConfigurationHelper.createCoreQueueConfiguration(context, queueName, model);
final ServiceName queueServiceName = MessagingServices.getQueueBaseServiceName(serviceName).append(queueName);
final ServiceBuilder sb = context.getServiceTarget().addService(queueServiceName);
sb.requires(ActiveMQActivationService.getServiceName(serviceName));
Supplier<ActiveMQServer> serverSupplier = sb.requires(serviceName);
final QueueService service = new QueueService(serverSupplier, queueConfiguration, false, true);
sb.setInitialMode(Mode.PASSIVE);
sb.setInstance(service);
sb.install();
}
// else the initial subsystem install is not complete; MessagingSubsystemAdd will add a
// handler that calls addQueueConfigs
}
}
| 3,987
| 42.347826
| 138
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/HTTPAcceptorDefinition.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.SimpleAttributeDefinitionBuilder.create;
import static org.wildfly.extension.messaging.activemq.Capabilities.HTTP_LISTENER_REGISTRY_CAPABILITY_NAME;
import static org.wildfly.extension.messaging.activemq.Capabilities.HTTP_UPGRADE_REGISTRY_CAPABILITY_NAME;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.HTTP_ACCEPTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.PARAMS;
import java.util.Arrays;
import java.util.Collection;
import java.util.Locale;
import java.util.ResourceBundle;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.registry.RuntimePackageDependency;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
import org.wildfly.extension.messaging.activemq.MessagingServices.ServerNameMapper;
/**
* HTTP acceptor resource definition
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2013 Red Hat Inc.
*/
public class HTTPAcceptorDefinition extends PersistentResourceDefinition {
static final RuntimeCapability<Void> CAPABILITY = RuntimeCapability.Builder.of("org.wildfly.messaging.activemq", true, HTTPUpgradeService.class)
.setDynamicNameMapper(new ServerNameMapper("http-upgrade-service"))
.addRequirements(HTTP_LISTENER_REGISTRY_CAPABILITY_NAME)
.build();
static final SimpleAttributeDefinition HTTP_LISTENER = create(CommonAttributes.HTTP_LISTENER, ModelType.STRING)
.setRequired(true)
.setCapabilityReference(HTTP_UPGRADE_REGISTRY_CAPABILITY_NAME, CAPABILITY)
.build();
static final SimpleAttributeDefinition UPGRADE_LEGACY = create("upgrade-legacy", ModelType.BOOLEAN)
.setDefaultValue(ModelNode.TRUE)
.setRequired(false)
.setAllowExpression(true)
.build();
static AttributeDefinition[] ATTRIBUTES = {HTTP_LISTENER, PARAMS, UPGRADE_LEGACY, CommonAttributes.SSL_CONTEXT};
HTTPAcceptorDefinition() {
super(new SimpleResourceDefinition.Parameters(MessagingExtension.HTTP_ACCEPTOR_PATH,
new StandardResourceDescriptionResolver(CommonAttributes.ACCEPTOR, MessagingExtension.RESOURCE_NAME, MessagingExtension.class.getClassLoader(), true, false) {
@Override
public String getResourceDescription(Locale locale, ResourceBundle bundle) {
return bundle.getString(HTTP_ACCEPTOR);
}
})
.addCapabilities(CAPABILITY)
.setAdditionalPackages(
RuntimePackageDependency.required("io.undertow.core"),
RuntimePackageDependency.required("org.jboss.as.remoting"),
RuntimePackageDependency.required("org.jboss.xnio"),
RuntimePackageDependency.required("org.jboss.xnio.netty.netty-xnio-transport"))
.setAddHandler(HTTPAcceptorAdd.INSTANCE)
.setRemoveHandler(HTTPAcceptorRemove.INSTANCE));
}
@Override
public void registerAttributes(ManagementResourceRegistration registry) {
OperationStepHandler attributeHandler = new ReloadRequiredWriteAttributeHandler(ATTRIBUTES);
for (AttributeDefinition attr : ATTRIBUTES) {
if (!attr.getFlags().contains(AttributeAccess.Flag.STORAGE_RUNTIME)) {
registry.registerReadWriteAttribute(attr, null, attributeHandler);
}
}
}
@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(ATTRIBUTES);
}
@Override
public void registerAdditionalRuntimePackages(ManagementResourceRegistration resourceRegistration) {
resourceRegistration.registerAdditionalRuntimePackages(
RuntimePackageDependency.required("io.undertow.core"),
RuntimePackageDependency.required("org.jboss.xnio"),
RuntimePackageDependency.required("org.jboss.xnio.netty.netty-xnio-transport"));
}
}
| 5,708
| 48.643478
| 174
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/HTTPAcceptorAdd.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.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;
/**
* The add 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 HTTPAcceptorAdd extends ActiveMQReloadRequiredHandlers.AddStepHandler {
public static final HTTPAcceptorAdd INSTANCE = new HTTPAcceptorAdd();
private HTTPAcceptorAdd() {
super(HTTPAcceptorDefinition.ATTRIBUTES);
}
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
super.performRuntime(context, operation, model);
String acceptorName = context.getCurrentAddressValue();
String activeMQServerName = context.getCurrentAddress().getParent().getLastElement().getValue();
final ModelNode fullModel = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS));
launchServices(context, activeMQServerName, acceptorName, fullModel);
}
void launchServices(OperationContext context, String activeMQServerName, String acceptorName, ModelNode model) throws OperationFailedException {
String httpConnectorName = HTTPAcceptorDefinition.HTTP_LISTENER.resolveModelAttribute(context, model).asString();
HTTPUpgradeService.installService(context.getCapabilityServiceTarget(),
activeMQServerName,
acceptorName,
httpConnectorName);
boolean upgradeLegacy = HTTPAcceptorDefinition.UPGRADE_LEGACY.resolveModelAttribute(context, model).asBoolean();
if (upgradeLegacy) {
HTTPUpgradeService.LegacyHttpUpgradeService.installService(context,
activeMQServerName,
acceptorName,
httpConnectorName);
}
}
}
| 3,110
| 42.208333
| 148
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/AbstractArtemisActionHandler.java
|
/*
* Copyright 2020 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;
import static org.jboss.as.controller.AbstractControllerService.PATH_MANAGER_CAPABILITY;
import static org.jboss.as.controller.PathAddress.EMPTY_ADDRESS;
import java.io.File;
import java.nio.file.Path;
import org.jboss.as.controller.AbstractRuntimeOnlyHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.registry.Resource;
import org.jboss.as.controller.services.path.AbsolutePathService;
import org.jboss.as.controller.services.path.PathManager;
import org.jboss.as.server.ServerEnvironment;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceController;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
*
* @author Emmanuel Hugonnet (c) 2020 Red Hat, Inc.
*/
public abstract class AbstractArtemisActionHandler extends AbstractRuntimeOnlyHandler {
protected String resolvePath(OperationContext context, PathElement pathElement) throws OperationFailedException {
Resource serverResource = context.readResource(EMPTY_ADDRESS);
// if the path resource does not exist, resolve its attributes against an empty ModelNode to get its default values
final ModelNode model = serverResource.hasChild(pathElement) ? serverResource.getChild(pathElement).getModel() : new ModelNode();
final String path = PathDefinition.PATHS.get(pathElement.getValue()).resolveModelAttribute(context, model).asString();
final String relativeToPath = PathDefinition.RELATIVE_TO.resolveModelAttribute(context, model).asString();
final String relativeTo = AbsolutePathService.isAbsoluteUnixOrWindowsPath(path) ? null : relativeToPath;
return getPathManager(context).resolveRelativePathEntry(path, relativeTo);
}
protected Path getServerTempDir(OperationContext context) {
return new File(getPathManager(context).getPathEntry(ServerEnvironment.CONTROLLER_TEMP_DIR).resolvePath()).toPath();
}
protected File resolveFile(OperationContext context, PathElement pathElement) throws OperationFailedException {
return new File(resolvePath(context, pathElement));
}
protected void checkAllowedOnJournal(OperationContext context, String operationName) throws OperationFailedException {
ModelNode journalDatasource = ServerDefinition.JOURNAL_DATASOURCE.resolveModelAttribute(context, context.readResource(EMPTY_ADDRESS).getModel());
if (journalDatasource.isDefined() && journalDatasource.asString() != null && !"".equals(journalDatasource.asString())) {
throw MessagingLogger.ROOT_LOGGER.operationNotAllowedOnJdbcStore(operationName);
}
}
@SuppressWarnings("unchecked")
private PathManager getPathManager(OperationContext context) {
final ServiceController<PathManager> service = (ServiceController<PathManager>) context.getServiceRegistry(false).getService(PATH_MANAGER_CAPABILITY.getCapabilityServiceName());
return service.getService().getValue();
}
}
| 3,726
| 50.763889
| 185
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/BroadcastGroupControlHandler.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.BroadcastGroupDefinition.GET_CONNECTOR_PAIRS_AS_JSON;
import org.apache.activemq.artemis.api.core.management.BaseBroadcastGroupControl;
import org.apache.activemq.artemis.api.core.management.ResourceNames;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
import org.jboss.dmr.ModelNode;
/**
* Handler for runtime operations that interact with a ActiveMQ {@link org.apache.activemq.artemis.api.core.management.BroadcastGroupControl}.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class BroadcastGroupControlHandler extends AbstractActiveMQComponentControlHandler<BaseBroadcastGroupControl> {
public static final BroadcastGroupControlHandler INSTANCE = new BroadcastGroupControlHandler();
private BroadcastGroupControlHandler() {
}
@Override
protected BaseBroadcastGroupControl getActiveMQComponentControl(ActiveMQServer activeMQServer, PathAddress address) {
final String resourceName = address.getLastElement().getValue();
return BaseBroadcastGroupControl.class.cast(activeMQServer.getManagementService().getResource(ResourceNames.BROADCAST_GROUP + resourceName));
}
@Override
protected String getDescriptionPrefix() {
return CommonAttributes.BROADCAST_GROUP;
}
@Override
protected Object handleOperation(String operationName, OperationContext context, ModelNode operation) throws OperationFailedException {
if (GET_CONNECTOR_PAIRS_AS_JSON.equals(operationName)) {
BaseBroadcastGroupControl control = getActiveMQComponentControl(context, operation, false);
try {
if(control != null) {
context.getResult().set(control.getConnectorPairsAsJSON());
}
} catch (Exception e) {
context.getFailureDescription().set(e.getLocalizedMessage());
}
} else {
unsupportedOperation(operationName);
}
return null;
}
}
| 3,252
| 42.373333
| 149
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/AbstractTransportDefinition.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 java.util.Arrays;
import java.util.Collection;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.function.Function;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.CapabilityReferenceRecorder;
import org.jboss.as.controller.ModelVersion;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
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.descriptions.StandardResourceDescriptionResolver;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.registry.Resource;
/**
* Abstract acceptor resource definition
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat Inc.
*/
public abstract class AbstractTransportDefinition extends PersistentResourceDefinition {
public static final String CONNECTOR_CAPABILITY_NAME = "org.wildfly.messaging.activemq.connector";
public static final String ACCEPTOR_CAPABILITY_NAME = "org.wildfly.messaging.activemq.acceptor";
private final boolean registerRuntimeOnly;
private final AttributeDefinition[] attrs;
protected final boolean isAcceptor;
private static class TransportCapabilityNameMapper implements Function<PathAddress,String[]> {
private static final TransportCapabilityNameMapper INSTANCE = new TransportCapabilityNameMapper();
private TransportCapabilityNameMapper(){}
@Override
public String[] apply(PathAddress address) {
String[] result = new String[2];
PathAddress serverAddress = MessagingServices.getActiveMQServerPathAddress(address);
if(serverAddress.size() > 0 ) {
result[0] = serverAddress.getLastElement().getValue();
} else {
result[0] = "external";
}
result[1] = address.getLastElement().getValue();
return result;
}
}
public static class TransportCapabilityReferenceRecorder extends CapabilityReferenceRecorder.ResourceCapabilityReferenceRecorder {
private final boolean external;
public TransportCapabilityReferenceRecorder(String baseDependentName, String baseRequirementName, boolean external) {
super(external ? DynamicNameMappers.SIMPLE : DynamicNameMappers.PARENT, baseDependentName, TransportCapabilityNameMapper.INSTANCE, baseRequirementName);
this.external = external;
}
@Override
public void addCapabilityRequirements(OperationContext context, Resource resource, String attributeName, String... attributeValues) {
processCapabilityRequirement(context, attributeName, false, attributeValues);
}
@Override
public void removeCapabilityRequirements(OperationContext context, Resource resource, String attributeName, String... attributeValues) {
processCapabilityRequirement(context, attributeName, true, attributeValues);
}
private void processCapabilityRequirement(OperationContext context, String attributeName, boolean remove, String... attributeValues) {
String dependentName = getDependentName(context.getCurrentAddress());
String requirement = getRequirementName(context.getCurrentAddress());
for (String att : attributeValues) {
String requirementName = RuntimeCapability.buildDynamicCapabilityName(requirement, att);
if (remove) {
context.deregisterCapabilityRequirement(requirementName, dependentName, attributeName);
} else {
context.registerAdditionalCapabilityRequirement(requirementName, dependentName, attributeName);
}
}
}
private String getDependentName(PathAddress address) {
if (external) {
return RuntimeCapability.buildDynamicCapabilityName(getBaseDependentName(), DynamicNameMappers.SIMPLE.apply(address));
}
return RuntimeCapability.buildDynamicCapabilityName(getBaseDependentName(), DynamicNameMappers.PARENT.apply(address));
}
private String getRequirementName(PathAddress address) {
PathAddress serverAddress = MessagingServices.getActiveMQServerPathAddress(address);
if (serverAddress.size() > 0) {
return RuntimeCapability.buildDynamicCapabilityName(getBaseRequirementName(), serverAddress.getLastElement().getValue());
}
return getBaseRequirementName();
}
@Override
public String getBaseRequirementName() {
if (external) {
return super.getBaseRequirementName() + ".external";
}
return super.getBaseRequirementName();
}
@Override
public String[] getRequirementPatternSegments(String dynamicElement, PathAddress registrationAddress) {
String[] dynamicElements;
if (!external) {
dynamicElements = new String[]{"$server"};
} else {
dynamicElements = new String[0];
}
if (dynamicElement != null && !dynamicElement.isEmpty()) {
String[] result = new String[dynamicElements.length + 1];
for (int i = 0; i < dynamicElements.length; i++) {
if (dynamicElements[i].charAt(0) == '$') {
result[i] = dynamicElements[i].substring(1);
} else {
result[i] = dynamicElements[i];
}
}
result[dynamicElements.length] = dynamicElement;
return result;
}
return dynamicElements;
}
}
protected AbstractTransportDefinition(final boolean isAcceptor, final String specificType, final boolean registerRuntimeOnly, AttributeDefinition... attrs) {
super(new SimpleResourceDefinition.Parameters(PathElement.pathElement(specificType),
new StandardResourceDescriptionResolver((isAcceptor ? CommonAttributes.ACCEPTOR : CommonAttributes.CONNECTOR),
MessagingExtension.RESOURCE_NAME, MessagingExtension.class.getClassLoader(), true, false) {
@Override
public String getResourceDescription(Locale locale, ResourceBundle bundle) {
return bundle.getString(specificType);
}
})
.setCapabilities(RuntimeCapability.Builder.of(isAcceptor ? ACCEPTOR_CAPABILITY_NAME : CONNECTOR_CAPABILITY_NAME, true)
.setDynamicNameMapper(TransportCapabilityNameMapper.INSTANCE)
.build())
.setAddHandler(new ActiveMQReloadRequiredHandlers.AddStepHandler(attrs))
.setRemoveHandler(new ActiveMQReloadRequiredHandlers.RemoveStepHandler()));
this.isAcceptor = isAcceptor;
this.registerRuntimeOnly = registerRuntimeOnly;
this.attrs = attrs;
}
protected AbstractTransportDefinition(final boolean isAcceptor, final String specificType, final boolean registerRuntimeOnly, ModelVersion deprecatedSince, AttributeDefinition... attrs) {
super(new SimpleResourceDefinition.Parameters(PathElement.pathElement(specificType),
new StandardResourceDescriptionResolver((isAcceptor ? CommonAttributes.ACCEPTOR : CommonAttributes.CONNECTOR),
MessagingExtension.RESOURCE_NAME, MessagingExtension.class.getClassLoader(), true, false) {
@Override
public String getResourceDescription(Locale locale, ResourceBundle bundle) {
return bundle.getString(specificType);
}
})
.setAddHandler(new ActiveMQReloadRequiredHandlers.AddStepHandler(attrs))
.setRemoveHandler(new ActiveMQReloadRequiredHandlers.RemoveStepHandler())
.setDeprecatedSince(deprecatedSince));
this.isAcceptor = isAcceptor;
this.registerRuntimeOnly = registerRuntimeOnly;
this.attrs = attrs;
}
@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(attrs);
}
@Override
public void registerAttributes(ManagementResourceRegistration registry) {
OperationStepHandler attributeHandler = new ReloadRequiredWriteAttributeHandler(attrs);
for (AttributeDefinition attr : attrs) {
if (!attr.getFlags().contains(AttributeAccess.Flag.STORAGE_RUNTIME)) {
registry.registerReadWriteAttribute(attr, null, attributeHandler);
}
}
if (isAcceptor) {
AcceptorControlHandler.INSTANCE.registerAttributes(registry);
}
}
@Override
public void registerOperations(ManagementResourceRegistration registry) {
if (isAcceptor && registerRuntimeOnly) {
AcceptorControlHandler.INSTANCE.registerOperations(registry, getResourceDescriptionResolver());
}
super.registerOperations(registry);
}
}
| 10,594
| 47.378995
| 191
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/MessagingSubsystemParser_7_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_COLOCATED_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.REPLICATION_MASTER_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.REPLICATION_SLAVE_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_7_0 extends PersistentResourceXMLParser {
static final String NAMESPACE = "urn:jboss:domain:messaging-activemq:7.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(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(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.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,866
| 79.467275
| 128
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/SecurityRoleRemove.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.HashSet;
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.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;
/**
* {@code OperationStepHandler} for removing a security role.
*
* @author Emanuel Muckenhuber
*/
class SecurityRoleRemove extends AbstractRemoveStepHandler {
static final SecurityRoleRemove INSTANCE = new SecurityRoleRemove();
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
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();
removeRole(server, match, roleName);
}
static void removeRole(ActiveMQServer server, String match, String roleName) {
if (server != null) {
final Set<Role> roles = server.getSecurityRepository().getMatch(match);
final Set<Role> newRoles = new HashSet<>();
for (final Role role : roles) {
if (!roleName.equals(role.getName())) {
newRoles.add(role);
}
}
server.getSecurityRepository().addMatch(match, newRoles);
}
}
}
| 2,948
| 40.535211
| 131
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/MessagingSubsystemRootResourceDefinition.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.registry.AttributeAccess.Flag.COUNTER_METRIC;
import static org.jboss.as.controller.registry.AttributeAccess.Flag.GAUGE_METRIC;
import static org.jboss.dmr.ModelType.INT;
import static org.jboss.dmr.ModelType.LONG;
import java.util.Arrays;
import java.util.Collection;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.function.BiConsumer;
import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.ReloadRequiredRemoveStepHandler;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.controller.client.helpers.MeasurementUnit;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.dmr.ModelNode;
/**
* {@link org.jboss.as.controller.ResourceDefinition} for the messaging subsystem root resource.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class MessagingSubsystemRootResourceDefinition extends PersistentResourceDefinition {
private static final String GLOBAL_CLIENT_PREFIX = "global-client-thread-pool-";
private static final String GLOBAL_CLIENT_SCHEDULED_PREFIX = "global-client-scheduled-thread-pool-";
public static final RuntimeCapability<Void> CONFIGURATION_CAPABILITY = RuntimeCapability.Builder.of("org.wildfly.messaging.activemq.external.configuration", false)
.setServiceType(ExternalBrokerConfigurationService.class)
.build();
public static final SimpleAttributeDefinition GLOBAL_CLIENT_THREAD_POOL_MAX_SIZE = create(GLOBAL_CLIENT_PREFIX + "max-size", INT)
.setAttributeGroup("global-client")
.setXmlName("thread-pool-max-size")
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
public static final SimpleAttributeDefinition GLOBAL_CLIENT_THREAD_POOL_ACTIVE_COUNT = create(GLOBAL_CLIENT_PREFIX + org.jboss.as.threads.CommonAttributes.ACTIVE_COUNT, INT)
.setAttributeGroup("global-client")
.setUndefinedMetricValue(ModelNode.ZERO)
.addFlag(GAUGE_METRIC)
.build();
public static final SimpleAttributeDefinition GLOBAL_CLIENT_THREAD_POOL_COMPLETED_TASK_COUNT = create(GLOBAL_CLIENT_PREFIX + org.jboss.as.threads.CommonAttributes.COMPLETED_TASK_COUNT, INT)
.setAttributeGroup("global-client")
.setUndefinedMetricValue(ModelNode.ZERO)
.addFlag(COUNTER_METRIC)
.build();
public static final SimpleAttributeDefinition GLOBAL_CLIENT_THREAD_POOL_CURRENT_THREAD_COUNT = create(GLOBAL_CLIENT_PREFIX + org.jboss.as.threads.CommonAttributes.CURRENT_THREAD_COUNT, INT)
.setAttributeGroup("global-client")
.setUndefinedMetricValue(ModelNode.ZERO)
.addFlag(GAUGE_METRIC)
.build();
public static final SimpleAttributeDefinition GLOBAL_CLIENT_THREAD_POOL_LARGEST_THREAD_COUNT = create(GLOBAL_CLIENT_PREFIX + org.jboss.as.threads.CommonAttributes.LARGEST_THREAD_COUNT, INT)
.setAttributeGroup("global-client")
.setUndefinedMetricValue(ModelNode.ZERO)
.addFlag(COUNTER_METRIC)
.build();
public static final SimpleAttributeDefinition GLOBAL_CLIENT_THREAD_POOL_TASK_COUNT = create(GLOBAL_CLIENT_PREFIX + org.jboss.as.threads.CommonAttributes.TASK_COUNT, INT)
.setAttributeGroup("global-client")
.setUndefinedMetricValue(ModelNode.ZERO)
.addFlag(COUNTER_METRIC)
.build();
public static final SimpleAttributeDefinition GLOBAL_CLIENT_THREAD_POOL_KEEPALIVE_TIME = create(GLOBAL_CLIENT_PREFIX + org.jboss.as.threads.CommonAttributes.KEEPALIVE_TIME, LONG)
.setAttributeGroup("global-client")
.setUndefinedMetricValue(ModelNode.ZERO)
.setMeasurementUnit(MeasurementUnit.NANOSECONDS)
.build();
public static final SimpleAttributeDefinition GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_MAX_SIZE = create(GLOBAL_CLIENT_SCHEDULED_PREFIX + "max-size", INT)
.setAttributeGroup("global-client")
.setXmlName("scheduled-thread-pool-max-size")
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
public static final SimpleAttributeDefinition GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_ACTIVE_COUNT = create(GLOBAL_CLIENT_SCHEDULED_PREFIX + org.jboss.as.threads.CommonAttributes.ACTIVE_COUNT, INT)
.setAttributeGroup("global-client")
.setUndefinedMetricValue(ModelNode.ZERO)
.addFlag(GAUGE_METRIC)
.build();
public static final SimpleAttributeDefinition GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_COMPLETED_TASK_COUNT = create(GLOBAL_CLIENT_SCHEDULED_PREFIX + org.jboss.as.threads.CommonAttributes.COMPLETED_TASK_COUNT, INT)
.setAttributeGroup("global-client")
.setUndefinedMetricValue(ModelNode.ZERO)
.addFlag(COUNTER_METRIC)
.build();
public static final SimpleAttributeDefinition GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_CURRENT_THREAD_COUNT = create(GLOBAL_CLIENT_SCHEDULED_PREFIX + org.jboss.as.threads.CommonAttributes.CURRENT_THREAD_COUNT, INT)
.setAttributeGroup("global-client")
.setUndefinedMetricValue(ModelNode.ZERO)
.addFlag(GAUGE_METRIC)
.build();
public static final SimpleAttributeDefinition GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_LARGEST_THREAD_COUNT = create(GLOBAL_CLIENT_SCHEDULED_PREFIX + org.jboss.as.threads.CommonAttributes.LARGEST_THREAD_COUNT, INT)
.setAttributeGroup("global-client")
.setUndefinedMetricValue(ModelNode.ZERO)
.addFlag(COUNTER_METRIC)
.build();
public static final SimpleAttributeDefinition GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_TASK_COUNT = create(GLOBAL_CLIENT_SCHEDULED_PREFIX + org.jboss.as.threads.CommonAttributes.TASK_COUNT, INT)
.setAttributeGroup("global-client")
.setUndefinedMetricValue(ModelNode.ZERO)
.addFlag(COUNTER_METRIC)
.build();
public static final SimpleAttributeDefinition GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_KEEPALIVE_TIME = create(GLOBAL_CLIENT_SCHEDULED_PREFIX + org.jboss.as.threads.CommonAttributes.KEEPALIVE_TIME, LONG)
.setAttributeGroup("global-client")
.setUndefinedMetricValue(ModelNode.ZERO)
.setMeasurementUnit(MeasurementUnit.NANOSECONDS)
.build();
public static final AttributeDefinition[] ATTRIBUTES = {
GLOBAL_CLIENT_THREAD_POOL_MAX_SIZE,
GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_MAX_SIZE
};
public static final AttributeDefinition[] METRICS = {
GLOBAL_CLIENT_THREAD_POOL_ACTIVE_COUNT, GLOBAL_CLIENT_THREAD_POOL_COMPLETED_TASK_COUNT, GLOBAL_CLIENT_THREAD_POOL_CURRENT_THREAD_COUNT,
GLOBAL_CLIENT_THREAD_POOL_LARGEST_THREAD_COUNT, GLOBAL_CLIENT_THREAD_POOL_TASK_COUNT, GLOBAL_CLIENT_THREAD_POOL_KEEPALIVE_TIME,
GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_ACTIVE_COUNT, GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_COMPLETED_TASK_COUNT,
GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_CURRENT_THREAD_COUNT, GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_LARGEST_THREAD_COUNT,
GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_TASK_COUNT, GLOBAL_CLIENT_SCHEDULED_THREAD_POOL_KEEPALIVE_TIME
};
MessagingSubsystemRootResourceDefinition(BiConsumer<OperationContext, String> broadcastCommandDispatcherFactoryInstaller) {
super(new SimpleResourceDefinition.Parameters(MessagingExtension.SUBSYSTEM_PATH,
MessagingExtension.getResourceDescriptionResolver(MessagingExtension.SUBSYSTEM_NAME))
.setAddHandler(new MessagingSubsystemAdd(broadcastCommandDispatcherFactoryInstaller))
.setRemoveHandler(ReloadRequiredRemoveStepHandler.INSTANCE)
.setCapabilities(CONFIGURATION_CAPABILITY));
}
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
super.registerAttributes(resourceRegistration);
for (AttributeDefinition metric : METRICS) {
resourceRegistration.registerMetric(metric, ClientThreadPoolMetricReader.INSTANCE);
}
}
@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(ATTRIBUTES);
}
private static final class ClientThreadPoolMetricReader implements OperationStepHandler {
private static final ClientThreadPoolMetricReader INSTANCE = new ClientThreadPoolMetricReader();
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
final String attributeName = operation.require(ModelDescriptionConstants.NAME).asString();
ThreadPoolExecutor pool;
String metric;
if (attributeName.startsWith(GLOBAL_CLIENT_PREFIX)) {
pool = (ThreadPoolExecutor) ActiveMQClient.getGlobalThreadPool();
metric = attributeName.substring(GLOBAL_CLIENT_PREFIX.length());
} else {
pool = (ThreadPoolExecutor) ActiveMQClient.getGlobalScheduledThreadPool();
metric = attributeName.substring(GLOBAL_CLIENT_SCHEDULED_PREFIX.length());
}
switch (metric) {
case org.jboss.as.threads.CommonAttributes.ACTIVE_COUNT:
context.getResult().set(pool.getActiveCount());
break;
case org.jboss.as.threads.CommonAttributes.COMPLETED_TASK_COUNT:
context.getResult().set(pool.getCompletedTaskCount());
break;
case org.jboss.as.threads.CommonAttributes.CURRENT_THREAD_COUNT:
context.getResult().set(pool.getPoolSize());
break;
case org.jboss.as.threads.CommonAttributes.LARGEST_THREAD_COUNT:
context.getResult().set(pool.getLargestPoolSize());
break;
case org.jboss.as.threads.CommonAttributes.TASK_COUNT:
context.getResult().set(pool.getTaskCount());
break;
case org.jboss.as.threads.CommonAttributes.KEEPALIVE_TIME:
context.getResult().set(pool.getKeepAliveTime(TimeUnit.NANOSECONDS));
break;
default:
// Programming bug. Throw a RuntimeException, not OFE, as this is not a client error
throw new IllegalArgumentException(metric);
}
}
}
}
| 12,316
| 52.552174
| 213
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/OperationValidator.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.AttributeDefinition;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.dmr.ModelNode;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* @author Emanuel Muckenhuber
*/
interface OperationValidator {
/**
* Validate.
*
* @param operation the operation to validate
* @throws OperationFailedException
*/
void validate(ModelNode operation) throws OperationFailedException;
/**
* Validate and Set
*
* @param operation the operation to validate
* @param subModel the subModel
* @throws OperationFailedException
*/
void validateAndSet(ModelNode operation, ModelNode subModel) throws OperationFailedException;
static class AttributeDefinitionOperationValidator implements OperationValidator {
private final AttributeDefinition[] attributes;
public AttributeDefinitionOperationValidator(AttributeDefinition... attributes) {
this.attributes = attributes;
}
@Override
public void validate(final ModelNode operation) throws OperationFailedException {
for(final AttributeDefinition definition : attributes) {
final String attributeName = definition.getName();
final boolean has = operation.has(attributeName);
if(! has && definition.isRequired(operation)) {
throw new OperationFailedException(MessagingLogger.ROOT_LOGGER.required(definition.getName()));
}
if(has) {
if(! definition.isAllowed(operation)) {
throw new OperationFailedException(MessagingLogger.ROOT_LOGGER.invalid(definition.getName()));
}
definition.validateOperation(operation);
}
}
}
@Override
public void validateAndSet(final ModelNode operation, final ModelNode subModel) throws OperationFailedException {
for(final AttributeDefinition definition : attributes) {
final String attributeName = definition.getName();
final boolean has = operation.has(attributeName);
if(! has && definition.isRequired(operation)) {
throw new OperationFailedException(MessagingLogger.ROOT_LOGGER.required(definition.getName()));
}
if(has) {
if(! definition.isAllowed(operation)) {
throw new OperationFailedException(MessagingLogger.ROOT_LOGGER.invalid(definition.getName()));
}
definition.validateAndSet(operation, subModel);
}
}
}
}
}
| 3,849
| 39.526316
| 121
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/ActiveMQServerControlWriteHandler.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;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.jboss.as.controller.security.CredentialReference.applyCredentialReferenceUpdateToRuntime;
import static org.jboss.as.controller.security.CredentialReference.handleCredentialReferenceUpdate;
import static org.jboss.as.controller.security.CredentialReference.rollbackCredentialStoreUpdate;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.CREDENTIAL_REFERENCE;
import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.jboss.as.controller.AbstractWriteAttributeHandler;
import org.jboss.as.controller.AttributeDefinition;
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.logging.ControllerLogger;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ImmutableManagementResourceRegistration;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.registry.Resource;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceRegistry;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* Write attribute handler for attributes that update ActiveMQServerControl.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class ActiveMQServerControlWriteHandler extends AbstractWriteAttributeHandler<Void> {
public static final ActiveMQServerControlWriteHandler INSTANCE = new ActiveMQServerControlWriteHandler();
private ActiveMQServerControlWriteHandler() {
super(ServerDefinition.ATTRIBUTES);
}
public void registerAttributes(final ManagementResourceRegistration registry, boolean registerRuntimeOnly) {
for (AttributeDefinition attr : ServerDefinition.ATTRIBUTES) {
if (registerRuntimeOnly || !attr.getFlags().contains(AttributeAccess.Flag.STORAGE_RUNTIME)) {
registry.registerReadWriteAttribute(attr, null, this);
}
}
}
@Override
protected void finishModelStage(OperationContext context, ModelNode operation, String attributeName, ModelNode newValue,
ModelNode oldValue, Resource resource) throws OperationFailedException {
super.finishModelStage(context, operation, attributeName, newValue, oldValue, resource);
if (attributeName.equals(CREDENTIAL_REFERENCE.getName())) {
handleCredentialReferenceUpdate(context, resource.getModel().get(attributeName), attributeName);
}
}
@Override
protected boolean applyUpdateToRuntime(final OperationContext context, final ModelNode operation, final String attributeName,
final ModelNode newValue, final ModelNode currentValue,
final HandbackHolder<Void> handbackHolder) throws OperationFailedException {
AttributeDefinition attr = getAttributeDefinition(attributeName);
if (attr.equals(CREDENTIAL_REFERENCE)) {
return applyCredentialReferenceUpdateToRuntime(context, operation, newValue, currentValue, attributeName);
}
if (attr.getFlags().contains(AttributeAccess.Flag.RESTART_ALL_SERVICES)) {
// Restart required
return true;
} else {
ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(OP_ADDR)));
ServiceController<?> service = registry.getService(serviceName);
if (service == null) {
// The service isn't installed, so the work done in the Stage.MODEL part is all there is to it
return false;
} else if (service.getState() != ServiceController.State.UP) {
// Service is installed but not up?
//throw new IllegalStateException(String.format("Cannot apply attribute %s to runtime; service %s is not in state %s, it is in state %s",
// attributeName, MessagingServices.JBOSS_MESSAGING, ServiceController.State.UP, service.getState()));
// No, don't barf; just let the update apply to the model and put the server in a reload-required state
return true;
} else {
if (!ActiveMQActivationService.isActiveMQServerActive(context, operation)) {
return false;
}
applyOperationToActiveMQService(operation, attributeName, newValue, service);
return false;
}
}
}
@Override
protected void revertUpdateToRuntime(final OperationContext context, final ModelNode operation,
final String attributeName, final ModelNode valueToRestore,
final ModelNode valueToRevert,
final Void handback) throws OperationFailedException {
AttributeDefinition attr = getAttributeDefinition(attributeName);
if (attr.equals(CREDENTIAL_REFERENCE)) {
rollbackCredentialStoreUpdate(attr, context, valueToRevert);
}
if (!attr.getFlags().contains(AttributeAccess.Flag.RESTART_ALL_SERVICES)) {
ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(OP_ADDR)));
ServiceController<?> service = registry.getService(serviceName);
if (service != null && service.getState() == ServiceController.State.UP) {
applyOperationToActiveMQService(operation, attributeName, valueToRestore, service);
}
}
}
private void applyOperationToActiveMQService(ModelNode operation, String attributeName, ModelNode newValue, ServiceController<?> activeMQServiceController) {
ActiveMQServerControl serverControl = ActiveMQServer.class.cast(activeMQServiceController.getValue()).getActiveMQServerControl();
if (serverControl == null) {
PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
throw ControllerLogger.ROOT_LOGGER.managementResourceNotFound(address);
}
try {
if (attributeName.equals(ServerDefinition.MESSAGE_COUNTER_SAMPLE_PERIOD.getName())) {
serverControl.setMessageCounterSamplePeriod(newValue.asLong());
} else if (attributeName.equals(ServerDefinition.MESSAGE_COUNTER_MAX_DAY_HISTORY.getName())) {
serverControl.setMessageCounterMaxDayCount(newValue.asInt());
} else if (attributeName.equals(ServerDefinition.STATISTICS_ENABLED.getName())) {
if (newValue.asBoolean()) {
serverControl.enableMessageCounters();
} else {
serverControl.disableMessageCounters();
}
} else {
// Bug! Someone added the attribute to the set but did not implement
throw MessagingLogger.ROOT_LOGGER.unsupportedRuntimeAttribute(attributeName);
}
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
private static class MessageCounterEnabledHandler implements OperationStepHandler {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
ModelNode aliased = getAliasedOperation(operation);
context.addStep(aliased, getHandlerForOperation(context, operation), OperationContext.Stage.MODEL, true);
}
private static ModelNode getAliasedOperation(ModelNode operation) {
ModelNode aliased = operation.clone();
aliased.get(ModelDescriptionConstants.NAME).set(ServerDefinition.STATISTICS_ENABLED.getName());
return aliased;
}
private static OperationStepHandler getHandlerForOperation(OperationContext context, ModelNode operation) {
ImmutableManagementResourceRegistration imrr = context.getResourceRegistration();
return imrr.getOperationHandler(PathAddress.EMPTY_ADDRESS, operation.get(OP).asString());
}
}
}
| 9,974
| 52.342246
| 161
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/DivertConfigurationWriteHandler.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 divert resource.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class DivertConfigurationWriteHandler extends ReloadRequiredWriteAttributeHandler {
public static final DivertConfigurationWriteHandler INSTANCE = new DivertConfigurationWriteHandler();
private DivertConfigurationWriteHandler() {
super(DivertDefinition.ATTRIBUTES);
}
}
| 1,576
| 39.435897
| 105
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/DefaultCredentials.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 java.util.UUID.randomUUID;
public class DefaultCredentials {
private static String username = null;
private static String password = null;
public static synchronized String getUsername() {
if (username == null) {
username = randomUUID().toString();
}
return username;
}
public static synchronized String getPassword() {
if (password == null) {
password = randomUUID().toString();
}
return password;
}
}
| 1,593
| 32.914894
| 70
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/GenericTransportDefinition.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.jboss.dmr.ModelType.STRING;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition;
/**
* Generic transport resource definition
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat Inc.
*/
public class GenericTransportDefinition extends AbstractTransportDefinition {
public static final SimpleAttributeDefinition SOCKET_BINDING = create("socket-binding", STRING)
.setRequired(false)
.setRestartAllServices()
.addAccessConstraint(SensitiveTargetAccessConstraintDefinition.SOCKET_BINDING_REF)
.build();
static AttributeDefinition[] ATTRIBUTES = { CommonAttributes.FACTORY_CLASS, SOCKET_BINDING, CommonAttributes.PARAMS };
static GenericTransportDefinition createAcceptorDefinition(boolean registerRuntimeOnly) {
return new GenericTransportDefinition(true, registerRuntimeOnly, CommonAttributes.ACCEPTOR);
}
static GenericTransportDefinition createConnectorDefinition(boolean registerRuntimeOnly) {
return new GenericTransportDefinition(false, registerRuntimeOnly, CommonAttributes.CONNECTOR);
}
private GenericTransportDefinition(boolean isAcceptor, boolean registerRuntimeOnly, String specificType) {
super(isAcceptor, specificType, registerRuntimeOnly, ATTRIBUTES);
}
}
| 2,624
| 43.491525
| 122
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/MessagingSubsystemParser_4_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_4_0 extends PersistentResourceXMLParser {
static final String NAMESPACE = "urn:jboss:domain:messaging-activemq:4.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,
// 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,798
| 82.409302
| 128
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/ServerDefinition.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.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.PERCENTAGE;
import static org.jboss.as.controller.client.helpers.MeasurementUnit.SECONDS;
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.InfiniteOrPositiveValidators.INT_INSTANCE;
import static org.wildfly.extension.messaging.activemq.InfiniteOrPositiveValidators.NEGATIVE_VALUE_CORRECTOR;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.VERSION_3_0_0;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumSet;
import java.util.List;
import java.util.function.BiConsumer;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
import org.apache.activemq.artemis.core.server.NetworkHealthCheck;
import org.apache.activemq.artemis.utils.critical.CriticalAnalyzerPolicy;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.ObjectTypeAttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition;
import org.jboss.as.controller.client.helpers.MeasurementUnit;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.operations.validation.EnumValidator;
import org.jboss.as.controller.operations.validation.IntRangeValidator;
import org.jboss.as.controller.operations.validation.LongRangeValidator;
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 static org.wildfly.extension.messaging.activemq.InfiniteOrPositiveValidators.LONG_INSTANCE;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.registry.AliasEntry;
import org.wildfly.extension.messaging.activemq.ha.LiveOnlyDefinition;
import org.wildfly.extension.messaging.activemq.ha.ReplicationColocatedDefinition;
import org.wildfly.extension.messaging.activemq.ha.ReplicationPrimaryDefinition;
import org.wildfly.extension.messaging.activemq.ha.ReplicationSecondaryDefinition;
import org.wildfly.extension.messaging.activemq.ha.SharedStoreColocatedDefinition;
import org.wildfly.extension.messaging.activemq.ha.SharedStorePrimaryDefinition;
import org.wildfly.extension.messaging.activemq.ha.SharedStoreSecondaryDefinition;
import org.wildfly.extension.messaging.activemq.jms.ConnectionFactoryDefinition;
import org.wildfly.extension.messaging.activemq.jms.JMSQueueDefinition;
import org.wildfly.extension.messaging.activemq.jms.JMSServerControlHandler;
import org.wildfly.extension.messaging.activemq.jms.JMSTopicDefinition;
import org.wildfly.extension.messaging.activemq.jms.PooledConnectionFactoryDefinition;
import org.wildfly.extension.messaging.activemq.jms.legacy.LegacyConnectionFactoryDefinition;
/**
* {@link org.jboss.as.controller.ResourceDefinition} for the messaging-activemq subsystem server resource.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class ServerDefinition extends PersistentResourceDefinition {
private static final String CLUSTER_ATTRIBUTE_GROUP = "cluster";
private static final String CRITICAL_ANALYZER_ATTRIBUTE_GROUP = "critical-analyzer";
private static final String DEBUG_ATTRIBUTE_GROUP = "debug";
private static final String JOURNAL_ATTRIBUTE_GROUP = "journal";
private static final String MANAGEMENT_ATTRIBUTE_GROUP = "management";
private static final String MESSAGE_EXPIRY_ATTRIBUTE_GROUP = "message-expiry";
private static final String NETWORK_ISOLATION_ATTRIBUTE_GROUP = "network-isolation";
private static final String SECURITY_ATTRIBUTE_GROUP = "security";
private static final String STATISTICS_ATTRIBUTE_GROUP = "statistics";
private static final String TRANSACTION_ATTRIBUTE_GROUP = "transaction";
/**
* @see ActiveMQDefaultConfiguration#getDefaultClusterPassword
*/
public static final SimpleAttributeDefinition CLUSTER_PASSWORD = create("cluster-password", ModelType.STRING, true)
.setAttributeGroup(CLUSTER_ATTRIBUTE_GROUP)
.setXmlName("password")
.setDefaultValue(new ModelNode("CHANGE ME!!"))
.setAllowExpression(true)
.setRestartAllServices()
.addAccessConstraint(SensitiveTargetAccessConstraintDefinition.CREDENTIAL)
.addAccessConstraint(MessagingExtension.MESSAGING_SECURITY_SENSITIVE_TARGET)
.setAlternatives("cluster-" + CredentialReference.CREDENTIAL_REFERENCE)
.build();
public static final ObjectTypeAttributeDefinition CREDENTIAL_REFERENCE =
CredentialReference.getAttributeBuilder("cluster-" + CredentialReference.CREDENTIAL_REFERENCE, CredentialReference.CREDENTIAL_REFERENCE, true, true)
.setAttributeGroup(CLUSTER_ATTRIBUTE_GROUP)
.setRestartAllServices()
.addAccessConstraint(SensitiveTargetAccessConstraintDefinition.CREDENTIAL)
.addAccessConstraint(MessagingExtension.MESSAGING_SECURITY_SENSITIVE_TARGET)
.setAlternatives(CLUSTER_PASSWORD.getName())
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultClusterUser
*/
public static final SimpleAttributeDefinition CLUSTER_USER = create("cluster-user", ModelType.STRING)
.setAttributeGroup(CLUSTER_ATTRIBUTE_GROUP)
.setXmlName("user")
.setDefaultValue(new ModelNode("ACTIVEMQ.CLUSTER.ADMIN.USER"))
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.addAccessConstraint(SensitiveTargetAccessConstraintDefinition.CREDENTIAL)
.addAccessConstraint(MessagingExtension.MESSAGING_SECURITY_SENSITIVE_TARGET)
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultScheduledThreadPoolMaxSize
*/
public static final AttributeDefinition SCHEDULED_THREAD_POOL_MAX_SIZE = 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();
public static final SimpleAttributeDefinition SECURITY_DOMAIN = create("security-domain", ModelType.STRING)
.setAttributeGroup(SECURITY_ATTRIBUTE_GROUP)
.setXmlName("domain")
.setAlternatives("elytron-domain")
.setRequired(false)
.setAllowExpression(false) // references the security domain service name
.setRestartAllServices()
.addAccessConstraint(SensitiveTargetAccessConstraintDefinition.SECURITY_DOMAIN_REF)
.addAccessConstraint(MessagingExtension.MESSAGING_SECURITY_SENSITIVE_TARGET)
.setCapabilityReference(Capabilities.LEGACY_SECURITY_DOMAIN_CAPABILITY.getName(), Capabilities.ACTIVEMQ_SERVER_CAPABILITY)
.setDeprecated(MessagingExtension.VERSION_2_0_0)
.build();
public static final SimpleAttributeDefinition ELYTRON_DOMAIN = create("elytron-domain", ModelType.STRING)
.setAttributeGroup(SECURITY_ATTRIBUTE_GROUP)
.setRequired(false)
.setAlternatives(SECURITY_DOMAIN.getName())
.setAllowExpression(false)
.setRestartAllServices()
.addAccessConstraint(SensitiveTargetAccessConstraintDefinition.ELYTRON_SECURITY_DOMAIN_REF)
.addAccessConstraint(MessagingExtension.MESSAGING_SECURITY_SENSITIVE_TARGET)
.setCapabilityReference(Capabilities.ELYTRON_DOMAIN_CAPABILITY, Capabilities.ACTIVEMQ_SERVER_CAPABILITY)
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultThreadPoolMaxSize
*/
public static final AttributeDefinition THREAD_POOL_MAX_SIZE = 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();
public static final SimpleAttributeDefinition OVERRIDE_IN_VM_SECURITY = create("override-in-vm-security", BOOLEAN)
.setAttributeGroup(SECURITY_ATTRIBUTE_GROUP)
.setDefaultValue(ModelNode.TRUE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#isDefaultWildcardRoutingEnabled
*/
public static final SimpleAttributeDefinition WILD_CARD_ROUTING_ENABLED = create("wild-card-routing-enabled", BOOLEAN)
.setDefaultValue(ModelNode.TRUE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
public static final SimpleAttributeDefinition STATISTICS_ENABLED = create(ModelDescriptionConstants.STATISTICS_ENABLED, BOOLEAN)
.setAttributeGroup(STATISTICS_ATTRIBUTE_GROUP)
.setXmlName("enabled")
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setAllowExpression(true)
.build();
// no default values, depends on whether NIO or AIO is used.
public static final SimpleAttributeDefinition JOURNAL_BUFFER_SIZE = create("journal-buffer-size", LONG)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setXmlName("buffer-size")
.setMeasurementUnit(BYTES)
.setRequired(false)
.setAllowExpression(true)
.setValidator(new LongRangeValidator(0,Long.MAX_VALUE,true,true))
.setRestartAllServices()
.build();
// no default values, depends on whether NIO or AIO is used.
public static final SimpleAttributeDefinition JOURNAL_BUFFER_TIMEOUT = create("journal-buffer-timeout", LONG)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setXmlName("buffer-timeout")
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultJournalCompactMinFiles
*/
public static final SimpleAttributeDefinition JOURNAL_COMPACT_MIN_FILES = create("journal-compact-min-files", INT)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setXmlName("compact-min-files")
.setDefaultValue(new ModelNode(10))
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultJournalCompactPercentage
*/
public static final SimpleAttributeDefinition JOURNAL_COMPACT_PERCENTAGE = create("journal-compact-percentage", INT)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setXmlName("compact-percentage")
.setDefaultValue(new ModelNode(30))
.setMeasurementUnit(PERCENTAGE)
.setValidator(new IntRangeValidator(0, 100, true, true))
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
// TODO: if this attribute is set, warn/error if any fs-related journal attribute is set.
// TODO: add capability for data-source https://github.com/wildfly/wildfly-capabilities/blob/main/org/wildfly/data-source/capability.adoc
public static final SimpleAttributeDefinition JOURNAL_DATASOURCE = create("journal-datasource", STRING)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setXmlName("datasource")
.setRequired(false)
// references another resource
.setAllowExpression(false)
.setCapabilityReference(Capabilities.DATA_SOURCE_CAPABILITY, Capabilities.ACTIVEMQ_SERVER_CAPABILITY)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultBindingsTableName
*/
public static final SimpleAttributeDefinition JOURNAL_BINDINGS_TABLE = create("journal-bindings-table", STRING)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setXmlName("bindings-table")
.setRequired(false)
.setDefaultValue(new ModelNode("BINDINGS"))
.setAllowExpression(true)
.setRestartAllServices()
.build();
@Deprecated
public static final SimpleAttributeDefinition JOURNAL_JMS_BINDINGS_TABLE = create("journal-jms-bindings-table", STRING)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setXmlName("jms-bindings-table")
.setRequired(false)
.setDefaultValue(new ModelNode("JMS_BINDINGS"))
.setAllowExpression(true)
.setDeprecated(VERSION_3_0_0)
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultLargeMessagesTableName
*/
public static final SimpleAttributeDefinition JOURNAL_LARGE_MESSAGES_TABLE = create("journal-large-messages-table", STRING)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setXmlName("large-messages-table")
.setRequired(false)
.setDefaultValue(new ModelNode("LARGE_MESSAGES"))
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultMessageTableName
*/
public static final SimpleAttributeDefinition JOURNAL_MESSAGES_TABLE = create("journal-messages-table", STRING)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setXmlName("messages-table")
.setRequired(false)
.setDefaultValue(new ModelNode("MESSAGES"))
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultNodeManagerStoreTableName
*/
public static final SimpleAttributeDefinition JOURNAL_NODE_MANAGER_STORE_TABLE = create("journal-node-manager-store-table", STRING)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setXmlName("node-manager-store-table")
.setRequired(false)
.setDefaultValue(new ModelNode("NODE_MANAGER_STORE"))
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultPageStoreTableName
*/
public static final SimpleAttributeDefinition JOURNAL_PAGE_STORE_TABLE = create("journal-page-store-table", STRING)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setXmlName("page-store-table")
.setRequired(false)
.setDefaultValue(new ModelNode("PAGE_STORE"))
.setAllowExpression(true)
.setRestartAllServices()
.build();
public static final AttributeDefinition JOURNAL_DATABASE = create("journal-database", STRING)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setXmlName("database")
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultJdbcLockExpirationMillis()
*/
public static final AttributeDefinition JOURNAL_JDBC_LOCK_EXPIRATION = create("journal-jdbc-lock-expiration", INT)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setXmlName("jdbc-lock-expiration")
.setDefaultValue(new ModelNode(20))
.setMeasurementUnit(SECONDS)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultJdbcLockRenewPeriodMillis()
*/
public static final AttributeDefinition JOURNAL_JDBC_LOCK_RENEW_PERIOD = create("journal-jdbc-lock-renew-period", INT)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setXmlName("jdbc-lock-renew-period")
.setDefaultValue(new ModelNode(4))
.setMeasurementUnit(SECONDS)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultJdbcNetworkTimeout()
*/
public static final AttributeDefinition JOURNAL_JDBC_NETWORK_TIMEOUT = create("journal-jdbc-network-timeout", INT)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setXmlName("jdbc-network-timeout")
.setDefaultValue(new ModelNode(20))
.setMeasurementUnit(SECONDS)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultJournalFileSize
*/
public static final SimpleAttributeDefinition JOURNAL_FILE_SIZE = create("journal-file-size", LONG)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setXmlName("file-size")
.setDefaultValue(new ModelNode(10485760L))
.setMeasurementUnit(BYTES)
.setValidator(new LongRangeValidator(1024, Long.MAX_VALUE, true, true))
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
// no default values, depends on whether NIO or AIO is used.
public static final SimpleAttributeDefinition JOURNAL_MAX_IO = create("journal-max-io", INT)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setXmlName("max-io")
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultJournalMinFiles
*/
public static final SimpleAttributeDefinition JOURNAL_MIN_FILES = create("journal-min-files", INT)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setXmlName("min-files")
.setDefaultValue(new ModelNode(2))
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.setValidator(new IntRangeValidator(2, true, true))
.build();
/**
* This is different from currant Artemis default value.
* @see ActiveMQDefaultConfiguration#getDefaultJournalPoolFiles
*/
public static final SimpleAttributeDefinition JOURNAL_POOL_FILES = create("journal-pool-files", INT)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setXmlName("pool-files")
.setDefaultValue(new ModelNode(10))
.setRequired(false)
.setAllowExpression(true)
.setCorrector(InfiniteOrPositiveValidators.NEGATIVE_VALUE_CORRECTOR)
.setValidator(InfiniteOrPositiveValidators.INT_INSTANCE)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultJournalFileOpenTimeout()
*/
public static final SimpleAttributeDefinition JOURNAL_FILE_OPEN_TIMEOUT = create("journal-file-open-timeout", INT)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setXmlName("file-open-timeout")
.setDefaultValue(new ModelNode(5))
.setRequired(false)
.setAllowExpression(true)
.setMeasurementUnit(SECONDS)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#isDefaultJournalSyncNonTransactional
*/
public static final SimpleAttributeDefinition JOURNAL_SYNC_NON_TRANSACTIONAL = create("journal-sync-non-transactional", BOOLEAN)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setXmlName("sync-non-transactional")
.setDefaultValue(ModelNode.TRUE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#isDefaultJournalSyncTransactional
*/
public static final SimpleAttributeDefinition JOURNAL_SYNC_TRANSACTIONAL = create("journal-sync-transactional", BOOLEAN)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setXmlName("sync-transactional")
.setDefaultValue(ModelNode.TRUE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
public static final SimpleAttributeDefinition JOURNAL_TYPE = create("journal-type", ModelType.STRING)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setXmlName("type")
.setDefaultValue(new ModelNode(JournalType.ASYNCIO.toString()))
.setRequired(false)
.setAllowExpression(true)
// list allowed values explicitly to exclude MAPPED
.setValidator(EnumValidator.create(JournalType.class))
.setRestartAllServices()
.build();
public static final SimpleAttributeDefinition JOURNAL_MAX_ATTIC_FILES = create("journal-max-attic-files", ModelType.INT)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setXmlName("max-attic-files")
.setDefaultValue(new ModelNode(10))
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#isDefaultJournalLogWriteRate
*/
public static final SimpleAttributeDefinition LOG_JOURNAL_WRITE_RATE = create("log-journal-write-rate", BOOLEAN)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setXmlName("log-write-rate")
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultConnectionTtlOverride
*/
public static final SimpleAttributeDefinition CONNECTION_TTL_OVERRIDE = create("connection-ttl-override", LONG)
.setDefaultValue(new ModelNode(-1L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.setValidator(InfiniteOrPositiveValidators.LONG_INSTANCE)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#isDefaultAsyncConnectionExecutionEnabled
*/
public static final SimpleAttributeDefinition ASYNC_CONNECTION_EXECUTION_ENABLED = create("async-connection-execution-enabled", BOOLEAN)
.setDefaultValue(ModelNode.TRUE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultMessageCounterMaxDayHistory
*/
public static final SimpleAttributeDefinition MESSAGE_COUNTER_MAX_DAY_HISTORY = create("message-counter-max-day-history", INT)
.setAttributeGroup(STATISTICS_ATTRIBUTE_GROUP)
.setDefaultValue(new ModelNode(10))
.setMeasurementUnit(DAYS)
.setRequired(false)
.setAllowExpression(true)
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultMessageCounterSamplePeriod
*/
public static final SimpleAttributeDefinition MESSAGE_COUNTER_SAMPLE_PERIOD = create("message-counter-sample-period", LONG)
.setAttributeGroup(STATISTICS_ATTRIBUTE_GROUP)
.setDefaultValue(new ModelNode(10000L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultTransactionTimeout
*/
public static final SimpleAttributeDefinition TRANSACTION_TIMEOUT = create("transaction-timeout", LONG)
.setAttributeGroup(TRANSACTION_ATTRIBUTE_GROUP)
.setXmlName("timeout")
.setDefaultValue(new ModelNode(300000L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultTransactionTimeoutScanPeriod
*/
public static final SimpleAttributeDefinition TRANSACTION_TIMEOUT_SCAN_PERIOD = create("transaction-timeout-scan-period", LONG)
.setAttributeGroup(TRANSACTION_ATTRIBUTE_GROUP)
.setXmlName("scan-period")
.setDefaultValue(new ModelNode(1000L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultMessageExpiryScanPeriod
*/
public static final SimpleAttributeDefinition MESSAGE_EXPIRY_SCAN_PERIOD = create("message-expiry-scan-period", LONG)
.setAttributeGroup(MESSAGE_EXPIRY_ATTRIBUTE_GROUP)
.setXmlName("scan-period")
.setDefaultValue(new ModelNode(30000L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultMessageExpiryThreadPriority
*/
public static final SimpleAttributeDefinition MESSAGE_EXPIRY_THREAD_PRIORITY = create("message-expiry-thread-priority", INT)
.setAttributeGroup(MESSAGE_EXPIRY_ATTRIBUTE_GROUP)
.setXmlName("thread-priority")
.setDefaultValue(new ModelNode(3))
.setRequired(false)
.setAllowExpression(true)
.setValidator(new IntRangeValidator(Thread.MIN_PRIORITY, Thread.MAX_PRIORITY, true, true))
.setRestartAllServices()
.build();
// Property no longer exists since Artemis 2
@Deprecated
public static final SimpleAttributeDefinition PERF_BLAST_PAGES = create("perf-blast-pages", INT)
.setAttributeGroup(DEBUG_ATTRIBUTE_GROUP)
.setDefaultValue(new ModelNode(-1))
.setRequired(false)
.setAllowExpression(true)
.setCorrector(InfiniteOrPositiveValidators.NEGATIVE_VALUE_CORRECTOR)
.setValidator(InfiniteOrPositiveValidators.INT_INSTANCE)
.setRestartAllServices()
.setDeprecated(VERSION_3_0_0)
.build();
// Property no longer exists since Artemis 2
@Deprecated
public static final SimpleAttributeDefinition RUN_SYNC_SPEED_TEST = create("run-sync-speed-test", BOOLEAN)
.setAttributeGroup(DEBUG_ATTRIBUTE_GROUP)
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.setDeprecated(VERSION_3_0_0)
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultServerDumpInterval
*/
public static final SimpleAttributeDefinition SERVER_DUMP_INTERVAL = create("server-dump-interval", LONG)
.setAttributeGroup(DEBUG_ATTRIBUTE_GROUP)
.setDefaultValue(new ModelNode(-1L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.setValidator(InfiniteOrPositiveValidators.LONG_INSTANCE)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultMemoryMeasureInterval
*/
public static final SimpleAttributeDefinition MEMORY_MEASURE_INTERVAL = create("memory-measure-interval", LONG)
.setAttributeGroup(DEBUG_ATTRIBUTE_GROUP)
.setDefaultValue(new ModelNode(-1L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.setValidator(InfiniteOrPositiveValidators.LONG_INSTANCE)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultMemoryWarningThreshold
*/
public static final SimpleAttributeDefinition MEMORY_WARNING_THRESHOLD = create("memory-warning-threshold", INT)
.setAttributeGroup(DEBUG_ATTRIBUTE_GROUP)
.setDefaultValue(new ModelNode(25))
.setMeasurementUnit(PERCENTAGE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultSecurityInvalidationInterval
*/
public static final SimpleAttributeDefinition SECURITY_INVALIDATION_INTERVAL = create("security-invalidation-interval", LONG)
.setAttributeGroup(SECURITY_ATTRIBUTE_GROUP)
.setXmlName("invalidation-interval")
.setDefaultValue(new ModelNode(10000L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.addAccessConstraint(MessagingExtension.MESSAGING_SECURITY_SENSITIVE_TARGET)
.build();
/**
* @see ActiveMQDefaultConfiguration#isDefaultSecurityEnabled
*/
public static final SimpleAttributeDefinition SECURITY_ENABLED = create("security-enabled", BOOLEAN)
.setAttributeGroup(SECURITY_ATTRIBUTE_GROUP)
.setXmlName("enabled")
.setDefaultValue(ModelNode.TRUE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.addAccessConstraint(MessagingExtension.MESSAGING_SECURITY_SENSITIVE_TARGET)
.build();
/**
* @see ActiveMQDefaultConfiguration#isDefaultPersistenceEnabled
*/
public static final SimpleAttributeDefinition PERSISTENCE_ENABLED = create("persistence-enabled", BOOLEAN)
.setDefaultValue(ModelNode.TRUE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultManagementNotificationAddress
*/
public static final SimpleAttributeDefinition MANAGEMENT_NOTIFICATION_ADDRESS = create("management-notification-address", ModelType.STRING)
.setAttributeGroup(MANAGEMENT_ATTRIBUTE_GROUP)
.setXmlName("notification-address")
.setDefaultValue(new ModelNode("activemq.notifications"))
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.addAccessConstraint(MessagingExtension.MESSAGING_MANAGEMENT_SENSITIVE_TARGET)
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultManagementAddress
*/
public static final SimpleAttributeDefinition MANAGEMENT_ADDRESS = create("management-address", ModelType.STRING)
.setAttributeGroup(MANAGEMENT_ATTRIBUTE_GROUP)
.setXmlName("address")
.setDefaultValue(new ModelNode("activemq.management"))
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.addAccessConstraint(MessagingExtension.MESSAGING_MANAGEMENT_SENSITIVE_TARGET)
.build();
public static final SimpleAttributeDefinition JMX_MANAGEMENT_ENABLED = create("jmx-management-enabled", BOOLEAN)
.setAttributeGroup(MANAGEMENT_ATTRIBUTE_GROUP)
.setXmlName("jmx-enabled")
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.addAccessConstraint(MessagingExtension.MESSAGING_MANAGEMENT_SENSITIVE_TARGET)
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultJmxDomain
*/
public static final SimpleAttributeDefinition JMX_DOMAIN = create("jmx-domain", ModelType.STRING)
.setAttributeGroup(MANAGEMENT_ATTRIBUTE_GROUP)
.setDefaultValue(new ModelNode("org.apache.activemq.artemis"))
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.addAccessConstraint(MessagingExtension.MESSAGING_MANAGEMENT_SENSITIVE_TARGET)
.build();
/**
* @see ActiveMQDefaultConfiguration#isDefaultPersistIdCache
*/
public static final SimpleAttributeDefinition PERSIST_ID_CACHE = create("persist-id-cache", BOOLEAN)
.setDefaultValue(ModelNode.TRUE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#isDefaultPersistDeliveryCountBeforeDelivery
*/
public static final SimpleAttributeDefinition PERSIST_DELIVERY_COUNT_BEFORE_DELIVERY = create("persist-delivery-count-before-delivery", BOOLEAN)
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultIdCacheSize
*/
public static final SimpleAttributeDefinition ID_CACHE_SIZE = create("id-cache-size", INT)
.setDefaultValue(new ModelNode(20000))
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultMaxConcurrentPageIo
*/
public static final SimpleAttributeDefinition PAGE_MAX_CONCURRENT_IO = create("page-max-concurrent-io", INT)
.setDefaultValue(new ModelNode(5))
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#isDefaultCreateBindingsDir
*/
public static final SimpleAttributeDefinition CREATE_BINDINGS_DIR = create("create-bindings-dir", BOOLEAN)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setDefaultValue(ModelNode.TRUE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#isDefaultCreateJournalDir
*/
public static final SimpleAttributeDefinition CREATE_JOURNAL_DIR = create("create-journal-dir", BOOLEAN)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setDefaultValue(ModelNode.TRUE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultMaxDiskUsage
*/
public static final SimpleAttributeDefinition GLOBAL_MAX_DISK_USAGE = create("global-max-disk-usage", INT)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setMeasurementUnit(MeasurementUnit.PERCENTAGE)
.setDefaultValue(new ModelNode(100))
.setRequired(false)
.setValidator(new IntRangeValidator(-1, 100))
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultDiskScanPeriod
*/
public static final SimpleAttributeDefinition DISK_SCAN_PERIOD = create("disk-scan-period", INT)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setMeasurementUnit(MeasurementUnit.MILLISECONDS)
.setDefaultValue(new ModelNode(5000))
.setValidator(INT_INSTANCE)
.setCorrector(NEGATIVE_VALUE_CORRECTOR)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultMaxGlobalSize
*/
public static final SimpleAttributeDefinition GLOBAL_MAX_MEMORY_SIZE = create("global-max-memory-size", LONG)
.setAttributeGroup(JOURNAL_ATTRIBUTE_GROUP)
.setMeasurementUnit(MeasurementUnit.BYTES)
.setDefaultValue(new ModelNode(-1L))
.setCorrector(NEGATIVE_VALUE_CORRECTOR)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultNetworkCheckNic
*/
public static final SimpleAttributeDefinition NETWORK_CHECK_NIC = create("network-check-nic", STRING)
.setAttributeGroup(NETWORK_ISOLATION_ATTRIBUTE_GROUP)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultNetworkCheckPeriod
*/
public static final SimpleAttributeDefinition NETWORK_CHECK_PERIOD = create("network-check-period", LONG)
.setAttributeGroup(NETWORK_ISOLATION_ATTRIBUTE_GROUP)
.setMeasurementUnit(MeasurementUnit.MILLISECONDS)
.setDefaultValue(new ModelNode(5000L))
.setRequired(false)
.setValidator(LONG_INSTANCE)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultNetworkCheckTimeout
*/
public static final SimpleAttributeDefinition NETWORK_CHECK_TIMEOUT = create("network-check-timeout", LONG)
.setAttributeGroup(NETWORK_ISOLATION_ATTRIBUTE_GROUP)
.setMeasurementUnit(MeasurementUnit.MILLISECONDS)
.setDefaultValue(new ModelNode(1000L))
.setRequired(false)
.setValidator(LONG_INSTANCE)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultNetworkCheckList
*/
public static final SimpleAttributeDefinition NETWORK_CHECK_LIST = create("network-check-list", STRING)
.setAttributeGroup(NETWORK_ISOLATION_ATTRIBUTE_GROUP)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultNetworkCheckURLList
*/
public static final SimpleAttributeDefinition NETWORK_CHECK_URL_LIST = create("network-check-url-list", STRING)
.setAttributeGroup(NETWORK_ISOLATION_ATTRIBUTE_GROUP)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see NetworkHealthCheck#IPV4_DEFAULT_COMMAND
*/
public static final SimpleAttributeDefinition NETWORK_CHECK_PING_COMMAND = create("network-check-ping-command", STRING)
.setAttributeGroup(NETWORK_ISOLATION_ATTRIBUTE_GROUP)
.setDefaultValue(new ModelNode("ping -c 1 -t %d %s"))
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see NetworkHealthCheck#IPV6_DEFAULT_COMMAND
*/
public static final SimpleAttributeDefinition NETWORK_CHECK_PING6_COMMAND = create("network-check-ping6-command", STRING)
.setAttributeGroup(NETWORK_ISOLATION_ATTRIBUTE_GROUP)
.setDefaultValue(new ModelNode("ping6 -c 1 %2$s"))
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
public static final SimpleAttributeDefinition CRITICAL_ANALYZER_ENABLED = create("critical-analyzer-enabled", BOOLEAN)
.setAttributeGroup(CRITICAL_ANALYZER_ATTRIBUTE_GROUP)
.setXmlName("enabled")
.setDefaultValue(ModelNode.TRUE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
public static final SimpleAttributeDefinition CRITICAL_ANALYZER_CHECK_PERIOD = create("critical-analyzer-check-period", LONG)
.setAttributeGroup(CRITICAL_ANALYZER_ATTRIBUTE_GROUP)
.setXmlName("check-period")
.setDefaultValue(new ModelNode(0L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getCriticalAnalyzerTimeout
*/
public static final SimpleAttributeDefinition CRITICAL_ANALYZER_TIMEOUT = create("critical-analyzer-timeout", LONG)
.setAttributeGroup(CRITICAL_ANALYZER_ATTRIBUTE_GROUP)
.setXmlName("timeout")
.setDefaultValue(new ModelNode(120000L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
public static final SimpleAttributeDefinition CRITICAL_ANALYZER_POLICY = create("critical-analyzer-policy", STRING)
.setAttributeGroup(CRITICAL_ANALYZER_ATTRIBUTE_GROUP)
.setXmlName("policy")
.setDefaultValue(new ModelNode("LOG"))
.setValidator(EnumValidator.create(CriticalAnalyzerPolicy.class, EnumSet.allOf(CriticalAnalyzerPolicy.class)))
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
public static final SimpleAttributeDefinition ADDRESS_QUEUE_SCAN_PERIOD = create("address-queue-scan-period", LONG)
.setDefaultValue(new ModelNode(30000L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
public static final AttributeDefinition[] ATTRIBUTES = {PERSISTENCE_ENABLED, SCHEDULED_THREAD_POOL_MAX_SIZE,
THREAD_POOL_MAX_SIZE, SECURITY_DOMAIN, ELYTRON_DOMAIN, SECURITY_ENABLED, SECURITY_INVALIDATION_INTERVAL,
OVERRIDE_IN_VM_SECURITY, WILD_CARD_ROUTING_ENABLED, MANAGEMENT_ADDRESS, MANAGEMENT_NOTIFICATION_ADDRESS,
CLUSTER_USER, CLUSTER_PASSWORD, CREDENTIAL_REFERENCE, JMX_MANAGEMENT_ENABLED, JMX_DOMAIN, STATISTICS_ENABLED, MESSAGE_COUNTER_SAMPLE_PERIOD,
MESSAGE_COUNTER_MAX_DAY_HISTORY, CONNECTION_TTL_OVERRIDE, ASYNC_CONNECTION_EXECUTION_ENABLED, TRANSACTION_TIMEOUT,
TRANSACTION_TIMEOUT_SCAN_PERIOD, MESSAGE_EXPIRY_SCAN_PERIOD, MESSAGE_EXPIRY_THREAD_PRIORITY, ID_CACHE_SIZE, PERSIST_ID_CACHE,
CommonAttributes.INCOMING_INTERCEPTORS, CommonAttributes.OUTGOING_INTERCEPTORS,
PERSIST_DELIVERY_COUNT_BEFORE_DELIVERY,
PAGE_MAX_CONCURRENT_IO, CREATE_BINDINGS_DIR, CREATE_JOURNAL_DIR, JOURNAL_TYPE, JOURNAL_BUFFER_TIMEOUT,
JOURNAL_BUFFER_SIZE,
JOURNAL_DATASOURCE, JOURNAL_DATABASE,
JOURNAL_JDBC_LOCK_EXPIRATION, JOURNAL_JDBC_LOCK_RENEW_PERIOD,
JOURNAL_JDBC_NETWORK_TIMEOUT,
JOURNAL_MESSAGES_TABLE, JOURNAL_BINDINGS_TABLE, JOURNAL_JMS_BINDINGS_TABLE, JOURNAL_LARGE_MESSAGES_TABLE, JOURNAL_PAGE_STORE_TABLE,
JOURNAL_NODE_MANAGER_STORE_TABLE,
JOURNAL_SYNC_TRANSACTIONAL, JOURNAL_SYNC_NON_TRANSACTIONAL, LOG_JOURNAL_WRITE_RATE,
JOURNAL_FILE_SIZE, JOURNAL_MIN_FILES, JOURNAL_POOL_FILES, JOURNAL_FILE_OPEN_TIMEOUT, JOURNAL_COMPACT_PERCENTAGE,
JOURNAL_COMPACT_MIN_FILES, JOURNAL_MAX_IO, JOURNAL_MAX_ATTIC_FILES,
PERF_BLAST_PAGES, RUN_SYNC_SPEED_TEST, SERVER_DUMP_INTERVAL, MEMORY_WARNING_THRESHOLD, MEMORY_MEASURE_INTERVAL,
GLOBAL_MAX_DISK_USAGE, DISK_SCAN_PERIOD, GLOBAL_MAX_MEMORY_SIZE,
NETWORK_CHECK_NIC, NETWORK_CHECK_PERIOD, NETWORK_CHECK_TIMEOUT,
NETWORK_CHECK_LIST, NETWORK_CHECK_URL_LIST, NETWORK_CHECK_PING_COMMAND, NETWORK_CHECK_PING6_COMMAND,
CRITICAL_ANALYZER_ENABLED, CRITICAL_ANALYZER_CHECK_PERIOD, CRITICAL_ANALYZER_TIMEOUT, CRITICAL_ANALYZER_POLICY,
ADDRESS_QUEUE_SCAN_PERIOD
};
private final boolean registerRuntimeOnly;
ServerDefinition(BiConsumer<OperationContext, String> broadcastCommandDispatcherFactoryInstaller, boolean registerRuntimeOnly) {
super(new SimpleResourceDefinition.Parameters(MessagingExtension.SERVER_PATH, MessagingExtension.getResourceDescriptionResolver(CommonAttributes.SERVER))
.setAddHandler(new ServerAdd(broadcastCommandDispatcherFactoryInstaller))
.setRemoveHandler(ServerRemove.INSTANCE)
.addCapabilities(Capabilities.ACTIVEMQ_SERVER_CAPABILITY));
this.registerRuntimeOnly = registerRuntimeOnly;
}
@Override
public void registerOperations(ManagementResourceRegistration resourceRegistration) {
super.registerOperations(resourceRegistration);
if (registerRuntimeOnly) {
ExportJournalOperation.registerOperation(resourceRegistration, getResourceDescriptionResolver());
ImportJournalOperation.registerOperation(resourceRegistration, getResourceDescriptionResolver());
PrintDataOperation.INSTANCE.registerOperation(resourceRegistration, getResourceDescriptionResolver());
ActiveMQServerControlHandler.INSTANCE.registerOperations(resourceRegistration, getResourceDescriptionResolver());
JMSServerControlHandler.INSTANCE.registerOperations(resourceRegistration, getResourceDescriptionResolver());
AddressSettingsResolveHandler.registerOperationHandler(resourceRegistration, getResourceDescriptionResolver());
}
}
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
ActiveMQServerControlWriteHandler.INSTANCE.registerAttributes(resourceRegistration, registerRuntimeOnly);
if (registerRuntimeOnly) {
ActiveMQServerControlHandler.INSTANCE.registerAttributes(resourceRegistration);
}
}
@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(ATTRIBUTES);
}
@Override
protected List<? extends PersistentResourceDefinition> getChildren() {
List<PersistentResourceDefinition> children = new ArrayList<>();
// Static resources
children.addAll(Arrays.asList(// HA policy
new LiveOnlyDefinition(),
new ReplicationPrimaryDefinition(MessagingExtension.REPLICATION_PRIMARY_PATH, false, registerRuntimeOnly),
new ReplicationSecondaryDefinition(MessagingExtension.REPLICATION_SECONDARY_PATH, false, registerRuntimeOnly),
new ReplicationColocatedDefinition(),
new SharedStorePrimaryDefinition(MessagingExtension.SHARED_STORE_PRIMARY_PATH, false),
new SharedStoreSecondaryDefinition(MessagingExtension.SHARED_STORE_SECONDARY_PATH, false),
new SharedStoreColocatedDefinition(),
new AddressSettingDefinition(),
new SecuritySettingDefinition(),
// Acceptors
new HTTPAcceptorDefinition(),
new DivertDefinition(false),
new ConnectorServiceDefinition(),
new GroupingHandlerDefinition(),
// Jakarta Messaging resources
new LegacyConnectionFactoryDefinition(),
new PooledConnectionFactoryDefinition(false)));
// Dynamic resources (depending on registerRuntimeOnly)
// acceptors
children.add(GenericTransportDefinition.createAcceptorDefinition(registerRuntimeOnly));
children.add(InVMTransportDefinition.createAcceptorDefinition(registerRuntimeOnly));
children.add(RemoteTransportDefinition.createAcceptorDefinition(registerRuntimeOnly));
// connectors
children.add(GenericTransportDefinition.createConnectorDefinition(registerRuntimeOnly));
children.add(InVMTransportDefinition.createConnectorDefinition(registerRuntimeOnly));
children.add(RemoteTransportDefinition.createConnectorDefinition(registerRuntimeOnly));
children.add(new HTTPConnectorDefinition(registerRuntimeOnly));
children.add(new BridgeDefinition(registerRuntimeOnly));
children.add(new BroadcastGroupDefinition(registerRuntimeOnly));
children.add(new SocketBroadcastGroupDefinition(registerRuntimeOnly));
children.add(new JGroupsBroadcastGroupDefinition(registerRuntimeOnly));
// WFLY-10518 - keep discovery-group resource under server
children.add(new DiscoveryGroupDefinition(registerRuntimeOnly, false));
children.add(new JGroupsDiscoveryGroupDefinition(registerRuntimeOnly, false));
children.add(new SocketDiscoveryGroupDefinition(registerRuntimeOnly, false));
children.add(new ClusterConnectionDefinition(registerRuntimeOnly));
children.add(new QueueDefinition(registerRuntimeOnly, MessagingExtension.QUEUE_PATH));
children.add(new JMSQueueDefinition(false, registerRuntimeOnly));
children.add(new JMSTopicDefinition(false, registerRuntimeOnly));
children.add(new ConnectionFactoryDefinition(registerRuntimeOnly));
return children;
}
@Override
public void registerChildren(ManagementResourceRegistration resourceRegistration) {
super.registerChildren(resourceRegistration);
resourceRegistration.registerAlias(MessagingExtension.REPLICATION_MASTER_PATH, createAlias(resourceRegistration, MessagingExtension.REPLICATION_PRIMARY_PATH));
resourceRegistration.registerAlias(MessagingExtension.REPLICATION_SLAVE_PATH, createAlias(resourceRegistration, MessagingExtension.REPLICATION_SECONDARY_PATH));
resourceRegistration.registerAlias(MessagingExtension.SHARED_STORE_MASTER_PATH, createAlias(resourceRegistration, MessagingExtension.SHARED_STORE_PRIMARY_PATH));
resourceRegistration.registerAlias(MessagingExtension.SHARED_STORE_SLAVE_PATH, createAlias(resourceRegistration, MessagingExtension.SHARED_STORE_SECONDARY_PATH));
// runtime queues and core-address are only registered when it is ok to register runtime resource (ie they are not registered on HC).
if (registerRuntimeOnly) {
resourceRegistration.registerSubModel(new QueueDefinition(registerRuntimeOnly, MessagingExtension.RUNTIME_QUEUE_PATH));
resourceRegistration.registerSubModel(new CoreAddressDefinition());
}
}
private static AliasEntry createAlias(ManagementResourceRegistration resourceRegistration, PathElement target) {
return new AliasEntry(resourceRegistration.getSubModel(PathAddress.pathAddress(target))) {
@Override
public PathAddress convertToTargetAddress(PathAddress aliasAddress, AliasContext aliasContext) {
return aliasAddress.getParent().append(target);
}
};
}
private enum JournalType {
NIO, ASYNCIO;
}
}
| 53,190
| 48.205365
| 170
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/ServerRemove.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.AbstractRemoveStepHandler;
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.wildfly.extension.messaging.activemq.jms.JMSServices;
/**
* Remove an ActiveMQ Server.
*
* @author Emanuel Muckenhuber
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
class ServerRemove extends AbstractRemoveStepHandler {
static final ServerRemove INSTANCE = new ServerRemove();
private ServerRemove() {
}
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final String serverName = context.getCurrentAddressValue();
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(serverName);
context.removeService(JMSServices.getJmsManagerBaseServiceName(serviceName));
context.removeService(MessagingServices.getActiveMQServiceName(serverName));
// remove services related to broadcast-group/discovery-group that are started
// when the server is added
if (model.hasDefined(CommonAttributes.BROADCAST_GROUP)) {
for (String name : model.get(CommonAttributes.BROADCAST_GROUP).keys()) {
context.removeService(GroupBindingService.getBroadcastBaseServiceName(serviceName).append(name));
}
}
if (model.hasDefined(CommonAttributes.DISCOVERY_GROUP)) {
for (String name : model.get(CommonAttributes.DISCOVERY_GROUP).keys()) {
context.removeService(GroupBindingService.getDiscoveryBaseServiceName(serviceName).append(name));
}
}
}
}
| 2,845
| 41.477612
| 131
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/InVMTransportDefinition.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.jboss.dmr.ModelType.INT;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.PARAMS;
import javax.xml.stream.XMLStreamException;
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.dmr.ModelNode;
/**
* remote acceptor resource definition
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat Inc.
*/
public class InVMTransportDefinition extends AbstractTransportDefinition {
public static final SimpleAttributeDefinition SERVER_ID = create("server-id", INT)
.setAllowExpression(true)
.setAttributeMarshaller(new AttributeMarshaller() {
public void marshallAsAttribute(AttributeDefinition attribute, ModelNode resourceModel, boolean marshallDefault, XMLStreamWriter writer) throws XMLStreamException {
if(isMarshallable(attribute, resourceModel)) {
writer.writeAttribute(attribute.getXmlName(), resourceModel.get(attribute.getName()).asString());
}
}
})
.setRestartAllServices()
.build();
static AttributeDefinition[] ATTRIBUTES = { SERVER_ID, PARAMS };
public static InVMTransportDefinition createAcceptorDefinition(final boolean registerRuntimeOnly) {
return new InVMTransportDefinition(registerRuntimeOnly, true, CommonAttributes.IN_VM_ACCEPTOR);
}
public static InVMTransportDefinition createConnectorDefinition(final boolean registerRuntimeOnly) {
return new InVMTransportDefinition(registerRuntimeOnly, false, CommonAttributes.IN_VM_CONNECTOR);
}
private InVMTransportDefinition(final boolean registerRuntimeOnly, boolean isAcceptor, String specificType) {
super(isAcceptor, specificType, registerRuntimeOnly, ATTRIBUTES);
}
}
| 3,136
| 43.814286
| 180
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/PrintDataOperation.java
|
/*
* Copyright 2020 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;
import static org.jboss.as.controller.RunningMode.ADMIN_ONLY;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ARCHIVE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SECRET;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.UUID;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.BINDINGS_DIRECTORY_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.JOURNAL_DIRECTORY_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.PAGING_DIRECTORY_PATH;
import java.io.File;
import java.io.PrintStream;
import java.nio.file.Files;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import org.apache.activemq.artemis.cli.commands.tools.PrintData;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
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.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
*
* @author Emmanuel Hugonnet (c) 2020 Red Hat, Inc.
*/
public class PrintDataOperation extends AbstractArtemisActionHandler {
public static final String OPERATION_NAME = "print-data";
static final PrintDataOperation INSTANCE = new PrintDataOperation();
private static final AttributeDefinition REPLY_UUID = new SimpleAttributeDefinitionBuilder(UUID, ModelType.STRING, false).build();
private static final AttributeDefinition PARAM_SECRET = new SimpleAttributeDefinitionBuilder(SECRET, ModelType.BOOLEAN, false)
.setDefaultValue(ModelNode.TRUE)
.build();
private static final AttributeDefinition PARAM_ARCHIVE = new SimpleAttributeDefinitionBuilder(ARCHIVE, ModelType.BOOLEAN, false)
.setDefaultValue(ModelNode.FALSE)
.build();
private PrintDataOperation() {
}
void registerOperation(final ManagementResourceRegistration registry, final ResourceDescriptionResolver resourceDescriptionResolver) {
registry.registerOperationHandler(
new SimpleOperationDefinitionBuilder(OPERATION_NAME, resourceDescriptionResolver)
.addParameter(PARAM_SECRET)
.addParameter(PARAM_ARCHIVE)
.setReplyParameters(REPLY_UUID)
.setRuntimeOnly()
.build(),
INSTANCE);
}
@Override
protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
if (context.getRunningMode() != ADMIN_ONLY) {
throw MessagingLogger.ROOT_LOGGER.managementOperationAllowedOnlyInRunningMode(OPERATION_NAME, ADMIN_ONLY);
}
checkAllowedOnJournal(context, OPERATION_NAME);
boolean secret = PARAM_SECRET.resolveModelAttribute(context, operation).asBoolean();
boolean archive = PARAM_ARCHIVE.resolveModelAttribute(context, operation).asBoolean();
final File bindings = resolveFile(context, BINDINGS_DIRECTORY_PATH);
final File paging = resolveFile(context, PAGING_DIRECTORY_PATH);
final File journal = resolveFile(context, JOURNAL_DIRECTORY_PATH);
try {
final TemporaryFileInputStream temp = new TemporaryFileInputStream(Files.createTempFile(getServerTempDir(context), "data-print", ".txt"));
try ( PrintStream out = new PrintStream(temp.getFile().toFile())) {
PrintData.printData(bindings, journal, paging, out, secret);
}
String uuid;
if (archive) {
final TemporaryFileInputStream tempZip = new TemporaryFileInputStream(Files.createTempFile(getServerTempDir(context), "data-print", ".zip"));
try ( ZipOutputStream out = new ZipOutputStream(Files.newOutputStream(tempZip.getFile()))) {
out.putNextEntry(new ZipEntry("data-print-report.txt"));
byte[] bytes = new byte[1024];
int length;
while ((length = temp.read(bytes)) >= 0) {
out.write(bytes, 0, length);
}
out.finish();
} finally {
temp.close();
}
uuid = context.attachResultStream("application/zip", tempZip);
} else {
uuid = context.attachResultStream("text/plain", temp);
}
context.getResult().get(UUID).set(uuid);
} catch (Exception e) {
throw new OperationFailedException(e);
}
}
}
| 5,639
| 47.205128
| 157
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/DivertAdd.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.ActiveMQServerControl;
import org.apache.activemq.artemis.core.config.DivertConfiguration;
import org.apache.activemq.artemis.core.config.TransformerConfiguration;
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.dmr.ModelNode;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceRegistry;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* Handler for adding a divert.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class DivertAdd extends AbstractAddStepHandler {
public static final DivertAdd INSTANCE = new DivertAdd(DivertDefinition.ATTRIBUTES);
private DivertAdd(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 {
ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
ServiceController<?> service = registry.getService(serviceName);
if (service != null) {
// The original subsystem initialization is complete; use the control object to create the divert
if (service.getState() != ServiceController.State.UP) {
throw MessagingLogger.ROOT_LOGGER.invalidServiceState(serviceName, ServiceController.State.UP, service.getState());
}
final String name = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
DivertConfiguration divertConfiguration = createDivertConfiguration(context, name, model);
ActiveMQServerControl serverControl = ActiveMQServer.class.cast(service.getValue()).getActiveMQServerControl();
createDivert(name, divertConfiguration, serverControl);
}
// else the initial subsystem install is not complete; MessagingSubsystemAdd will add a
// handler that calls addDivertConfigs
}
static DivertConfiguration createDivertConfiguration(final OperationContext context, String name, ModelNode model) throws OperationFailedException {
final String routingName = DivertDefinition.ROUTING_NAME.resolveModelAttribute(context, model).asStringOrNull();
final String address = DivertDefinition.ADDRESS.resolveModelAttribute(context, model).asString();
final String forwardingAddress = DivertDefinition.FORWARDING_ADDRESS.resolveModelAttribute(context, model).asString();
final boolean exclusive = DivertDefinition.EXCLUSIVE.resolveModelAttribute(context, model).asBoolean();
final String filter = CommonAttributes.FILTER.resolveModelAttribute(context, model).asStringOrNull();
DivertConfiguration config = new DivertConfiguration()
.setName(name)
.setRoutingName(routingName)
.setAddress(address)
.setForwardingAddress(forwardingAddress)
.setExclusive(exclusive)
.setFilterString(filter);
final ModelNode transformerClassName = CommonAttributes.TRANSFORMER_CLASS_NAME.resolveModelAttribute(context, model);
if (transformerClassName.isDefined()) {
config.setTransformerConfiguration(new TransformerConfiguration(transformerClassName.asString()));
}
return config;
}
static void createDivert(String name, DivertConfiguration divertConfiguration, ActiveMQServerControl serverControl) {
try {
String transformerClassName = divertConfiguration.getTransformerConfiguration() != null ? divertConfiguration.getTransformerConfiguration().getClassName() : null;
serverControl.createDivert(name, divertConfiguration.getRoutingName(), divertConfiguration.getAddress(),
divertConfiguration.getForwardingAddress(), divertConfiguration.isExclusive(),
divertConfiguration.getFilterString(), transformerClassName);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
// TODO should this be an OFE instead?
throw new RuntimeException(e);
}
}
}
| 6,006
| 49.90678
| 174
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/BroadcastGroupRemove.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.AbstractRemoveStepHandler;
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.registry.Resource;
import org.jboss.dmr.ModelNode;
/**
* Removes a broadcast group.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class BroadcastGroupRemove extends AbstractRemoveStepHandler {
public static final BroadcastGroupRemove INSTANCE = new BroadcastGroupRemove(false);
public static final BroadcastGroupRemove LEGACY_INSTANCE = new BroadcastGroupRemove(true);
private final boolean isLegacyCall;
private BroadcastGroupRemove(boolean isLegacyCall) {
super();
this.isLegacyCall= isLegacyCall;
}
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
if (!isLegacyCall) {
ModelNode op = operation.clone();
PathAddress target = context.getCurrentAddress().getParent();
OperationStepHandler removeHandler;
try {
context.readResourceFromRoot(target.append(CommonAttributes.JGROUPS_BROADCAST_GROUP, context.getCurrentAddressValue()), false);
target = target.append(CommonAttributes.JGROUPS_BROADCAST_GROUP, context.getCurrentAddressValue());
removeHandler = JGroupsBroadcastGroupRemove.LEGACY_INSTANCE;
} catch(Resource.NoSuchResourceException ex) {
target = target.append(CommonAttributes.SOCKET_BROADCAST_GROUP, context.getCurrentAddressValue());
removeHandler = SocketBroadcastGroupRemove.LEGACY_INSTANCE;
}
op.get(OP_ADDR).set(target.toModelNode());
context.addStep(op, removeHandler, OperationContext.Stage.MODEL, true);
}
super.execute(context, operation);
}
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
context.reloadRequired();
}
@Override
protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
context.revertReloadRequired();
}
}
| 3,531
| 42.604938
| 143
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/HTTPUpgradeService.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.apache.activemq.artemis.core.remoting.impl.netty.NettyConnector.ACTIVEMQ_REMOTING;
import static org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnector.MAGIC_NUMBER;
import static org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnector.SEC_ACTIVEMQ_REMOTING_ACCEPT;
import static org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnector.SEC_ACTIVEMQ_REMOTING_KEY;
import static org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.HTTP_UPGRADE_ENDPOINT_PROP_NAME;
import static org.hornetq.core.remoting.impl.netty.NettyConnector.HORNETQ_REMOTING;
import static org.hornetq.core.remoting.impl.netty.NettyConnector.SEC_HORNETQ_REMOTING_ACCEPT;
import static org.hornetq.core.remoting.impl.netty.NettyConnector.SEC_HORNETQ_REMOTING_KEY;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.CORE;
import static org.wildfly.extension.messaging.activemq.Capabilities.HTTP_LISTENER_REGISTRY_CAPABILITY_NAME;
import static org.wildfly.extension.messaging.activemq.Capabilities.HTTP_UPGRADE_REGISTRY_CAPABILITY_NAME;
import java.io.IOException;
import io.netty.channel.socket.SocketChannel;
import io.undertow.server.HttpServerExchange;
import io.undertow.server.HttpUpgradeListener;
import io.undertow.server.ListenerRegistry;
import io.undertow.server.handlers.ChannelUpgradeHandler;
import io.undertow.server.handlers.HttpUpgradeHandshake;
import io.undertow.util.FlexBase64;
import io.undertow.util.HttpString;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Map;
import java.util.function.Supplier;
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptor;
import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
import org.apache.activemq.artemis.core.remoting.server.RemotingService;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.cluster.ClusterManager;
import org.apache.activemq.artemis.core.server.cluster.ha.HAManager;
import org.jboss.as.controller.CapabilityServiceBuilder;
import org.jboss.as.controller.CapabilityServiceTarget;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
import org.xnio.ChannelListener;
import org.xnio.ChannelListeners;
import org.xnio.IoUtils;
import org.xnio.StreamConnection;
import org.xnio.netty.transport.WrappingXnioSocketChannel;
/**
* Service that handles HTTP upgrade for ActiveMQ remoting protocol.
*
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2013 Red Hat inc.
*/
public class HTTPUpgradeService implements Service<HTTPUpgradeService> {
private final String activeMQServerName;
private final String acceptorName;
private final String httpListenerName;
private final Supplier<ChannelUpgradeHandler> upgradeSupplier;
private final Supplier<ListenerRegistry> listenerRegistrySupplier;
// Keep a reference to the HttpUpgradeListener that is created when the service is started.
// There are many HttpUpgradeListener fro the artemis-remoting protocol (one per http-acceptor, for each
// activemq server) and only this httpUpgradeListener must be removed from the ChannelUpgradeHandler registry
// when this service is stopped.
private HttpUpgradeListener httpUpgradeListener;
private ListenerRegistry.HttpUpgradeMetadata httpUpgradeMetadata;
public HTTPUpgradeService(String activeMQServerName, String acceptorName, String httpListenerName, Supplier<ChannelUpgradeHandler> upgradeSupplier, Supplier<ListenerRegistry> listenerRegistrySupplier) {
this.activeMQServerName = activeMQServerName;
this.acceptorName = acceptorName;
this.httpListenerName = httpListenerName;
this.upgradeSupplier = upgradeSupplier;
this.listenerRegistrySupplier = listenerRegistrySupplier;
}
@SuppressWarnings("unchecked")
public static void installService(final CapabilityServiceTarget target, String activeMQServerName, final String acceptorName, final String httpListenerName) {
final CapabilityServiceBuilder sb = target.addCapability(HTTPAcceptorDefinition.CAPABILITY);
sb.provides(MessagingServices.getHttpUpgradeServiceName(activeMQServerName, acceptorName));
Supplier<ChannelUpgradeHandler> upgradeSupplier = sb.requiresCapability(HTTP_UPGRADE_REGISTRY_CAPABILITY_NAME, ChannelUpgradeHandler.class, httpListenerName);
Supplier<ListenerRegistry> listenerRegistrySupplier = sb.requiresCapability(HTTP_LISTENER_REGISTRY_CAPABILITY_NAME, ListenerRegistry.class);
sb.requires(ActiveMQActivationService.getServiceName(MessagingServices.getActiveMQServiceName(activeMQServerName)));
final HTTPUpgradeService service = new HTTPUpgradeService(activeMQServerName, acceptorName, httpListenerName, upgradeSupplier, listenerRegistrySupplier);
sb.setInitialMode(ServiceController.Mode.PASSIVE);
sb.setInstance(service);
sb.install();
}
@Override
public void start(StartContext context) throws StartException {
ListenerRegistry listenerRegistry = listenerRegistrySupplier.get();
ListenerRegistry.Listener listenerInfo = listenerRegistry.getListener(httpListenerName);
assert listenerInfo != null;
httpUpgradeMetadata = new ListenerRegistry.HttpUpgradeMetadata(getProtocol(), CORE);
listenerInfo.addHttpUpgradeMetadata(httpUpgradeMetadata);
MessagingLogger.ROOT_LOGGER.registeredHTTPUpgradeHandler(ACTIVEMQ_REMOTING, acceptorName);
ServiceController<?> activeMQService = context.getController().getServiceContainer().getService(MessagingServices.getActiveMQServiceName(activeMQServerName));
ActiveMQServer activeMQServer = ActiveMQServer.class.cast(activeMQService.getValue());
httpUpgradeListener = switchToMessagingProtocol(activeMQServer, acceptorName, getProtocol());
upgradeSupplier.get().addProtocol(getProtocol(),
httpUpgradeListener,
new HttpUpgradeHandshake() {
/**
* override the default upgrade handshake to take into account the
* {@code TransportConstants.HTTP_UPGRADE_ENDPOINT_PROP_NAME} header
* to select the correct acceptors among all that are configured in ActiveMQ.
*
* If the request does not have this header, the first acceptor will be used.
*/
@Override
public boolean handleUpgrade(HttpServerExchange exchange) throws IOException {
String secretKey = exchange.getRequestHeaders().getFirst(getSecKeyHeader());
if (secretKey == null) {
throw MessagingLogger.ROOT_LOGGER.upgradeRequestMissingKey();
}
ActiveMQServer server = selectServer(exchange, activeMQServer);
if (server == null) {
return false;
}
// If ActiveMQ remoting service is stopped (eg during shutdown), refuse
// the handshake so that the ActiveMQ client will detect the connection has failed
RemotingService remotingService = server.getRemotingService();
if (!server.isActive() || !remotingService.isStarted()) {
return false;
}
final String endpoint = exchange.getRequestHeaders().getFirst(getHttpUpgradeEndpointKey());
if (endpoint == null || endpoint.equals(acceptorName)) {
String response = createExpectedResponse(MAGIC_NUMBER, secretKey);
exchange.getResponseHeaders().put(HttpString.tryFromString(getSecAcceptHeader()), response);
return true;
}
return false;
}
private String createExpectedResponse(final String magicNumber, final String secretKey) throws IOException {
try {
final String concat = secretKey + magicNumber;
final MessageDigest digest = MessageDigest.getInstance("SHA1");
digest.update(concat.getBytes(StandardCharsets.UTF_8));
final byte[] bytes = digest.digest();
return FlexBase64.encodeString(bytes, false);
} catch (NoSuchAlgorithmException e) {
throw new IOException(e);
}
}
});
}
private static ActiveMQServer selectServer(HttpServerExchange exchange, ActiveMQServer rootServer) {
String activemqServerName = exchange.getRequestHeaders().getFirst(TransportConstants.ACTIVEMQ_SERVER_NAME);
if (activemqServerName == null) {
return rootServer;
}
ClusterManager clusterManager = rootServer.getClusterManager();
if (clusterManager != null) {
HAManager haManager = clusterManager.getHAManager();
if (haManager != null) {
for (Map.Entry<String, ActiveMQServer> entry : haManager.getBackupServers().entrySet()) {
if (entry.getKey().equals(activemqServerName)) {
return entry.getValue();
}
}
}
}
if (activemqServerName.equals(rootServer.getConfiguration().getName())) {
return rootServer;
} else {
return null;
}
}
@Override
public void stop(StopContext context) {
listenerRegistrySupplier.get().getListener(httpListenerName).removeHttpUpgradeMetadata(httpUpgradeMetadata);
httpUpgradeMetadata = null;
upgradeSupplier.get().removeProtocol(getProtocol(), httpUpgradeListener);
httpUpgradeListener = null;
}
@Override
public HTTPUpgradeService getValue() throws IllegalStateException, IllegalArgumentException {
return this;
}
private static HttpUpgradeListener switchToMessagingProtocol(final ActiveMQServer activemqServer, final String acceptorName, final String protocolName) {
return new HttpUpgradeListener() {
@Override
public void handleUpgrade(StreamConnection streamConnection, HttpServerExchange exchange) {
ChannelListener<StreamConnection> listener = new ChannelListener<StreamConnection>() {
@Override
public void handleEvent(StreamConnection connection) {
MessagingLogger.ROOT_LOGGER.debugf("Switching to %s protocol for %s http-acceptor", protocolName, acceptorName);
ActiveMQServer server = selectServer(exchange, activemqServer);
if (server == null) {
IoUtils.safeClose(connection);
return;
}
RemotingService remotingService = server.getRemotingService();
if (!server.isActive() || !remotingService.isStarted()) {
// ActiveMQ does not accept connection
IoUtils.safeClose(connection);
return;
}
NettyAcceptor acceptor = (NettyAcceptor) remotingService.getAcceptor(acceptorName);
SocketChannel channel = new WrappingXnioSocketChannel(connection);
try {
acceptor.transfer(channel);
connection.getSourceChannel().resumeReads();
} catch (IllegalStateException e) {
IoUtils.safeClose(connection);
}
}
};
ChannelListeners.invokeChannelListener(streamConnection, listener);
}
};
}
protected String getProtocol() {
return ACTIVEMQ_REMOTING;
}
protected String getSecKeyHeader() {
return SEC_ACTIVEMQ_REMOTING_KEY;
}
protected String getSecAcceptHeader() {
return SEC_ACTIVEMQ_REMOTING_ACCEPT;
}
protected String getHttpUpgradeEndpointKey() {
return HTTP_UPGRADE_ENDPOINT_PROP_NAME;
}
/**
* Service to handle HTTP upgrade for legacy (HornetQ) clients.
*
* Legacy clients use different protocol and security key and accept headers during the HTTP Upgrade handshake.
*/
static class LegacyHttpUpgradeService extends HTTPUpgradeService {
public static void installService(final OperationContext context, String activeMQServerName, final String acceptorName, final String httpListenerName) {
final CapabilityServiceBuilder sb = context.getCapabilityServiceTarget().addCapability(RuntimeCapability.Builder.of(MessagingServices.getLegacyHttpUpgradeServiceName(activeMQServerName, acceptorName).getCanonicalName(), false, LegacyHttpUpgradeService.class).build());
Supplier<ChannelUpgradeHandler> upgradeSupplier = sb.requiresCapability(HTTP_UPGRADE_REGISTRY_CAPABILITY_NAME, ChannelUpgradeHandler.class, httpListenerName);
Supplier<ListenerRegistry> listenerRegistrySupplier = sb.requiresCapability(HTTP_LISTENER_REGISTRY_CAPABILITY_NAME, ListenerRegistry.class);
sb.requires(ActiveMQActivationService.getServiceName(MessagingServices.getActiveMQServiceName(activeMQServerName)));
sb.setInitialMode(ServiceController.Mode.PASSIVE);
final LegacyHttpUpgradeService service = new LegacyHttpUpgradeService(activeMQServerName, acceptorName, httpListenerName, upgradeSupplier, listenerRegistrySupplier);
sb.setInstance(service);
sb.install();
}
private LegacyHttpUpgradeService(String activeMQServerName, String acceptorName, String httpListenerName, Supplier<ChannelUpgradeHandler> upgradeSupplier, Supplier<ListenerRegistry> listenerRegistrySupplier) {
super(activeMQServerName, acceptorName, httpListenerName, upgradeSupplier, listenerRegistrySupplier);
}
@Override
protected String getProtocol() {
return HORNETQ_REMOTING;
}
@Override
protected String getHttpUpgradeEndpointKey() {
return "http-upgrade-endpoint";
}
@Override
protected String getSecKeyHeader() {
return SEC_HORNETQ_REMOTING_KEY;
}
@Override
protected String getSecAcceptHeader() {
return SEC_HORNETQ_REMOTING_ACCEPT;
}
}
}
| 16,026
| 50.7
| 280
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/MessagingSubsystemParser_13_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 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_COLOCATED_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.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_13_0 extends PersistentResourceXMLParser {
static final String NAMESPACE = "urn:jboss:domain:messaging-activemq:13.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.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(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(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,
BridgeDefinition.CALL_TIMEOUT))
.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;
}
}
| 57,061
| 79.369014
| 128
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/SocketDiscoveryGroupRemove.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 socket binding.
* @author Emmanuel Hugonnet (c) 2019 Red Hat, Inc.
*/
public class SocketDiscoveryGroupRemove extends ReloadRequiredRemoveStepHandler {
public static final SocketDiscoveryGroupRemove INSTANCE = new SocketDiscoveryGroupRemove(true);
public static final SocketDiscoveryGroupRemove LEGACY_INSTANCE = new SocketDiscoveryGroupRemove(false);
private final boolean needLegacyCall;
private SocketDiscoveryGroupRemove(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());
context.addStep(op, DiscoveryGroupRemove.LEGACY_INSTANCE, OperationContext.Stage.MODEL, true);
} catch( Resource.NoSuchResourceException ex) {
// Legacy resource doesn't exist
}
}
super.execute(context, operation);
}
}
| 2,813
| 42.292308
| 148
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/QueueReadAttributeHandler.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.ignoreOperationIfServerNotActive;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.CONSUMER_COUNT;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.DELIVERING_COUNT;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.DURABLE;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.FILTER;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.MESSAGES_ADDED;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.MESSAGE_COUNT;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.PAUSED;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.SCHEDULED_COUNT;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.TEMPORARY;
import static org.wildfly.extension.messaging.activemq.QueueDefinition.ADDRESS;
import static org.wildfly.extension.messaging.activemq.QueueDefinition.DEAD_LETTER_ADDRESS;
import static org.wildfly.extension.messaging.activemq.QueueDefinition.EXPIRY_ADDRESS;
import static org.wildfly.extension.messaging.activemq.QueueDefinition.ID;
import static org.wildfly.extension.messaging.activemq.QueueDefinition.ROUTING_TYPE;
import static org.wildfly.extension.messaging.activemq.QueueDefinition.forwardToRuntimeQueue;
import java.util.ArrayList;
import java.util.List;
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.jboss.as.controller.AbstractRuntimeOnlyHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.logging.ControllerLogger;
import org.jboss.as.controller.operations.validation.ParametersValidator;
import org.jboss.as.controller.operations.validation.StringLengthValidator;
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;
/**
* Implements the {@code read-attribute} operation for runtime attributes exposed by a ActiveMQ
* {@link QueueControl}.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class QueueReadAttributeHandler extends AbstractRuntimeOnlyHandler {
public static final QueueReadAttributeHandler INSTANCE = new QueueReadAttributeHandler(false);
public static final QueueReadAttributeHandler RUNTIME_INSTANCE = new QueueReadAttributeHandler(true);
private ParametersValidator validator = new ParametersValidator();
private final boolean readStorageAttributes;
private QueueReadAttributeHandler(final boolean readStorageAttributes) {
this.readStorageAttributes = readStorageAttributes;
validator.registerValidator(CommonAttributes.NAME, new StringLengthValidator(1));
}
@Override
protected boolean resourceMustExist(OperationContext context, ModelNode operation) {
return false;
}
@Override
public void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
if(ignoreOperationIfServerNotActive(context, operation)) {
return;
}
validator.validate(operation);
if (forwardToRuntimeQueue(context, operation, RUNTIME_INSTANCE)) {
return;
}
final String attributeName = operation.require(ModelDescriptionConstants.NAME).asString();
String queueName = context.getCurrentAddressValue();
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(context.getCurrentAddress());
ServiceController<?> service = context.getServiceRegistry(false).getService(serviceName);
ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
QueueControl control = QueueControl.class.cast(server.getManagementService().getResource(ResourceNames.QUEUE + queueName));
if (control == null) {
throw ControllerLogger.ROOT_LOGGER.managementResourceNotFound(context.getCurrentAddress());
}
if (MESSAGE_COUNT.getName().equals(attributeName)) {
context.getResult().set(control.getMessageCount());
} else if (SCHEDULED_COUNT.getName().equals(attributeName)) {
context.getResult().set(control.getScheduledCount());
} else if (ROUTING_TYPE.getName().equals(attributeName)) {
context.getResult().set(control.getRoutingType());
} else if (CONSUMER_COUNT.getName().equals(attributeName)) {
context.getResult().set(control.getConsumerCount());
} else if (DELIVERING_COUNT.getName().equals(attributeName)) {
context.getResult().set(control.getDeliveringCount());
} else if (MESSAGES_ADDED.getName().equals(attributeName)) {
context.getResult().set(control.getMessagesAdded());
} else if (ID.getName().equals(attributeName)) {
context.getResult().set(control.getID());
} else if (PAUSED.getName().equals(attributeName)) {
try {
context.getResult().set(control.isPaused());
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
}
} else if (TEMPORARY.getName().equals(attributeName)) {
context.getResult().set(control.isTemporary());
} else if (EXPIRY_ADDRESS.getName().equals(attributeName)) {
if (control.getExpiryAddress() != null) {
context.getResult().set(control.getExpiryAddress());
}
} else if (DEAD_LETTER_ADDRESS.getName().equals(attributeName)) {
if (control.getDeadLetterAddress() != null) {
context.getResult().set(control.getDeadLetterAddress());
}
} else if (readStorageAttributes && getStorageAttributeNames().contains(attributeName)) {
if (ADDRESS.getName().equals(attributeName)) {
context.getResult().set(control.getAddress());
} else if (DURABLE.getName().equals(attributeName)) {
context.getResult().set(control.isDurable());
} else if (FILTER.getName().equals(attributeName)) {
ModelNode result = context.getResult();
String filter = control.getFilter();
if (filter != null) {
result.set(filter);
}
}
} else {
throw MessagingLogger.ROOT_LOGGER.unsupportedAttribute(attributeName);
}
}
private static List<String> getStorageAttributeNames() {
List<String> names = new ArrayList<String>();
for (SimpleAttributeDefinition attr : QueueDefinition.ATTRIBUTES) {
names.add(attr.getName());
}
return names;
}
}
| 8,256
| 48.14881
| 131
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/GroupingHandlerAdd.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.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.OperationStepHandler;
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;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* Handler for adding a grouping handler.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2012 Red Hat Inc.
*/
public class GroupingHandlerAdd extends AbstractAddStepHandler {
public static final GroupingHandlerAdd INSTANCE = new GroupingHandlerAdd(GroupingHandlerDefinition.ATTRIBUTES);
private GroupingHandlerAdd(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 {
ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
ServiceController<?> service = registry.getService(serviceName);
if (service != null) {
final ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
if (server.getGroupingHandler() != null) {
throw new OperationFailedException(MessagingLogger.ROOT_LOGGER.childResourceAlreadyExists(CommonAttributes.GROUPING_HANDLER));
}
// the groupingHandler is added as a child of the server resource. Requires a reload to restart the server with the grouping-handler
if (context.isNormalServer()) {
context.addStep(new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
context.reloadRequired();
context.completeStep(OperationContext.RollbackHandler.REVERT_RELOAD_REQUIRED_ROLLBACK_HANDLER);
}
}, OperationContext.Stage.RUNTIME);
}
}
// else the initial subsystem install is not complete and the grouping handler will be added in ServerAdd
}
}
| 3,970
| 46.843373
| 156
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/MessagingSubsystemParser_10_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_10_0 extends PersistentResourceXMLParser {
static final String NAMESPACE = "urn:jboss:domain:messaging-activemq:10.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(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,430
| 79.226727
| 128
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/ClusterConnectionRemove.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.AbstractRemoveStepHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.dmr.ModelNode;
/**
* Removes a cluster connection.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class ClusterConnectionRemove extends AbstractRemoveStepHandler {
public static final ClusterConnectionRemove INSTANCE = new ClusterConnectionRemove();
private ClusterConnectionRemove() {
super();
}
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
context.reloadRequired();
}
@Override
protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
context.revertReloadRequired();
}
}
| 1,977
| 36.320755
| 132
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/ConnectorServiceDefinition.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.registry.AttributeAccess.Flag.STORAGE_RUNTIME;
import java.util.Arrays;
import java.util.Collection;
import org.apache.activemq.artemis.utils.ClassloadingUtil;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.dmr.ModelNode;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* Connector service resource definition
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat Inc.
*/
public class ConnectorServiceDefinition extends PersistentResourceDefinition {
private static final AttributeDefinition[] ATTRIBUTES = {
CommonAttributes.FACTORY_CLASS,
CommonAttributes.PARAMS };
ConnectorServiceDefinition() {
super(MessagingExtension.CONNECTOR_SERVICE_PATH,
MessagingExtension.getResourceDescriptionResolver(false, CommonAttributes.CONNECTOR_SERVICE),
new ConnectorServiceAddHandler(ATTRIBUTES),
new ActiveMQReloadRequiredHandlers.RemoveStepHandler());
}
@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(ATTRIBUTES);
}
@Override
public void registerAttributes(ManagementResourceRegistration registry) {
OperationStepHandler writeHandler = new ConnectorServiceWriteAttributeHandler(ATTRIBUTES);
for (AttributeDefinition attr : ATTRIBUTES) {
if (!attr.getFlags().contains(STORAGE_RUNTIME)) {
registry.registerReadWriteAttribute(attr, null, writeHandler);
}
}
}
private static void checkFactoryClass(final String factoryClass) throws OperationFailedException {
try {
ClassloadingUtil.newInstanceFromClassLoader(factoryClass);
} catch (Throwable t) {
throw MessagingLogger.ROOT_LOGGER.unableToLoadConnectorServiceFactoryClass(factoryClass);
}
}
static class ConnectorServiceWriteAttributeHandler extends ReloadRequiredWriteAttributeHandler {
ConnectorServiceWriteAttributeHandler(AttributeDefinition... attributes) {
super(attributes);
}
@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName,
ModelNode resolvedValue, ModelNode currentValue,
HandbackHolder<Void> voidHandback)
throws OperationFailedException {
if (CommonAttributes.FACTORY_CLASS.getName().equals(attributeName)) {
checkFactoryClass(resolvedValue.asString());
}
return super.applyUpdateToRuntime(context, operation, attributeName, resolvedValue, currentValue, voidHandback);
}
}
static class ConnectorServiceAddHandler extends ActiveMQReloadRequiredHandlers.AddStepHandler {
ConnectorServiceAddHandler(AttributeDefinition... attributes) {
super(attributes);
}
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model)
throws OperationFailedException {
final String factoryClass = CommonAttributes.FACTORY_CLASS.resolveModelAttribute(context, model).asString();
checkFactoryClass(factoryClass);
super.performRuntime(context, operation, model);
}
}
}
| 4,823
| 42.459459
| 124
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/BroadcastGroupWriteAttributeHandler.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.CommonAttributes.CONNECTORS;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.BROADCAST_GROUP_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.JGROUPS_BROADCAST_GROUP_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.SOCKET_BROADCAST_GROUP_PATH;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
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.PathElement;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.registry.Resource;
import org.jboss.dmr.ModelNode;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* Write attribute handler for attributes that update a broadcast group resource.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class BroadcastGroupWriteAttributeHandler extends ReloadRequiredWriteAttributeHandler {
public static final BroadcastGroupWriteAttributeHandler INSTANCE = new BroadcastGroupWriteAttributeHandler(BROADCAST_GROUP_PATH, BroadcastGroupDefinition.ATTRIBUTES);
public static final BroadcastGroupWriteAttributeHandler JGROUP_INSTANCE = new BroadcastGroupWriteAttributeHandler(JGROUPS_BROADCAST_GROUP_PATH, JGroupsBroadcastGroupDefinition.ATTRIBUTES);
public static final BroadcastGroupWriteAttributeHandler SOCKET_INSTANCE = new BroadcastGroupWriteAttributeHandler(SOCKET_BROADCAST_GROUP_PATH, SocketBroadcastGroupDefinition.ATTRIBUTES);
private final PathElement path;
private BroadcastGroupWriteAttributeHandler(final PathElement path, final AttributeDefinition... definitions) {
super(definitions);
this.path = path;
}
@Override
protected void finishModelStage(final OperationContext context,final ModelNode operation,final String attributeName,final ModelNode newValue,
final ModelNode oldValue,final Resource model) throws OperationFailedException {
if(attributeName.equals(CONNECTORS)){
validateConnectors(context, operation, newValue);
}
super.finishModelStage(context, operation, attributeName, newValue, oldValue, model);
}
void validateConnectors(OperationContext context, ModelNode operation, ModelNode connectorRefs) throws OperationFailedException {
final Set<String> availableConnectors = getAvailableConnectors(context,operation);
final List<ModelNode> operationAddress = operation.get(ModelDescriptionConstants.OP_ADDR).asList();
final String broadCastGroup = operationAddress.get(operationAddress.size()-1).get(path.getKey()).asString();
if(connectorRefs.isDefined()) {
for(ModelNode connectorRef:connectorRefs.asList()){
final String connectorName = connectorRef.asString();
if(!availableConnectors.contains(connectorName)){
throw MessagingLogger.ROOT_LOGGER.wrongConnectorRefInBroadCastGroup(broadCastGroup, connectorName, availableConnectors);
}
}
}
}
// FIXME use capabilities & requirements
private static Set<String> getAvailableConnectors(final OperationContext context,final ModelNode operation) throws OperationFailedException{
PathAddress address = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR));
PathAddress active = MessagingServices.getActiveMQServerPathAddress(address);
Set<String> availableConnectors = new HashSet<>();
Resource subsystemResource = context.readResourceFromRoot(active.getParent(), false);
availableConnectors.addAll(subsystemResource.getChildrenNames(CommonAttributes.REMOTE_CONNECTOR));
Resource activeMQServerResource = context.readResourceFromRoot(active, false);
availableConnectors.addAll(activeMQServerResource.getChildrenNames(CommonAttributes.HTTP_CONNECTOR));
availableConnectors.addAll(activeMQServerResource.getChildrenNames(CommonAttributes.IN_VM_CONNECTOR));
availableConnectors.addAll(activeMQServerResource.getChildrenNames(CommonAttributes.REMOTE_CONNECTOR));
availableConnectors.addAll(activeMQServerResource.getChildrenNames(CommonAttributes.CONNECTOR));
return availableConnectors;
}
}
| 5,660
| 55.049505
| 192
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/CoreAddressResource.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.CommonAttributes.ROLE;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
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.management.ManagementService;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.registry.Resource;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
import org.jboss.dmr.ModelNode;
/**
* Resource for a runtime core ActiveMQ address.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class CoreAddressResource implements Resource {
private final String name;
private final ManagementService managementService;
public CoreAddressResource(final String name, final ManagementService managementService) {
this.name = name;
this.managementService = managementService;
}
@Override
public ModelNode getModel() {
return new ModelNode();
}
@Override
public void writeModel(ModelNode newModel) {
throw MessagingLogger.ROOT_LOGGER.immutableResource();
}
@Override
public boolean isModelDefined() {
return false;
}
@Override
public boolean hasChild(PathElement element) {
return ROLE.equals(element.getKey()) && hasSecurityRole(element);
}
@Override
public Resource getChild(PathElement element) {
return hasSecurityRole(element) ? SecurityRoleResource.INSTANCE : null;
}
@Override
public Resource requireChild(PathElement element) {
Resource child = getChild(element);
if (child != null) {
return child;
}
throw new NoSuchResourceException(element);
}
@Override
public boolean hasChildren(String childType) {
return !getChildrenNames(childType).isEmpty();
}
@Override
public Resource navigate(PathAddress address) {
return Tools.navigate(this, address);
}
@Override
public Set<String> getChildTypes() {
return Collections.singleton(ROLE);
}
@Override
public Set<String> getOrderedChildTypes() {
return Collections.emptySet();
}
@Override
public Set<String> getChildrenNames(String childType) {
if (ROLE.equals(childType)) {
return getSecurityRoles();
}
return Collections.emptySet();
}
@Override
public Set<ResourceEntry> getChildren(String childType) {
if (ROLE.equals(childType)) {
Set<ResourceEntry> result = new HashSet<ResourceEntry>();
for (String name : getSecurityRoles()) {
result.add(new SecurityRoleResource.SecurityRoleResourceEntry(name));
}
return result;
}
return Collections.emptySet();
}
@Override
public void registerChild(PathElement address, Resource resource) {
throw MessagingLogger.ROOT_LOGGER.immutableResource();
}
@Override
public void registerChild(PathElement pathElement, int i, Resource resource) {
throw MessagingLogger.ROOT_LOGGER.immutableResource();
}
@Override
public Resource removeChild(PathElement address) {
throw MessagingLogger.ROOT_LOGGER.immutableResource();
}
@Override
public boolean isRuntime() {
return true;
}
@Override
public boolean isProxy() {
return false;
}
@Override
public Resource clone() {
return new CoreAddressResource(name, managementService);
}
private Set<String> getSecurityRoles() {
AddressControl addressControl = getAddressControl();
if (addressControl == null) {
return Collections.emptySet();
} else {
try {
return Stream.of(addressControl.getRoles()).map(objRole -> ((Object[])objRole)[0].toString()).collect(Collectors.toSet());
} catch (Exception e) {
return Collections.emptySet();
}
}
}
private AddressControl getAddressControl() {
if (managementService == null) {
return null;
}
Object obj = managementService.getResource(ResourceNames.ADDRESS + name);
return AddressControl.class.cast(obj);
}
private boolean hasSecurityRole(PathElement element) {
String role = element.getValue();
return getSecurityRoles().contains(role);
}
public static class CoreAddressResourceEntry extends CoreAddressResource implements ResourceEntry {
final PathElement path;
// we keep a ref on the management service to be able to clone it... is there a more elegant way?
private final ManagementService managementService2;
public CoreAddressResourceEntry(final String name, final ManagementService managementService) {
super(name, managementService);
managementService2 = managementService;
path = PathElement.pathElement(CommonAttributes.CORE_ADDRESS, name);
}
@Override
public String getName() {
return path.getValue();
}
@Override
public PathElement getPathElement() {
return path;
}
@Override
public CoreAddressResourceEntry clone() {
return new CoreAddressResourceEntry(path.getValue(), managementService2);
}
}
}
| 6,709
| 30.209302
| 138
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/TemporaryFileInputStream.java
|
/*
* Copyright 2020 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;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
/**
*
* @author Emmanuel Hugonnet (c) 2020 Red Hat, Inc.
*/
class TemporaryFileInputStream extends InputStream {
private final InputStream delegate;
private final Path file;
public TemporaryFileInputStream(Path file) throws IOException {
this.file = file;
this.delegate = Files.newInputStream(file);
}
@Override
public int read() throws IOException {
return delegate.read();
}
@Override
public int read(byte[] b) throws IOException {
return delegate.read(b);
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
return delegate.read(b, off, len);
}
@Override
public long skip(long n) throws IOException {
return delegate.skip(n);
}
@Override
public int available() throws IOException {
return delegate.available();
}
@Override
public void close() throws IOException {
delegate.close();
Files.deleteIfExists(file);
}
@Override
public synchronized void mark(int readlimit) {
delegate.mark(readlimit);
}
@Override
public synchronized void reset() throws IOException {
delegate.reset();
}
@Override
public boolean markSupported() {
return delegate.markSupported();
}
public Path getFile() {
return file;
}
}
| 2,144
| 23.655172
| 75
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/JGroupsDiscoveryGroupAdd.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.JGroupsDiscoveryGroupDefinition.JGROUPS_CHANNEL;
import static org.wildfly.extension.messaging.activemq.JGroupsDiscoveryGroupDefinition.JGROUPS_CHANNEL_FACTORY;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.JGROUPS_CLUSTER;
import java.util.HashMap;
import java.util.Map;
import org.apache.activemq.artemis.api.core.BroadcastEndpointFactory;
import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.ReloadRequiredAddStepHandler;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.operations.common.Util;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.Property;
import org.wildfly.extension.messaging.activemq.broadcast.BroadcastCommandDispatcherFactory;
import org.wildfly.extension.messaging.activemq.broadcast.CommandDispatcherBroadcastEndpointFactory;
/**
* Handler for adding a discovery group using JGroups.
* @author Emmanuel Hugonnet (c) 2019 Red Hat, Inc.
*/
public class JGroupsDiscoveryGroupAdd extends ReloadRequiredAddStepHandler {
public static final JGroupsDiscoveryGroupAdd INSTANCE = new JGroupsDiscoveryGroupAdd(true);
public static final JGroupsDiscoveryGroupAdd LEGACY_INSTANCE = new JGroupsDiscoveryGroupAdd(false);
private final boolean needLegacyCall;
private JGroupsDiscoveryGroupAdd(boolean needLegacyCall) {
super(JGroupsDiscoveryGroupDefinition.ATTRIBUTES);
this.needLegacyCall= needLegacyCall;
}
private static boolean isSubsystemResource(final OperationContext context) {
return ModelDescriptionConstants.SUBSYSTEM.equals(context.getCurrentAddress().getParent().getLastElement().getKey());
}
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
CommonAttributes.renameChannelToCluster(operation);
if (operation.hasDefined(JGROUPS_CHANNEL_FACTORY.getName()) && !operation.hasDefined(JGROUPS_CHANNEL.getName())) {
// Handle legacy behavior
String channel = operation.get(JGROUPS_CLUSTER.getName()).asString();
operation.get(JGROUPS_CHANNEL.getName()).set(channel);
final PathAddress channelAddress;
if (isSubsystemResource(context)) {
channelAddress = context.getCurrentAddress().getParent().getParent().append(ModelDescriptionConstants.SUBSYSTEM, "jgroups").append("channel", channel);
} else {
channelAddress = context.getCurrentAddress().getParent().getParent().getParent().append(ModelDescriptionConstants.SUBSYSTEM, "jgroups").append("channel", channel);
}
ModelNode addChannelOperation = Util.createAddOperation(channelAddress);
addChannelOperation.get("stack").set(operation.get(JGROUPS_CHANNEL_FACTORY.getName()));
// Fabricate a channel resource
context.addStep(addChannelOperation, AddIfAbsentStepHandler.INSTANCE, OperationContext.Stage.MODEL);
}
super.execute(context, operation);
if(needLegacyCall) {
PathAddress target = context.getCurrentAddress().getParent().append(CommonAttributes.DISCOVERY_GROUP, context.getCurrentAddressValue());
ModelNode op = operation.clone();
op.get(OP_ADDR).set(target.toModelNode());
context.addStep(op, DiscoveryGroupAdd.LEGACY_INSTANCE, OperationContext.Stage.MODEL, true);
}
}
static Map<String, DiscoveryGroupConfiguration> addDiscoveryGroupConfigs(final OperationContext context, final ModelNode model) throws OperationFailedException {
Map<String, DiscoveryGroupConfiguration> configs = new HashMap<>();
if (model.hasDefined(CommonAttributes.JGROUPS_DISCOVERY_GROUP)) {
for (Property prop : model.get(CommonAttributes.JGROUPS_DISCOVERY_GROUP).asPropertyList()) {
configs.put(prop.getName(), createDiscoveryGroupConfiguration(context, prop.getName(), prop.getValue()));
}
}
return configs;
}
static DiscoveryGroupConfiguration createDiscoveryGroupConfiguration(final OperationContext context, final String name, final ModelNode model) throws OperationFailedException {
final long refreshTimeout = DiscoveryGroupDefinition.REFRESH_TIMEOUT.resolveModelAttribute(context, model).asLong();
final long initialWaitTimeout = DiscoveryGroupDefinition.INITIAL_WAIT_TIMEOUT.resolveModelAttribute(context, model).asLong();
return new DiscoveryGroupConfiguration()
.setName(name)
.setRefreshTimeout(refreshTimeout)
.setDiscoveryInitialWaitTimeout(initialWaitTimeout);
}
public static DiscoveryGroupConfiguration createDiscoveryGroupConfiguration(final String name, final DiscoveryGroupConfiguration config, final BroadcastCommandDispatcherFactory commandDispatcherFactory, final String channelName) throws Exception {
final long refreshTimeout = config.getRefreshTimeout();
final long initialWaitTimeout = config.getDiscoveryInitialWaitTimeout();
final BroadcastEndpointFactory endpointFactory = new CommandDispatcherBroadcastEndpointFactory(commandDispatcherFactory, channelName);
return new DiscoveryGroupConfiguration()
.setName(name)
.setRefreshTimeout(refreshTimeout)
.setDiscoveryInitialWaitTimeout(initialWaitTimeout)
.setBroadcastEndpointFactory(endpointFactory);
}
}
| 6,902
| 52.511628
| 250
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/MessagingSubsystemParser_12_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 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.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_12_0 extends PersistentResourceXMLParser {
static final String NAMESPACE = "urn:jboss:domain:messaging-activemq:12.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,
//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)
.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(MessagingExtension.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,283
| 79.405714
| 128
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/JGroupsDiscoveryGroupDefinition.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 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.PathElement;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
import org.jboss.as.controller.SimpleAttributeDefinition;
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.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
import org.wildfly.clustering.server.service.ClusteringDefaultRequirement;
import org.wildfly.clustering.server.service.ClusteringRequirement;
/**
* Discovery group resource definition using JGroups.
* @author Emmanuel Hugonnet (c) 2019 Red Hat, Inc.
*/
public class JGroupsDiscoveryGroupDefinition extends PersistentResourceDefinition {
public static final PathElement PATH = PathElement.pathElement(CommonAttributes.JGROUPS_DISCOVERY_GROUP);
public static final RuntimeCapability<Void> CAPABILITY = RuntimeCapability.Builder.of("org.wildfly.messaging.activemq.jgroups-discovery-group", true)
.setDynamicNameMapper(DynamicNameMappers.PARENT)
.addRequirements(ClusteringDefaultRequirement.COMMAND_DISPATCHER_FACTORY.getName())
// WFLY-10518 - only the name of the discovery-group is used for its capability as the resource can be
// either under server (and it is deprecated) or under the subsystem.
.build();
/**
* @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)
.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, REFRESH_TIMEOUT, INITIAL_WAIT_TIMEOUT
};
private final boolean registerRuntimeOnly;
protected JGroupsDiscoveryGroupDefinition(final boolean registerRuntimeOnly, final boolean subsystemResource) {
super(new SimpleResourceDefinition.Parameters(PATH, MessagingExtension.getResourceDescriptionResolver(CommonAttributes.DISCOVERY_GROUP))
.setAddHandler(JGroupsDiscoveryGroupAdd.INSTANCE)
.setRemoveHandler(JGroupsDiscoveryGroupRemove.INSTANCE)
.addCapabilities(CAPABILITY));
this.registerRuntimeOnly = registerRuntimeOnly;
}
@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(ATTRIBUTES);
}
@Override
public void registerAttributes(ManagementResourceRegistration registry) {
ReloadRequiredWriteAttributeHandler reloadRequiredWriteAttributeHandler = new ReloadRequiredWriteAttributeHandler(ATTRIBUTES);
for (AttributeDefinition attr : ATTRIBUTES) {
if (registerRuntimeOnly || !attr.getFlags().contains(AttributeAccess.Flag.STORAGE_RUNTIME)) {
registry.registerReadWriteAttribute(attr, null, reloadRequiredWriteAttributeHandler);
}
}
}
}
| 5,993
| 45.828125
| 153
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/MessagingSubsystemParser_6_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_COLOCATED_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_6_0 extends PersistentResourceXMLParser {
static final String NAMESPACE = "urn:jboss:domain:messaging-activemq:6.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(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.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();
}
}
| 54,189
| 82.497689
| 128
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/MessagingSubsystemParser_2_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 <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2015 Red Hat inc.
*/
public class MessagingSubsystemParser_2_0 extends PersistentResourceXMLParser {
static final String NAMESPACE = "urn:jboss:domain:messaging-activemq:2.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,
CommonAttributes.JGROUPS_CHANNEL,
BroadcastGroupDefinition.BROADCAST_PERIOD,
BroadcastGroupDefinition.CONNECTOR_REFS))
.addChild(
builder(DiscoveryGroupDefinition.PATH)
.addAttributes(
CommonAttributes.SOCKET_BINDING,
DiscoveryGroupDefinition.JGROUPS_CHANNEL_FACTORY,
CommonAttributes.JGROUPS_CHANNEL,
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,
// 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,
// 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)))
.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();
}
}
| 51,970
| 85.044702
| 128
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/AddressSettingAdd.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 static org.wildfly.extension.messaging.activemq.CommonAttributes.DEAD_LETTER_ADDRESS;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.EXPIRY_ADDRESS;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.core.settings.impl.SlowConsumerPolicy;
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.OperationStepHandler;
import org.jboss.as.controller.registry.Resource;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
/**
* {@code OperationStepHandler} adding a new address setting.
*
* @author Emanuel Muckenhuber
*/
class AddressSettingAdd extends AbstractAddStepHandler {
static final OperationStepHandler INSTANCE = new AddressSettingAdd(AddressSettingDefinition.ATTRIBUTES);
private AddressSettingAdd(AttributeDefinition... attributes) {
super(attributes);
}
@Override
protected void populateModel(OperationContext context, ModelNode operation, final Resource resource) throws OperationFailedException {
super.populateModel(context, operation, resource);
context.addStep(AddressSettingsValidator.ADD_VALIDATOR, OperationContext.Stage.MODEL, true);
}
@Override
protected boolean requiresRuntime(OperationContext context) {
return context.isDefaultRequiresRuntime() && !context.isBooting();
}
@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
final ActiveMQServer server = getActiveMQServer(context, operation);
if (server != null) {
final AddressSettings settings = createSettings(context, model);
server.getAddressSettingsRepository().addMatch(context.getCurrentAddressValue(), settings);
}
}
/**
* Create a setting.
*
* @param context the operation context
* @param config the detyped config
* @return the address settings
*
* @throws OperationFailedException if the model is invalid
*/
static AddressSettings createSettings(final OperationContext context, final ModelNode config) throws OperationFailedException {
final AddressSettings settings = new AddressSettings();
if (config.hasDefined(AddressSettingDefinition.ADDRESS_FULL_MESSAGE_POLICY.getName())) {
final AddressFullMessagePolicy addressPolicy = AddressFullMessagePolicy.valueOf(AddressSettingDefinition.ADDRESS_FULL_MESSAGE_POLICY.resolveModelAttribute(context, config).asString());
settings.setAddressFullMessagePolicy(addressPolicy);
}
// always set the auto-create|delete-jms-queues attributes as their default attribute values differ from Artemis defaults.
settings.setAutoCreateJmsQueues(AddressSettingDefinition.AUTO_CREATE_JMS_QUEUES.resolveModelAttribute(context, config).asBoolean());
settings.setAutoDeleteJmsQueues(AddressSettingDefinition.AUTO_DELETE_JMS_QUEUES.resolveModelAttribute(context, config).asBoolean());
settings.setAutoCreateQueues(AddressSettingDefinition.AUTO_CREATE_QUEUES.resolveModelAttribute(context, config).asBoolean());
settings.setAutoDeleteQueues(AddressSettingDefinition.AUTO_DELETE_QUEUES.resolveModelAttribute(context, config).asBoolean());
settings.setAutoCreateAddresses(AddressSettingDefinition.AUTO_CREATE_ADDRESSES.resolveModelAttribute(context, config).asBoolean());
settings.setAutoDeleteAddresses(AddressSettingDefinition.AUTO_DELETE_ADDRESSES.resolveModelAttribute(context, config).asBoolean());
settings.setAutoDeleteCreatedQueues(AddressSettingDefinition.AUTO_DELETE_CREATED_QUEUES.resolveModelAttribute(context, config).asBoolean());
if (config.hasDefined(DEAD_LETTER_ADDRESS.getName())) {
settings.setDeadLetterAddress(asSimpleString(DEAD_LETTER_ADDRESS.resolveModelAttribute(context, config), null));
}
if (config.hasDefined(CommonAttributes.EXPIRY_ADDRESS.getName())) {
settings.setExpiryAddress(asSimpleString(EXPIRY_ADDRESS.resolveModelAttribute(context, config), null));
}
if (config.hasDefined(AddressSettingDefinition.EXPIRY_DELAY.getName())) {
settings.setExpiryDelay(AddressSettingDefinition.EXPIRY_DELAY.resolveModelAttribute(context, config).asLong());
}
if (config.hasDefined(AddressSettingDefinition.LAST_VALUE_QUEUE.getName())) {
settings.setDefaultLastValueQueue(AddressSettingDefinition.LAST_VALUE_QUEUE.resolveModelAttribute(context, config).asBoolean());
}
if (config.hasDefined(AddressSettingDefinition.MAX_DELIVERY_ATTEMPTS.getName())) {
settings.setMaxDeliveryAttempts(AddressSettingDefinition.MAX_DELIVERY_ATTEMPTS.resolveModelAttribute(context, config).asInt());
}
if (config.hasDefined(AddressSettingDefinition.MAX_REDELIVERY_DELAY.getName())) {
settings.setMaxRedeliveryDelay(AddressSettingDefinition.MAX_REDELIVERY_DELAY.resolveModelAttribute(context, config).asLong());
}
if (config.hasDefined(AddressSettingDefinition.MAX_SIZE_BYTES.getName())) {
settings.setMaxSizeBytes(AddressSettingDefinition.MAX_SIZE_BYTES.resolveModelAttribute(context, config).asLong());
}
if (config.hasDefined(AddressSettingDefinition.MESSAGE_COUNTER_HISTORY_DAY_LIMIT.getName())) {
settings.setMessageCounterHistoryDayLimit(AddressSettingDefinition.MESSAGE_COUNTER_HISTORY_DAY_LIMIT.resolveModelAttribute(context, config).asInt());
}
if (config.hasDefined(AddressSettingDefinition.PAGE_MAX_CACHE_SIZE.getName())) {
settings.setPageCacheMaxSize(AddressSettingDefinition.PAGE_MAX_CACHE_SIZE.resolveModelAttribute(context, config).asInt());
}
if (config.hasDefined(AddressSettingDefinition.PAGE_SIZE_BYTES.getName())) {
settings.setPageSizeBytes(AddressSettingDefinition.PAGE_SIZE_BYTES.resolveModelAttribute(context, config).asInt());
}
if (config.hasDefined(AddressSettingDefinition.REDELIVERY_DELAY.getName())) {
settings.setRedeliveryDelay(AddressSettingDefinition.REDELIVERY_DELAY.resolveModelAttribute(context, config).asLong());
}
if (config.hasDefined(AddressSettingDefinition.REDELIVERY_MULTIPLIER.getName())) {
settings.setRedeliveryMultiplier(AddressSettingDefinition.REDELIVERY_MULTIPLIER.resolveModelAttribute(context, config).asDouble());
}
if (config.hasDefined(AddressSettingDefinition.REDISTRIBUTION_DELAY.getName())) {
settings.setRedistributionDelay(AddressSettingDefinition.REDISTRIBUTION_DELAY.resolveModelAttribute(context, config).asLong());
}
if (config.hasDefined(AddressSettingDefinition.SEND_TO_DLA_ON_NO_ROUTE.getName())) {
settings.setSendToDLAOnNoRoute(AddressSettingDefinition.SEND_TO_DLA_ON_NO_ROUTE.resolveModelAttribute(context, config).asBoolean());
}
if (config.hasDefined(AddressSettingDefinition.SLOW_CONSUMER_CHECK_PERIOD.getName())) {
settings.setSlowConsumerCheckPeriod(AddressSettingDefinition.SLOW_CONSUMER_CHECK_PERIOD.resolveModelAttribute(context, config).asLong());
}
if (config.hasDefined(AddressSettingDefinition.SLOW_CONSUMER_POLICY.getName())) {
final SlowConsumerPolicy slowConsumerPolicy = SlowConsumerPolicy.valueOf(AddressSettingDefinition.SLOW_CONSUMER_POLICY.resolveModelAttribute(context, config).asString());
settings.setSlowConsumerPolicy(slowConsumerPolicy);
}
if (config.hasDefined(AddressSettingDefinition.SLOW_CONSUMER_THRESHOLD.getName())) {
settings.setSlowConsumerThreshold(AddressSettingDefinition.SLOW_CONSUMER_THRESHOLD.resolveModelAttribute(context, config).asLong());
}
return settings;
}
static SimpleString asSimpleString(final ModelNode node, final String defVal) {
return SimpleString.toSimpleString(node.getType() != ModelType.UNDEFINED ? node.asString() : defVal);
}
}
| 9,657
| 59.3625
| 196
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/DiscoveryGroupAdd.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 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.wildfly.extension.messaging.activemq.logging.MessagingLogger;
import org.wildfly.extension.messaging.activemq.shallow.ShallowResourceAdd;
/**
* Handler for adding a discovery group.
* This is now a ShallowResourceAdd.
*
* @deprecated please use Jgroups DiscoveryGroupAdd or Socket DiscoveryGroupAdd
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class DiscoveryGroupAdd extends ShallowResourceAdd {
public static final DiscoveryGroupAdd INSTANCE = new DiscoveryGroupAdd(false);
public static final DiscoveryGroupAdd LEGACY_INSTANCE = new DiscoveryGroupAdd(true);
private final boolean isLegacyCall;
private DiscoveryGroupAdd(boolean isLegacyCall) {
super(DiscoveryGroupDefinition.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_DISCOVERY_GROUP, context.getCurrentAddressValue());
addHandler = JGroupsDiscoveryGroupAdd.LEGACY_INSTANCE;
} else if (operation.hasDefined(CommonAttributes.SOCKET_BINDING.getName())) {
target = target.append(CommonAttributes.SOCKET_DISCOVERY_GROUP, context.getCurrentAddressValue());
addHandler = SocketDiscoveryGroupAdd.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);
}
}
| 3,509
| 45.184211
| 115
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/ModularLongRangeParameterValidator.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, 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.OperationFailedException;
import org.jboss.as.controller.operations.validation.LongRangeValidator;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* @author wangc
*
*/
public class ModularLongRangeParameterValidator extends LongRangeValidator {
private final long moduleSize;
public ModularLongRangeParameterValidator(final long moduleSize, final long min) {
super(min);
this.moduleSize = moduleSize;
}
public ModularLongRangeParameterValidator(final long moduleSize, final long min, final boolean nullable) {
super(min, nullable);
this.moduleSize = moduleSize;
}
public ModularLongRangeParameterValidator(final long moduleSize, final long min, final long max, final boolean nullable,
final boolean allowExpressions) {
super(min, max, nullable, allowExpressions);
this.moduleSize = moduleSize;
}
@Override
public void validateParameter(String parameterName, ModelNode value) throws OperationFailedException {
super.validateParameter(parameterName, value);
if (value.isDefined() && value.getType() != ModelType.EXPRESSION) {
long val = value.asLong();
if (val % moduleSize != 0)
throw MessagingLogger.ROOT_LOGGER.invalidModularParameterValue(val, parameterName, moduleSize);
}
}
}
| 2,552
| 38.276923
| 124
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/SecuritySettingRemove.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.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;
/**
* {@code OperationStepHandler} for removing an existing security setting.
*
* @author Emanuel Muckenhuber
*/
class SecuritySettingRemove extends AbstractRemoveStepHandler {
static final SecuritySettingRemove INSTANCE = new SecuritySettingRemove();
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final ActiveMQServer server = getActiveMQServer(context, operation);
if (server != null) {
final PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
final String match = address.getLastElement().getValue();
server.getSecurityRepository().removeMatch(match);
}
}
}
| 2,336
| 42.277778
| 131
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/SocketBroadcastGroupDefinition.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.BROADCAST_GROUP;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.CONNECTORS;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.SOCKET_BROADCAST_GROUP_PATH;
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;
/**
* Broadcast group resource definition using socket bindings.
* @author Emmanuel Hugonnet (c) 2019 Red Hat, Inc.
*/
public class SocketBroadcastGroupDefinition extends PersistentResourceDefinition {
public static final RuntimeCapability<Void> CAPABILITY = RuntimeCapability.Builder.of("org.wildfly.messaging.activemq.socket-broadcast-group", true)
.setDynamicNameMapper(DynamicNameMappers.PARENT)
.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();
public static final SimpleAttributeDefinition SOCKET_BINDING = create(CommonAttributes.SOCKET_BINDING)
.setRequired(true)
.setAlternatives(new String[0])
.build();
public static final AttributeDefinition[] ATTRIBUTES = {SOCKET_BINDING, BROADCAST_PERIOD, CONNECTOR_REFS};
public static final String GET_CONNECTOR_PAIRS_AS_JSON = "get-connector-pairs-as-json";
private final boolean registerRuntimeOnly;
SocketBroadcastGroupDefinition(boolean registerRuntimeOnly) {
super(new SimpleResourceDefinition.Parameters(SOCKET_BROADCAST_GROUP_PATH, MessagingExtension.getResourceDescriptionResolver(BROADCAST_GROUP))
.setAddHandler(SocketBroadcastGroupAdd.INSTANCE)
.setRemoveHandler(SocketBroadcastGroupRemove.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.SOCKET_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,195
| 45.586466
| 152
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/DivertRemove.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.DivertConfiguration;
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 divert.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class DivertRemove extends AbstractRemoveStepHandler {
public static final DivertRemove INSTANCE = new DivertRemove();
private DivertRemove() {
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().destroyDivert(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 DivertConfiguration divertConfiguration = DivertAdd.createDivertConfiguration(context, name, model);
ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
DivertAdd.createDivert(name, divertConfiguration, server.getActiveMQServerControl());
}
}
}
| 4,007
| 45.604651
| 156
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/SecuritySettingDefinition.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.wildfly.extension.messaging.activemq.MessagingExtension.SECURITY_SETTING_ACCESS_CONSTRAINT;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.SECURITY_SETTING_PATH;
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.access.management.AccessConstraintDefinition;
/**
* Security setting resource definition
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat Inc.
*/
public class SecuritySettingDefinition extends PersistentResourceDefinition {
SecuritySettingDefinition() {
super(SECURITY_SETTING_PATH,
MessagingExtension.getResourceDescriptionResolver(false, SECURITY_SETTING_PATH.getKey()),
SecuritySettingAdd.INSTANCE,
SecuritySettingRemove.INSTANCE);
}
@Override
public Collection<AttributeDefinition> getAttributes() {
return Collections.emptyList();
}
@Override
protected List<? extends PersistentResourceDefinition> getChildren() {
return List.of(new SecurityRoleDefinition(false));
}
@Override
public List<AccessConstraintDefinition> getAccessConstraints() {
return Arrays.asList(SECURITY_SETTING_ACCESS_CONSTRAINT);
}
}
| 2,502
| 36.924242
| 109
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/ConfigurationHelper.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;
import static org.wildfly.extension.messaging.activemq.BridgeAdd.createBridgeConfiguration;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.DURABLE;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.FILTER;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.SELECTOR;
import static org.wildfly.extension.messaging.activemq.DivertAdd.createDivertConfiguration;
import static org.wildfly.extension.messaging.activemq.GroupingHandlerDefinition.GROUPING_HANDLER_ADDRESS;
import static org.wildfly.extension.messaging.activemq.GroupingHandlerDefinition.GROUP_TIMEOUT;
import static org.wildfly.extension.messaging.activemq.GroupingHandlerDefinition.REAPER_PERIOD;
import static org.wildfly.extension.messaging.activemq.GroupingHandlerDefinition.TIMEOUT;
import static org.wildfly.extension.messaging.activemq.QueueDefinition.DEFAULT_ROUTING_TYPE;
import static org.wildfly.extension.messaging.activemq.QueueDefinition.ROUTING_TYPE;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
import org.apache.activemq.artemis.api.core.RoutingType;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.config.BridgeConfiguration;
import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration;
import org.apache.activemq.artemis.core.config.Configuration;
import org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration;
import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
import org.apache.activemq.artemis.core.config.DivertConfiguration;
import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType;
import org.apache.activemq.artemis.core.server.group.impl.GroupingHandlerConfiguration;
import org.apache.activemq.artemis.utils.SelectorTranslator;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.Property;
/**
* Helper to create Artemis configuration.
* @author Emmanuel Hugonnet (c) 2019 Red Hat, Inc.
*/
public class ConfigurationHelper {
static void addQueueConfigurations(final OperationContext context, final Configuration configuration, final ModelNode model) throws OperationFailedException {
if (model.hasDefined(CommonAttributes.QUEUE)) {
final List<CoreQueueConfiguration> configs = configuration.getQueueConfigurations();
for (Property prop : model.get(CommonAttributes.QUEUE).asPropertyList()) {
configs.add(createCoreQueueConfiguration(context, prop.getName(), prop.getValue()));
}
}
if (model.hasDefined(CommonAttributes.JMS_QUEUE)) {
final List<CoreQueueConfiguration> configs = configuration.getQueueConfigurations();
for (Property prop : model.get(CommonAttributes.JMS_QUEUE).asPropertyList()) {
configs.add(createJMSDestinationConfiguration(context, prop.getName(), prop.getValue()));
}
}
}
static CoreQueueConfiguration createCoreQueueConfiguration(final OperationContext context, String name, ModelNode model) throws OperationFailedException {
final String queueAddress = QueueDefinition.ADDRESS.resolveModelAttribute(context, model).asString();
final String filter = FILTER.resolveModelAttribute(context, model).asStringOrNull();
final String routing;
if(DEFAULT_ROUTING_TYPE != null && ! model.hasDefined(ROUTING_TYPE.getName())) {
routing = RoutingType.valueOf(DEFAULT_ROUTING_TYPE.toUpperCase(Locale.ENGLISH)).toString();
} else {
routing = ROUTING_TYPE.resolveModelAttribute(context, model).asString();
}
final boolean durable = DURABLE.resolveModelAttribute(context, model).asBoolean();
return new CoreQueueConfiguration()
.setAddress(queueAddress)
.setName(name)
.setFilterString(filter)
.setDurable(durable)
.setRoutingType(RoutingType.valueOf(routing));
}
static CoreQueueConfiguration createJMSDestinationConfiguration(final OperationContext context, String name, ModelNode model) throws OperationFailedException {
final String selector = SELECTOR.resolveModelAttribute(context, model).asStringOrNull();
final boolean durable = DURABLE.resolveModelAttribute(context, model).asBoolean();
final String destinationAddress = "jms.queue." + name;
return new CoreQueueConfiguration()
.setAddress(destinationAddress)
.setName(destinationAddress)
.setFilterString(SelectorTranslator.convertToActiveMQFilterString(selector))
.setDurable(durable)
.setRoutingType(RoutingType.ANYCAST);
}
static void addDivertConfigurations(final OperationContext context, final Configuration configuration, final ModelNode model) throws OperationFailedException {
if (model.hasDefined(CommonAttributes.DIVERT)) {
final List<DivertConfiguration> configs = configuration.getDivertConfigurations();
for (Property prop : model.get(CommonAttributes.DIVERT).asPropertyList()) {
configs.add(createDivertConfiguration(context, prop.getName(), prop.getValue()));
}
}
}
static Map<String, DiscoveryGroupConfiguration> addDiscoveryGroupConfigurations(final OperationContext context, final ModelNode model) throws OperationFailedException {
Map<String, DiscoveryGroupConfiguration> configs = new HashMap<>();
if (model.hasDefined(CommonAttributes.JGROUPS_DISCOVERY_GROUP)) {
for (Property prop : model.get(CommonAttributes.JGROUPS_DISCOVERY_GROUP).asPropertyList()) {
configs.put(prop.getName(), new DiscoveryGroupConfiguration()
.setName(prop.getName())
.setRefreshTimeout(DiscoveryGroupDefinition.REFRESH_TIMEOUT.resolveModelAttribute(context, prop.getValue()).asLong())
.setDiscoveryInitialWaitTimeout(DiscoveryGroupDefinition.INITIAL_WAIT_TIMEOUT.resolveModelAttribute(context, prop.getValue()).asLong()));
}
}
if (model.hasDefined(CommonAttributes.SOCKET_DISCOVERY_GROUP)) {
for (Property prop : model.get(CommonAttributes.SOCKET_DISCOVERY_GROUP).asPropertyList()) {
configs.put(prop.getName(), new DiscoveryGroupConfiguration()
.setName(prop.getName())
.setRefreshTimeout(DiscoveryGroupDefinition.REFRESH_TIMEOUT.resolveModelAttribute(context, prop.getValue()).asLong())
.setDiscoveryInitialWaitTimeout(DiscoveryGroupDefinition.INITIAL_WAIT_TIMEOUT.resolveModelAttribute(context, prop.getValue()).asLong()));
}
}
return configs;
}
static void addBridgeConfigurations(final OperationContext context, final Configuration configuration, final ModelNode model) throws OperationFailedException {
if (model.hasDefined(CommonAttributes.BRIDGE)) {
final List<BridgeConfiguration> configs = configuration.getBridgeConfigurations();
for (Property prop : model.get(CommonAttributes.BRIDGE).asPropertyList()) {
configs.add(createBridgeConfiguration(context, prop.getName(), prop.getValue()));
}
}
}
static void addGroupingHandlerConfiguration(final OperationContext context, final Configuration configuration, final ModelNode model) throws OperationFailedException {
if (model.hasDefined(CommonAttributes.GROUPING_HANDLER)) {
final Property prop = model.get(CommonAttributes.GROUPING_HANDLER).asProperty();
final String name = prop.getName();
final ModelNode node = prop.getValue();
final GroupingHandlerConfiguration.TYPE type = GroupingHandlerConfiguration.TYPE.valueOf(GroupingHandlerDefinition.TYPE.resolveModelAttribute(context, node).asString());
final String address = GROUPING_HANDLER_ADDRESS.resolveModelAttribute(context, node).asString();
final int timeout = TIMEOUT.resolveModelAttribute(context, node).asInt();
final long groupTimeout = GROUP_TIMEOUT.resolveModelAttribute(context, node).asLong();
final long reaperPeriod = REAPER_PERIOD.resolveModelAttribute(context, node).asLong();
final GroupingHandlerConfiguration conf = new GroupingHandlerConfiguration()
.setName(SimpleString.toSimpleString(name))
.setType(type)
.setAddress(SimpleString.toSimpleString(address))
.setTimeout(timeout)
.setGroupTimeout(groupTimeout)
.setReaperPeriod(reaperPeriod);
configuration.setGroupingHandlerConfiguration(conf);
}
}
static void addClusterConnectionConfigurations(final OperationContext context, final Configuration configuration, final ModelNode model) throws OperationFailedException {
if (model.hasDefined(CommonAttributes.CLUSTER_CONNECTION)) {
final List<ClusterConnectionConfiguration> configs = configuration.getClusterConfigurations();
for (Property prop : model.get(CommonAttributes.CLUSTER_CONNECTION).asPropertyList()) {
configs.add(createClusterConnectionConfiguration(context, prop.getName(), prop.getValue()));
}
}
}
private static ClusterConnectionConfiguration createClusterConnectionConfiguration(final OperationContext context, final String name, final ModelNode model) throws OperationFailedException {
final String address = ClusterConnectionDefinition.ADDRESS.resolveModelAttribute(context, model).asString();
final String connectorName = ClusterConnectionDefinition.CONNECTOR_NAME.resolveModelAttribute(context, model).asString();
final long retryInterval = ClusterConnectionDefinition.RETRY_INTERVAL.resolveModelAttribute(context, model).asLong();
final boolean duplicateDetection = ClusterConnectionDefinition.USE_DUPLICATE_DETECTION.resolveModelAttribute(context, model).asBoolean();
final long connectionTTL = ClusterConnectionDefinition.CONNECTION_TTL.resolveModelAttribute(context, model).asInt();
final int initialConnectAttempts = ClusterConnectionDefinition.INITIAL_CONNECT_ATTEMPTS.resolveModelAttribute(context, model).asInt();
final int reconnectAttempts = ClusterConnectionDefinition.RECONNECT_ATTEMPTS.resolveModelAttribute(context, model).asInt();
final long maxRetryInterval = ClusterConnectionDefinition.MAX_RETRY_INTERVAL.resolveModelAttribute(context, model).asLong();
final double retryIntervalMultiplier = ClusterConnectionDefinition.RETRY_INTERVAL_MULTIPLIER.resolveModelAttribute(context, model).asDouble();
final long clientFailureCheckPeriod = ClusterConnectionDefinition.CHECK_PERIOD.resolveModelAttribute(context, model).asInt();
final String messageLoadBalancingType = ClusterConnectionDefinition.MESSAGE_LOAD_BALANCING_TYPE.resolveModelAttribute(context, model).asString();
final int maxHops = ClusterConnectionDefinition.MAX_HOPS.resolveModelAttribute(context, model).asInt();
final int confirmationWindowSize = CommonAttributes.BRIDGE_CONFIRMATION_WINDOW_SIZE.resolveModelAttribute(context, model).asInt();
final int producerWindowSize = ClusterConnectionDefinition.PRODUCER_WINDOW_SIZE.resolveModelAttribute(context, model).asInt();
final ModelNode discoveryNode = ClusterConnectionDefinition.DISCOVERY_GROUP_NAME.resolveModelAttribute(context, model);
final int minLargeMessageSize = CommonAttributes.MIN_LARGE_MESSAGE_SIZE.resolveModelAttribute(context, model).asInt();
final long callTimeout = CommonAttributes.CALL_TIMEOUT.resolveModelAttribute(context, model).asLong();
final long callFailoverTimeout = ClusterConnectionDefinition.CALL_FAILOVER_TIMEOUT.resolveModelAttribute(context, model).asLong();
final long clusterNotificationInterval = ClusterConnectionDefinition.NOTIFICATION_INTERVAL.resolveModelAttribute(context, model).asLong();
final int clusterNotificationAttempts = ClusterConnectionDefinition.NOTIFICATION_ATTEMPTS.resolveModelAttribute(context, model).asInt();
ClusterConnectionConfiguration config = new ClusterConnectionConfiguration()
.setName(name)
.setAddress(address)
.setConnectorName(connectorName)
.setMinLargeMessageSize(minLargeMessageSize)
.setClientFailureCheckPeriod(clientFailureCheckPeriod)
.setConnectionTTL(connectionTTL)
.setRetryInterval(retryInterval)
.setRetryIntervalMultiplier(retryIntervalMultiplier)
.setMaxRetryInterval(maxRetryInterval)
.setInitialConnectAttempts(initialConnectAttempts)
.setReconnectAttempts(reconnectAttempts)
.setCallTimeout(callTimeout)
.setCallFailoverTimeout(callFailoverTimeout)
.setDuplicateDetection(duplicateDetection)
.setMessageLoadBalancingType(MessageLoadBalancingType.valueOf(messageLoadBalancingType))
.setMaxHops(maxHops)
.setConfirmationWindowSize(confirmationWindowSize)
.setProducerWindowSize(producerWindowSize)
.setClusterNotificationInterval(clusterNotificationInterval)
.setClusterNotificationAttempts(clusterNotificationAttempts);
final String discoveryGroupName = discoveryNode.isDefined() ? discoveryNode.asString() : null;
final List<String> staticConnectors = discoveryGroupName == null ? getStaticConnectors(model) : null;
final boolean allowDirectOnly = ClusterConnectionDefinition.ALLOW_DIRECT_CONNECTIONS_ONLY.resolveModelAttribute(context, model).asBoolean();
if (discoveryGroupName != null) {
config.setDiscoveryGroupName(discoveryGroupName);
} else {
config.setStaticConnectors(staticConnectors)
.setAllowDirectConnectionsOnly(allowDirectOnly);
}
return config;
}
private static List<String> getStaticConnectors(ModelNode model) {
if (!model.hasDefined(CommonAttributes.STATIC_CONNECTORS)) {
return null;
}
List<String> result = new ArrayList<>();
for (ModelNode connector : model.require(CommonAttributes.STATIC_CONNECTORS).asList()) {
result.add(connector.asString());
}
return result;
}
static void addConnectorServiceConfigurations(final OperationContext context, final Configuration configuration, final ModelNode model) throws OperationFailedException {
if (model.hasDefined(CommonAttributes.CONNECTOR_SERVICE)) {
final List<ConnectorServiceConfiguration> configs = configuration.getConnectorServiceConfigurations();
for (Property prop : model.get(CommonAttributes.CONNECTOR_SERVICE).asPropertyList()) {
configs.add(createConnectorServiceConfiguration(context, prop.getName(), prop.getValue()));
}
}
}
private static ConnectorServiceConfiguration createConnectorServiceConfiguration(final OperationContext context, final String name, final ModelNode model) throws OperationFailedException {
final String factoryClass = CommonAttributes.FACTORY_CLASS.resolveModelAttribute(context, model).asString();
Map<String, String> unwrappedParameters = CommonAttributes.PARAMS.unwrap(context, model);
Map<String, Object> parameters = new HashMap<String, Object>(unwrappedParameters);
return new ConnectorServiceConfiguration()
.setFactoryClassName(factoryClass)
.setParams(parameters)
.setName(name);
}
}
| 16,816
| 62.221805
| 194
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/ImportJournalOperation.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.PathAddress.EMPTY_ADDRESS;
import static org.jboss.as.controller.RunningMode.NORMAL;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.apache.activemq.artemis.api.core.TransportConfiguration;
import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
import org.apache.activemq.artemis.api.core.client.ClientSession;
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.apache.activemq.artemis.cli.commands.tools.xml.XmlDataImporter;
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory;
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.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.SimpleOperationDefinitionBuilder;
import org.jboss.as.controller.descriptions.ResourceDescriptionResolver;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.registry.Resource;
import org.jboss.as.controller.services.path.PathResourceDefinition;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* Import a dump of Artemis journal in a running Artemis server.
* WildFly must be running in NORMAL mode to perform this operation.
*
* The dump file MUST be on WildFly host. It is not attached to the operation stream.
*
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2015 Red Hat inc.
*/
public class ImportJournalOperation extends AbstractArtemisActionHandler {
private static AttributeDefinition FILE = SimpleAttributeDefinitionBuilder.create("file", PathResourceDefinition.PATH)
.setAllowExpression(false)
.setRequired(true)
.build();
private static AttributeDefinition LEGACY_PREFIXES = SimpleAttributeDefinitionBuilder.create("legacy-prefixes", ModelType.BOOLEAN)
// import with legacy prefix by default for backwards compatibility
.setDefaultValue(ModelNode.TRUE)
.setAllowExpression(false)
.setRequired(false)
.build();
private static final String OPERATION_NAME = "import-journal";
static final ImportJournalOperation INSTANCE = new ImportJournalOperation();
private ImportJournalOperation() {
}
static void registerOperation(final ManagementResourceRegistration registry, final ResourceDescriptionResolver resourceDescriptionResolver) {
registry.registerOperationHandler(new SimpleOperationDefinitionBuilder(OPERATION_NAME, resourceDescriptionResolver)
.addParameter(FILE)
.addParameter(LEGACY_PREFIXES)
.setRuntimeOnly()
.setReplyValueType(ModelType.BOOLEAN)
.build(),
INSTANCE);
}
@Override
protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
if (context.getRunningMode() != NORMAL) {
throw MessagingLogger.ROOT_LOGGER.managementOperationAllowedOnlyInRunningMode(OPERATION_NAME, NORMAL);
}
checkAllowedOnJournal(context, OPERATION_NAME);
String file = FILE.resolveModelAttribute(context, operation).asString();
boolean legacyPrefixes = LEGACY_PREFIXES.resolveModelAttribute(context, operation).asBoolean();
final XmlDataImporter importer = new XmlDataImporter();
importer.legacyPrefixes = legacyPrefixes;
TransportConfiguration transportConfiguration = createInVMTransportConfiguration(context);
try (
InputStream is = new FileInputStream(new File(file));
ServerLocator serverLocator = ActiveMQClient.createServerLocator(false, transportConfiguration);
ClientSessionFactory sf = serverLocator.createSessionFactory()
) {
ClientSession session = sf.createSession();
importer.process(is, session);
} catch (Exception e) {
throw new OperationFailedException(e);
}
}
/**
* The XmlDataImporter requires a connector to connect to the artemis broker.
*
* We require to use a in-vm one so that importing a journal is not subject to any network connection problem.
*/
private TransportConfiguration createInVMTransportConfiguration(OperationContext context) throws OperationFailedException {
final Resource serverResource = context.readResource(EMPTY_ADDRESS, false);
Set<Resource.ResourceEntry> invmConnectors = serverResource.getChildren(CommonAttributes.IN_VM_CONNECTOR);
if (invmConnectors.isEmpty()) {
throw MessagingLogger.ROOT_LOGGER.noInVMConnector();
}
Resource.ResourceEntry connectorEntry = invmConnectors.iterator().next();
Resource connectorResource = context.readResource(PathAddress.pathAddress(connectorEntry.getPathElement()), false);
ModelNode model = connectorResource.getModel();
Map<String, Object> params = new HashMap<>(CommonAttributes.PARAMS.unwrap(context, model));
params.put(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, InVMTransportDefinition.SERVER_ID.resolveModelAttribute(context, model).asInt());
TransportConfiguration transportConfiguration = new TransportConfiguration(InVMConnectorFactory.class.getName(), params);
return transportConfiguration;
}
}
| 6,927
| 46.77931
| 192
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/MessagingSubsystemParser_1_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 <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2015 Red Hat inc.
*/
public class MessagingSubsystemParser_1_0 extends PersistentResourceXMLParser {
static final String NAMESPACE = "urn:jboss:domain:messaging-activemq:1.0";
@Override
public PersistentResourceXMLDescription getParserDescription() {
return builder(MessagingExtension.SUBSYSTEM_PATH, NAMESPACE)
.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_DOMAIN,
ServerDefinition.SECURITY_ENABLED,
ServerDefinition.SECURITY_INVALIDATION_INTERVAL,
ServerDefinition.OVERRIDE_IN_VM_SECURITY,
// cluster
ServerDefinition.CLUSTER_USER,
ServerDefinition.CLUSTER_PASSWORD,
// 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,
// 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(CONFIGURATION_MASTER_PATH)
.addAttributes(
HAAttributes.CLUSTER_NAME,
HAAttributes.GROUP_NAME,
HAAttributes.CHECK_FOR_LIVE_SERVER,
HAAttributes.INITIAL_REPLICATION_SYNC_TIMEOUT))
.addChild(builder(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,
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,
CommonAttributes.JGROUPS_CHANNEL,
BroadcastGroupDefinition.BROADCAST_PERIOD,
BroadcastGroupDefinition.CONNECTOR_REFS))
.addChild(
builder(DiscoveryGroupDefinition.PATH)
.addAttributes(
CommonAttributes.SOCKET_BINDING,
DiscoveryGroupDefinition.JGROUPS_CHANNEL_FACTORY,
CommonAttributes.JGROUPS_CHANNEL,
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.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.USER,
BridgeDefinition.PASSWORD,
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,
// 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,
// pooled
ConnectionFactoryAttributes.Pooled.USE_JNDI,
ConnectionFactoryAttributes.Pooled.JNDI_PARAMS,
ConnectionFactoryAttributes.Pooled.USE_LOCAL_TX,
ConnectionFactoryAttributes.Pooled.SETUP_ATTEMPTS,
ConnectionFactoryAttributes.Pooled.SETUP_INTERVAL,
ConnectionFactoryAttributes.Pooled.TRANSACTION,
ConnectionFactoryAttributes.Pooled.USER,
ConnectionFactoryAttributes.Pooled.PASSWORD,
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)))
.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.TARGET_CONNECTION_FACTORY,
JMSBridgeDefinition.TARGET_DESTINATION,
JMSBridgeDefinition.TARGET_USER,
JMSBridgeDefinition.TARGET_PASSWORD,
JMSBridgeDefinition.SOURCE_CONTEXT,
JMSBridgeDefinition.TARGET_CONTEXT))
.build();
}
}
| 53,300
| 92.020942
| 136
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/ExportJournalOperation.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.RunningMode.ADMIN_ONLY;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.BINDINGS_DIRECTORY_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.JOURNAL_DIRECTORY_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.LARGE_MESSAGES_DIRECTORY_PATH;
import static org.wildfly.extension.messaging.activemq.MessagingExtension.PAGING_DIRECTORY_PATH;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Date;
import org.apache.activemq.artemis.cli.commands.tools.xml.XmlDataExporter;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
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.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* Export a dump of Artemis journal. WildFly must be running in ADMIN-ONLY mode to perform this operation.
*
* The dump is stored on WildFly host and is not sent to the client invoking the operation.
*
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2015 Red Hat inc.
*/
public class ExportJournalOperation extends AbstractArtemisActionHandler {
private static final String OPERATION_NAME = "export-journal";
static final ExportJournalOperation INSTANCE = new ExportJournalOperation();
// name file of the dump follows the format journal-yyyyMMdd-HHmmssSSSTZ-dump.xml
private static final String FILE_NAME_FORMAT = "journal-%1$tY%<tm%<td-%<tH%<tM%<tS%<TL%<tz-dump.xml";
private ExportJournalOperation() {
}
static void registerOperation(final ManagementResourceRegistration registry, final ResourceDescriptionResolver resourceDescriptionResolver) {
registry.registerOperationHandler(new SimpleOperationDefinitionBuilder(OPERATION_NAME, resourceDescriptionResolver)
.setRuntimeOnly()
.setReplyValueType(ModelType.STRING)
.build(),
INSTANCE);
}
@Override
protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
if (context.getRunningMode() != ADMIN_ONLY) {
throw MessagingLogger.ROOT_LOGGER.managementOperationAllowedOnlyInRunningMode(OPERATION_NAME, ADMIN_ONLY);
}
checkAllowedOnJournal(context, OPERATION_NAME);
final String journal = resolvePath(context, JOURNAL_DIRECTORY_PATH);
final String bindings = resolvePath(context, BINDINGS_DIRECTORY_PATH);
final String paging = resolvePath(context, PAGING_DIRECTORY_PATH);
final String largeMessages = resolvePath(context, LARGE_MESSAGES_DIRECTORY_PATH);
final XmlDataExporter exporter = new XmlDataExporter();
String name = String.format(FILE_NAME_FORMAT, new Date());
// write the exported dump at the same level than the journal directory
File dump = new File(new File(journal).getParent(), name);
FileOutputStream fos = null;
try {
fos = new FileOutputStream(dump);
exporter.process(fos, bindings, journal, paging, largeMessages);
context.getResult().set(dump.getAbsolutePath());
} catch (Exception e) {
throw new OperationFailedException(e);
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
}
}
}
}
}
| 4,861
| 44.439252
| 145
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/ServerAdd.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.logging.MessagingLogger.ROOT_LOGGER;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.PATH;
import static org.jboss.as.controller.security.CredentialReference.handleCredentialReferenceUpdate;
import static org.jboss.as.controller.security.CredentialReference.rollbackCredentialStoreUpdate;
import static org.wildfly.extension.messaging.activemq.Capabilities.ACTIVEMQ_SERVER_CAPABILITY;
import static org.wildfly.extension.messaging.activemq.Capabilities.DATA_SOURCE_CAPABILITY;
import static org.wildfly.extension.messaging.activemq.Capabilities.ELYTRON_DOMAIN_CAPABILITY;
import static org.wildfly.extension.messaging.activemq.Capabilities.ELYTRON_SSL_CONTEXT_CAPABILITY_NAME;
import static org.wildfly.extension.messaging.activemq.Capabilities.HTTP_UPGRADE_REGISTRY_CAPABILITY_NAME;
import static org.wildfly.extension.messaging.activemq.Capabilities.JMX_CAPABILITY;
import static org.wildfly.extension.messaging.activemq.Capabilities.OUTBOUND_SOCKET_BINDING_CAPABILITY;
import static org.wildfly.extension.messaging.activemq.Capabilities.OUTBOUND_SOCKET_BINDING_CAPABILITY_NAME;
import static org.wildfly.extension.messaging.activemq.Capabilities.PATH_MANAGER_CAPABILITY;
import static org.wildfly.extension.messaging.activemq.Capabilities.SOCKET_BINDING_CAPABILITY_NAME;
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.HTTP_ACCEPTOR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.INCOMING_INTERCEPTORS;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.JGROUPS_CLUSTER;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.JGROUPS_BROADCAST_GROUP;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.JGROUPS_DISCOVERY_GROUP;
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.MODULE;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.NAME;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.OUTGOING_INTERCEPTORS;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.PAGING_DIRECTORY;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.SECURITY_SETTING;
import static org.wildfly.extension.messaging.activemq.PathDefinition.PATHS;
import static org.wildfly.extension.messaging.activemq.PathDefinition.RELATIVE_TO;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.ADDRESS_QUEUE_SCAN_PERIOD;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.ASYNC_CONNECTION_EXECUTION_ENABLED;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.CLUSTER_PASSWORD;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.CLUSTER_USER;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.CONNECTION_TTL_OVERRIDE;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.CREATE_BINDINGS_DIR;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.CREATE_JOURNAL_DIR;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.CREDENTIAL_REFERENCE;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.DISK_SCAN_PERIOD;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.ELYTRON_DOMAIN;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.GLOBAL_MAX_DISK_USAGE;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.GLOBAL_MAX_MEMORY_SIZE;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.ID_CACHE_SIZE;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.JMX_DOMAIN;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.JMX_MANAGEMENT_ENABLED;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.JOURNAL_BINDINGS_TABLE;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.JOURNAL_BUFFER_SIZE;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.JOURNAL_BUFFER_TIMEOUT;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.JOURNAL_COMPACT_MIN_FILES;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.JOURNAL_COMPACT_PERCENTAGE;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.JOURNAL_DATASOURCE;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.JOURNAL_FILE_OPEN_TIMEOUT;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.JOURNAL_FILE_SIZE;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.JOURNAL_JDBC_LOCK_EXPIRATION;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.JOURNAL_JDBC_LOCK_RENEW_PERIOD;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.JOURNAL_JDBC_NETWORK_TIMEOUT;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.JOURNAL_LARGE_MESSAGES_TABLE;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.JOURNAL_MAX_ATTIC_FILES;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.JOURNAL_MAX_IO;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.JOURNAL_MESSAGES_TABLE;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.JOURNAL_MIN_FILES;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.JOURNAL_NODE_MANAGER_STORE_TABLE;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.JOURNAL_PAGE_STORE_TABLE;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.JOURNAL_POOL_FILES;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.JOURNAL_SYNC_NON_TRANSACTIONAL;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.JOURNAL_SYNC_TRANSACTIONAL;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.JOURNAL_TYPE;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.LOG_JOURNAL_WRITE_RATE;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.MANAGEMENT_ADDRESS;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.MANAGEMENT_NOTIFICATION_ADDRESS;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.MEMORY_MEASURE_INTERVAL;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.MEMORY_WARNING_THRESHOLD;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.MESSAGE_COUNTER_MAX_DAY_HISTORY;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.MESSAGE_COUNTER_SAMPLE_PERIOD;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.MESSAGE_EXPIRY_SCAN_PERIOD;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.MESSAGE_EXPIRY_THREAD_PRIORITY;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.NETWORK_CHECK_LIST;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.NETWORK_CHECK_NIC;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.NETWORK_CHECK_PERIOD;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.NETWORK_CHECK_PING6_COMMAND;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.NETWORK_CHECK_PING_COMMAND;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.NETWORK_CHECK_TIMEOUT;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.NETWORK_CHECK_URL_LIST;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.OVERRIDE_IN_VM_SECURITY;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.PAGE_MAX_CONCURRENT_IO;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.PERSISTENCE_ENABLED;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.PERSIST_DELIVERY_COUNT_BEFORE_DELIVERY;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.PERSIST_ID_CACHE;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.SCHEDULED_THREAD_POOL_MAX_SIZE;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.SECURITY_DOMAIN;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.SECURITY_ENABLED;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.SECURITY_INVALIDATION_INTERVAL;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.SERVER_DUMP_INTERVAL;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.STATISTICS_ENABLED;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.THREAD_POOL_MAX_SIZE;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.TRANSACTION_TIMEOUT;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.TRANSACTION_TIMEOUT_SCAN_PERIOD;
import static org.wildfly.extension.messaging.activemq.ServerDefinition.WILD_CARD_ROUTING_ENABLED;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.Supplier;
import javax.management.MBeanServer;
import javax.sql.DataSource;
import io.undertow.server.handlers.ChannelUpgradeHandler;
import javax.net.ssl.SSLContext;
import org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration;
import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
import org.apache.activemq.artemis.api.core.Interceptor;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.config.BridgeConfiguration;
import org.apache.activemq.artemis.core.config.Configuration;
import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
import org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration;
import org.apache.activemq.artemis.core.security.Role;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.JournalType;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.utils.critical.CriticalAnalyzerPolicy;
import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.CapabilityServiceBuilder;
import org.jboss.as.controller.CapabilityServiceTarget;
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.PathAddress;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.registry.Resource;
import org.jboss.as.controller.security.CredentialReference;
import org.jboss.as.controller.services.path.PathManager;
import org.jboss.as.network.OutboundSocketBinding;
import org.jboss.as.network.SocketBinding;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.Property;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceController.Mode;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.value.InjectedValue;
import org.wildfly.common.function.ExceptionSupplier;
import org.wildfly.extension.messaging.activemq.broadcast.BroadcastCommandDispatcherFactory;
import org.wildfly.extension.messaging.activemq.ha.HAPolicyConfigurationBuilder;
import org.wildfly.extension.messaging.activemq.jms.JMSService;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
import org.wildfly.security.auth.server.SecurityDomain;
import org.wildfly.security.credential.source.CredentialSource;
/**
* Add handler for a ActiveMQ server instance.
*
* @author Emanuel Muckenhuber
* @author <a href="mailto:andy.taylor@jboss.com">Andy Taylor</a>
* @author Brian Stansberry (c) 2011 Red Hat Inc.
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat Inc.
*/
class ServerAdd extends AbstractAddStepHandler {
// Artemis-specific system properties
private static final String ARTEMIS_BROKER_CONFIG_NODEMANAGER_STORE_TABLE_NAME = "brokerconfig.storeConfiguration.nodeManagerStoreTableName";
private static final String ARTEMIS_BROKER_CONFIG_JBDC_LOCK_RENEW_PERIOD_MILLIS = "brokerconfig.storeConfiguration.jdbcLockRenewPeriodMillis";
private static final String ARTEMIS_BROKER_CONFIG_JBDC_LOCK_EXPIRATION_MILLIS = "brokerconfig.storeConfiguration.jdbcLockExpirationMillis";
private static final String ARTEMIS_BROKER_CONFIG_JDBC_LOCK_ACQUISITION_TIMEOUT_MILLIS = "brokerconfig.storeConfiguration.jdbcLockAcquisitionTimeoutMillis";
final BiConsumer<OperationContext, String> broadcastCommandDispatcherFactoryInstaller;
ServerAdd(BiConsumer<OperationContext, String> broadcastCommandDispatcherFactoryInstaller) {
super(ServerDefinition.ATTRIBUTES);
this.broadcastCommandDispatcherFactoryInstaller = broadcastCommandDispatcherFactoryInstaller;
}
@Override
protected Resource createResource(OperationContext context) {
ActiveMQServerResource resource = new ActiveMQServerResource();
context.addResource(PathAddress.EMPTY_ADDRESS, resource);
return resource;
}
@Override
protected void populateModel(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
super.populateModel(context, operation, resource);
handleCredentialReferenceUpdate(context, resource.getModel().get(CREDENTIAL_REFERENCE.getName()), CREDENTIAL_REFERENCE.getName());
// add an operation to create all the messaging paths resources that have not been already been created
// prior to adding the ActiveMQ server
context.addStep(new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
final ModelNode model = Resource.Tools.readModel(resource);
for (String path : PathDefinition.PATHS.keySet()) {
if (!model.get(ModelDescriptionConstants.PATH).hasDefined(path)) {
PathAddress pathAddress = PathAddress.pathAddress(PathElement.pathElement(ModelDescriptionConstants.PATH, path));
context.createResource(pathAddress);
}
}
}
}, OperationContext.Stage.MODEL);
context.addStep((operationContext, model) -> {
// check that if journal-datasource is defined, no other attributes related to file-system journal are set.
if (ServerDefinition.JOURNAL_DATASOURCE.resolveModelAttribute(context, model).isDefined()) {
checkNoAttributesIsDefined(ServerDefinition.JOURNAL_DATASOURCE.getName(), operationContext.getCurrentAddress(), model,
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);
}
}, OperationContext.Stage.MODEL);
}
/*
* Check that none of the attrs are defined, or log a warning.
*/
private void checkNoAttributesIsDefined(String definedAttributeName, PathAddress address, ModelNode model, AttributeDefinition... attrs) throws OperationFailedException {
List<String> definedAttributes = new ArrayList<>();
for (AttributeDefinition attr : attrs) {
if (model.get(attr.getName()).isDefined()) {
definedAttributes.add(attr.getName());
}
}
if (!definedAttributes.isEmpty()) {
MessagingLogger.ROOT_LOGGER.invalidConfiguration(address, definedAttributeName, definedAttributes);
}
}
@Override
protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
// Add a RUNTIME step to actually install the ActiveMQ Service. This will execute after the runtime step
// added by any child resources whose ADD handler executes after this one in the model stage.
context.addStep(new InstallServerHandler(resource), OperationContext.Stage.RUNTIME);
}
@Override
protected void rollbackRuntime(OperationContext context, final ModelNode operation, final Resource resource) {
rollbackCredentialStoreUpdate(CREDENTIAL_REFERENCE, context, resource);
}
private class InstallServerHandler implements OperationStepHandler {
private final Resource resource;
private InstallServerHandler(Resource resource) {
this.resource = resource;
}
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
final CapabilityServiceTarget capabilityServiceTarget= context.getCapabilityServiceTarget();
final String serverName = context.getCurrentAddressValue();
// Transform the configuration based on the recursive model
final ModelNode model = Resource.Tools.readModel(resource);
final Configuration configuration = transformConfig(context, serverName, model);
// Create path services
String bindingsPath = PATHS.get(BINDINGS_DIRECTORY).resolveModelAttribute(context, model.get(PATH, BINDINGS_DIRECTORY)).asString();
String bindingsRelativeToPath = RELATIVE_TO.resolveModelAttribute(context, model.get(PATH, BINDINGS_DIRECTORY)).asString();
String journalPath = PATHS.get(JOURNAL_DIRECTORY).resolveModelAttribute(context, model.get(PATH, JOURNAL_DIRECTORY)).asString();
String journalRelativeToPath = RELATIVE_TO.resolveModelAttribute(context, model.get(PATH, JOURNAL_DIRECTORY)).asString();
String largeMessagePath = PATHS.get(LARGE_MESSAGES_DIRECTORY).resolveModelAttribute(context, model.get(PATH, LARGE_MESSAGES_DIRECTORY)).asString();
String largeMessageRelativeToPath = RELATIVE_TO.resolveModelAttribute(context, model.get(PATH, LARGE_MESSAGES_DIRECTORY)).asString();
String pagingPath = PATHS.get(PAGING_DIRECTORY).resolveModelAttribute(context, model.get(PATH, PAGING_DIRECTORY)).asString();
String pagingRelativeToPath = RELATIVE_TO.resolveModelAttribute(context, model.get(PATH, PAGING_DIRECTORY)).asString();
// Add the ActiveMQ Service
ServiceName activeMQServiceName = MessagingServices.getActiveMQServiceName(serverName);
final CapabilityServiceBuilder serviceBuilder = capabilityServiceTarget.addCapability(ACTIVEMQ_SERVER_CAPABILITY);
Supplier<PathManager> pathManager = serviceBuilder.requiresCapability(PATH_MANAGER_CAPABILITY, PathManager.class);
Optional<Supplier<DataSource>> dataSource = Optional.empty();
String dataSourceName = JOURNAL_DATASOURCE.resolveModelAttribute(context, model).asStringOrNull();
if (dataSourceName != null) {
dataSource = Optional.of(serviceBuilder.requiresCapability(DATA_SOURCE_CAPABILITY, DataSource.class, dataSourceName));
}
Optional<Supplier<MBeanServer>> mbeanServer = Optional.empty();
if (context.hasOptionalCapability(JMX_CAPABILITY, ACTIVEMQ_SERVER_CAPABILITY.getDynamicName(serverName), null)) {
ServiceName jmxCapability = context.getCapabilityServiceName(JMX_CAPABILITY, MBeanServer.class);
mbeanServer = Optional.of(serviceBuilder.requires(jmxCapability));
}
// Inject a reference to the Elytron security domain if one has been defined.
Optional<Supplier<SecurityDomain>> elytronSecurityDomain = Optional.empty();
if (configuration.isSecurityEnabled()) {
final String elytronSecurityDomainName = ELYTRON_DOMAIN.resolveModelAttribute(context, model).asStringOrNull();
if (elytronSecurityDomainName != null) {
elytronSecurityDomain = Optional.of(serviceBuilder.requiresCapability(ELYTRON_DOMAIN_CAPABILITY, SecurityDomain.class, elytronSecurityDomainName));
} else {
final String legacySecurityDomain = SECURITY_DOMAIN.resolveModelAttribute(context, model).asStringOrNull();
if (legacySecurityDomain == null) {
throw ROOT_LOGGER.securityEnabledWithoutDomain();
}
// legacy security
throw ROOT_LOGGER.legacySecurityUnsupported();
}
}
List<Interceptor> incomingInterceptors = processInterceptors(INCOMING_INTERCEPTORS.resolveModelAttribute(context, operation));
List<Interceptor> outgoingInterceptors = processInterceptors(OUTGOING_INTERCEPTORS.resolveModelAttribute(context, operation));
// Process acceptors and connectors
final Set<String> socketBindingNames = new HashSet<>();
final Map<String, String> sslContextNames = new HashMap<>();
TransportConfigOperationHandlers.processAcceptors(context, configuration, model, socketBindingNames, sslContextNames);
Map<String, Supplier<SocketBinding>> socketBindings = new HashMap<>();
for (final String socketBindingName : socketBindingNames) {
Supplier<SocketBinding> socketBinding = serviceBuilder.requiresCapability(SOCKET_BINDING_CAPABILITY_NAME, SocketBinding.class, socketBindingName);
socketBindings.put(socketBindingName, socketBinding);
}
final Set<String> connectorsSocketBindings = new HashSet<>();
configuration.setConnectorConfigurations(TransportConfigOperationHandlers.processConnectors(context, configuration.getName(), model, connectorsSocketBindings, sslContextNames));
Map<String, Supplier<SSLContext>> sslContexts = new HashMap<>();
for (final Map.Entry<String, String> entry : sslContextNames.entrySet()) {
Supplier<SSLContext> sslContext = serviceBuilder.requiresCapability(ELYTRON_SSL_CONTEXT_CAPABILITY_NAME, SSLContext.class, entry.getValue());
sslContexts.put(entry.getValue(), sslContext);
}
Map<String, Supplier<OutboundSocketBinding>> outboundSocketBindings = new HashMap<>();
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> outboundSocketBinding = serviceBuilder.requiresCapability(OUTBOUND_SOCKET_BINDING_CAPABILITY_NAME, OutboundSocketBinding.class, connectorSocketBinding);
outboundSocketBindings.put(connectorSocketBinding, outboundSocketBinding);
} else {
// check if the socket binding has not already been added by the acceptors
if (!socketBindings.containsKey(connectorSocketBinding)) {
Supplier<SocketBinding> socketBinding = serviceBuilder.requiresCapability(SOCKET_BINDING_CAPABILITY_NAME, SocketBinding.class, connectorSocketBinding);
socketBindings.put(connectorSocketBinding, socketBinding);
}
}
}
// if there is any HTTP acceptor, add a dependency on the http-upgrade-registry service to
// make sure that ActiveMQ server will be stopped *after* the registry (and its underlying XNIO thread)
// is stopped.
Set<String> httpListeners = new HashSet<>();
if (model.hasDefined(HTTP_ACCEPTOR)) {
for (final Property property : model.get(HTTP_ACCEPTOR).asPropertyList()) {
String httpListener = HTTPAcceptorDefinition.HTTP_LISTENER.resolveModelAttribute(context, property.getValue()).asString();
httpListeners.add(httpListener);
}
}
for (String httpListener : httpListeners) {
serviceBuilder.requires(context.getCapabilityServiceName(HTTP_UPGRADE_REGISTRY_CAPABILITY_NAME, httpListener, ChannelUpgradeHandler.class));
}
//this requires connectors
BroadcastGroupAdd.addBroadcastGroupConfigs(context, configuration.getBroadcastGroupConfigurations(), configuration.getConnectorConfigurations().keySet(), model);
final List<BroadcastGroupConfiguration> broadcastGroupConfigurations = configuration.getBroadcastGroupConfigurations();
final Map<String, DiscoveryGroupConfiguration> discoveryGroupConfigurations = configuration.getDiscoveryGroupConfigurations();
final Map<String, String> clusterNames = new HashMap<>(); // Maps key -> cluster name
final Map<String, Supplier<BroadcastCommandDispatcherFactory>> commandDispatcherFactories = new HashMap<>();
final Map<String, Supplier<SocketBinding>> groupBindings = new HashMap<>();
final Map<ServiceName, Supplier<SocketBinding>> groupBindingServices = new HashMap<>();
if (broadcastGroupConfigurations != null) {
for (final BroadcastGroupConfiguration config : broadcastGroupConfigurations) {
final String name = config.getName();
final String key = "broadcast" + name;
if (model.hasDefined(JGROUPS_BROADCAST_GROUP, name)) {
ModelNode broadcastGroupModel = model.get(JGROUPS_BROADCAST_GROUP, name);
String channelName = JGroupsBroadcastGroupDefinition.JGROUPS_CHANNEL.resolveModelAttribute(context, broadcastGroupModel).asStringOrNull();
ServerAdd.this.broadcastCommandDispatcherFactoryInstaller.accept(context, channelName);
commandDispatcherFactories.put(key, serviceBuilder.requires(MessagingServices.getBroadcastCommandDispatcherFactoryServiceName(channelName)));
String clusterName = JGROUPS_CLUSTER.resolveModelAttribute(context, broadcastGroupModel).asString();
clusterNames.put(key, clusterName);
} else {
final ServiceName groupBindingServiceName = GroupBindingService.getBroadcastBaseServiceName(activeMQServiceName).append(name);
if (!groupBindingServices.containsKey(groupBindingServiceName)) {
Supplier<SocketBinding> groupBinding = serviceBuilder.requires(groupBindingServiceName);
groupBindingServices.put(groupBindingServiceName, groupBinding);
}
groupBindings.put(key, groupBindingServices.get(groupBindingServiceName));
}
}
}
if (discoveryGroupConfigurations != null) {
for (final DiscoveryGroupConfiguration config : discoveryGroupConfigurations.values()) {
final String name = config.getName();
final String key = "discovery" + name;
if (model.hasDefined(JGROUPS_DISCOVERY_GROUP, name)) {
ModelNode discoveryGroupModel = model.get(JGROUPS_DISCOVERY_GROUP, name);
String channelName = JGroupsDiscoveryGroupDefinition.JGROUPS_CHANNEL.resolveModelAttribute(context, discoveryGroupModel).asStringOrNull();
ServerAdd.this.broadcastCommandDispatcherFactoryInstaller.accept(context, channelName);
commandDispatcherFactories.put(key, serviceBuilder.requires(MessagingServices.getBroadcastCommandDispatcherFactoryServiceName(channelName)));
String clusterName = JGROUPS_CLUSTER.resolveModelAttribute(context, discoveryGroupModel).asString();
clusterNames.put(key, clusterName);
} else {
final ServiceName groupBindingServiceName = GroupBindingService.getDiscoveryBaseServiceName(activeMQServiceName).append(name);
if (!groupBindingServices.containsKey(groupBindingServiceName)) {
Supplier<SocketBinding> groupBinding = serviceBuilder.requires(groupBindingServiceName);
groupBindingServices.put(groupBindingServiceName, groupBinding);
}
groupBindings.put(key, groupBindingServices.get(groupBindingServiceName));
}
}
}
// Create the ActiveMQ Service
final ActiveMQServerService serverService = new ActiveMQServerService(
configuration,
new ActiveMQServerService.PathConfig(bindingsPath, bindingsRelativeToPath, journalPath, journalRelativeToPath, largeMessagePath, largeMessageRelativeToPath, pagingPath, pagingRelativeToPath),
pathManager,
incomingInterceptors,
outgoingInterceptors,
socketBindings,
outboundSocketBindings,
groupBindings,
commandDispatcherFactories,
clusterNames,
elytronSecurityDomain,
mbeanServer,
dataSource,
sslContexts
);
// inject credential-references for bridges
addBridgeCredentialStoreReference(serverService, configuration, BridgeDefinition.CREDENTIAL_REFERENCE, context, model, serviceBuilder);
addClusterCredentialStoreReference(serverService, CREDENTIAL_REFERENCE, context, model, serviceBuilder);
// Install the ActiveMQ Service
ServiceController activeMQServerServiceController = serviceBuilder.setInstance(serverService)
.install();
//Add the queue services for the core queues created throught the internal broker configuration (those queues are not added as service via the QueueAdd OSH)
if (model.hasDefined(CommonAttributes.QUEUE)) {
ModelNode coreQueues = model.get(CommonAttributes.QUEUE);
for (CoreQueueConfiguration queueConfiguration : configuration.getQueueConfigurations()) {
if (coreQueues.has(queueConfiguration.getName())) {
final ServiceName queueServiceName = activeMQServiceName.append(queueConfiguration.getName());
final ServiceBuilder sb = context.getServiceTarget().addService(queueServiceName);
sb.requires(ActiveMQActivationService.getServiceName(activeMQServiceName));
Supplier<ActiveMQServer> serverSupplier = sb.requires(activeMQServiceName);
final QueueService queueService = new QueueService(serverSupplier, queueConfiguration, false, false);
sb.setInitialMode(Mode.PASSIVE);
sb.setInstance(queueService);
sb.install();
}
}
}
// Provide our custom Resource impl a ref to the ActiveMQ server so it can create child runtime resources
((ActiveMQServerResource) resource).setActiveMQServerServiceController(activeMQServerServiceController);
// Install the JMSService
boolean overrideInVMSecurity = OVERRIDE_IN_VM_SECURITY.resolveModelAttribute(context, operation).asBoolean();
JMSService.addService(capabilityServiceTarget, activeMQServiceName, overrideInVMSecurity);
context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER);
}
private void processStorageConfiguration(OperationContext context, ModelNode model, Configuration configuration) throws OperationFailedException {
ModelNode journalDataSource = JOURNAL_DATASOURCE.resolveModelAttribute(context, model);
if (!journalDataSource.isDefined()) {
return;
}
DatabaseStorageConfiguration storageConfiguration = new DatabaseStorageConfiguration();
storageConfiguration.setBindingsTableName(JOURNAL_BINDINGS_TABLE.resolveModelAttribute(context, model).asString());
storageConfiguration.setMessageTableName(JOURNAL_MESSAGES_TABLE.resolveModelAttribute(context, model).asString());
storageConfiguration.setLargeMessageTableName(JOURNAL_LARGE_MESSAGES_TABLE.resolveModelAttribute(context, model).asString());
storageConfiguration.setPageStoreTableName(JOURNAL_PAGE_STORE_TABLE.resolveModelAttribute(context, model).asString());
long networkTimeout = SECONDS.toMillis(JOURNAL_JDBC_NETWORK_TIMEOUT.resolveModelAttribute(context, model).asInt());
// ARTEMIS-1493: Artemis API is not correct. the value must be in millis but it requires an int instead of a long.
storageConfiguration.setJdbcNetworkTimeout((int) networkTimeout);
// WFLY-9513 - check for System properties for HA JDBC store attributes
//
// if the attribute is defined, we use its value
// otherwise, we check first for a system property
// finally we use the attribute's default value
//
// this behaviour applies to JOURNAL_NODE_MANAGER_STORE_TABLE, JOURNAL_JDBC_LOCK_EXPIRATION
// and JOURNAL_JDBC_LOCK_RENEW_PERIOD attributes.
final String nodeManagerStoreTableName;
if (model.hasDefined(JOURNAL_NODE_MANAGER_STORE_TABLE.getName())) {
nodeManagerStoreTableName = JOURNAL_NODE_MANAGER_STORE_TABLE.resolveModelAttribute(context, model).asString();
} else if (org.wildfly.security.manager.WildFlySecurityManager.getSystemPropertiesPrivileged().containsKey(ARTEMIS_BROKER_CONFIG_NODEMANAGER_STORE_TABLE_NAME)) {
nodeManagerStoreTableName = org.wildfly.security.manager.WildFlySecurityManager.getSystemPropertiesPrivileged().getProperty(ARTEMIS_BROKER_CONFIG_NODEMANAGER_STORE_TABLE_NAME);
} else {
nodeManagerStoreTableName = JOURNAL_NODE_MANAGER_STORE_TABLE.getDefaultValue().asString();
}
// the system property is removed, otherwise Artemis will use it to override the value from the configuration
org.wildfly.security.manager.WildFlySecurityManager.getSystemPropertiesPrivileged().remove(ARTEMIS_BROKER_CONFIG_NODEMANAGER_STORE_TABLE_NAME);
storageConfiguration.setNodeManagerStoreTableName(nodeManagerStoreTableName);
final long lockExpirationInMillis;
if (model.hasDefined(JOURNAL_JDBC_LOCK_EXPIRATION.getName())) {
lockExpirationInMillis = SECONDS.toMillis(JOURNAL_JDBC_LOCK_EXPIRATION.resolveModelAttribute(context, model).asInt());
} else if (org.wildfly.security.manager.WildFlySecurityManager.getSystemPropertiesPrivileged().containsKey(ARTEMIS_BROKER_CONFIG_JBDC_LOCK_EXPIRATION_MILLIS)) {
lockExpirationInMillis = Long.parseLong(org.wildfly.security.manager.WildFlySecurityManager.getSystemPropertiesPrivileged().getProperty(ARTEMIS_BROKER_CONFIG_JBDC_LOCK_EXPIRATION_MILLIS));
} else {
lockExpirationInMillis = SECONDS.toMillis(JOURNAL_JDBC_LOCK_EXPIRATION.getDefaultValue().asInt());
}
// the system property is removed, otherwise Artemis will use it to override the value from the configuration
org.wildfly.security.manager.WildFlySecurityManager.getSystemPropertiesPrivileged().remove(ARTEMIS_BROKER_CONFIG_JBDC_LOCK_EXPIRATION_MILLIS);
storageConfiguration.setJdbcLockExpirationMillis(lockExpirationInMillis);
final long lockRenewPeriodInMillis;
if (model.hasDefined(JOURNAL_JDBC_LOCK_RENEW_PERIOD.getName())) {
lockRenewPeriodInMillis = SECONDS.toMillis(JOURNAL_JDBC_LOCK_RENEW_PERIOD.resolveModelAttribute(context, model).asInt());
} else if (org.wildfly.security.manager.WildFlySecurityManager.getSystemPropertiesPrivileged().containsKey(ARTEMIS_BROKER_CONFIG_JBDC_LOCK_RENEW_PERIOD_MILLIS)) {
lockRenewPeriodInMillis = Long.parseLong(org.wildfly.security.manager.WildFlySecurityManager.getSystemPropertiesPrivileged().getProperty(ARTEMIS_BROKER_CONFIG_JBDC_LOCK_RENEW_PERIOD_MILLIS));
} else {
lockRenewPeriodInMillis = SECONDS.toMillis(JOURNAL_JDBC_LOCK_RENEW_PERIOD.getDefaultValue().asInt());
}
// the system property is removed, otherwise Artemis will use it to override the value from the configuration
org.wildfly.security.manager.WildFlySecurityManager.getSystemPropertiesPrivileged().remove(ARTEMIS_BROKER_CONFIG_JBDC_LOCK_RENEW_PERIOD_MILLIS);
storageConfiguration.setJdbcLockRenewPeriodMillis(lockRenewPeriodInMillis);
// this property is used for testing only and has no corresponding model attribute.
// However the default value in Artemis is not correct (should be -1, not 60s)
final long jdbcLockAcquisitionTimeoutMillis;
if (org.wildfly.security.manager.WildFlySecurityManager.getSystemPropertiesPrivileged().containsKey(ARTEMIS_BROKER_CONFIG_JDBC_LOCK_ACQUISITION_TIMEOUT_MILLIS)) {
jdbcLockAcquisitionTimeoutMillis = Long.parseLong(org.wildfly.security.manager.WildFlySecurityManager.getSystemPropertiesPrivileged().getProperty(ARTEMIS_BROKER_CONFIG_JDBC_LOCK_ACQUISITION_TIMEOUT_MILLIS));
} else {
jdbcLockAcquisitionTimeoutMillis = -1;
}
// the system property is removed, otherwise Artemis will use it to override the value from the configuration
org.wildfly.security.manager.WildFlySecurityManager.getSystemPropertiesPrivileged().remove(ARTEMIS_BROKER_CONFIG_JDBC_LOCK_ACQUISITION_TIMEOUT_MILLIS);
storageConfiguration.setJdbcLockAcquisitionTimeoutMillis(jdbcLockAcquisitionTimeoutMillis);
configuration.setStoreConfiguration(storageConfiguration);
}
/**
* Transform the detyped operation parameters into the ActiveMQ configuration.
*
* @param context the operation context
* @param serverName the name of the ActiveMQ instance
* @param model the subsystem root resource model
* @return the ActiveMQ configuration
*/
private Configuration transformConfig(final OperationContext context, String serverName, final ModelNode model) throws OperationFailedException {
Configuration configuration = new ConfigurationImpl();
configuration.setName(serverName);
//To avoid the automatic reloading of the logging.properties by the broker.
configuration.setConfigurationFileRefreshPeriod(-1);
configuration.setAddressQueueScanPeriod(ADDRESS_QUEUE_SCAN_PERIOD.resolveModelAttribute(context, model).asLong());
configuration.setEnabledAsyncConnectionExecution(ASYNC_CONNECTION_EXECUTION_ENABLED.resolveModelAttribute(context, model).asBoolean());
configuration.setClusterPassword(CLUSTER_PASSWORD.resolveModelAttribute(context, model).asString());
configuration.setClusterUser(CLUSTER_USER.resolveModelAttribute(context, model).asString());
configuration.setConnectionTTLOverride(CONNECTION_TTL_OVERRIDE.resolveModelAttribute(context, model).asInt());
configuration.setCreateBindingsDir(CREATE_BINDINGS_DIR.resolveModelAttribute(context, model).asBoolean());
configuration.setCreateJournalDir(CREATE_JOURNAL_DIR.resolveModelAttribute(context, model).asBoolean());
configuration.setGlobalMaxSize(GLOBAL_MAX_MEMORY_SIZE.resolveModelAttribute(context, model).asLong());
configuration.setMaxDiskUsage(GLOBAL_MAX_DISK_USAGE.resolveModelAttribute(context, model).asInt());
configuration.setDiskScanPeriod(DISK_SCAN_PERIOD.resolveModelAttribute(context, model).asInt());
configuration.setIDCacheSize(ID_CACHE_SIZE.resolveModelAttribute(context, model).asInt());
// TODO do we want to allow the jmx configuration ?
configuration.setJMXDomain(JMX_DOMAIN.resolveModelAttribute(context, model).asString());
configuration.setJMXManagementEnabled(JMX_MANAGEMENT_ENABLED.resolveModelAttribute(context, model).asBoolean());
// Journal
final JournalType journalType = JournalType.valueOf(JOURNAL_TYPE.resolveModelAttribute(context, model).asString());
configuration.setJournalType(journalType);
ModelNode value = JOURNAL_BUFFER_SIZE.resolveModelAttribute(context, model);
if (value.isDefined()) {
configuration.setJournalBufferSize_AIO(value.asInt());
configuration.setJournalBufferSize_NIO(value.asInt());
}
value = JOURNAL_BUFFER_TIMEOUT.resolveModelAttribute(context, model);
if (value.isDefined()) {
configuration.setJournalBufferTimeout_AIO(value.asInt());
configuration.setJournalBufferTimeout_NIO(value.asInt());
}
value = JOURNAL_MAX_IO.resolveModelAttribute(context, model);
if (value.isDefined()) {
configuration.setJournalMaxIO_AIO(value.asInt());
configuration.setJournalMaxIO_NIO(value.asInt());
}
configuration.setJournalCompactMinFiles(JOURNAL_COMPACT_MIN_FILES.resolveModelAttribute(context, model).asInt());
configuration.setJournalCompactPercentage(JOURNAL_COMPACT_PERCENTAGE.resolveModelAttribute(context, model).asInt());
configuration.setJournalFileSize(JOURNAL_FILE_SIZE.resolveModelAttribute(context, model).asInt());
configuration.setJournalMinFiles(JOURNAL_MIN_FILES.resolveModelAttribute(context, model).asInt());
configuration.setJournalPoolFiles(JOURNAL_POOL_FILES.resolveModelAttribute(context, model).asInt());
configuration.setJournalFileOpenTimeout(JOURNAL_FILE_OPEN_TIMEOUT.resolveModelAttribute(context, model).asInt());
configuration.setJournalSyncNonTransactional(JOURNAL_SYNC_NON_TRANSACTIONAL.resolveModelAttribute(context, model).asBoolean());
configuration.setJournalSyncTransactional(JOURNAL_SYNC_TRANSACTIONAL.resolveModelAttribute(context, model).asBoolean());
configuration.setJournalMaxAtticFiles(JOURNAL_MAX_ATTIC_FILES.resolveModelAttribute(context, model).asInt());
configuration.setLogJournalWriteRate(LOG_JOURNAL_WRITE_RATE.resolveModelAttribute(context, model).asBoolean());
configuration.setManagementAddress(SimpleString.toSimpleString(MANAGEMENT_ADDRESS.resolveModelAttribute(context, model).asString()));
configuration.setManagementNotificationAddress(SimpleString.toSimpleString(MANAGEMENT_NOTIFICATION_ADDRESS.resolveModelAttribute(context, model).asString()));
configuration.setMemoryMeasureInterval(MEMORY_MEASURE_INTERVAL.resolveModelAttribute(context, model).asLong());
configuration.setMemoryWarningThreshold(MEMORY_WARNING_THRESHOLD.resolveModelAttribute(context, model).asInt());
configuration.setMessageCounterEnabled(STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean());
configuration.setMessageCounterSamplePeriod(MESSAGE_COUNTER_SAMPLE_PERIOD.resolveModelAttribute(context, model).asInt());
configuration.setMessageCounterMaxDayHistory(MESSAGE_COUNTER_MAX_DAY_HISTORY.resolveModelAttribute(context, model).asInt());
configuration.setMessageExpiryScanPeriod(MESSAGE_EXPIRY_SCAN_PERIOD.resolveModelAttribute(context, model).asLong());
configuration.setMessageExpiryThreadPriority(MESSAGE_EXPIRY_THREAD_PRIORITY.resolveModelAttribute(context, model).asInt());
configuration.setPersistDeliveryCountBeforeDelivery(PERSIST_DELIVERY_COUNT_BEFORE_DELIVERY.resolveModelAttribute(context, model).asBoolean());
configuration.setPageMaxConcurrentIO(PAGE_MAX_CONCURRENT_IO.resolveModelAttribute(context, model).asInt());
configuration.setPersistenceEnabled(PERSISTENCE_ENABLED.resolveModelAttribute(context, model).asBoolean());
configuration.setPersistIDCache(PERSIST_ID_CACHE.resolveModelAttribute(context, model).asBoolean());
configuration.setScheduledThreadPoolMaxSize(SCHEDULED_THREAD_POOL_MAX_SIZE.resolveModelAttribute(context, model).asInt());
configuration.setSecurityEnabled(SECURITY_ENABLED.resolveModelAttribute(context, model).asBoolean());
configuration.setSecurityInvalidationInterval(SECURITY_INVALIDATION_INTERVAL.resolveModelAttribute(context, model).asLong());
configuration.setServerDumpInterval(SERVER_DUMP_INTERVAL.resolveModelAttribute(context, model).asLong());
configuration.setThreadPoolMaxSize(THREAD_POOL_MAX_SIZE.resolveModelAttribute(context, model).asInt());
configuration.setTransactionTimeout(TRANSACTION_TIMEOUT.resolveModelAttribute(context, model).asLong());
configuration.setTransactionTimeoutScanPeriod(TRANSACTION_TIMEOUT_SCAN_PERIOD.resolveModelAttribute(context, model).asLong());
configuration.getWildcardConfiguration().setRoutingEnabled(WILD_CARD_ROUTING_ENABLED.resolveModelAttribute(context, model).asBoolean());
if (model.hasDefined(NETWORK_CHECK_NIC.getName())
|| model.hasDefined(NETWORK_CHECK_PERIOD.getName())
|| model.hasDefined(NETWORK_CHECK_TIMEOUT.getName())
|| model.hasDefined(NETWORK_CHECK_LIST.getName())
|| model.hasDefined(NETWORK_CHECK_URL_LIST.getName())
|| model.hasDefined(NETWORK_CHECK_PING_COMMAND.getName())
|| model.hasDefined(NETWORK_CHECK_PING6_COMMAND.getName())) {
configuration.setNetworCheckNIC(NETWORK_CHECK_NIC.resolveModelAttribute(context, model).asStringOrNull());
configuration.setNetworkCheckList(NETWORK_CHECK_LIST.resolveModelAttribute(context, model).asStringOrNull());
configuration.setNetworkCheckPeriod(NETWORK_CHECK_PERIOD.resolveModelAttribute(context, model).asLong());
configuration.setNetworkCheckPing6Command(NETWORK_CHECK_PING6_COMMAND.resolveModelAttribute(context, model).asString());
configuration.setNetworkCheckPingCommand(NETWORK_CHECK_PING_COMMAND.resolveModelAttribute(context, model).asString());
configuration.setNetworkCheckTimeout(NETWORK_CHECK_TIMEOUT.resolveModelAttribute(context, model).asInt());
configuration.setNetworkCheckURLList(NETWORK_CHECK_URL_LIST.resolveModelAttribute(context, model).asStringOrNull());
}
configuration.setCriticalAnalyzer(ServerDefinition.CRITICAL_ANALYZER_ENABLED.resolveModelAttribute(context, model).asBoolean());
configuration.setCriticalAnalyzerCheckPeriod(ServerDefinition.CRITICAL_ANALYZER_CHECK_PERIOD.resolveModelAttribute(context, model).asLong());
configuration.setCriticalAnalyzerPolicy(CriticalAnalyzerPolicy.valueOf(ServerDefinition.CRITICAL_ANALYZER_POLICY.resolveModelAttribute(context, model).asString()));
configuration.setCriticalAnalyzerTimeout(ServerDefinition.CRITICAL_ANALYZER_TIMEOUT.resolveModelAttribute(context, model).asLong());
processStorageConfiguration(context, model, configuration);
HAPolicyConfigurationBuilder.getInstance().addHAPolicyConfiguration(context, configuration, model);
processAddressSettings(context, configuration, model);
processSecuritySettings(context, configuration, model);
// Add in items from child resources
ConfigurationHelper.addGroupingHandlerConfiguration(context, configuration, model);
configuration.setDiscoveryGroupConfigurations(ConfigurationHelper.addDiscoveryGroupConfigurations(context, model));
ConfigurationHelper.addDivertConfigurations(context, configuration, model);
ConfigurationHelper.addQueueConfigurations(context, configuration, model);
ConfigurationHelper.addBridgeConfigurations(context, configuration, model);
ConfigurationHelper.addClusterConnectionConfigurations(context, configuration, model);
ConfigurationHelper.addConnectorServiceConfigurations(context, configuration, model);
return configuration;
}
/**
* Process the address settings.
*
* @param configuration the ActiveMQ configuration
* @param params the detyped operation parameters
* @throws OperationFailedException
*/
private void processAddressSettings(final OperationContext context, final Configuration configuration, final ModelNode params) throws OperationFailedException {
if (params.hasDefined(ADDRESS_SETTING)) {
for (final Property property : params.get(ADDRESS_SETTING).asPropertyList()) {
final String match = property.getName();
final ModelNode config = property.getValue();
final AddressSettings settings = AddressSettingAdd.createSettings(context, config);
configuration.addAddressSetting(match, settings);
}
}
}
private List<Class> unwrapClasses(List<ModelNode> classesModel) throws OperationFailedException {
List<Class> classes = new ArrayList<>();
for (ModelNode classModel : classesModel) {
Class<?> clazz = unwrapClass(classModel);
classes.add(clazz);
}
return classes;
}
private Class unwrapClass(ModelNode classModel) throws OperationFailedException {
String className = classModel.get(NAME).asString();
String moduleName = classModel.get(MODULE).asString();
try {
ModuleIdentifier moduleID = ModuleIdentifier.fromString(moduleName);
Module module = Module.getCallerModuleLoader().loadModule(moduleID);
Class<?> clazz = module.getClassLoader().loadClass(className);
return clazz;
} catch (Exception e) {
throw MessagingLogger.ROOT_LOGGER.unableToLoadClassFromModule(className, moduleName);
}
}
private List<Interceptor> processInterceptors(ModelNode model) throws OperationFailedException {
if (!model.isDefined()) {
return Collections.emptyList();
}
List<Interceptor> interceptors = new ArrayList<>();
List<ModelNode> interceptorModels = model.asList();
for (Class clazz : unwrapClasses(interceptorModels)) {
try {
Interceptor interceptor = Interceptor.class.cast(clazz.newInstance());
interceptors.add(interceptor);
} catch (Exception e) {
throw new OperationFailedException(e);
}
}
return interceptors;
}
/**
* Process the security settings.
*
* @param configuration the ActiveMQ configuration
* @param params the detyped operation parameters
*/
private void processSecuritySettings(final OperationContext context, final Configuration configuration, final ModelNode params) throws OperationFailedException {
if (params.get(SECURITY_SETTING).isDefined()) {
for (final Property property : params.get(SECURITY_SETTING).asPropertyList()) {
final String match = property.getName();
final ModelNode config = property.getValue();
if (config.hasDefined(CommonAttributes.ROLE)) {
final Set<Role> roles = new HashSet<Role>();
for (final Property role : config.get(CommonAttributes.ROLE).asPropertyList()) {
roles.add(SecurityRoleDefinition.transform(context, role.getName(), role.getValue()));
}
configuration.getSecurityRoles().put(match, roles);
}
}
}
}
private void addBridgeCredentialStoreReference(ActiveMQServerService amqService, Configuration configuration, ObjectTypeAttributeDefinition credentialReferenceAttributeDefinition, OperationContext context, ModelNode model, ServiceBuilder<?> serviceBuilder) throws OperationFailedException {
for (BridgeConfiguration bridgeConfiguration : configuration.getBridgeConfigurations()) {
String name = bridgeConfiguration.getName();
InjectedValue<ExceptionSupplier<CredentialSource, Exception>> injector = amqService.getBridgeCredentialSourceSupplierInjector(name);
String[] modelFilter = {CommonAttributes.BRIDGE, name};
ModelNode filteredModelNode = model;
if (modelFilter != null && modelFilter.length > 0) {
for (String path : modelFilter) {
if (filteredModelNode.get(path).isDefined()) {
filteredModelNode = filteredModelNode.get(path);
} else {
break;
}
}
}
ModelNode value = credentialReferenceAttributeDefinition.resolveModelAttribute(context, filteredModelNode);
if (value.isDefined()) {
injector.inject(CredentialReference.getCredentialSourceSupplier(context, credentialReferenceAttributeDefinition, filteredModelNode, serviceBuilder));
}
}
}
private void addClusterCredentialStoreReference(ActiveMQServerService amqService, ObjectTypeAttributeDefinition credentialReferenceAttributeDefinition, OperationContext context, ModelNode model, ServiceBuilder<?> serviceBuilder) throws OperationFailedException {
ModelNode value = credentialReferenceAttributeDefinition.resolveModelAttribute(context, model);
if (value.isDefined()) {
amqService.getClusterCredentialSourceSupplierInjector()
.inject(CredentialReference.getCredentialSourceSupplier(context, credentialReferenceAttributeDefinition, model, serviceBuilder));
}
}
}
}
| 57,829
| 69.957055
| 298
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/ActiveMQServerResource.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.CommonAttributes.CORE_ADDRESS;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.RUNTIME_QUEUE;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
import org.apache.activemq.artemis.api.core.management.AddressControl;
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.management.ManagementService;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.registry.PlaceholderResource;
import org.jboss.as.controller.registry.Resource;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceController;
/**
* Resource representing a ActiveMQ server.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class ActiveMQServerResource implements Resource {
private final Resource delegate;
private volatile ServiceController<ActiveMQServer> activeMQServerServiceController;
public ActiveMQServerResource() {
this(Factory.create());
}
public ActiveMQServerResource(final Resource delegate) {
this.delegate = delegate;
}
public ServiceController<ActiveMQServer> getActiveMQServerServiceController() {
return activeMQServerServiceController;
}
public void setActiveMQServerServiceController(ServiceController<ActiveMQServer> activeMQServerServiceController) {
this.activeMQServerServiceController = activeMQServerServiceController;
}
@Override
public ModelNode getModel() {
return delegate.getModel();
}
@Override
public void writeModel(ModelNode newModel) {
delegate.writeModel(newModel);
}
@Override
public boolean isModelDefined() {
return delegate.isModelDefined();
}
@Override
public boolean hasChild(PathElement element) {
if (CORE_ADDRESS.equals(element.getKey())) {
return hasAddressControl(element);
} else if (RUNTIME_QUEUE.equals(element.getKey())) {
return hasQueueControl(element.getValue());
} else {
return delegate.hasChild(element);
}
}
@Override
public Resource getChild(PathElement element) {
if (CORE_ADDRESS.equals(element.getKey())) {
return hasAddressControl(element) ? new CoreAddressResource(element.getValue(), getManagementService()) : null;
} else if (RUNTIME_QUEUE.equals(element.getKey())) {
return hasQueueControl(element.getValue()) ? PlaceholderResource.INSTANCE : null;
} else {
return delegate.getChild(element);
}
}
@Override
public Resource requireChild(PathElement element) {
if (CORE_ADDRESS.equals(element.getKey())) {
if (hasAddressControl(element)) {
return new CoreAddressResource(element.getValue(), getManagementService());
}
throw new NoSuchResourceException(element);
} else if (RUNTIME_QUEUE.equals(element.getKey())) {
if (hasQueueControl(element.getValue())) {
return PlaceholderResource.INSTANCE;
}
throw new NoSuchResourceException(element);
} else {
return delegate.requireChild(element);
}
}
@Override
public boolean hasChildren(String childType) {
if (CORE_ADDRESS.equals(childType)) {
return !getChildrenNames(CORE_ADDRESS).isEmpty();
} else if (RUNTIME_QUEUE.equals(childType)) {
return !getChildrenNames(RUNTIME_QUEUE).isEmpty();
} else {
return delegate.hasChildren(childType);
}
}
@Override
public Resource navigate(PathAddress address) {
if (address.size() > 0 && CORE_ADDRESS.equals(address.getElement(0).getKey())) {
if (address.size() > 1) {
throw new NoSuchResourceException(address.getElement(1));
}
return new CoreAddressResource(address.getElement(0).getValue(), getManagementService());
} else if (address.size() > 0 && RUNTIME_QUEUE.equals(address.getElement(0).getKey())) {
if (address.size() > 1) {
throw new NoSuchResourceException(address.getElement(1));
}
return PlaceholderResource.INSTANCE;
} else {
return delegate.navigate(address);
}
}
@Override
public Set<String> getChildTypes() {
Set<String> result = new HashSet<String>(delegate.getChildTypes());
result.add(CORE_ADDRESS);
result.add(RUNTIME_QUEUE);
return result;
}
@Override
public Set<String> getOrderedChildTypes() {
return Collections.emptySet();
}
@Override
public Set<String> getChildrenNames(String childType) {
if (CORE_ADDRESS.equals(childType)) {
return getCoreAddressNames();
} else if (RUNTIME_QUEUE.equals(childType)) {
return getCoreQueueNames();
} else {
return delegate.getChildrenNames(childType);
}
}
@Override
public Set<ResourceEntry> getChildren(String childType) {
if (CORE_ADDRESS.equals(childType)) {
Set<ResourceEntry> result = new HashSet<ResourceEntry>();
for (String name : getCoreAddressNames()) {
result.add(new CoreAddressResource.CoreAddressResourceEntry(name, getManagementService()));
}
return result;
} else if (RUNTIME_QUEUE.equals(childType)) {
Set<ResourceEntry> result = new LinkedHashSet<ResourceEntry>();
for (String name : getCoreQueueNames()) {
result.add(new PlaceholderResource.PlaceholderResourceEntry(RUNTIME_QUEUE, name));
}
return result;
} else {
return delegate.getChildren(childType);
}
}
@Override
public void registerChild(PathElement address, Resource resource) {
String type = address.getKey();
if (CORE_ADDRESS.equals(type) ||
RUNTIME_QUEUE.equals(type)) {
throw MessagingLogger.ROOT_LOGGER.canNotRegisterResourceOfType(type);
} else {
delegate.registerChild(address, resource);
}
}
@Override
public void registerChild(PathElement address, int index, Resource resource) {
throw MessagingLogger.ROOT_LOGGER.indexedChildResourceRegistrationNotAvailable(address);
}
@Override
public Resource removeChild(PathElement address) {
String type = address.getKey();
if (CORE_ADDRESS.equals(type) ||
RUNTIME_QUEUE.equals(type)) {
throw MessagingLogger.ROOT_LOGGER.canNotRemoveResourceOfType(type);
} else {
return delegate.removeChild(address);
}
}
@Override
public boolean isRuntime() {
return delegate.isRuntime();
}
@Override
public boolean isProxy() {
return delegate.isProxy();
}
@Override
public Resource clone() {
ActiveMQServerResource clone = new ActiveMQServerResource(delegate.clone());
clone.setActiveMQServerServiceController(activeMQServerServiceController);
return clone;
}
private boolean hasAddressControl(PathElement element) {
final ManagementService managementService = getManagementService();
return managementService == null ? false : managementService.getResource(ResourceNames.ADDRESS + element.getValue()) != null;
}
private boolean hasQueueControl(String name) {
final ManagementService managementService = getManagementService();
return managementService == null ? false : managementService.getResource(ResourceNames.QUEUE + name) != null;
}
private Set<String> getCoreAddressNames() {
final ManagementService managementService = getManagementService();
if (managementService == null) {
return Collections.emptySet();
} else {
Set<String> result = new HashSet<String>();
for (Object obj : managementService.getResources(AddressControl.class)) {
AddressControl ac = AddressControl.class.cast(obj);
result.add(ac.getAddress());
}
return result;
}
}
private Set<String> getCoreQueueNames() {
final ManagementService managementService = getManagementService();
if (managementService == null) {
return Collections.emptySet();
} else {
Set<String> result = new HashSet<String>();
for (Object obj : managementService.getResources(QueueControl.class)) {
QueueControl qc = QueueControl.class.cast(obj);
result.add(qc.getName());
}
return result;
}
}
private ManagementService getManagementService() {
if (activeMQServerServiceController == null
|| activeMQServerServiceController.getState() != ServiceController.State.UP) {
return null;
} else {
return activeMQServerServiceController.getValue().getManagementService();
}
}
}
| 10,587
| 35.763889
| 133
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/BroadcastGroupDefinition.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.dmr.ModelType.LONG;
import static org.jboss.dmr.ModelType.STRING;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.CONNECTORS;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.JGROUPS_CLUSTER;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.SOCKET_BINDING;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
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.DeprecationData;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
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.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.operations.validation.StringLengthValidator;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.registry.Resource;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
import org.wildfly.extension.messaging.activemq.shallow.ShallowResourceDefinition;
/**
* Broadcast group resource definition
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat Inc.
* @deprecated Use JGroupsBroadcastGroupDefinition or SocketBroadcastGroupDefinition.
*/
public class BroadcastGroupDefinition extends ShallowResourceDefinition {
public static final PrimitiveListAttributeDefinition CONNECTOR_REFS = new StringListAttributeDefinition.Builder(CONNECTORS)
.setRequired(true)
.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)
.build();
public static final SimpleAttributeDefinition JGROUPS_CHANNEL = create(CommonAttributes.JGROUPS_CHANNEL)
.build();
public static final AttributeDefinition[] ATTRIBUTES = {JGROUPS_CHANNEL_FACTORY, JGROUPS_CHANNEL, JGROUPS_CLUSTER, SOCKET_BINDING,
BROADCAST_PERIOD, CONNECTOR_REFS};
public static final String GET_CONNECTOR_PAIRS_AS_JSON = "get-connector-pairs-as-json";
BroadcastGroupDefinition(boolean registerRuntimeOnly) {
super(new SimpleResourceDefinition.Parameters(MessagingExtension.BROADCAST_GROUP_PATH, MessagingExtension.getResourceDescriptionResolver(CommonAttributes.BROADCAST_GROUP))
.setAddHandler(BroadcastGroupAdd.INSTANCE)
.setRemoveHandler(BroadcastGroupRemove.INSTANCE)
.setFeature(false)
.setDeprecationData(new DeprecationData(MessagingExtension.VERSION_9_0_0, true)),
registerRuntimeOnly);
}
@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(ATTRIBUTES);
}
@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);
}
}
static void validateConnectors(OperationContext context, ModelNode operation, ModelNode connectorRefs) throws OperationFailedException {
final Set<String> availableConnectors = getAvailableConnectors(context, operation);
final List<ModelNode> operationAddress = operation.get(ModelDescriptionConstants.ADDRESS).asList();
if (connectorRefs.isDefined()) {
for (ModelNode connectorRef : connectorRefs.asList()) {
final String connectorName = connectorRef.asString();
if (!availableConnectors.contains(connectorName)) {
throw MessagingLogger.ROOT_LOGGER.wrongConnectorRefInBroadCastGroup(getBroadCastGroupName(operationAddress.get(operationAddress.size() - 1)), connectorName, availableConnectors);
}
}
}
}
private static String getBroadCastGroupName(ModelNode node) {
if (node.hasDefined(CommonAttributes.BROADCAST_GROUP)) {
return node.get(CommonAttributes.BROADCAST_GROUP).asString();
}
if (node.hasDefined(CommonAttributes.SOCKET_BROADCAST_GROUP)) {
return node.get(CommonAttributes.SOCKET_BROADCAST_GROUP).asString();
}
if (node.hasDefined(CommonAttributes.JGROUPS_BROADCAST_GROUP)) {
return node.get(CommonAttributes.JGROUPS_BROADCAST_GROUP).asString();
}
return ModelType.UNDEFINED.name();
}
// FIXME use capabilities & requirements
private static Set<String> getAvailableConnectors(final OperationContext context, final ModelNode operation) throws OperationFailedException {
PathAddress address = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR));
PathAddress active = MessagingServices.getActiveMQServerPathAddress(address);
Set<String> availableConnectors = new HashSet<>();
Resource subsystemResource = context.readResourceFromRoot(active.getParent(), false);
availableConnectors.addAll(subsystemResource.getChildrenNames(CommonAttributes.REMOTE_CONNECTOR));
Resource activeMQServerResource = context.readResourceFromRoot(active, false);
availableConnectors.addAll(activeMQServerResource.getChildrenNames(CommonAttributes.HTTP_CONNECTOR));
availableConnectors.addAll(activeMQServerResource.getChildrenNames(CommonAttributes.IN_VM_CONNECTOR));
availableConnectors.addAll(activeMQServerResource.getChildrenNames(CommonAttributes.REMOTE_CONNECTOR));
availableConnectors.addAll(activeMQServerResource.getChildrenNames(CommonAttributes.CONNECTOR));
return availableConnectors;
}
@Override
public PathAddress convert(OperationContext context, ModelNode operation) {
PathAddress parent = context.getCurrentAddress().getParent();
PathAddress targetAddress = parent.append(CommonAttributes.JGROUPS_BROADCAST_GROUP, context.getCurrentAddressValue());
try {
context.readResourceFromRoot(targetAddress, false);
return targetAddress;
} catch (Resource.NoSuchResourceException ex) {
return parent.append(CommonAttributes.SOCKET_BROADCAST_GROUP, context.getCurrentAddressValue());
}
}
@Override
public Set<String> getIgnoredAttributes(OperationContext context, ModelNode operation) {
PathAddress targetAddress = context.getCurrentAddress().getParent().append(CommonAttributes.JGROUPS_BROADCAST_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_BROADCAST_GROUP.equals(targetAddress.getLastElement().getKey());
}
}
| 10,252
| 48.771845
| 198
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/AddIfAbsentStepHandler.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2018, 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.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.dmr.ModelNode;
/**
* Executes an add operation only if the resource does not yet exist.
* @author Paul Ferraro
*/
public enum AddIfAbsentStepHandler implements OperationStepHandler {
INSTANCE;
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
PathAddress address = context.getCurrentAddress();
Resource parentResource = context.readResourceFromRoot(address.getParent(), false);
if (!parentResource.hasChild(address.getLastElement())) {
context.getResourceRegistration().getOperationHandler(PathAddress.EMPTY_ADDRESS, ModelDescriptionConstants.ADD).execute(context, operation);
}
}
}
| 2,126
| 41.54
| 152
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/ExternalBrokerConfigurationService.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;
import java.util.Map;
import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
import org.apache.activemq.artemis.api.core.TransportConfiguration;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;
/**
*
* @author Emmanuel Hugonnet (c) 2018 Red Hat, inc.
*/
public class ExternalBrokerConfigurationService implements Service<ExternalBrokerConfigurationService> {
private final Map<String, TransportConfiguration> connectors;
private final Map<String, DiscoveryGroupConfiguration> discoveryGroupConfigurations;
private final Map<String, ServiceName> socketBindings;
private final Map<String, ServiceName> outboundSocketBindings;
private final Map<String, ServiceName> groupBindings;
// mapping between the {broadcast|discovery}-groups and the cluster names they use
private final Map<String, String> clusterNames;
// mapping between the {broadcast|discovery}-groups and the command dispatcher factory they use
private final Map<String, ServiceName> commandDispatcherFactories;
private final Map<String, String> sslContextNames;
public ExternalBrokerConfigurationService(final Map<String, TransportConfiguration> connectors,
Map<String, DiscoveryGroupConfiguration> discoveryGroupConfigurations,
Map<String, ServiceName> socketBindings,
Map<String, ServiceName> outboundSocketBindings,
Map<String, ServiceName> groupBindings,
Map<String, ServiceName> commandDispatcherFactories,
Map<String, String> clusterNames,
Map<String, String> sslContextNames) {
this.connectors = connectors;
this.discoveryGroupConfigurations = discoveryGroupConfigurations;
this.clusterNames = clusterNames;
this.commandDispatcherFactories = commandDispatcherFactories;
this.groupBindings = groupBindings;
this.outboundSocketBindings = outboundSocketBindings;
this.socketBindings = socketBindings;
this.sslContextNames = sslContextNames;
}
@Override
public void start(StartContext context) throws StartException {
}
@Override
public void stop(StopContext context) {
}
public Map<String, TransportConfiguration> getConnectors() {
return connectors;
}
public Map<String, ServiceName> getSocketBindings() {
return socketBindings;
}
public Map<String, ServiceName> getOutboundSocketBindings() {
return outboundSocketBindings;
}
public Map<String, ServiceName> getGroupBindings() {
return groupBindings;
}
public Map<String, String> getClusterNames() {
return clusterNames;
}
public Map<String, ServiceName> getCommandDispatcherFactories() {
return commandDispatcherFactories;
}
public Map<String, DiscoveryGroupConfiguration> getDiscoveryGroupConfigurations() {
return discoveryGroupConfigurations;
}
public Map<String, String> getSslContextNames() {
return sslContextNames;
}
@Override
public ExternalBrokerConfigurationService getValue() throws IllegalStateException, IllegalArgumentException {
return this;
}
}
| 3,995
| 36.345794
| 113
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/ManagementUtil.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.client.helpers.ClientConstants.NAME;
import static org.wildfly.extension.messaging.activemq.SecurityRoleDefinition.BROWSE;
import static org.wildfly.extension.messaging.activemq.SecurityRoleDefinition.CONSUME;
import static org.wildfly.extension.messaging.activemq.SecurityRoleDefinition.CREATE_ADDRESS;
import static org.wildfly.extension.messaging.activemq.SecurityRoleDefinition.CREATE_DURABLE_QUEUE;
import static org.wildfly.extension.messaging.activemq.SecurityRoleDefinition.CREATE_NON_DURABLE_QUEUE;
import static org.wildfly.extension.messaging.activemq.SecurityRoleDefinition.DELETE_ADDRESS;
import static org.wildfly.extension.messaging.activemq.SecurityRoleDefinition.DELETE_DURABLE_QUEUE;
import static org.wildfly.extension.messaging.activemq.SecurityRoleDefinition.DELETE_NON_DURABLE_QUEUE;
import static org.wildfly.extension.messaging.activemq.SecurityRoleDefinition.MANAGE;
import static org.wildfly.extension.messaging.activemq.SecurityRoleDefinition.SEND;
import org.jboss.as.controller.OperationContext;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.Property;
/**
* Helper class to report management attributes or operation results
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class ManagementUtil {
public static void reportRolesAsJSON(OperationContext context, String rolesAsJSON) {
ModelNode camelCase = ModelNode.fromJSONString(rolesAsJSON);
ModelNode converted = convertSecurityRole(camelCase);
String json = converted.toJSONString(true);
context.getResult().set(json);
}
public static void reportRoles(OperationContext context, Object[] roles) {
context.getResult().set(convertRoles(roles));
}
public static ModelNode convertRoles(Object[] roles) {
final ModelNode result = new ModelNode();
result.setEmptyList();
if (roles != null && roles.length > 0) {
for (Object objRole : roles) {
Object[] role = (Object[])objRole;
final ModelNode roleNode = result.add();
roleNode.get(NAME).set(role[0].toString());
roleNode.get(SEND.getName()).set((Boolean)role[1]);
roleNode.get(CONSUME.getName()).set((Boolean)role[2]);
roleNode.get(CREATE_DURABLE_QUEUE.getName()).set((Boolean)role[3]);
roleNode.get(DELETE_DURABLE_QUEUE.getName()).set((Boolean)role[4]);
roleNode.get(CREATE_NON_DURABLE_QUEUE.getName()).set((Boolean)role[5]);
roleNode.get(DELETE_NON_DURABLE_QUEUE.getName()).set((Boolean)role[6]);
roleNode.get(MANAGE.getName()).set((Boolean)role[7]);
roleNode.get(BROWSE.getName()).set((Boolean)role[8]);
roleNode.get(CREATE_ADDRESS.getName()).set((Boolean)role[9]);
roleNode.get(DELETE_ADDRESS.getName()).set((Boolean)role[10]);
}
}
return result;
}
public static void reportListOfStrings(OperationContext context, String[] strings) {
final ModelNode result = context.getResult();
result.setEmptyList();
for (String str : strings) {
result.add(str);
}
}
private ManagementUtil() {
}
/**
* Utility for converting camel case based ActiveMQ formats to WildFly standards.
*/
static ModelNode convertSecurityRole(final ModelNode camelCase) {
final ModelNode result = new ModelNode();
result.setEmptyList();
if (camelCase.isDefined()) {
for (ModelNode role : camelCase.asList()) {
final ModelNode roleNode = result.add();
for (Property prop : role.asPropertyList()) {
String key = prop.getName();
if (null != key) switch (key) {
case "createDurableQueue":
key = SecurityRoleDefinition.CREATE_DURABLE_QUEUE.getName();
break;
case "deleteDurableQueue":
key = SecurityRoleDefinition.DELETE_DURABLE_QUEUE.getName();
break;
case "createNonDurableQueue":
key = SecurityRoleDefinition.CREATE_NON_DURABLE_QUEUE.getName();
break;
case "deleteNonDurableQueue":
key = SecurityRoleDefinition.DELETE_NON_DURABLE_QUEUE.getName();
break;
case "createAddress":
key = "create-address";
break;
case "deleteAddress":
key = "delete-address";
break;
default:
break;
}
roleNode.get(key).set(prop.getValue());
}
}
}
return result;
}
}
| 6,122
| 44.69403
| 103
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/SocketDiscoveryGroupDefinition.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 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.PathElement;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
import org.jboss.as.controller.SimpleAttributeDefinition;
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.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
/**
* Discovery group resource definition using socket bindings.
* @author Emmanuel Hugonnet (c) 2019 Red Hat, Inc.
*/
public class SocketDiscoveryGroupDefinition extends PersistentResourceDefinition {
public static final PathElement PATH = PathElement.pathElement(CommonAttributes.SOCKET_DISCOVERY_GROUP);
public static final RuntimeCapability<Void> CAPABILITY = RuntimeCapability.Builder.of("org.wildfly.messaging.activemq.socket-discovery-group", true)
.setDynamicNameMapper(DynamicNameMappers.PARENT)
// WFLY-10518 - only the name of the discovery-group is used for its capability as the resource can be
// either under server (and it is deprecated) or under the subsystem.
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultBroadcastRefreshTimeout
*/
public static final SimpleAttributeDefinition REFRESH_TIMEOUT = create("refresh-timeout", ModelType.LONG)
.setDefaultValue(new ModelNode(10000L))
.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();
public static final SimpleAttributeDefinition SOCKET_BINDING = create(CommonAttributes.SOCKET_BINDING)
.setRequired(true)
.setAlternatives(new String[0])
.build();
public static final AttributeDefinition[] ATTRIBUTES = {SOCKET_BINDING, REFRESH_TIMEOUT, INITIAL_WAIT_TIMEOUT};
private final boolean registerRuntimeOnly;
protected SocketDiscoveryGroupDefinition(final boolean registerRuntimeOnly, final boolean subsystemResource) {
super(new SimpleResourceDefinition.Parameters(PATH, MessagingExtension.getResourceDescriptionResolver(CommonAttributes.DISCOVERY_GROUP))
.setAddHandler(SocketDiscoveryGroupAdd.INSTANCE)
.setRemoveHandler(SocketDiscoveryGroupRemove.INSTANCE)
.addCapabilities(CAPABILITY));
this.registerRuntimeOnly = registerRuntimeOnly;
}
@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(ATTRIBUTES);
}
@Override
public void registerAttributes(ManagementResourceRegistration registry) {
ReloadRequiredWriteAttributeHandler reloadRequiredWriteAttributeHandler = new ReloadRequiredWriteAttributeHandler(ATTRIBUTES);
for (AttributeDefinition attr : ATTRIBUTES) {
if (registerRuntimeOnly || !attr.getFlags().contains(AttributeAccess.Flag.STORAGE_RUNTIME)) {
registry.registerReadWriteAttribute(attr, null, reloadRequiredWriteAttributeHandler);
}
}
}
}
| 5,225
| 44.443478
| 152
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/JGroupsBroadcastGroupRemove.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.dmr.ModelNode;
/**
* Removes a broadcast group using JGroups.
* @author Emmanuel Hugonnet (c) 2019 Red Hat, Inc.
*/
public class JGroupsBroadcastGroupRemove extends ReloadRequiredRemoveStepHandler {
public static final JGroupsBroadcastGroupRemove INSTANCE = new JGroupsBroadcastGroupRemove(true);
public static final JGroupsBroadcastGroupRemove LEGACY_INSTANCE = new JGroupsBroadcastGroupRemove(false);
private final boolean needLegacyCall;
private JGroupsBroadcastGroupRemove(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.BROADCAST_GROUP, context.getCurrentAddressValue());
ModelNode op = operation.clone();
op.get(OP_ADDR).set(target.toModelNode());
context.addStep(op, BroadcastGroupRemove.LEGACY_INSTANCE, OperationContext.Stage.MODEL, true);
}
super.execute(context, operation);
}
}
| 2,554
| 42.305085
| 148
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/GroupingHandlerRemove.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.AbstractRemoveStepHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.dmr.ModelNode;
/**
* Removes the grouping handler.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class GroupingHandlerRemove extends AbstractRemoveStepHandler {
public static final GroupingHandlerRemove INSTANCE = new GroupingHandlerRemove();
private GroupingHandlerRemove() {
super();
}
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
context.reloadRequired();
}
@Override
protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
context.revertReloadRequired();
}
}
| 1,969
| 36.169811
| 132
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/SecurityRoleAttributeHandler.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.HashSet;
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.AbstractWriteAttributeHandler;
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;
/**
* @author Emanuel Muckenhuber
*/
class SecurityRoleAttributeHandler extends AbstractWriteAttributeHandler<Set<Role>> {
static final SecurityRoleAttributeHandler INSTANCE = new SecurityRoleAttributeHandler();
private SecurityRoleAttributeHandler() {
super(SecurityRoleDefinition.ATTRIBUTES);
}
@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName,
ModelNode newValue, ModelNode currentValue,
HandbackHolder<Set<Role>> handbackHolder) throws OperationFailedException {
final ActiveMQServer server = getActiveMQServer(context, operation);
if(server != null) {
final PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
final String match = address.getElement(address.size() - 2).getValue();
final String roleName = address.getLastElement().getValue();
final Set<Role> newRoles = new HashSet<Role>();
final Set<Role> roles = server.getSecurityRepository().getMatch(match);
handbackHolder.setHandback(roles);
for(final Role role : roles) {
if(! roleName.equals(role.getName())) {
newRoles.add(role);
}
}
final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
final ModelNode subModel = resource.getModel();
final Role updatedRole = SecurityRoleDefinition.transform(context, roleName, subModel);
newRoles.add(updatedRole);
server.getSecurityRepository().addMatch(match, newRoles);
}
return false;
}
@Override
protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, Set<Role> handback) throws OperationFailedException {
if (handback != null) {
final ActiveMQServer server = getActiveMQServer(context, operation);
if(server != null) {
final PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
final String match = address.getElement(address.size() - 2).getValue();
server.getSecurityRepository().addMatch(match, handback);
}
}
}
}
| 4,196
| 45.633333
| 214
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/MessagingServices.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.wildfly.extension.messaging.activemq.Capabilities.ACTIVEMQ_SERVER_CAPABILITY;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.JMS_BRIDGE;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.SUBSYSTEM;
import java.util.function.Function;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.capability.CapabilityServiceSupport;
import org.jboss.msc.service.ServiceName;
/**
* @author Emanuel Muckenhuber
*/
public class MessagingServices {
public static final ServiceName ACTIVEMQ_CLIENT_THREAD_POOL = ACTIVEMQ_SERVER_CAPABILITY.getCapabilityServiceName().getParent().append("client-thread-pool");
private static final ServiceName COMMAND_DISPATCHER_FACTORY = ACTIVEMQ_SERVER_CAPABILITY.getCapabilityServiceName().getParent().append("command-dispatcher-factory");
// Cached by MessagingSubsystemAdd at the beginning of runtime processing
static volatile CapabilityServiceSupport capabilityServiceSupport;
public static ServiceName getActiveMQServiceName(PathAddress pathAddress) {
// We need to figure out what ActiveMQ this operation is targeting.
// We can get that from the "address" element of the operation, as the "server=x" part of
// the address will specify the name of the ActiveMQ server
// We are a handler for requests related to a jms-topic resource. Those reside on level below the server
// resources in the resource tree. So we could look for the server in the 2nd to last element
// in the PathAddress. But to be more generic and future-proof, we'll walk the tree looking
PathAddress serverPathAddress = getActiveMQServerPathAddress(pathAddress);
if (serverPathAddress != null && serverPathAddress.size() > 0) {
return ACTIVEMQ_SERVER_CAPABILITY.getCapabilityServiceName(serverPathAddress.getLastElement().getValue());
}
return null;
}
public static PathAddress getActiveMQServerPathAddress(PathAddress pathAddress) {
for (int i = pathAddress.size() - 1; i >=0; i--) {
PathElement pe = pathAddress.getElement(i);
if (CommonAttributes.SERVER.equals(pe.getKey())) {
return pathAddress.subAddress(0, i + 1);
}
}
return PathAddress.EMPTY_ADDRESS;
}
public static ServiceName getActiveMQServiceName() {
return ACTIVEMQ_SERVER_CAPABILITY.getCapabilityServiceName().getParent();
}
public static ServiceName getActiveMQServiceName(String serverName) {
if(serverName == null || serverName.isEmpty()) {
return getActiveMQServiceName();
}
return ACTIVEMQ_SERVER_CAPABILITY.getCapabilityServiceName(serverName);
}
public static ServiceName getQueueBaseServiceName(ServiceName serverServiceName) {
return serverServiceName.append(CommonAttributes.QUEUE);
}
static ServiceName getHttpUpgradeServiceName(String activemqServerName, String acceptorName) {
return getActiveMQServiceName(activemqServerName).append("http-upgrade-service", acceptorName);
}
static ServiceName getLegacyHttpUpgradeServiceName(String activemqServerName, String acceptorName) {
return getActiveMQServiceName(activemqServerName).append(CommonAttributes.LEGACY, "http-upgrade-service", acceptorName);
}
public static ServiceName getJMSBridgeServiceName(String bridgeName) {
return ACTIVEMQ_SERVER_CAPABILITY.getCapabilityServiceName().getParent().append(JMS_BRIDGE).append(bridgeName);
}
public static ServiceName getBroadcastCommandDispatcherFactoryServiceName(String channelName) {
return (channelName != null) ? COMMAND_DISPATCHER_FACTORY.append(channelName) : COMMAND_DISPATCHER_FACTORY;
}
/**
* Determines a ServiceName from a capability name. Only supported for use by services installed by
* this subsystem; will not function reliably until the subsystem has begun adding runtime services.
*
* @param capabilityBaseName the base name of the capability, or its full name if it is not dynamic
* @param dynamicParts any dynamic parts of the capability name. May be {@code null}
* @return the service name
*
* @throws IllegalStateException if invoked before the subsystem has begun adding runtime services
*/
public static ServiceName getCapabilityServiceName(String capabilityBaseName, String... dynamicParts) {
if (capabilityServiceSupport == null) {
throw new IllegalStateException();
}
if (dynamicParts == null || dynamicParts.length == 0) {
return capabilityServiceSupport.getCapabilityServiceName(capabilityBaseName);
}
return capabilityServiceSupport.getCapabilityServiceName(capabilityBaseName, dynamicParts);
}
/**
* Name of the capability that ensures a local provider of transactions is present.
* Once its service is started, calls to the getInstance() methods of ContextTransactionManager,
* ContextTransactionSynchronizationRegistry and LocalUserTransaction can be made knowing
* that the global default TM, TSR and UT will be from that provider.
*/
public static final String LOCAL_TRANSACTION_PROVIDER_CAPABILITY = "org.wildfly.transactions.global-default-local-provider";
/**
* The capability name for the transaction XAResourceRecoveryRegistry.
*/
public static final String TRANSACTION_XA_RESOURCE_RECOVERY_REGISTRY_CAPABILITY = "org.wildfly.transactions.xa-resource-recovery-registry";
public static boolean isSubsystemResource(final OperationContext context) {
return context.getCurrentAddress().size() > 0 && SUBSYSTEM.equals(context.getCurrentAddress().getParent().getLastElement().getKey());
}
public static class ServerNameMapper implements Function<PathAddress, String[]> {
private final String name;
public ServerNameMapper(String name) {
this.name = name;
}
@Override
public String[] apply(PathAddress pathAddress) {
PathAddress serverAddress = getActiveMQServerPathAddress(pathAddress);
if (serverAddress.size() > 0) {
String servername = getActiveMQServerPathAddress(pathAddress).getLastElement().getValue();
return new String[]{
servername,
name,
pathAddress.getLastElement().getValue()
};
}
return new String[]{name,
pathAddress.getLastElement().getValue()
};
}
}
}
| 7,803
| 46.877301
| 169
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/ElytronSecurityManager.java
|
/*
* Copyright 2016 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 java.util.HashSet;
import java.util.Set;
import org.apache.activemq.artemis.core.security.CheckType;
import org.apache.activemq.artemis.core.security.Role;
import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
import org.wildfly.security.auth.server.RealmUnavailableException;
import org.wildfly.security.auth.server.SecurityDomain;
import org.wildfly.security.auth.server.SecurityIdentity;
import org.wildfly.security.auth.server.ServerAuthenticationContext;
import org.wildfly.security.evidence.PasswordGuessEvidence;
/**
* This class implements an {@link ActiveMQSecurityManager} that uses an Elytron {@link SecurityDomain} to authenticate
* users and perform role checking.
*
* @author <a href="mailto:sguilhen@redhat.com">Stefan Guilhen</a>
*/
public class ElytronSecurityManager implements ActiveMQSecurityManager {
private final SecurityDomain securityDomain;
private final String defaultUser;
private final String defaultPassword;
/**
* Creates an instance of {@link ElytronSecurityManager} with the specified {@link SecurityDomain}.
*
* @param securityDomain a reference to the Elytron {@link SecurityDomain} that will be used to authenticate users.
*/
public ElytronSecurityManager(final SecurityDomain securityDomain) {
if (securityDomain == null)
throw MessagingLogger.ROOT_LOGGER.invalidNullSecurityDomain();
this.securityDomain = securityDomain;
this.defaultUser = DefaultCredentials.getUsername();
this.defaultPassword = DefaultCredentials.getPassword();
}
@Override
public boolean validateUser(String username, String password) {
if (defaultUser.equals(username) && defaultPassword.equals(password))
return true;
return this.authenticate(username, password) != null;
}
@Override
public boolean validateUserAndRole(String username, String password, Set<Role> roles, CheckType checkType) {
if (defaultUser.equals(username) && defaultPassword.equals(password))
return true;
final SecurityIdentity identity = this.authenticate(username, password);
if (identity == null) {
return false;
}
final Set<String> filteredRoles = new HashSet<>();
for (Role role : roles) {
if (checkType.hasRole(role)) {
String name = role.getName();
filteredRoles.add(name);
}
}
return identity.getRoles().containsAny(filteredRoles);
}
/**
* Attempt to authenticate and authorize an username with the specified password evidence.
*
* @param username the username being authenticated.
* @param password the password to be verified.
* @return a reference to the {@link SecurityIdentity} if the user was successfully authenticated and authorized;
* {@code null} otherwise.
*/
private SecurityIdentity authenticate(final String username, final String password) {
ServerAuthenticationContext context = this.securityDomain.createNewAuthenticationContext();
PasswordGuessEvidence evidence = null;
try {
if (password == null) {
if (username == null) {
if (context.authorizeAnonymous()) {
context.succeed();
return context.getAuthorizedIdentity();
} else {
context.fail();
return null;
}
} else {
// treat a non-null user name with a null password as a auth failure
context.fail();
return null;
}
}
context.setAuthenticationName(username);
evidence = new PasswordGuessEvidence(password.toCharArray());
if (context.verifyEvidence(evidence)) {
if (context.authorize()) {
context.succeed();
return context.getAuthorizedIdentity();
}
else {
context.fail();
MessagingLogger.ROOT_LOGGER.failedAuthorization(username);
}
} else {
context.fail();
MessagingLogger.ROOT_LOGGER.failedAuthentication(username);
}
} catch (IllegalArgumentException | IllegalStateException | RealmUnavailableException e) {
context.fail();
MessagingLogger.ROOT_LOGGER.failedAuthenticationWithException(e, username, e.getMessage());
} finally {
if (evidence != null) {
evidence.destroy();
}
}
return null;
}
}
| 5,499
| 38.568345
| 119
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/Capabilities.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 javax.net.ssl.SSLContext;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.network.OutboundSocketBinding;
import org.jboss.as.network.SocketBinding;
/**
* Capabilities for the messaging-activemq extension. This is not to be used outside of this extension.
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2017 Red Hat Inc.
*/
public class Capabilities {
/**
* Represents the data source capability
*
* @see <a href="https://github.com/wildfly/wildfly-capabilities/blob/main/org/wildfly/data-source/capability.adoc">Capability documentation</a>
*/
static final String DATA_SOURCE_CAPABILITY = "org.wildfly.data-source";
/**
* The capability name for the JMX management.
*
* @see <a href="https://github.com/wildfly/wildfly-capabilities/blob/main/org/wildfly/management/jmx/capability.adoc">Capability documentation</a>
*/
static final String JMX_CAPABILITY = "org.wildfly.management.jmx";
/**
* The capability name for the current messaging-activemq server configuration.
*
* @see <a href="https://github.com/wildfly/wildfly-capabilities/blob/main/org/wildfly/messaging/activemq/server/capability.adoc">Capability documentation</a>
*/
static final String ACTIVEMQ_SERVER_CAPABILITY_NAME = "org.wildfly.messaging.activemq.server";
/**
* A capability for the current messaging-activemq server configuration.
*
* @see <a href="https://github.com/wildfly/wildfly-capabilities/blob/main/org/wildfly/messaging/activemq/server/capability.adoc">Capability documentation</a>
*/
static final RuntimeCapability<Void> ACTIVEMQ_SERVER_CAPABILITY = RuntimeCapability.Builder.of(ACTIVEMQ_SERVER_CAPABILITY_NAME, true, ActiveMQServer.class)
//.addRuntimeOnlyRequirements(JMX_CAPABILITY) -- has no function so don't use it
.build();
/**
* The capability name for the legacy security domain.
* @see <a href="https://github.com/wildfly/wildfly-capabilities/blob/main/org/wildfly/security/security-domain/capability.adoc">Capability documentation</a>
*/
static final RuntimeCapability<Void> LEGACY_SECURITY_DOMAIN_CAPABILITY = RuntimeCapability.Builder.of("org.wildfly.security.legacy-security-domain", true)
.build();
/**
* The capability name for the Elytron security domain.
* @see <a href="https://github.com/wildfly/wildfly-capabilities/blob/master/org/wildfly/security/security-domain/capability.adoc">documentation</a>
*/
static final String ELYTRON_DOMAIN_CAPABILITY = "org.wildfly.security.security-domain";
/**
* The capability for the PathManager
*
* @see <a href="https://github.com/wildfly/wildfly-capabilities/blob/main/org/wildfly/management/path-manager/capability.adoc">documentation</a>
*/
static final String PATH_MANAGER_CAPABILITY = "org.wildfly.management.path-manager";
/**
* The capability for the Http Listener Registry
*
* @see <a href="https://github.com/wildfly/wildfly-capabilities/blob/main/org/wildfly/remoting/http-listener-registry/capability.adoc">documentation</a>
*/
static final String HTTP_LISTENER_REGISTRY_CAPABILITY_NAME = "org.wildfly.remoting.http-listener-registry";
/**
* The capability for the Http Upgrade Registry
*
* @see <a href="https://github.com/wildfly/wildfly-capabilities/blob/main/org/wildfly/undertow/listener/http-upgrade-registry/capability.adoc">documentation</a>
*/
static final String HTTP_UPGRADE_REGISTRY_CAPABILITY_NAME = "org.wildfly.undertow.listener.http-upgrade-registry";
/**
* The capability for the SocketBinding capability
*
* @see <a href="https://github.com/wildfly/wildfly-capabilities/blob/main/org/wildfly/network/socket-binding/capability.adoc">documentation</a>
*/
public static final String SOCKET_BINDING_CAPABILITY_NAME = "org.wildfly.network.socket-binding";
/**
* The capability for the SocketBinding capability
*
* @see <a href="https://github.com/wildfly/wildfly-capabilities/blob/main/org/wildfly/network/socket-binding/capability.adoc">documentation</a>
*/
public static final RuntimeCapability<Void> SOCKET_BINDING_CAPABILITY = RuntimeCapability.Builder.of(SOCKET_BINDING_CAPABILITY_NAME, true, SocketBinding.class)
.build();
/**
* A capability for the current messaging-activemq server configuration.
*
* @see <a href="https://github.com/wildfly/wildfly-capabilities/blob/main/org/wildfly/network/outbound-socket-binding/capability.adoc">Capability documentation</a>
*/
public static final String OUTBOUND_SOCKET_BINDING_CAPABILITY_NAME ="org.wildfly.network.outbound-socket-binding";
/**
* A capability for the current messaging-activemq server configuration.
*
* @see <a href="https://github.com/wildfly/wildfly-capabilities/blob/main/org/wildfly/network/outbound-socket-binding/capability.adoc">Capability documentation</a>
*/
public static final RuntimeCapability<Void> OUTBOUND_SOCKET_BINDING_CAPABILITY = RuntimeCapability.Builder.of(OUTBOUND_SOCKET_BINDING_CAPABILITY_NAME, true, OutboundSocketBinding.class)
.build();
/**
* The capability name for the Elytron SSL context.
*
* @see <a href="https://github.com/wildfly/wildfly-capabilities/blob/master/org/wildfly/security/ssl-context/capability.adoc">documentation</a>
*/
public static final String ELYTRON_SSL_CONTEXT_CAPABILITY_NAME = "org.wildfly.security.ssl-context";
/**
* The capability name for the Elytron SSL context.
*
* @see <a href="https://github.com/wildfly/wildfly-capabilities/blob/master/org/wildfly/security/ssl-context/capability.adoc">documentation</a>
*/
public static final RuntimeCapability<Void> ELYTRON_SSL_CONTEXT_CAPABILITY = RuntimeCapability.Builder.of(ELYTRON_SSL_CONTEXT_CAPABILITY_NAME, true, SSLContext.class).build();
}
| 7,158
| 48.715278
| 189
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/BinderServiceUtil.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;
import static org.wildfly.extension.messaging.activemq.logging.MessagingLogger.ROOT_LOGGER;
import static org.jboss.as.naming.deployment.ContextNames.BindInfo;
import javax.naming.InitialContext;
import org.jboss.as.naming.ContextListAndJndiViewManagedReferenceFactory;
import org.jboss.as.naming.ContextListManagedReferenceFactory;
import org.jboss.as.naming.ManagedReference;
import org.jboss.as.naming.ServiceBasedNamingStore;
import org.jboss.as.naming.ValueManagedReference;
import org.jboss.as.naming.ValueManagedReferenceFactory;
import org.jboss.as.naming.deployment.ContextNames;
import org.jboss.as.naming.service.BinderService;
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;
/**
* Utility class to install BinderService (either to bind actual objects or create alias on another binding).
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2013 Red Hat Inc.
*/
public class BinderServiceUtil {
/**
* Install a binder service to bind the {@code obj} using the binding {@code name}.
* @param serviceTarget
* @param name the binding name
* @param obj the object that must be bound
*/
public static void installBinderService(final ServiceTarget serviceTarget,
final String name,
final Object obj) {
final BindInfo bindInfo = ContextNames.bindInfoFor(name);
final BinderService binderService = new BinderService(bindInfo.getBindName());
binderService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(obj));
serviceTarget.addService(bindInfo.getBinderServiceName(), binderService)
.addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector())
.install();
}
/**
* Install a binder service to bind the value of the {@code service} using the binding {@code name}.
* @param serviceTarget
* @param name the binding name
* @param service the service whose value must be bound
*/
public static void installBinderService(final ServiceTarget serviceTarget,
final String name,
final Service<?> service,
final ServiceName dependency) {
final BindInfo bindInfo = ContextNames.bindInfoFor(name);
final BinderService binderService = new BinderService(bindInfo.getBindName());
binderService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(service));
final ServiceBuilder serviceBuilder = serviceTarget.addService(bindInfo.getBinderServiceName(), binderService)
.addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector())
// we set it in passive mode so that missing dependencies (which is possible/valid when it's a backup HornetQ server and the services
// haven't been activated on it due to the presence of a different live server) don't cause jms-topic/jms-queue add operations
// to fail
.setInitialMode(ServiceController.Mode.PASSIVE);
if (dependency != null) {
serviceBuilder.requires(dependency);
}
serviceBuilder.install();
}
public static void installAliasBinderService(final ServiceTarget serviceTarget,
final BindInfo bindInfo,
final String alias) {
final BindInfo aliasBindInfo = ContextNames.bindInfoFor(alias);
final BinderService aliasBinderService = new BinderService(alias);
aliasBinderService.getManagedObjectInjector().inject(new AliasManagedReferenceFactory(bindInfo.getAbsoluteJndiName()));
final ServiceBuilder sb = serviceTarget.addService(aliasBindInfo.getBinderServiceName(), aliasBinderService);
sb.addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, aliasBinderService.getNamingStoreInjector());
sb.requires(bindInfo.getBinderServiceName());
sb.addListener(new LifecycleListener() {
private volatile boolean bound;
@Override
public void handleEvent(ServiceController<?> controller, LifecycleEvent event) {
switch (event) {
case UP: {
ROOT_LOGGER.boundJndiName(alias);
bound = true;
break;
}
case DOWN: {
if (bound) {
ROOT_LOGGER.unboundJndiName(alias);
}
break;
}
case REMOVED: {
ROOT_LOGGER.debugf("Removed messaging object [%s]", alias);
break;
}
}
}
});
sb.install();
}
private static final class AliasManagedReferenceFactory implements ContextListAndJndiViewManagedReferenceFactory {
private final String name;
/**
* @param name original JNDI name
*/
public AliasManagedReferenceFactory(String name) {
this.name = name;
}
@Override
public ManagedReference getReference() {
try {
final Object value = new InitialContext().lookup(name);
return new ValueManagedReference(value);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override
public String getInstanceClassName() {
final Object value = getReference().getInstance();
return value != null ? value.getClass().getName() : ContextListManagedReferenceFactory.DEFAULT_INSTANCE_CLASS_NAME;
}
@Override
public String getJndiViewInstanceValue() {
return String.valueOf(getReference().getInstance());
}
}
}
| 7,696
| 45.932927
| 149
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/SocketDiscoveryGroupAdd.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.CommonAttributes.JGROUPS_CLUSTER;
import java.util.HashMap;
import java.util.Map;
import org.apache.activemq.artemis.api.core.BroadcastEndpointFactory;
import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
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.PathAddress;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
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 discovery group using socket bindings.
* @author Emmanuel Hugonnet (c) 2019 Red Hat, Inc.
*/
public class SocketDiscoveryGroupAdd extends AbstractAddStepHandler {
public static final SocketDiscoveryGroupAdd INSTANCE = new SocketDiscoveryGroupAdd(true);
public static final SocketDiscoveryGroupAdd LEGACY_INSTANCE = new SocketDiscoveryGroupAdd(false);
private final boolean needLegacyCall;
private SocketDiscoveryGroupAdd(boolean needLegacyCall) {
super(SocketDiscoveryGroupDefinition.ATTRIBUTES);
this.needLegacyCall = needLegacyCall;
}
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
super.execute(context, operation);
if(needLegacyCall) {
PathAddress target = context.getCurrentAddress().getParent().append(CommonAttributes.DISCOVERY_GROUP, context.getCurrentAddressValue());
ModelNode op = operation.clone();
op.get(OP_ADDR).set(target.toModelNode());
context.addStep(op, DiscoveryGroupAdd.LEGACY_INSTANCE, OperationContext.Stage.MODEL, true);
}
}
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
final String name = address.getLastElement().getValue();
ServiceRegistry registry = context.getServiceRegistry(false);
ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
ServiceController<?> service = serviceName == null ? null : registry.getService(serviceName);
if (service != null) {
context.reloadRequired();
} else {
final ServiceTarget target = context.getServiceTarget();
if (model.hasDefined(JGROUPS_CLUSTER.getName())) {
// nothing to do, in that case, the clustering.jgroups subsystem will have setup the stack
} else if(model.hasDefined(RemoteTransportDefinition.SOCKET_BINDING.getName())) {
if(serviceName == null) {
serviceName = MessagingServices.getActiveMQServiceName((String) null);
}
ServiceBuilder builder = target.addService(GroupBindingService.getDiscoveryBaseServiceName(serviceName).append(name));
builder.setInstance(new GroupBindingService(builder.requires(SOCKET_BINDING_CAPABILITY.getCapabilityServiceName(model.get(SOCKET_BINDING).asString()))));
builder.install();
}
}
}
static Map<String, DiscoveryGroupConfiguration> addDiscoveryGroupConfigs(final OperationContext context, final ModelNode model) throws OperationFailedException {
Map<String, DiscoveryGroupConfiguration> configs = new HashMap<>();
if (model.hasDefined(CommonAttributes.SOCKET_DISCOVERY_GROUP)) {
for (Property prop : model.get(CommonAttributes.SOCKET_DISCOVERY_GROUP).asPropertyList()) {
configs.put(prop.getName(), createDiscoveryGroupConfiguration(context, prop.getName(), prop.getValue()));
}
}
return configs;
}
static DiscoveryGroupConfiguration createDiscoveryGroupConfiguration(final OperationContext context, final String name, final ModelNode model) throws OperationFailedException {
final long refreshTimeout = DiscoveryGroupDefinition.REFRESH_TIMEOUT.resolveModelAttribute(context, model).asLong();
final long initialWaitTimeout = DiscoveryGroupDefinition.INITIAL_WAIT_TIMEOUT.resolveModelAttribute(context, model).asLong();
return new DiscoveryGroupConfiguration()
.setName(name)
.setRefreshTimeout(refreshTimeout)
.setDiscoveryInitialWaitTimeout(initialWaitTimeout);
}
public static DiscoveryGroupConfiguration createDiscoveryGroupConfiguration(final String name, final DiscoveryGroupConfiguration config, final SocketBinding socketBinding) throws Exception {
final String localAddress = socketBinding.getAddress().getHostAddress();
if (socketBinding.getMulticastAddress() == null) {
throw MessagingLogger.ROOT_LOGGER.socketBindingMulticastNotSet("socket-discovery-group", name, socketBinding.getName());
}
final String groupAddress = socketBinding.getMulticastAddress().getHostAddress();
final int groupPort = socketBinding.getMulticastPort();
final long refreshTimeout = config.getRefreshTimeout();
final long initialWaitTimeout = config.getDiscoveryInitialWaitTimeout();
final BroadcastEndpointFactory endpointFactory = new UDPBroadcastEndpointFactory()
.setGroupAddress(groupAddress)
.setGroupPort(groupPort)
.setLocalBindAddress(localAddress)
.setLocalBindPort(-1);
return new DiscoveryGroupConfiguration()
.setName(name)
.setRefreshTimeout(refreshTimeout)
.setDiscoveryInitialWaitTimeout(initialWaitTimeout)
.setBroadcastEndpointFactory(endpointFactory);
}
}
| 7,695
| 51
| 193
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/SecuritySettingAdd.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.HashSet;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
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;
/**
* {@code OperationStepHandler} for adding a new security setting.
*
* @author Emanuel Muckenhuber
*/
class SecuritySettingAdd extends AbstractAddStepHandler {
static final SecuritySettingAdd INSTANCE = new SecuritySettingAdd();
@Override
protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException {
model.setEmptyObject();
}
@Override
protected boolean requiresRuntime(OperationContext context) {
return context.isDefaultRequiresRuntime() && !context.isBooting();
}
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final ActiveMQServer server = getActiveMQServer(context, operation);
if (server != null) {
final PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
final String match = address.getLastElement().getValue();
server.getSecurityRepository().addMatch(match, new HashSet<>());
}
}
}
| 2,674
| 39.530303
| 131
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/DiscoveryGroupRemove.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.AbstractRemoveStepHandler;
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.registry.Resource;
import org.jboss.dmr.ModelNode;
/**
* Removes a discovery group.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class DiscoveryGroupRemove extends AbstractRemoveStepHandler {
public static final DiscoveryGroupRemove INSTANCE = new DiscoveryGroupRemove(false);
public static final DiscoveryGroupRemove LEGACY_INSTANCE = new DiscoveryGroupRemove(true);
private final boolean isLegacyCall;
private DiscoveryGroupRemove(boolean isLegacyCall) {
super();
this.isLegacyCall = isLegacyCall;
}
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
if (!isLegacyCall) {
ModelNode op = operation.clone();
PathAddress target = context.getCurrentAddress().getParent();
OperationStepHandler removeHandler;
try {
context.readResourceFromRoot(target.append(CommonAttributes.JGROUPS_DISCOVERY_GROUP, context.getCurrentAddressValue()), false);
target = target.append(CommonAttributes.JGROUPS_DISCOVERY_GROUP, context.getCurrentAddressValue());
removeHandler = JGroupsDiscoveryGroupRemove.LEGACY_INSTANCE;
} catch(Resource.NoSuchResourceException ex) {
target = target.append(CommonAttributes.SOCKET_DISCOVERY_GROUP, context.getCurrentAddressValue());
removeHandler = SocketDiscoveryGroupRemove.LEGACY_INSTANCE;
}
op.get(OP_ADDR).set(target.toModelNode());
context.addStep(op, removeHandler, OperationContext.Stage.MODEL, true);
}
super.execute(context, operation);
}
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
context.reloadRequired();
}
@Override
protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
context.revertReloadRequired();
}
}
| 3,532
| 42.617284
| 143
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/GroupBindingService.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 java.util.function.Supplier;
import org.jboss.as.network.SocketBinding;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;
/**
* @author Emanuel Muckenhuber
*/
public class GroupBindingService implements Service<SocketBinding> {
private static final String BASE = "bindings";
private static final String BROADCAST = "broadcast";
private static final String DISCOVERY = "discovery";
private final Supplier<SocketBinding> bindingSupplier;
public GroupBindingService(Supplier<SocketBinding> bindingSupplier) {
this.bindingSupplier = bindingSupplier;
}
@Override
public void start(final StartContext context) throws StartException {
//
}
@Override
public void stop(StopContext context) {
//
}
@Override
public SocketBinding getValue() throws IllegalStateException, IllegalArgumentException {
return bindingSupplier.get();
}
public static ServiceName getBroadcastBaseServiceName(ServiceName activeMQServiceName) {
return activeMQServiceName.append(BASE).append(BROADCAST);
}
public static ServiceName getDiscoveryBaseServiceName(ServiceName activeMQServiceName) {
return activeMQServiceName.append(BASE).append(DISCOVERY);
}
}
| 2,498
| 34.197183
| 92
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/TransportConfigOperationHandlers.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.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME;
import static org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.ACTIVEMQ_SERVER_NAME;
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.FACTORY_CLASS;
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.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 java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.Collection;
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 org.apache.activemq.artemis.api.core.TransportConfiguration;
import org.apache.activemq.artemis.core.config.Configuration;
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory;
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory;
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory;
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory;
import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
import org.jboss.as.controller.OperationContext;
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.controller.registry.Resource;
import org.jboss.as.network.ClientMapping;
import org.jboss.as.network.NetworkUtils;
import org.jboss.as.network.OutboundSocketBinding;
import org.jboss.as.network.SocketBinding;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.Property;
import org.jboss.msc.service.StartException;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* Basic {@link TransportConfiguration} (Acceptor/Connector) related operations.
*
* Artemis changed the naming convention for naming its parameters and uses CamelCase names.
* WildFly convention is to use hyphen-separated names. The mapping is done when creating Artemis connector/acceptor
* configuration based on the WildFly management model.
*
* @author Emanuel Muckenhuber
*/
public class TransportConfigOperationHandlers {
private static final Map<String, String> CONNECTORS_KEYS_MAP = new HashMap<>();
private static final Map<String, String> ACCEPTOR_KEYS_MAP = new HashMap<>();
private static final Set<String> IN_VM_ALLOWABLE_KEYS;
private static final String BATCH_DELAY = "batch-delay";
private static final String HTTP_UPGRADE_ENABLED = "http-upgrade-enabled";
private static final String KEY_STORE_PASSWORD = "key-store-password";
private static final String KEY_STORE_PATH = "key-store-path";
private static final String KEY_STORE_PROVIDER = "key-store-provider";
private static final String KEY_STORE_TYPE = "key-store-type";
private static final String TCP_RECEIVE_BUFFER_SIZE = "tcp-receive-buffer-size";
private static final String TCP_SEND_BUFFER_SIZE = "tcp-send-buffer-size";
private static final String TRUST_STORE_PASSWORD = "trust-store-password";
private static final String TRUST_STORE_PATH = "trust-store-path";
private static final String TRUST_STORE_PROVIDER = "trust-store-provider";
private static final String TRUST_STORE_TYPE = "trust-store-type";
private static final String ENABLED_PROTOCOLS = "enabled-protocols";
private static final String ENABLED_CIPHER_SUITES = "enabled-cipher-suites";
private static final String HOST = "host";
private static final String PORT = "port";
public static final String SSL_ENABLED = "ssl-enabled";
public static final String USE_NIO = "use-nio";
public static final String TCP_NO_DELAY = "tcp-no-delay";
public static final String VERIFY_HOST = "verify-host";
/**
* The name of the SocketBinding reference to use for HOST/PORT
* configuration
*/
private static final String SOCKET_REF = RemoteTransportDefinition.SOCKET_BINDING.getName();
static {
CONNECTORS_KEYS_MAP.put(InVMTransportDefinition.SERVER_ID.getName(),
org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME);
CONNECTORS_KEYS_MAP.put("buffer-pooling", org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.BUFFER_POOLING);
CONNECTORS_KEYS_MAP.put(SSL_ENABLED,
TransportConstants.SSL_ENABLED_PROP_NAME);
CONNECTORS_KEYS_MAP.put("http-enabled",
TransportConstants.HTTP_ENABLED_PROP_NAME);
CONNECTORS_KEYS_MAP.put("http-client-idle-time",
TransportConstants.HTTP_CLIENT_IDLE_PROP_NAME);
CONNECTORS_KEYS_MAP.put("http-client-idle-scan-period",
TransportConstants.HTTP_CLIENT_IDLE_SCAN_PERIOD);
CONNECTORS_KEYS_MAP.put("http-requires-session-id",
TransportConstants.HTTP_REQUIRES_SESSION_ID);
CONNECTORS_KEYS_MAP.put(HTTP_UPGRADE_ENABLED,
TransportConstants.HTTP_UPGRADE_ENABLED_PROP_NAME);
CONNECTORS_KEYS_MAP.put("http-upgrade-endpoint",
TransportConstants.HTTP_UPGRADE_ENDPOINT_PROP_NAME);
CONNECTORS_KEYS_MAP.put("use-servlet",
TransportConstants.USE_SERVLET_PROP_NAME);
CONNECTORS_KEYS_MAP.put("servlet-path",
TransportConstants.SERVLET_PATH);
CONNECTORS_KEYS_MAP.put(USE_NIO,
TransportConstants.USE_NIO_PROP_NAME);
CONNECTORS_KEYS_MAP.put("use-nio-global-worker-pool",
TransportConstants.USE_NIO_GLOBAL_WORKER_POOL_PROP_NAME);
CONNECTORS_KEYS_MAP.put(HOST,
TransportConstants.HOST_PROP_NAME);
CONNECTORS_KEYS_MAP.put(PORT,
TransportConstants.PORT_PROP_NAME);
CONNECTORS_KEYS_MAP.put("local-address",
TransportConstants.LOCAL_ADDRESS_PROP_NAME);
CONNECTORS_KEYS_MAP.put("local-port",
TransportConstants.LOCAL_PORT_PROP_NAME);
CONNECTORS_KEYS_MAP.put(KEY_STORE_PROVIDER,
TransportConstants.KEYSTORE_PROVIDER_PROP_NAME);
CONNECTORS_KEYS_MAP.put(KEY_STORE_PATH,
TransportConstants.KEYSTORE_PATH_PROP_NAME);
CONNECTORS_KEYS_MAP.put(KEY_STORE_PASSWORD,
TransportConstants.KEYSTORE_PASSWORD_PROP_NAME);
CONNECTORS_KEYS_MAP.put(KEY_STORE_TYPE, "keyStoreType"); // todo use KEYSTORE_TYPE_PROP_NAME once Artemis is upgraded
CONNECTORS_KEYS_MAP.put(TRUST_STORE_PROVIDER,
TransportConstants.TRUSTSTORE_PROVIDER_PROP_NAME);
CONNECTORS_KEYS_MAP.put(TRUST_STORE_PATH,
TransportConstants.TRUSTSTORE_PATH_PROP_NAME);
CONNECTORS_KEYS_MAP.put(TRUST_STORE_PASSWORD,
TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME);
CONNECTORS_KEYS_MAP.put(TRUST_STORE_TYPE, "trustStoreType"); // todo use TRUSTSTORE_TYPE_PROP_NAME once Artemis is upgraded
CONNECTORS_KEYS_MAP.put(ENABLED_CIPHER_SUITES,
TransportConstants.ENABLED_CIPHER_SUITES_PROP_NAME);
CONNECTORS_KEYS_MAP.put(ENABLED_PROTOCOLS,
TransportConstants.ENABLED_PROTOCOLS_PROP_NAME);
CONNECTORS_KEYS_MAP.put(TCP_NO_DELAY,
TransportConstants.TCP_NODELAY_PROPNAME);
CONNECTORS_KEYS_MAP.put(TCP_SEND_BUFFER_SIZE,
TransportConstants.TCP_SENDBUFFER_SIZE_PROPNAME);
CONNECTORS_KEYS_MAP.put(TCP_RECEIVE_BUFFER_SIZE,
TransportConstants.TCP_RECEIVEBUFFER_SIZE_PROPNAME);
CONNECTORS_KEYS_MAP.put("nio-remoting-threads",
TransportConstants.NIO_REMOTING_THREADS_PROPNAME);
CONNECTORS_KEYS_MAP.put("remoting-threads",
TransportConstants.REMOTING_THREADS_PROPNAME);
CONNECTORS_KEYS_MAP.put(BATCH_DELAY,
TransportConstants.BATCH_DELAY);
CONNECTORS_KEYS_MAP.put("connect-timeout-millis",
TransportConstants.NETTY_CONNECT_TIMEOUT);
CONNECTORS_KEYS_MAP.put("anycast-prefix", "anycastPrefix");
CONNECTORS_KEYS_MAP.put("multicast-prefix", "multicastPrefix");
CONNECTORS_KEYS_MAP.put("ssl-context", TransportConstants.SSL_CONTEXT_PROP_NAME);
CONNECTORS_KEYS_MAP.put(VERIFY_HOST, TransportConstants.VERIFY_HOST_PROP_NAME);
ACCEPTOR_KEYS_MAP.put(InVMTransportDefinition.SERVER_ID.getName(),
org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME);
ACCEPTOR_KEYS_MAP.put(BATCH_DELAY,
TransportConstants.BATCH_DELAY);
ACCEPTOR_KEYS_MAP.put("buffer-pooling", org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.BUFFER_POOLING);
ACCEPTOR_KEYS_MAP.put("cluster-connection",
TransportConstants.CLUSTER_CONNECTION);
ACCEPTOR_KEYS_MAP.put("connection-ttl",
TransportConstants.CONNECTION_TTL);
ACCEPTOR_KEYS_MAP.put("connections-allowed",
TransportConstants.CONNECTIONS_ALLOWED);
ACCEPTOR_KEYS_MAP.put("direct-deliver",
TransportConstants.DIRECT_DELIVER);
ACCEPTOR_KEYS_MAP.put(ENABLED_CIPHER_SUITES,
TransportConstants.ENABLED_CIPHER_SUITES_PROP_NAME);
ACCEPTOR_KEYS_MAP.put(ENABLED_PROTOCOLS,
TransportConstants.ENABLED_PROTOCOLS_PROP_NAME);
ACCEPTOR_KEYS_MAP.put(HOST,
TransportConstants.HOST_PROP_NAME);
ACCEPTOR_KEYS_MAP.put("http-response-time",
TransportConstants.HTTP_RESPONSE_TIME_PROP_NAME);
ACCEPTOR_KEYS_MAP.put("http-server-scan-period",
TransportConstants.HTTP_SERVER_SCAN_PERIOD_PROP_NAME);
ACCEPTOR_KEYS_MAP.put(HTTP_UPGRADE_ENABLED,
TransportConstants.HTTP_UPGRADE_ENABLED_PROP_NAME);
ACCEPTOR_KEYS_MAP.put(KEY_STORE_PASSWORD,
TransportConstants.KEYSTORE_PASSWORD_PROP_NAME);
ACCEPTOR_KEYS_MAP.put(KEY_STORE_PATH,
TransportConstants.KEYSTORE_PATH_PROP_NAME);
ACCEPTOR_KEYS_MAP.put(KEY_STORE_PROVIDER,
TransportConstants.KEYSTORE_PROVIDER_PROP_NAME);
ACCEPTOR_KEYS_MAP.put(KEY_STORE_TYPE,
"keyStoreType"); // todo use KEYSTORE_TYPE_PROP_NAME once Artemis is upgraded
ACCEPTOR_KEYS_MAP.put("needs-client-auth",
TransportConstants.NEED_CLIENT_AUTH_PROP_NAME);
ACCEPTOR_KEYS_MAP.put("nio-remoting-threads",
TransportConstants.NIO_REMOTING_THREADS_PROPNAME);
ACCEPTOR_KEYS_MAP.put("remoting-threads",
TransportConstants.REMOTING_THREADS_PROPNAME);
ACCEPTOR_KEYS_MAP.put(PORT,
TransportConstants.PORT_PROP_NAME);
ACCEPTOR_KEYS_MAP.put("protocols",
TransportConstants.PROTOCOLS_PROP_NAME);
ACCEPTOR_KEYS_MAP.put(SSL_ENABLED,
TransportConstants.SSL_ENABLED_PROP_NAME);
ACCEPTOR_KEYS_MAP.put("ssl-context", TransportConstants.SSL_CONTEXT_PROP_NAME);
ACCEPTOR_KEYS_MAP.put("stomp-enable-message-id",
TransportConstants.STOMP_ENABLE_MESSAGE_ID);
ACCEPTOR_KEYS_MAP.put("stomp-min-large-message-size",
TransportConstants.STOMP_MIN_LARGE_MESSAGE_SIZE);
ACCEPTOR_KEYS_MAP.put("stomp-consumer-credits",
TransportConstants.STOMP_CONSUMERS_CREDIT);
ACCEPTOR_KEYS_MAP.put(TCP_NO_DELAY,
TransportConstants.TCP_NODELAY_PROPNAME);
ACCEPTOR_KEYS_MAP.put(TCP_RECEIVE_BUFFER_SIZE,
TransportConstants.TCP_RECEIVEBUFFER_SIZE_PROPNAME);
ACCEPTOR_KEYS_MAP.put(TCP_SEND_BUFFER_SIZE,
TransportConstants.TCP_SENDBUFFER_SIZE_PROPNAME);
ACCEPTOR_KEYS_MAP.put(TRUST_STORE_PASSWORD,
TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME);
ACCEPTOR_KEYS_MAP.put(TRUST_STORE_PATH,
TransportConstants.TRUSTSTORE_PATH_PROP_NAME);
ACCEPTOR_KEYS_MAP.put(TRUST_STORE_PROVIDER,
TransportConstants.TRUSTSTORE_PROVIDER_PROP_NAME);
ACCEPTOR_KEYS_MAP.put(TRUST_STORE_TYPE,
"trustStoreType"); // todo use TRUSTSTORE_TYPE_PROP_NAME once Artemis is upgraded
ACCEPTOR_KEYS_MAP.put("use-invm",
TransportConstants.USE_INVM_PROP_NAME);
ACCEPTOR_KEYS_MAP.put(USE_NIO,
TransportConstants.USE_NIO_PROP_NAME);
ACCEPTOR_KEYS_MAP.put(VERIFY_HOST, TransportConstants.VERIFY_HOST_PROP_NAME);
Set<String> allowable = new HashSet<>(3);
allowable.add(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.BUFFER_POOLING);
allowable.add(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.CONNECTIONS_ALLOWED);
allowable.add(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME);
IN_VM_ALLOWABLE_KEYS = Collections.unmodifiableSet(allowable);
}
/**
* Process the acceptor information.
*
* @param context the operation context
* @param configuration the ActiveMQ configuration
* @param params the detyped operation parameters
* @param bindings the referenced socket bindings
* @throws OperationFailedException
*/
static void processAcceptors(final OperationContext context, final Configuration configuration, final ModelNode params, final Set<String> bindings, final Map<String, String> sslContexts) throws OperationFailedException {
final Map<String, TransportConfiguration> acceptors = new HashMap<>();
if (params.hasDefined(ACCEPTOR)) {
for (final Property property : params.get(ACCEPTOR).asPropertyList()) {
final String acceptorName = property.getName();
final ModelNode config = property.getValue();
final Map<String, Object> parameters = getParameters(context, config, ACCEPTOR_KEYS_MAP);
final Map<String, Object> extraParameters = getExtraParameters(TransportConstants.ALLOWABLE_ACCEPTOR_KEYS, parameters);
final String clazz = config.get(FACTORY_CLASS.getName()).asString();
if(config.hasDefined(CommonAttributes.SSL_CONTEXT.getName())) {
String sslContextName = config.get(CommonAttributes.SSL_CONTEXT.getName()).asString();
sslContexts.put(acceptorName, sslContextName);
parameters.put(TransportConstants.SSL_CONTEXT_PROP_NAME, sslContextName);
parameters.put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
}
ModelNode socketBinding = GenericTransportDefinition.SOCKET_BINDING.resolveModelAttribute(context, config);
if (socketBinding.isDefined()) {
bindings.add(socketBinding.asString());
// uses the parameters to pass the socket binding name that will be read in ActiveMQServerService.start()
parameters.put(GenericTransportDefinition.SOCKET_BINDING.getName(), socketBinding.asString());
}
acceptors.put(acceptorName, new TransportConfiguration(clazz, parameters, acceptorName, extraParameters));
}
}
if (params.hasDefined(REMOTE_ACCEPTOR)) {
for (final Property property : params.get(REMOTE_ACCEPTOR).asPropertyList()) {
final String acceptorName = property.getName();
final ModelNode config = property.getValue();
final Map<String, Object> parameters = getParameters(context, config, ACCEPTOR_KEYS_MAP);
final Map<String, Object> extraParameters = getExtraParameters(TransportConstants.ALLOWABLE_ACCEPTOR_KEYS, parameters);
final String binding = config.get(RemoteTransportDefinition.SOCKET_BINDING.getName()).asString();
bindings.add(binding);
// uses the parameters to pass the socket binding name that will be read in ActiveMQServerService.start()
parameters.put(RemoteTransportDefinition.SOCKET_BINDING.getName(), binding);
if(config.hasDefined(CommonAttributes.SSL_CONTEXT.getName())) {
String sslContextName = config.get(CommonAttributes.SSL_CONTEXT.getName()).asString();
sslContexts.put(acceptorName, sslContextName);
parameters.put(TransportConstants.SSL_CONTEXT_PROP_NAME, sslContextName);
parameters.put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
}
acceptors.put(acceptorName, new TransportConfiguration(NettyAcceptorFactory.class.getName(), parameters, acceptorName, extraParameters));
}
}
if (params.hasDefined(IN_VM_ACCEPTOR)) {
for (final Property property : params.get(IN_VM_ACCEPTOR).asPropertyList()) {
final String acceptorName = property.getName();
final ModelNode config = property.getValue();
final Map<String, Object> parameters = getParameters(context, config, ACCEPTOR_KEYS_MAP);
final Map<String, Object> extraParameters = getExtraParameters(IN_VM_ALLOWABLE_KEYS, parameters);
parameters.put(SERVER_ID_PROP_NAME, InVMTransportDefinition.SERVER_ID.resolveModelAttribute(context, config).asInt());
acceptors.put(acceptorName, new TransportConfiguration(InVMAcceptorFactory.class.getName(), parameters, acceptorName, extraParameters));
}
}
if (params.hasDefined(HTTP_ACCEPTOR)) {
for (final Property property : params.get(HTTP_ACCEPTOR).asPropertyList()) {
final String acceptorName = property.getName();
final ModelNode config = property.getValue();
final Map<String, Object> parameters = getParameters(context, config, ACCEPTOR_KEYS_MAP);
final Map<String, Object> extraParameters = getExtraParameters(TransportConstants.ALLOWABLE_ACCEPTOR_KEYS, parameters);
parameters.put(TransportConstants.HTTP_UPGRADE_ENABLED_PROP_NAME, true);
if(config.hasDefined(CommonAttributes.SSL_CONTEXT.getName())) {
String sslContextName = config.get(CommonAttributes.SSL_CONTEXT.getName()).asString();
sslContexts.put(acceptorName, config.get(CommonAttributes.SSL_CONTEXT.getName()).asString());
parameters.put(TransportConstants.SSL_CONTEXT_PROP_NAME, sslContextName);
parameters.put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
}
acceptors.put(acceptorName, new TransportConfiguration(NettyAcceptorFactory.class.getName(), parameters, acceptorName, extraParameters));
}
}
configuration.setAcceptorConfigurations(new HashSet<>(acceptors.values()));
}
/**
* Extract extra parameters from the map of parameters.
* @param allowedKeys: the keys for allowed parameters.
* @param parameters all the parameters (allowed and extra).
* @return a Map of extra parameters (those that are not allowed).
*/
private static Map<String, Object> getExtraParameters(final Set<String> allowedKeys, final Map<String, Object> parameters) {
Map<String, Object> extraParameters = new HashMap<>();
for(Map.Entry<String, Object> parameter : parameters.entrySet()) {
if(!allowedKeys.contains(parameter.getKey())) {
extraParameters.put(parameter.getKey(), parameter.getValue());
}
}
for (String extraParam : extraParameters.keySet()) {
parameters.remove(extraParam);
}
return extraParameters;
}
/**
* Get the parameters.
*
* @param context the operation context
* @param config the transport configuration
* @param mapping Mapping betwen WildFly parameters (keys) and Artemis constants (values)
* @return the extracted parameters
* @throws OperationFailedException if an expression can not be resolved
*/
public static Map<String, Object> getParameters(final OperationContext context, final ModelNode config, final Map<String, String> mapping) throws OperationFailedException {
Map<String, String> fromModel = CommonAttributes.PARAMS.unwrap(context, config);
Map<String, Object> parameters = new HashMap<>();
for (Map.Entry<String, String> entry : fromModel.entrySet()) {
parameters.put(mapping.getOrDefault(entry.getKey(), entry.getKey()), entry.getValue());
}
return parameters;
}
/**
* Process the connector information.
*
* @param context the operation context
* @param configuration the ActiveMQ configuration
* @param params the detyped operation parameters
* @param bindings the referenced socket bindings
* @throws OperationFailedException
*/
static Map<String, TransportConfiguration> processConnectors(final OperationContext context, final String configServerName,
final ModelNode params, final Set<String> bindings, Map<String, String> sslContexts) throws OperationFailedException {
final Map<String, TransportConfiguration> connectors = new HashMap<String, TransportConfiguration>();
if (params.hasDefined(CONNECTOR)) {
for (final Property property : params.get(CONNECTOR).asPropertyList()) {
final String connectorName = property.getName();
final ModelNode config = property.getValue();
final Map<String, Object> parameters = getParameters(context, config, CONNECTORS_KEYS_MAP);
final Map<String, Object> extraParameters = getExtraParameters(TransportConstants.ALLOWABLE_CONNECTOR_KEYS, parameters);
ModelNode socketBinding = GenericTransportDefinition.SOCKET_BINDING.resolveModelAttribute(context, config);
if(config.hasDefined(CommonAttributes.SSL_CONTEXT.getName())) {
String sslContextName = config.get(CommonAttributes.SSL_CONTEXT.getName()).asString();
sslContexts.put(connectorName, sslContextName);
parameters.put(TransportConstants.SSL_CONTEXT_PROP_NAME, sslContextName);
parameters.put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
}
if (socketBinding.isDefined()) {
bindings.add(socketBinding.asString());
// uses the parameters to pass the socket binding name that will be read in ActiveMQServerService.start()
parameters.put(GenericTransportDefinition.SOCKET_BINDING.getName(), socketBinding.asString());
}
final String clazz = FACTORY_CLASS.resolveModelAttribute(context, config).asString();
connectors.put(connectorName, new TransportConfiguration(clazz, parameters, connectorName, extraParameters));
}
}
if (params.hasDefined(REMOTE_CONNECTOR)) {
for (final Property property : params.get(REMOTE_CONNECTOR).asPropertyList()) {
final String connectorName = property.getName();
final ModelNode config = property.getValue();
final Map<String, Object> parameters = getParameters(context, config, CONNECTORS_KEYS_MAP);
final Map<String, Object> extraParameters = getExtraParameters(TransportConstants.ALLOWABLE_CONNECTOR_KEYS, parameters);
final String binding = config.get(RemoteTransportDefinition.SOCKET_BINDING.getName()).asString();
bindings.add(binding);
// uses the parameters to pass the socket binding name that will be read in ActiveMQServerService.start()
parameters.put(RemoteTransportDefinition.SOCKET_BINDING.getName(), binding);
if(config.hasDefined(CommonAttributes.SSL_CONTEXT.getName())) {
String sslContextName = config.get(CommonAttributes.SSL_CONTEXT.getName()).asString();
sslContexts.put(connectorName, sslContextName);
parameters.put(TransportConstants.SSL_CONTEXT_PROP_NAME, sslContextName);
parameters.put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
}
connectors.put(connectorName, new TransportConfiguration(NettyConnectorFactory.class.getName(), parameters, connectorName, extraParameters));
}
}
if (params.hasDefined(IN_VM_CONNECTOR)) {
for (final Property property : params.get(IN_VM_CONNECTOR).asPropertyList()) {
final String connectorName = property.getName();
final ModelNode config = property.getValue();
final Map<String, Object> parameters = getParameters(context, config, CONNECTORS_KEYS_MAP);
final Map<String, Object> extraParameters = getExtraParameters(IN_VM_ALLOWABLE_KEYS, parameters);
parameters.put(CONNECTORS_KEYS_MAP.get(InVMTransportDefinition.SERVER_ID.getName()), InVMTransportDefinition.SERVER_ID.resolveModelAttribute(context, config).asInt());
connectors.put(connectorName, new TransportConfiguration(InVMConnectorFactory.class.getName(), parameters, connectorName, extraParameters));
}
}
if (params.hasDefined(HTTP_CONNECTOR)) {
for (final Property property : params.get(HTTP_CONNECTOR).asPropertyList()) {
final String connectorName = property.getName();
final ModelNode config = property.getValue();
final Map<String, Object> parameters = getParameters(context, config, CONNECTORS_KEYS_MAP);
final Map<String, Object> extraParameters = getExtraParameters(TransportConstants.ALLOWABLE_CONNECTOR_KEYS, parameters);
final String binding = HTTPConnectorDefinition.SOCKET_BINDING.resolveModelAttribute(context, config).asString();
bindings.add(binding);
// ARTEMIS-803 Artemis knows that is must not offset the HTTP port when it is used by colocated backups
parameters.put(TransportConstants.HTTP_UPGRADE_ENABLED_PROP_NAME, true);
parameters.put(TransportConstants.HTTP_UPGRADE_ENDPOINT_PROP_NAME, HTTPConnectorDefinition.ENDPOINT.resolveModelAttribute(context, config).asString());
// uses the parameters to pass the socket binding name that will be read in ActiveMQServerService.start()
parameters.put(HTTPConnectorDefinition.SOCKET_BINDING.getName(), binding);
ModelNode serverNameModelNode = HTTPConnectorDefinition.SERVER_NAME.resolveModelAttribute(context, config);
// use the name of this server if the server-name attribute is undefined
String serverName = serverNameModelNode.isDefined() ? serverNameModelNode.asString() : configServerName;
parameters.put(ACTIVEMQ_SERVER_NAME, serverName);
if (config.hasDefined(CommonAttributes.SSL_CONTEXT.getName())) {
String sslContextName = config.get(CommonAttributes.SSL_CONTEXT.getName()).asString();
sslContexts.put(connectorName, sslContextName);
parameters.put(TransportConstants.SSL_CONTEXT_PROP_NAME, sslContextName);
parameters.put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
}
connectors.put(connectorName, new TransportConfiguration(NettyConnectorFactory.class.getName(), parameters, connectorName, extraParameters));
}
}
return connectors;
}
public static TransportConfiguration[] processConnectors(final OperationContext context, final Collection<String> names,
Set<String> bindings, Set<String> sslContexts) throws OperationFailedException {
final List<TransportConfiguration> connectors = new ArrayList<>();
final PathAddress subsystemAddress = context.getCurrentAddress().getParent();
Resource subsystemResource = context.readResourceFromRoot(subsystemAddress, false);
for (String connectorName : names) {
if (subsystemResource.hasChild(PathElement.pathElement(CommonAttributes.CONNECTOR, connectorName))) {
final ModelNode config = context.readResourceFromRoot(subsystemAddress.append(PathElement.pathElement(CommonAttributes.CONNECTOR, connectorName)), true).getModel();
final Map<String, Object> parameters = getParameters(context, config, CONNECTORS_KEYS_MAP);
ModelNode socketBinding = GenericTransportDefinition.SOCKET_BINDING.resolveModelAttribute(context, config);
if (socketBinding.isDefined()) {
// uses the parameters to pass the socket binding name that will be read in ActiveMQServerService.start()
parameters.put(GenericTransportDefinition.SOCKET_BINDING.getName(), socketBinding.asString());
bindings.add(socketBinding.asString());
}
final String clazz = FACTORY_CLASS.resolveModelAttribute(context, config).asString();
if (config.hasDefined(CommonAttributes.SSL_CONTEXT.getName())) {
String sslContextName = config.get(CommonAttributes.SSL_CONTEXT.getName()).asString();
sslContexts.add(sslContextName);
parameters.put(TransportConstants.SSL_CONTEXT_PROP_NAME, sslContextName);
parameters.put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
}
connectors.add(new TransportConfiguration(clazz, parameters, connectorName));
}
if (subsystemResource.hasChild(PathElement.pathElement(CommonAttributes.REMOTE_CONNECTOR, connectorName))) {
final ModelNode config = context.readResourceFromRoot(subsystemAddress.append(PathElement.pathElement(CommonAttributes.REMOTE_CONNECTOR, connectorName)), true).getModel();
final Map<String, Object> parameters = getParameters(context, config, CONNECTORS_KEYS_MAP);
ModelNode socketBinding = GenericTransportDefinition.SOCKET_BINDING.resolveModelAttribute(context, config);
if (socketBinding.isDefined()) {
// uses the parameters to pass the socket binding name that will be read in ActiveMQServerService.start()
parameters.put(GenericTransportDefinition.SOCKET_BINDING.getName(), socketBinding.asString());
bindings.add(socketBinding.asString());
}
if(!config.hasDefined(FACTORY_CLASS.getName())) {
config.get(FACTORY_CLASS.getName()).set(NettyConnectorFactory.class.getName());
}
final String clazz = FACTORY_CLASS.resolveModelAttribute(context, config).asString();
if (config.hasDefined(CommonAttributes.SSL_CONTEXT.getName())) {
String sslContextName = config.get(CommonAttributes.SSL_CONTEXT.getName()).asString();
sslContexts.add(sslContextName);
parameters.put(TransportConstants.SSL_CONTEXT_PROP_NAME, sslContextName);
parameters.put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
}
connectors.add(new TransportConfiguration(clazz, parameters, connectorName));
}
if (subsystemResource.hasChild(PathElement.pathElement(CommonAttributes.IN_VM_CONNECTOR, connectorName))) {
final ModelNode config = context.readResourceFromRoot(subsystemAddress.append(PathElement.pathElement(CommonAttributes.IN_VM_CONNECTOR, connectorName)), true).getModel();
final Map<String, Object> parameters = getParameters(context, config, CONNECTORS_KEYS_MAP);
parameters.put(CONNECTORS_KEYS_MAP.get(InVMTransportDefinition.SERVER_ID.getName()), InVMTransportDefinition.SERVER_ID.resolveModelAttribute(context, config).asInt());
connectors.add(new TransportConfiguration(InVMConnectorFactory.class.getName(), parameters, connectorName));
}
if (subsystemResource.hasChild(PathElement.pathElement(CommonAttributes.HTTP_CONNECTOR, connectorName))) {
final ModelNode config = context.readResourceFromRoot(subsystemAddress.append(PathElement.pathElement(CommonAttributes.HTTP_CONNECTOR, connectorName)), true).getModel();
final Map<String, Object> parameters = getParameters(context, config, CONNECTORS_KEYS_MAP);
final String binding = HTTPConnectorDefinition.SOCKET_BINDING.resolveModelAttribute(context, config).asString();
// ARTEMIS-803 Artemis knows that is must not offset the HTTP port when it is used by colocated backups
parameters.put(TransportConstants.HTTP_UPGRADE_ENABLED_PROP_NAME, true);
parameters.put(TransportConstants.HTTP_UPGRADE_ENDPOINT_PROP_NAME, HTTPConnectorDefinition.ENDPOINT.resolveModelAttribute(context, config).asString());
// uses the parameters to pass the socket binding name that will be read in ActiveMQServerService.start()
parameters.put(HTTPConnectorDefinition.SOCKET_BINDING.getName(), binding);
bindings.add(binding);
ModelNode serverNameModelNode = HTTPConnectorDefinition.SERVER_NAME.resolveModelAttribute(context, config);
if( serverNameModelNode.isDefined()) {
parameters.put(ACTIVEMQ_SERVER_NAME, serverNameModelNode.asString());
}
if (config.hasDefined(CommonAttributes.SSL_CONTEXT.getName())) {
String sslContextName = config.get(CommonAttributes.SSL_CONTEXT.getName()).asString();
sslContexts.add(sslContextName);
parameters.put(TransportConstants.SSL_CONTEXT_PROP_NAME, sslContextName);
parameters.put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
}
connectors.add(new TransportConfiguration(NettyConnectorFactory.class.getName(), parameters, connectorName));
}
}
return connectors.toArray(new TransportConfiguration[connectors.size()]);
}
public static Map<String, Boolean> listOutBoundSocketBinding(OperationContext context, Collection<String> names) throws OperationFailedException {
Map<String, Boolean> result = new HashMap<>();
Resource root = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false);
Set<String> groups = root.getChildrenNames(ModelDescriptionConstants.SOCKET_BINDING_GROUP);
for (String groupName : groups) {
Resource socketBindingGroup = context.readResourceFromRoot(PathAddress.pathAddress(ModelDescriptionConstants.SOCKET_BINDING_GROUP, groupName));
for (String name : names) {
if (socketBindingGroup.getChildrenNames(ModelDescriptionConstants.SOCKET_BINDING).contains(name)) {
result.put(name, Boolean.FALSE);
} else if (socketBindingGroup.getChildrenNames(ModelDescriptionConstants.LOCAL_DESTINATION_OUTBOUND_SOCKET_BINDING).contains(name)
|| socketBindingGroup.getChildrenNames(ModelDescriptionConstants.REMOTE_DESTINATION_OUTBOUND_SOCKET_BINDING).contains(name)) {
result.put(name, Boolean.TRUE);
}
}
}
if (result.size() != names.size()) {
for(String name : names) {
if(!result.containsKey(name)) {
throw MessagingLogger.ROOT_LOGGER.noSocketBinding(name);
}
}
}
return result;
}
public static void processConnectorBindings(Collection<TransportConfiguration> connectors,
Map<String, Supplier<SocketBinding>> socketBindings,
Map<String, Supplier<OutboundSocketBinding>> outboundSocketBindings) throws StartException {
if (connectors != null) {
for (TransportConfiguration tc : connectors) {
// If there is a socket binding set the HOST/PORT values
Object socketRef = tc.getParams().remove(SOCKET_REF);
if (socketRef != null) {
String name = socketRef.toString();
String host;
int port;
if (!outboundSocketBindings.containsKey(name)) {
final SocketBinding socketBinding = socketBindings.get(name).get();
if (socketBinding == null) {
throw MessagingLogger.ROOT_LOGGER.failedToFindConnectorSocketBinding(tc.getName());
}
if (socketBinding.getClientMappings() != null && !socketBinding.getClientMappings().isEmpty()) {
// At the moment ActiveMQ doesn't allow to select mapping based on client's network.
// Instead the first client-mapping element will always be used - see WFLY-8432
ClientMapping clientMapping = socketBinding.getClientMappings().get(0);
host = NetworkUtils.canonize(clientMapping.getDestinationAddress());
port = clientMapping.getDestinationPort();
if (socketBinding.getClientMappings().size() > 1) {
MessagingLogger.ROOT_LOGGER.multipleClientMappingsFound(socketBinding.getName(), tc.getName(), host, port);
}
} else {
InetSocketAddress sa = socketBinding.getSocketAddress();
port = sa.getPort();
// resolve the host name of the address only if a loopback address has been set
if (sa.getAddress().isLoopbackAddress()) {
host = NetworkUtils.canonize(sa.getAddress().getHostName());
} else {
host = NetworkUtils.canonize(sa.getAddress().getHostAddress());
}
}
} else {
OutboundSocketBinding binding = outboundSocketBindings.get(name).get();
port = binding.getDestinationPort();
host = NetworkUtils.canonize(binding.getUnresolvedDestinationAddress());
if (binding.getSourceAddress() != null) {
tc.getParams().put(TransportConstants.LOCAL_ADDRESS_PROP_NAME,
NetworkUtils.canonize(binding.getSourceAddress().getHostAddress()));
}
if (binding.getSourcePort() != null) {
// Use absolute port to account for source port offset/fixation
tc.getParams().put(TransportConstants.LOCAL_PORT_PROP_NAME, binding.getAbsoluteSourcePort());
}
}
tc.getParams().put(HOST, host);
tc.getParams().put(PORT, port);
}
}
}
}
}
| 41,304
| 64.356013
| 224
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/ClusterConnectionDefinition.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.DOUBLE;
import static org.jboss.dmr.ModelType.INT;
import static org.jboss.dmr.ModelType.LONG;
import static org.jboss.dmr.ModelType.OBJECT;
import static org.jboss.dmr.ModelType.STRING;
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.PersistentResourceDefinition;
import org.jboss.as.controller.PrimitiveListAttributeDefinition;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleOperationDefinition;
import org.jboss.as.controller.SimpleOperationDefinitionBuilder;
import org.jboss.as.controller.StringListAttributeDefinition;
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.dmr.ModelNode;
/**
* Cluster connection resource definition
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat Inc.
*/
public class ClusterConnectionDefinition extends PersistentResourceDefinition {
public static final String GET_NODES = "get-nodes";
public static final SimpleAttributeDefinition ADDRESS = create("cluster-connection-address", STRING)
.setXmlName(CommonAttributes.ADDRESS)
.setDefaultValue(null)
// empty string is allowed to route *any* address to the cluster
.setValidator(new StringLengthValidator(0))
.setAllowExpression(true)
.setRestartAllServices()
.build();
public static final SimpleAttributeDefinition ALLOW_DIRECT_CONNECTIONS_ONLY = create("allow-direct-connections-only", BOOLEAN)
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setAllowExpression(true)
.setRequires(STATIC_CONNECTORS)
.setRestartAllServices()
.build();
public static final SimpleAttributeDefinition CALL_FAILOVER_TIMEOUT = create(CommonAttributes.CALL_FAILOVER_TIMEOUT)
// cluster connection will wait forever during failover for a non-blocking call
.setDefaultValue(new ModelNode(-1L))
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultClusterFailureCheckPeriod
*/
public static final SimpleAttributeDefinition CHECK_PERIOD = create("check-period", LONG)
.setDefaultValue(new ModelNode(30000L))
.setRequired(false)
.setAllowExpression(true)
.setMeasurementUnit(MILLISECONDS)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultClusterConnectionTtl
*/
public static final SimpleAttributeDefinition CONNECTION_TTL = create("connection-ttl", LONG)
.setDefaultValue(new ModelNode(60000L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.setValidator(InfiniteOrPositiveValidators.LONG_INSTANCE)
.setRestartAllServices()
.build();
public static final SimpleAttributeDefinition CONNECTOR_NAME = create("connector-name", STRING)
.setRestartAllServices()
.build();
public static final PrimitiveListAttributeDefinition CONNECTOR_REFS = new StringListAttributeDefinition.Builder(STATIC_CONNECTORS)
.setRequired(true)
.setElementValidator(new StringLengthValidator(1))
.setAttributeParser(AttributeParser.STRING_LIST)
.setAttributeMarshaller(AttributeMarshaller.STRING_LIST)
.setAlternatives(CommonAttributes.DISCOVERY_GROUP)
.setRestartAllServices()
.build();
public static final SimpleAttributeDefinition DISCOVERY_GROUP_NAME = create(CommonAttributes.DISCOVERY_GROUP, STRING)
.setRequired(true)
.setAlternatives(CONNECTOR_REFS.getName())
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultClusterMessageLoadBalancingType
*/
// FIXME WFLY-4587 forward-when-no-consumers == true ? STRICT : ON_DEMAND
public static final SimpleAttributeDefinition MESSAGE_LOAD_BALANCING_TYPE = create("message-load-balancing-type", STRING)
.setDefaultValue(new ModelNode(MessageLoadBalancingType.ON_DEMAND.toString()))
.setValidator(EnumValidator.create(MessageLoadBalancingType.class))
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultClusterInitialConnectAttempts
*/
public static final SimpleAttributeDefinition INITIAL_CONNECT_ATTEMPTS = create("initial-connect-attempts", INT)
.setDefaultValue(new ModelNode(-1))
.setRequired(false)
.setAllowExpression(true)
.setCorrector(InfiniteOrPositiveValidators.NEGATIVE_VALUE_CORRECTOR)
.setValidator(InfiniteOrPositiveValidators.INT_INSTANCE)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultClusterMaxHops
*/
public static final SimpleAttributeDefinition MAX_HOPS = create("max-hops", INT)
.setDefaultValue(new ModelNode(1))
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultClusterMaxRetryInterval
*/
public static final SimpleAttributeDefinition MAX_RETRY_INTERVAL = create("max-retry-interval", LONG)
.setDefaultValue(new ModelNode(2000L))
.setRequired(false)
.setAllowExpression(true)
.setMeasurementUnit(MILLISECONDS)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultClusterNotificationAttempts
*/
public static final SimpleAttributeDefinition NOTIFICATION_ATTEMPTS = create("notification-attempts",INT)
.setDefaultValue(new ModelNode(2))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultClusterNotificationInterval
*/
public static final SimpleAttributeDefinition NOTIFICATION_INTERVAL = create("notification-interval",LONG)
.setDefaultValue(new ModelNode(1000L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.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#getDefaultClusterRetryInterval
*/
public static final SimpleAttributeDefinition RETRY_INTERVAL = create("retry-interval", LONG)
.setDefaultValue(new ModelNode(500L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultClusterReconnectAttempts
*/
public static final SimpleAttributeDefinition RECONNECT_ATTEMPTS = create("reconnect-attempts", INT)
.setDefaultValue(new ModelNode(-1))
.setRequired(false)
.setAllowExpression(true)
.setCorrector(InfiniteOrPositiveValidators.NEGATIVE_VALUE_CORRECTOR)
.setValidator(InfiniteOrPositiveValidators.INT_INSTANCE)
.setRestartAllServices()
.build();
/**
* @see ActiveMQDefaultConfiguration#getDefaultClusterRetryIntervalMultiplier
*/
public static final SimpleAttributeDefinition RETRY_INTERVAL_MULTIPLIER = create("retry-interval-multiplier", DOUBLE)
.setDefaultValue(new ModelNode(1.0d))
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
public static final SimpleAttributeDefinition USE_DUPLICATE_DETECTION = create("use-duplicate-detection", BOOLEAN)
.setDefaultValue(ModelNode.TRUE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
public static final AttributeDefinition[] ATTRIBUTES = {
ADDRESS, CONNECTOR_NAME,
CHECK_PERIOD,
CONNECTION_TTL,
CommonAttributes.MIN_LARGE_MESSAGE_SIZE,
CommonAttributes.CALL_TIMEOUT,
CALL_FAILOVER_TIMEOUT,
RETRY_INTERVAL, RETRY_INTERVAL_MULTIPLIER, MAX_RETRY_INTERVAL,
INITIAL_CONNECT_ATTEMPTS,
RECONNECT_ATTEMPTS, USE_DUPLICATE_DETECTION,
MESSAGE_LOAD_BALANCING_TYPE, MAX_HOPS,
CommonAttributes.BRIDGE_CONFIRMATION_WINDOW_SIZE,
PRODUCER_WINDOW_SIZE,
NOTIFICATION_ATTEMPTS,
NOTIFICATION_INTERVAL,
CONNECTOR_REFS,
ALLOW_DIRECT_CONNECTIONS_ONLY,
DISCOVERY_GROUP_NAME,
};
public static final SimpleAttributeDefinition NODE_ID = create("node-id", STRING)
.setStorageRuntime()
.build();
public static final SimpleAttributeDefinition TOPOLOGY = create("topology", STRING)
.setStorageRuntime()
.build();
public static final AttributeDefinition[] READONLY_ATTRIBUTES = {
TOPOLOGY,
NODE_ID
};
private final boolean registerRuntimeOnly;
ClusterConnectionDefinition(boolean registerRuntimeOnly) {
super(MessagingExtension.CLUSTER_CONNECTION_PATH,
MessagingExtension.getResourceDescriptionResolver(CommonAttributes.CLUSTER_CONNECTION),
ClusterConnectionAdd.INSTANCE,
ClusterConnectionRemove.INSTANCE);
this.registerRuntimeOnly = registerRuntimeOnly;
}
@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(ATTRIBUTES);
}
@Override
public void registerAttributes(ManagementResourceRegistration registry) {
ReloadRequiredWriteAttributeHandler reloadRequiredWriteAttributeHandler = new ReloadRequiredWriteAttributeHandler(ATTRIBUTES);
for (AttributeDefinition attr : ATTRIBUTES) {
if (!attr.getFlags().contains(AttributeAccess.Flag.STORAGE_RUNTIME)) {
registry.registerReadWriteAttribute(attr, null, reloadRequiredWriteAttributeHandler);
}
}
ClusterConnectionControlHandler.INSTANCE.registerAttributes(registry);
for (AttributeDefinition attr : READONLY_ATTRIBUTES) {
registry.registerReadOnlyAttribute(attr, ClusterConnectionControlHandler.INSTANCE);
}
}
@Override
public void registerOperations(ManagementResourceRegistration registry) {
super.registerOperations(registry);
if (registerRuntimeOnly) {
ClusterConnectionControlHandler.INSTANCE.registerOperations(registry, getResourceDescriptionResolver());
SimpleOperationDefinition getNodesDef = new SimpleOperationDefinitionBuilder(ClusterConnectionDefinition.GET_NODES, getResourceDescriptionResolver())
.setReadOnly()
.setRuntimeOnly()
.setReplyType(OBJECT)
.setReplyValueType(STRING)
.build();
registry.registerOperationHandler(getNodesDef, ClusterConnectionControlHandler.INSTANCE);
}
}
private enum MessageLoadBalancingType {
OFF, STRICT, ON_DEMAND;
}
}
| 14,193
| 40.994083
| 161
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/PathDefinition.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.SimpleAttributeDefinitionBuilder.create;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.BINDINGS_DIRECTORY;
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.PAGING_DIRECTORY;
import java.io.File;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.jboss.as.controller.AbstractRemoveStepHandler;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.ExtensionContext;
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.PathElement;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
import org.jboss.as.controller.SimpleAttributeDefinition;
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.controller.services.path.PathResourceDefinition;
import org.jboss.as.controller.services.path.ResolvePathHandler;
import org.jboss.as.server.ServerEnvironment;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
/**
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2014 Red Hat inc.
*/
public class PathDefinition extends PersistentResourceDefinition {
static final String DEFAULT_RELATIVE_TO = ServerEnvironment.SERVER_DATA_DIR;
// base attribute for the 4 messaging path subresources.
// each one define a different default values. Their respective attributes are accessed through the PATHS map.
private static final SimpleAttributeDefinition PATH_BASE = create(PathResourceDefinition.PATH)
.setAllowExpression(true)
.setRequired(false)
.setRestartAllServices()
.build();
public static final SimpleAttributeDefinition RELATIVE_TO = create(PathResourceDefinition.RELATIVE_TO)
.setDefaultValue(new ModelNode(DEFAULT_RELATIVE_TO))
.setRequired(false)
.setRestartAllServices()
.build();
protected static final Map<String, SimpleAttributeDefinition> PATHS = new HashMap<String, SimpleAttributeDefinition>();
private static final String DEFAULT_PATH = "activemq";
static final String DEFAULT_BINDINGS_DIR = DEFAULT_PATH + File.separator + "bindings";
static final String DEFAULT_JOURNAL_DIR = DEFAULT_PATH + File.separator + "journal";
static final String DEFAULT_LARGE_MESSAGE_DIR = DEFAULT_PATH + File.separator + "largemessages";
static final String DEFAULT_PAGING_DIR = DEFAULT_PATH + File.separator + "paging";
static {
PATHS.put(BINDINGS_DIRECTORY, create(PATH_BASE).setDefaultValue(new ModelNode(DEFAULT_BINDINGS_DIR)).build());
PATHS.put(JOURNAL_DIRECTORY, create(PATH_BASE).setDefaultValue(new ModelNode(DEFAULT_JOURNAL_DIR)).build());
PATHS.put(LARGE_MESSAGES_DIRECTORY, create(PATH_BASE).setDefaultValue(new ModelNode(DEFAULT_LARGE_MESSAGE_DIR)).build());
PATHS.put(PAGING_DIRECTORY, create(PATH_BASE).setDefaultValue(new ModelNode(DEFAULT_PAGING_DIR)).build());
}
static final OperationStepHandler PATH_ADD = new OperationStepHandler() {
@Override
public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException {
final Resource resource = context.createResource(PathAddress.EMPTY_ADDRESS);
final ModelNode model = resource.getModel();
final String path = PathAddress.pathAddress(operation.require(OP_ADDR)).getLastElement().getValue();
for (AttributeDefinition attribute : getAttributes(path)) {
attribute.validateAndSet(operation, model);
}
reloadRequiredStep(context);
}
};
static final OperationStepHandler PATH_REMOVE = new AbstractRemoveStepHandler() {
@Override
protected void performRemove(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
super.performRemove(context, operation, model);
reloadRequiredStep(context);
}
};
private final PathElement path;
static final AttributeDefinition[] getAttributes(final String path) {
return new AttributeDefinition[] { PATHS.get(path), RELATIVE_TO };
}
PathDefinition(PathElement path) {
super(path,
MessagingExtension.getResourceDescriptionResolver(ModelDescriptionConstants.PATH),
PATH_ADD,
PATH_REMOVE);
this.path = path;
}
@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(getAttributes(getPathElement().getValue()));
}
@Override
public void registerAttributes(ManagementResourceRegistration registry) {
AttributeDefinition[] attributes = getAttributes(path.getValue());
OperationStepHandler attributeHandler = new ReloadRequiredWriteAttributeHandler(attributes);
for (AttributeDefinition attribute : attributes) {
registry.registerReadWriteAttribute(attribute, null, attributeHandler);
}
}
// TODO add @Override once the WFCORE version with this method is integrated
public int getMinOccurs() {
return 1;
}
protected static void registerResolveOperationHandler(ExtensionContext context, ManagementResourceRegistration registry) {
if (context.getProcessType().isServer()) {
final ResolvePathHandler resolvePathHandler = ResolvePathHandler.Builder.of(context.getPathManager())
.setPathAttribute(PATHS.get(registry.getPathAddress().getLastElement().getValue()))
.setRelativeToAttribute(PathDefinition.RELATIVE_TO)
.setCheckAbsolutePath(true)
.build();
registry.registerOperationHandler(resolvePathHandler.getOperationDefinition(), resolvePathHandler);
}
}
static void reloadRequiredStep(final OperationContext context) {
if(context.isNormalServer()) {
context.addStep(new OperationStepHandler() {
@Override
public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException {
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
final ServiceController<?> controller = context.getServiceRegistry(false).getService(serviceName);
OperationContext.RollbackHandler rh;
if(controller != null) {
context.reloadRequired();
rh = OperationContext.RollbackHandler.REVERT_RELOAD_REQUIRED_ROLLBACK_HANDLER;
} else {
rh = OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER;
}
context.completeStep(rh);
}
}, OperationContext.Stage.RUNTIME);
}
}
}
| 8,795
| 46.545946
| 168
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/ActiveMQResourceAdapter.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;
import java.security.AccessController;
import jakarta.resource.spi.work.ExecutionContext;
import jakarta.resource.spi.work.Work;
import jakarta.resource.spi.work.WorkException;
import jakarta.resource.spi.work.WorkListener;
import jakarta.resource.spi.work.WorkManager;
import org.apache.activemq.artemis.api.core.BroadcastEndpointFactory;
import org.apache.activemq.artemis.ra.ConnectionFactoryProperties;
import org.jboss.as.naming.context.NamespaceContextSelector;
import org.jboss.as.server.CurrentServiceContainer;
import org.jboss.msc.service.ServiceContainer;
import org.wildfly.extension.messaging.activemq.broadcast.CommandDispatcherBroadcastEndpointFactory;
import org.wildfly.extension.messaging.activemq.jms.ExternalPooledConnectionFactoryService;
import org.wildfly.extension.messaging.activemq.jms.JMSServices;
/**
* Custom resource adapter that returns an appropriate BroadcastEndpointFactory if discovery is configured using
* JGroups.
*
* @author Paul Ferraro
*/
public class ActiveMQResourceAdapter extends org.apache.activemq.artemis.ra.ActiveMQResourceAdapter {
private static final long serialVersionUID = 170278234232275756L;
public ActiveMQResourceAdapter() {
super();
this.setEnable1xPrefixes(true);
this.getProperties().setEnable1xPrefixes(true);
}
@Override
protected BroadcastEndpointFactory createBroadcastEndpointFactory(ConnectionFactoryProperties overrideProperties) {
String clusterName = overrideProperties.getJgroupsChannelName() != null ? overrideProperties.getJgroupsChannelName() : getJgroupsChannelName();
if (clusterName != null) {
String channelRefName = this.getProperties().getJgroupsChannelRefName();
String[] split = channelRefName.split("/");
String serverName = split[0];
String key = split[1];
String pcf = null;
if (key.indexOf(':') >= 0) {
split = key.split(":");
pcf = split[0];
key = split[1];
}
if (serverName != null && !serverName.isEmpty()) {
ActiveMQServerService service = (ActiveMQServerService) currentServiceContainer().getService(MessagingServices.getActiveMQServiceName(serverName)).getService();
return new CommandDispatcherBroadcastEndpointFactory(service.getCommandDispatcherFactory(key), clusterName);
}
assert pcf != null;
ExternalPooledConnectionFactoryService service = (ExternalPooledConnectionFactoryService) currentServiceContainer().getService(JMSServices.getPooledConnectionFactoryBaseServiceName(MessagingServices.getActiveMQServiceName()).append(pcf)).getService();
return new CommandDispatcherBroadcastEndpointFactory(service.getCommandDispatcherFactory(key), clusterName);
}
return super.createBroadcastEndpointFactory(overrideProperties);
}
private static ServiceContainer currentServiceContainer() {
return (System.getSecurityManager() == null) ? CurrentServiceContainer.getServiceContainer() : AccessController.doPrivileged(CurrentServiceContainer.GET_ACTION);
}
@Override
public WorkManager getWorkManager() {
return new NamingWorkManager(super.getWorkManager());
}
private class NamingWorkManager implements WorkManager {
private final WorkManager delegate;
private NamingWorkManager(WorkManager delegate) {
this.delegate = delegate;
}
@Override
public void doWork(Work work) throws WorkException {
delegate.doWork(wrapWork(work));
}
@Override
public void doWork(Work work, long startTimeout, ExecutionContext execContext, WorkListener workListener) throws WorkException {
delegate.doWork(wrapWork(work), startTimeout, execContext, workListener);
}
@Override
public long startWork(Work work) throws WorkException {
return delegate.startWork(wrapWork(work));
}
@Override
public long startWork(Work work, long startTimeout, ExecutionContext execContext, WorkListener workListener) throws WorkException {
return delegate.startWork(wrapWork(work), startTimeout, execContext, workListener);
}
@Override
public void scheduleWork(Work work) throws WorkException {
delegate.scheduleWork(wrapWork(work));
}
@Override
public void scheduleWork(Work work, long startTimeout, ExecutionContext execContext, WorkListener workListener) throws WorkException {
delegate.scheduleWork(wrapWork(work), startTimeout, execContext, workListener);
}
private Work wrapWork(Work work) {
return new WorkWrapper(NamespaceContextSelector.getCurrentSelector(), work);
}
}
private class WorkWrapper implements Work {
private final Work delegate;
private final NamespaceContextSelector selector;
private WorkWrapper(NamespaceContextSelector selector, Work work) {
this.selector = selector;
this.delegate = work;
}
@Override
public void release() {
NamespaceContextSelector.pushCurrentSelector(selector);
try {
delegate.release();
} finally {
NamespaceContextSelector.popCurrentSelector();
}
}
@Override
public void run() {
NamespaceContextSelector.pushCurrentSelector(selector);
try {
delegate.run();
} finally {
NamespaceContextSelector.popCurrentSelector();
}
}
}
}
| 6,822
| 39.856287
| 263
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/ActiveMQServerControlHandler.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.READ_ATTRIBUTE_OPERATION;
import static org.jboss.dmr.ModelType.BOOLEAN;
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.ManagementUtil.reportRoles;
import static org.wildfly.extension.messaging.activemq.ManagementUtil.reportRolesAsJSON;
import static org.wildfly.extension.messaging.activemq.OperationDefinitionHelper.createNonEmptyStringAttribute;
import static org.wildfly.extension.messaging.activemq.OperationDefinitionHelper.runtimeOnlyOperation;
import static org.wildfly.extension.messaging.activemq.OperationDefinitionHelper.runtimeReadOnlyOperation;
import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl;
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.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.RunningMode;
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.operations.validation.StringAllowedValuesValidator;
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.logging.MessagingLogger;
/**
* Handles operations and attribute reads supported by a ActiveMQ {@link org.apache.activemq.api.core.management.ActiveMQServerControl}.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class ActiveMQServerControlHandler extends AbstractRuntimeOnlyHandler {
private static final String[] ALLOWED_RUNTIME_JOURNAL_TYPE = {"ASYNCIO", "NIO", "DATABASE", "NONE"};
static final ActiveMQServerControlHandler INSTANCE = new ActiveMQServerControlHandler();
public static final AttributeDefinition ACTIVE = create("active", BOOLEAN)
.setStorageRuntime()
.build();
public static final AttributeDefinition STARTED = new SimpleAttributeDefinitionBuilder(CommonAttributes.STARTED, ModelType.BOOLEAN,
false).setStorageRuntime().build();
public static final AttributeDefinition RUNTIME_JOURNAL_TYPE = create("runtime-journal-type", STRING)
.setStorageRuntime()
.setValidator(new StringAllowedValuesValidator(ALLOWED_RUNTIME_JOURNAL_TYPE))
.build();
public static final AttributeDefinition VERSION = new SimpleAttributeDefinitionBuilder(CommonAttributes.VERSION, ModelType.STRING,
true).setStorageRuntime().build();
private static final AttributeDefinition[] ATTRIBUTES = { STARTED, VERSION, ACTIVE, RUNTIME_JOURNAL_TYPE};
public static final String GET_CONNECTORS_AS_JSON = "get-connectors-as-json";
// public static final String ENABLE_MESSAGE_COUNTERS = "enable-message-counters";
// public static final String DISABLE_MESSAGE_COUNTERS = "disable-message-counters";
public static final String RESET_ALL_MESSAGE_COUNTERS = "reset-all-message-counters";
public static final String RESET_ALL_MESSAGE_COUNTER_HISTORIES = "reset-all-message-counter-histories";
public static final String LIST_PREPARED_TRANSACTIONS = "list-prepared-transactions";
public static final String LIST_PREPARED_TRANSACTION_DETAILS_AS_JSON = "list-prepared-transaction-details-as-json";
public static final String LIST_PREPARED_TRANSACTION_DETAILS_AS_HTML = "list-prepared-transaction-details-as-html";
public static final String LIST_HEURISTIC_COMMITTED_TRANSACTIONS = "list-heuristic-committed-transactions";
public static final String LIST_HEURISTIC_ROLLED_BACK_TRANSACTIONS = "list-heuristic-rolled-back-transactions";
public static final String COMMIT_PREPARED_TRANSACTION = "commit-prepared-transaction";
public static final String ROLLBACK_PREPARED_TRANSACTION = "rollback-prepared-transaction";
public static final String LIST_REMOTE_ADDRESSES = "list-remote-addresses";
public static final String CLOSE_CONNECTIONS_FOR_ADDRESS = "close-connections-for-address";
public static final String CLOSE_CONNECTIONS_FOR_USER = "close-connections-for-user";
public static final String CLOSE_CONSUMER_CONNECTIONS_FOR_ADDRESS= "close-consumer-connections-for-address";
public static final String LIST_CONNECTION_IDS= "list-connection-ids";
public static final String LIST_PRODUCERS_INFO_AS_JSON = "list-producers-info-as-json";
public static final String LIST_SESSIONS = "list-sessions";
public static final String GET_ROLES = "get-roles";
// we keep the operation for backwards compatibility but it duplicates the "get-roles" operation
// (except it returns a String instead of a List)
@Deprecated
public static final String GET_ROLES_AS_JSON = "get-roles-as-json";
public static final String GET_ADDRESS_SETTINGS_AS_JSON = "get-address-settings-as-json";
public static final String FORCE_FAILOVER = "force-failover";
public static final AttributeDefinition TRANSACTION_AS_BASE_64 = createNonEmptyStringAttribute("transaction-as-base-64");
public static final AttributeDefinition ADDRESS_MATCH = createNonEmptyStringAttribute("address-match");
public static final AttributeDefinition USER = createNonEmptyStringAttribute("user");
public static final AttributeDefinition CONNECTION_ID = createNonEmptyStringAttribute("connection-id");
public static final AttributeDefinition REQUIRED_IP_ADDRESS = createNonEmptyStringAttribute("ip-address");
public static final AttributeDefinition OPTIONAL_IP_ADDRESS = SimpleAttributeDefinitionBuilder.create("ip-address", ModelType.STRING)
.setRequired(false)
.setValidator(new StringLengthValidator(1, Integer.MAX_VALUE, true, false))
.build();
private ActiveMQServerControlHandler() {
}
@Override
protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
final String operationName = operation.require(OP).asString();
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
if (READ_ATTRIBUTE_OPERATION.equals(operationName)) {
ActiveMQServer server = null;
if (context.getRunningMode() == RunningMode.NORMAL) {
ServiceController<?> service = context.getServiceRegistry(false).getService(serviceName);
if (service == null || service.getState() != ServiceController.State.UP) {
throw MessagingLogger.ROOT_LOGGER.activeMQServerNotInstalled(serviceName.getSimpleName());
}
server = ActiveMQServer.class.cast(service.getValue());
}
handleReadAttribute(context, operation, server);
return;
}
if (rollbackOperationIfServerNotActive(context, operation)) {
return;
}
final ActiveMQServerControl serverControl = getServerControl(context, operation);
try {
if (GET_CONNECTORS_AS_JSON.equals(operationName)) {
String json = serverControl.getConnectorsAsJSON();
context.getResult().set(json);
} else if (RESET_ALL_MESSAGE_COUNTERS.equals(operationName)) {
serverControl.resetAllMessageCounters();
context.getResult();
} else if (RESET_ALL_MESSAGE_COUNTER_HISTORIES.equals(operationName)) {
serverControl.resetAllMessageCounterHistories();
context.getResult();
} else if (LIST_PREPARED_TRANSACTIONS.equals(operationName)) {
String[] list = serverControl.listPreparedTransactions();
reportListOfStrings(context, list);
} else if (LIST_PREPARED_TRANSACTION_DETAILS_AS_JSON.equals(operationName)) {
String json = serverControl.listPreparedTransactionDetailsAsJSON();
context.getResult().set(json);
} else if (LIST_PREPARED_TRANSACTION_DETAILS_AS_HTML.equals(operationName)) {
String html = serverControl.listPreparedTransactionDetailsAsHTML();
context.getResult().set(html);
} else if (LIST_HEURISTIC_COMMITTED_TRANSACTIONS.equals(operationName)) {
String[] list = serverControl.listHeuristicCommittedTransactions();
reportListOfStrings(context, list);
} else if (LIST_HEURISTIC_ROLLED_BACK_TRANSACTIONS.equals(operationName)) {
String[] list = serverControl.listHeuristicRolledBackTransactions();
reportListOfStrings(context, list);
} else if (COMMIT_PREPARED_TRANSACTION.equals(operationName)) {
String txId = TRANSACTION_AS_BASE_64.resolveModelAttribute(context, operation).asString();
boolean committed = serverControl.commitPreparedTransaction(txId);
context.getResult().set(committed);
} else if (ROLLBACK_PREPARED_TRANSACTION.equals(operationName)) {
String txId = TRANSACTION_AS_BASE_64.resolveModelAttribute(context, operation).asString();
boolean committed = serverControl.rollbackPreparedTransaction(txId);
context.getResult().set(committed);
} else if (LIST_REMOTE_ADDRESSES.equals(operationName)) {
ModelNode address = OPTIONAL_IP_ADDRESS.resolveModelAttribute(context, operation);
String[] list = address.isDefined() ? serverControl.listRemoteAddresses(address.asString()) : serverControl.listRemoteAddresses();
reportListOfStrings(context, list);
} else if (CLOSE_CONNECTIONS_FOR_ADDRESS.equals(operationName)) {
String address = REQUIRED_IP_ADDRESS.resolveModelAttribute(context, operation).asString();
boolean closed = serverControl.closeConnectionsForAddress(address);
context.getResult().set(closed);
} else if (CLOSE_CONNECTIONS_FOR_USER.equals(operationName)) {
String user = USER.resolveModelAttribute(context, operation).asString();
boolean closed = serverControl.closeConnectionsForUser(user);
context.getResult().set(closed);
} else if (CLOSE_CONSUMER_CONNECTIONS_FOR_ADDRESS.equals(operationName)) {
String address = ADDRESS_MATCH.resolveModelAttribute(context, operation).asString();
boolean closed = serverControl.closeConsumerConnectionsForAddress(address);
context.getResult().set(closed);
} else if (LIST_CONNECTION_IDS.equals(operationName)) {
String[] list = serverControl.listConnectionIDs();
reportListOfStrings(context, list);
} else if (LIST_PRODUCERS_INFO_AS_JSON.equals(operationName)) {
String json = serverControl.listProducersInfoAsJSON();
context.getResult().set(json);
} else if (LIST_SESSIONS.equals(operationName)) {
String connectionID = CONNECTION_ID.resolveModelAttribute(context, operation).asString();
String[] list = serverControl.listSessions(connectionID);
reportListOfStrings(context, list);
} else if (GET_ROLES.equals(operationName)) {
String addressMatch = ADDRESS_MATCH.resolveModelAttribute(context, operation).asString();
reportRoles(context, serverControl.getRoles(addressMatch));
} else if (GET_ROLES_AS_JSON.equals(operationName)) {
String addressMatch = ADDRESS_MATCH.resolveModelAttribute(context, operation).asString();
String json = serverControl.getRolesAsJSON(addressMatch);
reportRolesAsJSON(context, json);
} else if (GET_ADDRESS_SETTINGS_AS_JSON.equals(operationName)) {
String addressMatch = ADDRESS_MATCH.resolveModelAttribute(context, operation).asString();
String json = serverControl.getAddressSettingsAsJSON(addressMatch);
context.getResult().set(json);
} else if (FORCE_FAILOVER.equals(operationName)) {
serverControl.forceFailover();
context.getResult();
} else {
// Bug
throw MessagingLogger.ROOT_LOGGER.unsupportedOperation(operationName);
}
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
context.getFailureDescription().set(e.getLocalizedMessage());
}
}
public void registerAttributes(final ManagementResourceRegistration registry) {
for (AttributeDefinition attr : ATTRIBUTES) {
registry.registerReadOnlyAttribute(attr, this);
}
}
public void registerOperations(final ManagementResourceRegistration registry, ResourceDescriptionResolver resolver) {
registry.registerOperationHandler(runtimeReadOnlyOperation(GET_CONNECTORS_AS_JSON, resolver)
.setReplyType(STRING)
.build(),
this);
registry.registerOperationHandler(runtimeOnlyOperation(RESET_ALL_MESSAGE_COUNTERS, resolver)
.build(),
this);
registry.registerOperationHandler(runtimeOnlyOperation(RESET_ALL_MESSAGE_COUNTER_HISTORIES, resolver)
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_PREPARED_TRANSACTIONS, resolver)
.setReplyType(LIST)
.setReplyValueType(STRING)
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_PREPARED_TRANSACTION_DETAILS_AS_JSON, resolver)
.setReplyType(STRING)
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_PREPARED_TRANSACTION_DETAILS_AS_HTML, resolver)
.setReplyType(STRING)
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_HEURISTIC_COMMITTED_TRANSACTIONS, resolver)
.setReplyType(LIST)
.setReplyValueType(STRING)
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_HEURISTIC_ROLLED_BACK_TRANSACTIONS, resolver)
.setReplyType(LIST)
.setReplyValueType(STRING)
.build(),
this);
registry.registerOperationHandler(runtimeOnlyOperation(COMMIT_PREPARED_TRANSACTION, resolver)
.setParameters(TRANSACTION_AS_BASE_64)
.setReplyType(BOOLEAN)
.build(),
this);
registry.registerOperationHandler(runtimeOnlyOperation(ROLLBACK_PREPARED_TRANSACTION, resolver)
.setParameters(TRANSACTION_AS_BASE_64)
.setReplyType(BOOLEAN)
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_REMOTE_ADDRESSES, resolver)
.setParameters(OPTIONAL_IP_ADDRESS)
.setReplyType(LIST)
.setReplyValueType(STRING)
.build(),
this);
registry.registerOperationHandler(runtimeOnlyOperation(CLOSE_CONNECTIONS_FOR_ADDRESS, resolver)
.setParameters(REQUIRED_IP_ADDRESS)
.setReplyType(BOOLEAN)
.build(),
this);
registry.registerOperationHandler(runtimeOnlyOperation(CLOSE_CONNECTIONS_FOR_USER, resolver)
.setParameters(USER)
.setReplyType(BOOLEAN)
.build(),
this);
registry.registerOperationHandler(runtimeOnlyOperation(CLOSE_CONSUMER_CONNECTIONS_FOR_ADDRESS, resolver)
.setParameters(ADDRESS_MATCH)
.setReplyType(BOOLEAN)
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_CONNECTION_IDS, resolver)
.setReplyType(LIST)
.setReplyValueType(STRING)
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_PRODUCERS_INFO_AS_JSON, resolver)
.setReplyType(STRING)
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(LIST_SESSIONS, resolver)
.setParameters(CONNECTION_ID)
.setReplyType(LIST)
.setReplyValueType(STRING)
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(GET_ROLES_AS_JSON, resolver)
.setParameters(ADDRESS_MATCH)
.setReplyType(STRING)
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(GET_ADDRESS_SETTINGS_AS_JSON, resolver)
.setParameters(ADDRESS_MATCH)
.setReplyType(STRING)
.build(),
this);
registry.registerOperationHandler(runtimeOnlyOperation(FORCE_FAILOVER, resolver)
.build(),
this);
registry.registerOperationHandler(runtimeReadOnlyOperation(GET_ROLES, resolver)
.setParameters(ADDRESS_MATCH)
.setReplyType(LIST)
.setReplyParameters(SecurityRoleDefinition.NAME,
SecurityRoleDefinition.SEND,
SecurityRoleDefinition.CONSUME,
SecurityRoleDefinition.CREATE_DURABLE_QUEUE,
SecurityRoleDefinition.DELETE_DURABLE_QUEUE,
SecurityRoleDefinition.CREATE_NON_DURABLE_QUEUE,
SecurityRoleDefinition.DELETE_NON_DURABLE_QUEUE,
SecurityRoleDefinition.MANAGE,
SecurityRoleDefinition.BROWSE,
SecurityRoleDefinition.CREATE_ADDRESS,
SecurityRoleDefinition.DELETE_ADDRESS)
.build(),
this);
}
private void handleReadAttribute(OperationContext context, ModelNode operation, final ActiveMQServer server) throws OperationFailedException {
final String name = operation.require(ModelDescriptionConstants.NAME).asString();
if (STARTED.getName().equals(name)) {
boolean started = server != null ? server.isStarted() : false;
context.getResult().set(started);
} else if (VERSION.getName().equals(name)) {
if (server != null) {
String version = server.getVersion().getFullVersion();
context.getResult().set(version);
}
} else if (ACTIVE.getName().equals(name)) {
boolean active = server != null ? server.isActive() : false;
context.getResult().set(active);
} else if (RUNTIME_JOURNAL_TYPE.getName().equals(name)) {
if (server != null) {
// if the configured journal type is not supported (e.g. using ASYNCIO without having installed libaio),
// ActiveMQ will override its configuration to use the NIO journal type (that is available on any platform).
if (server.getConfiguration().isPersistenceEnabled()) {
if (server.getConfiguration().getStoreConfiguration() != null && "DATABASE".equals(server.getConfiguration().getStoreConfiguration().getStoreType().name())) {
context.getResult().set("DATABASE");
} else {
context.getResult().set(server.getConfiguration().getJournalType().toString());
}
} else {
context.getResult().set("NONE");
}
}
} else {
// Bug
throw MessagingLogger.ROOT_LOGGER.unsupportedAttribute(name);
}
}
private ActiveMQServerControl getServerControl(final OperationContext context, ModelNode operation) throws OperationFailedException {
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
ServiceController<?> service = context.getServiceRegistry(false).getService(serviceName);
if (service == null || service.getState() != ServiceController.State.UP) {
throw MessagingLogger.ROOT_LOGGER.activeMQServerNotInstalled(serviceName.getSimpleName());
}
ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
return server.getActiveMQServerControl();
}
}
| 22,843
| 56.11
| 178
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/AddressControlHandler.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;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_ATTRIBUTE_OPERATION;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.BINDING_NAMES;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.NUMBER_OF_BYTES_PER_PAGE;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.NUMBER_OF_PAGES;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.QUEUE_NAMES;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.ROLES_ATTR_NAME;
import static org.wildfly.extension.messaging.activemq.ActiveMQActivationService.ignoreOperationIfServerNotActive;
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.ManagementUtil.reportRoles;
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;
/**
* Handles operations and attribute reads supported by a ActiveMQ {@link org.apache.activemq.api.core.management.AddressControl}.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
class AddressControlHandler extends AbstractRuntimeOnlyHandler {
static final AddressControlHandler INSTANCE = new AddressControlHandler();
private AddressControlHandler() {
}
@Override
protected boolean resourceMustExist(OperationContext context, ModelNode operation) {
return false;
}
@Override
protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
if (rollbackOperationIfServerNotActive(context, operation)) {
return;
}
final String operationName = operation.require(OP).asString();
if (READ_ATTRIBUTE_OPERATION.equals(operationName)) {
handleReadAttribute(context, operation);
}
}
private void handleReadAttribute(OperationContext context, ModelNode operation) {
if (ignoreOperationIfServerNotActive(context, operation)) {
return;
}
final AddressControl addressControl = getAddressControl(context, operation);
if (addressControl == null) {
PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
throw ControllerLogger.ROOT_LOGGER.managementResourceNotFound(address);
}
final String name = operation.require(ModelDescriptionConstants.NAME).asString();
try {
if (ROLES_ATTR_NAME.equals(name)) {
reportRoles(context, addressControl.getRoles());
} else if (QUEUE_NAMES.equals(name)) {
String[] queues = addressControl.getQueueNames();
reportListOfStrings(context, queues);
} else if (NUMBER_OF_BYTES_PER_PAGE.equals(name)) {
long l = addressControl.getNumberOfBytesPerPage();
context.getResult().set(l);
} else if (NUMBER_OF_PAGES.equals(name)) {
context.getResult().set(addressControl.getNumberOfPages());
} else if (BINDING_NAMES.equals(name)) {
String[] bindings = addressControl.getBindingNames();
reportListOfStrings(context, bindings);
} else {
// Bug
throw MessagingLogger.ROOT_LOGGER.unsupportedAttribute(name);
}
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
context.getFailureDescription().set(e.getLocalizedMessage());
}
}
private AddressControl getAddressControl(final OperationContext context, final ModelNode operation) {
final String addressName = PathAddress.pathAddress(operation.require(OP_ADDR)).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());
return AddressControl.class.cast(server.getManagementService().getResource(ResourceNames.ADDRESS + addressName));
}
}
| 6,259
| 47.527132
| 156
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/OperationDefinitionHelper.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.wildfly.extension.messaging.activemq.CommonAttributes.FILTER;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.SimpleOperationDefinitionBuilder;
import org.jboss.as.controller.descriptions.ResourceDescriptionResolver;
import org.jboss.as.controller.operations.validation.StringLengthValidator;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
/**
* Helper class to define operations.
*
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2014 Red Hat inc.
*/
public class OperationDefinitionHelper {
public static AttributeDefinition createNonEmptyStringAttribute(String attributeName) {
return SimpleAttributeDefinitionBuilder.create(attributeName, ModelType.STRING)
.setRequired(true)
.setValidator(new StringLengthValidator(1))
.build();
}
/**
* Create a {@code SimpleOperationDefinitionBuilder} for the given operationName and flag it as
* <strong>read only and runtime only</strong>.
*/
public static SimpleOperationDefinitionBuilder runtimeReadOnlyOperation(String operationName, ResourceDescriptionResolver resolver) {
return new SimpleOperationDefinitionBuilder(operationName, resolver)
.setRuntimeOnly()
.setReadOnly();
}
/**
* Create a {@code SimpleOperationDefinitionBuilder} for the given operationName and flag it as
* <strong>runtime only</strong>.
*/
public static SimpleOperationDefinitionBuilder runtimeOnlyOperation(String operationName, ResourceDescriptionResolver resolver) {
return new SimpleOperationDefinitionBuilder(operationName, resolver)
.setRuntimeOnly();
}
public static String resolveFilter(OperationContext context, ModelNode operation) throws OperationFailedException {
return FILTER.resolveModelAttribute(context, operation).asStringOrNull();
}
}
| 3,207
| 42.945205
| 137
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/CommonAttributes.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.jboss.as.controller.client.helpers.MeasurementUnit.BYTES;
import static org.jboss.as.controller.client.helpers.MeasurementUnit.MILLISECONDS;
import static org.jboss.as.controller.registry.AttributeAccess.Flag.COUNTER_METRIC;
import static org.jboss.as.controller.registry.AttributeAccess.Flag.GAUGE_METRIC;
import static org.jboss.as.controller.registry.AttributeAccess.Flag.RESTART_ALL_SERVICES;
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.wildfly.extension.messaging.activemq.Capabilities.ELYTRON_SSL_CONTEXT_CAPABILITY;
import static org.wildfly.extension.messaging.activemq.jms.Validators.noDuplicateElements;
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.AttributeMarshaller;
import org.jboss.as.controller.AttributeMarshallers;
import org.jboss.as.controller.AttributeParser;
import org.jboss.as.controller.AttributeParsers;
import org.jboss.as.controller.ObjectListAttributeDefinition;
import org.jboss.as.controller.ObjectTypeAttributeDefinition;
import org.jboss.as.controller.PropertiesAttributeDefinition;
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.operations.validation.StringLengthValidator;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
/**
* @author Emanuel Muckenhuber
* @author <a href="mailto:andy.taylor@jboss.com">Andy Taylor</a>
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public interface CommonAttributes {
String ENTRIES = "entries";
String MODULE = "module";
String NAME = "name";
/**
* @see ActiveMQClient.DEFAULT_CALL_TIMEOUT
*/
AttributeDefinition CALL_TIMEOUT = create("call-timeout", LONG)
.setDefaultValue(new ModelNode(30000L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
SimpleAttributeDefinition CALL_FAILOVER_TIMEOUT = create("call-failover-timeout", LONG)
// ActiveMQClient.DEFAULT_CALL_FAILOVER_TIMEOUT was changed from -1 to 30000 in ARTEMIS-255
// we set it to 60s to leave more time for WildFly to failover
.setDefaultValue(new ModelNode(60000L))
.setRequired(false)
.setAllowExpression(true)
.setMeasurementUnit(MILLISECONDS)
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD
*/
SimpleAttributeDefinition CHECK_PERIOD = create("check-period", LONG)
.setDefaultValue(new ModelNode(30000L))
.setRequired(false)
.setAllowExpression(true)
.setMeasurementUnit(MILLISECONDS)
.setValidator(InfiniteOrPositiveValidators.LONG_INSTANCE)
.setFlags(RESTART_ALL_SERVICES)
.build();
SimpleAttributeDefinition CLIENT_ID = create("client-id", ModelType.STRING)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
AttributeDefinition CONSUMER_COUNT = create("consumer-count", INT)
.setStorageRuntime()
.setRequired(false)
.addFlag(GAUGE_METRIC)
.build();
/**
* @see ActiveMQDefaultConfiguration#DEFAULT_BRIDGE_CONFIRMATION_WINDOW_SIZE
*/
SimpleAttributeDefinition BRIDGE_CONFIRMATION_WINDOW_SIZE = create("confirmation-window-size", INT)
.setDefaultValue(new ModelNode(1024 * 1024 * 10))
.setMeasurementUnit(BYTES)
.setRequired(false)
.setAllowExpression(true)
.setCorrector(InfiniteOrPositiveValidators.NEGATIVE_VALUE_CORRECTOR)
.setValidator(InfiniteOrPositiveValidators.INT_INSTANCE)
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_CONNECTION_TTL
*/
SimpleAttributeDefinition CONNECTION_TTL = create("connection-ttl", LONG)
.setDefaultValue(new ModelNode(60000L))
.setRequired(false)
.setAllowExpression(true)
.setValidator(InfiniteOrPositiveValidators.LONG_INSTANCE)
.setMeasurementUnit(MILLISECONDS)
.setRestartAllServices()
.build();
SimpleAttributeDefinition DEAD_LETTER_ADDRESS = create("dead-letter-address", ModelType.STRING)
.setRequired(false)
.setAllowExpression(true)
.build();
AttributeDefinition DELIVERING_COUNT = create("delivering-count", INT)
.setStorageRuntime()
.setUndefinedMetricValue(ModelNode.ZERO)
.addFlag(GAUGE_METRIC)
.build();
StringListAttributeDefinition DESTINATION_ENTRIES = new StringListAttributeDefinition.Builder(ENTRIES)
.setRequired(true)
.setListValidator(noDuplicateElements(new StringLengthValidator(1, false, true)))
.setAllowExpression(true)
.setAttributeParser(AttributeParser.STRING_LIST)
.setAttributeMarshaller(AttributeMarshaller.STRING_LIST)
.setRestartAllServices()
.build();
StringListAttributeDefinition LEGACY_ENTRIES = new StringListAttributeDefinition.Builder("legacy-entries")
.setRequired(false)
.setListValidator(noDuplicateElements(new StringLengthValidator(1, false, true)))
.setAllowExpression(true)
.setAttributeParser(AttributeParser.STRING_LIST)
.setAttributeMarshaller(AttributeMarshaller.STRING_LIST)
.setRestartAllServices()
.build();
SimpleAttributeDefinition DURABLE = create("durable", BOOLEAN)
.setDefaultValue(ModelNode.TRUE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
SimpleAttributeDefinition FACTORY_CLASS = create("factory-class", ModelType.STRING)
.setAllowExpression(false)
.setRestartAllServices()
.build();
SimpleAttributeDefinition EXPIRY_ADDRESS = create("expiry-address", ModelType.STRING)
.setRequired(false)
.setAllowExpression(true)
.build();
SimpleAttributeDefinition FILTER = create("filter", ModelType.STRING)
.setRequired(false)
.setValidator(new StringLengthValidator(0))
.setAllowExpression(true)
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_HA
*/
SimpleAttributeDefinition HA = create("ha", BOOLEAN)
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
PropertiesAttributeDefinition PARAMS = new PropertiesAttributeDefinition.Builder("params", true)
.setAllowExpression(true)
.setAttributeParser(new AttributeParsers.PropertiesParser(null, "param", false))
.setAttributeMarshaller(new AttributeMarshallers.PropertiesAttributeMarshaller(null, "param", false))
.build();
@Deprecated SimpleAttributeDefinition JGROUPS_CHANNEL_FACTORY = create("jgroups-stack", ModelType.STRING)
.setRequired(false)
// do not allow expression as this may reference another resource
.setAllowExpression(false)
.setRequires("jgroups-cluster")
.setDeprecated(MessagingExtension.VERSION_3_0_0)
.setRestartAllServices()
.build();
SimpleAttributeDefinition JGROUPS_CHANNEL = create("jgroups-channel", ModelType.STRING)
.setRequired(false)
// do not allow expression as this may reference another resource
.setAllowExpression(false)
.setRequires("jgroups-cluster")
.setRestartAllServices()
.build();
SimpleAttributeDefinition JGROUPS_CLUSTER = create("jgroups-cluster", ModelType.STRING)
.setRequired(false)
// do not allow expression as this may reference another resource
.setAllowExpression(false)
.setAlternatives("socket-binding")
.setRestartAllServices()
.build();
/**
* @see ActiveMQClient.DEFAULT_MAX_RETRY_INTERVAL
*/
AttributeDefinition MAX_RETRY_INTERVAL = create("max-retry-interval", LONG)
.setDefaultValue(new ModelNode(2000L))
.setMeasurementUnit(MILLISECONDS)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
AttributeDefinition MESSAGE_COUNT = create("message-count", LONG)
.setStorageRuntime()
.setUndefinedMetricValue(ModelNode.ZERO)
.addFlag(GAUGE_METRIC)
.build();
AttributeDefinition MESSAGES_ADDED = create("messages-added", LONG)
.setStorageRuntime()
.setUndefinedMetricValue(ModelNode.ZERO)
.addFlag(COUNTER_METRIC)
.build();
/**
* @see ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE
*/
AttributeDefinition MIN_LARGE_MESSAGE_SIZE = create("min-large-message-size", INT)
.setDefaultValue(new ModelNode(100 * 1024))
.setMeasurementUnit(BYTES)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
AttributeDefinition PAUSED = create("paused", BOOLEAN)
.setStorageRuntime()
.build();
ObjectTypeAttributeDefinition CLASS = ObjectTypeAttributeDefinition.Builder.of("class",
create(NAME, ModelType.STRING, false)
.setAllowExpression(false)
.build(),
create(MODULE, ModelType.STRING, false)
.setAllowExpression(false)
.build())
.build();
ObjectListAttributeDefinition INCOMING_INTERCEPTORS = ObjectListAttributeDefinition.Builder.of("incoming-interceptors", CommonAttributes.CLASS)
.setRequired(false)
.setAllowExpression(false)
.setMinSize(1)
.setMaxSize(Integer.MAX_VALUE)
.build();
ObjectListAttributeDefinition OUTGOING_INTERCEPTORS = ObjectListAttributeDefinition.Builder.of("outgoing-interceptors", CommonAttributes.CLASS)
.setRequired(false)
.setAllowExpression(false)
.setMinSize(1)
.setMaxSize(Integer.MAX_VALUE)
.build();
/**
* @see ActiveMQClient.DEFAULT_RETRY_INTERVAL
*/
AttributeDefinition RETRY_INTERVAL = 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();
AttributeDefinition SCHEDULED_COUNT = create("scheduled-count", LONG)
.setStorageRuntime()
.setUndefinedMetricValue(ModelNode.ZERO)
.addFlag(GAUGE_METRIC)
.build();
SimpleAttributeDefinition SELECTOR = create("selector", ModelType.STRING)
.setRequired(false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
SimpleAttributeDefinition SOCKET_BINDING = create("socket-binding", ModelType.STRING)
.setRequired(false)
.setAlternatives(JGROUPS_CLUSTER.getName())
.setRestartAllServices()
.addAccessConstraint(SensitiveTargetAccessConstraintDefinition.SOCKET_BINDING_REF)
.build();
AttributeDefinition TEMPORARY = create("temporary", BOOLEAN)
.setStorageRuntime()
.build();
SimpleAttributeDefinition TRANSFORMER_CLASS_NAME = create("transformer-class-name", ModelType.STRING)
.setRequired(false)
.setAllowExpression(false)
.setRestartAllServices()
.build();
SimpleAttributeDefinition SSL_CONTEXT = new SimpleAttributeDefinitionBuilder("ssl-context", ModelType.STRING, true)
.setCapabilityReference(ELYTRON_SSL_CONTEXT_CAPABILITY.getName())
.setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES)
.setValidator(new StringLengthValidator(1))
.setAccessConstraints(SensitiveTargetAccessConstraintDefinition.SSL_REF)
.build();
String ACCEPTOR = "acceptor";
String ACCEPTORS = "acceptors";
String ACTIVEMQ_ADDRESS = "activemq-address";
String ADDRESS = "address";
String ADDRESS_SETTING = "address-setting";
String ADDRESS_SETTINGS = "address-settings";
String BINDING_NAMES = "binding-names";
String BINDINGS_DIRECTORY = "bindings-directory";
String BRIDGE = "bridge";
String BRIDGES = "bridges";
String BROADCAST_GROUP = "broadcast-group";
String BROADCAST_GROUPS = "broadcast-groups";
String CHECK_FOR_LIVE_SERVER2 = "check-for-live-server";
String CLASS_NAME = "class-name";
String EXTERNAL_JMS_QUEUE = "external-jms-queue";
String EXTERNAL_JMS_TOPIC = "external-jms-topic";
String CLUSTER_CONNECTION = "cluster-connection";
String CLUSTER_CONNECTIONS = "cluster-connections";
String CLUSTER_NAME = "cluster-name";
String COLOCATED = "colocated";
String CONFIGURATION = "configuration";
String CONNECTION_FACTORY = "connection-factory";
String CONNECTOR = "connector";
String CONNECTORS = "connectors";
String CONNECTOR_NAME = "connector-name";
String CONNECTOR_REF_STRING = "connector-ref";
String CONNECTOR_SERVICE = "connector-service";
String CONNECTOR_SERVICES = "connector-services";
String CORE = "core";
String CORE_ADDRESS = "core-address";
String CORE_QUEUE = "core-queue";
String CORE_QUEUES = "core-queues";
String DEFAULT = "default";
String DESTINATION = "destination";
String DISCOVERY_GROUP = "discovery-group";
String DISCOVERY_GROUPS = "discovery-groups";
String DISCOVERY_GROUP_REF = "discovery-group-ref";
String DIVERT = "divert";
String DIVERTS = "diverts";
String DURABLE_MESSAGE_COUNT = "durable-message-count";
String DURABLE_SUBSCRIPTION_COUNT = "durable-subscription-count";
String ENABLED = "enabled";
String ENTRY = "entry";
String EXCLUDES = "excludes";
String FILE_DEPLOYMENT_ENABLED = "file-deployment-enabled";
String GROUP_NAME = "group-name";
String GROUPING_HANDLER = "grouping-handler";
String HA_POLICY = "ha-policy";
String HOST = "host";
String HTTP = "http";
String HTTP_ACCEPTOR = "http-acceptor";
String HTTP_CONNECTOR = "http-connector";
String HTTP_LISTENER = "http-listener";
String ID = "id";
String IN_VM_ACCEPTOR = "in-vm-acceptor";
String IN_VM_CONNECTOR = "in-vm-connector";
String LEGACY = "legacy";
String LEGACY_CONNECTION_FACTORY = "legacy-connection-factory";
String JGROUPS_BROADCAST_GROUP = "jgroups-broadcast-group";
String JGROUPS_DISCOVERY_GROUP = "jgroups-discovery-group";
String JMS_BRIDGE = "jms-bridge";
String JMS_CONNECTION_FACTORIES = "jms-connection-factories";
String JMS_DESTINATION = "jms-destination";
String JMS_DESTINATIONS = "jms-destinations";
String JMS_QUEUE = "jms-queue";
String JMS_TOPIC = "jms-topic";
String JNDI_BINDING = "jndi-binding";
String JOURNAL_DIRECTORY = "journal-directory";
String KEY = "key";
String INBOUND_CONFIG = "inbound-config";
String LARGE_MESSAGES_DIRECTORY = "large-messages-directory";
String LAST_VALUE_QUEUE = "last-value=queue";
String LIVE_ONLY = "live-only";
String LOCAL = "local";
String LOCAL_TX = "LocalTransaction";
String MANAGE_XML_NAME = "manage";
String MASTER = "master";
String MATCH = "match";
String MESSAGE_ID = "message-id";
String MODE = "mode";
String NETTY_ACCEPTOR = "netty-acceptor";
String NETTY_CONNECTOR = "netty-connector";
String NONE = "none";
String NON_DURABLE_MESSAGE_COUNT = "non-durable-message-count";
String NON_DURABLE_SUBSCRIPTION_COUNT = "non-durable-subscription-count";
String NO_TX = "NoTransaction";
String NUMBER_OF_BYTES_PER_PAGE = "number-of-bytes-per-page";
String NUMBER_OF_PAGES = "number-of-pages";
String PAGING_DIRECTORY = "paging-directory";
String PARAM = "param";
String PASSWORD = "password";
String PERMISSION_ELEMENT_NAME = "permission";
String POOLED_CONNECTION_FACTORY = "pooled-connection-factory";
String PRIMARY = "primary";
String QUEUE = "queue";
String QUEUE_NAME = "queue-name";
String QUEUE_NAMES = "queue-names";
String REMOTE_ACCEPTOR = "remote-acceptor";
String REMOTE_CONNECTOR = "remote-connector";
String REPLICATION = "replication";
String REPLICATION_COLOCATED = "replication-colocated";
String REPLICATION_MASTER = "replication-master";
String REPLICATION_PRIMARY = "replication-primary";
String REPLICATION_SECONDARY = "replication-secondary";
String REPLICATION_SLAVE = "replication-slave";
String RESOURCE_ADAPTER = "resource-adapter";
String RESOLVE_ADDRESS_SETTING = "resolve-address-setting";
String ROLE = "role";
String ROLES_ATTR_NAME = "roles";
String RUNTIME_QUEUE = "runtime-queue";
String SCALE_DOWN = "scale-down";
String SECONDARY = "secondary";
String SECURITY_ROLE = "security-role";
String SECURITY_SETTING = "security-setting";
String SECURITY_SETTINGS = "security-settings";
String SERVER = "server";
String SERVLET_PATH = "servlet-path";
String SHARED_STORE = "shared-store";
String SHARED_STORE_COLOCATED = "shared-store-colocated";
String SHARED_STORE_MASTER = "shared-store-master";
String SHARED_STORE_PRIMARY = "shared-store-primary";
String SHARED_STORE_SECONDARY = "shared-store-secondary";
String SHARED_STORE_SLAVE = "shared-store-slave";
String SLAVE = "slave";
String SOCKET_BROADCAST_GROUP = "socket-broadcast-group";
String SOCKET_DISCOVERY_GROUP = "socket-discovery-group";
String SOURCE = "source";
String STARTED = "started";
String STATIC_CONNECTORS = "static-connectors";
String STRING = "string";
String SUBSCRIPTION_COUNT = "subscription-count";
String SUBSYSTEM = "subsystem";
String TARGET = "target";
String TOPIC_ADDRESS = "topic-address";
String TYPE_ATTR_NAME = "type";
String USE_INVM = "use-invm";
String USE_SERVLET = "use-servlet";
String VERSION = "version";
String XA = "xa";
String XA_TX = "XATransaction";
static void renameChannelToCluster(ModelNode operation) {
// Handle jgroups-channel -> jgroups-cluster rename
if (!operation.hasDefined(CommonAttributes.JGROUPS_CLUSTER.getName()) && operation.hasDefined(CommonAttributes.JGROUPS_CHANNEL.getName())) {
operation.get(CommonAttributes.JGROUPS_CLUSTER.getName()).set(operation.get(CommonAttributes.JGROUPS_CHANNEL.getName()));
operation.remove(CommonAttributes.JGROUPS_CHANNEL.getName());
}
}
}
| 21,257
| 41.686747
| 148
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/BridgeAdd.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.security.CredentialReference.handleCredentialReferenceUpdate;
import static org.jboss.as.controller.security.CredentialReference.rollbackCredentialStoreUpdate;
import static org.wildfly.extension.messaging.activemq.BridgeDefinition.ATTRIBUTES;
import static org.wildfly.extension.messaging.activemq.BridgeDefinition.CALL_TIMEOUT;
import static org.wildfly.extension.messaging.activemq.BridgeDefinition.CREDENTIAL_REFERENCE;
import static org.wildfly.extension.messaging.activemq.BridgeDefinition.DISCOVERY_GROUP_NAME;
import static org.wildfly.extension.messaging.activemq.BridgeDefinition.FORWARDING_ADDRESS;
import static org.wildfly.extension.messaging.activemq.BridgeDefinition.INITIAL_CONNECT_ATTEMPTS;
import static org.wildfly.extension.messaging.activemq.BridgeDefinition.PASSWORD;
import static org.wildfly.extension.messaging.activemq.BridgeDefinition.PRODUCER_WINDOW_SIZE;
import static org.wildfly.extension.messaging.activemq.BridgeDefinition.QUEUE_NAME;
import static org.wildfly.extension.messaging.activemq.BridgeDefinition.RECONNECT_ATTEMPTS;
import static org.wildfly.extension.messaging.activemq.BridgeDefinition.RECONNECT_ATTEMPTS_ON_SAME_NODE;
import static org.wildfly.extension.messaging.activemq.BridgeDefinition.USER;
import static org.wildfly.extension.messaging.activemq.BridgeDefinition.USE_DUPLICATE_DETECTION;
import java.util.ArrayList;
import java.util.List;
import org.apache.activemq.artemis.core.config.BridgeConfiguration;
import org.apache.activemq.artemis.core.config.TransformerConfiguration;
import org.apache.activemq.artemis.core.persistence.StorageManager;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ComponentConfigurationRoutingType;
import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.ExpressionResolver;
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;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceRegistry;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* Handler for adding a bridge.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class BridgeAdd extends AbstractAddStepHandler {
public static final BridgeAdd INSTANCE = new BridgeAdd();
static final String CALL_TIMEOUT_PROPERTY = "org.wildfly.messaging.core.bridge.call-timeout";
static final String ROUTING_TYPE_PROPERTY = "org.wildfly.messaging.core.bridge.%s.routing-type";
private BridgeAdd() {
super(ATTRIBUTES);
}
@Override
protected void populateModel(final OperationContext context, final ModelNode operation, final Resource resource) throws OperationFailedException {
super.populateModel(context, operation, resource);
handleCredentialReferenceUpdate(context, resource.getModel());
}
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
ServiceController<?> service = registry.getService(serviceName);
if (service != null) {
// The original subsystem initialization is complete; use the control object to create the divert
if (service.getState() != ServiceController.State.UP) {
throw MessagingLogger.ROOT_LOGGER.invalidServiceState(serviceName, ServiceController.State.UP, service.getState());
}
final String name = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
BridgeConfiguration bridgeConfig = createBridgeConfiguration(context, name, model);
//noinspection RedundantClassCall
ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
createBridge(bridgeConfig, server);
}
// else the initial subsystem install is not complete; MessagingSubsystemAdd will add a
// handler that calls addBridgeConfigs
}
@Override
protected void rollbackRuntime(OperationContext context, final ModelNode operation, final Resource resource) {
rollbackCredentialStoreUpdate(CREDENTIAL_REFERENCE, context, resource);
}
static BridgeConfiguration createBridgeConfiguration(final ExpressionResolver expressionResolver, final String name, final ModelNode model) throws OperationFailedException {
final String queueName = QUEUE_NAME.resolveModelAttribute(expressionResolver, model).asString();
final String forwardingAddress = FORWARDING_ADDRESS.resolveModelAttribute(expressionResolver, model).asStringOrNull();
final String filterString = CommonAttributes.FILTER.resolveModelAttribute(expressionResolver, model).asStringOrNull();
final int minLargeMessageSize = CommonAttributes.MIN_LARGE_MESSAGE_SIZE.resolveModelAttribute(expressionResolver, model).asInt();
final long retryInterval = CommonAttributes.RETRY_INTERVAL.resolveModelAttribute(expressionResolver, model).asLong();
final double retryIntervalMultiplier = CommonAttributes.RETRY_INTERVAL_MULTIPLIER.resolveModelAttribute(expressionResolver, model).asDouble();
final long maxRetryInterval = CommonAttributes.MAX_RETRY_INTERVAL.resolveModelAttribute(expressionResolver, model).asLong();
final int initialConnectAttempts = INITIAL_CONNECT_ATTEMPTS.resolveModelAttribute(expressionResolver, model).asInt();
final int reconnectAttempts = RECONNECT_ATTEMPTS.resolveModelAttribute(expressionResolver, model).asInt();
final int reconnectAttemptsOnSameNode = RECONNECT_ATTEMPTS_ON_SAME_NODE.resolveModelAttribute(expressionResolver, model).asInt();
final boolean useDuplicateDetection = USE_DUPLICATE_DETECTION.resolveModelAttribute(expressionResolver, model).asBoolean();
final int confirmationWindowSize = CommonAttributes.BRIDGE_CONFIRMATION_WINDOW_SIZE.resolveModelAttribute(expressionResolver, model).asInt();
final int producerWindowSize = PRODUCER_WINDOW_SIZE.resolveModelAttribute(expressionResolver, model).asInt();
final long clientFailureCheckPeriod = CommonAttributes.CHECK_PERIOD.resolveModelAttribute(expressionResolver, model).asLong();
final long connectionTTL = CommonAttributes.CONNECTION_TTL.resolveModelAttribute(expressionResolver, model).asLong();
final ModelNode discoveryNode = DISCOVERY_GROUP_NAME.resolveModelAttribute(expressionResolver, model);
final String discoveryGroupName = discoveryNode.isDefined() ? discoveryNode.asString() : null;
List<String> staticConnectors = discoveryGroupName == null ? getStaticConnectors(model) : null;
final boolean ha = CommonAttributes.HA.resolveModelAttribute(expressionResolver, model).asBoolean();
final String user = USER.resolveModelAttribute(expressionResolver, model).asString();
final String password = PASSWORD.resolveModelAttribute(expressionResolver, model).asString();
String routingType = getRoutingTypeFromSystemProperty(name);
if(routingType == null) {
routingType = BridgeDefinition.ROUTING_TYPE.resolveModelAttribute(expressionResolver, model).asString();
}
Long callTimeout = getCallTimeoutFromSystemProperty();
if (callTimeout == null) {
callTimeout = CALL_TIMEOUT.resolveModelAttribute(expressionResolver, model).asLong();
}
BridgeConfiguration config = new BridgeConfiguration()
.setName(name)
.setQueueName(queueName)
.setForwardingAddress(forwardingAddress)
.setFilterString(filterString)
.setMinLargeMessageSize(minLargeMessageSize)
.setClientFailureCheckPeriod(clientFailureCheckPeriod)
.setConnectionTTL(connectionTTL)
.setRetryInterval(retryInterval)
.setMaxRetryInterval(maxRetryInterval)
.setRetryIntervalMultiplier(retryIntervalMultiplier)
.setInitialConnectAttempts(initialConnectAttempts)
.setReconnectAttempts(reconnectAttempts)
.setReconnectAttemptsOnSameNode(reconnectAttemptsOnSameNode)
.setUseDuplicateDetection(useDuplicateDetection)
.setConfirmationWindowSize(confirmationWindowSize)
.setProducerWindowSize(producerWindowSize)
.setHA(ha)
.setUser(user)
.setPassword(password)
.setCallTimeout(callTimeout)
.setRoutingType(ComponentConfigurationRoutingType.valueOf(routingType));
if (discoveryGroupName != null) {
config.setDiscoveryGroupName(discoveryGroupName);
} else {
config.setStaticConnectors(staticConnectors);
}
final ModelNode transformerClassName = CommonAttributes.TRANSFORMER_CLASS_NAME.resolveModelAttribute(expressionResolver, model);
if (transformerClassName.isDefined()) {
config.setTransformerConfiguration(new TransformerConfiguration(transformerClassName.asString()));
}
return config;
}
private static List<String> getStaticConnectors(ModelNode model) {
List<String> result = new ArrayList<>();
for (ModelNode connector : model.require(CommonAttributes.STATIC_CONNECTORS).asList()) {
result.add(connector.asString());
}
return result;
}
static void createBridge(BridgeConfiguration bridgeConfig, ActiveMQServer server) throws OperationFailedException {
checkStarted(server);
clearIO(server);
try {
if(!server.deployBridge(bridgeConfig)) {
throw MessagingLogger.ROOT_LOGGER.failedBridgeDeployment(bridgeConfig.getName());
}
} catch (OperationFailedException | RuntimeException e) {
throw e;
} catch (Exception e) {
// TODO should this be an OFE instead?
throw new RuntimeException(e);
} finally {
blockOnIO(server);
}
}
static void checkStarted(ActiveMQServer server) {
// extracted from ActiveMQServerControlImpl#checkStarted()
if (!server.isStarted()) {
throw MessagingLogger.ROOT_LOGGER.brokerNotStarted();
}
}
static void clearIO(ActiveMQServer server) {
// extracted from ActiveMQServerControlImpl#clearIO()
StorageManager storageManager = server.getStorageManager();
// the storage manager could be null on the backup on certain components
if (storageManager != null) {
storageManager.clearContext();
}
}
static void blockOnIO(ActiveMQServer server) {
// extracted from ActiveMQServerControlImpl#blockOnIO()
StorageManager storageManager = server.getStorageManager();
// the storage manager could be null on the backup on certain components
if (storageManager != null && storageManager.isStarted()) {
try {
storageManager.waitOnOperations();
storageManager.clearContext();
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
}
/**
* In upstream this property is gonna be part of the management model. Here we need to get it from a system property.
*/
private static Long getCallTimeoutFromSystemProperty() {
String value = org.wildfly.security.manager.WildFlySecurityManager.getSystemPropertiesPrivileged().getProperty(CALL_TIMEOUT_PROPERTY);
if (value == null) {
return null;
}
return Long.parseLong(value);
}
/**
* In upstream this property is gonna be part of the management model. Here we need to get it from a system property.
*/
private static String getRoutingTypeFromSystemProperty(String name) {
return org.wildfly.security.manager.WildFlySecurityManager.getSystemPropertiesPrivileged().getProperty(String.format(ROUTING_TYPE_PROPERTY, name));
}
}
| 13,724
| 51.385496
| 177
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/QueueService.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 java.util.function.Supplier;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
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.logging.MessagingLogger;
/**
* Service responsible for create ActiveMQ core queues.
*
* @author Emanuel Muckenhuber
*/
class QueueService implements Service<Void> {
private final Supplier<ActiveMQServer> activeMQServerSupplier;
private final CoreQueueConfiguration queueConfiguration;
private final boolean temporary;
private final boolean createQueue;
public QueueService(final Supplier<ActiveMQServer> activeMQServerSupplier, final CoreQueueConfiguration queueConfiguration, final boolean temporary, final boolean createQueue) {
if(queueConfiguration == null) {
throw MessagingLogger.ROOT_LOGGER.nullVar("queueConfiguration");
}
this.activeMQServerSupplier = activeMQServerSupplier;
this.queueConfiguration = queueConfiguration;
this.temporary = temporary;
this.createQueue = createQueue;
}
/** {@inheritDoc} */
@Override
public synchronized void start(StartContext context) throws StartException {
if (createQueue) {
try {
final ActiveMQServer server = this.activeMQServerSupplier.get();
MessagingLogger.ROOT_LOGGER.debugf("Deploying queue on server %s with address: %s , name: %s, filter: %s ands durable: %s, temporary: %s",
server.getNodeID(), new SimpleString(queueConfiguration.getAddress()), new SimpleString(queueConfiguration.getName()),
SimpleString.toSimpleString(queueConfiguration.getFilterString()), queueConfiguration.isDurable(), temporary);
final SimpleString resourceName = new SimpleString(queueConfiguration.getName());
final SimpleString address = new SimpleString(queueConfiguration.getAddress());
final SimpleString filterString = SimpleString.toSimpleString(queueConfiguration.getFilterString());
server.createQueue(address,
queueConfiguration.getRoutingType(),
resourceName,
filterString,
queueConfiguration.isDurable(),
temporary);
} catch (Exception e) {
throw new StartException(e);
}
}
}
/** {@inheritDoc} */
@Override
public synchronized void stop(StopContext context) {
try {
final ActiveMQServer server = this.activeMQServerSupplier.get();
server.destroyQueue(new SimpleString(queueConfiguration.getName()), null, false);
MessagingLogger.ROOT_LOGGER.debugf("Destroying queue from server %s queue with name: %s",server.getNodeID() , new SimpleString(queueConfiguration.getName()));
} catch(Exception e) {
MessagingLogger.ROOT_LOGGER.failedToDestroy("queue", queueConfiguration.getName());
}
}
/** {@inheritDoc} */
@Override
public Void getValue() throws IllegalStateException {
return null;
}
}
| 4,502
| 44.484848
| 181
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/WildFlySecurityManager.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 java.util.Set;
import org.apache.activemq.artemis.core.security.CheckType;
import org.apache.activemq.artemis.core.security.Role;
import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
public class WildFlySecurityManager implements ActiveMQSecurityManager {
private String defaultUser = null;
private String defaultPassword = null;
public WildFlySecurityManager() {
defaultUser = DefaultCredentials.getUsername();
defaultPassword = DefaultCredentials.getPassword();
}
@Override
public boolean validateUser(String username, String password) {
if (defaultUser.equals(username) && defaultPassword.equals(password))
return true;
throw MessagingLogger.ROOT_LOGGER.legacySecurityUnsupported();
}
@Override
public boolean validateUserAndRole(final String username, final String password, final Set<Role> roles, final CheckType checkType) {
if (defaultUser.equals(username) && defaultPassword.equals(password))
return true;
throw MessagingLogger.ROOT_LOGGER.legacySecurityUnsupported();
}
}
| 2,280
| 39.017544
| 136
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/SecurityRoleDefinition.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.registry.AttributeAccess.Flag.RESTART_NONE;
import static org.jboss.dmr.ModelType.BOOLEAN;
import static org.jboss.dmr.ModelType.STRING;
import java.util.Collection;
import java.util.Collections;
import org.apache.activemq.artemis.core.security.Role;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.ObjectTypeAttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.dmr.ModelNode;
/**
* Security role resource definition
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat Inc.
*/
public class SecurityRoleDefinition extends PersistentResourceDefinition {
public static ObjectTypeAttributeDefinition getObjectTypeAttributeDefinition() {
// add the role name as an attribute of the object type
SimpleAttributeDefinition[] attrs = new SimpleAttributeDefinition[ATTRIBUTES.length + 1];
attrs[0] = NAME;
System.arraycopy(ATTRIBUTES, 0, attrs, 1, ATTRIBUTES.length);
return ObjectTypeAttributeDefinition.Builder.of(CommonAttributes.ROLE, attrs).build();
}
private static SimpleAttributeDefinition create(final String name) {
return SimpleAttributeDefinitionBuilder.create(name, BOOLEAN)
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setFlags(RESTART_NONE)
.build();
}
static final SimpleAttributeDefinition SEND = create("send");
static final SimpleAttributeDefinition CONSUME = create("consume");
static final SimpleAttributeDefinition CREATE_DURABLE_QUEUE = create("create-durable-queue");
static final SimpleAttributeDefinition DELETE_DURABLE_QUEUE = create("delete-durable-queue");
static final SimpleAttributeDefinition CREATE_NON_DURABLE_QUEUE = create("create-non-durable-queue");
static final SimpleAttributeDefinition DELETE_NON_DURABLE_QUEUE = create("delete-non-durable-queue");
static final SimpleAttributeDefinition MANAGE = SimpleAttributeDefinitionBuilder.create("manage", BOOLEAN)
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setFlags(RESTART_NONE)
.addAccessConstraint(MessagingExtension.MESSAGING_MANAGEMENT_SENSITIVE_TARGET)
.build();
static final SimpleAttributeDefinition BROWSE = SimpleAttributeDefinitionBuilder.create("browse", BOOLEAN)
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setFlags(RESTART_NONE)
.setStorageRuntime()
.addAccessConstraint(MessagingExtension.MESSAGING_MANAGEMENT_SENSITIVE_TARGET)
.build();
static final SimpleAttributeDefinition CREATE_ADDRESS = SimpleAttributeDefinitionBuilder.create("create-address", BOOLEAN)
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setFlags(RESTART_NONE)
.setStorageRuntime()
.addAccessConstraint(MessagingExtension.MESSAGING_MANAGEMENT_SENSITIVE_TARGET)
.build();
static final SimpleAttributeDefinition DELETE_ADDRESS = SimpleAttributeDefinitionBuilder.create("delete-address", BOOLEAN)
.setDefaultValue(ModelNode.FALSE)
.setRequired(false)
.setFlags(RESTART_NONE)
.setStorageRuntime()
.addAccessConstraint(MessagingExtension.MESSAGING_MANAGEMENT_SENSITIVE_TARGET)
.build();
static final SimpleAttributeDefinition[] ATTRIBUTES = {
SEND,
CONSUME,
CREATE_DURABLE_QUEUE,
DELETE_DURABLE_QUEUE,
CREATE_NON_DURABLE_QUEUE,
DELETE_NON_DURABLE_QUEUE,
MANAGE
};
static final SimpleAttributeDefinition NAME = SimpleAttributeDefinitionBuilder.create("name", STRING)
.build();
private final boolean runtimeOnly;
static Role transform(final OperationContext context, final String name, final ModelNode node) throws OperationFailedException {
final boolean send = SEND.resolveModelAttribute(context, node).asBoolean();
final boolean consume = CONSUME.resolveModelAttribute(context, node).asBoolean();
final boolean createDurableQueue = CREATE_DURABLE_QUEUE.resolveModelAttribute(context, node).asBoolean();
final boolean deleteDurableQueue = DELETE_DURABLE_QUEUE.resolveModelAttribute(context, node).asBoolean();
final boolean createNonDurableQueue = CREATE_NON_DURABLE_QUEUE.resolveModelAttribute(context, node).asBoolean();
final boolean deleteNonDurableQueue = DELETE_NON_DURABLE_QUEUE.resolveModelAttribute(context, node).asBoolean();
final boolean manage = MANAGE.resolveModelAttribute(context, node).asBoolean();
return new Role(name, send, consume, createDurableQueue, deleteDurableQueue, createNonDurableQueue,
deleteNonDurableQueue, manage, consume, createDurableQueue || createNonDurableQueue,
deleteDurableQueue || deleteNonDurableQueue);
}
SecurityRoleDefinition(final boolean runtimeOnly) {
super(MessagingExtension.ROLE_PATH,
MessagingExtension.getResourceDescriptionResolver(CommonAttributes.SECURITY_ROLE),
runtimeOnly ? null : SecurityRoleAdd.INSTANCE,
runtimeOnly ? null : SecurityRoleRemove.INSTANCE,
runtimeOnly);
this.runtimeOnly = runtimeOnly;
}
@Override
public Collection<AttributeDefinition> getAttributes() {
return Collections.emptyList();
}
@Override
public void registerAttributes(ManagementResourceRegistration registry) {
super.registerAttributes(registry);
if (runtimeOnly) {
for (SimpleAttributeDefinition attr : ATTRIBUTES) {
AttributeDefinition readOnlyAttr = SimpleAttributeDefinitionBuilder.create(attr)
.setStorageRuntime()
.build();
registry.registerReadOnlyAttribute(readOnlyAttr, SecurityRoleReadAttributeHandler.INSTANCE);
}
registry.registerReadOnlyAttribute(BROWSE, SecurityRoleReadAttributeHandler.INSTANCE);
registry.registerReadOnlyAttribute(CREATE_ADDRESS, SecurityRoleReadAttributeHandler.INSTANCE);
registry.registerReadOnlyAttribute(DELETE_ADDRESS, SecurityRoleReadAttributeHandler.INSTANCE);
} else {
for (AttributeDefinition attr : ATTRIBUTES) {
if (!attr.getFlags().contains(AttributeAccess.Flag.STORAGE_RUNTIME)) {
registry.registerReadWriteAttribute(attr, null, SecurityRoleAttributeHandler.INSTANCE);
}
}
}
}
}
| 8,150
| 48.4
| 132
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/CoreAddressDefinition.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.dmr.ModelType.LONG;
import static org.jboss.dmr.ModelType.STRING;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.PrimitiveListAttributeDefinition;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
/**
* Core address resource definition
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat Inc.
*/
public class CoreAddressDefinition extends SimpleResourceDefinition {
public static final PathElement PATH = PathElement.pathElement(CommonAttributes.CORE_ADDRESS);
private static final AttributeDefinition QUEUE_NAMES = PrimitiveListAttributeDefinition.Builder.of(CommonAttributes.QUEUE_NAMES, STRING)
.setFlags(AttributeAccess.Flag.STORAGE_RUNTIME)
.build();
private static final AttributeDefinition BINDING_NAMES = PrimitiveListAttributeDefinition.Builder.of(CommonAttributes.BINDING_NAMES, STRING)
.setFlags(AttributeAccess.Flag.STORAGE_RUNTIME)
.build();
private static final AttributeDefinition NUMBER_OF_PAGES = create(CommonAttributes.NUMBER_OF_PAGES, LONG)
.setStorageRuntime()
.build();
private static final AttributeDefinition NUMBER_OF_BYTES_PER_PAGE = create(CommonAttributes.NUMBER_OF_BYTES_PER_PAGE, LONG)
.setMeasurementUnit(BYTES)
.setStorageRuntime()
.build();
public static final AttributeDefinition[] ATTRS = { QUEUE_NAMES, BINDING_NAMES, NUMBER_OF_PAGES, NUMBER_OF_BYTES_PER_PAGE };
public CoreAddressDefinition() {
super(new Parameters(PATH,
MessagingExtension.getResourceDescriptionResolver(CommonAttributes.CORE_ADDRESS)).setRuntime());
}
@Override
public boolean isRuntime() {
return true;
}
@Override
public void registerAttributes(ManagementResourceRegistration registry) {
for (AttributeDefinition attr : ATTRS) {
registry.registerReadOnlyAttribute(attr, AddressControlHandler.INSTANCE);
}
}
@Override
public void registerChildren(ManagementResourceRegistration registry) {
registry.registerSubModel(new SecurityRoleDefinition(true));
}
}
| 3,614
| 40.551724
| 144
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/ClusterConnectionControlHandler.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 java.util.Map;
import org.apache.activemq.artemis.api.core.management.ClusterConnectionControl;
import org.apache.activemq.artemis.api.core.management.ResourceNames;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
import org.jboss.dmr.ModelNode;
/**
* Handler for runtime operations that interact with a ActiveMQ {@link org.apache.activemq.api.core.management.ClusterConnectionControl}.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class ClusterConnectionControlHandler extends AbstractActiveMQComponentControlHandler<ClusterConnectionControl> {
public static final ClusterConnectionControlHandler INSTANCE = new ClusterConnectionControlHandler();
private ClusterConnectionControlHandler() {
}
@Override
protected ClusterConnectionControl getActiveMQComponentControl(ActiveMQServer activeMQServer, PathAddress address) {
final String resourceName = address.getLastElement().getValue();
return ClusterConnectionControl.class.cast(activeMQServer.getManagementService().getResource(ResourceNames.CORE_CLUSTER_CONNECTION + resourceName));
}
@Override
protected String getDescriptionPrefix() {
return CommonAttributes.CLUSTER_CONNECTION;
}
@Override
protected void handleReadAttribute(String attributeName, OperationContext context, ModelNode operation) throws OperationFailedException {
if (ClusterConnectionDefinition.NODE_ID.getName().equals(attributeName)) {
ClusterConnectionControl control = getActiveMQComponentControl(context, operation, false);
if(control != null) {
context.getResult().set(control.getNodeID());
}
} else if (ClusterConnectionDefinition.TOPOLOGY.getName().equals(attributeName)) {
ClusterConnectionControl control = getActiveMQComponentControl(context, operation, false);
if(control != null) {
context.getResult().set(formatTopology(control.getTopology()));
}
} else {
unsupportedAttribute(attributeName);
}
}
public static String formatTopology(String topology) {
String prefix = "";
StringBuilder builder = new StringBuilder();
boolean params = false;
char previous = ' ';
for (char c : topology.toCharArray()) {
switch (c) {
case '[':
case '{':
case '(':
builder.append(c);
prefix += TAB;
break;
case '?':
if(' ' == previous) {
builder.deleteCharAt(builder.length()-1);
builder.append(',').append(NEW).append(prefix);
}
params = true;
prefix += TAB;
builder.append('{').append(NEW).append(prefix);
break;
case '&':
builder.append(',').append(NEW).append(prefix);
break;
case ',':
if(params) {
prefix = prefix.substring(0, prefix.length() - TAB.length());
builder.append(NEW).append(prefix).append('}').append(c).append(NEW).append(prefix);
} else {
builder.append(c);
}
params = false;
break;
case ']':
case '}':
prefix = prefix.substring(0, prefix.length() - TAB.length());
builder.append(NEW).append(prefix);
builder.append(c);
break;
case ')':
prefix = prefix.substring(0, prefix.length() - TAB.length());
builder.append(c);
break;
case ' ':
if (',' != previous) {
builder.append(c);
}
break;
default:
if (',' == previous) {
builder.append(NEW).append(prefix);
}
builder.append(c);
}
if (c != ' ' || previous != ',') {
previous = c;
}
}
return builder.toString().trim();
}
private static final String TAB = "\t";
private static final String NEW = System.lineSeparator();
@Override
protected Object handleOperation(String operationName, OperationContext context, ModelNode operation) throws OperationFailedException {
if (ClusterConnectionDefinition.GET_NODES.equals(operationName)) {
ClusterConnectionControl control = getActiveMQComponentControl(context, operation, false);
try {
if (control != null) {
Map<String, String> nodes = control.getNodes();
final ModelNode result = context.getResult();
result.setEmptyObject();
for (Map.Entry<String, String> entry : nodes.entrySet()) {
result.get(entry.getKey()).set(entry.getValue());
}
}
} catch (Exception e) {
context.getFailureDescription().set(e.getLocalizedMessage());
}
} else {
unsupportedOperation(operationName);
}
return null;
}
}
| 6,750
| 40.417178
| 156
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/AddressSettingsValidator.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.PathAddress.pathAddress;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.DEAD_LETTER_ADDRESS;
import static org.wildfly.extension.messaging.activemq.CommonAttributes.EXPIRY_ADDRESS;
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.dmr.ModelNode;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
/**
* Validate that address-settings' attributes are properly configured.
*
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2014 Red Hat inc.
*/
class AddressSettingsValidator {
private static final String JMS_QUEUE_ADDRESS_PREFIX = "jms.queue.";
private static final String JMS_TOPIC_ADDRESS_PREFIX = "jms.topic.";
/**
* Validates that an address-setting:add operation does not define expiry-address or dead-letter address
* without corresponding resources for them.
*/
static OperationStepHandler ADD_VALIDATOR = new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
String addressSetting = PathAddress.pathAddress(operation.require(OP_ADDR)).getLastElement().getValue();
PathAddress address = pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
Resource activeMQServer = context.readResourceFromRoot(MessagingServices.getActiveMQServerPathAddress(address), false);
checkExpiryAddress(context, operation, activeMQServer, addressSetting);
checkDeadLetterAddress(context, operation, activeMQServer, addressSetting);
}
};
/**
* Validate that an updated address-settings still has resources bound corresponding
* to expiry-address and dead-letter-address (if they are defined).
*/
static void validateModel(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
String addressSetting = PathAddress.pathAddress(operation.require(OP_ADDR)).getLastElement().getValue();
PathAddress address = pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
Resource activeMQServer = context.readResourceFromRoot(MessagingServices.getActiveMQServerPathAddress(address), true);
checkExpiryAddress(context, resource.getModel(), activeMQServer, addressSetting);
checkDeadLetterAddress(context, resource.getModel(), activeMQServer, addressSetting);
}
private static void checkExpiryAddress(OperationContext context, ModelNode model, Resource activeMQServer, String addressSetting) throws OperationFailedException {
ModelNode expiryAddress = EXPIRY_ADDRESS.resolveModelAttribute(context, model);
if (!findMatchingResource(expiryAddress, activeMQServer)) {
MessagingLogger.ROOT_LOGGER.noMatchingExpiryAddress(expiryAddress.asString(), addressSetting);
}
}
private static void checkDeadLetterAddress(OperationContext context, ModelNode model, Resource activeMQServer, String addressSetting) throws OperationFailedException {
ModelNode deadLetterAddress = DEAD_LETTER_ADDRESS.resolveModelAttribute(context, model);
if (!findMatchingResource(deadLetterAddress, activeMQServer)) {
MessagingLogger.ROOT_LOGGER.noMatchingDeadLetterAddress(deadLetterAddress.asString(), addressSetting);
}
}
private static boolean findMatchingResource(ModelNode addressNode, Resource activeMQServer) {
if (!addressNode.isDefined()) {
// do not search for a match if the address is not defined
return true;
}
final String address = addressNode.asString();
final String addressPrefix;
final String childType;
if (address.startsWith(JMS_QUEUE_ADDRESS_PREFIX)) {
// Jakarta Messaging Queue
childType = CommonAttributes.JMS_QUEUE;
addressPrefix = JMS_QUEUE_ADDRESS_PREFIX;
} else if (address.startsWith(JMS_TOPIC_ADDRESS_PREFIX)) {
// Jakarta Messaging Topic
childType = CommonAttributes.JMS_TOPIC;
addressPrefix = JMS_TOPIC_ADDRESS_PREFIX;
} else {
// Core Queue
childType = CommonAttributes.CORE_QUEUE;
// no special address prefix for core queues
addressPrefix = "";
}
for (String childName : activeMQServer.getChildrenNames(childType)) {
if (address.equals(addressPrefix + childName)) {
return true;
}
}
return false;
}
}
| 6,059
| 47.095238
| 171
|
java
|
null |
wildfly-main/messaging-activemq/subsystem/src/main/java/org/wildfly/extension/messaging/activemq/QueueControlHandler.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.wildfly.extension.messaging.activemq.OperationDefinitionHelper.createNonEmptyStringAttribute;
import static org.wildfly.extension.messaging.activemq.QueueDefinition.forwardToRuntimeQueue;
import static org.jboss.dmr.ModelType.INT;
import static org.jboss.dmr.ModelType.LONG;
import java.util.ArrayList;
import java.util.List;
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.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.operations.validation.AllowedValuesValidator;
import org.jboss.as.controller.operations.validation.ModelTypeValidator;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
/**
* Handler for runtime operations that invoke on a ActiveMQ {@link QueueControl}.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class QueueControlHandler extends AbstractQueueControlHandler<QueueControl> {
public static final QueueControlHandler INSTANCE = new QueueControlHandler();
private static final AttributeDefinition MESSAGE_ID = create(CommonAttributes.MESSAGE_ID, LONG)
.build();
private static class TypeValidator extends ModelTypeValidator implements AllowedValuesValidator {
private TypeValidator() {
super(ModelType.INT);
}
@Override
public List<ModelNode> getAllowedValues() {
List<ModelNode> values = new ArrayList<>();
values.add(ModelNode.ZERO);
values.add(new ModelNode(2));
values.add(new ModelNode(3));
values.add(new ModelNode(4));
values.add(new ModelNode(5));
values.add(new ModelNode(6));
return values;
}
}
private QueueControlHandler() {
}
@Override
protected AttributeDefinition getMessageIDAttributeDefinition() {
return MESSAGE_ID;
}
@Override
protected AttributeDefinition[] getReplyMessageParameterDefinitions() {
return new AttributeDefinition[] {
createNonEmptyStringAttribute("messageID"),
createNonEmptyStringAttribute("userID"),
createNonEmptyStringAttribute("address"),
create("type", INT)
.setValidator(new TypeValidator())
.build(),
create("durable", INT)
.build(),
create("expiration", LONG)
.build(),
create("priority", INT)
.setValidator(PRIORITY_VALIDATOR)
.build()
};
}
/*
* Do not check whether the queue resource exists.
*
* In the core queue resource does not exist, the {@link #executeRuntimeStep(org.jboss.as.controller.OperationContext, org.jboss.dmr.ModelNode)}
* will forward the operation to the corresponding runtime-queue.
*/
@Override
protected boolean resourceMustExist(OperationContext context, ModelNode operation) {
return false;
}
@Override
protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
if (forwardToRuntimeQueue(context, operation, INSTANCE)) {
} else {
super.executeRuntimeStep(context, operation);
}
}
@Override
protected Object handleAdditionalOperation(String operationName, ModelNode operation, OperationContext context,
QueueControl queueControl) throws OperationFailedException {
throwUnimplementedOperationException(operationName);
return null;
}
@Override
protected void revertAdditionalOperation(String operationName, ModelNode operation, OperationContext context, QueueControl queueControl, Object handback) {
// no-op
}
@Override
protected DelegatingQueueControl<QueueControl> getQueueControl(ActiveMQServer server, String queueName) {
final QueueControl control = QueueControl.class.cast(server.getManagementService().getResource(ResourceNames.QUEUE + queueName));
if (control == null) {
return null;
}
return new DelegatingQueueControl<QueueControl>() {
public QueueControl getDelegate() {
return control;
}
@Override
public String listMessagesAsJSON(String filter) throws Exception {
return control.listMessagesAsJSON(filter);
}
@Override
public long countMessages(String filter) throws Exception {
return control.countMessages(filter);
}
@Override
public boolean removeMessage(ModelNode id) throws Exception {
return control.removeMessage(id.asLong());
}
@Override
public int removeMessages(String filter) throws Exception {
return control.removeMessages(filter);
}
@Override
public int expireMessages(String filter) throws Exception {
return control.expireMessages(filter);
}
@Override
public boolean expireMessage(ModelNode id) throws Exception {
return control.expireMessage(id.asLong());
}
@Override
public boolean sendMessageToDeadLetterAddress(ModelNode id) throws Exception {
return control.sendMessageToDeadLetterAddress(id.asLong());
}
@Override
public int sendMessagesToDeadLetterAddress(String filter) throws Exception {
return control.sendMessagesToDeadLetterAddress(filter);
}
@Override
public boolean changeMessagePriority(ModelNode id, int priority) throws Exception {
return control.changeMessagePriority(id.asLong(), priority);
}
@Override
public int changeMessagesPriority(String filter, int priority) throws Exception {
return control.changeMessagesPriority(filter, priority);
}
@Override
public boolean moveMessage(ModelNode id, String otherQueue) throws Exception {
return control.moveMessage(id.asLong(), otherQueue);
}
@Override
public boolean moveMessage(ModelNode id, String otherQueue, boolean rejectDuplicates) throws Exception {
return control.moveMessage(id.asLong(), otherQueue, rejectDuplicates);
}
@Override
public int moveMessages(String filter, String otherQueue) throws Exception {
return control.moveMessages(filter, otherQueue);
}
@Override
public int moveMessages(String filter, String otherQueue, boolean rejectDuplicates) throws Exception {
return control.moveMessages(filter, otherQueue, rejectDuplicates);
}
@Override
public String listMessageCounter() throws Exception {
return control.listMessageCounter();
}
@Override
public void resetMessageCounter() throws Exception {
control.resetMessageCounter();
}
@Override
public String listMessageCounterAsHTML() throws Exception {
return control.listMessageCounterAsHTML();
}
@Override
public String listMessageCounterHistory() throws Exception {
return control.listMessageCounterHistory();
}
@Override
public String listMessageCounterHistoryAsHTML() throws Exception {
return control.listMessageCounterHistoryAsHTML();
}
@Override
public void pause() throws Exception {
control.pause();
}
@Override
public void resume() throws Exception {
control.resume();
}
@Override
public String listConsumersAsJSON() throws Exception {
return control.listConsumersAsJSON();
}
@Override
public String listScheduledMessagesAsJSON() throws Exception {
return control.listScheduledMessagesAsJSON();
}
@Override
public String listDeliveringMessagesAsJSON() throws Exception {
return control.listDeliveringMessagesAsJSON();
}
};
}
}
| 10,020
| 36.252788
| 159
|
java
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.