Package org.springframework.context.support

Examples of org.springframework.context.support.AbstractApplicationContext.publishEvent()


    context.refresh();

    SamplePersonEventListener listener = new SamplePersonEventListener();
    context.addApplicationListener(listener);

    context.publishEvent(new BeforeConvertEvent<Person>(new Person("Dave", "Matthews")));
    assertThat(listener.invokedOnBeforeConvert, is(true));

    listener.invokedOnBeforeConvert = false;
    context.publishEvent(new BeforeConvertEvent<String>("Test"));
    assertThat(listener.invokedOnBeforeConvert, is(false));
View Full Code Here


    context.publishEvent(new BeforeConvertEvent<Person>(new Person("Dave", "Matthews")));
    assertThat(listener.invokedOnBeforeConvert, is(true));

    listener.invokedOnBeforeConvert = false;
    context.publishEvent(new BeforeConvertEvent<String>("Test"));
    assertThat(listener.invokedOnBeforeConvert, is(false));

    context.close();
  }
View Full Code Here

    AbstractApplicationContext context = new ClassPathXmlApplicationContext("auditing.xml", getClass());

    Entity entity = new Entity();
    BeforeConvertEvent<Entity> event = new BeforeConvertEvent<Entity>(entity);
    context.publishEvent(event);

    assertThat(entity.created, is(notNullValue()));
    assertThat(entity.modified, is(entity.created));

    Thread.sleep(10);
View Full Code Here

    assertThat(entity.modified, is(entity.created));

    Thread.sleep(10);
    entity.id = 1L;
    event = new BeforeConvertEvent<Entity>(entity);
    context.publishEvent(event);

    assertThat(entity.created, is(notNullValue()));
    assertThat(entity.modified, is(not(entity.created)));
    context.close();
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.