Java Code Examples for org.springframework.context.event.SimpleApplicationEventMulticaster

Following code examples demonstrate how to use org.springframework.context.event.SimpleApplicationEventMulticasterfrom spring-framework. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.springframework.context.event.SimpleApplicationEventMulticasterand various code implementation of this class.

    public ApplicationEventMulticaster simpleApplicationEventMulticaster() {
        final SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster();

        eventMulticaster.setTaskExecutor(new SimpleAsyncTaskExecutor());
        return eventMulticaster;
    } 


	public ApplicationEventMulticaster applicationEventMulticaster() {

		SimpleApplicationEventMulticaster evt = new SimpleApplicationEventMulticaster();
		evt.setTaskExecutor(new SimpleAsyncTaskExecutor());
		return evt;

	} 

    public ApplicationEventMulticaster simpleApplicationEventMulticaster() {
        SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster();
        eventMulticaster.setTaskExecutor(new SimpleAsyncTaskExecutor());
        return eventMulticaster;
    } 

    public ApplicationEventMulticaster simpleApplicationEventMulticaster() {
        SimpleApplicationEventMulticaster eventMulticaster
                = new SimpleApplicationEventMulticaster();
        System.out.println("Amount of Rs."+ UserDaoImpl.bal+" is debited from your Account");
        eventMulticaster.setTaskExecutor(new SimpleAsyncTaskExecutor());
        return eventMulticaster;
    } 

    SimpleApplicationEventMulticaster getBean(ThreadPoolTaskExecutor taskExecutor) {
        SimpleApplicationEventMulticaster multicaster = new SimpleApplicationEventMulticaster();
        multicaster.setTaskExecutor(taskExecutor);
        return multicaster;
    } 

	public void publishEvent() {
		SimpleApplicationEventMulticaster multicaster = new SimpleApplicationEventMulticaster();
		multicaster.addApplicationListener(new AppListener());
		multicaster.addApplicationListener(new AppListener());
		
		multicaster.multicastEvent(new AppEvent(this, "I am winner"));
	} 

	public ApplicationEventMulticaster applicationEventMulticaster(){
		SimpleApplicationEventMulticaster sm = new SimpleApplicationEventMulticaster();
		sm.setTaskExecutor(new SimpleAsyncTaskExecutor());
		return sm;
	} 

    public ApplicationEventMulticaster simpleApplicationEventMultiCaster(){
        SimpleApplicationEventMulticaster eventMulticaster=new SimpleApplicationEventMulticaster();
        eventMulticaster.setTaskExecutor(new SimpleAsyncTaskExecutor());
        return eventMulticaster;
    } 

Advertisement
Javadoc
Simple implementation of the ApplicationEventMulticaster interface.

Multicasts all events

to all registered listeners, leaving it up to the listeners to ignore events that they are not interested in. Listeners will usually perform corresponding instanceof checks on the passed-in event object.

By default, all listeners are invoked in the calling thread. This allows the danger of a rogue listener blocking the entire application, but adds minimal overhead. Specify an alternative task executor to have listeners executed in different threads, for example from a thread pool. @author Rod Johnson @author Juergen Hoeller @author Stephane Nicoll @see #setTaskExecutor

Read More
Advertisement