public static void main(String[] args) throws InterruptedException { SpringApplicationBuilder builder = new SpringApplicationBuilder(Launcher.class); Set<ApplicationListener<?>> listeners = builder.application().getListeners(); for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) { ApplicationListener<?> listener = it.next(); if (listener instanceof LoggingApplicationListener) { it.remove(); } } builder.application().setListeners(listeners); builder.run(args); LOGGER.info("hi-log-log4j2 start successfully"); String a = "哈哈"; while (true) { LOGGER.info("i am test, {}", a); Thread.sleep(1000); } }
public static void main(String[] args) { SpringApplicationBuilder builder = new SpringApplicationBuilder(Launcher.class); Set<ApplicationListener<?>> listeners = builder.application().getListeners(); for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) { ApplicationListener<?> listener = it.next(); if (listener instanceof LoggingApplicationListener) { it.remove(); } } builder.application().setListeners(listeners); ConfigurableApplicationContext context = builder.run(args); LOGGER.info("collector trace start successfully"); KafkaConsumer kafkaConsumer = (KafkaConsumer<byte[], String>) context.getBean("kafkaConsumer"); Task task = (Task) context.getBean("rpcTraceTask"); // 优雅停止项目 Runtime.getRuntime().addShutdownHook(new ShutdownHookRunner(kafkaConsumer, task)); task.doTask(); }
public static void main(String[] args) { SpringApplicationBuilder builder = new SpringApplicationBuilder(Launcher.class); Set<ApplicationListener<?>> listeners = builder.application().getListeners(); for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) { ApplicationListener<?> listener = it.next(); if (listener instanceof LoggingApplicationListener) { it.remove(); } } builder.application().setListeners(listeners); ConfigurableApplicationContext context = builder.run(args); LOGGER.info("collector indexer start successfully"); KafkaConsumer kafkaConsumer = (KafkaConsumer<byte[], String>) context.getBean("kafkaConsumer"); Task task = (Task) context.getBean("indexerTask"); // 优雅停止项目 Runtime.getRuntime().addShutdownHook(new ShutdownHookRunner(kafkaConsumer, task)); task.doTask(); }
public static void main(String[] args) { SpringApplicationBuilder builder = new SpringApplicationBuilder(Launcher.class); Set<ApplicationListener<?>> listeners = builder.application().getListeners(); for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) { ApplicationListener<?> listener = it.next(); if (listener instanceof LoggingApplicationListener) { it.remove(); } } builder.application().setListeners(listeners); ConfigurableApplicationContext context = builder.run(args); LOGGER.info("collector backup start successfully"); KafkaConsumer kafkaConsumer = (KafkaConsumer<byte[], String>) context.getBean("kafkaConsumer"); Task task = (Task) context.getBean("backupTask"); // 优雅停止项目 Runtime.getRuntime().addShutdownHook(new ShutdownHookRunner(kafkaConsumer, task)); task.doTask(); }
public static void main(String[] args) { SpringApplicationBuilder builder = new SpringApplicationBuilder(Launcher.class); Set<ApplicationListener<?>> listeners = builder.application().getListeners(); for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) { ApplicationListener<?> listener = it.next(); if (listener instanceof LoggingApplicationListener) { it.remove(); } } builder.application().setListeners(listeners); ConfigurableApplicationContext context = builder.run(args); LOGGER.info("collector metrics start successfully"); KafkaConsumer kafkaConsumer = (KafkaConsumer<byte[], String>) context.getBean("kafkaConsumer"); Task task = (Task) context.getBean("metricsTask"); // 优雅停止项目 Runtime.getRuntime().addShutdownHook(new ShutdownHookRunner(kafkaConsumer, task)); task.doTask(); }
public static void main(String[] args) { SpringApplicationBuilder builder = new SpringApplicationBuilder(Launcher.class); Set<ApplicationListener<?>> listeners = builder.application().getListeners(); for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) { ApplicationListener<?> listener = it.next(); if (listener instanceof LoggingApplicationListener) { it.remove(); } } builder.application().setListeners(listeners); builder.run(args); LOGGER.info("服务C start successfully"); // 优雅停止项目 Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { LOGGER.info("try to stop the system"); synchronized (Launcher.class) { RUNNING = false; Launcher.class.notify(); } } }); synchronized (Launcher.class) { while (RUNNING) { try { Launcher.class.wait(); } catch (InterruptedException e) { LOGGER.error("wait error"); e.printStackTrace(); } } } }
public static void main(String[] args) { SpringApplicationBuilder builder = new SpringApplicationBuilder(Launcher.class); Set<ApplicationListener<?>> listeners = builder.application().getListeners(); for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) { ApplicationListener<?> listener = it.next(); if (listener instanceof LoggingApplicationListener) { it.remove(); } } builder.application().setListeners(listeners); builder.run(args); LOGGER.info("服务B start successfully"); // 优雅停止项目 Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { LOGGER.info("try to stop the system"); synchronized (Launcher.class) { RUNNING = false; Launcher.class.notify(); } } }); synchronized (Launcher.class) { while (RUNNING) { try { Launcher.class.wait(); } catch (InterruptedException e) { LOGGER.error("wait error"); e.printStackTrace(); } } } }
public static void main(String[] args) { SpringApplicationBuilder builder = new SpringApplicationBuilder(Launcher.class); Set<ApplicationListener<?>> listeners = builder.application().getListeners(); for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) { ApplicationListener<?> listener = it.next(); if (listener instanceof LoggingApplicationListener) { it.remove(); } } builder.application().setListeners(listeners); builder.run(args); LOGGER.info("服务E start successfully"); // 优雅停止项目 Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { LOGGER.info("try to stop the system"); synchronized (Launcher.class) { RUNNING = false; Launcher.class.notify(); } } }); synchronized (Launcher.class) { while (RUNNING) { try { Launcher.class.wait(); } catch (InterruptedException e) { LOGGER.error("wait error"); e.printStackTrace(); } } } }
public static void main(String[] args) { SpringApplicationBuilder builder = new SpringApplicationBuilder(Launcher.class); Set<ApplicationListener<?>> listeners = builder.application().getListeners(); for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) { ApplicationListener<?> listener = it.next(); if (listener instanceof LoggingApplicationListener) { it.remove(); } } builder.application().setListeners(listeners); builder.run(args); LOGGER.info("服务D start successfully"); // 优雅停止项目 Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { LOGGER.info("try to stop the system"); synchronized (Launcher.class) { RUNNING = false; Launcher.class.notify(); } } }); synchronized (Launcher.class) { while (RUNNING) { try { Launcher.class.wait(); } catch (InterruptedException e) { LOGGER.error("wait error"); e.printStackTrace(); } } } }
public static void main(String[] args) { SpringApplicationBuilder builder = new SpringApplicationBuilder(Application.class); Set<ApplicationListener<?>> listeners = builder.application().getListeners(); for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) { ApplicationListener<?> listener = it.next(); if (listener instanceof LoggingApplicationListener) { it.remove(); } } builder.application().setListeners(listeners); builder.run(args); LOGGER.info("接口A start successfully"); }
public static void main(String[] args) { SpringApplicationBuilder builder = new SpringApplicationBuilder(Launcher.class); Set<ApplicationListener<?>> listeners = builder.application().getListeners(); for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) { ApplicationListener<?> listener = it.next(); if (listener instanceof LoggingApplicationListener) { it.remove(); } } builder.application().setListeners(listeners); builder.run(args); LOGGER.info("alarm start successfully"); // 优雅停止项目 Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { LOGGER.info("try to stop the system"); synchronized (Launcher.class) { RUNNING = false; Launcher.class.notify(); } } }); synchronized (Launcher.class) { while (RUNNING) { try { Launcher.class.wait(); } catch (InterruptedException e) { LOGGER.error("wait error"); e.printStackTrace(); } } } }
public static void main(String[] args) { SpringApplicationBuilder builder = new SpringApplicationBuilder(Application.class); Set<ApplicationListener<?>> listeners = builder.application().getListeners(); for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) { ApplicationListener<?> listener = it.next(); if (listener instanceof LoggingApplicationListener) { it.remove(); } } builder.application().setListeners(listeners); builder.run(args); LOGGER.info("web start successfully"); }
public static void main(String[] args) { SpringApplicationBuilder builder = new SpringApplicationBuilder(Launcher.class); Set<ApplicationListener<?>> listeners = builder.application().getListeners(); for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) { ApplicationListener<?> listener = it.next(); if (listener instanceof LoggingApplicationListener) { it.remove(); } } builder.application().setListeners(listeners); builder.run(args); LOGGER.info("monitor start successfully"); // 优雅停止项目 Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { LOGGER.info("try to stop the system"); synchronized (Launcher.class) { RUNNING = false; Launcher.class.notify(); } } }); synchronized (Launcher.class) { while (RUNNING) { try { Launcher.class.wait(); } catch (InterruptedException e) { LOGGER.error("wait error"); e.printStackTrace(); } } } }
private Collection<ApplicationListener<?>> getListeners() { List<ApplicationListener<?>> listeners = new ArrayList<ApplicationListener<?>>(); listeners.add(new AnsiOutputApplicationListener()); listeners.add(new ConfigFileApplicationListener()); listeners.add(new ClasspathLoggingApplicationListener()); listeners.add(new LoggingApplicationListener()); listeners.add(new RemoteUrlPropertyExtractor()); return listeners; }
private Collection<ApplicationListener<?>> getListeners() { List<ApplicationListener<?>> listeners = new ArrayList<ApplicationListener<?>>(); listeners.add(new AnsiOutputApplicationListener()); listeners.add(new ConfigFileEnvironmentPostProcessor()); listeners.add(new EnvironmentPostProcessingApplicationListener()); listeners.add(new ClasspathLoggingApplicationListener()); listeners.add(new LoggingApplicationListener()); listeners.add(new RemoteUrlPropertyExtractor()); return listeners; }
public static SdcctApplication buildApplication() { ResourceLoader resourceLoader = new DefaultResourceLoader(); ResourcePatternResolver resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader); SdcctApplication app = ((SdcctApplication) new SdcctApplicationBuilder(buildSources(resourcePatternResolver)).addCommandLineProperties(false) .bannerMode(Mode.OFF).headless(true).resourceLoader(resourceLoader).application()); app.setPropertySource(buildPropertySource(resourcePatternResolver)); app.setListeners( app.getListeners().stream().filter((appListener -> !appListener.getClass().equals(LoggingApplicationListener.class))).collect(Collectors.toList())); return app; }
public static CrigttApplication buildApplication() { ResourceLoader resourceLoader = new DefaultResourceLoader(); CrigttApplication app = ((CrigttApplication) new CrigttApplicationBuilder(buildApplicationSources(resourceLoader)).addCommandLineProperties(false).showBanner(false) .headless(true).resourceLoader(resourceLoader).application()); app.setListeners(app.getListeners().stream().filter((appListener -> !appListener.getClass().equals(LoggingApplicationListener.class))) .collect(Collectors.toList())); return app; }
@Override public int getOrder() { return LoggingApplicationListener.DEFAULT_ORDER - 1; }
public static void main(String[] args) { SpringApplicationBuilder builder = new SpringApplicationBuilder(Launcher.class); Set<ApplicationListener<?>> listeners = builder.application().getListeners(); for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) { ApplicationListener<?> listener = it.next(); if (listener instanceof LoggingApplicationListener) { it.remove(); } } builder.application().setListeners(listeners); ConfigurableApplicationContext context = builder.run(args); LOGGER.info("log-generator start successfully"); GenerateLogService logService = context.getBean(GenerateLogService.class); logService.generateCoverLog(); // 优雅停止项目 Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { LOGGER.info("try to stop the system"); synchronized (Launcher.class) { RUNNING = false; Launcher.class.notify(); } } }); synchronized (Launcher.class) { while (RUNNING) { try { Launcher.class.wait(); } catch (InterruptedException e) { LOGGER.error("wait error"); e.printStackTrace(); } } } }