Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Replace run() with performWork() below ConfigurableProjectCommand
Browse files Browse the repository at this point in the history
    This prepares to split run() into phases to:-

     - run preparatory checks, possibly aborting
     - run "before" command
     - perform work
     - run "after" command

    To avoid the upfront cost of rewriting each implementation, this
    simple rename and wrapper will allow us to update subclasses as
    we have time.
  • Loading branch information
davidmason committed Nov 18, 2013
1 parent 317b862 commit 9f46659
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 8 deletions.
Expand Up @@ -59,4 +59,12 @@ public ConfigurableProjectCommand(O opts) {
protected String getProjectType() {
return this.getOpts().getProjectType();
}


@Override
public void run() throws Exception {
performWork();
};

protected abstract void performWork() throws Exception;

This comment has been minimized.

Copy link
@seanf

seanf Nov 19, 2013

Contributor

These two methods need javadocs to make the distinction clear. ZanataCommand.run() should probably say something too (eg "may include before/after hooks"). Actually, if ZanataCommand.run() is well documented, ConfigurableProjectCommand.run() can just inherit the docs.

}
Expand Up @@ -24,7 +24,7 @@ public ListLocalCommand(ConfigurableProjectOptions opts) {
}

@Override
public void run() {
public void performWork() {
// TODO remove this
log.debug("listlocal");

Expand Down
Expand Up @@ -43,7 +43,7 @@ public ListRemoteCommand(ConfigurableProjectOptions opts) {
}

@Override
public void run() throws Exception {
public void performWork() throws Exception {
log.info("Server: " + getOpts().getUrl());
log.info("Project: " + getOpts().getProj());
log.info("Version: " + getOpts().getProjectVersion());
Expand Down
Expand Up @@ -68,7 +68,7 @@ protected String getProjectType() {
}

@Override
public void run() throws Exception {
public void performWork() throws Exception {
log.info("Server: {}", getOpts().getUrl());
log.info("Project: {}", getOpts().getProj());
log.info("Version: {}", getOpts().getProjectVersion());
Expand Down
Expand Up @@ -79,7 +79,7 @@ protected String getProjectType() {
}

@Override
public void run() throws Exception {
public void performWork() throws Exception {
log.info("Server: {}", getOpts().getUrl());
log.info("Project: {}", getOpts().getProj());
log.info("Version: {}", getOpts().getProjectVersion());
Expand Down
Expand Up @@ -138,7 +138,7 @@ public static void logOptions(Logger logger, PullOptions opts) {
}

@Override
public void run() throws Exception {
public void performWork() throws Exception {
logOptions();

LocaleList locales = getOpts().getLocaleMapList();
Expand Down
Expand Up @@ -59,7 +59,7 @@ public RawPullCommand(PullOptions opts) {
}

@Override
public void run() throws Exception {
public void performWork() throws Exception {
PullCommand.logOptions(log, getOpts());
if (getOpts().isDryRun()) {
log.info("DRY RUN: no permanent changes will be made");
Expand Down
Expand Up @@ -197,7 +197,7 @@ private boolean pushTrans() {
}

@Override
public void run() throws Exception {
public void performWork() throws Exception {
logOptions(log, getOpts());
pushCurrentModule();

Expand Down
Expand Up @@ -82,7 +82,7 @@ public RawPushCommand(PushOptions opts, ZanataProxyFactory factory,
}

@Override
public void run() throws Exception {
public void performWork() throws Exception {
PushCommand.logOptions(log, getOpts());
log.warn("Using EXPERIMENTAL project type 'file'.");

Expand Down

0 comments on commit 9f46659

Please sign in to comment.