List of usage examples for org.springframework.context.event ApplicationContextEvent getApplicationContext
public final ApplicationContext getApplicationContext()
From source file:org.messic.server.api.dlna.DLNAServer.java
@Override public void onApplicationEvent(ApplicationContextEvent arg0) { ApplicationContext ac = arg0.getApplicationContext(); synchronized (this) { if (ac != null && !this.flagMessicInited) { this.flagMessicInited = true; refreshServer();// ww w . jav a2s . com } } }
From source file:com.example.app.config.MyAppConfig.java
/** * Example to test if weaving is working. * @param event the event./*from w w w .j a v a 2 s .c o m*/ */ @SuppressFBWarnings("DM_EXIT") @Override public void onApplicationEvent(ApplicationEvent event) { if (event instanceof ContextRefreshedEvent) { if (!new AspectWeavingTest().isConfigured()) { ApplicationContextEvent ace = (ApplicationContextEvent) event; ApplicationContext applicationContext = ace.getApplicationContext(); try { if (applicationContext instanceof AbstractApplicationContext) ((AbstractApplicationContext) applicationContext).close(); } finally { ApplicationContextException ex = new ApplicationContextException( "AspectJ weaving is not working. Configure compile-time or load-time weaving."); _logger.fatal("AspectJ weaving misconfiguration.", ex); } System.exit(1); } } }
From source file:org.alfresco.bm.test.LifecycleController.java
@Override public void onApplicationEvent(ApplicationContextEvent event) { // Ignore events from different application contexts if (event.getApplicationContext() != ctx) { // Ignore return;//from w w w .jav a 2s . c o m } 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; } } }
From source file:com.example.app.profile.model.ProfileTypeProvider.java
@Override public void onApplicationEvent(ApplicationContextEvent event) { if (!_initialized && (event instanceof ContextRefreshedEvent || event instanceof ContextStartedEvent)) { final HibernateSessionHandler handler = (HibernateSessionHandler) event.getApplicationContext() .getBean(HibernateSessionHandler.RESOURCE_NAME); try {//from w w w.j av a2 s .c o m handler.openSessions(); initialize(); _initialized = true; } catch (Exception e) { _logger.fatal("ProfileTypeProvider failed to initialize.", e); } finally { handler.clearSessions(); } } }
From source file:com.example.app.profile.service.MembershipOperationConfiguration.java
@Override public void onApplicationEvent(ApplicationContextEvent event) { if (!_initialized && (event instanceof ContextRefreshedEvent || event instanceof ContextStartedEvent)) { final HibernateSessionHandler handler = (HibernateSessionHandler) event.getApplicationContext() .getBean(HibernateSessionHandler.RESOURCE_NAME); try {/*w ww . j a va2s. co m*/ handler.openSessions(); initializeOperations(); _initialized = true; } catch (Exception e) { _logger.fatal("MembershipOperationConfiguration failed to initialize.", e); } finally { handler.clearSessions(); } } }
From source file:com.example.app.profile.model.membership.MembershipTypeProvider.java
@Override public void onApplicationEvent(ApplicationContextEvent event) { if (!_initialized && (event instanceof ContextRefreshedEvent || event instanceof ContextStartedEvent)) { //Ensure that the profile type provider is initialized _profileTypeProvider.onApplicationEvent(event); final HibernateSessionHandler handler = (HibernateSessionHandler) event.getApplicationContext() .getBean(HibernateSessionHandler.RESOURCE_NAME); try {/*from www.ja v a 2s . com*/ handler.openSessions(); initialize(); _initialized = true; } catch (Exception e) { _logger.fatal("MembershipTypeProvider failed to initialize.", e); } finally { handler.clearSessions(); } } }
From source file:org.eclipse.gemini.blueprint.blueprint.container.support.BlueprintContainerServicePublisher.java
public void onApplicationEvent(ApplicationContextEvent event) { // publish// www . j a va 2 s. co m if (event instanceof ContextRefreshedEvent) { registerService(event.getApplicationContext()); } else if (event instanceof ContextClosedEvent) { unregisterService(); } }
From source file:org.springframework.integration.config.IdGeneratorConfigurer.java
public synchronized void onApplicationEvent(ApplicationContextEvent event) { ApplicationContext context = event.getApplicationContext(); if (event instanceof ContextRefreshedEvent) { boolean contextHasIdGenerator = context.getBeanNamesForType(IdGenerator.class).length > 0; if (contextHasIdGenerator) { if (this.setIdGenerator(context)) { IdGeneratorConfigurer.generatorContextId.add(context.getId()); }// w w w .j a va 2s .c o m } } else if (event instanceof ContextClosedEvent) { if (IdGeneratorConfigurer.generatorContextId.contains(context.getId())) { if (IdGeneratorConfigurer.generatorContextId.size() == 1) { this.unsetIdGenerator(); } IdGeneratorConfigurer.generatorContextId.remove(context.getId()); } } }