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.

ExtensionStorage.java 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (C) 2012-present the original author or authors.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.pf4j.processor;
  17. import javax.annotation.processing.Filer;
  18. import javax.lang.model.element.Element;
  19. import java.util.Map;
  20. import java.util.Set;
  21. /**
  22. * It's a storage (database) that persists {@link org.pf4j.Extension}s.
  23. * The standard operations supported by storage are {@link #read} and {@link #write}.
  24. * The storage is populated by {@link ExtensionAnnotationProcessor}.
  25. *
  26. * @author Decebal Suiu
  27. */
  28. public abstract class ExtensionStorage {
  29. protected final ExtensionAnnotationProcessor processor;
  30. public ExtensionStorage(ExtensionAnnotationProcessor processor) {
  31. this.processor = processor;
  32. }
  33. public abstract Map<String, Set<String>> read();
  34. public abstract void write(Map<String, Set<String>> extensions);
  35. /**
  36. * Helper method.
  37. */
  38. protected Filer getFiler() {
  39. return processor.getProcessingEnvironment().getFiler();
  40. }
  41. /**
  42. * Helper method.
  43. */
  44. protected void error(String message, Object... args) {
  45. processor.error(message, args);
  46. }
  47. /**
  48. * Helper method.
  49. */
  50. protected void error(Element element, String message, Object... args) {
  51. processor.error(element, message, args);
  52. }
  53. /**
  54. * Helper method.
  55. */
  56. protected void info(String message, Object... args) {
  57. processor.info(message, args);
  58. }
  59. /**
  60. * Helper method.
  61. */
  62. protected void info(Element element, String message, Object... args) {
  63. processor.info(element, message, args);
  64. }
  65. }