Java 类org.springframework.context.event.ApplicationEventMulticaster 实例源码

项目:lams    文件:AbstractApplicationContext.java   
/**
 * 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 + "]");
        }
    }
}
项目:spring4-understanding    文件:AbstractApplicationContext.java   
/**
 * 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 + "]");
        }
    }
}
项目:my-spring-cache-redis    文件:AbstractApplicationContext.java   
/**
 * 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 + "]");
        }
    }
}
项目:spring    文件:AbstractApplicationContext.java   
/**
 * 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 + "]");
        }
    }
}
项目:GemFireLite    文件:ApplicationListenerRegistry.java   
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;
}
项目:class-guard    文件:AbstractApplicationContext.java   
/**
 * 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 + "]");
        }
    }
}
项目:spring-rich-client    文件:EditorDescriptor.java   
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;
}
项目:spring-richclient    文件:EditorDescriptor.java   
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;
}
项目:freqtrade-java    文件:FreqTradeConfiguration.java   
@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;
}
项目:alfresco-repository    文件:ChildApplicationContextFactory.java   
@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);
    }
}
项目:lams    文件:AbstractApplicationContext.java   
/**
 * 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;
}
项目:lams    文件:PostProcessorRegistrationDelegate.java   
@Override
public void postProcessBeforeDestruction(Object bean, String beanName) {
    if (bean instanceof ApplicationListener) {
        ApplicationEventMulticaster multicaster = this.applicationContext.getApplicationEventMulticaster();
        multicaster.removeApplicationListener((ApplicationListener<?>) bean);
        multicaster.removeApplicationListenerBean(beanName);
    }
}
项目:flow-platform    文件:AppConfig.java   
@Bean(name = "applicationEventMulticaster")
public ApplicationEventMulticaster simpleApplicationEventMulticaster() {
    multicasterExecutor.initialize();
    SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster();
    eventMulticaster.setTaskExecutor(multicasterExecutor);
    return eventMulticaster;
}
项目:flow-platform    文件:PluginServiceTest.java   
@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);
}
项目:metacat    文件:MetacatApplicationEventMulticaster.java   
/**
 * Constructor.
 *
 * @param asyncEventMulticaster The asynchronous event multicaster to use
 */
public MetacatApplicationEventMulticaster(
    @Nonnull @NonNull final ApplicationEventMulticaster asyncEventMulticaster
) {
    super();
    this.asyncEventMulticaster = asyncEventMulticaster;
}
项目:metacat    文件:CommonServerConfig.java   
/**
 * 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);
}
项目:metacat    文件:CommonServerConfig.java   
/**
 * 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;
}
项目:spring4-understanding    文件:AbstractApplicationContext.java   
/**
 * 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;
}
项目:spring4-understanding    文件:PostProcessorRegistrationDelegate.java   
@Override
public void postProcessBeforeDestruction(Object bean, String beanName) {
    if (bean instanceof ApplicationListener) {
        ApplicationEventMulticaster multicaster = this.applicationContext.getApplicationEventMulticaster();
        multicaster.removeApplicationListener((ApplicationListener<?>) bean);
        multicaster.removeApplicationListenerBean(beanName);
    }
}
项目:my-spring-cache-redis    文件:AbstractApplicationContext.java   
/**
 * 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;
}
项目:my-spring-cache-redis    文件:PostProcessorRegistrationDelegate.java   
@Override
public void postProcessBeforeDestruction(Object bean, String beanName) {
    if (bean instanceof ApplicationListener) {
        ApplicationEventMulticaster multicaster = this.applicationContext.getApplicationEventMulticaster();
        multicaster.removeApplicationListener((ApplicationListener<?>) bean);
        multicaster.removeApplicationListenerBean(beanName);
    }
}
项目:spring    文件:AbstractApplicationContext.java   
/**
 * 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;
}
项目:spring    文件:PostProcessorRegistrationDelegate.java   
@Override
public void postProcessBeforeDestruction(Object bean, String beanName) {
    if (bean instanceof ApplicationListener) {
        ApplicationEventMulticaster multicaster = this.applicationContext.getApplicationEventMulticaster();
        multicaster.removeApplicationListener((ApplicationListener<?>) bean);
        multicaster.removeApplicationListenerBean(beanName);
    }
}
项目:hawkbit    文件:EventPublisherAutoConfiguration.java   
/**
 * 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;
}
项目:community-edition-old    文件:ChildApplicationContextFactory.java   
@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);
    }
}
项目:spring-component-framework    文件:ContextUtils.java   
/**
 * 修改特定上下文的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);

}
项目:spring-component-framework    文件:ContextUtils.java   
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);
    }
}
项目:class-guard    文件:AbstractApplicationContext.java   
/**
 * 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
 */
private 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;
}
项目:spring-rich-client    文件:EditorDescriptor.java   
public ApplicationEventMulticaster getApplicationEventMulticaster() {
    if (getApplicationContext() != null) {
        final String beanName = AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME;
        if (getApplicationContext().containsBean(beanName)) {
            return (ApplicationEventMulticaster)getApplicationContext().getBean(beanName);
        }
    }
    return null;
}
项目:spring-richclient    文件:EditorDescriptor.java   
public ApplicationEventMulticaster getApplicationEventMulticaster() {
    if (getApplicationContext() != null) {
        final String beanName = AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME;
        if (getApplicationContext().containsBean(beanName)) {
            return (ApplicationEventMulticaster)getApplicationContext().getBean(beanName);
        }
    }
    return null;
}
项目:flow-platform    文件:AppConfig.java   
@Bean(name = "applicationEventMulticaster")
public ApplicationEventMulticaster simpleApplicationEventMulticaster() {
    SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster();
    eventMulticaster.setTaskExecutor(executor);
    return eventMulticaster;
}
项目:flow-platform    文件:SpringContext.java   
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
    this.applicationContext = applicationContext;
    this.eventMulticaster = (ApplicationEventMulticaster) applicationContext
        .getBean(AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME);
}
项目:simbest-cores    文件:AsyncAndSyncEventMulticaster.java   
public void setAsyncEventMulticaster(ApplicationEventMulticaster asyncEventMulticaster) {
    this.asyncEventMulticaster = asyncEventMulticaster;
}
项目:simbest-cores    文件:AsyncAndSyncEventMulticaster.java   
public void setSyncEventMulticaster(ApplicationEventMulticaster syncEventMulticaster) {
    this.syncEventMulticaster = syncEventMulticaster;
}
项目:Catdogtion    文件:CatdogtionApplication.java   
@Bean(name = "applicationEventMulticaster")
public ApplicationEventMulticaster simpleApplicationEventMulticaster() {
  SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster();
  eventMulticaster.setTaskExecutor(new SimpleAsyncTaskExecutor());
  return eventMulticaster;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringApplicationTests.java   
@Bean(name = AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME)
public ApplicationEventMulticaster applicationEventMulticaster() {
    return spy(new SimpleApplicationEventMulticaster());
}
项目:spring-boot-concourse    文件:SpringApplicationTests.java   
@Bean(name = AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME)
public ApplicationEventMulticaster applicationEventMulticaster() {
    return spy(new SimpleApplicationEventMulticaster());
}
项目:hawkbit    文件:EventVerifier.java   
private void removeEventListener(final TestContext testContext) {
    final ApplicationEventMulticaster multicaster = testContext.getApplicationContext()
            .getBean(ApplicationEventMulticaster.class);
    multicaster.removeApplicationListener(eventCaptor);
}
项目:data-prep    文件:DataPrepEvents.java   
/**
 * @return The default application context ApplicationEventMulticaster.
 */
// do NOT change the name as it is important to replace the default application context event multi caster
@Bean(name = "applicationEventMulticaster")
public ApplicationEventMulticaster getDataPrepEventsCaster( ) {
    return new DataPrepEventsCaster(executor, beanFactory);
}
项目:spring-restlet    文件:MulticastRegister.java   
/**
 * {@inheritDoc}
 */
@Override
public void afterPropertiesSet() throws Exception {
    Assert.hasText(channelName, "channelName is required");
    Assert.hasText(channelVersion, "channelVersion is required");
    localChannel = new Channel();
    localChannel.setName(channelName);
    localChannel.setVersion(channelVersion);
    // Retrieve host address
    try {

        localChannel.setHostAddress(InetAddress.getLocalHost().getHostAddress());
    } catch (UnknownHostException e) {
        throw new Exception("Unable to resolve localhost address", e);
    }
    DefaultListableBeanFactory autowireCapableBeanFactory = (DefaultListableBeanFactory) this.applicationContext
            .getAutowireCapableBeanFactory();

    ApplicationEventMulticaster eventMulticaster = this.applicationContext.getBean(
            AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME, ApplicationEventMulticaster.class);
    Assert.notNull(eventMulticaster, "Spring multicaster is required");
    if (multicastProvider == null) {
        Assert.hasText(clusterName, "clusterName is required");
        JGroupsMulticastProvider provider = new JGroupsMulticastProvider();
        provider.setClusterName(getClusterName());
        provider.setStartOnContext(false);
        autowireCapableBeanFactory.autowireBeanProperties(provider, AutowireCapableBeanFactory.AUTOWIRE_NO, false);
        autowireCapableBeanFactory.initializeBean(provider, "jGroupsMulticastProvider");
        this.multicastProvider = provider;
        eventMulticaster.addApplicationListener(provider);

    }
    if (multicastProvider.isStartOnContext()) {
        throw new RuntimeException(
                "multicastProvider hasn't to start automatically, set 'startOnContext' property to false");
    }

    multicast = new Multicast();
    multicast.setProvider(multicastProvider);
    autowireCapableBeanFactory.autowireBeanProperties(multicast, AutowireCapableBeanFactory.AUTOWIRE_NO, false);
    autowireCapableBeanFactory.initializeBean(multicast, "multicast");
    eventMulticaster.addApplicationListener(this.multicast);

}