public static Map<String, ParamModel> init(Class commandType, I18n i18n, LocalStringManager localStrings) { Class currentClazz = commandType; Map<String, ParamModel> results = new LinkedHashMap<String, ParamModel>(); while (currentClazz != null) { for (Field f : currentClazz.getDeclaredFields()) { I18n fieldI18n = f.getAnnotation(I18n.class); if (fieldI18n!=null) { localStrings = new LocalStringManagerImpl(commandType); } add(results, f, i18n, localStrings); } for (Method m : currentClazz.getDeclaredMethods()) { I18n fieldI18n = m.getAnnotation(I18n.class); if (fieldI18n!=null) { localStrings = new LocalStringManagerImpl(commandType); } add(results, m, i18n, localStrings); } currentClazz = currentClazz.getSuperclass(); } return results; }
public static Map<String, ParamModel> init(Class commandType, I18n i18n, LocalStringManager localStrings) { Class currentClazz = commandType; Map<String, ParamModel> results = new LinkedHashMap<String, ParamModel>(); while (currentClazz != null) { for (Field f : currentClazz.getDeclaredFields()) { I18n fieldI18n = f.getAnnotation(I18n.class); if (fieldI18n!=null) { localStrings = new LocalStringManagerImpl(commandType); } add(results, f, i18n, localStrings); } for (Method m : currentClazz.getDeclaredMethods()) { I18n fieldI18n = m.getAnnotation(I18n.class); if (fieldI18n!=null) { localStrings = new LocalStringManagerImpl(commandType); } add(results, m, i18n, localStrings); } currentClazz = currentClazz.getSuperclass(); } return results; }
public static Map<String, ParamModel> init(Class commandType, I18n i18n, LocalStringManager localStrings) { Class currentClazz = commandType; Map<String, ParamModel> results = new LinkedHashMap<String, ParamModel>(); while (currentClazz != null) { for (Field f : currentClazz.getDeclaredFields()) { I18n fieldI18n = f.getAnnotation(I18n.class); if (fieldI18n!=null) { localStrings = new LocalStringManagerImpl(commandType); } add(results, f, i18n, localStrings); } for (Method m : currentClazz.getDeclaredMethods()) { I18n fieldI18n = m.getAnnotation(I18n.class); if (fieldI18n!=null) { localStrings = new LocalStringManagerImpl(commandType); } add(results, m, i18n, localStrings); } currentClazz = currentClazz.getSuperclass(); } return results; }
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); 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; }
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 writeReport(OutputStream os) throws IOException { // The caller will read MAGIC and the next characters for success/failure // everything after the HEADER_END is good data writer = new PrintWriter(os); writer.print(MAGIC); if (isFailure()) { writer.print("FAILURE"); Throwable t = getFailureCause(); if (t != null) { writer.print(t); } } else { writer.print("SUCCESS"); } StringBuilder finalOutput = new StringBuilder(); getCombinedMessages(this, finalOutput); String outs = finalOutput.toString(); if (!ok(outs)) { // we want at least one line of output. Otherwise RemoteResponseManager // will consider this an error. It is NOT an error there just is no data to report. LocalStringManagerImpl localStrings = new LocalStringManagerImpl(PlainTextActionReporter.class); writer.print(localStrings.getLocalString("get.mon.no.data", "No monitoring data to report.")); writer.print("\n"); // forces an error to manifest constructor } else writer.print(outs); writer.flush(); }
public void postConstruct() { super.postConstruct(); listing = targetMethod.getAnnotation(Listing.class); resolverType = listing.resolver(); try { // we pass false for "useAnnotations" as the @Param declarations on // the target type are not used for the List method parameters. model = new GenericCommandModel(targetType, false, null, listing.i18n(), new LocalStringManagerImpl(targetType), habitat.getComponent(DomDocument.class), commandName, listing.resolver(), null); if (logger.isLoggable(level)) { for (String paramName : model.getParametersNames()) { CommandModel.ParamModel param = model.getModelFor(paramName); logger.fine("I take " + param.getName() + " parameters"); } } } 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.severe(msg); throw new ComponentException(msg, e); } }
@Override public void decorate(AdminCommandContext context, LbConfigs parent, LbConfig child) throws PropertyVetoException, TransactionFailure { Logger logger = LogDomains.getLogger(LbConfig.class, LogDomains.ADMIN_LOGGER); LocalStringManagerImpl localStrings = new LocalStringManagerImpl(LbConfig.class); String lbConfigName = child.getName(); LbConfig lbConfig = domain.getLbConfigs().getLbConfig(lbConfigName); //Ensure there are no refs if ( (lbConfig.getClusterRefOrServerRef().size() != 0 ) ) { String msg = localStrings.getLocalString("LbConfigNotEmpty", lbConfigName); throw new TransactionFailure(msg); } logger.info(localStrings.getLocalString("http_lb_admin.LbConfigDeleted", lbConfigName)); } }
@Override public void decorate(AdminCommandContext context, LbConfigs parent, LbConfig child) throws PropertyVetoException, TransactionFailure { Logger logger = LogDomains.getLogger(LbConfig.class, LogDomains.ADMIN_LOGGER); LocalStringManagerImpl localStrings = new LocalStringManagerImpl(LbConfig.class); String lbConfigName = child.getName(); LbConfig lbConfig = domain.getExtensionByType(LbConfigs.class).getLbConfig(lbConfigName); //Ensure there are no refs if ( (lbConfig.getClusterRefOrServerRef().size() != 0 ) ) { String msg = localStrings.getLocalString("LbConfigNotEmpty", lbConfigName); throw new TransactionFailure(msg); } logger.info(localStrings.getLocalString("http_lb_admin.LbConfigDeleted", lbConfigName)); } }
@Override public void decorate(AdminCommandContext context, LbConfigs parent, LbConfig child) throws PropertyVetoException, TransactionFailure { Logger logger = LogDomains.getLogger(LbConfig.class, LogDomains.ADMIN_LOGGER); LocalStringManagerImpl localStrings = new LocalStringManagerImpl(LbConfig.class); String lbConfigName = child.getName(); LbConfig lbConfig = domain.getExtensionByType(LbConfigs.class).getLbConfig(lbConfigName); //Ensure there are no refs if ( (lbConfig.getClusterRefOrServerRef().size() != 0 ) ) { String msg = localStrings.getLocalString("LbConfigNotEmpty", lbConfigName); throw new TransactionFailure(msg); } logger.info(localStrings.getLocalString("http_lb_admin.LbConfigDeleted", lbConfigName)); } }
@Override public void postConstruct() { super.postConstruct(); listing = targetMethod.getAnnotation(Listing.class); resolverType = listing.resolver(); try { // we pass false for "useAnnotations" as the @Param declarations on // the target type are not used for the List method parameters. cmdModel = new GenericCommandModel(targetType, false, null, listing.i18n(), new LocalStringManagerImpl(targetType), habitat.<DomDocument>getService(DomDocument.class), commandName, false, listing.resolver(), GenericListCommand.class); targetModel = habitat.<DomDocument>getService(DomDocument.class).buildModel(targetType); if (logger.isLoggable(level)) { for (String paramName : cmdModel.getParametersNames()) { CommandModel.ParamModel param = cmdModel.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, 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.getComponent(DomDocument.class), commandName, delete.resolver(), delete.decorator()); if (logger.isLoggable(level)) { for (String paramName : model.getParametersNames()) { CommandModel.ParamModel param = model.getModelFor(paramName); logger.fine("I take " + param.getName() + " parameters"); } } } 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.severe(msg); throw new ComponentException(msg, e); } }
PropertyVetoException, TransactionFailure { Logger logger = ConfigApiLoggerInfo.getLogger(); LocalStringManagerImpl localStrings = new LocalStringManagerImpl(Node.class); String nodeName = child.getName();
PropertyVetoException, TransactionFailure{ Logger logger = LogDomains.getLogger(Node.class, LogDomains.ADMIN_LOGGER); LocalStringManagerImpl localStrings = new LocalStringManagerImpl(Node.class); final ActionReport report = context.getActionReport(); String nodeName = child.getName();
@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); } }
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.getComponent(DomDocument.class), commandName, create.resolver(), create.decorator()); if (logger.isLoggable(level)) { for (String paramName : model.getParametersNames()) { CommandModel.ParamModel param = model.getModelFor(paramName); logger.fine("I take " + param.getName() + " parameters"); } } } 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.severe(msg); throw new ComponentException(msg, e); } }
LogDomains.ADMIN_LOGGER); LocalStringManagerImpl localStrings = new LocalStringManagerImpl(LbConfig.class); String msg = localStrings.getLocalString( "UnableToSetPropertyInLbconfig",
LogDomains.ADMIN_LOGGER); LocalStringManagerImpl localStrings = new LocalStringManagerImpl(LbConfig.class); String msg = localStrings.getLocalString( "UnableToSetPropertyInLbconfig",
@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); } }