use of com.haulmont.cuba.core.global.Events in project cuba by cuba-platform.
the class ControllerDependencyInjector method injectEventListeners.
protected void injectEventListeners(Frame frame) {
Class<? extends Frame> clazz = frame.getClass();
List<Method> eventListenerMethods = getAnnotatedListenerMethods(clazz);
if (!eventListenerMethods.isEmpty()) {
Events events = (Events) applicationContext.getBean(Events.NAME);
List<ApplicationListener> listeners = eventListenerMethods.stream().map(m -> new UiEventListenerMethodAdapter(frame, clazz, m, events)).collect(Collectors.toList());
((AbstractFrame) frame).setUiEventListeners(listeners);
}
}
use of com.haulmont.cuba.core.global.Events in project cuba by cuba-platform.
the class AbstractAppContextLoader method initAppContext.
protected void initAppContext() {
String configProperty = AppContext.getProperty(SPRING_CONTEXT_CONFIG);
if (StringUtils.isBlank(configProperty)) {
throw new IllegalStateException("Missing " + SPRING_CONTEXT_CONFIG + " application property");
}
StrTokenizer tokenizer = new StrTokenizer(configProperty);
String[] locations = tokenizer.getTokenArray();
replaceLocationsFromConf(locations);
ApplicationContext appContext = createApplicationContext(locations);
AppContext.Internals.setApplicationContext(appContext);
Events events = AppBeans.get(Events.NAME);
events.publish(new AppContextInitializedEvent(appContext));
log.debug("AppContext initialized");
}
use of com.haulmont.cuba.core.global.Events in project cuba by cuba-platform.
the class AppContext method stopContext.
/**
* Called by the framework right before the application shutdown.
*/
static void stopContext() {
if (!started)
return;
started = false;
for (int i = listeners.size() - 1; i >= 0; i--) {
Listener listener = listeners.get(i);
listener.applicationStopped();
}
Events events = (Events) getApplicationContext().getBean(Events.NAME);
events.publish(new AppContextStoppedEvent(context));
if (context != null && context instanceof ConfigurableApplicationContext) {
((ConfigurableApplicationContext) context).close();
}
}
use of com.haulmont.cuba.core.global.Events in project cuba by cuba-platform.
the class UserRemoveAction method afterRemove.
@Override
protected void afterRemove(Set removedItems) {
super.afterRemove(removedItems);
Events events = AppBeans.get(Events.NAME);
for (Object removedItem : removedItems) {
UserRemovedEvent event = new UserRemovedEvent((User) removedItem);
events.publish(event);
}
}
use of com.haulmont.cuba.core.global.Events in project cuba by cuba-platform.
the class AppContext method startContext.
static void startContext() {
if (started)
return;
started = true;
listeners.sort(new OrderComparator());
for (Listener listener : listeners) {
listener.applicationStarted();
}
Events events = (Events) getApplicationContext().getBean(Events.NAME);
events.publish(new AppContextStartedEvent(context));
listenersNotified = true;
}
Aggregations