/maven-amps-plugin/src/main/java/com/atlassian/maven/plugins/amps/product/ProductHandler.java

https://bitbucket.org/mmeinhold/amps · Java · 96 lines · 23 code · 16 blank · 57 comment · 0 complexity · 31774a4650711a137af45b60b28155ef MD5 · raw file

  1. package com.atlassian.maven.plugins.amps.product;
  2. import java.io.File;
  3. import java.io.IOException;
  4. import java.util.List;
  5. import org.apache.maven.plugin.MojoExecutionException;
  6. import com.atlassian.maven.plugins.amps.Product;
  7. import com.atlassian.maven.plugins.amps.util.ConfigFileUtils;
  8. public interface ProductHandler
  9. {
  10. /**
  11. * @return a convenient string to identify this application, especially for the context path.
  12. * No further restriction is defined on this ID.
  13. */
  14. String getId();
  15. /**
  16. * Extracts the product and its home, prepares them and starts the product.
  17. * @return the port on which the product is accessible
  18. */
  19. int start(Product ctx) throws MojoExecutionException;
  20. void stop(Product ctx) throws MojoExecutionException;
  21. int getDefaultHttpPort();
  22. String getDefaultContextPath();
  23. String getDefaultContainerId();
  24. /**
  25. * Return the directory to snapshot when we want to restore
  26. * the state of the instance.
  27. *
  28. * Most often, equivalent to the home directory.
  29. *
  30. * Studio snapshots several homes together.
  31. */
  32. File getSnapshotDirectory(Product product);
  33. File getHomeDirectory(Product product);
  34. File getBaseDirectory(Product product);
  35. /**
  36. * Lists parameters which must be replaced in the configuration files of the home directory.
  37. * <p/>
  38. * Replacements returned by this method are guaranteed to be reversed when creating the home zip.
  39. *
  40. * @return a mutable list of replacements
  41. */
  42. List<ConfigFileUtils.Replacement> getReplacements(Product product);
  43. /**
  44. * List the configuration files. Used when doing a snapshot to reopen on another
  45. * machine, with different port, context path, path, instanceId
  46. * <p/>
  47. * Files returned by this method are guaranteed to be reversed when creating the home zip.
  48. *
  49. * @param snapshotCopyDir A snapshot equivalent to the home in most cases. It is a copy of the folder: {@link #getSnapshotDirectory(Product)}
  50. * The only exception is for the Studio product itself, as the snapshot dir is the parent of the studio home (so that it
  51. * contains the homes of all products).
  52. *
  53. * @return a mutable list of files
  54. */
  55. List<File> getConfigFiles(Product product, File snapshotCopyDir);
  56. /**
  57. * Snapshots the home directory. The goal is that the state is totally restored if we restart the application
  58. * with this minimal snapshot.
  59. * <p/>
  60. * It must call {@link #cleanupProductHomeForZip(Product, File)} to clean up the snapshot.
  61. *
  62. *
  63. * @param homeDirectory The path to the previous run's home directory.
  64. * @param targetZip The path to the final zip file.
  65. * @param product The product
  66. *
  67. * @since 3.1-m3
  68. */
  69. public void createHomeZip(final File homeDirectory, final File targetZip, final Product product) throws MojoExecutionException;
  70. /**
  71. * Prepares the home directory to be zipped.
  72. * <ul>
  73. * <li>Removes all unnecessary files</li>
  74. * <li>Perform product-specific clean-up</li>
  75. * <ul>
  76. * @param product the product details
  77. * @param homeDirectory an image of the home directory. This is not the current home, so you're free to remove files and parametrise them.
  78. */
  79. public void cleanupProductHomeForZip(Product product, File homeDirectory) throws MojoExecutionException, IOException;
  80. }