Example usage for org.springframework.context ConfigurableApplicationContext getMessage

List of usage examples for org.springframework.context ConfigurableApplicationContext getMessage

Introduction

In this page you can find the example usage for org.springframework.context ConfigurableApplicationContext getMessage.

Prototype

String getMessage(String code, @Nullable Object[] args, Locale locale) throws NoSuchMessageException;

Source Link

Document

Try to resolve the message.

Usage

From source file:com.jaspersoft.jasperserver.export.BaseExportImportCommand.java

protected boolean process(String[] args) throws IOException {
    Parameters exportParameters = parseArgs(args);
    ConfigurableApplicationContext ctx;
    if (exportParameters.hasParameter(ARG_HELP)) {
        ctx = createSpringContext(exportParameters, "helpApplicationContext-export-import*.xml");
    } else {//from  w ww.  ja  v  a 2s .  com
        ctx = createSpringContext(exportParameters, "applicationContext*.xml");
    }
    try {
        boolean success = true;
        CommandMetadata metadataBean = getCommandMetadataBean(ctx);
        if (exportParameters.hasParameter(ARG_HELP)) {
            CommandHelp helpBean = getHelpBean(ctx);
            helpBean.printHelp(args[0], metadataBean, System.out);
        } else {
            CommandBean commandBean = getCommandBean(exportParameters, ctx);
            try {
                metadataBean.validateParameters(exportParameters);
                commandBean.process(exportParameters);
            } catch (JSExceptionWrapper e) {
                throw e;
            } catch (JSException e) {
                success = false;
                if (log.isInfoEnabled()) {
                    log.info(e.getMessage(), e);
                }

                String message = ctx.getMessage(e.getMessage(), e.getArgs(), Locale.getDefault());
                System.err.println(message);
            }
        }
        return success;
    } finally {
        ctx.close();
    }
}