当前位置: 首页>>代码示例>>Java>>正文


Java HandlerUtils类代码示例

本文整理汇总了Java中org.springframework.shell.support.logging.HandlerUtils的典型用法代码示例。如果您正苦于以下问题:Java HandlerUtils类的具体用法?Java HandlerUtils怎么用?Java HandlerUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HandlerUtils类属于org.springframework.shell.support.logging包,在下文中一共展示了HandlerUtils类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: HandleHelp

import org.springframework.shell.support.logging.HandlerUtils; //导入依赖的package包/类
private InterpreterResult HandleHelp(JLineShell shell, String st) {
  java.util.logging.StreamHandler sh = null;
  java.util.logging.Logger springLogger = null;
  java.util.logging.Formatter formatter = new java.util.logging.Formatter() {
    public String format(java.util.logging.LogRecord record) {
      return record.getMessage();
    }
  };
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  try {
    sh = new java.util.logging.StreamHandler(baos, formatter);
    springLogger = HandlerUtils.getLogger(org.springframework.shell.core.SimpleParser.class);
    springLogger.addHandler(sh);
    shell.executeCommand(st);
  } catch (Exception e) {
    s_logger.error(e.getMessage(), e);
    return new InterpreterResult(Code.ERROR, e.getMessage());
  }
  finally {
    sh.flush();
    springLogger.removeHandler(sh);
    sh.close();
  }
  return new InterpreterResult(Code.SUCCESS, baos.toString());
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:26,代码来源:LensInterpreter.java

示例2: main

import org.springframework.shell.support.logging.HandlerUtils; //导入依赖的package包/类
public static void main(String[] args) {

		SpringApplication application = new SpringApplication(Application.class);
		application.setAdditionalProfiles("local");

		try {
			BootShim bs = new BootShim(args, application.run(args));
			bs.run();
		} catch (RuntimeException e) {
			throw e;
		} finally {
			HandlerUtils.flushAllHandlers(Logger.getLogger(""));
		}
	}
 
开发者ID:spring-projects,项目名称:spring-data-dev-tools,代码行数:15,代码来源:Application.java

示例3: main

import org.springframework.shell.support.logging.HandlerUtils; //导入依赖的package包/类
public static void main(String[] args) {

        ConfigurableApplicationContext ctx = SpringApplication.run(DemoApplication.class, args);

        try {
            BootShim bs = new BootShim(args,ctx);
            bs.run();
        } catch (RuntimeException e) {
            throw e;
        } finally {
            HandlerUtils.flushAllHandlers(Logger.getLogger(""));
        }
        }
 
开发者ID:jeffellin,项目名称:springshellwithboot,代码行数:14,代码来源:DemoApplication.java

示例4: setupLogging

import org.springframework.shell.support.logging.HandlerUtils; //导入依赖的package包/类
private void setupLogging() {
    Logger rootLogger = Logger.getLogger("");
    HandlerUtils.wrapWithDeferredLogHandler(rootLogger, Level.SEVERE);
    Logger sfwLogger = Logger.getLogger("org.springframework");
    sfwLogger.setLevel(Level.WARNING);
    Logger rooLogger = Logger.getLogger("org.springframework.shell");
    rooLogger.setLevel(Level.FINE);
}
 
开发者ID:jeffellin,项目名称:springshellwithboot,代码行数:9,代码来源:BootShim.java

示例5: doRun

import org.springframework.shell.support.logging.HandlerUtils; //导入依赖的package包/类
private ExitShellRequest doRun() {
    this.stopWatch.start();
    try {

        String[] commandsToExecuteAndThenQuit = this.commandLine.getShellCommandsToExecute();
        ExitShellRequest exitShellRequest;
        if (null != commandsToExecuteAndThenQuit) {

            boolean successful = false;
            exitShellRequest = ExitShellRequest.FATAL_EXIT;

            for (String cmd : commandsToExecuteAndThenQuit) {
                if (!(successful = this.lineShellComponent.executeCommand(cmd).isSuccess()))
                    break;
            }

            if (successful) {
                exitShellRequest = ExitShellRequest.NORMAL_EXIT;
            }
        }
        else if (this.applicationArguments.containsOption("help")) {
            System.out.println(FileUtils.readBanner(ShellCommandLineRunner.class, "/usage.txt"));
            exitShellRequest = ExitShellRequest.NORMAL_EXIT;
        } else {
            this.lineShellComponent.start();
            this.lineShellComponent.promptLoop();
            exitShellRequest = this.lineShellComponent.getExitShellRequest();
            if (exitShellRequest == null) {
                exitShellRequest = ExitShellRequest.NORMAL_EXIT;
            }
            this.lineShellComponent.waitForComplete();
        }

        if (this.lineShellComponent.isDevelopmentMode()) {
            System.out.println("Total execution time: " + this.stopWatch
                    .getLastTaskTimeMillis() + " ms");
        }

        return exitShellRequest;
    } catch (Exception ex) {
        throw new ShellException(ex.getMessage(), ex);
    } finally {
        HandlerUtils.flushAllHandlers(this.logger);
        this.stopWatch.stop();
    }
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:47,代码来源:ShellCommandLineRunner.java

示例6: doRun

import org.springframework.shell.support.logging.HandlerUtils; //导入依赖的package包/类
private ExitShellRequest doRun() {
	this.stopWatch.start();
	try {

		String[] commandsToExecuteAndThenQuit = this.commandLine.getShellCommandsToExecute();
		ExitShellRequest exitShellRequest;
		if (null != commandsToExecuteAndThenQuit) {

			boolean successful = false;
			exitShellRequest = ExitShellRequest.FATAL_EXIT;

			for (String cmd : commandsToExecuteAndThenQuit) {
				if (!(successful = this.lineShellComponent.executeCommand(cmd).isSuccess()))
					break;
			}

			if (successful) {
				exitShellRequest = ExitShellRequest.NORMAL_EXIT;
			}
		}
		else if (this.applicationArguments.containsOption("help")) {
			System.out.println(FileUtils.readBanner(ShellCommandLineRunner.class, "/usage.txt"));
			exitShellRequest = ExitShellRequest.NORMAL_EXIT;
		}
		else {
			this.lineShellComponent.start();
			this.lineShellComponent.promptLoop();
			exitShellRequest = this.lineShellComponent.getExitShellRequest();
			if (exitShellRequest == null) {
				exitShellRequest = ExitShellRequest.NORMAL_EXIT;
			}
			this.lineShellComponent.waitForComplete();
		}

		if (this.lineShellComponent.isDevelopmentMode()) {
			System.out.println("Total execution time: " + this.stopWatch.getLastTaskTimeMillis() + " ms");
		}

		return exitShellRequest;
	}
	catch (Exception ex) {
		throw new ShellException(ex.getMessage(), ex);
	}
	finally {
		HandlerUtils.flushAllHandlers(this.logger);
		this.stopWatch.stop();
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:49,代码来源:ShellCommandLineRunner.java


注:本文中的org.springframework.shell.support.logging.HandlerUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。