class BaseSubsystem extends AnnotatedSubsystem<M> {

   protected void setAttribute(String name, Object value, SubsystemContext<M> context) throws ErrorEventException {
      NamespacedKey key = NamespacedKey.parse(name);
      String attributeName = key.getNamedRepresentation();
      AttributeDefinition ad = registry.getAttribute(attributeName);
      if(ad == null || !ad.isWritable()) {
         context.logger().debug("Received set for unrecognized attribute {}", name);
         ErrorEvent error = Errors.unsupportedAttribute(name);
         throw new ErrorEventException(error);
      }
      
      if(key.isInstanced()) {
         if(!context.model().hasInstanceOf(key.getInstance(), key.getNamespace())) {
            context.logger().debug("Received set for unsupported instance attribute {}", name);
            ErrorEvent error = Errors.unsupportedAttribute(name);
            throw new ErrorEventException(error);
         }
      }
      else {
         if(!context.model().getCapabilities().contains(key.getNamespace())) {
            context.logger().debug("Received set for unsupported attribute {}", name);
            ErrorEvent error = Errors.unsupportedAttribute(name);
            throw new ErrorEventException(error);
         }
      }
      
      if(ad.hasMinMax()) {
         Errors.assertValidRequest(ad.isInRange(value), String.format("Attribute %s must be between %s and %s", ad.getName(), ad.getMin(), ad.getMax()));
      }
      context.model().setAttribute(name, ad.getType().coerce(value));
   }

}