Skip to content

Commit

Permalink
GenericSubsystemDescribeHandler to OperationDefinition
Browse files Browse the repository at this point in the history
  • Loading branch information
ctomc authored and kabir committed Sep 24, 2012
1 parent 1669732 commit 8e486b3
Show file tree
Hide file tree
Showing 43 changed files with 74 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void initialize(final ExtensionContext context) {
MANAGEMENT_API_MINOR_VERSION, MANAGEMENT_API_MICRO_VERSION);

final ManagementResourceRegistration subsystemRegistration = subsystem.registerSubsystemModel(CMPSubsystemRootResourceDescription.INSTANCE);
subsystemRegistration.registerOperationHandler(DESCRIBE, GenericSubsystemDescribeHandler.INSTANCE, GenericSubsystemDescribeHandler.INSTANCE, false, OperationEntry.EntryType.PRIVATE);
subsystemRegistration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);

subsystem.registerXMLElementWriter(CmpSubsystem10Parser.INSTANCE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
import org.jboss.as.controller.descriptions.ResourceDescriptionResolver;
import org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver;
import org.jboss.as.controller.descriptions.common.CommonDescriptions;
import org.jboss.as.controller.operations.common.GenericSubsystemDescribeHandler;
import org.jboss.as.controller.operations.common.Util;
import org.jboss.as.controller.parsing.ExtensionParsingContext;
import org.jboss.as.controller.persistence.SubsystemMarshallingContext;
Expand Down Expand Up @@ -931,7 +932,7 @@ public void execute(OperationContext context, ModelNode operation) throws Operat

@Override
public ModelNode getModelDescription(Locale locale) {
return CommonDescriptions.getSubsystemDescribeOperation(locale);
return GenericSubsystemDescribeHandler.DEFINITION.getDescriptionProvider().getModelDescription(locale);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void initialize(final ExtensionContext context) {
MANAGEMENT_API_MINOR_VERSION, MANAGEMENT_API_MICRO_VERSION);

final ManagementResourceRegistration registration = subsystem.registerSubsystemModel(JcaSubsystemRootDefinition.INSTANCE);
registration.registerOperationHandler(DESCRIBE, GenericSubsystemDescribeHandler.INSTANCE, GenericSubsystemDescribeHandler.INSTANCE, false, OperationEntry.EntryType.PRIVATE);
registration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);

final ManagementResourceRegistration archiveValidation = registration.registerSubModel(JcaArchiveValidationDefinition.INSTANCE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void initialize(final ExtensionContext context) {
final ManagementResourceRegistration subsystem = registration.registerSubsystemModel(SUBSYSTEM);
subsystem.registerOperationHandler(ADD, ResourceAdaptersSubSystemAdd.INSTANCE, SUBSYSTEM_ADD_DESC, false);
subsystem.registerOperationHandler(REMOVE, ReloadRequiredRemoveStepHandler.INSTANCE, SUBSYSTEM_REMOVE_DESC, false);
subsystem.registerOperationHandler(DESCRIBE, GenericSubsystemDescribeHandler.INSTANCE, GenericSubsystemDescribeHandler.INSTANCE, false, OperationEntry.EntryType.PRIVATE);
subsystem.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);

final ManagementResourceRegistration resourceadapter = subsystem.registerSubModel(PathElement.pathElement(RESOURCEADAPTER_NAME),
RESOURCEADAPTER_DESC);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ public SimpleOperationDefinitionBuilder setEntryType(OperationEntry.EntryType en
return this;
}

public SimpleOperationDefinitionBuilder setPrivateEntry() {
this.entryType = OperationEntry.EntryType.PRIVATE;
return this;
}

public SimpleOperationDefinitionBuilder withFlags(EnumSet<OperationEntry.Flag> flags) {
this.flags = flags;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,6 @@ public DefaultOperationDescriptionProvider(final String operationName,
this(operationName, descriptionResolver, descriptionResolver, replyType, replyValueType, deprecationData, null, parameters);
}

/* public DefaultOperationDescriptionProvider(final String operationName,
final ResourceDescriptionResolver descriptionResolver,
final ModelType replyType,
final ModelType replyValueType,
final DeprecationData deprecationData,
final AttributeDefinition[] replyParameters,
final AttributeDefinition... parameters) {
this(operationName,descriptionResolver,null,replyType,replyValueType,deprecationData,replyParameters,parameters);
}*/

public DefaultOperationDescriptionProvider(final String operationName,
final ResourceDescriptionResolver descriptionResolver,
final ResourceDescriptionResolver attributeDescriptionResolver,
Expand Down Expand Up @@ -195,6 +185,7 @@ public ModelNode getModelDescription(Locale locale) {
*/
protected ModelNode getReplyValueTypeDescription(ResourceDescriptionResolver descriptionResolver, Locale locale, ResourceBundle bundle) {
// bug -- user specifies a complex reply type but does not override this method to describe it
throw MESSAGES.operationReplyValueTypeRequired(operationName);
return new ModelNode(ModelType.OBJECT); //todo rethink this
//throw MESSAGES.operationReplyValueTypeRequired(operationName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public static ModelNode getCompositeOperation(final Locale locale) {
return descr;
}

@Deprecated
public static ModelNode getSubsystemDescribeOperation(final Locale locale) {
final ResourceBundle bundle = getResourceBundle(locale);
final ModelNode root = new ModelNode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,6 @@ public ModelNode getModelDescription(Locale locale) {
}
};

public static final DescriptionProvider SUBSYSTEM_DESCRIBE_PROVIDER = new DescriptionProvider() {

@Override
public ModelNode getModelDescription(Locale locale) {
return CommonDescriptions.getSubsystemDescribeOperation(locale);
}
};

/**
* Provider for a sub-resource that exposes the MSC ServiceContainer.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@

package org.jboss.as.controller.operations.common;

import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DESCRIBE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;

import java.util.Locale;
import java.util.Set;
Expand All @@ -32,12 +34,15 @@
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.SimpleOperationDefinition;
import org.jboss.as.controller.SimpleOperationDefinitionBuilder;
import org.jboss.as.controller.descriptions.DescriptionProvider;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.descriptions.common.CommonDescriptions;
import org.jboss.as.controller.registry.ImmutableManagementResourceRegistration;
import org.jboss.as.controller.registry.Resource;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;

/**
* A generic handler recursively creating add operations for a managed resource using it's
Expand All @@ -48,6 +53,11 @@
public class GenericSubsystemDescribeHandler implements OperationStepHandler, DescriptionProvider {

public static final GenericSubsystemDescribeHandler INSTANCE = new GenericSubsystemDescribeHandler();
public static final SimpleOperationDefinition DEFINITION = new SimpleOperationDefinitionBuilder(DESCRIBE,CommonDescriptions.getResourceDescriptionResolver(SUBSYSTEM))
.setReplyType(ModelType.LIST)
.setReplyValueType(ModelType.OBJECT)
.setPrivateEntry()
.build();

protected GenericSubsystemDescribeHandler() {
//
Expand Down Expand Up @@ -107,9 +117,17 @@ protected ModelNode createAddOperation(final ModelNode address, final ModelNode
return operation;
}

/**
*
* @param locale the locale to use to generate any localized text used in the description.
* May be {@code null}, in which case {@link Locale#getDefault()} should be used
*
* @return definition of operation
* @deprecated use {@link #DEFINITION} for registration of operation
*/
@Override
public ModelNode getModelDescription(Locale locale) {
// This is a private operation, so we should not be getting requests for descriptions
return CommonDescriptions.getSubsystemDescribeOperation(locale);
return DEFINITION.getDescriptionProvider().getModelDescription(locale);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public ManagementResourceRegistration registerSubModel(final ResourceDefinition

@Override
public void registerOperationHandler(OperationDefinition definition, OperationStepHandler handler, boolean inherited) {
registerOperationHandler(definition.getName(), handler, definition.getDescriptionProvider(), inherited, definition.getFlags());
registerOperationHandler(definition.getName(), handler, definition.getDescriptionProvider(), inherited, definition.getEntryType(), definition.getFlags());
}

public void unregisterSubModel(final PathElement address) throws IllegalArgumentException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ protected void initModel(Resource rootResource, ManagementResourceRegistration r
registration.registerOperationHandler(UNDEFINE_ATTRIBUTE_OPERATION, GlobalOperationHandlers.UNDEFINE_ATTRIBUTE, CommonProviders.UNDEFINE_ATTRIBUTE_PROVIDER, true);
registration.registerOperationHandler(WRITE_ATTRIBUTE_OPERATION, GlobalOperationHandlers.WRITE_ATTRIBUTE, CommonProviders.WRITE_ATTRIBUTE_PROVIDER, true);

registration.registerOperationHandler(DESCRIBE, GenericSubsystemDescribeHandler.INSTANCE, GenericSubsystemDescribeHandler.INSTANCE);
registration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);

ManagementResourceRegistration coreResourceRegistration = registration.registerSubModel(new CoreResourceDefinition());
registration.registerAlias(getAliasedModelElement(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void initialize(ExtensionContext context) {
subsystem.registerXMLElementWriter(DeploymentScannerParser_1_1.INSTANCE);

final ManagementResourceRegistration registration = subsystem.registerSubsystemModel(new DeploymentScannerSubsystemDefinition());
registration.registerOperationHandler(DESCRIBE, GenericSubsystemDescribeHandler.INSTANCE, GenericSubsystemDescribeHandler.INSTANCE, false, OperationEntry.EntryType.PRIVATE);
registration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);
registration.registerSubModel(new DeploymentScannerDefinition(context.getPathManager()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void initialize(ExtensionContext context) {
final ManagementResourceRegistration rootResource = subsystem.registerSubsystemModel(EeSubsystemRootResource.INSTANCE);

// Mandatory describe operation
rootResource.registerOperationHandler(DESCRIBE, GenericSubsystemDescribeHandler.INSTANCE, GenericSubsystemDescribeHandler.INSTANCE, false, OperationEntry.EntryType.PRIVATE);
rootResource.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);

subsystem.registerXMLElementWriter(EESubsystemParser11.INSTANCE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void initialize(ExtensionContext context) {
final ManagementResourceRegistration subsystemRegistration = subsystem.registerSubsystemModel(EJB3SubsystemRootResourceDefinition.INSTANCE);

// describe operation for the subsystem
subsystemRegistration.registerOperationHandler(DESCRIBE, GenericSubsystemDescribeHandler.INSTANCE, GenericSubsystemDescribeHandler.INSTANCE, false, OperationEntry.EntryType.PRIVATE);
subsystemRegistration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);

// subsystem=ejb3/service=remote
subsystemRegistration.registerSubModel(EJB3RemoteResourceDefinition.INSTANCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void initialize(ExtensionContext context) {
final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, MANAGEMENT_API_MAJOR_VERSION,
MANAGEMENT_API_MINOR_VERSION, MANAGEMENT_API_MICRO_VERSION);
final ManagementResourceRegistration subsystemRegistration = subsystem.registerSubsystemModel(JacORBSubsystemResource.INSTANCE);
subsystemRegistration.registerOperationHandler(DESCRIBE, GenericSubsystemDescribeHandler.INSTANCE, GenericSubsystemDescribeHandler.INSTANCE, false, OperationEntry.EntryType.PRIVATE);
subsystemRegistration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);
subsystem.registerXMLElementWriter(PARSER);
}

Expand Down
3 changes: 2 additions & 1 deletion jaxrs/src/main/java/org/jboss/as/jaxrs/JaxrsExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import org.jboss.as.controller.descriptions.common.CommonDescriptions;
import org.jboss.as.controller.operations.common.GenericSubsystemDescribeHandler;
import org.jboss.as.controller.parsing.ExtensionParsingContext;
import static org.jboss.as.controller.parsing.ParseUtils.requireNoAttributes;
import static org.jboss.as.controller.parsing.ParseUtils.requireNoContent;
Expand Down Expand Up @@ -150,7 +151,7 @@ public void execute(OperationContext context, ModelNode operation) throws Operat

@Override
public ModelNode getModelDescription(Locale locale) {
return CommonDescriptions.getSubsystemDescribeOperation(locale);
return GenericSubsystemDescribeHandler.DEFINITION.getDescriptionProvider().getModelDescription(locale);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void initialize(ExtensionContext context) {
MANAGEMENT_API_MINOR_VERSION, MANAGEMENT_API_MICRO_VERSION);

ManagementResourceRegistration root = subsystemRegistration.registerSubsystemModel(JdrReportSubsystemDefinition.INSTANCE);
root.registerOperationHandler(DESCRIBE, GenericSubsystemDescribeHandler.INSTANCE, GenericSubsystemDescribeHandler.INSTANCE, false, OperationEntry.EntryType.PRIVATE);
root.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);


if (context.isRuntimeOnlyRegistrationValid()) {
Expand Down
2 changes: 1 addition & 1 deletion jmx/src/main/java/org/jboss/as/jmx/JMXExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void initialize(ExtensionContext context) {
MANAGEMENT_API_MINOR_VERSION, MANAGEMENT_API_MICRO_VERSION);
final boolean registerRuntimeOnly = context.isRuntimeOnlyRegistrationValid();
final ManagementResourceRegistration subsystem = registration.registerSubsystemModel(new JMXSubsystemRootResource());
subsystem.registerOperationHandler(DESCRIBE, GenericSubsystemDescribeHandler.INSTANCE, GenericSubsystemDescribeHandler.INSTANCE, false, OperationEntry.EntryType.PRIVATE);
subsystem.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);
subsystem.registerSubModel(ExposeModelResourceResolved.INSTANCE);
subsystem.registerSubModel(ExposeModelResourceExpression.INSTANCE);
subsystem.registerSubModel(RemotingConnectorResource.INSTANCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void initialize(ExtensionContext context) {
SubsystemRegistration registration = context.registerSubsystem(SUBSYSTEM_NAME, MANAGEMENT_API_MAJOR_VERSION,
MANAGEMENT_API_MINOR_VERSION, MANAGEMENT_API_MICRO_VERSION);
final ManagementResourceRegistration nodeRegistration = registration.registerSubsystemModel(JPADefinition.INSTANCE);
nodeRegistration.registerOperationHandler(DESCRIBE, GenericSubsystemDescribeHandler.INSTANCE, GenericSubsystemDescribeHandler.INSTANCE, false, OperationEntry.EntryType.PRIVATE);
nodeRegistration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);
registration.registerXMLElementWriter(parser);

initializeTransformers_1_1_0(registration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void initialize(final ExtensionContext context) {
final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, MANAGEMENT_API_MAJOR_VERSION,
MANAGEMENT_API_MINOR_VERSION, MANAGEMENT_API_MICRO_VERSION);
final ManagementResourceRegistration registration = subsystem.registerSubsystemModel(JSF_SUBSYSTEM_RESOURCE);
registration.registerOperationHandler(DESCRIBE, GenericSubsystemDescribeHandler.INSTANCE, GenericSubsystemDescribeHandler.INSTANCE, false, OperationEntry.EntryType.PRIVATE);
registration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);
subsystem.registerXMLElementWriter(PARSER);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.jboss.as.controller.descriptions.ResourceDescriptionResolver;
import org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver;
import org.jboss.as.controller.descriptions.common.CommonDescriptions;
import org.jboss.as.controller.operations.common.GenericSubsystemDescribeHandler;
import org.jboss.as.controller.parsing.ExtensionParsingContext;
import org.jboss.as.controller.parsing.ParseUtils;
import org.jboss.as.controller.persistence.SubsystemMarshallingContext;
Expand Down Expand Up @@ -135,7 +136,7 @@ public void execute(OperationContext context, ModelNode operation) throws Operat

@Override
public ModelNode getModelDescription(Locale locale) {
return CommonDescriptions.getSubsystemDescribeOperation(locale);
return GenericSubsystemDescribeHandler.DEFINITION.getDescriptionProvider().getModelDescription(locale);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void initialize(final ExtensionContext context) {
final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, MANAGEMENT_API_MAJOR_VERSION,
MANAGEMENT_API_MINOR_VERSION, MANAGEMENT_API_MICRO_VERSION);
final ManagementResourceRegistration registration = subsystem.registerSubsystemModel(LoggingRootResource.INSTANCE);
registration.registerOperationHandler(DESCRIBE, GenericSubsystemDescribeHandler.INSTANCE, GenericSubsystemDescribeHandler.INSTANCE, false, OperationEntry.EntryType.PRIVATE);
registration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);

registration.registerSubModel(RootLoggerResourceDefinition.INSTANCE);
registration.registerSubModel(LoggerResourceDefinition.INSTANCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void initialize(ExtensionContext context) {
MANAGEMENT_API_MINOR_VERSION, MANAGEMENT_API_MICRO_VERSION);

final ManagementResourceRegistration subsystemRegistration = subsystem.registerSubsystemModel(MailSubsystemResource.INSTANCE);
subsystemRegistration.registerOperationHandler(DESCRIBE, GenericSubsystemDescribeHandler.INSTANCE, GenericSubsystemDescribeHandler.INSTANCE, false, OperationEntry.EntryType.PRIVATE);
subsystemRegistration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);
// /subsystem=mail/mail-session
ManagementResourceRegistration session = subsystemRegistration.registerSubModel(MailSessionDefinition.INSTANCE);
// /subsystem=mail/mail-session=java:/Mail/server=imap
Expand Down
Loading

0 comments on commit 8e486b3

Please sign in to comment.