@Override public void onApplicationEvent(ApplicationContextEvent event) { if (event instanceof ContextRefreshedEvent && !servicePublisherStarted) { // Application initialization complete. Export astrix-services. if (isServer()) { this.astrixContext.startServicePublisher(); } servicePublisherStarted = true; } else if (event instanceof ContextClosedEvent || event instanceof ContextStoppedEvent) { /* * What's the difference between the "stopped" and "closed" event? In our embedded * integration tests we only receive ContextClosedEvent */ destroyAstrixContext(); } }
@Override public void onApplicationEvent(ApplicationContextEvent event) { try { if (event instanceof ContextRefreshedEvent && !isDeployed) { // deploy the process application afterPropertiesSet(); } else if (event instanceof ContextClosedEvent) { // undeploy the process application destroy(); } else { // ignore } } catch (Exception e) { throw new RuntimeException(e); } }
@Override public void onApplicationEvent(ApplicationContextEvent event) { if (event instanceof ContextClosedEvent || event instanceof ContextStoppedEvent) { List<Entity> everyone = entityRepository.findByXIsNotNullAndYIsNotNullAndZIsNotNull(); GameOutput output = new GameOutput("[red]EmergentMUD is shutting down. Please check back later!"); entityService.sendMessageToListeners(everyone, output); } }
public void onApplicationEvent(ApplicationContextEvent event) { // publish if (event instanceof ContextRefreshedEvent) { registerService(event.getApplicationContext()); } else if (event instanceof ContextClosedEvent) { unregisterService(); } }
@Override public final void onApplicationEvent(final ApplicationContextEvent event) { try { final ApplicationContext context = event.getApplicationContext(); if (context instanceof XmlWebApplicationContext) { final XmlWebApplicationContext ctx = (XmlWebApplicationContext) context; String webContextName = ctx.getServletContext().getServletContextName(); if (webContextName.contains("/")) { webContextName = webContextName.substring(webContextName.indexOf('/')); } ctx.setDisplayName(webContextName); MDC.put(LeveringVeld.MDC_APPLICATIE_NAAM, webContextName).close(); } LOGGER.debug("Context event '{}'; id='{}', displayName='{}'", event.getClass().getSimpleName(), event .getApplicationContext().getId(), event.getApplicationContext().getDisplayName()); if (event instanceof ContextClosedEvent) { LOGGER.info("==> Context voor applicatie '{}' is gestopt", event.getApplicationContext().getId()); } /* Wanneer een applicatie is gestart, dan wordt een ContextRefreshedEvent gestuurt **/ if (event instanceof ContextRefreshedEvent) { LOGGER.info("==> Context voor applicatie '{}' is gestart/herstart", event.getApplicationContext() .getId()); logJvmSettings(); } } catch (final ApplicationContextException ex) { LOGGER.error("Fout bij het opstarten van de applicatiecontext bij event {}", event.toString(), ex); } }
@Test public void contextRefreshed() throws Exception { Assert.assertEquals(2, contextRefreshedList.size()); for (int i = 0; i < contextRefreshedList.size(); i++) Assert.assertEquals(i + 1, numeric.toInt(contextRefreshedList.get(i))); for (int i = 0; i < 2; i++) { ((ContainerImpl) container).onApplicationEvent(new ContextRefreshedEvent(getApplicationContext())); Assert.assertEquals(4 + i * 2, contextRefreshedList.size()); for (int j = 0; j < contextRefreshedList.size(); j++) Assert.assertEquals(j % 2 + 1, numeric.toInt(contextRefreshedList.get(j))); } Field field = ContainerImpl.class.getDeclaredField("refreshedListeners"); field.setAccessible(true); Object object = field.get(container); field.set(container, Optional.empty()); for (int i = 0; i < 2; i++) { ((ContainerImpl) container).onApplicationEvent(new ContextRefreshedEvent(getApplicationContext())); Assert.assertEquals(6, contextRefreshedList.size()); for (int j = 0; j < contextRefreshedList.size(); j++) Assert.assertEquals(j % 2 + 1, numeric.toInt(contextRefreshedList.get(j))); } ((ContainerImpl) container).onApplicationEvent(new ApplicationContextEvent(getApplicationContext()) { }); Assert.assertEquals(6, contextRefreshedList.size()); for (int i = 0; i < contextRefreshedList.size(); i++) Assert.assertEquals(i % 2 + 1, numeric.toInt(contextRefreshedList.get(i))); field.set(container, object); }
@Test public void contextClosed() throws Exception { for (int i = 0; i < 2; i++) { ((ContainerImpl) container).onApplicationEvent(new ContextClosedEvent(getApplicationContext())); Assert.assertEquals(2 + i * 2, contextClosedList.size()); for (int j = 0; j < contextRefreshedList.size(); j++) Assert.assertEquals(j % 2 + 1, numeric.toInt(contextClosedList.get(j))); } Field field = ContainerImpl.class.getDeclaredField("closedListeners"); field.setAccessible(true); Object object = field.get(container); field.set(container, Optional.empty()); for (int i = 0; i < 2; i++) { ((ContainerImpl) container).onApplicationEvent(new ContextClosedEvent(getApplicationContext())); Assert.assertEquals(4, contextClosedList.size()); for (int j = 0; j < contextClosedList.size(); j++) Assert.assertEquals(j % 2 + 1, numeric.toInt(contextClosedList.get(j))); } ((ContainerImpl) container).onApplicationEvent(new ApplicationContextEvent(getApplicationContext()) { }); Assert.assertEquals(4, contextClosedList.size()); for (int i = 0; i < contextClosedList.size(); i++) Assert.assertEquals(i % 2 + 1, numeric.toInt(contextClosedList.get(i))); field.set(container, object); }
protected void onApplicationEvent(ApplicationEvent event) { ConfigurableApplicationContext initializerApplicationContext = AutoConfigurationReportLoggingInitializer.this.applicationContext; if (event instanceof ContextRefreshedEvent) { if (((ApplicationContextEvent) event) .getApplicationContext() == initializerApplicationContext) { logAutoConfigurationReport(); } } else if (event instanceof ApplicationFailedEvent) { if (((ApplicationFailedEvent) event) .getApplicationContext() == initializerApplicationContext) { logAutoConfigurationReport(true); } } }
/** * {@inheritDoc} * @see org.springframework.context.ApplicationListener#onApplicationEvent(org.springframework.context.ApplicationEvent) */ @Override public void onApplicationEvent(final ApplicationContextEvent event) { if(event.getApplicationContext()==appCtx) { if(event instanceof ContextRefreshedEvent) { start(); } else if(event instanceof ContextStoppedEvent) { stop(); } } }
/** * {@inheritDoc} * @see org.springframework.context.ApplicationListener#onApplicationEvent(org.springframework.context.ApplicationEvent) */ @Override public void onApplicationEvent(final ApplicationContextEvent event) { if(event.getApplicationContext()==appCtx) { if(event instanceof ContextRefreshedEvent) { try { start(); } catch (Exception ex) { throw new RuntimeException(ex); } } else if(event instanceof ContextClosedEvent) { stop(); } } }
@Override public void onApplicationEvent(ApplicationContextEvent event) { if (event instanceof ContextRefreshedEvent && event.getApplicationContext().getParent() == null) { startMuleContext(event.getApplicationContext()); } else if (event instanceof ContextClosedEvent) { stopMuleContext(); } }
public void onApplicationEvent(ApplicationEvent event) { if (event instanceof ContextRefreshedEvent || event instanceof ContextBeanChangedEvent) { ApplicationContext context = ((ApplicationContextEvent) event).getApplicationContext(); boolean hasInboundChannels = !context.getBeansOfType(InboundChannel.class).isEmpty(); int flowControls = context.getBeansOfType(PipelineFlowControl.class).size(); // Ignore this, but if there are others, register for management if (hasInboundChannels || flowControls > 1) { Management.removeBeanOrFolder(getBeanName(), this); Management.addBean(getBeanName(), this); } } }
@Override public void onApplicationEvent(ApplicationContextEvent arg0) { if (arg0 instanceof ContextRefreshedEvent) { LOG.warn("READY: " + this.version); } else if (arg0 instanceof ContextClosedEvent) { LOG.warn("SHUTDOWN: " + this.version); } }
@Override public void onApplicationEvent(ApplicationContextEvent event) { ApplicationContext ctx = event.getApplicationContext(); if(!(ctx instanceof AnnotationConfigWebApplicationContext)) throw new RuntimeException("Initialization of the apllication-context failed!"); try { FileSystemUtil fsu = ctx.getBean(FileSystemUtil.class); fsu.init(); } catch (Exception e) { throw new RuntimeException(e); } logger.info("*** Application-context successful initialized"); }
/** * Listens for application lifecycle events (specifically start/stop), * and schedules the new run/cancels the next run as appropriate. * * @param event the application event to process. */ @Override public void onApplicationEvent(final ApplicationContextEvent event) { if (event instanceof ContextRefreshedEvent) { this.applicationContext = event.getApplicationContext(); this.startTimer(); } else if (event instanceof ContextClosedEvent) { this.cancel(); this.applicationContext = null; // This manually deregisters JDBC driver, which prevents Tomcat 7 // from complaining about memory leaks from this class // XXX: Disabled as it's dangerous and Tomcat handles this much // better, even if it does complain /* Enumeration<Driver> drivers = DriverManager.getDrivers(); while (drivers.hasMoreElements()) { final Driver driver = drivers.nextElement(); // Really ought to take the list of drivers to de-register from // application context if (driver instanceof com.microsoft.sqlserver.jdbc.SQLServerDriver) { try { DriverManager.deregisterDriver(driver); } catch (SQLException e) { log.error(String.format("Error deregistering driver %s", driver), e); } } } */ } }
@Override public void onApplicationEvent(ApplicationContextEvent event) { if (event instanceof ContextRefreshedEvent) { load(); } else if (event instanceof ContextClosedEvent) { shutdown(); } }
/** * Return JMXControl bean from the ApplicationContext *if* the given event is * an {@link ApplicationContextEvent} (or null otherwise). * <p> * A utility method wrapping one way in which we'd call * {@link #getFromContext(ApplicationContext)}. */ public static JMXControl getFromEvent(ApplicationEvent event) { if (event instanceof ApplicationContextEvent) { return getFromContext(((ApplicationContextEvent) event).getApplicationContext()); } else { return null; } }
@Override public void onApplicationEvent(ApplicationContextEvent event) { // Ignore events from different application contexts if (event.getApplicationContext() != ctx) { // Ignore return; } String eventName = event.getClass().getSimpleName(); if (eventName.equals("ContextRefreshedEvent")) { // Only start once if (!started) { start(); started = true; } } else if (eventName.equals("ContextClosedEvent")) { // Only stop once if (started) { stop(); started = false; } } }
public void onApplicationEvent(ApplicationContextEvent event) { lifecycle.onApplicationEvent(event); }
@Override public void onApplicationEvent(ApplicationContextEvent event) { }
@Override public void onApplicationEvent(ApplicationContextEvent applicationContextEvent) { List<Type> liveTypes = iLiveService.getAllType(); ServletContext.liveTypes = liveTypes; }
@Override public void onApplicationEvent(ApplicationContextEvent event) { log.info(LOG_PREFIX + "ApplicationListener.onApplicationEvent('" + event.getClass().getSimpleName() + "'): " + event); }