private InjectionResolver<Param> getInjector(AdminCommand command, ParameterMap parameters, Map<String, File> map) { CommandModel model; try { CommandModelProvider c = CommandModelProvider.class.cast(command); model = c.getModel(); } catch (ClassCastException e) { model = new CommandModelImpl(command.getClass()); } return new MapInjectionResolver(model, parameters, map); }
private InjectionResolver<Param> getInjector(AdminCommand command, ParameterMap parameters, MultiMap<String, File> map, AdminCommandContext context) { CommandModel model = command instanceof CommandModelProvider ? ((CommandModelProvider)command).getModel() : new CommandModelImpl(command.getClass()); MapInjectionResolver injector = new MapInjectionResolver(model, parameters, map); injector.setContext(context); return injector; }
/** * Inject this instance with the final values of all the command * parameters. * * @throws CommandException if execution of the command fails * @throws CommandValidationException if there's something wrong * with the options or arguments */ protected void inject() throws CommandException { // injector expects operands to be in the ParameterMap with the key // "DEFAULT" options.set("DEFAULT", operands); // if command has a "terse" option, set it from ProgramOptions if (commandModel.getModelFor("terse") != null) options.set("terse", Boolean.toString(programOpts.isTerse())); // initialize the injector. InjectionResolver<Param> injector = new MapInjectionResolver(commandModel, options); // inject try { injectionMgr.inject(this, injector); } catch (UnsatisfiedDependencyException e) { throw new CommandValidationException(e.getMessage(), e); } }
/** * Inject this instance with the final values of all the command * parameters. * * @throws CommandException if execution of the command fails * @throws CommandValidationException if there's something wrong * with the options or arguments */ protected void inject() throws CommandException { // injector expects operands to be in the ParameterMap with the key // "DEFAULT" options.set("DEFAULT", operands); // if command has a "terse" option, set it from ProgramOptions if (commandModel.getModelFor("terse") != null) options.set("terse", Boolean.toString(programOpts.isTerse())); // initialize the injector. InjectionResolver<Param> injector = new MapInjectionResolver(commandModel, options); // inject try { injectionMgr.inject(this, injector); } catch (UnsatisfiedDependencyException e) { throw new CommandValidationException(e.getMessage(), e); } }
new MapInjectionResolver(model, parameters, ufm.optionNameToFileMap()); injectionMgr.setContext(context);
new MapInjectionResolver(model, parameters, ufm.optionNameToFileMap()); injectionMgr.setContext(context);