01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tctest.spring.bean;
05:
06: import org.springframework.beans.BeansException;
07: import org.springframework.context.ApplicationContext;
08: import org.springframework.context.ApplicationContextAware;
09:
10: import java.util.Date;
11:
12: public class EventManagerImpl implements EventManager,
13: ApplicationContextAware {
14:
15: private SimpleListener listener;
16: private ApplicationContext ctx;
17:
18: public EventManagerImpl(SimpleListener listener) {
19: this .listener = listener;
20: }
21:
22: public void setApplicationContext(ApplicationContext ctx)
23: throws BeansException {
24: this .ctx = ctx;
25: }
26:
27: public int size() {
28: return listener.size();
29: }
30:
31: public void publishEvents(Object source, String message, int count) {
32: for (int i = 0; i < count; i++) {
33: ctx.publishEvent(new DistributedSingletonEvent(source,
34: message + "[" + i + "]"));
35: }
36: }
37:
38: public void publishLocalEvent(Object source, String message) {
39: ctx.publishEvent(new NonDistributedSingletonEvent(source,
40: message));
41: }
42:
43: public void clear() {
44: listener.clear();
45: }
46:
47: public Date getLastEventTime() {
48: return listener.getLastEventTime();
49: }
50:
51: }
|