use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class MessagingXMLWriter method writeConnectorServices.
private static void writeConnectorServices(XMLExtendedStreamWriter writer, ModelNode node) throws XMLStreamException {
if (!node.isDefined()) {
return;
}
List<Property> properties = node.asPropertyList();
if (!properties.isEmpty()) {
writer.writeStartElement(Element.CONNECTOR_SERVICES.getLocalName());
for (final Property property : node.asPropertyList()) {
writer.writeStartElement(Element.CONNECTOR_SERVICE.getLocalName());
writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
final ModelNode service = property.getValue();
for (AttributeDefinition attribute : ConnectorServiceDefinition.ATTRIBUTES) {
attribute.marshallAsElement(property.getValue(), writer);
}
// TODO use a custom attribute marshaller
if (service.hasDefined(CommonAttributes.PARAM)) {
for (Property param : service.get(CommonAttributes.PARAM).asPropertyList()) {
writer.writeEmptyElement(Element.PARAM.getLocalName());
writer.writeAttribute(Attribute.KEY.getLocalName(), param.getName());
writer.writeAttribute(Attribute.VALUE.getLocalName(), param.getValue().get(ConnectorServiceParamDefinition.VALUE.getName()).asString());
}
}
writer.writeEndElement();
}
writer.writeEndElement();
writeNewLine(writer);
}
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class MessagingXMLWriter method writeBroadcastGroups.
private static void writeBroadcastGroups(final XMLExtendedStreamWriter writer, final ModelNode node) throws XMLStreamException {
if (!node.isDefined()) {
return;
}
List<Property> properties = node.asPropertyList();
if (!properties.isEmpty()) {
writer.writeStartElement(Element.BROADCAST_GROUPS.getLocalName());
for (final Property property : properties) {
writer.writeStartElement(Element.BROADCAST_GROUP.getLocalName());
writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
for (AttributeDefinition attribute : BroadcastGroupDefinition.ATTRIBUTES) {
attribute.marshallAsElement(property.getValue(), writer);
}
writer.writeEndElement();
}
writer.writeEndElement();
writeNewLine(writer);
}
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class MessagingXMLWriter method writeAddressSettings.
private static void writeAddressSettings(final XMLExtendedStreamWriter writer, final ModelNode node) throws XMLStreamException {
if (!node.isDefined()) {
return;
}
List<Property> properties = node.asPropertyList();
if (!properties.isEmpty()) {
writer.writeStartElement(Element.ADDRESS_SETTINGS.getLocalName());
for (Property matchSetting : properties) {
writer.writeStartElement(Element.ADDRESS_SETTING.getLocalName());
writer.writeAttribute(Attribute.MATCH.getLocalName(), matchSetting.getName());
final ModelNode setting = matchSetting.getValue();
for (AttributeDefinition attribute : AddressSettingDefinition.ATTRIBUTES) {
attribute.marshallAsElement(setting, writer);
}
writer.writeEndElement();
}
writer.writeEndElement();
writeNewLine(writer);
}
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class PooledConnectionFactoryAdd 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 : getDefinitions(PooledConnectionFactoryDefinition.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<String>();
for (ModelNode node : resolvedModel.get(Common.ENTRIES.getName()).asList()) {
jndiNames.add(node.asString());
}
String managedConnectionPoolClassName = null;
if (resolvedModel.hasDefined(ConnectionFactoryAttributes.Pooled.MANAGED_CONNECTION_POOL.getName())) {
managedConnectionPoolClassName = resolvedModel.get(ConnectionFactoryAttributes.Pooled.MANAGED_CONNECTION_POOL.getName()).asString();
}
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 = null;
if (resolvedModel.hasDefined(ConnectionFactoryAttributes.Pooled.ENLISTMENT_TRACE.getName())) {
enlistmentTrace = resolvedModel.get(ConnectionFactoryAttributes.Pooled.ENLISTMENT_TRACE.getName()).asBoolean();
}
final String txSupport;
if (resolvedModel.hasDefined(ConnectionFactoryAttributes.Pooled.TRANSACTION.getName())) {
String txType = resolvedModel.get(ConnectionFactoryAttributes.Pooled.TRANSACTION.getName()).asString();
if (LOCAL.equals(txType)) {
txSupport = LOCAL_TX;
} else if (NONE.equals(txType)) {
txSupport = NO_TX;
} else {
txSupport = XA_TX;
}
} else {
txSupport = XA_TX;
}
ServiceTarget serviceTarget = context.getServiceTarget();
List<String> connectors = Common.CONNECTORS.unwrap(context, model);
String discoveryGroupName = getDiscoveryGroup(resolvedModel);
String jgroupsChannelName = null;
if (discoveryGroupName != null) {
Resource dgResource = context.readResourceFromRoot(MessagingServices.getActiveMQServerPathAddress(address).append(CommonAttributes.DISCOVERY_GROUP, discoveryGroupName));
ModelNode dgModel = dgResource.getModel();
jgroupsChannelName = JGROUPS_CHANNEL.resolveModelAttribute(context, dgModel).asString();
}
List<PooledConnectionFactoryConfigProperties> adapterParams = getAdapterParams(resolvedModel, context);
final PathAddress serverAddress = MessagingServices.getActiveMQServerPathAddress(address);
PooledConnectionFactoryService.installService(serviceTarget, name, serverAddress.getLastElement().getValue(), connectors, discoveryGroupName, jgroupsChannelName, adapterParams, jndiNames, txSupport, minPoolSize, maxPoolSize, managedConnectionPoolClassName, enlistmentTrace);
boolean statsEnabled = ConnectionFactoryAttributes.Pooled.STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean();
if (statsEnabled) {
installStatistics(context, name);
}
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class PooledConnectionFactoryAdd method getAdapterParams.
static List<PooledConnectionFactoryConfigProperties> getAdapterParams(ModelNode model, OperationContext context) throws OperationFailedException {
List<PooledConnectionFactoryConfigProperties> configs = new ArrayList<PooledConnectionFactoryConfigProperties>();
for (ConnectionFactoryAttribute nodeAttribute : PooledConnectionFactoryDefinition.ATTRIBUTES) {
if (!nodeAttribute.isResourceAdapterProperty())
continue;
AttributeDefinition definition = nodeAttribute.getDefinition();
ModelNode node = definition.resolveModelAttribute(context, model);
if (node.isDefined()) {
String value = node.asString();
configs.add(new PooledConnectionFactoryConfigProperties(nodeAttribute.getPropertyName(), value, nodeAttribute.getClassType()));
}
}
return configs;
}
Aggregations