Skip to content

Commit

Permalink
WINDUP-1724 Reduce list {source,target,tag} commands execution time: …
Browse files Browse the repository at this point in the history
…enhanced
  • Loading branch information
mrizzi committed Oct 30, 2017
1 parent 2784ded commit 8d62b1c
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package org.jboss.windup.bootstrap.commands;

import java.util.*;

import org.jboss.forge.furnace.Furnace;
import org.jboss.windup.bootstrap.help.Help;

/**
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*/
public abstract class AbstractListCommand implements Command, FurnaceDependent
public abstract class AbstractListCommand extends AbstractListCommandWithoutFurnace implements Command, FurnaceDependent
{
private Furnace furnace;

Expand All @@ -22,28 +19,4 @@ public void setFurnace(Furnace furnace)
{
this.furnace = furnace;
}

/**
* Print the given values after displaying the provided message.
*/
protected static void printValuesSorted(String message, Set<String> values)
{
System.out.println();
System.out.println(message + ":");
List<String> sorted = new ArrayList<>(values);
Collections.sort(sorted);
for (String value : sorted)
{
System.out.println("\t" + value);
}
}

protected static Set<String> getOptionValuesFromHelp(String optionName)
{
Set<String> options = new HashSet<>();
Help.load().getOptions().stream()
.filter(opt -> opt.getName().equals(optionName))
.forEach(optionDescription -> options.addAll(optionDescription.getAvailableOptions()));
return options;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.jboss.windup.bootstrap.commands;

import org.jboss.forge.furnace.Furnace;
import org.jboss.windup.bootstrap.help.Help;

import java.util.*;

/**
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*/
public abstract class AbstractListCommandWithoutFurnace implements Command
{
/**
* Print the given values after displaying the provided message.
*/
protected static void printValuesSorted(String message, Set<String> values)
{
System.out.println();
System.out.println(message + ":");
List<String> sorted = new ArrayList<>(values);
Collections.sort(sorted);
for (String value : sorted)
{
System.out.println("\t" + value);
}
}

protected static Set<String> getOptionValuesFromHelp(String optionName)
{
Set<String> options = new HashSet<>();
Help.load().getOptions().stream()
.filter(opt -> opt.getName().equals(optionName))
.forEach(optionDescription -> options.addAll(optionDescription.getAvailableOptions()));
return options;
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package org.jboss.windup.bootstrap.commands.windup;

import org.jboss.windup.bootstrap.commands.AbstractListCommand;
import org.jboss.windup.bootstrap.commands.AbstractListCommandWithoutFurnace;
import org.jboss.windup.bootstrap.commands.Command;
import org.jboss.windup.bootstrap.commands.CommandPhase;
import org.jboss.windup.bootstrap.commands.CommandResult;
import org.jboss.windup.bootstrap.commands.FurnaceDependent;
import org.jboss.windup.exec.configuration.options.SourceOption;

/**
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*/
public class ListSourceTechnologiesCommand extends AbstractListCommand implements Command, FurnaceDependent
public class ListSourceTechnologiesCommand extends AbstractListCommandWithoutFurnace implements Command
{
@Override
public CommandResult execute()
Expand All @@ -22,6 +21,6 @@ public CommandResult execute()
@Override
public CommandPhase getPhase()
{
return CommandPhase.PRE_EXECUTION;
return CommandPhase.PRE_CONFIGURATION;
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package org.jboss.windup.bootstrap.commands.windup;

import org.jboss.windup.bootstrap.commands.AbstractListCommand;
import org.jboss.windup.bootstrap.commands.AbstractListCommandWithoutFurnace;
import org.jboss.windup.bootstrap.commands.Command;
import org.jboss.windup.bootstrap.commands.CommandPhase;
import org.jboss.windup.bootstrap.commands.CommandResult;
import org.jboss.windup.bootstrap.commands.FurnaceDependent;
import org.jboss.windup.exec.configuration.options.IncludeTagsOption;

/**
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*/
public class ListTagsCommand extends AbstractListCommand implements Command, FurnaceDependent
public class ListTagsCommand extends AbstractListCommandWithoutFurnace implements Command
{
@Override
public CommandResult execute()
Expand All @@ -22,7 +21,7 @@ public CommandResult execute()
@Override
public CommandPhase getPhase()
{
return CommandPhase.PRE_EXECUTION;
return CommandPhase.PRE_CONFIGURATION;
}

}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package org.jboss.windup.bootstrap.commands.windup;

import org.jboss.windup.bootstrap.commands.AbstractListCommand;
import org.jboss.windup.bootstrap.commands.AbstractListCommandWithoutFurnace;
import org.jboss.windup.bootstrap.commands.Command;
import org.jboss.windup.bootstrap.commands.CommandPhase;
import org.jboss.windup.bootstrap.commands.CommandResult;
import org.jboss.windup.bootstrap.commands.FurnaceDependent;
import org.jboss.windup.exec.configuration.options.TargetOption;

/**
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*/
public class ListTargetTechnologiesCommand extends AbstractListCommand implements Command, FurnaceDependent
public class ListTargetTechnologiesCommand extends AbstractListCommandWithoutFurnace implements Command
{
@Override
public CommandResult execute()
Expand All @@ -22,7 +21,7 @@ public CommandResult execute()
@Override
public CommandPhase getPhase()
{
return CommandPhase.PRE_EXECUTION;
return CommandPhase.PRE_CONFIGURATION;
}

}

0 comments on commit 8d62b1c

Please sign in to comment.