当前位置: 首页>>代码示例>>Java>>正文


Java ApplicationEvent类代码示例

本文整理汇总了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());       
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:ModuleStarter.java

示例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);
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:SimpleApplicationEventMulticaster.java

示例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");
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:26,代码来源:RuntimeExecShutdownBean.java

示例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();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:EmailServer.java

示例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));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:DictionaryRepositoryBootstrap.java

示例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());
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:26,代码来源:ChainingUserRegistrySynchronizer.java

示例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;
	}
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:26,代码来源:BlueprintContainerProcessor.java

示例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());
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:22,代码来源:RepositoryContainer.java

示例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);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:ConfigurationChecker.java

示例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());
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:17,代码来源:ImapServiceImpl.java

示例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);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:17,代码来源:FullTextSearchIndexerBootstrapBean.java

示例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;
        }
    });
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:EncryptionChecker.java

示例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);
  }
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:WorkflowDeployer.java


注:本文中的org.springframework.context.ApplicationEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。