本文整理汇总了Java中org.springframework.context.event.ApplicationEventMulticaster类的典型用法代码示例。如果您正苦于以下问题:Java ApplicationEventMulticaster类的具体用法?Java ApplicationEventMulticaster怎么用?Java ApplicationEventMulticaster使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ApplicationEventMulticaster类属于org.springframework.context.event包,在下文中一共展示了ApplicationEventMulticaster类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initApplicationEventMulticaster
import org.springframework.context.event.ApplicationEventMulticaster; //导入依赖的package包/类
/**
* Initialize the ApplicationEventMulticaster.
* Uses SimpleApplicationEventMulticaster if none defined in the context.
* @see org.springframework.context.event.SimpleApplicationEventMulticaster
*/
protected void initApplicationEventMulticaster() {
ConfigurableListableBeanFactory beanFactory = getBeanFactory();
if (beanFactory.containsLocalBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME)) {
this.applicationEventMulticaster =
beanFactory.getBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, ApplicationEventMulticaster.class);
if (logger.isDebugEnabled()) {
logger.debug("Using ApplicationEventMulticaster [" + this.applicationEventMulticaster + "]");
}
}
else {
this.applicationEventMulticaster = new SimpleApplicationEventMulticaster(beanFactory);
beanFactory.registerSingleton(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, this.applicationEventMulticaster);
if (logger.isDebugEnabled()) {
logger.debug("Unable to locate ApplicationEventMulticaster with name '" +
APPLICATION_EVENT_MULTICASTER_BEAN_NAME +
"': using default [" + this.applicationEventMulticaster + "]");
}
}
}
示例2: getApplicationEventMulticaster
import org.springframework.context.event.ApplicationEventMulticaster; //导入依赖的package包/类
private synchronized ApplicationEventMulticaster getApplicationEventMulticaster()
{
try
{
Field field = DataStore.class.getDeclaredField("mainContext");
field.setAccessible(true);
AbstractApplicationContext ctx = (AbstractApplicationContext) field.get(DataStore.getInstance());
if (ctx == null)
return null;
Method m = AbstractApplicationContext.class.getDeclaredMethod("getApplicationEventMulticaster");
m.setAccessible(true);
ApplicationEventMulticaster eventCaster = (ApplicationEventMulticaster) m.invoke(ctx);
field.setAccessible(false);
m.setAccessible(false);
return eventCaster;
}
catch (Exception e)
{
e.printStackTrace();
}
return null;
}
示例3: createEditor
import org.springframework.context.event.ApplicationEventMulticaster; //导入依赖的package包/类
private Editor createEditor(){
Object o = BeanUtils.instantiateClass(editorClass);
Assert.isTrue((o instanceof Editor), "Editor class '"+
editorClass + "' was instantiated but is not an Editor");
Editor editor = (Editor)o;
editor.setDescriptor(this);
ApplicationEventMulticaster multicaster = getApplicationEventMulticaster();
if(editor instanceof ApplicationListener && multicaster != null){
multicaster.addApplicationListener((ApplicationListener)editor);
}
if(editorProperties != null){
BeanWrapper wrapper = new BeanWrapperImpl(editor);
wrapper.setPropertyValues(editorProperties);
}
if(editor instanceof InitializingBean){
try {
((InitializingBean)editor).afterPropertiesSet();
}
catch (Exception e) {
throw new BeanInitializationException("Problem running on " + editor, e);
}
}
return editor;
}
示例4: simpleApplicationEventMulticaster
import org.springframework.context.event.ApplicationEventMulticaster; //导入依赖的package包/类
@Bean(name = "applicationEventMulticaster")
public ApplicationEventMulticaster simpleApplicationEventMulticaster() {
SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster();
taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setThreadNamePrefix("asyncEventExecutor-");
taskExecutor.setCorePoolSize(4);
taskExecutor.initialize();
eventMulticaster.setTaskExecutor(taskExecutor);
return eventMulticaster;
}
示例5: publishEvent
import org.springframework.context.event.ApplicationEventMulticaster; //导入依赖的package包/类
@Override
public void publishEvent(ApplicationEvent event)
{
Assert.notNull(event, "Event must not be null");
if (logger.isTraceEnabled())
{
logger.trace("Publishing event in " + getDisplayName() + ": " + event);
}
((ApplicationEventMulticaster) getBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME)).multicastEvent(event);
if (!(getParent() == null || event instanceof ContextRefreshedEvent || event instanceof ContextClosedEvent))
{
getParent().publishEvent(event);
}
}
示例6: getApplicationEventMulticaster
import org.springframework.context.event.ApplicationEventMulticaster; //导入依赖的package包/类
/**
* Return the internal ApplicationEventMulticaster used by the context.
* @return the internal ApplicationEventMulticaster (never {@code null})
* @throws IllegalStateException if the context has not been initialized yet
*/
ApplicationEventMulticaster getApplicationEventMulticaster() throws IllegalStateException {
if (this.applicationEventMulticaster == null) {
throw new IllegalStateException("ApplicationEventMulticaster not initialized - " +
"call 'refresh' before multicasting events via the context: " + this);
}
return this.applicationEventMulticaster;
}
示例7: postProcessBeforeDestruction
import org.springframework.context.event.ApplicationEventMulticaster; //导入依赖的package包/类
@Override
public void postProcessBeforeDestruction(Object bean, String beanName) {
if (bean instanceof ApplicationListener) {
ApplicationEventMulticaster multicaster = this.applicationContext.getApplicationEventMulticaster();
multicaster.removeApplicationListener((ApplicationListener<?>) bean);
multicaster.removeApplicationListenerBean(beanName);
}
}
示例8: simpleApplicationEventMulticaster
import org.springframework.context.event.ApplicationEventMulticaster; //导入依赖的package包/类
@Bean(name = "applicationEventMulticaster")
public ApplicationEventMulticaster simpleApplicationEventMulticaster() {
multicasterExecutor.initialize();
SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster();
eventMulticaster.setTaskExecutor(multicasterExecutor);
return eventMulticaster;
}
示例9: init
import org.springframework.context.event.ApplicationEventMulticaster; //导入依赖的package包/类
@Before
public void init() throws Throwable {
stubDemo();
pluginDao.refresh();
initGit();
if (Files.exists(Paths.get(gitWorkspace.toString(), "plugin_cache.json"))) {
Files.delete(Paths.get(gitWorkspace.toString(), "plugin_cache.json"));
}
applicationEventMulticaster = (ApplicationEventMulticaster) applicationContext
.getBean(AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME);
}
示例10: MetacatApplicationEventMulticaster
import org.springframework.context.event.ApplicationEventMulticaster; //导入依赖的package包/类
/**
* Constructor.
*
* @param asyncEventMulticaster The asynchronous event multicaster to use
*/
public MetacatApplicationEventMulticaster(
@Nonnull @NonNull final ApplicationEventMulticaster asyncEventMulticaster
) {
super();
this.asyncEventMulticaster = asyncEventMulticaster;
}
示例11: applicationEventMulticaster
import org.springframework.context.event.ApplicationEventMulticaster; //导入依赖的package包/类
/**
* The application event multicaster to use.
*
* @param asyncEventMulticaster The asynchronous event publisher
* @return The application event multicaster to use.
*/
@Bean
public MetacatApplicationEventMulticaster applicationEventMulticaster(
final ApplicationEventMulticaster asyncEventMulticaster
) {
return new MetacatApplicationEventMulticaster(asyncEventMulticaster);
}
示例12: asyncEventMulticaster
import org.springframework.context.event.ApplicationEventMulticaster; //导入依赖的package包/类
/**
* A multicast (async) event publisher to replace the synchronous one used by Spring via the ApplicationContext.
*
* @param taskExecutor The task executor to use
* @return The application event multicaster to use
*/
@Bean
public ApplicationEventMulticaster asyncEventMulticaster(final TaskExecutor taskExecutor) {
final SimpleApplicationEventMulticaster applicationEventMulticaster = new SimpleApplicationEventMulticaster();
applicationEventMulticaster.setTaskExecutor(taskExecutor);
return applicationEventMulticaster;
}
示例13: applicationEventMulticaster
import org.springframework.context.event.ApplicationEventMulticaster; //导入依赖的package包/类
/**
* Server internal event publisher that allows parallel event processing if
* the event listener is marked as so.
*
* @return publisher bean
*/
@Bean(name = AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME)
public ApplicationEventMulticaster applicationEventMulticaster() {
final SimpleApplicationEventMulticaster simpleApplicationEventMulticaster = new TenantAwareApplicationEventPublisher(
tenantAware, applicationEventFilter());
simpleApplicationEventMulticaster.setTaskExecutor(executor);
return simpleApplicationEventMulticaster;
}
示例14: initApplicationEventMulticaster
import org.springframework.context.event.ApplicationEventMulticaster; //导入依赖的package包/类
/**
* 修改特定上下文的Event Multicaster的默认实现
*
* @param context 被修改的上下文
*/
public static void initApplicationEventMulticaster(GenericApplicationContext context) {
ApplicationEventMulticaster multicaster;
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
if (beanFactory.containsLocalBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME)) {
multicaster =
beanFactory.getBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, ApplicationEventMulticaster.class);
} else {
multicaster = new SmartApplicationEventMulticaster(beanFactory);
beanFactory.registerSingleton(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, multicaster);
}
setApplicationEventMulticaster(context, multicaster);
}
示例15: setApplicationEventMulticaster
import org.springframework.context.event.ApplicationEventMulticaster; //导入依赖的package包/类
private static void setApplicationEventMulticaster(GenericApplicationContext context,
ApplicationEventMulticaster applicationEventMulticaster) {
try {
FieldUtils.writeField(context, "applicationEventMulticaster", applicationEventMulticaster, true);
} catch (IllegalAccessException e) {
throw new ApplicationContextException("Can't hacking the spring context for applicationEventMulticaster", e);
}
}