本文整理汇总了Java中org.springframework.context.ApplicationContext.publishEvent方法的典型用法代码示例。如果您正苦于以下问题:Java ApplicationContext.publishEvent方法的具体用法?Java ApplicationContext.publishEvent怎么用?Java ApplicationContext.publishEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.context.ApplicationContext
的用法示例。
在下文中一共展示了ApplicationContext.publishEvent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBootstrapAndShutdown
import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
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());
}
示例2: onApplicationEvent
import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
@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()));
}
}
示例3: sessionDestroyed
import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
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);
}
示例4: publishEvent
import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
/**
* 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));
}