use of org.jboss.as.controller.parsing.ParseUtils.unexpectedElement in project wildfly by wildfly.
the class MessagingSubsystemParser method createConnectionFactory.
protected ModelNode createConnectionFactory(XMLExtendedStreamReader reader, ModelNode connectionFactory, boolean pooled) throws XMLStreamException {
Set<Element> seen = EnumSet.noneOf(Element.class);
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
if (!seen.add(element)) {
throw ParseUtils.duplicateNamedElement(reader, element.getLocalName());
}
switch(element) {
// elements common to regular & pooled connection factories
case DISCOVERY_GROUP_REF:
{
checkOtherElementIsNotAlreadyDefined(reader, seen, Element.DISCOVERY_GROUP_REF, Element.CONNECTORS);
final String groupRef = readStringAttributeElement(reader, Common.DISCOVERY_GROUP_NAME.getXmlName());
Common.DISCOVERY_GROUP_NAME.parseAndSetParameter(groupRef, connectionFactory, reader);
break;
}
case CONNECTORS:
{
checkOtherElementIsNotAlreadyDefined(reader, seen, Element.CONNECTORS, Element.DISCOVERY_GROUP_REF);
connectionFactory.get(CONNECTOR).set(processJmsConnectors(reader));
break;
}
case ENTRIES:
{
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element local = Element.forName(reader.getLocalName());
if (local != Element.ENTRY) {
throw ParseUtils.unexpectedElement(reader);
}
final String entry = readStringAttributeElement(reader, CommonAttributes.NAME);
Common.ENTRIES.parseAndAddParameterElement(entry, connectionFactory, reader);
}
break;
}
case HA:
case CLIENT_FAILURE_CHECK_PERIOD:
case CALL_TIMEOUT:
case CONSUMER_WINDOW_SIZE:
case CONSUMER_MAX_RATE:
case PRODUCER_WINDOW_SIZE:
case PRODUCER_MAX_RATE:
case CACHE_LARGE_MESSAGE_CLIENT:
case CLIENT_ID:
case DUPS_OK_BATCH_SIZE:
case TRANSACTION_BATH_SIZE:
case BLOCK_ON_ACK:
case BLOCK_ON_NON_DURABLE_SEND:
case BLOCK_ON_DURABLE_SEND:
case AUTO_GROUP:
case PRE_ACK:
case FAILOVER_ON_INITIAL_CONNECTION:
case FAILOVER_ON_SERVER_SHUTDOWN:
case LOAD_BALANCING_CLASS_NAME:
case USE_GLOBAL_POOLS:
case GROUP_ID:
handleElementText(reader, element, connectionFactory);
break;
case CONFIRMATION_WINDOW_SIZE:
case CONNECTION_TTL:
case MAX_RETRY_INTERVAL:
case MIN_LARGE_MESSAGE_SIZE:
case RECONNECT_ATTEMPTS:
case RETRY_INTERVAL:
case RETRY_INTERVAL_MULTIPLIER:
case SCHEDULED_THREAD_POOL_MAX_SIZE:
case THREAD_POOL_MAX_SIZE:
// Use the "connection" variant
handleElementText(reader, element, "connection", connectionFactory);
break;
case DISCOVERY_INITIAL_WAIT_TIMEOUT:
MessagingLogger.ROOT_LOGGER.deprecatedXMLElement(element.toString());
skipElementText(reader);
break;
// elements specific to regular (non-pooled) connection factories
case CONNECTION_FACTORY_TYPE:
if (pooled) {
throw unexpectedElement(reader);
}
handleElementText(reader, element, connectionFactory);
break;
// elements specific to pooled connection factories
case INBOUND_CONFIG:
{
if (!pooled) {
throw unexpectedElement(reader);
}
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element local = Element.forName(reader.getLocalName());
switch(local) {
case USE_JNDI:
case JNDI_PARAMS:
case USE_LOCAL_TX:
case SETUP_ATTEMPTS:
case SETUP_INTERVAL:
handleElementText(reader, local, connectionFactory);
break;
default:
throw unexpectedElement(reader);
}
}
break;
}
case TRANSACTION:
{
if (!pooled) {
throw ParseUtils.unexpectedElement(reader);
}
final String txType = reader.getAttributeValue(0);
if (txType != null) {
connectionFactory.get(Pooled.TRANSACTION.getName()).set(txType);
}
ParseUtils.requireNoContent(reader);
break;
}
case USER:
if (!pooled) {
throw unexpectedElement(reader);
}
// Element name is overloaded, handleElementText can not be used, we must use the correct attribute
Pooled.USER.parseAndSetParameter(reader.getElementText(), connectionFactory, reader);
break;
case PASSWORD:
if (!pooled) {
throw unexpectedElement(reader);
}
// Element name is overloaded, handleElementText can not be used, we must use the correct attribute
Pooled.PASSWORD.parseAndSetParameter(reader.getElementText(), connectionFactory, reader);
break;
// =========================================================
default:
{
handleUnknownConnectionFactoryAttribute(reader, element, connectionFactory, pooled);
}
}
}
checkOnlyOneOfElements(reader, seen, Element.CONNECTORS, Element.DISCOVERY_GROUP_REF);
return connectionFactory;
}
use of org.jboss.as.controller.parsing.ParseUtils.unexpectedElement in project wildfly by wildfly.
the class MessagingSubsystemParser method processConnectors.
void processConnectors(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> updates) throws XMLStreamException {
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
String name = null;
String socketBinding = null;
String serverId = null;
int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String attrValue = reader.getAttributeValue(i);
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch(attribute) {
case NAME:
{
name = attrValue;
break;
}
case SOCKET_BINDING:
{
socketBinding = attrValue;
break;
}
case SERVER_ID:
{
serverId = attrValue;
break;
}
default:
{
throw ParseUtils.unexpectedAttribute(reader, i);
}
}
}
if (name == null) {
throw missingRequired(reader, Collections.singleton(Attribute.NAME));
}
final ModelNode connectorAddress = address.clone();
final ModelNode operation = new ModelNode();
operation.get(OP).set(ADD);
boolean generic = false;
final Element element = Element.forName(reader.getLocalName());
switch(element) {
case CONNECTOR:
{
operation.get(OP_ADDR).set(connectorAddress.add(CONNECTOR, name));
if (socketBinding != null) {
operation.get(RemoteTransportDefinition.SOCKET_BINDING.getName()).set(socketBinding);
}
generic = true;
break;
}
case NETTY_CONNECTOR:
{
operation.get(OP_ADDR).set(connectorAddress.add(REMOTE_CONNECTOR, name));
if (socketBinding == null) {
throw missingRequired(reader, Collections.singleton(Attribute.SOCKET_BINDING));
}
operation.get(RemoteTransportDefinition.SOCKET_BINDING.getName()).set(socketBinding);
break;
}
case IN_VM_CONNECTOR:
{
operation.get(OP_ADDR).set(connectorAddress.add(IN_VM_CONNECTOR, name));
if (serverId != null) {
InVMTransportDefinition.SERVER_ID.parseAndSetParameter(serverId, operation, reader);
}
break;
}
default:
{
throw ParseUtils.unexpectedElement(reader);
}
}
updates.add(operation);
parseTransportConfiguration(reader, operation, generic, updates);
}
}
use of org.jboss.as.controller.parsing.ParseUtils.unexpectedElement in project wildfly by wildfly.
the class MailSubsystemParser method parseCustomServerConfig.
private void parseCustomServerConfig(final XMLExtendedStreamReader reader, final PathAddress parent, List<ModelNode> list) throws XMLStreamException {
final ModelNode operation = Util.createAddOperation(parent);
list.add(operation);
String name = null;
for (int i = 0; i < reader.getAttributeCount(); i++) {
Attribute attr = Attribute.forName(reader.getAttributeLocalName(i));
String value = reader.getAttributeValue(i);
if (attr == Attribute.OUTBOUND_SOCKET_BINDING_REF) {
OUTBOUND_SOCKET_BINDING_REF_OPTIONAL.parseAndSetParameter(value, operation, reader);
} else if (attr == Attribute.SSL) {
SSL.parseAndSetParameter(value, operation, reader);
} else if (attr == Attribute.TLS) {
TLS.parseAndSetParameter(value, operation, reader);
} else if (attr == Attribute.NAME) {
name = value;
} else {
throw ParseUtils.unexpectedAttribute(reader, i);
}
}
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
switch(element) {
case LOGIN:
{
for (int i = 0; i < reader.getAttributeCount(); i++) {
String att = reader.getAttributeLocalName(i);
String value = reader.getAttributeValue(i);
if (att.equals(Attribute.USERNAME.getLocalName())) {
MailServerDefinition.USERNAME.parseAndSetParameter(value, operation, reader);
} else if (att.equals(Attribute.PASSWORD.getLocalName())) {
PASSWORD.parseAndSetParameter(value, operation, reader);
}
}
ParseUtils.requireNoContent(reader);
break;
}
case PROPERTY:
{
final String[] array = requireAttributes(reader, org.jboss.as.controller.parsing.Attribute.NAME.getLocalName(), org.jboss.as.controller.parsing.Attribute.VALUE.getLocalName());
MailServerDefinition.PROPERTIES.parseAndAddParameterElement(array[0], array[1], operation, reader);
ParseUtils.requireNoContent(reader);
break;
}
default:
{
throw ParseUtils.unexpectedElement(reader);
}
}
}
if (name == null) {
throw ParseUtils.missingRequired(reader, EnumSet.of(Attribute.NAME));
}
PathAddress address = parent.append(MailSubsystemModel.CUSTOM, name);
operation.get(OP_ADDR).set(address.toModelNode());
}
use of org.jboss.as.controller.parsing.ParseUtils.unexpectedElement in project wildfly by wildfly.
the class MessagingSubsystemParser method processStaticConnectors.
protected void processStaticConnectors(XMLExtendedStreamReader reader, ModelNode addOperation, boolean cluster) throws XMLStreamException {
if (cluster) {
int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch(attribute) {
case ALLOW_DIRECT_CONNECTIONS_ONLY:
{
final String attrValue = reader.getAttributeValue(i);
ClusterConnectionDefinition.ALLOW_DIRECT_CONNECTIONS_ONLY.parseAndSetParameter(attrValue, addOperation, reader);
break;
}
default:
{
throw ParseUtils.unexpectedAttribute(reader, i);
}
}
}
} else {
requireNoAttributes(reader);
}
EnumSet<Element> required = EnumSet.of(Element.CONNECTOR_REF);
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
required.remove(element);
switch(element) {
case CONNECTOR_REF:
{
handleElementText(reader, element, cluster ? "cluster-connection" : "bridge", addOperation);
break;
}
default:
{
throw ParseUtils.unexpectedElement(reader);
}
}
}
if (!required.isEmpty()) {
throw missingRequired(reader, required);
}
}
use of org.jboss.as.controller.parsing.ParseUtils.unexpectedElement in project wildfly by wildfly.
the class MessagingSubsystemParser method parseDivert.
private static void parseDivert(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list) throws XMLStreamException {
requireSingleAttribute(reader, CommonAttributes.NAME);
String name = reader.getAttributeValue(0);
ModelNode divertAdd = org.jboss.as.controller.operations.common.Util.getEmptyOperation(ADD, address.clone().add(CommonAttributes.DIVERT, name));
EnumSet<Element> required = EnumSet.of(Element.ADDRESS, Element.FORWARDING_ADDRESS);
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
required.remove(element);
switch(element) {
case ROUTING_NAME:
{
handleElementText(reader, element, divertAdd);
break;
}
case ADDRESS:
{
handleElementText(reader, element, DivertDefinition.ADDRESS.getName(), divertAdd);
break;
}
case FORWARDING_ADDRESS:
{
handleElementText(reader, element, "divert", divertAdd);
break;
}
case FILTER:
{
String string = readStringAttributeElement(reader, CommonAttributes.STRING);
FILTER.parseAndSetParameter(string, divertAdd, reader);
break;
}
case TRANSFORMER_CLASS_NAME:
{
handleElementText(reader, element, divertAdd);
break;
}
case EXCLUSIVE:
{
handleElementText(reader, element, divertAdd);
break;
}
default:
{
throw ParseUtils.unexpectedElement(reader);
}
}
}
if (!required.isEmpty()) {
throw missingRequired(reader, required);
}
list.add(divertAdd);
}
Aggregations