/uaa/src/main/java/org/springframework/roo/uaa/UaaRegistrationService.java

http://github.com/SpringSource/spring-roo · Java · 93 lines · 14 code · 8 blank · 71 comment · 0 complexity · 15b64985f72e3f410641d259c453234f MD5 · raw file

  1. package org.springframework.roo.uaa;
  2. import org.springframework.uaa.client.UaaService;
  3. import org.springframework.uaa.client.VersionHelper;
  4. import org.springframework.uaa.client.protobuf.UaaClient.Product;
  5. /**
  6. * Provides an API for any other Roo modules or add-ons to use to record UAA
  7. * data.
  8. * <p>
  9. * This API ensures UAA conventions used by Roo are observed.
  10. * <p>
  11. * Implementations should perform the initial registration of the
  12. * {@link #SPRING_ROO} product.
  13. * <p>
  14. * Implementations are required to buffer all notifications until such time as
  15. * the {@link UaaService} reaches a privacy level where they can be successfully
  16. * persisted. An implementation can rely on an invocation of
  17. * {@link #flushIfPossible()} or attempt to write notifications on a subsequent
  18. * call to a standard registration method. Implementations are therefore not
  19. * required to establish a thread to handle flushing themselves, although they
  20. * should make a final attempt on component deactivation.
  21. *
  22. * @author Ben Alex
  23. * @since 1.1.1
  24. */
  25. public interface UaaRegistrationService {
  26. /**
  27. * A HTTP URL of an "empty file" that add-ons can request if they wish to
  28. * eagerly perform a UAA upload.
  29. */
  30. String EMPTY_FILE_URL = "http://spring-roo-repository.springsource.org/empty_file.html";
  31. /**
  32. * Static representation of the Spring Roo product that should be used by
  33. * any modules requiring a product representation.
  34. */
  35. Product SPRING_ROO = VersionHelper.getProductFromManifest(
  36. UaaRegistrationServiceImpl.class, "Spring Roo");
  37. /**
  38. * Indicates to attempt to flush the buffered notifications. If the
  39. * {@link UaaService} is at a privacy level where it will accept
  40. * registrations, the buffered notifications should be sent to the service.
  41. * If the privacy level does not support this, the buffer should be
  42. * preserved.
  43. */
  44. void flushIfPossible();
  45. /**
  46. * Registers a new "feature use" within UAA. This method requires every
  47. * feature to be a bundle symbolic name. This method permits (but does not
  48. * require) the presentation of UTF-8 encoded custom JSON that will be
  49. * stored as feature_data in the resulting UAA payload.
  50. * <p>
  51. * This method may be invoked without determining if the bundle symbolic
  52. * name is public or not. This determination will be automatically made by
  53. * implementations. Non-public bundle symbolic names will not be used.
  54. *
  55. * @param bundleSymbolicName a BSN to register the use of (required)
  56. * @param customJson an optional JSON payload (can be null or an empty
  57. * string if required)
  58. */
  59. void registerBundleSymbolicNameUse(String bundleSymbolicName,
  60. String customJson);
  61. /**
  62. * Registers a new "project" within UAA against the presented product. Note
  63. * that UAA will use SHA-256 encoding for the project ID and it is never
  64. * stored or transmitted in a non-hashed form.
  65. * <p>
  66. * A product is mandatory because a caller requiring a fallback product may
  67. * use {@link #SPRING_ROO}. A project ID is mandatory because if low-level
  68. * product information is available, this indicates a project configuration
  69. * of some description is also available and therefore a project ID should
  70. * also be available.
  71. *
  72. * @param product the product (required)
  73. * @param projectId the project name to register (required)
  74. */
  75. void registerProject(Product product, String projectId);
  76. /**
  77. * Attempts to transmit the data immediately to the server. This will only
  78. * occur if the privacy level is acceptable and the {@link UaaService} is
  79. * capable of transmission. Note this method should very rarely be
  80. * necessary. It is only useful if an immediate transmission is desirable
  81. * for some special reason (eg UAA is being used to convey user
  82. * contributions to the server).
  83. */
  84. void requestTransmission();
  85. }