ServiceManager.js 695 B

1234567891011121314151617181920212223242526272829
  1. /**
  2. * ServiceManager.js
  3. *
  4. * @author realor
  5. */
  6. import { Service } from './Service.js'
  7. class ServiceManager {
  8. static classes = {}
  9. static addClass(serviceClass) {
  10. this.classes[serviceClass.name] = serviceClass
  11. }
  12. /* returns an array with the names of the services of the given class */
  13. static getTypesOf(serviceClass) {
  14. let types = []
  15. for (let className in this.classes) {
  16. let cls = this.classes[className]
  17. if (cls.prototype instanceof serviceClass || cls === serviceClass) {
  18. types.push(className)
  19. }
  20. }
  21. return types
  22. }
  23. }
  24. export { ServiceManager }