PageRenderTime 15ms CodeModel.GetById 11ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

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