1 package com.atlassian.maven.plugins.amps.product;
2
3 import java.io.File;
4
5 import java.util.List;
6 import java.util.Map;
7
8 import com.atlassian.maven.plugins.amps.MavenContext;
9 import org.apache.maven.plugin.MojoExecutionException;
10 import org.apache.maven.project.MavenProject;
11
12 import com.atlassian.maven.plugins.amps.MavenGoals;
13 import com.atlassian.maven.plugins.amps.Product;
14 import com.atlassian.maven.plugins.amps.ProductArtifact;
15
16 import static com.atlassian.maven.plugins.amps.util.ProjectUtils.firstNotNull;
17 import static com.atlassian.maven.plugins.amps.util.ProjectUtils.createDirectory;
18
19 public abstract class AbstractWebappProductHandler extends AbstractProductHandler
20 {
21 public AbstractWebappProductHandler(final MavenContext context, final MavenGoals goals, PluginProvider pluginProvider)
22 {
23 super(context, goals, pluginProvider);
24 }
25
26 public final void stop(final Product ctx) throws MojoExecutionException
27 {
28 goals.stopWebapp(ctx.getInstanceId(), ctx.getContainerId(), ctx);
29 }
30
31 @Override
32 protected final File extractApplication(Product ctx, File homeDir) throws MojoExecutionException
33 {
34 ProductArtifact defaults = getArtifact();
35 ProductArtifact artifact = new ProductArtifact(
36 firstNotNull(ctx.getGroupId(), defaults.getGroupId()),
37 firstNotNull(ctx.getArtifactId(), defaults.getArtifactId()),
38 firstNotNull(ctx.getVersion(), defaults.getVersion()));
39
40
41 return goals.copyWebappWar(ctx.getId(), getBaseDirectory(ctx), artifact);
42 }
43
44 @Override
45 protected final int startApplication(Product ctx, File app, File homeDir, Map<String, String> properties) throws MojoExecutionException
46 {
47 return goals.startWebapp(ctx.getInstanceId(), app, properties, getExtraContainerDependencies(), ctx);
48 }
49
50 @Override
51 protected boolean supportsStaticPlugins()
52 {
53 return true;
54 }
55
56 @Override
57 protected String getLog4jPropertiesPath()
58 {
59 return "WEB-INF/classes/log4j.properties";
60 }
61
62 protected abstract List<ProductArtifact> getExtraContainerDependencies();
63 }