本文整理匯總了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));
}