class LimitsCheckingWorkspaceManager extends WorkspaceManager {

  @VisibleForTesting
  void checkRuntimeResourceAvailability(String accountId)
      throws NotFoundException, ServerException {
    try {
      resourceManager.checkResourcesAvailability(
          accountId,
          singletonList(new ResourceImpl(RuntimeResourceType.ID, 1, RuntimeResourceType.UNIT)));
    } catch (NoEnoughResourcesException e) {
      throw new LimitExceededException("You are not allowed to start more workspaces.");
    }
  }

  @Inject public  LimitsCheckingWorkspaceManager(
      WorkspaceDao workspaceDao,
      WorkspaceRuntimes runtimes,
      EventService eventService,
      AccountManager accountManager,
      PreferenceManager preferenceManager,
      WorkspaceValidator workspaceValidator,
      // own injects
      @Named("che.limits.workspace.env.ram") String maxRamPerEnv,
      EnvironmentRamCalculator environmentRamCalculator,
      ResourceManager resourceManager,
      ResourcesLocks resourcesLocks,
      DevfileIntegrityValidator devfileIntegrityValidator);

}