You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ServiceManager.java 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Copyright (c) 2006-2014 DMDirc Developers
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. package com.dmdirc.plugins;
  23. import java.util.List;
  24. /**
  25. * A service manager handles registration and searches for {@link Service}s.
  26. */
  27. public interface ServiceManager {
  28. /**
  29. * Get a List of all services
  30. *
  31. * @return The list of all services.
  32. */
  33. List<Service> getAllServices();
  34. /**
  35. * Get an ExportedService object of the given name from any provider that provides it. This is
  36. * the same as doing getServiceProvider("export", name).getExportedService(name)
  37. *
  38. * @param name Name of this service
  39. *
  40. * @return An ExportedService object.
  41. *
  42. * @throws NoSuchProviderException If no provider exists for the requested service.
  43. */
  44. ExportedService getExportedService(final String name);
  45. /**
  46. * Get a service object for the given name/type if one exists.
  47. *
  48. * @param type Type of this service
  49. * @param name Name of this service
  50. *
  51. * @return The service requested, or null if service wasn't found and create wasn't specified
  52. */
  53. Service getService(final String type, final String name);
  54. /**
  55. * Get a service object for the given name/type.
  56. *
  57. * @param type Type of this service
  58. * @param name Name of this service
  59. * @param create If the requested service doesn't exist, should it be created?
  60. *
  61. * @return The service requested, or null if service wasn't found and create wasn't specified
  62. */
  63. Service getService(final String type, final String name, final boolean create);
  64. /**
  65. * Get a ServiceProvider object for the given name/type if one exists.
  66. *
  67. * @param type Type of this service
  68. * @param name Name of this service
  69. *
  70. * @return A ServiceProvider that provides the requested service.
  71. *
  72. * @throws NoSuchProviderException If no provider exists for the requested service
  73. */
  74. ServiceProvider getServiceProvider(final String type, final String name) throws
  75. NoSuchProviderException;
  76. /**
  77. * Get a ServiceProvider object for the given tpye, prioritising those in the list of names.
  78. *
  79. * @param type Type to look for
  80. * @param names Names to look for
  81. * @param fallback Fallback to the first provider of type that exists if one from the list is
  82. * not found.
  83. *
  84. * @return A ServiceProvider that provides the requested service.
  85. *
  86. * @throws NoSuchProviderException If no provider exists for the requested service and fallback
  87. * is false, or no providers exist at all.
  88. */
  89. ServiceProvider getServiceProvider(final String type, final List<String> names,
  90. final boolean fallback) throws NoSuchProviderException;
  91. /**
  92. * Get a List of all services of a specified type.
  93. *
  94. * @param type Type of service
  95. *
  96. * @return The list of services requested.
  97. */
  98. List<Service> getServicesByType(final String type);
  99. }