Skip to content

Commit

Permalink
Complex command invocation structures #131
Browse files Browse the repository at this point in the history
* renaming CommandRefWithDecorator to CommandRefDecorated
  • Loading branch information
andrus committed Nov 28, 2017
1 parent f3f7f99 commit 8ff4677
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions bootique/src/main/java/io/bootique/BQCoreModule.java
Expand Up @@ -21,7 +21,7 @@
import io.bootique.command.CommandDispatchThreadFactory; import io.bootique.command.CommandDispatchThreadFactory;
import io.bootique.command.CommandManager; import io.bootique.command.CommandManager;
import io.bootique.command.CommandManagerBuilder; import io.bootique.command.CommandManagerBuilder;
import io.bootique.command.CommandRefWithDecorator; import io.bootique.command.CommandRefDecorated;
import io.bootique.command.ExecutionPlanBuilder; import io.bootique.command.ExecutionPlanBuilder;
import io.bootique.config.CliConfigurationSource; import io.bootique.config.CliConfigurationSource;
import io.bootique.config.ConfigurationFactory; import io.bootique.config.ConfigurationFactory;
Expand Down Expand Up @@ -311,7 +311,7 @@ Cli provideCli(CliFactory cliFactory, @Args String[] args) {
ExecutionPlanBuilder provideExecutionPlanBuilder( ExecutionPlanBuilder provideExecutionPlanBuilder(
Provider<CliFactory> cliFactoryProvider, Provider<CliFactory> cliFactoryProvider,
Provider<CommandManager> commandManagerProvider, Provider<CommandManager> commandManagerProvider,
Set<CommandRefWithDecorator> commandDecorators, Set<CommandRefDecorated> commandDecorators,
BootLogger logger, BootLogger logger,
ShutdownManager shutdownManager) { ShutdownManager shutdownManager) {


Expand Down
10 changes: 5 additions & 5 deletions bootique/src/main/java/io/bootique/BQCoreModuleExtender.java
Expand Up @@ -11,7 +11,7 @@
import io.bootique.annotation.LogLevels; import io.bootique.annotation.LogLevels;
import io.bootique.command.Command; import io.bootique.command.Command;
import io.bootique.command.CommandDecorator; import io.bootique.command.CommandDecorator;
import io.bootique.command.CommandRefWithDecorator; import io.bootique.command.CommandRefDecorated;
import io.bootique.env.DeclaredVariable; import io.bootique.env.DeclaredVariable;
import io.bootique.meta.application.OptionMetadata; import io.bootique.meta.application.OptionMetadata;


Expand All @@ -34,7 +34,7 @@ public class BQCoreModuleExtender extends ModuleExtender<BQCoreModuleExtender> {
private Multibinder<DeclaredVariable> declaredVariables; private Multibinder<DeclaredVariable> declaredVariables;
private Multibinder<OptionMetadata> options; private Multibinder<OptionMetadata> options;
private Multibinder<Command> commands; private Multibinder<Command> commands;
private Multibinder<CommandRefWithDecorator> commandDecorators; private Multibinder<CommandRefDecorated> commandDecorators;


protected BQCoreModuleExtender(Binder binder) { protected BQCoreModuleExtender(Binder binder) {
super(binder); super(binder);
Expand Down Expand Up @@ -240,7 +240,7 @@ public BQCoreModuleExtender addCommand(Class<? extends Command> commandType) {
* @since 0.25 * @since 0.25
*/ */
public BQCoreModuleExtender decorateCommand(Class<? extends Command> commandType, CommandDecorator commandDecorator) { public BQCoreModuleExtender decorateCommand(Class<? extends Command> commandType, CommandDecorator commandDecorator) {
contributeCommandDecorators().addBinding().toInstance(new CommandRefWithDecorator(commandType, commandDecorator)); contributeCommandDecorators().addBinding().toInstance(new CommandRefDecorated(commandType, commandDecorator));
return this; return this;
} }


Expand All @@ -263,8 +263,8 @@ protected Multibinder<Command> contributeCommands() {
return commands != null ? commands : (commands = newSet(Command.class)); return commands != null ? commands : (commands = newSet(Command.class));
} }


protected Multibinder<CommandRefWithDecorator> contributeCommandDecorators() { protected Multibinder<CommandRefDecorated> contributeCommandDecorators() {
return commandDecorators != null ? commandDecorators : (commandDecorators = newSet(CommandRefWithDecorator.class)); return commandDecorators != null ? commandDecorators : (commandDecorators = newSet(CommandRefDecorated.class));
} }


protected MapBinder<String, String> contributeProperties() { protected MapBinder<String, String> contributeProperties() {
Expand Down
@@ -1,14 +1,16 @@
package io.bootique.command; package io.bootique.command;


/** /**
* An internal data structure that denotes a reference to a command combined with that command decorator.
*
* @since 0.25 * @since 0.25
*/ */
public class CommandRefWithDecorator { public class CommandRefDecorated {


private Class<? extends Command> commandType; private Class<? extends Command> commandType;
private CommandDecorator decorator; private CommandDecorator decorator;


public CommandRefWithDecorator(Class<? extends Command> commandType, CommandDecorator decorator) { public CommandRefDecorated(Class<? extends Command> commandType, CommandDecorator decorator) {
this.commandType = commandType; this.commandType = commandType;
this.decorator = decorator; this.decorator = decorator;
} }
Expand Down
Expand Up @@ -39,7 +39,7 @@ public ExecutionPlanBuilder(
} }


public static Map<Class<? extends Command>, CommandDecorator> mergeDecorators( public static Map<Class<? extends Command>, CommandDecorator> mergeDecorators(
Set<CommandRefWithDecorator> decoratorSet) { Set<CommandRefDecorated> decoratorSet) {




if (decoratorSet.isEmpty()) { if (decoratorSet.isEmpty()) {
Expand Down

0 comments on commit 8ff4677

Please sign in to comment.