Permalink
Browse files

Fix failed appclient test & jmx tests

  • Loading branch information...
1 parent d66b878 commit e973afd455efc9cd128a8be33cb30645aa9e0de5 @ctomc ctomc committed with bstansberry Jan 7, 2013
View
13 appclient/src/main/java/org/jboss/as/appclient/subsystem/AppClientExtension.java
@@ -28,9 +28,12 @@
import org.jboss.as.controller.Extension;
import org.jboss.as.controller.ExtensionContext;
+import org.jboss.as.controller.PathAddress;
+import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.SubsystemRegistration;
import org.jboss.as.controller.descriptions.ResourceDescriptionResolver;
import org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver;
+import org.jboss.as.controller.operations.common.Util;
import org.jboss.as.controller.parsing.ExtensionParsingContext;
import org.jboss.as.controller.parsing.ParseUtils;
import org.jboss.as.controller.persistence.SubsystemMarshallingContext;
@@ -55,6 +58,7 @@
public static final String NAMESPACE_1_0 = "urn:jboss:domain:appclient:1.0";
public static final String SUBSYSTEM_NAME = "appclient";
+ static final PathElement SUBSYSTEM_PATH = PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME);
private static final int MAJOR_VERSION = 1;
private static final int MINOR_VERSION = 1;
@@ -96,17 +100,10 @@ public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingCon
public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException {
ParseUtils.requireNoAttributes(reader);
ParseUtils.requireNoContent(reader);
- list.add(createAddOperation());
+ list.add(Util.createAddOperation(PathAddress.pathAddress(SUBSYSTEM_PATH)));
}
}
- static ModelNode createAddOperation() {
- final ModelNode subsystem = new ModelNode();
- subsystem.get(OP).set(ADD);
- subsystem.get(OP_ADDR).add(SUBSYSTEM, Constants.SUBSYSTEM_NAME);
- return subsystem;
- }
-
public static ResourceDescriptionResolver getResourceDescriptionResolver(final String keyPrefix) {
return new StandardResourceDescriptionResolver(keyPrefix, RESOURCE_NAME, AppClientExtension.class.getClassLoader(), true, true);
}
View
8 appclient/src/main/java/org/jboss/as/appclient/subsystem/AppClientServerConfiguration.java
@@ -24,6 +24,8 @@
import java.util.ArrayList;
import java.util.List;
+import org.jboss.as.controller.PathAddress;
+import org.jboss.as.controller.operations.common.Util;
import org.jboss.dmr.ModelNode;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
@@ -56,15 +58,13 @@ private AppClientServerConfiguration() {
private static void appclient(List<ModelNode> nodes, final String filePath, final String deploymentName, final String hostUrl, final String propertiesFileUrl, final List<String> parameters) {
loadExtension(nodes, "org.jboss.as.appclient");
- ModelNode add = new ModelNode();
- add.get(OP_ADDR).set(new ModelNode().setEmptyList()).add(SUBSYSTEM, APPCLIENT);
- add.get(OP).set(ADD);
+ ModelNode add = Util.createAddOperation(PathAddress.pathAddress(AppClientExtension.SUBSYSTEM_PATH));
add.get(Constants.FILE).set(filePath);
if (deploymentName != null) {
add.get(Constants.DEPLOYMENT).set(deploymentName);
}
if (parameters.isEmpty()) {
- add.get(Constants.PARAMETERS).addEmptyList();
+ add.get(Constants.PARAMETERS).setEmptyList();
} else {
for (String param : parameters) {
add.get(Constants.PARAMETERS).add(param);
View
10 appclient/src/main/java/org/jboss/as/appclient/subsystem/AppClientSubsystemAdd.java
@@ -29,7 +29,7 @@
import org.jboss.as.appclient.deployment.ActiveApplicationClientProcessor;
import org.jboss.as.appclient.deployment.AppClientJBossAllParser;
import org.jboss.as.appclient.deployment.ApplicationClientDependencyProcessor;
-import org.jboss.as.ee.component.deployers.DescriptorEnvironmentLifecycleMethodProcessor;
+import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.appclient.deployment.ApplicationClientManifestProcessor;
import org.jboss.as.appclient.deployment.ApplicationClientParsingDeploymentProcessor;
import org.jboss.as.appclient.deployment.ApplicationClientStartProcessor;
@@ -40,7 +40,6 @@
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.ServiceVerificationHandler;
-import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.server.AbstractDeploymentChainStep;
import org.jboss.as.server.DeploymentProcessorTarget;
import org.jboss.as.server.Services;
@@ -69,7 +68,7 @@ private AppClientSubsystemAdd() {
}
protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException {
- for(SimpleAttributeDefinition attr : AppClientSubsystemResourceDefinition.ATTRIBUTES) {
+ for(AttributeDefinition attr : AppClientSubsystemResourceDefinition.ATTRIBUTES) {
attr.validateAndSet(operation, model);
}
}
@@ -79,10 +78,7 @@ protected void performBoottime(final OperationContext context, ModelNode operati
final File file = new File(AppClientSubsystemResourceDefinition.FILE.resolveModelAttribute(context, model).asString());
final String hostUrl = model.hasDefined(HOST_URL) ? AppClientSubsystemResourceDefinition.HOST_URL.resolveModelAttribute(context, model).asString() : null;
final String connectionPropertiesUrl = model.hasDefined(CONNECTION_PROPERTIES_URL) ? AppClientSubsystemResourceDefinition.CONNECTION_PROPERTIES_URL.resolveModelAttribute(context, model).asString() : null;
- final List<String> parameters = new ArrayList<String>();
- for (ModelNode param : AppClientSubsystemResourceDefinition.PARAMETERS.resolveModelAttribute(context, model).asList()) {
- parameters.add(param.asString());
- }
+ final List<String> parameters = AppClientSubsystemResourceDefinition.PARAMETERS.unwrap(context,model);
context.addStep(new AbstractDeploymentChainStep() {
protected void execute(DeploymentProcessorTarget processorTarget) {
View
12 .../src/main/java/org/jboss/as/appclient/subsystem/AppClientSubsystemResourceDefinition.java
@@ -22,10 +22,12 @@
package org.jboss.as.appclient.subsystem;
+import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.SimpleResourceDefinition;
+import org.jboss.as.controller.StringListAttributeDefinition;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.registry.OperationEntry;
@@ -59,9 +61,9 @@
new SimpleAttributeDefinitionBuilder(Constants.CONNECTION_PROPERTIES_URL, ModelType.STRING, true)
.setAllowExpression(true).build();
- public static final SimpleAttributeDefinition PARAMETERS =
- new SimpleAttributeDefinitionBuilder(Constants.PARAMETERS, ModelType.LIST, true)
- .setAllowExpression(true).build();
+ public static final StringListAttributeDefinition PARAMETERS = new StringListAttributeDefinition.Builder(Constants.PARAMETERS)
+ .setAllowExpression(true)
+ .build();
private AppClientSubsystemResourceDefinition() {
super(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, AppClientExtension.SUBSYSTEM_NAME),
@@ -70,7 +72,7 @@ private AppClientSubsystemResourceDefinition() {
OperationEntry.Flag.RESTART_ALL_SERVICES, OperationEntry.Flag.RESTART_ALL_SERVICES);
}
- static final SimpleAttributeDefinition[] ATTRIBUTES = {
+ static final AttributeDefinition[] ATTRIBUTES = {
FILE,
DEPLOYMENT,
PARAMETERS,
@@ -80,7 +82,7 @@ private AppClientSubsystemResourceDefinition() {
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
- for(SimpleAttributeDefinition attr : ATTRIBUTES) {
+ for (AttributeDefinition attr : ATTRIBUTES) {
resourceRegistration.registerReadOnlyAttribute(attr, null);
}
}
View
34 jmx/src/main/java/org/jboss/as/jmx/model/MBeanInfoFactory.java
@@ -44,6 +44,7 @@
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_RESOURCE_OPERATION;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REPLY_PROPERTIES;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REQUEST_PROPERTIES;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.TYPE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION;
import static org.jboss.as.jmx.JmxMessages.MESSAGES;
@@ -53,7 +54,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-
import javax.management.Descriptor;
import javax.management.ImmutableDescriptor;
import javax.management.InstanceNotFoundException;
@@ -85,6 +85,7 @@
import org.jboss.as.server.deployment.DeploymentUploadStreamAttachmentHandler;
import org.jboss.as.server.operations.RootResourceHack;
import org.jboss.dmr.ModelNode;
+import org.jboss.dmr.ModelType;
import org.jboss.dmr.Property;
/**
@@ -93,12 +94,12 @@
*/
public class MBeanInfoFactory {
- private final String DESC_MBEAN_EXPR = "mbean.expression.support";
- private final String DESC_MBEAN_EXPR_DESCR = "mbean.expression.support.description";
- private final String DESC_ALTERNATE_MBEAN = "alternate.mbean";
- private final String DESC_ALTERNATE_MBEAN_DESCR = "alternate.mbean.description";
- private final String DESC_EXPRESSIONS_ALLOWED = "expressions.allowed";
- private final String DESC_EXPRESSIONS_ALLOWED_DESC = "expressions.allowed.description";
+ private static final String DESC_MBEAN_EXPR = "mbean.expression.support";
+ private static final String DESC_MBEAN_EXPR_DESCR = "mbean.expression.support.description";
+ private static final String DESC_ALTERNATE_MBEAN = "alternate.mbean";
+ private static final String DESC_ALTERNATE_MBEAN_DESCR = "alternate.mbean.description";
+ private static final String DESC_EXPRESSIONS_ALLOWED = "expressions.allowed";
+ private static final String DESC_EXPRESSIONS_ALLOWED_DESC = "expressions.allowed.description";
private static final OpenMBeanParameterInfo[] EMPTY_PARAMETERS = new OpenMBeanParameterInfo[0];
private final ObjectName name;
@@ -162,12 +163,7 @@ private OpenMBeanAttributeInfo getAttribute(String name) {
final String escapedName = NameConverter.convertToCamelCase(name);
ModelNode attribute = providedDescription.require(ATTRIBUTES).require(name);
AttributeAccess access = resourceRegistration.getAttributeAccess(PathAddress.EMPTY_ADDRESS, name);
- final boolean writable;
- if (!standalone) {
- writable = false;
- } else {
- writable = access != null ? access.getAccessType() == AccessType.READ_WRITE : false;
- }
+ final boolean writable = standalone && (access != null && access.getAccessType() == AccessType.READ_WRITE);
return new OpenMBeanAttributeInfoSupport(
escapedName,
@@ -208,7 +204,7 @@ private OpenMBeanAttributeInfo getAttribute(String name) {
}
}
final OperationEntry opEntry = entry.getValue();
- if (standalone ? true : opEntry.getFlags().contains(OperationEntry.Flag.READ_ONLY)) {
+ if (standalone || opEntry.getFlags().contains(OperationEntry.Flag.READ_ONLY)) {
ops.add(getOperation(NameConverter.convertToCamelCase(entry.getKey()), null, opEntry));
}
}
@@ -265,8 +261,10 @@ private OpenMBeanOperationInfo getOperation(String name, OpenMBeanParameterInfo
Object defaultValue = getIfExists(value, DEFAULT);
descriptions.put(DEFAULT_VALUE_FIELD, defaultValue);
if (value.has(ALLOWED)) {
- List<ModelNode> allowed = value.get(ALLOWED).asList();
- descriptions.put(LEGAL_VALUES_FIELD,fromModelNodes(value, allowed));
+ if (value.get(TYPE).asType()!=ModelType.LIST){
+ List<ModelNode> allowed = value.get(ALLOWED).asList();
+ descriptions.put(LEGAL_VALUES_FIELD, fromModelNodes(allowed));
+ }
} else {
if (value.has(MIN)) {
descriptions.put(MIN_VALUE_FIELD, getIfExistsAsComparable(value, MIN));
@@ -289,10 +287,10 @@ private OpenMBeanOperationInfo getOperation(String name, OpenMBeanParameterInfo
return params.toArray(new OpenMBeanParameterInfo[params.size()]);
}
- private Set<?> fromModelNodes(final ModelNode parentNode, final List<ModelNode> nodes) {
+ private Set<?> fromModelNodes(final List<ModelNode> nodes) {
Set<Object> values = new HashSet<Object>(nodes.size());
for (ModelNode node : nodes) {
- values.add(converters.fromModelNode(parentNode, node));
+ values.add(converters.getConverter(ModelType.STRING,null).fromModelNode(node));
}
return values;
}
View
72 jmx/src/main/java/org/jboss/as/jmx/model/TypeConverters.java
@@ -33,7 +33,6 @@
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
-
import javax.management.openmbean.ArrayType;
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.CompositeDataSupport;
@@ -130,45 +129,48 @@ public TypeConverter getConverter(ModelNode description) {
description.hasDefined(VALUE_TYPE) ? description.get(VALUE_TYPE) : null);
}
+ TypeConverter getConverter(ModelType modelType, ModelNode valueTypeNode) {
+ switch (modelType) {
+ case BIG_DECIMAL:
+ return expressions ? BIG_DECIMAL_EXPR : BIG_DECIMAL_NO_EXPR;
+ case BIG_INTEGER:
+ return expressions ? BIG_INTEGER_EXPR : BIG_INTEGER_NO_EXPR;
+ case BOOLEAN:
+ return expressions ? BOOLEAN_EXPR : BOOLEAN_NO_EXPR;
+ case BYTES:
+ //Allowing expressions for byte[] seems pointless
+ return BYTES_NO_EXPR;
+ case DOUBLE:
+ return expressions ? DOUBLE_EXPR : DOUBLE_NO_EXPR;
+ case STRING:
+ return expressions ? STRING_EXPR : STRING_NO_EXPR;
+ case PROPERTY:
+ //For the legacy setup properties are converted to a dmr string
+ //For the expr setup or legacy with legacyWithProperPropertyFormat=true we use a composite type
+ return expressions || legacyWithProperPropertyFormat ? new PropertyTypeConverter(valueTypeNode) : PROPERTY_NO_EXPR;
+ case INT:
+ return expressions ? INT_EXPR : INT_NO_EXPR;
+ case LONG:
+ return expressions ? LONG_EXPR : LONG_NO_EXPR;
+ case TYPE:
+ return expressions ? TYPE_EXPR : TYPE_NO_EXPR;
+ case UNDEFINED:
+ return expressions ? UNDEFINED_EXPR : UNDEFINED_NO_EXPR;
+ case OBJECT:
+ return new ObjectTypeConverter(valueTypeNode);
+ case LIST:
+ return new ListTypeConverter(valueTypeNode);
+ default:
+ throw MESSAGES.unknownType(modelType);
+ }
+ }
+
TypeConverter getConverter(ModelNode typeNode, ModelNode valueTypeNode) {
ModelType modelType = getType(typeNode);
if (modelType == null) {
return new ComplexTypeConverter(typeNode);
}
-
- switch (modelType) {
- case BIG_DECIMAL:
- return expressions ? BIG_DECIMAL_EXPR: BIG_DECIMAL_NO_EXPR;
- case BIG_INTEGER:
- return expressions ? BIG_INTEGER_EXPR : BIG_INTEGER_NO_EXPR;
- case BOOLEAN:
- return expressions ? BOOLEAN_EXPR : BOOLEAN_NO_EXPR;
- case BYTES:
- //Allowing expressions for byte[] seems pointless
- return BYTES_NO_EXPR;
- case DOUBLE:
- return expressions ? DOUBLE_EXPR : DOUBLE_NO_EXPR;
- case STRING:
- return expressions ? STRING_EXPR : STRING_NO_EXPR;
- case PROPERTY:
- //For the legacy setup properties are converted to a dmr string
- //For the expr setup or legacy with legacyWithProperPropertyFormat=true we use a composite type
- return expressions || legacyWithProperPropertyFormat ? new PropertyTypeConverter(valueTypeNode) : PROPERTY_NO_EXPR;
- case INT:
- return expressions ? INT_EXPR : INT_NO_EXPR;
- case LONG:
- return expressions ? LONG_EXPR : LONG_NO_EXPR;
- case TYPE:
- return expressions ? TYPE_EXPR : TYPE_NO_EXPR;
- case UNDEFINED:
- return expressions ? UNDEFINED_EXPR : UNDEFINED_NO_EXPR;
- case OBJECT:
- return new ObjectTypeConverter(valueTypeNode);
- case LIST:
- return new ListTypeConverter(valueTypeNode);
- default:
- throw MESSAGES.unknownType(modelType);
- }
+ return getConverter(modelType, valueTypeNode);
}
private static ModelNode nullNodeAsUndefined(ModelNode node) {

0 comments on commit e973afd

Please sign in to comment.