Skip to content

Commit

Permalink
AS7-5001 Add micro versions to the management API
Browse files Browse the repository at this point in the history
  • Loading branch information
bstansberry committed Jun 18, 2012
1 parent e88fb02 commit 03006ae
Show file tree
Hide file tree
Showing 73 changed files with 341 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,15 @@ public class AppClientExtension implements Extension {

public static final String NAMESPACE_1_0 = "urn:jboss:domain:appclient:1.0";

private static final int MAJOR_VERSION = 1;
private static final int MINOR_VERSION = 0;
private static final int MICRO_VERSION = 0;

private static final ApplicationClientSubsystemParser parser = new ApplicationClientSubsystemParser();

@Override
public void initialize(final ExtensionContext context) {
final SubsystemRegistration subsystem = context.registerSubsystem(Constants.SUBSYSTEM_NAME, 1, 0);
final SubsystemRegistration subsystem = context.registerSubsystem(Constants.SUBSYSTEM_NAME, MAJOR_VERSION, MINOR_VERSION, MICRO_VERSION);
final ManagementResourceRegistration subsystemRegistration = subsystem.registerSubsystemModel(AppClientSubsystemProviders.SUBSYSTEM);

// register the operations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public class InfinispanExtension implements Extension {

private static final int MANAGEMENT_API_MAJOR_VERSION = 1;
private static final int MANAGEMENT_API_MINOR_VERSION = 4;
private static final int MANAGEMENT_API_MICRO_VERSION = 0;

/**
* {@inheritDoc}
Expand All @@ -81,7 +82,8 @@ public class InfinispanExtension implements Extension {
@Override
public void initialize(ExtensionContext context) {
// IMPORTANT: Management API version != xsd version! Not all Management API changes result in XSD changes
SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, MANAGEMENT_API_MAJOR_VERSION, MANAGEMENT_API_MINOR_VERSION);
SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, MANAGEMENT_API_MAJOR_VERSION,
MANAGEMENT_API_MINOR_VERSION, MANAGEMENT_API_MICRO_VERSION);
subsystem.registerXMLElementWriter(new InfinispanSubsystemXMLWriter());

ManagementResourceRegistration registration = subsystem.registerSubsystemModel(InfinispanSubsystemProviders.SUBSYSTEM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class InfinispanSubsystemTransformer_1_3 extends AbstractSubsystemTransformer {

public InfinispanSubsystemTransformer_1_3() {
super(1, 3);
super(1, 3, 0);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class JGroupsExtension implements Extension {

private static final int MANAGEMENT_API_MAJOR_VERSION = 1;
private static final int MANAGEMENT_API_MINOR_VERSION = 1;
private static final int MANAGEMENT_API_MICRO_VERSION = 0;

/**
* {@inheritDoc}
Expand All @@ -66,7 +67,8 @@ public class JGroupsExtension implements Extension {
public void initialize(ExtensionContext context) {

// IMPORTANT: Management API version != xsd version! Not all Management API changes result in XSD changes
SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, MANAGEMENT_API_MAJOR_VERSION, MANAGEMENT_API_MINOR_VERSION);
SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, MANAGEMENT_API_MAJOR_VERSION,
MANAGEMENT_API_MINOR_VERSION, MANAGEMENT_API_MICRO_VERSION);
subsystem.registerXMLElementWriter(new JGroupsSubsystemXMLWriter());

ManagementResourceRegistration registration = subsystem.registerSubsystemModel(JGroupsSubsystemProviders.SUBSYSTEM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ public class CmpExtension implements Extension {

private static final String RESOURCE_NAME = CmpExtension.class.getPackage().getName() + ".LocalDescriptions";

private static final int MANAGEMENT_API_MAJOR_VERSION = 1;
private static final int MANAGEMENT_API_MINOR_VERSION = 0;
private static final int MANAGEMENT_API_MICRO_VERSION = 0;

public void initialize(final ExtensionContext context) {
final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, 1, 0);
final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, MANAGEMENT_API_MAJOR_VERSION,
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public class ConfigAdminExtension implements Extension {

public static final String SUBSYSTEM_NAME = "configadmin";

private static final int MANAGEMENT_API_MAJOR_VERSION = 1;
private static final int MANAGEMENT_API_MINOR_VERSION = 0;
private static final int MANAGEMENT_API_MICRO_VERSION = 0;

static ConfigAdminServiceImpl getConfigAdminService(OperationContext context) {
ServiceController<?> controller = context.getServiceRegistry(true).getService(ConfigAdminService.SERVICE_NAME);
return controller != null ? (ConfigAdminServiceImpl) controller.getValue() : null;
Expand All @@ -61,7 +65,8 @@ public void initialize(ExtensionContext context) {

boolean registerRuntimeOnly = context.isRuntimeOnlyRegistrationValid();

final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, 1, 0);
final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, MANAGEMENT_API_MAJOR_VERSION,
MANAGEMENT_API_MINOR_VERSION, MANAGEMENT_API_MICRO_VERSION);
final ManagementResourceRegistration registration = subsystem.registerSubsystemModel(ConfigAdminProviders.SUBSYSTEM);
registration.registerOperationHandler(ModelDescriptionConstants.ADD, ConfigAdminAdd.INSTANCE, ConfigAdminAdd.DESCRIPTION, false);
registration.registerOperationHandler(ModelDescriptionConstants.DESCRIBE, ConfigAdminDescribeHandler.INSTANCE, ConfigAdminAdd.DESCRIPTION, false, OperationEntry.EntryType.PRIVATE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ public class DataSourcesExtension implements Extension {

private static final int MANAGEMENT_API_MAJOR_VERSION = 1;
private static final int MANAGEMENT_API_MINOR_VERSION = 1;
private static final int MANAGEMENT_API_MICRO_VERSION = 0;

@Override
public void initialize(final ExtensionContext context) {
Expand All @@ -209,7 +210,8 @@ public void initialize(final ExtensionContext context) {
boolean registerRuntimeOnly = context.isRuntimeOnlyRegistrationValid();

// Register the remoting subsystem
final SubsystemRegistration registration = context.registerSubsystem(SUBSYSTEM_NAME, MANAGEMENT_API_MAJOR_VERSION, MANAGEMENT_API_MINOR_VERSION);
final SubsystemRegistration registration = context.registerSubsystem(SUBSYSTEM_NAME, MANAGEMENT_API_MAJOR_VERSION,
MANAGEMENT_API_MINOR_VERSION, MANAGEMENT_API_MICRO_VERSION);

registration.registerXMLElementWriter(DataSourceSubsystemParser.INSTANCE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,16 @@ public class JcaExtension implements Extension {

private static final int MANAGEMENT_API_MAJOR_VERSION = 1;
private static final int MANAGEMENT_API_MINOR_VERSION = 1;
private static final int MANAGEMENT_API_MICRO_VERSION = 0;

@Override
public void initialize(final ExtensionContext context) {
ROOT_LOGGER.debugf("Initializing Connector Extension");

final boolean registerRuntimeOnly = context.isRuntimeOnlyRegistrationValid();

final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, MANAGEMENT_API_MAJOR_VERSION, MANAGEMENT_API_MINOR_VERSION);
final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, MANAGEMENT_API_MAJOR_VERSION,
MANAGEMENT_API_MINOR_VERSION, MANAGEMENT_API_MICRO_VERSION);

final ManagementResourceRegistration registration = subsystem.registerSubsystemModel(JcaSubsystemProviders.SUBSYSTEM);
registration.registerOperationHandler(ADD, JcaSubsystemAdd.INSTANCE, JcaSubsystemProviders.SUBSYSTEM_ADD_DESC, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,14 @@ public class ResourceAdaptersExtension implements Extension {

private static final int MANAGEMENT_API_MAJOR_VERSION = 1;
private static final int MANAGEMENT_API_MINOR_VERSION = 1;
private static final int MANAGEMENT_API_MICRO_VERSION = 0;

@Override
public void initialize(final ExtensionContext context) {
SUBSYSTEM_RA_LOGGER.debugf("Initializing ResourceAdapters Extension");
// Register the remoting subsystem
final SubsystemRegistration registration = context.registerSubsystem(SUBSYSTEM_NAME, MANAGEMENT_API_MAJOR_VERSION, MANAGEMENT_API_MINOR_VERSION);
final SubsystemRegistration registration = context.registerSubsystem(SUBSYSTEM_NAME, MANAGEMENT_API_MAJOR_VERSION,
MANAGEMENT_API_MINOR_VERSION, MANAGEMENT_API_MICRO_VERSION);

ReloadRequiredWriteAttributeHandler disabledRequiredWriteAttributeHandler = new ReloadRequiredWriteAttributeHandler();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@
*/
public interface ExtensionContext {

/**
* Convenience variant of {@link #registerSubsystem(String, int, int, int)} that uses {@code 0}
* as the {@code microVersion}.
*
* @param name the name of the subsystem
* @param majorVersion the major version of the subsystem's management interface
* @param minorVersion the minor version of the subsystem's management interface
*
* @return the {@link SubsystemRegistration}
*
* @throws IllegalStateException if the subsystem name has already been registered
*/
SubsystemRegistration registerSubsystem(String name, int majorVersion, int minorVersion);

/**
* Register a new subsystem type. The returned registration object should be used
* to configure XML parsers, operation handlers, and other subsystem-specific constructs
Expand All @@ -48,12 +62,13 @@ public interface ExtensionContext {
* @param name the name of the subsystem
* @param majorVersion the major version of the subsystem's management interface
* @param minorVersion the minor version of the subsystem's management interface
* @param minorVersion the micro version of the subsystem's management interface
*
* @return the {@link SubsystemRegistration}
*
* @throws IllegalStateException if the subsystem name has already been registered
*/
SubsystemRegistration registerSubsystem(String name, int majorVersion, int minorVersion);
SubsystemRegistration registerSubsystem(String name, int majorVersion, int minorVersion, int microVersion);

/**
* Gets the type of the current process.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public class ModelDescriptionConstants {
public static final String MANAGEMENT_INTERFACE = "management-interface";
public static final String MANAGEMENT_MAJOR_VERSION = "management-major-version";
public static final String MANAGEMENT_MINOR_VERSION = "management-minor-version";
public static final String MANAGEMENT_MICRO_VERSION = "management-micro-version";
public static final String MASK = "mask";
public static final String MASTER = "master";
public static final String MAX = "max";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,18 @@ private ExtensionContextImpl(String extensionName, PathManager pathManager) {

@Override
public SubsystemRegistration registerSubsystem(String name, int majorVersion, int minorVersion) throws IllegalArgumentException, IllegalStateException {
return registerSubsystem(name, majorVersion, minorVersion, 0);
}

@Override
public SubsystemRegistration registerSubsystem(String name, int majorVersion, int minorVersion, int microVersion) {
assert name != null : "name is null";
this.subsystemName = name;
checkNewSubystem(extension.extensionModuleName, name);
SubsystemInformationImpl info = extension.getSubsystemInfo(name);
info.setMajorVersion(majorVersion);
info.setMinorVersion(minorVersion);
info.setMicroVersion(microVersion);
subsystemsInfo.put(name, info);
return new SubsystemRegistrationImpl(name);
}
Expand Down Expand Up @@ -474,6 +480,7 @@ private class SubsystemInformationImpl implements SubsystemInformation {

private Integer majorVersion;
private Integer minorVersion;
private Integer microVersion;
private final List<String> parsingNamespaces = new ArrayList<String>();

@Override
Expand Down Expand Up @@ -502,6 +509,15 @@ public Integer getManagementInterfaceMinorVersion() {
private void setMinorVersion(Integer minorVersion) {
this.minorVersion = minorVersion;
}

@Override
public Integer getManagementInterfaceMicroVersion() {
return microVersion;
}

private void setMicroVersion(Integer microVersion) {
this.microVersion = microVersion;
}
}

public class SubsystemRegistrationImpl implements SubsystemRegistration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ public ModelNode getModel() {
if (minor != null) {
minorNode.set(minor.intValue());
}
final ModelNode microNode = model.get(ExtensionSubsystemResourceDefinition.MICRO_VERSION.getName());
Integer micro = subsystemInformation.getManagementInterfaceMicroVersion();
if (micro != null) {
microNode.set(micro.intValue());
}

final ModelNode xmlNode = model.get(ExtensionSubsystemResourceDefinition.XML_NAMESPACES.getName()).setEmptyList();
List<String> namespaces = subsystemInformation.getXMLNamespaces();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.EXTENSION;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.MANAGEMENT_MAJOR_VERSION;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.MANAGEMENT_MINOR_VERSION;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.MANAGEMENT_MICRO_VERSION;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;

import java.util.Locale;
Expand All @@ -43,6 +44,7 @@
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.descriptions.ResourceDescriptionResolver;
import org.jboss.as.controller.descriptions.common.CommonDescriptions;
import org.jboss.as.controller.operations.validation.IntRangeValidator;
import org.jboss.as.controller.operations.validation.StringLengthValidator;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
Expand Down Expand Up @@ -93,6 +95,11 @@ private void setValueType(ModelNode node) {
.setFlags(AttributeAccess.Flag.STORAGE_RUNTIME).build();

public static final SimpleAttributeDefinition MINOR_VERSION = new SimpleAttributeDefinitionBuilder(MANAGEMENT_MINOR_VERSION, ModelType.INT, true)
.setValidator(new IntRangeValidator(0, Integer.MAX_VALUE, true, false))
.setFlags(AttributeAccess.Flag.STORAGE_RUNTIME).build();

public static final SimpleAttributeDefinition MICRO_VERSION = new SimpleAttributeDefinitionBuilder(MANAGEMENT_MICRO_VERSION, ModelType.INT, true)
.setValidator(new IntRangeValidator(0, Integer.MAX_VALUE, true, false))
.setFlags(AttributeAccess.Flag.STORAGE_RUNTIME).build();

ExtensionSubsystemResourceDefinition() {
Expand All @@ -103,6 +110,7 @@ private void setValueType(ModelNode node) {
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
resourceRegistration.registerReadOnlyAttribute(MAJOR_VERSION, null);
resourceRegistration.registerReadOnlyAttribute(MINOR_VERSION, null);
resourceRegistration.registerReadOnlyAttribute(MICRO_VERSION, null);
resourceRegistration.registerReadOnlyAttribute(XML_NAMESPACES, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,11 @@ public interface SubsystemInformation {
* @return the minor interface version, or {@code null} if the subsystem does not have a versioned interface
*/
Integer getManagementInterfaceMinorVersion();

/**
* Gets the micro version of the subsystem's management interface, if available.
*
* @return the micro interface version, or {@code null} if the subsystem does not have a versioned interface
*/
Integer getManagementInterfaceMicroVersion();
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,32 @@
* @author <a href="mailto:tomaz.cerar@redhat.com">Tomaz Cerar</a>
*/
public abstract class AbstractSubsystemTransformer implements SubsystemTransformer {
private int majorManagementVersion;
private int minorManagementVersion;

protected AbstractSubsystemTransformer(int majorManagementVersion, int minorManagementVersion) {
private final int majorManagementVersion;
private final int minorManagementVersion;
private final int microManagementVersion;

protected AbstractSubsystemTransformer(int majorManagementVersion, int minorManagementVersion, int microManagementVersion) {
this.majorManagementVersion = majorManagementVersion;
this.minorManagementVersion = minorManagementVersion;
this.microManagementVersion = microManagementVersion;
}

@Override
public int getMajorManagementVersion() {
return majorManagementVersion;
}

@Override
public int getMinorManagementVersion() {
return minorManagementVersion;
}

@Override
public int getMicroManagementVersion() {
return microManagementVersion;
}

@Override
public ModelNode transformOperation(TransformationContext context, PathAddress address, ModelNode operation) {
return operation;
Expand Down
Loading

0 comments on commit 03006ae

Please sign in to comment.