本文整理匯總了Java中org.springframework.context.ApplicationEvent類的典型用法代碼示例。如果您正苦於以下問題:Java ApplicationEvent類的具體用法?Java ApplicationEvent怎麽用?Java ApplicationEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ApplicationEvent類屬於org.springframework.context包,在下文中一共展示了ApplicationEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onBootstrap
import org.springframework.context.ApplicationEvent; //導入依賴的package包/類
@Override
protected void onBootstrap(ApplicationEvent event)
{
PropertyCheck.mandatory(this, "moduleService", moduleService);
final RetryingTransactionCallback<Object> startModulesCallback = new RetryingTransactionCallback<Object>()
{
public Object execute() throws Throwable
{
moduleService.startModules();
return null;
}
};
AuthenticationUtil.runAs(new RunAsWork<Object>()
{
@Override
public Object doWork() throws Exception
{
transactionService.getRetryingTransactionHelper().doInTransaction(startModulesCallback, transactionService.isReadOnly());
return null;
}
}, AuthenticationUtil.getSystemUserName());
}
示例2: multicastEvent
import org.springframework.context.ApplicationEvent; //導入依賴的package包/類
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void multicastEvent(final ApplicationEvent event) {
for (final ApplicationListener listener : getApplicationListeners(event)) {
Executor executor = getTaskExecutor();
if (executor != null) {
executor.execute(new Runnable() {
@Override
public void run() {
listener.onApplicationEvent(event);
}
});
}
else {
listener.onApplicationEvent(event);
}
}
}
示例3: onShutdown
import org.springframework.context.ApplicationEvent; //導入依賴的package包/類
@Override
protected void onShutdown(ApplicationEvent event)
{
// remove shutdown hook and execute
if (shutdownHook != null)
{
// execute
execute();
// remove hook
try
{
Runtime.getRuntime().removeShutdownHook(shutdownHook);
}
catch (IllegalStateException e)
{
// VM is already shutting down
}
shutdownHook = null;
if (logger.isDebugEnabled())
{
logger.debug("Deregistered shutdown hook");
}
}
}
示例4: multicastEvent
import org.springframework.context.ApplicationEvent; //導入依賴的package包/類
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void multicastEvent(ApplicationEvent event, ResolvableType eventType) {
ResolvableType type = eventType == null ? ResolvableType.forInstance(event) : eventType;
Collection<ApplicationListener<?>> listeners = getApplicationListeners(event, type);
if (listeners.isEmpty()) {
return;
}
List<ApplicationListener<?>> transactionalListeners = listeners.stream()//
.filter(PersistentApplicationEventMulticaster::isTransactionalApplicationEventListener)//
.collect(Collectors.toList());
if (!transactionalListeners.isEmpty()) {
Object eventToPersist = getEventToPersist(event);
registry.getObject().store(eventToPersist, transactionalListeners);
// EventStore.persist(eventThis)
// SpringMVC Controller Atom Feed
}
for (ApplicationListener listener : listeners) {
listener.onApplicationEvent(event);
}
}
開發者ID:olivergierke,項目名稱:spring-domain-events,代碼行數:29,代碼來源:PersistentApplicationEventMulticaster.java
示例5: onBootstrap
import org.springframework.context.ApplicationEvent; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
protected void onBootstrap(ApplicationEvent event)
{
if (!enabled)
{
return;
}
// Check properties
PropertyCheck.mandatory(this, "domain", domain);
if (port <= 0 || port > 65535)
{
throw new AlfrescoRuntimeException("Property 'port' is incorrect");
}
PropertyCheck.mandatory(this, "emailService", emailService);
// Startup
startup();
}
示例6: onBootstrap
import org.springframework.context.ApplicationEvent; //導入依賴的package包/類
@Override
protected void onBootstrap(ApplicationEvent event)
{
// Reset the dictionary (destroy and reload) in order to ensure that we have a basic version of
// the dictionary (static models) loaded at least
dictionaryDAO.reset();
// Register listeners, which will be called when the dictionary is next reloaded
register();
// Trigger a reload. The callbacks will occur immediately on the current thread, however,
// the model created in reset() will still be available for the basic necessities
dictionaryDAO.init();
// The listeners can now know about this
// However, the listeners will be needing to access the dictionary themselves, hence the earlier 'reset'
// to ensure that there is no deadlock waiting for a new dictionary
((ApplicationContext) event.getSource()).publishEvent(new DictionaryRepositoryBootstrappedEvent(this));
}
示例7: onBootstrap
import org.springframework.context.ApplicationEvent; //導入依賴的package包/類
@Override
protected void onBootstrap(ApplicationEvent event)
{
// Do an initial differential sync on startup, using transaction splitting. This ensures that on the very
// first startup, we don't have to wait for a very long login operation to trigger the first sync!
if (this.syncOnStartup)
{
AuthenticationUtil.runAs(new RunAsWork<Object>()
{
public Object doWork() throws Exception
{
try
{
synchronizeInternal(false, false, true);
}
catch (Exception e)
{
ChainingUserRegistrySynchronizer.logger.warn("Failed initial synchronize with user registries",
e);
}
return null;
}
}, AuthenticationUtil.getSystemUserName());
}
}
示例8: onApplicationEvent
import org.springframework.context.ApplicationEvent; //導入依賴的package包/類
public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof ContextClosedEvent) {
enabled = false;
return;
}
if (event instanceof ContextRefreshedEvent) {
initialized = true;
return;
}
if (event instanceof OsgiServiceDependencyWaitStartingEvent) {
if (enabled) {
OsgiServiceDependencyWaitStartingEvent evt = (OsgiServiceDependencyWaitStartingEvent) event;
String[] filter = new String[] { evt.getServiceDependency().getServiceFilter().toString() };
BlueprintEvent waitingEvent =
new BlueprintEvent(BlueprintEvent.WAITING, bundleContext.getBundle(), extenderBundle,
filter);
listenerManager.blueprintEvent(waitingEvent);
dispatcher.waiting(waitingEvent);
}
return;
}
}
示例9: onBootstrap
import org.springframework.context.ApplicationEvent; //導入依賴的package包/類
@Override
protected void onBootstrap(ApplicationEvent event)
{
Descriptor descriptor = descriptorService.getInstalledRepositoryDescriptor();
if (patch == null)
{
patchApplied = true;
}
else
{
AppliedPatch appliedPatch = patchService.getPatch(patch.getId());
if (appliedPatch == null)
{
patchApplied = patch.getFixesToSchema() < descriptor.getSchema();
}
else
{
patchApplied = appliedPatch.getSucceeded();
}
}
}
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:22,代碼來源:OptionalPatchApplicationCheckBootstrapBean.java
示例10: onApplicationEvent
import org.springframework.context.ApplicationEvent; //導入依賴的package包/類
@Override
public void onApplicationEvent(ApplicationEvent event)
{
if (event instanceof ContextRefreshedEvent)
{
ContextRefreshedEvent refreshEvent = (ContextRefreshedEvent)event;
ApplicationContext refreshContext = refreshEvent.getApplicationContext();
if (refreshContext != null && refreshContext.equals(applicationContext))
{
RunAsWork<Object> work = new RunAsWork<Object>()
{
public Object doWork() throws Exception
{
reset();
return null;
}
};
AuthenticationUtil.runAs(work, AuthenticationUtil.getSystemUserName());
}
}
}
示例11: onBootstrap
import org.springframework.context.ApplicationEvent; //導入依賴的package包/類
@Override
protected void onBootstrap(ApplicationEvent event)
{
RetryingTransactionCallback<Object> checkWork = new RetryingTransactionCallback<Object>()
{
public Object execute() throws Throwable {
// run as System on bootstrap
return AuthenticationUtil.runAs(new RunAsWork<Object>()
{
public Object doWork()
{
check();
return null;
}
}, AuthenticationUtil.getSystemUserName());
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(checkWork, true);
}
示例12: onShutdown
import org.springframework.context.ApplicationEvent; //導入依賴的package包/類
@Override
protected void onShutdown(ApplicationEvent event)
{
AuthenticationUtil.runAs(new RunAsWork<Void>()
{
@Override
public Void doWork() throws Exception
{
if (service.getImapServerEnabled())
{
service.shutdown();
}
return null;
}
}, AuthenticationUtil.getSystemUserName());
}
示例13: onBootstrap
import org.springframework.context.ApplicationEvent; //導入依賴的package包/類
@Override
protected void onBootstrap(ApplicationEvent event)
{
String majorVersion = I18NUtil.getMessage("version.major");
String minorVersion = I18NUtil.getMessage("version.minor");
// Internationalizes the message
String errorMsg = I18NUtil.getMessage("system.err.lucene_not_supported", majorVersion + "." + minorVersion);
log.error(errorMsg);
List<StoreRef> storeRefs = nodeService.getStores();
for (StoreRef storeRef : storeRefs)
{
fullTextSearchIndexer.requiresIndex(storeRef);
}
}
示例14: onBootstrap
import org.springframework.context.ApplicationEvent; //導入依賴的package包/類
@Override
protected void onBootstrap(ApplicationEvent event)
{
RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
txnHelper.setForceWritable(true); // Force write in case server is read-only
txnHelper.doInTransaction(new RetryingTransactionCallback<Void>()
{
public Void execute() throws Throwable
{
try
{
keyStoreChecker.validateKeyStores();
}
catch(Throwable e)
{
// Just throw as a runtime exception
throw new AlfrescoRuntimeException("Keystores are invalid", e);
}
return null;
}
});
}
示例15: onBootstrap
import org.springframework.context.ApplicationEvent; //導入依賴的package包/類
@Override
protected void onBootstrap(ApplicationEvent event)
{
RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
txnHelper.setForceWritable(true);
txnHelper.doInTransaction(new RetryingTransactionCallback<Object>() {
@Override
public Object execute() throws Throwable {
// run as System on bootstrap
return AuthenticationUtil.runAs(new RunAsWork<Object>()
{
public Object doWork()
{
init();
return null;
}
}, AuthenticationUtil.getSystemUserName());
}
}, false, true);
tenantAdminService.register(this);
}