use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class ExternalPooledConnectionFactoryAdd method performRuntime.
@Override
protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
ModelNode model = resource.getModel();
PathAddress address = context.getCurrentAddress();
final String name = context.getCurrentAddressValue();
final ModelNode resolvedModel = model.clone();
for (final AttributeDefinition attribute : attributes) {
resolvedModel.get(attribute.getName()).set(attribute.resolveModelAttribute(context, resolvedModel));
}
// We validated that jndiName part of the model in populateModel
final List<String> jndiNames = new ArrayList<>();
for (ModelNode node : resolvedModel.get(Common.ENTRIES.getName()).asList()) {
jndiNames.add(node.asString());
}
final BindInfo bindInfo = ContextNames.bindInfoFor(jndiNames.get(0));
List<String> jndiAliases;
if (jndiNames.size() > 1) {
jndiAliases = new ArrayList<>(jndiNames.subList(1, jndiNames.size()));
} else {
jndiAliases = Collections.emptyList();
}
String managedConnectionPoolClassName = resolvedModel.get(ConnectionFactoryAttributes.Pooled.MANAGED_CONNECTION_POOL.getName()).asStringOrNull();
final int minPoolSize = resolvedModel.get(ConnectionFactoryAttributes.Pooled.MIN_POOL_SIZE.getName()).asInt();
final int maxPoolSize = resolvedModel.get(ConnectionFactoryAttributes.Pooled.MAX_POOL_SIZE.getName()).asInt();
Boolean enlistmentTrace = resolvedModel.get(ConnectionFactoryAttributes.Pooled.ENLISTMENT_TRACE.getName()).asBooleanOrNull();
String txSupport = getTxSupport(resolvedModel);
List<String> connectors = Common.CONNECTORS.unwrap(context, model);
String discoveryGroupName = getDiscoveryGroup(resolvedModel);
String jgroupClusterName = null;
String jgroupsChannelName = null;
final PathAddress serverAddress = MessagingServices.getActiveMQServerPathAddress(address);
if (discoveryGroupName != null) {
Resource dgResource;
if (isSubsystemResource(context)) {
PathAddress dgAddress = address.getParent().append(CommonAttributes.SOCKET_DISCOVERY_GROUP, discoveryGroupName);
try {
dgResource = context.readResourceFromRoot(dgAddress, false);
} catch (Resource.NoSuchResourceException ex) {
dgAddress = address.getParent().append(CommonAttributes.JGROUPS_DISCOVERY_GROUP, discoveryGroupName);
dgResource = context.readResourceFromRoot(dgAddress, false);
}
} else {
PathAddress dgAddress = serverAddress.append(CommonAttributes.SOCKET_DISCOVERY_GROUP, discoveryGroupName);
try {
dgResource = context.readResourceFromRoot(dgAddress, false);
} catch (Resource.NoSuchResourceException ex) {
dgAddress = address.getParent().append(CommonAttributes.JGROUPS_DISCOVERY_GROUP, discoveryGroupName);
dgResource = context.readResourceFromRoot(dgAddress, false);
}
}
ModelNode dgModel = dgResource.getModel();
ModelNode jgroupCluster = JGROUPS_CLUSTER.resolveModelAttribute(context, dgModel);
if (jgroupCluster.isDefined()) {
jgroupClusterName = jgroupCluster.asString();
ModelNode channel = DiscoveryGroupDefinition.JGROUPS_CHANNEL.resolveModelAttribute(context, dgModel);
if (channel.isDefined()) {
jgroupsChannelName = channel.asString();
}
}
}
List<PooledConnectionFactoryConfigProperties> adapterParams = PooledConnectionFactoryAdd.getAdapterParams(resolvedModel, context, ExternalPooledConnectionFactoryDefinition.ATTRIBUTES);
DiscoveryGroupConfiguration discoveryGroupConfiguration = null;
if (discoveryGroupName != null) {
discoveryGroupConfiguration = ExternalConnectionFactoryAdd.getDiscoveryGroup(context, discoveryGroupName);
}
Set<String> connectorsSocketBindings = new HashSet<>();
TransportConfiguration[] transportConfigurations = TransportConfigOperationHandlers.processConnectors(context, connectors, connectorsSocketBindings);
ExternalPooledConnectionFactoryService.installService(context, name, transportConfigurations, discoveryGroupConfiguration, connectorsSocketBindings, jgroupClusterName, jgroupsChannelName, adapterParams, bindInfo, jndiAliases, txSupport, minPoolSize, maxPoolSize, managedConnectionPoolClassName, enlistmentTrace, model);
boolean statsEnabled = ConnectionFactoryAttributes.Pooled.STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean();
if (statsEnabled) {
// Add the stats resource. This is kind of a hack as we are modifying the resource
// in runtime, but oh well. We don't use readResourceForUpdate for this reason.
// This only runs in this add op anyway, and because it's an add we know readResource
// is going to be returning the current write snapshot of the model, i.e. the one we want
PooledConnectionFactoryStatisticsService.registerStatisticsResources(resource);
installStatistics(context, name);
}
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class PooledConnectionFactoryDefinition method define.
// the generation of the Pooled CF attributes is a bit ugly but it is with purpose:
// * factorize the attributes which are common between the regular CF and the pooled CF
// * keep in a single place the subtle differences (e.g. different default values for reconnect-attempts between
// the regular and pooled CF
private static ConnectionFactoryAttribute[] define(ConnectionFactoryAttribute[] specific, ConnectionFactoryAttribute... common) {
int size = common.length + specific.length;
ConnectionFactoryAttribute[] result = new ConnectionFactoryAttribute[size];
arraycopy(specific, 0, result, 0, specific.length);
for (int i = 0; i < common.length; i++) {
ConnectionFactoryAttribute attr = common[i];
AttributeDefinition definition = attr.getDefinition();
ConnectionFactoryAttribute newAttr;
// replace the reconnect-attempts attribute to use a different default value for pooled CF
if (definition == Common.RECONNECT_ATTEMPTS) {
AttributeDefinition copy = copy(Pooled.RECONNECT_ATTEMPTS, AttributeAccess.Flag.RESTART_ALL_SERVICES);
newAttr = ConnectionFactoryAttribute.create(copy, Pooled.RECONNECT_ATTEMPTS_PROP_NAME, true);
} else if (definition == Common.CONNECTORS) {
StringListAttributeDefinition copy = new StringListAttributeDefinition.Builder(Common.CONNECTORS).setAlternatives(CommonAttributes.DISCOVERY_GROUP).setRequired(true).setAttributeParser(AttributeParser.STRING_LIST).setAttributeMarshaller(AttributeMarshaller.STRING_LIST).setCapabilityReference(new AbstractTransportDefinition.TransportCapabilityReferenceRecorder(CAPABILITY_NAME, CONNECTOR_CAPABILITY_NAME, false)).setRestartAllServices().build();
newAttr = ConnectionFactoryAttribute.create(copy, attr.getPropertyName(), attr.isResourceAdapterProperty(), attr.getConfigType());
} else {
AttributeDefinition copy = copy(definition, AttributeAccess.Flag.RESTART_ALL_SERVICES);
newAttr = ConnectionFactoryAttribute.create(copy, attr.getPropertyName(), attr.isResourceAdapterProperty(), attr.getConfigType());
}
result[specific.length + i] = newAttr;
}
return result;
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class TransactionSubsystemAdd method populateModel.
@Override
protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException {
populateModelWithRecoveryEnvConfig(operation, model);
populateModelWithCoreEnvConfig(operation, model);
populateModelWithCoordinatorEnvConfig(operation, model);
populateModelWithObjectStoreConfig(operation, model);
TransactionSubsystemRootResourceDefinition.JTS.validateAndSet(operation, model);
validateStoreConfig(operation, model);
TransactionSubsystemRootResourceDefinition.USE_JOURNAL_STORE.validateAndSet(operation, model);
for (AttributeDefinition ad : TransactionSubsystemRootResourceDefinition.attributes_1_2) {
ad.validateAndSet(operation, model);
}
TransactionSubsystemRootResourceDefinition.JOURNAL_STORE_ENABLE_ASYNC_IO.validateAndSet(operation, model);
TransactionSubsystemRootResourceDefinition.STALE_TRANSACTION_TIME.validateAndSet(operation, model);
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class Filter method createHttpHandler.
public HttpHandler createHttpHandler(final Predicate predicate, final ModelNode model, HttpHandler next) {
List<AttributeDefinition> attributes = new ArrayList<>(getAttributes());
HttpHandler handler = createHandler(getHandlerClass(), model, attributes, next);
if (predicate != null) {
return Handlers.predicate(predicate, handler, next);
} else {
return handler;
}
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class MessagingSubsystem30TestCase method doTestRejectExpressions_2_0_0_or_2_1_0.
/**
* Tests rejection of expressions in either 2.0.0 or 2.1.0 model.
*/
private void doTestRejectExpressions_2_0_0_or_2_1_0(KernelServicesBuilder builder, ModelVersion version) throws Exception {
KernelServices mainServices = builder.build();
assertTrue(mainServices.isSuccessfulBoot());
KernelServices legacyServices = mainServices.getLegacyServices(version);
assertNotNull(legacyServices);
assertTrue(legacyServices.isSuccessfulBoot());
//Use the real xml with expressions for testing all the attributes
PathAddress subsystemAddress = PathAddress.pathAddress(pathElement(SUBSYSTEM, MessagingExtension.SUBSYSTEM_NAME));
List<ModelNode> modelNodes = builder.parseXmlResource("subsystem_3_0_expressions.xml");
modelNodes.remove(0);
checkFailedTransformedBootOperations(mainServices, version, modelNodes, new FailedOperationTransformationConfig().addFailedAttribute(subsystemAddress.append(HORNETQ_SERVER_PATH), createChainedConfig(new AttributeDefinition[] {}, new AttributeDefinition[] { OVERRIDE_IN_VM_SECURITY })).addFailedAttribute(subsystemAddress.append(HORNETQ_SERVER_PATH).append(AddressSettingDefinition.PATH), createChainedConfig(new AttributeDefinition[] {}, new AttributeDefinition[] { AddressSettingDefinition.MAX_REDELIVERY_DELAY, AddressSettingDefinition.REDELIVERY_MULTIPLIER, AddressSettingDefinition.SLOW_CONSUMER_CHECK_PERIOD, AddressSettingDefinition.SLOW_CONSUMER_POLICY, AddressSettingDefinition.SLOW_CONSUMER_THRESHOLD })));
}
Aggregations