public CommandModelImpl(Class<?> commandType) { Service service = commandType.getAnnotation(Service.class); commandName = service != null ? service.name() : null; commandClass = commandType; i18n = commandType.getAnnotation(I18n.class); execOn = commandType.getAnnotation(ExecuteOn.class); localStrings = new LocalStringManagerImpl(commandType); managedJob = AnnotationUtil.presentTransitive(ManagedJob.class, commandType); params = init(commandType, i18n, localStrings); Class currentClazz = commandType; boolean found = false; while (currentClazz != null) { if (currentClazz.isAnnotationPresent(UnknownOptionsAreOperands.class)) { found = true; } currentClazz = currentClazz.getSuperclass(); } dashOk = found; }
public CommandModelImpl(Class<?> commandType) { Service service = commandType.getAnnotation(Service.class); commandName = service != null ? service.name() : null; commandClass = commandType; i18n = commandType.getAnnotation(I18n.class); execOn = commandType.getAnnotation(ExecuteOn.class); localStrings = new LocalStringManagerImpl(commandType); managedJob = AnnotationUtil.presentTransitive(ManagedJob.class, commandType); params = init(commandType, i18n, localStrings); Class currentClazz = commandType; boolean found = false; while (currentClazz != null) { if (currentClazz.isAnnotationPresent(UnknownOptionsAreOperands.class)) { found = true; } currentClazz = currentClazz.getSuperclass(); } dashOk = found; }
@Override public void postConstruct() { super.postConstruct(); create = getAnnotation(targetMethod, Create.class); resolverType = create.resolver(); try { model = new GenericCommandModel(targetType, true, create.cluster(), create.i18n(), new LocalStringManagerImpl(targetType), habitat.<DomDocument>getService(DomDocument.class), commandName, AnnotationUtil.presentTransitive(ManagedJob.class, create.decorator()), create.resolver(), create.decorator()); if (logger.isLoggable(level)) { for (String paramName : model.getParametersNames()) { CommandModel.ParamModel param = model.getModelFor(paramName); logger.log(Level.FINE, "I take {0} parameters", param.getName()); } } } catch(Exception e) { String msg = localStrings.getLocalString(GenericCrudCommand.class, "GenericCreateCommand.command_model_exception", "Exception while creating the command model for the generic command {0} : {1}", commandName, e.getMessage()); logger.log(Level.SEVERE, ConfigApiLoggerInfo.GENERIC_CREATE_CMD_FAILED, commandName); throw new RuntimeException(msg, e); } }
@Override public void postConstruct() { super.postConstruct(); delete = targetMethod.getAnnotation(Delete.class); resolverType = delete.resolver(); try { // we pass false for "useAnnotations" as the @Param declarations on // the target type are not used for the Delete method parameters. model = new GenericCommandModel(targetType, false, delete.cluster(), delete.i18n(), new LocalStringManagerImpl(targetType), habitat.<DomDocument>getService(DomDocument.class), commandName, AnnotationUtil.presentTransitive(ManagedJob.class, delete.decorator()), delete.resolver(), delete.decorator()); if (logger.isLoggable(level)) { for (String paramName : model.getParametersNames()) { CommandModel.ParamModel param = model.getModelFor(paramName); logger.log(Level.FINE, "I take {0} parameters", param.getName()); } } } catch(Exception e) { String msg = localStrings.getLocalString(GenericCrudCommand.class, "GenericCreateCommand.command_model_exception", "Exception while creating the command model for the generic command {0} : {1}", commandName, e.getMessage()); LogHelper.log(logger, Level.SEVERE, ConfigApiLoggerInfo.GENERIC_CREATE_CMD_FAILED, e, new Object[] {commandName}); throw new RuntimeException(msg, e); } }
isManagedJob = AnnotationUtil.presentTransitive(ManagedJob.class, command.getClass());
isManagedJob = AnnotationUtil.presentTransitive(ManagedJob.class, command.getClass());