本文整理汇总了Java中org.jboss.as.controller.parsing.ParseUtils.missingRequired方法的典型用法代码示例。如果您正苦于以下问题:Java ParseUtils.missingRequired方法的具体用法?Java ParseUtils.missingRequired怎么用?Java ParseUtils.missingRequired使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.as.controller.parsing.ParseUtils
的用法示例。
在下文中一共展示了ParseUtils.missingRequired方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseChild
import org.jboss.as.controller.parsing.ParseUtils; //导入方法依赖的package包/类
private ModelNode parseChild(XMLExtendedStreamReader reader) throws XMLStreamException {
ModelNode add = null;
int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
final String attribute = reader.getAttributeLocalName(i);
switch (attribute) {
case "name": {
add = Util.createAddOperation(PathAddress.pathAddress(
PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, SUBSYSTEM_NAME),
PathElement.pathElement("child", value)));
break;
}
default: {
throw ParseUtils.unexpectedAttribute(reader, i);
}
}
}
if (add == null) {
throw ParseUtils.missingRequired(reader, Collections.singleton("child"));
}
// Require no content
ParseUtils.requireNoContent(reader);
return add;
}
示例2: prepareOperation
import org.jboss.as.controller.parsing.ParseUtils; //导入方法依赖的package包/类
public static void prepareOperation(String address, XMLExtendedStreamReader reader, List<ModelNode> list, ModelNode parent)
throws XMLStreamException {
String jndiName = null;
final ModelNode operation = new ModelNode();
for (int i = 0; i < reader.getAttributeCount(); i++) {
String value = reader.getAttributeValue(i);
String attributeName = reader.getAttributeLocalName(i);
if (attributeName.equals(ModelConstants.HOST)) {
Attributes.HOST.parseAndSetParameter(value, operation, reader);
} else if (attributeName.equals(ModelConstants.PORT)) {
Attributes.PORT.parseAndSetParameter(value, operation, reader);
} else if (attributeName.equals(ModelConstants.JNDI_NAME)) {
Attributes.JNDI_NAME.parseAndSetParameter(value, operation, reader);
jndiName = value;
} else {
throw ParseUtils.unexpectedElement(reader);
}
}
if (jndiName == null) {
throw ParseUtils.missingRequired(reader, Collections.singleton(ModelConstants.JNDI_NAME));
}
final ModelNode dsAddress = parent.clone();
dsAddress.add(address, jndiName);
dsAddress.protect();
operation.get(OP_ADDR).set(dsAddress);
operation.get(OP).set(ADD);
list.add(operation);
}
示例3: parseConnector
import org.jboss.as.controller.parsing.ParseUtils; //导入方法依赖的package包/类
void parseConnector(XMLExtendedStreamReader reader) throws XMLStreamException {
JmxLogger.ROOT_LOGGER.jmxConnectorNotSupported();
String serverBinding = null;
String registryBinding = null;
int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
final String attribute = reader.getAttributeLocalName(i);
switch (attribute) {
case CommonAttributes.SERVER_BINDING: {
serverBinding = value;
break;
}
case CommonAttributes.REGISTRY_BINDING: {
registryBinding = value;
break;
}
default: {
throw ParseUtils.unexpectedAttribute(reader, i);
}
}
}
// Require no content
ParseUtils.requireNoContent(reader);
if (serverBinding == null) {
throw ParseUtils.missingRequired(reader, Collections.singleton(CommonAttributes.SERVER_BINDING));
}
if (registryBinding == null) {
throw ParseUtils.missingRequired(reader, Collections.singleton(CommonAttributes.REGISTRY_BINDING));
}
}
示例4: parseAuditLogHandler
import org.jboss.as.controller.parsing.ParseUtils; //导入方法依赖的package包/类
private void parseAuditLogHandler(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException {
String name = null;
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
final String attribute = reader.getAttributeLocalName(i);
switch (attribute) {
case NAME:
name = value;
break;
default:
throw ParseUtils.unexpectedAttribute(reader, i);
}
}
if (name == null) {
throw ParseUtils.missingRequired(reader, Collections.singleton(NAME));
}
ModelNode op = createOperation(ADD,
JmxAuditLoggerResourceDefinition.PATH_ELEMENT.getKey(),
JmxAuditLoggerResourceDefinition.PATH_ELEMENT.getValue(),
JmxAuditLogHandlerReferenceResourceDefinition.PATH_ELEMENT.getKey(), name);
list.add(op);
ParseUtils.requireNoContent(reader);
}
示例5: parseAgentPath
import org.jboss.as.controller.parsing.ParseUtils; //导入方法依赖的package包/类
private static void parseAgentPath(final XMLExtendedStreamReader reader, ModelNode addOp)
throws XMLStreamException {
// Handle attributes
boolean valueSet = false;
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
if (!isNoNamespaceAttribute(reader, i)) {
throw ParseUtils.unexpectedAttribute(reader, i);
} else {
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case VALUE: {
if (checkParseAndSetParameter(JvmAttributes.AGENT_PATH, value, addOp, reader)){
throw ParseUtils.duplicateNamedElement(reader, reader.getLocalName());
}
valueSet = true;
break;
}
default:
throw ParseUtils.unexpectedAttribute(reader, i);
}
}
}
if (!valueSet) {
throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.VALUE));
}
// Handle elements
requireNoContent(reader);
}
示例6: parsePrincipal
import org.jboss.as.controller.parsing.ParseUtils; //导入方法依赖的package包/类
private void parsePrincipal(final XMLExtendedStreamReader reader, final ModelNode parentAddress, final String incExcType, final String principalType,
final List<ModelNode> list) throws XMLStreamException {
String alias = null;
String realm = null;
String name = null;
ModelNode addOp = new ModelNode();
addOp.get(OP).set(ADD);
addOp.get(TYPE).set(principalType);
int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
if (!isNoNamespaceAttribute(reader, i)) {
throw unexpectedAttribute(reader, i);
} else {
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case ALIAS: {
alias = value;
break;
}
case NAME: {
name = value;
PrincipalResourceDefinition.NAME.parseAndSetParameter(value, addOp, reader);
break;
}
case REALM: {
realm = value;
PrincipalResourceDefinition.REALM.parseAndSetParameter(value, addOp, reader);
break;
}
default: {
throw unexpectedAttribute(reader, i);
}
}
}
}
if (name == null) {
throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.NAME));
}
String addrValue = alias == null ? generateAlias(principalType, name, realm) : alias;
ModelNode addAddr = parentAddress.clone().add(incExcType, addrValue);
addOp.get(OP_ADDR).set(addAddr);
list.add(addOp);
ParseUtils.requireNoContent(reader);
}
示例7: parseClassificationType
import org.jboss.as.controller.parsing.ParseUtils; //导入方法依赖的package包/类
private void parseClassificationType(final XMLExtendedStreamReader reader, final ModelNode address,
final List<ModelNode> list, boolean vault) throws XMLStreamException {
final int count = reader.getAttributeCount();
String name = null;
String type = null;
Map<String, ModelNode> values = new HashMap<String, ModelNode>();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
if (!isNoNamespaceAttribute(reader, i)) {
throw unexpectedAttribute(reader, i);
} else {
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case NAME: {
name = value;
break;
}
case TYPE: {
type = value;
break;
}
case REQUIRES_READ: {
values.put(SensitivityResourceDefinition.CONFIGURED_REQUIRES_READ.getName(),
SensitivityResourceDefinition.CONFIGURED_REQUIRES_READ.parse(value, reader));
break;
}
case REQUIRES_WRITE: {
values.put(SensitivityResourceDefinition.CONFIGURED_REQUIRES_WRITE.getName(),
SensitivityResourceDefinition.CONFIGURED_REQUIRES_WRITE.parse(value, reader));
break;
}
case REQUIRES_ADDRESSABLE: {
if (!vault) {
values.put(SensitivityResourceDefinition.CONFIGURED_REQUIRES_ADDRESSABLE.getName(),
SensitivityResourceDefinition.CONFIGURED_REQUIRES_ADDRESSABLE.parse(value, reader));
break;
}
}
default: {
throw unexpectedAttribute(reader, i);
}
}
}
}
if (name == null && !vault) {
throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.NAME));
}
if (type == null && !vault) {
throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.TYPE));
}
final ModelNode newAddress = vault ? address :
address.clone()
.add(SensitivityClassificationTypeResourceDefinition.PATH_ELEMENT.getKey(), type)
.add(SensitivityResourceDefinition.PATH_ELEMENT.getKey(), name);
for (Map.Entry<String, ModelNode> entry : values.entrySet()) {
list.add(Util.getWriteAttributeOperation(newAddress, entry.getKey(), entry.getValue()));
}
ParseUtils.requireNoContent(reader);
}
示例8: parseApplicationClassification
import org.jboss.as.controller.parsing.ParseUtils; //导入方法依赖的package包/类
private void parseApplicationClassification(final XMLExtendedStreamReader reader, final ModelNode address,
final List<ModelNode> list) throws XMLStreamException {
String name = null;
String type = null;
Boolean applicationValue = null;
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
if (!isNoNamespaceAttribute(reader, i)) {
throw unexpectedAttribute(reader, i);
} else {
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case NAME:
name = value;
break;
case TYPE:
type = value;
break;
case APPLICATION:
applicationValue = Boolean.valueOf(value);
break;
default: {
throw unexpectedAttribute(reader, i);
}
}
}
}
if (name == null) {
throw ParseUtils.missingRequired(reader, Collections.singleton(NAME));
}
if (type == null) {
throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.TYPE));
}
if (applicationValue == null) {
throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.APPLICATION));
}
ModelNode newAddress = address.clone()
.add(ApplicationClassificationTypeResourceDefinition.PATH_ELEMENT.getKey(), type)
.add(ApplicationClassificationConfigResourceDefinition.PATH_ELEMENT.getKey(), name);
list.add(Util.getWriteAttributeOperation(newAddress, ApplicationClassificationConfigResourceDefinition.CONFIGURED_APPLICATION.getName(), applicationValue.toString()));
ParseUtils.requireNoContent(reader);
}
示例9: parseIgnoredResource
import org.jboss.as.controller.parsing.ParseUtils; //导入方法依赖的package包/类
private void parseIgnoredResource(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list, final Set<String> foundTypes) throws XMLStreamException {
ModelNode op = new ModelNode();
op.get(OP).set(ADD);
String type = null;
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
if (!isNoNamespaceAttribute(reader, i)) {
throw unexpectedAttribute(reader, i);
}
final String value = reader.getAttributeValue(i);
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case TYPE: {
if (!foundTypes.add(value)) {
throw HostControllerLogger.ROOT_LOGGER.duplicateIgnoredResourceType(Element.IGNORED_RESOURCE.getLocalName(), value, reader.getLocation());
}
type = value;
break;
}
case WILDCARD: {
IgnoredDomainTypeResourceDefinition.WILDCARD.parseAndSetParameter(value, op, reader);
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
if (type == null) {
throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.TYPE.getLocalName()));
}
ModelNode addr = op.get(OP_ADDR).set(address);
addr.add(CORE_SERVICE, IGNORED_RESOURCES);
addr.add(IGNORED_RESOURCE_TYPE, type);
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
requireNamespace(reader, namespace);
final Element element = Element.forName(reader.getLocalName());
switch (element) {
case INSTANCE: {
String name = ParseUtils.readStringAttributeElement(reader, NAME);
IgnoredDomainTypeResourceDefinition.NAMES.parseAndAddParameterElement(name, op, reader);
break;
}
default:
throw unexpectedElement(reader);
}
}
list.add(op);
}
示例10: parseRemoteDomainControllerAttributes_1_0
import org.jboss.as.controller.parsing.ParseUtils; //导入方法依赖的package包/类
private void parseRemoteDomainControllerAttributes_1_0(final XMLExtendedStreamReader reader, final ModelNode address,
final List<ModelNode> list) throws XMLStreamException {
// Handle attributes
String host = null;
ModelNode port = null;
String securityRealm = null;
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
if (!isNoNamespaceAttribute(reader, i)) {
throw unexpectedAttribute(reader, i);
} else {
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case HOST: {
host = value;
break;
}
case PORT: {
port = parsePossibleExpression(value);
if(port.getType() != ModelType.EXPRESSION) {
try {
int portNo = Integer.parseInt(value);
if (portNo < 1) {
throw ControllerLogger.ROOT_LOGGER.invalidPort(attribute.getLocalName(), value, reader.getLocation());
}
}catch(NumberFormatException e) {
throw ControllerLogger.ROOT_LOGGER.invalidPort(attribute.getLocalName(), value, reader.getLocation());
}
}
break;
}
case SECURITY_REALM: {
securityRealm = value;
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
}
if (host == null) {
throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.HOST.getLocalName()));
}
if (port == null) {
throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.PORT.getLocalName()));
}
final ModelNode update = new ModelNode();
update.get(OP_ADDR).set(address);
update.get(OP).set(RemoteDomainControllerAddHandler.OPERATION_NAME);
update.get(HOST).set(parsePossibleExpression(host));
update.get(PORT).set(port);
if (securityRealm != null) {
update.get(SECURITY_REALM).set(securityRealm);
}
list.add(update);
}
示例11: parseRemoteDomainControllerAttributes_1_3
import org.jboss.as.controller.parsing.ParseUtils; //导入方法依赖的package包/类
private void parseRemoteDomainControllerAttributes_1_3(final XMLExtendedStreamReader reader, final ModelNode address,
final List<ModelNode> list) throws XMLStreamException {
// Handle attributes
String host = null;
ModelNode port = null;
String securityRealm = null;
String username = null;
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
if (!isNoNamespaceAttribute(reader, i)) {
throw unexpectedAttribute(reader, i);
} else {
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case HOST: {
host = value;
break;
}
case PORT: {
port = parsePossibleExpression(value);
if(port.getType() != ModelType.EXPRESSION) {
try {
int portNo = Integer.parseInt(value);
if (portNo < 1) {
throw ControllerLogger.ROOT_LOGGER.invalidPort(attribute.getLocalName(), value, reader.getLocation());
}
}catch(NumberFormatException e) {
throw ControllerLogger.ROOT_LOGGER.invalidPort(attribute.getLocalName(), value, reader.getLocation());
}
}
break;
}
case SECURITY_REALM: {
securityRealm = value;
break;
}
case USERNAME: {
username = value;
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
}
if (host == null) {
throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.HOST.getLocalName()));
}
if (port == null) {
throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.PORT.getLocalName()));
}
final ModelNode update = new ModelNode();
update.get(OP_ADDR).set(address);
update.get(OP).set(RemoteDomainControllerAddHandler.OPERATION_NAME);
update.get(HOST).set(parsePossibleExpression(host));
update.get(PORT).set(port);
if (securityRealm != null) {
update.get(SECURITY_REALM).set(securityRealm);
}
if (username != null) {
update.get(USERNAME).set(username);
}
list.add(update);
}
示例12: parseRemoteDomainControllerAttributes_1_5
import org.jboss.as.controller.parsing.ParseUtils; //导入方法依赖的package包/类
/**
* The only difference between version 1.5 and 1.6 of the schema were to make is possible to define discovery options, this
* resulted in the host and port attributes becoming optional -this method also indicates if discovery options are required
* where the host and port were not supplied.
*
* @param allowDiscoveryOptions i.e. are host and port potentially optional?
* @return true if discovery options are required, i.e. no host and port set and the admin policy requires a config.
*/
private boolean parseRemoteDomainControllerAttributes_1_5(final XMLExtendedStreamReader reader, final ModelNode address,
final List<ModelNode> list, boolean allowDiscoveryOptions) throws XMLStreamException {
final ModelNode update = new ModelNode();
update.get(OP_ADDR).set(address);
update.get(OP).set(RemoteDomainControllerAddHandler.OPERATION_NAME);
// Handle attributes
AdminOnlyDomainConfigPolicy adminOnlyPolicy = AdminOnlyDomainConfigPolicy.DEFAULT;
boolean requireDiscoveryOptions = false;
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
if (!isNoNamespaceAttribute(reader, i)) {
throw unexpectedAttribute(reader, i);
} else {
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case HOST: {
DomainControllerWriteAttributeHandler.HOST.parseAndSetParameter(value, update, reader);
break;
}
case PORT: {
DomainControllerWriteAttributeHandler.PORT.parseAndSetParameter(value, update, reader);
break;
}
case SECURITY_REALM: {
DomainControllerWriteAttributeHandler.SECURITY_REALM.parseAndSetParameter(value, update, reader);
break;
}
case USERNAME: {
DomainControllerWriteAttributeHandler.USERNAME.parseAndSetParameter(value, update, reader);
break;
}
case ADMIN_ONLY_POLICY: {
DomainControllerWriteAttributeHandler.ADMIN_ONLY_POLICY.parseAndSetParameter(value, update, reader);
ModelNode nodeValue = update.get(DomainControllerWriteAttributeHandler.ADMIN_ONLY_POLICY.getName());
if (nodeValue.getType() != ModelType.EXPRESSION) {
adminOnlyPolicy = AdminOnlyDomainConfigPolicy.getPolicy(nodeValue.asString());
}
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
}
if (!update.hasDefined(DomainControllerWriteAttributeHandler.HOST.getName())) {
if (allowDiscoveryOptions) {
requireDiscoveryOptions = isRequireDiscoveryOptions(adminOnlyPolicy);
} else {
throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.HOST.getLocalName()));
}
}
if (!update.hasDefined(DomainControllerWriteAttributeHandler.PORT.getName())) {
if (allowDiscoveryOptions) {
requireDiscoveryOptions = requireDiscoveryOptions || isRequireDiscoveryOptions(adminOnlyPolicy);
} else {
throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.PORT.getLocalName()));
}
}
list.add(update);
return requireDiscoveryOptions;
}
示例13: parseJvmAttributes
import org.jboss.as.controller.parsing.ParseUtils; //导入方法依赖的package包/类
private static String parseJvmAttributes(XMLExtendedStreamReader reader, ModelNode addOp, Set<String> jvmNames, boolean server) throws XMLStreamException {
// Handle attributes
String name = null;
Boolean debugEnabled = null;
String debugOptions = null;
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
if (!isNoNamespaceAttribute(reader, i)) {
throw ParseUtils.unexpectedAttribute(reader, i);
} else {
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case NAME: {
if (name != null)
throw ParseUtils.duplicateAttribute(reader, attribute.getLocalName());
if (!jvmNames.add(value)) {
throw ControllerLogger.ROOT_LOGGER.duplicateDeclaration("JVM", value, reader.getLocation());
}
name = value;
break;
}
case JAVA_HOME: {
JvmAttributes.JAVA_HOME.parseAndSetParameter(value, addOp, reader);
break;
}
case TYPE: {
try {
// Validate the type against the enum
JvmAttributes.TYPE.parseAndSetParameter(value, addOp, reader);
} catch (final IllegalArgumentException e) {
throw ParseUtils.invalidAttributeValue(reader, i);
}
break;
}
case DEBUG_ENABLED: {
if (!server) {
throw ParseUtils.unexpectedAttribute(reader, i);
}
debugEnabled = Boolean.valueOf(value);
JvmAttributes.DEBUG_ENABLED.parseAndSetParameter(value, addOp, reader);
break;
}
case DEBUG_OPTIONS: {
if (!server) {
throw ParseUtils.unexpectedAttribute(reader, i);
}
debugOptions = value;
JvmAttributes.DEBUG_OPTIONS.parseAndSetParameter(value, addOp, reader);
break;
}
case ENV_CLASSPATH_IGNORED: {
JvmAttributes.ENV_CLASSPATH_IGNORED.parseAndSetParameter(value, addOp, reader);
break;
}
default:
throw ParseUtils.unexpectedAttribute(reader, i);
}
}
}
if (name == null) {
// FIXME and fix xsd. A name is only required at domain and host
// level (i.e. when wrapped in <jvms/>). At server-group and server
// levels it can be unnamed, in which case configuration from
// domain and host levels aren't mixed in. OR make name required in xsd always
throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.NAME));
}
if (debugEnabled != null && debugOptions == null && debugEnabled) {
throw ParseUtils.missingRequired(reader, EnumSet.of(Attribute.DEBUG_OPTIONS));
}
return name;
}
示例14: parseSystemProperties
import org.jboss.as.controller.parsing.ParseUtils; //导入方法依赖的package包/类
void parseSystemProperties(final XMLExtendedStreamReader reader, final ModelNode address,
final Namespace expectedNs, final List<ModelNode> updates, boolean standalone) throws XMLStreamException {
while (reader.nextTag() != END_ELEMENT) {
requireNamespace(reader, expectedNs);
final Element element = Element.forName(reader.getLocalName());
if (element != Element.PROPERTY) {
throw unexpectedElement(reader);
}
boolean setName = false;
boolean setValue = false;
boolean setBoottime = false;
// Will set OP_ADDR after parsing the NAME attribute
ModelNode op = Util.getEmptyOperation(SystemPropertyAddHandler.OPERATION_NAME, new ModelNode());
final int count = reader.getAttributeCount();
String name = null;
for (int i = 0; i < count; i++) {
final String val = reader.getAttributeValue(i);
if (!isNoNamespaceAttribute(reader, i)) {
throw unexpectedAttribute(reader, i);
} else {
final String attribute = reader.getAttributeLocalName(i);
switch (attribute) {
case NAME: {
if (setName) {
throw ParseUtils.duplicateAttribute(reader, NAME);
}
setName = true;
ModelNode addr = new ModelNode().set(address).add(SYSTEM_PROPERTY, val);
op.get(OP_ADDR).set(addr);
name = val;
break;
}
case VALUE: {
if (setValue) {
throw ParseUtils.duplicateAttribute(reader, VALUE);
}
setValue = true;
SystemPropertyResourceDefinition.VALUE.parseAndSetParameter(val, op, reader);
break;
}
case BOOT_TIME: {
if (standalone) {
throw unexpectedAttribute(reader, i);
}
if (setBoottime) {
throw ParseUtils.duplicateAttribute(reader, BOOT_TIME);
}
setBoottime = true;
SystemPropertyResourceDefinition.BOOT_TIME.parseAndSetParameter(val, op, reader);
break;
}
default: {
throw unexpectedAttribute(reader, i);
}
}
}
}
requireNoContent(reader);
if (!setName) {
throw ParseUtils.missingRequired(reader, Collections.singleton(NAME));
}
if(standalone) {
//eagerly set the property so it can potentially be used by jboss modules
//only do this for standalone servers
try {
System.setProperty(name, SystemPropertyResourceDefinition.VALUE.resolveValue(ExpressionResolver.SIMPLE, op.get(VALUE)).asString());
} catch (OperationFailedException e) {
ServerLogger.AS_ROOT_LOGGER.tracef(e, "Failed to set property %s at parse time, it will be set later in the boot process", name);
}
}
updates.add(op);
}
}
示例15: parseScanner
import org.jboss.as.controller.parsing.ParseUtils; //导入方法依赖的package包/类
void parseScanner(XMLExtendedStreamReader reader, final ModelNode address, List<ModelNode> list) throws XMLStreamException {
// Handle attributes
String name = DeploymentScannerExtension.DEFAULT_SCANNER_NAME;
String path = null;
final ModelNode operation = new ModelNode();
operation.get(OP).set(ADD);
final int attrCount = reader.getAttributeCount();
for (int i = 0; i < attrCount; i++) {
requireNoNamespaceAttribute(reader, i);
final String value = reader.getAttributeValue(i);
final String attribute = reader.getAttributeLocalName(i);
switch (attribute) {
case PATH: {
path = value;
DeploymentScannerDefinition.PATH.parseAndSetParameter(value,operation,reader);
break;
}
case NAME: {
name = DeploymentScannerDefinition.NAME.parse(value,reader).asString();
break;
}
case RELATIVE_TO: {
DeploymentScannerDefinition.RELATIVE_TO.parseAndSetParameter(value,operation,reader);
break;
}
case SCAN_INTERVAL: {
DeploymentScannerDefinition.SCAN_INTERVAL.parseAndSetParameter(value,operation,reader);
break;
}
case SCAN_ENABLED: {
DeploymentScannerDefinition.SCAN_ENABLED.parseAndSetParameter(value,operation,reader);
break;
}
case AUTO_DEPLOY_ZIPPED: {
DeploymentScannerDefinition.AUTO_DEPLOY_ZIPPED.parseAndSetParameter(value,operation,reader);
break;
}
case AUTO_DEPLOY_EXPLODED: {
DeploymentScannerDefinition.AUTO_DEPLOY_EXPLODED.parseAndSetParameter(value,operation,reader);
break;
}
case AUTO_DEPLOY_XML: {
DeploymentScannerDefinition.AUTO_DEPLOY_XML.parseAndSetParameter(value,operation,reader);
break;
}
case DEPLOYMENT_TIMEOUT: {
DeploymentScannerDefinition.DEPLOYMENT_TIMEOUT.parseAndSetParameter(value,operation,reader);
break;
}
default:
throw ParseUtils.unexpectedAttribute(reader, i);
}
}
if (name == null) {
throw ParseUtils.missingRequired(reader, Collections.singleton(CommonAttributes.NAME));
}
if (path == null) {
throw ParseUtils.missingRequired(reader, Collections.singleton(PATH));
}
requireNoContent(reader);
operation.get(OP_ADDR).set(address).add(CommonAttributes.SCANNER, name);
list.add(operation);
}