@Override
public void initialize(ExtensionContext context) {
ROOT_LOGGER.debugf("Activating mod_cluster extension");
ModelVersion current = ModClusterModel.CURRENT.getVersion();
final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, current.getMajor(), current.getMinor(), current.getMicro());
final ManagementResourceRegistration registration = subsystem.registerSubsystemModel(new ModClusterSubsystemResourceDefinition(context.isRuntimeOnlyRegistrationValid()));
final ManagementResourceRegistration configuration = registration.registerSubModel(new ModClusterConfigResourceDefinition());
configuration.registerSubModel(new ModClusterSSLResourceDefinition());
final ManagementResourceRegistration dynamicLoadProvider = configuration.registerSubModel(DynamicLoadProviderDefinition.INSTANCE);
dynamicLoadProvider.registerSubModel(LoadMetricDefinition.INSTANCE);
dynamicLoadProvider.registerSubModel(CustomLoadMetricDefinition.INSTANCE);
subsystem.registerXMLElementWriter(new ModClusterSubsystemXMLWriter());
if (context.isRegisterTransformers()) {
// Register transformers for all versions except for the current one
for (ModClusterModel model : EnumSet.complementOf(EnumSet.of(ModClusterModel.CURRENT))) {
ModelVersion version = model.getVersion();
TransformationDescription.Tools.register(ModClusterSubsystemResourceDefinition.buildTransformation(version), subsystem, version);
}
}
}