-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Radim Hatlapatka
committed
Feb 13, 2016
1 parent
169cca7
commit cfc233d
Showing
2 changed files
with
111 additions
and
24 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
commands/src/main/java/org/wildfly/extras/creaper/commands/deployments/Undeploy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package org.wildfly.extras.creaper.commands.deployments; | ||
|
||
|
||
import org.wildfly.extras.creaper.core.online.OnlineCommand; | ||
import org.wildfly.extras.creaper.core.online.OnlineCommandContext; | ||
|
||
/** | ||
* Command which takes care about undeploying specified application (the content is by default also removed) | ||
* <p> | ||
* In case of domain the deployment is by default undeployed from all relevant server groups | ||
* (server groups having the deployment enabled) | ||
* </p> | ||
*/ | ||
public final class Undeploy implements OnlineCommand { | ||
private final String deploymentName; | ||
private final boolean keepContent; | ||
|
||
private Undeploy(Builder builder) { | ||
this.deploymentName = builder.deploymentName; | ||
this.keepContent = builder.keepContent; | ||
} | ||
|
||
@Override | ||
public void apply(OnlineCommandContext ctx) throws Exception { | ||
StringBuilder cmd = new StringBuilder("undeploy ").append(deploymentName); | ||
if (keepContent) { | ||
cmd.append(" --keep-content"); | ||
} | ||
if (ctx.options.isDomain) { | ||
cmd.append(" --all-relevant-server-groups"); | ||
} | ||
ctx.client.executeCli(cmd.toString()); | ||
} | ||
|
||
public static final class Builder { | ||
private String deploymentName; | ||
private boolean keepContent = false; | ||
|
||
public Builder(String deploymentName) { | ||
this.deploymentName = deploymentName; | ||
} | ||
|
||
/** | ||
* Defines that the content should be left in the deployment repository => only undeployed without removing it. | ||
*/ | ||
public Builder keepContent() { | ||
this.keepContent = true; | ||
return this; | ||
} | ||
|
||
|
||
public Undeploy build() { | ||
return new Undeploy(this); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters