Permalink
Browse files

Add transformers to ejb3 subsystem

  • Loading branch information...
1 parent 4458ce9 commit 45477e7b6edf0d8cc36bf3db4a477a29ac4b5829 @bstansberry bstansberry committed with kabir Jan 9, 2013
Showing with 938 additions and 172 deletions.
  1. +9 −0 controller/src/main/java/org/jboss/as/controller/ControllerLogger.java
  2. +16 −17 controller/src/main/java/org/jboss/as/controller/ControllerMessages.java
  3. +31 −9 ...oller/src/main/java/org/jboss/as/controller/transform}/AddNameFromAddressResourceTransformer.java
  4. +257 −0 ...roller/src/main/java/org/jboss/as/controller/transform/DiscardUndefinedAttributesTransformer.java
  5. +0 −1 ejb3/src/main/java/org/jboss/as/ejb3/subsystem/CacheFactoryResourceDefinition.java
  6. +15 −0 ejb3/src/main/java/org/jboss/as/ejb3/subsystem/ChannelCreationOptionResource.java
  7. +15 −2 ejb3/src/main/java/org/jboss/as/ejb3/subsystem/ClusterPassivationStoreResourceDefinition.java
  8. +7 −58 ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3Extension.java
  9. +13 −0 ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3RemoteResourceDefinition.java
  10. +91 −3 ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3SubsystemRootResourceDefinition.java
  11. +10 −2 ejb3/src/main/java/org/jboss/as/ejb3/subsystem/FilePassivationStoreResourceDefinition.java
  12. +16 −0 ejb3/src/main/java/org/jboss/as/ejb3/subsystem/PassivationStoreResourceDefinition.java
  13. +16 −1 ejb3/src/main/java/org/jboss/as/ejb3/subsystem/StrictMaxPoolResourceDefinition.java
  14. +33 −3 ejb3/src/main/java/org/jboss/as/ejb3/subsystem/TimerServiceResourceDefinition.java
  15. +165 −0 ejb3/src/test/java/org/jboss/as/ejb3/subsystem/Ejb3SubsystemUnitTestCase.java
  16. +0 −58 ejb3/src/test/java/org/jboss/as/ejb3/subsystem/SubsystemParsingUnitTestCase.java
  17. +3 −2 ejb3/src/test/resources/org/jboss/as/ejb3/subsystem/subsystem.xml
  18. +54 −0 ejb3/src/test/resources/org/jboss/as/ejb3/subsystem/transform_1_1_0.xml
  19. +1 −1 host-controller/src/main/java/org/jboss/as/domain/controller/transformers/DomainTransformers.java
  20. +155 −1 model-test/src/main/java/org/jboss/as/model/test/FailedOperationTransformationConfig.java
  21. +27 −11 model-test/src/main/java/org/jboss/as/model/test/ModelTestUtils.java
  22. +4 −3 subsystem-test/src/main/java/org/jboss/as/subsystem/test/KnownVersions.java
View
9 controller/src/main/java/org/jboss/as/controller/ControllerLogger.java
@@ -444,4 +444,13 @@
@LogMessage(level = WARN)
@Message(id = 13402, value = "Transforming resource %s for host controller '%s' to subsystem '%s' model version '%s' -- attributes %s do not support expressions in that model version and this resource will need to be ignored on that host.")
void rejectExpressionSubsystemModelResourceTransformerFoundExpressions(PathAddress pathAddress, String legacyHostName, String subsystem, ModelVersion modelVersion, Set<String> attributeNames);
+
+ @LogMessage(level = WARN)
+ @Message(id = 13403, value = "Transforming resource %s for host controller '%s' to core model version '%s' -- attributes %s are not understood in that model version and this resource will need to be ignored on that host.")
+ void newAttributesCoreModelResourceTransformerFoundDefinedAttributes(PathAddress pathAddress, String legacyHostName, ModelVersion modelVersion, Set<String> attributeNames);
+
+ @LogMessage(level = WARN)
+ @Message(id = 13404, value = "Transforming resource %s for host controller '%s' to subsystem '%s' model version '%s' -- attributes %s are not understood in that model version and this resource will need to be ignored on that host.")
+ void newAttributesSubsystemModelResourceTransformerFoundDefinedAttributes(PathAddress pathAddress, String legacyHostName, String subsystem, ModelVersion modelVersion, Set<String> attributeNames);
+
}
View
33 controller/src/main/java/org/jboss/as/controller/ControllerMessages.java
@@ -2579,29 +2579,28 @@
@Message(id = 14884, value = "No operation named '%s' exists at address %s")
String noHandlerForOperation(String operationName, PathAddress address);
- /**
- * Indicates {@code permissionName} is not a valid permission for use with permission class {@code permissionClass}
- * @param permissionClass the class of the permission
- * @param permissionName the name of the permission provided by the user
- * @return the exception
- */
- @Message(id = 14885, value = "Invalid %s \"%s\"")
- IllegalArgumentException invalidPermission(String permissionClass, String permissionName);
-
- @Message(id = 14886, value = "Method cannot be called from a chained transformer")
- IllegalStateException cannotCallMethodFromChainedTransformer();
-
-
- @Message(id = 14887, value = "Transforming resource %s for host controller '%s' to core model version '%s' -- attributes %s do not support expressions in that model version and this resource will need to be ignored on that host.")
+ @Message(id = 14885, value = "Transforming resource %s for host controller '%s' to core model version '%s' -- attributes %s do not support expressions in that model version and this resource will need to be ignored on that host.")
OperationFailedException rejectExpressionCoreModelResourceTransformerFoundExpressions(PathAddress pathAddress, String legacyHostName, ModelVersion modelVersion, Set<String> attributeNames);
- @Message(id = 14888, value = "Transforming operation %s at resource %s for host controller '%s' to core model version '%s' -- attributes %s do not support expressions in that model version and this resource will need to be ignored on that host.")
+ @Message(id = 14886, value = "Transforming operation %s at resource %s for host controller '%s' to core model version '%s' -- attributes %s do not support expressions in that model version and this resource will need to be ignored on that host.")
OperationFailedException rejectExpressionCoreModelOperationTransformerFoundExpressions(ModelNode op, PathAddress pathAddress, String legacyHostName, ModelVersion modelVersion, Set<String> attributeNames);
- @Message(id = 14889, value = "Transforming resource %s for host controller '%s' to subsystem '%s' model version '%s' -- attributes %s do not support expressions in that model version and this resource will need to be ignored on that host.")
+ @Message(id = 14887, value = "Transforming resource %s for host controller '%s' to subsystem '%s' model version '%s' -- attributes %s do not support expressions in that model version and this resource will need to be ignored on that host.")
OperationFailedException rejectExpressionSubsystemModelResourceTransformerFoundExpressions(PathAddress pathAddress, String legacyHostName, String subsystem, ModelVersion modelVersion, Set<String> attributeNames);
- @Message(id = 14890, value = "Transforming operation %s at resource %s for host controller '%s' to subsystem '%s' model version '%s' -- attributes %s do not support expressions in that model version and this resource will need to be ignored on that host.")
+ @Message(id = 14888, value = "Transforming operation %s at resource %s for host controller '%s' to subsystem '%s' model version '%s' -- attributes %s do not support expressions in that model version and this resource will need to be ignored on that host.")
OperationFailedException rejectExpressionSubsystemModelOperationTransformerFoundExpressions(ModelNode op, PathAddress pathAddress, String legacyHostName, String subsystem, ModelVersion modelVersion, Set<String> attributeNames);
+ @Message(id = 14889, value = "Transforming resource %s for host controller '%s' to core model version '%s' -- attributes %s are not understood in that model version and this resource will need to be ignored on that host.")
+ OperationFailedException newAttributesCoreModelResourceTransformerFoundDefinedAttributes(PathAddress pathAddress, String legacyHostName, ModelVersion modelVersion, Set<String> attributeNames);
+
+ @Message(id = 14890, value = "Transforming operation %s at resource %s for host controller '%s' to core model version '%s' -- attributes %s are not understood in that model version and this resource will need to be ignored on that host.")
+ OperationFailedException newAttributesCoreModelOperationTransformerFoundDefinedAttributes(ModelNode op, PathAddress pathAddress, String legacyHostName, ModelVersion modelVersion, Set<String> attributeNames);
+
+ @Message(id = 14891, value = "Transforming resource %s for host controller '%s' to subsystem '%s' model version '%s' -- attributes %s are not understood in that model version and this resource will need to be ignored on that host.")
+ OperationFailedException newAttributesSubsystemModelResourceTransformerFoundDefinedAttributes(PathAddress pathAddress, String legacyHostName, String subsystem, ModelVersion modelVersion, Set<String> attributeNames);
+
+ @Message(id = 14892, value = "Transforming operation %s at resource %s for host controller '%s' to subsystem '%s' model version '%s' -- attributes %s are not understood in that model version and this resource will need to be ignored on that host.")
+ OperationFailedException newAttributesSubsystemModelOperationTransformerFoundDefinedAttributes(ModelNode op, PathAddress pathAddress, String legacyHostName, String subsystem, ModelVersion modelVersion, Set<String> attributeNames);
+
}
View
40 ...ddNameFromAddressResourceTransformer.java → ...ddNameFromAddressResourceTransformer.java
@@ -19,29 +19,51 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.as.domain.controller.transformers;
+package org.jboss.as.controller.transform;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.NAME;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
+import org.jboss.as.controller.ReadResourceNameOperationStepHandler;
import org.jboss.as.controller.registry.Resource;
-import org.jboss.as.controller.transform.ResourceTransformationContext;
-import org.jboss.as.controller.transform.ResourceTransformer;
+import org.jboss.as.controller.transform.chained.ChainedResourceTransformationContext;
+import org.jboss.as.controller.transform.chained.ChainedResourceTransformerEntry;
-class AddNameFromAddressResourceTransformer implements ResourceTransformer {
- static final ResourceTransformer INSTANCE = new AddNameFromAddressResourceTransformer();
+/**
+ * {@link ResourceTransformer} that takes the value in the last element of the given address
+ * and stores it in a model attribute named {@code name}.
+ * <p>
+ * This transformer can be used to preserve compatibility when {@link ReadResourceNameOperationStepHandler} is
+ * used to replace storage of a resource name in the model.
+ * </p>
+ *
+ * @see ReadResourceNameOperationStepHandler
+ */
+@SuppressWarnings("deprecation")
+public class AddNameFromAddressResourceTransformer implements ResourceTransformer, ChainedResourceTransformerEntry {
+ public static final AddNameFromAddressResourceTransformer INSTANCE = new AddNameFromAddressResourceTransformer();
private AddNameFromAddressResourceTransformer() {
}
@Override
public void transformResource(final ResourceTransformationContext context, final PathAddress address, final Resource resource) throws OperationFailedException {
- //The
- final PathElement element = address.getLastElement();
- resource.getModel().get(NAME).set(element.getValue());
+
+ transformResourceInternal(address, resource);
ResourceTransformationContext childContext = context.addTransformedResource(PathAddress.EMPTY_ADDRESS, resource);
childContext.processChildren(resource);
}
-}
+
+ @Override
+ public void transformResource(ChainedResourceTransformationContext context, PathAddress address, Resource resource) throws OperationFailedException {
+ transformResourceInternal(address, resource);
+ }
+
+ private void transformResourceInternal(final PathAddress address, final Resource resource) throws OperationFailedException {
+
+ final PathElement element = address.getLastElement();
+ resource.getModel().get(NAME).set(element.getValue());
+ }
+}
View
257 ...rc/main/java/org/jboss/as/controller/transform/DiscardUndefinedAttributesTransformer.java
@@ -0,0 +1,257 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.as.controller.transform;
+
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.NAME;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.VALUE;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.as.controller.AttributeDefinition;
+import org.jboss.as.controller.ControllerLogger;
+import org.jboss.as.controller.ControllerMessages;
+import org.jboss.as.controller.ModelVersion;
+import org.jboss.as.controller.OperationFailedException;
+import org.jboss.as.controller.PathAddress;
+import org.jboss.as.controller.PathElement;
+import org.jboss.as.controller.registry.Resource;
+import org.jboss.as.controller.transform.chained.ChainedResourceTransformationContext;
+import org.jboss.as.controller.transform.chained.ChainedResourceTransformerEntry;
+import org.jboss.dmr.ModelNode;
+
+/**
+ * Transformer that hides new attributes from legacy slaves if the attribute value is undefined. A defined value
+ * leads to a log warning or an {@link OperationFailedException} unless the resource is ignored by the target.
+ *
+ * @author Brian Stansberry (c) 2012 Red Hat Inc.
+ */
+public class DiscardUndefinedAttributesTransformer implements ChainedResourceTransformerEntry, ResourceTransformer, OperationTransformer {
+
+ private final Set<String> attributeNames;
+ private final OperationTransformer writeAttributeTransformer = new WriteAttributeTransformer();
+ private final OperationTransformer undefineAttributeTransformer = new UndefineAttributeTransformer();
+
+ public DiscardUndefinedAttributesTransformer(AttributeDefinition... attributes) {
+ this(namesFromDefinitions(attributes));
+ }
+
+ private static Set<String> namesFromDefinitions(AttributeDefinition... attributes) {
+ final Set<String> names = new HashSet<String>();
+ for(final AttributeDefinition def : attributes) {
+ names.add(def.getName());
+ }
+ return names;
+ }
+
+ public DiscardUndefinedAttributesTransformer(String... attributeNames) {
+ this(new HashSet<String>(Arrays.asList(attributeNames)));
+ }
+
+ public DiscardUndefinedAttributesTransformer(Set<String> attributeNames) {
+ this.attributeNames = attributeNames;
+ }
+
+ public OperationTransformer getWriteAttributeTransformer() {
+ return writeAttributeTransformer;
+ }
+
+ public OperationTransformer getUndefineAttributeTransformer() {
+ return undefineAttributeTransformer;
+ }
+
+ @Override
+ public void transformResource(ChainedResourceTransformationContext context, PathAddress address, Resource resource) throws OperationFailedException {
+ transformResource(context.getTarget(), address, resource);
+ }
+
+ @Override
+ public void transformResource(ResourceTransformationContext context, PathAddress address, Resource resource) throws OperationFailedException {
+ transformResource(context.getTarget(), address, resource);
+
+ final ResourceTransformationContext childContext = context.addTransformedResource(PathAddress.EMPTY_ADDRESS, resource);
+ childContext.processChildren(resource);
+ }
+
+ @Override
+ public TransformedOperation transformOperation(final TransformationContext context, final PathAddress address,
+ final ModelNode operation) throws OperationFailedException {
+
+ final Set<String> problems = checkModelNode(operation);
+ final boolean reject = problems != null;
+ final OperationRejectionPolicy rejectPolicy;
+ if (reject) {
+ rejectPolicy = new OperationRejectionPolicy() {
+ @Override
+ public boolean rejectOperation(ModelNode preparedResult) {
+ // Reject successful operations
+ return true;
+ }
+
+ @Override
+ public String getFailureDescription() {
+ // TODO OFE.getMessage
+ try {
+ return logWarning(context.getTarget(), address, problems, operation);
+ } catch (OperationFailedException e) {
+ //This will not happen
+ return null;
+ }
+ }
+ };
+ } else {
+ rejectPolicy = OperationTransformer.DEFAULT_REJECTION_POLICY;
+ }
+ // Return untransformed
+ return new TransformedOperation(operation, rejectPolicy, OperationResultTransformer.ORIGINAL_RESULT);
+ }
+
+ private void transformResource(TransformationTarget target, PathAddress address,
+ Resource resource) throws OperationFailedException {
+
+ Set<String> problems = checkModelNode(resource.getModel());
+ if (problems != null) {
+ logWarning(target, address, problems, null);
+ }
+ }
+
+ private Set<String> checkModelNode(ModelNode modelNode) {
+
+ Set<String> problems = null;
+ for (String attr : attributeNames) {
+ if (modelNode.has(attr)) {
+ if (modelNode.hasDefined(attr)) {
+ if (problems == null) {
+ problems = new HashSet<String>();
+ }
+ problems.add(attr);
+ } else {
+ modelNode.remove(attr);
+ }
+ }
+ }
+ return problems;
+ }
+
+ private class WriteAttributeTransformer implements OperationTransformer {
+
+ @Override
+ public TransformedOperation transformOperation(final TransformationContext context, final PathAddress address, final ModelNode operation) throws OperationFailedException {
+ final String attribute = operation.require(NAME).asString();
+ boolean ourAttribute = attributeNames.contains(attribute);
+ final boolean rejectResult = ourAttribute && operation.hasDefined(VALUE);
+ if (rejectResult) {
+ // Create the rejection policy
+ final OperationRejectionPolicy rejectPolicy = new OperationRejectionPolicy() {
+ @Override
+ public boolean rejectOperation(ModelNode preparedResult) {
+ // Reject successful operations
+ return true;
+ }
+
+ @Override
+ public String getFailureDescription() {
+ try {
+ return logWarning(context.getTarget(), address, Collections.singleton(attribute), operation);
+ } catch (OperationFailedException e) {
+ //This will not happen
+ return null;
+ }
+ }
+ };
+ return new TransformedOperation(operation, rejectPolicy, OperationResultTransformer.ORIGINAL_RESULT);
+ } else if (ourAttribute) {
+ // It's an attribute the slave doesn't understand, but the new value is "undefined"
+ // Just discard this operation
+ return OperationTransformer.DISCARD.transformOperation(context, address, operation);
+ }
+ // Not relevant to us
+ return new TransformedOperation(operation, OperationResultTransformer.ORIGINAL_RESULT);
+ }
+ }
+
+ private class UndefineAttributeTransformer implements OperationTransformer {
+
+ @Override
+ public TransformedOperation transformOperation(final TransformationContext context, final PathAddress address, final ModelNode operation) throws OperationFailedException {
+ final String attribute = operation.require(NAME).asString();
+ if (attributeNames.contains(attribute)) {
+ // It's an attribute the slave doesn't understand, but the new value is "undefined"
+ // Just discard this operation
+ return OperationTransformer.DISCARD.transformOperation(context, address, operation);
+ }
+ // Not relevant to us
+ return new TransformedOperation(operation, OperationResultTransformer.ORIGINAL_RESULT);
+ }
+ }
+
+ private String logWarning(TransformationTarget tgt, PathAddress pathAddress, Set<String> attributes, ModelNode op) throws OperationFailedException {
+
+ //TODO the determining of whether the version is 1.4.0, i.e. knows about ignored resources or not could be moved to a utility method
+
+ final String hostName = tgt.getHostName();
+ final ModelVersion coreVersion = tgt.getVersion();
+ final String subsystemName = findSubsystemVersion(pathAddress);
+ final ModelVersion usedVersion = subsystemName == null ? coreVersion : tgt.getSubsystemVersion(subsystemName);
+
+ //For 7.1.x, we have no idea if the slave has ignored the resource or not. On 7.2.x the slave registers the ignored resources as
+ //part of the registration process so we have a better idea and can throw errors if the slave was ignored
+ if (op == null) {
+ if (coreVersion.getMajor() >= 1 && coreVersion.getMinor() >= 4) {
+ //We are 7.2.x so we should throw an error
+ if (subsystemName != null) {
+ throw ControllerMessages.MESSAGES.newAttributesSubsystemModelResourceTransformerFoundDefinedAttributes(pathAddress, hostName, subsystemName, usedVersion, attributes);
+ }
+ throw ControllerMessages.MESSAGES.newAttributesCoreModelResourceTransformerFoundDefinedAttributes(pathAddress, hostName, usedVersion, attributes);
+ }
+ }
+
+ if (op == null) {
+ if (subsystemName != null) {
+ ControllerLogger.TRANSFORMER_LOGGER.newAttributesSubsystemModelResourceTransformerFoundDefinedAttributes(pathAddress, hostName, subsystemName, usedVersion, attributes);
+ } else {
+ ControllerLogger.TRANSFORMER_LOGGER.newAttributesCoreModelResourceTransformerFoundDefinedAttributes(pathAddress, hostName, usedVersion, attributes);
+ }
+ return null;
+ } else {
+ if (subsystemName != null) {
+ return ControllerMessages.MESSAGES.newAttributesSubsystemModelOperationTransformerFoundDefinedAttributes(op, pathAddress, hostName, subsystemName, usedVersion, attributes).getMessage();
+ } else {
+ return ControllerMessages.MESSAGES.newAttributesCoreModelOperationTransformerFoundDefinedAttributes(op, pathAddress, hostName, usedVersion, attributes).getMessage();
+ }
+ }
+ }
+
+
+ private String findSubsystemVersion(PathAddress pathAddress) {
+ for (PathElement element : pathAddress) {
+ if (element.getKey().equals(SUBSYSTEM)) {
+ return element.getValue();
+ }
+ }
+ return null;
+ }
+}
View
1 ejb3/src/main/java/org/jboss/as/ejb3/subsystem/CacheFactoryResourceDefinition.java
@@ -27,7 +27,6 @@
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.AttributeMarshaller;
import org.jboss.as.controller.PathElement;
-import org.jboss.as.controller.ReadResourceNameOperationStepHandler;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
View
15 ejb3/src/main/java/org/jboss/as/ejb3/subsystem/ChannelCreationOptionResource.java
@@ -21,6 +21,9 @@
*/
package org.jboss.as.ejb3.subsystem;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION;
+
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
@@ -37,6 +40,9 @@
import org.jboss.as.controller.operations.validation.ModelTypeValidator;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
+import org.jboss.as.controller.transform.RejectExpressionValuesTransformer;
+import org.jboss.as.controller.transform.ResourceTransformer;
+import org.jboss.as.controller.transform.TransformersSubRegistration;
import org.jboss.as.ejb3.EjbMessages;
import org.jboss.as.ejb3.remote.EJBRemoteConnectorService;
import org.jboss.dmr.ModelNode;
@@ -184,5 +190,14 @@ public void validateParameter(String parameterName, ModelNode value) throws Oper
}
}
+ static void registerTransformers_1_1_0(TransformersSubRegistration parent) {
+
+ RejectExpressionValuesTransformer transformer = new RejectExpressionValuesTransformer(CHANNEL_CREATION_OPTION_VALUE);
+ final TransformersSubRegistration transformers110 = parent.registerSubResource(INSTANCE.getPathElement(),
+ (ResourceTransformer) transformer);
+ transformers110.registerOperationTransformer(ADD, transformer);
+ transformers110.registerOperationTransformer(WRITE_ATTRIBUTE_OPERATION, transformer.getWriteAttributeTransformer());
+ }
+
}
View
17 .../src/main/java/org/jboss/as/ejb3/subsystem/ClusterPassivationStoreResourceDefinition.java
@@ -22,13 +22,19 @@
package org.jboss.as.ejb3.subsystem;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION;
+
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.ReadResourceNameOperationStepHandler;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
+import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.registry.OperationEntry;
+import org.jboss.as.controller.transform.RejectExpressionValuesTransformer;
+import org.jboss.as.controller.transform.ResourceTransformer;
+import org.jboss.as.controller.transform.TransformersSubRegistration;
import org.jboss.as.ejb3.cache.impl.backing.clustering.ClusteredBackingCacheEntryStoreConfig;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
@@ -38,7 +44,9 @@
*/
public class ClusterPassivationStoreResourceDefinition extends PassivationStoreResourceDefinition {
- static final SimpleAttributeDefinition MAX_SIZE = MAX_SIZE_BUILDER.setDefaultValue(new ModelNode(ClusteredBackingCacheEntryStoreConfig.DEFAULT_MAX_SIZE)).build();
+ static final SimpleAttributeDefinition MAX_SIZE = new SimpleAttributeDefinitionBuilder(MAX_SIZE_BUILDER.build())
+ .setDefaultValue(new ModelNode(ClusteredBackingCacheEntryStoreConfig.DEFAULT_MAX_SIZE)).build();
+
static final SimpleAttributeDefinition CACHE_CONTAINER =
new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.CACHE_CONTAINER, ModelType.STRING, true)
.setXmlName(EJB3SubsystemXMLAttribute.CACHE_CONTAINER.getLocalName())
@@ -76,6 +84,11 @@
static final ClusterPassivationStoreResourceDefinition INSTANCE = new ClusterPassivationStoreResourceDefinition();
private ClusterPassivationStoreResourceDefinition() {
- super(EJB3SubsystemModel.CLUSTER_PASSIVATION_STORE, ADD_HANDLER, REMOVE_HANDLER, OperationEntry.Flag.RESTART_NONE, OperationEntry.Flag.RESTART_RESOURCE_SERVICES, WRITE_HANDLER, ATTRIBUTES);
+ super(EJB3SubsystemModel.CLUSTER_PASSIVATION_STORE, ADD_HANDLER, REMOVE_HANDLER, OperationEntry.Flag.RESTART_NONE,
+ OperationEntry.Flag.RESTART_RESOURCE_SERVICES, WRITE_HANDLER, ATTRIBUTES);
+ }
+
+ static void registerTransformers_1_1_0(TransformersSubRegistration parent) {
+ PassivationStoreResourceDefinition.registerTransformers_1_1_0(INSTANCE.getPathElement(), parent);
}
}
View
65 ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3Extension.java
@@ -24,20 +24,17 @@
import org.jboss.as.controller.Extension;
import org.jboss.as.controller.ExtensionContext;
-import org.jboss.as.controller.ModelVersion;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.ResourceDefinition;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.SubsystemRegistration;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.descriptions.ResourceDescriptionResolver;
import org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver;
-import org.jboss.as.controller.operations.common.GenericSubsystemDescribeHandler;
import org.jboss.as.controller.parsing.ExtensionParsingContext;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
+import org.jboss.as.controller.services.path.PathManager;
import org.jboss.as.controller.services.path.ResolvePathHandler;
-import org.jboss.as.controller.transform.ResourceTransformer;
-import org.jboss.as.controller.transform.TransformersSubRegistration;
import org.jboss.as.ejb3.subsystem.deployment.EntityBeanResourceDefinition;
import org.jboss.as.ejb3.subsystem.deployment.MessageDrivenBeanResourceDefinition;
import org.jboss.as.ejb3.subsystem.deployment.SingletonBeanDeploymentResourceDefinition;
@@ -62,6 +59,8 @@
public static final String NAMESPACE_1_3 = EJB3SubsystemNamespace.EJB3_1_3.getUriString();
public static final String NAMESPACE_1_4 = EJB3SubsystemNamespace.EJB3_1_4.getUriString();
+ static final PathElement SUBSYSTEM_PATH = PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, SUBSYSTEM_NAME);
+
private static final int MANAGEMENT_API_MAJOR_VERSION = 1;
private static final int MANAGEMENT_API_MINOR_VERSION = 2;
private static final int MANAGEMENT_API_MICRO_VERSION = 0;
@@ -85,41 +84,8 @@ public void initialize(ExtensionContext context) {
subsystem.registerXMLElementWriter(EJB3SubsystemXMLPersister.INSTANCE);
- final ManagementResourceRegistration subsystemRegistration = subsystem.registerSubsystemModel(EJB3SubsystemRootResourceDefinition.INSTANCE);
-
- // describe operation for the subsystem
- subsystemRegistration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);
-
- // subsystem=ejb3/service=remote
- subsystemRegistration.registerSubModel(EJB3RemoteResourceDefinition.INSTANCE);
-
- // subsystem=ejb3/service=async
- subsystemRegistration.registerSubModel(EJB3AsyncResourceDefinition.INSTANCE);
-
- // subsystem=ejb3/strict-max-bean-instance-pool=*
- subsystemRegistration.registerSubModel(StrictMaxPoolResourceDefinition.INSTANCE);
-
- subsystemRegistration.registerSubModel(CacheFactoryResourceDefinition.INSTANCE);
- subsystemRegistration.registerSubModel(FilePassivationStoreResourceDefinition.INSTANCE);
- subsystemRegistration.registerSubModel(ClusterPassivationStoreResourceDefinition.INSTANCE);
-
- // subsystem=ejb3/service=timerservice
- final ManagementResourceRegistration timerService = subsystemRegistration.registerSubModel(TimerServiceResourceDefinition.INSTANCE);
- // Create the path resolver handler
- if (context.getProcessType().isServer()) {
- final ResolvePathHandler resolvePathHandler = ResolvePathHandler.Builder.of(context.getPathManager())
- .setPathAttribute(TimerServiceResourceDefinition.PATH)
- .setRelativeToAttribute(TimerServiceResourceDefinition.RELATIVE_TO)
- .build();
- timerService.registerOperationHandler(resolvePathHandler.getOperationDefinition(), resolvePathHandler);
- }
-
- // subsystem=ejb3/thread-pool=*
- subsystemRegistration.registerSubModel(UnboundedQueueThreadPoolResourceDefinition.create(EJB3SubsystemModel.THREAD_POOL,
- new EJB3ThreadFactoryResolver(), EJB3SubsystemModel.BASE_THREAD_POOL_SERVICE_NAME, registerRuntimeOnly));
-
- // subsystem=ejb3/service=iiop
- subsystemRegistration.registerSubModel(EJB3IIOPResourceDefinition.INSTANCE);
+ PathManager pathManager = context.getProcessType().isServer() ? context.getPathManager() : null;
+ subsystem.registerSubsystemModel(new EJB3SubsystemRootResourceDefinition(registerRuntimeOnly, pathManager));
if (registerRuntimeOnly) {
ResourceDefinition deploymentsDef = new SimpleResourceDefinition(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, SUBSYSTEM_NAME),
@@ -132,13 +98,8 @@ public void initialize(ExtensionContext context) {
deploymentsRegistration.registerSubModel(StatefulSessionBeanDeploymentResourceDefinition.INSTANCE);
}
- registerTransformers(subsystem);
- }
-
- private void registerTransformers(SubsystemRegistration subsystem) {
- ModelVersion subsystem110 = ModelVersion.create(1, 1);
- final TransformersSubRegistration transformers110 = subsystem.registerModelTransformers(subsystem110, ResourceTransformer.DEFAULT);
- UnboundedQueueThreadPoolResourceDefinition.registerTransformers1_0(transformers110, EJB3SubsystemModel.THREAD_POOL);
+ // Transformers
+ EJB3SubsystemRootResourceDefinition.registerTransformers(subsystem);
}
/**
@@ -152,16 +113,4 @@ public void initializeParsers(ExtensionParsingContext context) {
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, NAMESPACE_1_3, EJB3Subsystem13Parser.INSTANCE);
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, NAMESPACE_1_4, EJB3Subsystem14Parser.INSTANCE);
}
-
- private static class EJB3ThreadFactoryResolver extends ThreadFactoryResolver.SimpleResolver {
-
- private EJB3ThreadFactoryResolver() {
- super(ThreadsServices.FACTORY);
- }
-
- @Override
- protected String getThreadGroupName(String threadPoolName) {
- return "EJB " + threadPoolName;
- }
- }
}
View
13 ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3RemoteResourceDefinition.java
@@ -22,13 +22,19 @@
package org.jboss.as.ejb3.subsystem;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION;
+
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
+import org.jboss.as.controller.transform.RejectExpressionValuesTransformer;
+import org.jboss.as.controller.transform.ResourceTransformer;
+import org.jboss.as.controller.transform.TransformersSubRegistration;
import org.jboss.dmr.ModelType;
import java.util.Collections;
@@ -88,4 +94,11 @@ public void registerChildren(ManagementResourceRegistration resourceRegistration
// register channel-creation-options as sub model for EJB remote service
resourceRegistration.registerSubModel(new ChannelCreationOptionResource());
}
+
+ static void registerTransformers_1_1_0(TransformersSubRegistration parent) {
+
+ final TransformersSubRegistration transformers110 = parent.registerSubResource(EJB3SubsystemModel.REMOTE_SERVICE_PATH,
+ ResourceTransformer.DEFAULT);
+ ChannelCreationOptionResource.registerTransformers_1_1_0(transformers110);
+ }
}
View
94 ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3SubsystemRootResourceDefinition.java
@@ -22,18 +22,34 @@
package org.jboss.as.ejb3.subsystem;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.UNDEFINE_ATTRIBUTE_OPERATION;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION;
+
+import org.jboss.as.controller.ModelVersion;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.ResourceDefinition;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.SimpleResourceDefinition;
+import org.jboss.as.controller.SubsystemRegistration;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
+import org.jboss.as.controller.operations.common.GenericSubsystemDescribeHandler;
import org.jboss.as.controller.operations.validation.LongRangeValidator;
import org.jboss.as.controller.operations.validation.StringLengthValidator;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.registry.OperationEntry;
+import org.jboss.as.controller.services.path.PathManager;
+import org.jboss.as.controller.transform.DiscardUndefinedAttributesTransformer;
+import org.jboss.as.controller.transform.RejectExpressionValuesTransformer;
+import org.jboss.as.controller.transform.TransformersSubRegistration;
+import org.jboss.as.controller.transform.chained.ChainedOperationTransformer;
+import org.jboss.as.controller.transform.chained.ChainedResourceTransformer;
import org.jboss.as.ejb3.deployment.processors.EJBDefaultSecurityDomainProcessor;
+import org.jboss.as.threads.ThreadFactoryResolver;
+import org.jboss.as.threads.ThreadsServices;
+import org.jboss.as.threads.UnboundedQueueThreadPoolResourceDefinition;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
@@ -113,14 +129,16 @@
private static final EJBDefaultSecurityDomainProcessor defaultSecurityDomainDeploymentProcessor = new EJBDefaultSecurityDomainProcessor(null);
- public static final EJB3SubsystemRootResourceDefinition INSTANCE = new EJB3SubsystemRootResourceDefinition();
-
+ private final boolean registerRuntimeOnly;
+ private final PathManager pathManager;
- private EJB3SubsystemRootResourceDefinition() {
+ EJB3SubsystemRootResourceDefinition(boolean registerRuntimeOnly, PathManager pathManager) {
super(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, EJB3Extension.SUBSYSTEM_NAME),
EJB3Extension.getResourceDescriptionResolver(EJB3Extension.SUBSYSTEM_NAME),
new EJB3SubsystemAdd(defaultSecurityDomainDeploymentProcessor), EJB3SubsystemRemove.INSTANCE,
OperationEntry.Flag.RESTART_ALL_SERVICES, OperationEntry.Flag.RESTART_ALL_SERVICES);
+ this.registerRuntimeOnly = registerRuntimeOnly;
+ this.pathManager = pathManager;
}
static final SimpleAttributeDefinition[] ATTRIBUTES = {
@@ -157,4 +175,74 @@ public void registerAttributes(ManagementResourceRegistration resourceRegistrati
final EJBDefaultSecurityDomainWriteHandler defaultSecurityDomainWriteHandler = new EJBDefaultSecurityDomainWriteHandler(DEFAULT_SECURITY_DOMAIN, defaultSecurityDomainDeploymentProcessor);
resourceRegistration.registerReadWriteAttribute(DEFAULT_SECURITY_DOMAIN, null, defaultSecurityDomainWriteHandler);
}
+
+ @Override
+ public void registerOperations(ManagementResourceRegistration subsystemRegistration) {
+ super.registerOperations(subsystemRegistration);
+ subsystemRegistration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);
+ }
+
+ @Override
+ public void registerChildren(ManagementResourceRegistration subsystemRegistration) {
+
+ // subsystem=ejb3/service=remote
+ subsystemRegistration.registerSubModel(EJB3RemoteResourceDefinition.INSTANCE);
+
+ // subsystem=ejb3/service=async
+ subsystemRegistration.registerSubModel(EJB3AsyncResourceDefinition.INSTANCE);
+
+ // subsystem=ejb3/strict-max-bean-instance-pool=*
+ subsystemRegistration.registerSubModel(StrictMaxPoolResourceDefinition.INSTANCE);
+
+ subsystemRegistration.registerSubModel(CacheFactoryResourceDefinition.INSTANCE);
+ subsystemRegistration.registerSubModel(FilePassivationStoreResourceDefinition.INSTANCE);
+ subsystemRegistration.registerSubModel(ClusterPassivationStoreResourceDefinition.INSTANCE);
+
+ // subsystem=ejb3/service=timerservice
+ subsystemRegistration.registerSubModel(new TimerServiceResourceDefinition(pathManager));
+
+ // subsystem=ejb3/thread-pool=*
+ subsystemRegistration.registerSubModel(UnboundedQueueThreadPoolResourceDefinition.create(EJB3SubsystemModel.THREAD_POOL,
+ new EJB3ThreadFactoryResolver(), EJB3SubsystemModel.BASE_THREAD_POOL_SERVICE_NAME, registerRuntimeOnly));
+
+ // subsystem=ejb3/service=iiop
+ subsystemRegistration.registerSubModel(EJB3IIOPResourceDefinition.INSTANCE);
+ }
+
+ static void registerTransformers(SubsystemRegistration subsystemRegistration) {
+ registerTransformers_1_1_0(subsystemRegistration);
+ }
+
+ private static void registerTransformers_1_1_0(SubsystemRegistration subsystemRegistration) {
+
+ ModelVersion subsystem110 = ModelVersion.create(1, 1);
+
+ RejectExpressionValuesTransformer rejectTransformer = new RejectExpressionValuesTransformer(EJB3SubsystemRootResourceDefinition.ENABLE_STATISTICS);
+ DiscardUndefinedAttributesTransformer discardTransformer = new DiscardUndefinedAttributesTransformer(EJB3SubsystemRootResourceDefinition.DEFAULT_SECURITY_DOMAIN);
+ ChainedResourceTransformer ctr = new ChainedResourceTransformer(rejectTransformer.getChainedTransformer(), discardTransformer);
+ final TransformersSubRegistration transformers110 = subsystemRegistration.registerModelTransformers(subsystem110, ctr);
+ transformers110.registerOperationTransformer(ADD, new ChainedOperationTransformer(rejectTransformer, discardTransformer));
+ transformers110.registerOperationTransformer(WRITE_ATTRIBUTE_OPERATION,
+ new ChainedOperationTransformer(rejectTransformer.getWriteAttributeTransformer(), discardTransformer.getWriteAttributeTransformer()));
+ transformers110.registerOperationTransformer(UNDEFINE_ATTRIBUTE_OPERATION, discardTransformer);
+
+ UnboundedQueueThreadPoolResourceDefinition.registerTransformers1_0(transformers110, EJB3SubsystemModel.THREAD_POOL);
+
+ StrictMaxPoolResourceDefinition.registerTransformers_1_1_0(transformers110);
+ FilePassivationStoreResourceDefinition.registerTransformers_1_1_0(transformers110);
+ ClusterPassivationStoreResourceDefinition.registerTransformers_1_1_0(transformers110);
+ TimerServiceResourceDefinition.registerTransformers_1_1_0(transformers110);
+ }
+
+ private static class EJB3ThreadFactoryResolver extends ThreadFactoryResolver.SimpleResolver {
+
+ private EJB3ThreadFactoryResolver() {
+ super(ThreadsServices.FACTORY);
+ }
+
+ @Override
+ protected String getThreadGroupName(String threadPoolName) {
+ return "EJB " + threadPoolName;
+ }
+ }
}
View
12 ejb3/src/main/java/org/jboss/as/ejb3/subsystem/FilePassivationStoreResourceDefinition.java
@@ -22,14 +22,18 @@
package org.jboss.as.ejb3.subsystem;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION;
+
import org.jboss.as.controller.AttributeDefinition;
-import org.jboss.as.controller.ReadResourceNameOperationStepHandler;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
+import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.operations.validation.IntRangeValidator;
import org.jboss.as.controller.registry.AttributeAccess;
-import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.registry.OperationEntry;
+import org.jboss.as.controller.transform.RejectExpressionValuesTransformer;
+import org.jboss.as.controller.transform.ResourceTransformer;
+import org.jboss.as.controller.transform.TransformersSubRegistration;
import org.jboss.as.ejb3.cache.impl.factory.NonClusteredBackingCacheEntryStoreSource;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
@@ -81,4 +85,8 @@
private FilePassivationStoreResourceDefinition() {
super(EJB3SubsystemModel.FILE_PASSIVATION_STORE, ADD, REMOVE, OperationEntry.Flag.RESTART_NONE, OperationEntry.Flag.RESTART_RESOURCE_SERVICES, WRITE_HANDLER, ATTRIBUTES);
}
+
+ static void registerTransformers_1_1_0(TransformersSubRegistration parent) {
+ PassivationStoreResourceDefinition.registerTransformers_1_1_0(INSTANCE.getPathElement(), parent);
+ }
}
View
16 ejb3/src/main/java/org/jboss/as/ejb3/subsystem/PassivationStoreResourceDefinition.java
@@ -22,17 +22,25 @@
package org.jboss.as.ejb3.subsystem;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION;
+
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationStepHandler;
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.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.operations.validation.LongRangeValidator;
import org.jboss.as.controller.operations.validation.TimeUnitValidator;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.registry.OperationEntry;
+import org.jboss.as.controller.transform.AddNameFromAddressResourceTransformer;
+import org.jboss.as.controller.transform.RejectExpressionValuesTransformer;
+import org.jboss.as.controller.transform.ResourceTransformer;
+import org.jboss.as.controller.transform.TransformersSubRegistration;
+import org.jboss.as.controller.transform.chained.ChainedResourceTransformer;
import org.jboss.as.ejb3.cache.spi.BackingCacheEntryStoreConfig;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
@@ -82,4 +90,12 @@ public void registerAttributes(ManagementResourceRegistration resourceRegistrati
resourceRegistration.registerReadWriteAttribute(definition, null, this.writeHandler);
}
}
+
+ static void registerTransformers_1_1_0(PathElement path, TransformersSubRegistration parent) {
+
+ RejectExpressionValuesTransformer rejectTransformer = new RejectExpressionValuesTransformer(IDLE_TIMEOUT_UNIT);
+ final TransformersSubRegistration transformers110 = parent.registerSubResource(path, (ResourceTransformer) rejectTransformer);
+ transformers110.registerOperationTransformer(ModelDescriptionConstants.ADD, rejectTransformer);
+ transformers110.registerOperationTransformer(WRITE_ATTRIBUTE_OPERATION, rejectTransformer.getWriteAttributeTransformer());
+ }
}
View
17 ejb3/src/main/java/org/jboss/as/ejb3/subsystem/StrictMaxPoolResourceDefinition.java
@@ -22,13 +22,15 @@
package org.jboss.as.ejb3.subsystem;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION;
+
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.PathElement;
-import org.jboss.as.controller.ReadResourceNameOperationStepHandler;
import org.jboss.as.controller.ResourceDefinition;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
@@ -39,6 +41,11 @@
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.registry.OperationEntry;
+import org.jboss.as.controller.transform.AddNameFromAddressResourceTransformer;
+import org.jboss.as.controller.transform.RejectExpressionValuesTransformer;
+import org.jboss.as.controller.transform.ResourceTransformer;
+import org.jboss.as.controller.transform.TransformersSubRegistration;
+import org.jboss.as.controller.transform.chained.ChainedResourceTransformer;
import org.jboss.as.ejb3.component.pool.StrictMaxPoolConfig;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
@@ -100,4 +107,12 @@ public void registerAttributes(ManagementResourceRegistration resourceRegistrati
resourceRegistration.registerReadWriteAttribute(attr, null, StrictMaxPoolWriteHandler.INSTANCE);
}
}
+
+ static void registerTransformers_1_1_0(TransformersSubRegistration parent) {
+
+ RejectExpressionValuesTransformer rejectTransformer = new RejectExpressionValuesTransformer(INSTANCE_ACQUISITION_TIMEOUT_UNIT);
+ final TransformersSubRegistration transformers110 = parent.registerSubResource(INSTANCE.getPathElement(), (ResourceTransformer) rejectTransformer);
+ transformers110.registerOperationTransformer(ADD, rejectTransformer);
+ transformers110.registerOperationTransformer(WRITE_ATTRIBUTE_OPERATION, rejectTransformer.getWriteAttributeTransformer());
+ }
}
View
36 ejb3/src/main/java/org/jboss/as/ejb3/subsystem/TimerServiceResourceDefinition.java
@@ -22,6 +22,9 @@
package org.jboss.as.ejb3.subsystem;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION;
+
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -37,6 +40,11 @@
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.registry.OperationEntry;
+import org.jboss.as.controller.services.path.PathManager;
+import org.jboss.as.controller.services.path.ResolvePathHandler;
+import org.jboss.as.controller.transform.RejectExpressionValuesTransformer;
+import org.jboss.as.controller.transform.ResourceTransformer;
+import org.jboss.as.controller.transform.TransformersSubRegistration;
import org.jboss.dmr.ModelType;
/**
@@ -46,8 +54,6 @@
*/
public class TimerServiceResourceDefinition extends SimpleResourceDefinition {
- public static final TimerServiceResourceDefinition INSTANCE = new TimerServiceResourceDefinition();
-
public static final SimpleAttributeDefinition PATH =
new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.PATH, ModelType.STRING, true)
.setAllowExpression(true)
@@ -78,11 +84,14 @@
ATTRIBUTES = Collections.unmodifiableMap(map);
}
- private TimerServiceResourceDefinition() {
+ private final PathManager pathManager;
+
+ TimerServiceResourceDefinition(PathManager pathManager) {
super(EJB3SubsystemModel.TIMER_SERVICE_PATH,
EJB3Extension.getResourceDescriptionResolver(EJB3SubsystemModel.TIMER_SERVICE),
TimerServiceAdd.INSTANCE, TimerServiceRemove.INSTANCE,
OperationEntry.Flag.RESTART_ALL_SERVICES, OperationEntry.Flag.RESTART_ALL_SERVICES);
+ this.pathManager = pathManager;
}
@Override
@@ -91,4 +100,25 @@ public void registerAttributes(ManagementResourceRegistration resourceRegistrati
resourceRegistration.registerReadWriteAttribute(attr, null, new ReloadRequiredWriteAttributeHandler(attr));
}
}
+
+ @Override
+ public void registerOperations(ManagementResourceRegistration resourceRegistration) {
+ super.registerOperations(resourceRegistration);
+ if (pathManager != null) {
+ final ResolvePathHandler resolvePathHandler = ResolvePathHandler.Builder.of(pathManager)
+ .setPathAttribute(TimerServiceResourceDefinition.PATH)
+ .setRelativeToAttribute(TimerServiceResourceDefinition.RELATIVE_TO)
+ .build();
+ resourceRegistration.registerOperationHandler(resolvePathHandler.getOperationDefinition(), resolvePathHandler);
+ }
+ }
+
+ static void registerTransformers_1_1_0(TransformersSubRegistration parent) {
+
+ RejectExpressionValuesTransformer transformer = new RejectExpressionValuesTransformer(PATH);
+ final TransformersSubRegistration transformers110 = parent.registerSubResource(EJB3SubsystemModel.TIMER_SERVICE_PATH,
+ (ResourceTransformer) transformer);
+ transformers110.registerOperationTransformer(ADD, transformer);
+ transformers110.registerOperationTransformer(WRITE_ATTRIBUTE_OPERATION, transformer.getWriteAttributeTransformer());
+ }
}
View
165 ejb3/src/test/java/org/jboss/as/ejb3/subsystem/Ejb3SubsystemUnitTestCase.java
@@ -0,0 +1,165 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.as.ejb3.subsystem;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.as.controller.ModelVersion;
+import org.jboss.as.controller.PathAddress;
+import org.jboss.as.controller.PathElement;
+import org.jboss.as.controller.RunningMode;
+import org.jboss.as.model.test.FailedOperationTransformationConfig;
+import org.jboss.as.model.test.ModelFixer;
+import org.jboss.as.model.test.ModelTestUtils;
+import org.jboss.as.server.ServerEnvironment;
+import org.jboss.as.subsystem.test.AbstractSubsystemBaseTest;
+import org.jboss.as.subsystem.test.AdditionalInitialization;
+import org.jboss.as.subsystem.test.KernelServices;
+import org.jboss.as.subsystem.test.KernelServicesBuilder;
+import org.jboss.as.threads.CommonAttributes;
+import org.jboss.as.threads.PoolAttributeDefinitions;
+import org.jboss.as.threads.ThreadsExtension;
+import org.jboss.dmr.ModelNode;
+import org.jboss.dmr.ModelType;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @author Emanuel Muckenhuber
+ */
+public class Ejb3SubsystemUnitTestCase extends AbstractSubsystemBaseTest {
+
+ public Ejb3SubsystemUnitTestCase() {
+ super(EJB3Extension.SUBSYSTEM_NAME, new EJB3Extension());
+ }
+
+
+ @Override
+ protected String getSubsystemXml() throws IOException {
+ return readResource("subsystem.xml");
+ }
+
+ /**
+ * Tests transformation of model from 1.2.0 version into 1.1.0 version.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testTransformer_1_1_0() throws Exception {
+ String subsystemXml = "transform_1_1_0.xml"; //This has no expressions not understood by 1.1.0
+ ModelVersion modelVersion = ModelVersion.create(1, 1, 0); //The old model version
+ //Use the non-runtime version of the extension which will happen on the HC
+ KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT)
+ .setSubsystemXmlResource(subsystemXml);
+
+ // Add legacy subsystems
+ builder.createLegacyKernelServicesBuilder(null, modelVersion)
+ .addMavenResourceURL("org.jboss.as:jboss-as-ejb3:7.1.2.Final")
+ .addMavenResourceURL("org.jboss.as:jboss-as-threads:7.1.2.Final");
+
+ KernelServices mainServices = builder.build();
+ KernelServices legacyServices = mainServices.getLegacyServices(modelVersion);
+ Assert.assertNotNull(legacyServices);
+ checkSubsystemModelTransformation(mainServices, modelVersion, V_1_1_0_FIXER);
+ }
+
+ @Test
+ public void testRejectExpressions_1_1_0() throws Exception {
+ // create builder for current subsystem version
+ KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization());
+
+ // create builder for legacy subsystem version
+ ModelVersion version_1_1_0 = ModelVersion.create(1, 1, 0);
+ builder.createLegacyKernelServicesBuilder(null, version_1_1_0)
+ .addMavenResourceURL("org.jboss.as:jboss-as-ejb3:7.1.2.Final")
+ .addMavenResourceURL("org.jboss.as:jboss-as-threads:7.1.2.Final");
+
+ KernelServices mainServices = builder.build();
+ KernelServices legacyServices = mainServices.getLegacyServices(version_1_1_0);
+
+ Assert.assertNotNull(legacyServices);
+ Assert.assertTrue("main services did not boot", mainServices.isSuccessfulBoot());
+ Assert.assertTrue(legacyServices.isSuccessfulBoot());
+
+ List<ModelNode> xmlOps = builder.parseXmlResource("subsystem.xml");
+
+ ModelTestUtils.checkFailedTransformedBootOperations(mainServices, version_1_1_0, xmlOps, getConfig());
+ }
+
+ private FailedOperationTransformationConfig getConfig() {
+ PathAddress subsystemAddress = PathAddress.pathAddress(EJB3Extension.SUBSYSTEM_PATH);
+ FailedOperationTransformationConfig.RejectExpressionsConfig keepaliveOnly =
+ new FailedOperationTransformationConfig.RejectExpressionsConfig(PoolAttributeDefinitions.KEEPALIVE_TIME);
+
+ Map<String, FailedOperationTransformationConfig.PathAddressConfig> map = new HashMap<String, FailedOperationTransformationConfig.PathAddressConfig>();
+ map.put(EJB3SubsystemRootResourceDefinition.ENABLE_STATISTICS.getName(),
+ new FailedOperationTransformationConfig.RejectExpressionsConfig(EJB3SubsystemRootResourceDefinition.ENABLE_STATISTICS));
+ map.put(EJB3SubsystemRootResourceDefinition.DEFAULT_SECURITY_DOMAIN.getName(),
+ new FailedOperationTransformationConfig.NewAttributesConfig(EJB3SubsystemRootResourceDefinition.DEFAULT_SECURITY_DOMAIN));
+
+ return new FailedOperationTransformationConfig()
+ .addFailedAttribute(subsystemAddress, new FailedOperationTransformationConfig.ChainedConfig(map))
+ .addFailedAttribute(subsystemAddress.append(PathElement.pathElement(EJB3SubsystemModel.THREAD_POOL)),
+ keepaliveOnly)
+ .addFailedAttribute(subsystemAddress.append(StrictMaxPoolResourceDefinition.INSTANCE.getPathElement()),
+ new FailedOperationTransformationConfig.RejectExpressionsConfig(StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT_UNIT))
+ .addFailedAttribute(subsystemAddress.append(FilePassivationStoreResourceDefinition.INSTANCE.getPathElement()),
+ new FailedOperationTransformationConfig.RejectExpressionsConfig(FilePassivationStoreResourceDefinition.IDLE_TIMEOUT_UNIT))
+ .addFailedAttribute(subsystemAddress.append(ClusterPassivationStoreResourceDefinition.INSTANCE.getPathElement()),
+ new FailedOperationTransformationConfig.RejectExpressionsConfig(ClusterPassivationStoreResourceDefinition.IDLE_TIMEOUT_UNIT))
+ .addFailedAttribute(subsystemAddress.append(EJB3SubsystemModel.TIMER_SERVICE_PATH),
+ new FailedOperationTransformationConfig.RejectExpressionsConfig(TimerServiceResourceDefinition.PATH))
+ .addFailedAttribute(subsystemAddress.append(EJB3SubsystemModel.REMOTE_SERVICE_PATH, ChannelCreationOptionResource.INSTANCE.getPathElement()),
+ new FailedOperationTransformationConfig.RejectExpressionsConfig(ChannelCreationOptionResource.CHANNEL_CREATION_OPTION_VALUE));
+ }
+
+ private static final ModelFixer V_1_1_0_FIXER = new ModelFixer() {
+
+ @Override
+ public ModelNode fixModel(ModelNode modelNode) {
+ // Legacy parser stores incorrect type
+ ModelNode iiopEnabled = modelNode.get("service", "iiop", "enable-by-default");
+ if (iiopEnabled.getType() == ModelType.STRING) {
+ iiopEnabled.set(iiopEnabled.asBoolean());
+ }
+ ModelNode useQualfified = modelNode.get("service", "iiop", "use-qualified-name");
+ if (useQualfified.getType() == ModelType.STRING) {
+ useQualfified.set(useQualfified.asBoolean());
+ }
+ // Bogus 'name' attributes that weren't in the legacy resource definition.
+ // We don't include them in transformed resources either; if the server wants
+ // them at runtime, the bogus server code will add them anyway
+ modelNode.get("file-passivation-store", "file").remove("name");
+ modelNode.get("cluster-passivation-store", "cluster").remove("name");
+ modelNode.get("strict-max-bean-instance-pool", "slsb-strict-max-pool").remove("name");
+ modelNode.get("strict-max-bean-instance-pool", "mdb-strict-max-pool").remove("name");
+ modelNode.get("cache", "simple").remove("name");
+ modelNode.get("cache", "passivating").remove("name");
+ modelNode.get("cache", "clustered").remove("name");
+ return modelNode;
+ }
+ };
+}
View
58 ejb3/src/test/java/org/jboss/as/ejb3/subsystem/SubsystemParsingUnitTestCase.java
@@ -1,58 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.as.ejb3.subsystem;
-
-import java.io.IOException;
-
-import org.jboss.as.controller.RunningMode;
-import org.jboss.as.server.ServerEnvironment;
-import org.jboss.as.subsystem.test.AbstractSubsystemBaseTest;
-import org.jboss.as.subsystem.test.AdditionalInitialization;
-
-/**
- * @author Emanuel Muckenhuber
- */
-public class SubsystemParsingUnitTestCase extends AbstractSubsystemBaseTest {
-
- public SubsystemParsingUnitTestCase() {
- super(EJB3Extension.SUBSYSTEM_NAME, new EJB3Extension());
- }
-
-
- @Override
- protected String getSubsystemXml() throws IOException {
- return readResource("subsystem.xml");
- }
-
- /* @Override
- protected AdditionalInitialization createAdditionalInitialization() {
- System.setProperty(ServerEnvironment.NODE_NAME, "myNode");
- return new AdditionalInitialization() {
- @Override
- protected RunningMode getRunningMode() {
- return RunningMode.NORMAL;
- }
- };
-
- }*/
-}
View
5 ejb3/src/test/resources/org/jboss/as/ejb3/subsystem/subsystem.xml
@@ -28,11 +28,11 @@
</passivation-stores>
<async thread-pool-name="default"/>
<timer-service thread-pool-name="default">
- <data-store path="timer-service-data" relative-to="jboss.server.data.dir"/>
+ <data-store path="${prop.timer-service.path:timer-service-data}" relative-to="jboss.server.data.dir"/>
</timer-service>
<remote connector-ref="remoting-connector" thread-pool-name="default">
<channel-creation-options>
- <option name="READ_TIMEOUT" value="20" type="xnio"/>
+ <option name="READ_TIMEOUT" value="${prop.remoting-connector.read.timeout:20}" type="xnio"/>
<option name="MAX_OUTBOUND_MESSAGES" value="1234" type="remoting"/>
</channel-creation-options>
</remote>
@@ -50,4 +50,5 @@
<in-vm-remote-interface-invocation pass-by-value="false"/>
<statistics enabled="${ejb.enable-statistics:true}" />
<default-distinct-name value="myname"/>
+ <default-security-domain value="domain"/>
</subsystem>
View
54 ejb3/src/test/resources/org/jboss/as/ejb3/subsystem/transform_1_1_0.xml
@@ -0,0 +1,54 @@
+
+<subsystem xmlns="urn:jboss:domain:ejb3:1.3">
+ <session-bean>
+ <stateless>
+ <bean-instance-pool-ref pool-name="slsb-strict-max-pool"/>
+ </stateless>
+ <stateful default-access-timeout="${prop.default-access-timeout:5000}" cache-ref="file" clustered-cache-ref="cluster"/>
+ <singleton default-access-timeout="${prop.default-access-timeout:5000}"/>
+ </session-bean>
+ <entity-bean>
+ <bean-instance-pool-ref pool-name="entity-strict-max-pool"/>
+ <optimistic-locking enabled="true"/>
+ </entity-bean>
+ <!-- EJB3 pools -->
+ <pools>
+ <bean-instance-pools>
+ <strict-max-pool name="slsb-strict-max-pool" max-pool-size="${prop.strict-max-pool:20}" instance-acquisition-timeout="${prop.instance-acquisition-timeout:5}" instance-acquisition-timeout-unit="MINUTES"/>
+ <strict-max-pool name="mdb-strict-max-pool" max-pool-size="${prop.strict-max-pool:20}" instance-acquisition-timeout="${prop.instance-acquisition-timeout:5}" instance-acquisition-timeout-unit="MINUTES"/>
+ </bean-instance-pools>
+ </pools>
+ <caches>
+ <cache name="simple"/>
+ <cache name="passivating" passivation-store-ref="file"/>
+ <cache name="clustered" passivation-store-ref="cluster"/>
+ </caches>
+ <passivation-stores>
+ <file-passivation-store name="file"/>
+ <cluster-passivation-store name="cluster" cache-container="sfsb" bean-cache="repl" client-mappings-cache="client-mappings" idle-timeout="${prop.idle-timeout:5}" idle-timeout-unit="MINUTES"/>
+ </passivation-stores>
+ <async thread-pool-name="default"/>
+ <timer-service thread-pool-name="default">
+ <data-store path="timer-service-data" relative-to="jboss.server.data.dir"/>
+ </timer-service>
+ <remote connector-ref="remoting-connector" thread-pool-name="default">
+ <channel-creation-options>
+ <option name="READ_TIMEOUT" value="20" type="xnio"/>
+ <option name="MAX_OUTBOUND_MESSAGES" value="1234" type="remoting"/>
+ </channel-creation-options>
+ </remote>
+
+ <!-- Session bean configurations -->
+ <thread-pools>
+ <thread-pool name="default">
+ <max-threads count="${prop.max-thread-count:10}"/>
+ <keepalive-time time="100" unit="milliseconds"/>
+ </thread-pool>
+ </thread-pools>
+
+ <iiop use-qualified-name="true" enable-by-default="true"/>
+ <!-- Disable pass-by-value for in-vm remote interface invocations on EJBs -->
+ <in-vm-remote-interface-invocation pass-by-value="false"/>
+ <statistics enabled="true" />
+ <default-distinct-name value="myname"/>
+</subsystem>
View
2 ...troller/src/main/java/org/jboss/as/domain/controller/transformers/DomainTransformers.java
@@ -35,13 +35,13 @@
import org.jboss.as.controller.extension.ExtensionRegistry;
import org.jboss.as.controller.extension.SubsystemInformation;
import org.jboss.as.controller.registry.Resource;
+import org.jboss.as.controller.transform.AddNameFromAddressResourceTransformer;
import org.jboss.as.controller.transform.ResourceTransformationContext;
import org.jboss.as.controller.transform.ResourceTransformer;
import org.jboss.as.controller.transform.TransformationTarget;
import org.jboss.as.controller.transform.TransformerRegistry;
import org.jboss.as.controller.transform.TransformersSubRegistration;
import org.jboss.as.domain.controller.resources.ServerGroupResourceDefinition;
-import org.jboss.as.host.controller.model.jvm.JvmResourceDefinition;
/**
* Global transformation rules for the domain, host and server-config model.
View
156 model-test/src/main/java/org/jboss/as/model/test/FailedOperationTransformationConfig.java
@@ -36,16 +36,19 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.TreeMap;
import org.jboss.as.controller.AttributeDefinition;
+import org.jboss.as.controller.ModelVersion;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.operations.common.Util;
+import org.jboss.as.controller.transform.DiscardUndefinedAttributesTransformer;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.Property;
/**
- * Sets up how to handle failed transformation for use with {@link ModelTestUtils#checkFailedTransformedAddOperations(ModelTestKernelServices, org.jboss.as.controller.ModelVersion, List, FailedOperationTransformationConfig)}
+ * Sets up how to handle failed transformation for use with {@link ModelTestUtils#checkFailedTransformedAddOperation(ModelTestKernelServices, ModelVersion, ModelNode, FailedOperationTransformationConfig)}
*
*
* @author <a href="kabir.khan@jboss.com">Kabir Khan</a>
@@ -407,4 +410,155 @@ private boolean childHasExpressions(RejectExpressionsConfig complexChildConfig,
}
}
+ /**
+ * A standard configuration for the {@link DiscardUndefinedAttributesTransformer}
+ * for use with attributes that are new in a version.
+ */
+ public static class NewAttributesConfig extends AttributesPathAddressConfig<NewAttributesConfig> {
+
+ public NewAttributesConfig(String...attributes) {
+ super(attributes);
+ }
+
+ public NewAttributesConfig(AttributeDefinition...attributes) {
+ super(convert(attributes));
+ }
+
+ static String[] convert(AttributeDefinition...defs) {
+ String[] attrs = new String[defs.length];
+ for (int i = 0 ; i < defs.length ; i++) {
+ attrs[i] = defs[i].getName();
+ }
+ return attrs;
+ }
+
+
+ @Override
+ public boolean expectFailed(ModelNode operation) {
+ ModelNode op = operation.clone();
+ for (String attr : attributes) {
+ if (op.hasDefined(attr)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public ModelNode correctOperation(ModelNode operation) {
+ ModelNode op = operation.clone();
+ for (String attr : attributes) {
+ if (op.has(attr)) {
+ op.remove(attr);
+ return op;
+ }
+ }
+ return operation;
+ }
+
+ @Override
+ public ModelNode correctWriteAttributeOperation(ModelNode operation) {
+ ModelNode op = operation.clone();
+ if (op.hasDefined(VALUE)) {
+ op.get(VALUE).set(new ModelNode());
+ return op;
+ }
+ return operation;
+ }
+
+ @Override
+ protected boolean isAttributeWritable(String attributeName) {
+ return true;
+ }
+
+ @Override
+ public boolean canCorrectMore(ModelNode operation) {
+ ModelNode op = operation.clone();
+ for (String attr : attributes) {
+ if (op.hasDefined(attr)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean expectFailedWriteAttributeOperation(ModelNode operation) {
+ return operation.hasDefined(VALUE);
+ }
+
+ }
+
+ /**
+ * A standard configuration that allows multiple separate configs to be used.
+ */
+ public static class ChainedConfig extends AttributesPathAddressConfig {
+
+ private final Map<String, PathAddressConfig> links = new TreeMap<String, PathAddressConfig>();
+
+ public ChainedConfig(Map<String, PathAddressConfig> links) {
+ super(links.keySet().toArray(new String[links.size()]));
+ this.links.putAll(links);
+ }
+
+
+ @Override
+ public boolean expectFailed(ModelNode operation) {
+ for (PathAddressConfig link : links.values()) {
+ if (link.expectFailed(operation)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public ModelNode correctOperation(ModelNode operation) {
+ for (PathAddressConfig link : links.values()) {
+ ModelNode op = link.correctOperation(operation);
+ if (!op.equals(operation)) {
+ return op;
+ }
+ }
+ return operation;
+ }
+
+ @Override
+ public ModelNode correctWriteAttributeOperation(ModelNode operation) {
+ for (PathAddressConfig link : links.values()) {
+ ModelNode op = link.correctWriteAttributeOperation(operation);
+ if (!op.equals(operation)) {
+ return op;
+ }
+ }
+ return operation;
+ }
+
+ @Override
+ protected boolean isAttributeWritable(String attributeName) {
+ return true;
+ }
+
+ @Override
+ public boolean canCorrectMore(ModelNode operation) {
+ for (PathAddressConfig link : links.values()) {
+ if (link.canCorrectMore(operation)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean expectFailedWriteAttributeOperation(ModelNode operation) {
+ for (PathAddressConfig link : links.values()) {
+ if (link.expectFailedWriteAttributeOperation(operation)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ }
+
}
View
38 model-test/src/main/java/org/jboss/as/model/test/ModelTestUtils.java
@@ -308,7 +308,7 @@ private static void compare(ModelNode node1, ModelNode node2, boolean ignoreUnde
Assert.assertTrue("key=" + key + "\n with child1 \n" + child1.toString() + "\n has child2 not defined\n node2 is:\n" + node2.toString(), child2.isDefined());
}
stack.push(key + "/");
- compare(child1, child2, ignoreUndefined);
+ compare(child1, child2, ignoreUndefined, stack);
stack.pop();
} else if (!ignoreUndefined) {
Assert.assertFalse(child2.asString(), child2.isDefined());
@@ -321,7 +321,7 @@ private static void compare(ModelNode node1, ModelNode node2, boolean ignoreUnde
for (int i = 0; i < list1.size(); i++) {
stack.push(i + "/");
- compare(list1.get(i), list2.get(i), ignoreUndefined);
+ compare(list1.get(i), list2.get(i), ignoreUndefined, stack);
stack.pop();
}
@@ -330,7 +330,7 @@ private static void compare(ModelNode node1, ModelNode node2, boolean ignoreUnde
Property prop2 = node2.asProperty();
Assert.assertEquals(prop1 + "\n" + prop2, prop1.getName(), prop2.getName());
stack.push(prop1.getName() + "/");
- compare(prop1.getValue(), prop2.getValue(), ignoreUndefined);
+ compare(prop1.getValue(), prop2.getValue(), ignoreUndefined, stack);
stack.pop();
} else {
@@ -386,17 +386,21 @@ private static String getCompareStackAsString(Stack<String> stack) {
}
public static void checkModelAgainstDefinition(final ModelNode model, ManagementResourceRegistration rr) {
+ checkModelAgainstDefinition(model, rr, new Stack<PathElement>());
+ }
+
+ private static void checkModelAgainstDefinition(final ModelNode model, ManagementResourceRegistration rr, Stack<PathElement> stack) {
final Set<String> children = rr.getChildNames(PathAddress.EMPTY_ADDRESS);
final Set<String> attributeNames = rr.getAttributeNames(PathAddress.EMPTY_ADDRESS);
for (ModelNode el : model.asList()) {
String name = el.asProperty().getName();
ModelNode value = el.asProperty().getValue();
if (attributeNames.contains(name)) {
AttributeAccess aa = rr.getAttributeAccess(PathAddress.EMPTY_ADDRESS, name);
- Assert.assertNotNull("Attribute " + name + " is not known", aa);
+ Assert.assertNotNull(getComparePathAsString(stack) + " Attribute " + name + " is not known", aa);
AttributeDefinition ad = aa.getAttributeDefinition();
if (!value.isDefined()) {
- Assert.assertTrue("Attribute " + name + " does not allow null", ad.isAllowNull());
+ Assert.assertTrue(getComparePathAsString(stack) + " Attribute " + name + " does not allow null", ad.isAllowNull());
} else {
// Assert.assertEquals("Attribute '" + name + "' type mismatch", value.getType(), ad.getType()); //todo re-enable this check
}
@@ -405,11 +409,11 @@ public static void checkModelAgainstDefinition(final ModelNode model, Management
ad.getValidator().validateParameter(name, value);
}
} catch (OperationFailedException e) {
- Assert.fail("validation for attribute '" + name + "' failed, " + e.getFailureDescription().asString());
+ Assert.fail(getComparePathAsString(stack) + " validation for attribute '" + name + "' failed, " + e.getFailureDescription().asString());
}
} else if (!children.contains(name)) {
- Assert.fail("Element '" + name + "' is not known in target definition");
+ Assert.fail(getComparePathAsString(stack) + " Element '" + name + "' is not known in target definition");
}
}
@@ -420,9 +424,11 @@ public static void checkModelAgainstDefinition(final ModelNode model, Management
String name = v.asProperty().getName();
ModelNode value = v.asProperty().getValue();
ManagementResourceRegistration sub = rr.getSubModel(PathAddress.pathAddress(pe));
- Assert.assertNotNull("Child with name '" + name + "' not found", sub);
+ Assert.assertNotNull(getComparePathAsString(stack) + " Child with name '" + name + "' not found", sub);
if (value.isDefined()) {
- checkModelAgainstDefinition(value, sub);
+ stack.push(pe);
+ checkModelAgainstDefinition(value, sub, stack);
+ stack.pop();
}
}
}
@@ -431,15 +437,25 @@ public static void checkModelAgainstDefinition(final ModelNode model, Management
String name = pe.getValue();
ModelNode value = model.get(pe.getKeyValuePair());
ManagementResourceRegistration sub = rr.getSubModel(PathAddress.pathAddress(pe));
- Assert.assertNotNull("Child with name '" + name + "' not found", sub);
+ Assert.assertNotNull(getComparePathAsString(stack) + " Child with name '" + name + "' not found", sub);
if (value.isDefined()) {
- checkModelAgainstDefinition(value, sub);
+ stack.push(pe);
+ checkModelAgainstDefinition(value, sub, stack);
+ stack.pop();
}
}
}
}
}
+ private static String getComparePathAsString(Stack<PathElement> stack) {
+ PathAddress pa = PathAddress.EMPTY_ADDRESS;
+ for (PathElement element : stack) {
+ pa = pa.append(element);
+ }
+ return pa.toModelNode().asString();
+ }
+
/**
* A standard test for transformers where things should be rejected.
* Takes the operations and installs them in the main controller.
View
7 subsystem-test/src/main/java/org/jboss/as/subsystem/test/KnownVersions.java
@@ -50,19 +50,20 @@
//1.0.0 of configadmin belongs to AS 7.1.3 (inferred from the 1.3.0 core model version)
addSubsystemVersion(map, "configadmin", "1.0.0", "1.3.0");
- addSubsystemVersion(map, "jacorb", "1.1.0", "1.3.0");
+ addSubsystemVersion(map, "ejb3", "1.1.0", "1.2.0");
addSubsystemVersion(map, "infinispan", "1.3.0", "1.3.0");
+ addSubsystemVersion(map, "jacorb", "1.1.0", "1.3.0");
+ addSubsystemVersion(map, "jgroups", "1.1.0", "1.3.0");
addSubsystemVersion(map, "jmx", "1.0.0", "1.2.0");
addSubsystemVersion(map, "jmx", "1.1.0", "1.3.0");
- addSubsystemVersion(map, "jgroups", "1.1.0", "1.3.0");
addSubsystemVersion(map, "jpa", "1.1.0", "1.3.0");
addSubsystemVersion(map, "logging", "1.1.0", "1.3.0");
addSubsystemVersion(map, "mail", "1.1.0", "1.3.0");
addSubsystemVersion(map, "messaging", "1.1.0", "1.3.0");
addSubsystemVersion(map, "naming", "1.1.0", "1.3.0");
addSubsystemVersion(map, "osgi", "1.0.0", "1.3.0");
- addSubsystemVersion(map, "security", "1.1.0", "1.2.0");
addSubsystemVersion(map, "remoting", "1.1.0", "1.3.0");
+ addSubsystemVersion(map, "security", "1.1.0", "1.2.0");
addSubsystemVersion(map, "threads", "1.0.0", "1.2.0");
addSubsystemVersion(map, "transactions", "1.1.0", "1.2.0");
addSubsystemVersion(map, "transactions", "1.1.1", "1.3.0");

0 comments on commit 45477e7

Please sign in to comment.