@Override
public ManagementResourceRegistration registerSubModel(final ResourceDefinition resourceDefinition) {
if (resourceDefinition == null) {
throw MESSAGES.nullVar("resourceDefinition");
}
final PathElement address = resourceDefinition.getPathElement();
if (address == null) {
throw MESSAGES.cannotRegisterSubmodelWithNullPath();
}
if (isRuntimeOnly()) {
throw MESSAGES.cannotRegisterSubmodel();
}
final AbstractResourceRegistration existing = getSubRegistration(PathAddress.pathAddress(address));
if (existing != null && existing.getValueString().equals(address.getValue())) {
throw MESSAGES.nodeAlreadyRegistered(existing.getLocationString());
}
final String key = address.getKey();
final NodeSubregistry child = getOrCreateSubregistry(key);
final ManagementResourceRegistration resourceRegistration = child.register(address.getValue(), resourceDefinition, false);
resourceDefinition.registerAttributes(resourceRegistration);
resourceDefinition.registerOperations(resourceRegistration);
resourceDefinition.registerChildren(resourceRegistration);
return resourceRegistration;
}