Java Code Examples for org.springframework.context.ApplicationContext.publishEvent()

The following are Jave code examples for showing how to use publishEvent() of the org.springframework.context.ApplicationContext class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: alfresco-core   File: RuntimeExecBeansTest.java   View Source Code Vote up 6 votes
public void testBootstrapAndShutdown() throws Exception
{
    // now bring up the bootstrap
    ApplicationContext ctx = new ClassPathXmlApplicationContext(APP_CONTEXT_XML);
    
    // the folder should be gone
    assertFalse("Folder was not deleted by bootstrap", dir.exists());
    
    // now create the folder again
    dir.mkdir();
    assertTrue("Directory not created", dir.exists());
    
    // announce that the context is closing
    ctx.publishEvent(new ContextClosedEvent(ctx));
    
    // the folder should be gone
    assertFalse("Folder was not deleted by shutdown", dir.exists());
}
 
Example 2
Project: alfresco-object-storage-connectors   File: ObjectStorageContentStore.java   View Source Code Vote up 5 votes
@Override
public void onApplicationEvent(ApplicationEvent event) {
	// Once the context has been refreshed, we tell other interested beans
	// about the existence of this content store
	// (e.g. for monitoring purposes)
	if (event instanceof ContextRefreshedEvent && event.getSource() == this.applicationContext) {
		ApplicationContext context = ((ContextRefreshedEvent) event).getApplicationContext();
		context.publishEvent(new ContentStoreCreatedEvent(this, Collections.<String, Serializable>emptyMap()));
	}
}
 
Example 3
Project: lemon   File: LogoutHttpSessionListener.java   View Source Code Vote up 5 votes
public void sessionDestroyed(HttpSessionEvent se) {
    ApplicationContext ctx = WebApplicationContextUtils
            .getWebApplicationContext(se.getSession().getServletContext());

    if (ctx == null) {
        logger.warn("cannot find applicationContext");

        return;
    }

    HttpSession session = se.getSession();
    UserAuthDTO userAuthDto = this.internalUserAuthConnector
            .findFromSession(session);

    String tenantId = null;

    if (userAuthDto != null) {
        tenantId = userAuthDto.getTenantId();
    }

    LogoutEvent logoutEvent = new LogoutEvent(session, null,
            session.getId(), tenantId);
    ctx.publishEvent(logoutEvent);
}
 
Example 4
Project: alfresco-repository   File: FileContentStore.java   View Source Code Vote up 2 votes
/**
 * Publishes an event to the application context that will notify any interested parties of the existence of this
 * content store.
 * 
 * @param context
 *            the application context
 * @param extendedEventParams 
 */
private void publishEvent(ApplicationContext context, Map<String, Serializable> extendedEventParams)
{
    context.publishEvent(new ContentStoreCreatedEvent(this, extendedEventParams));
}