All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.agiletec.aps.system.common.notify.NotifyManager Maven / Gradle / Ivy

Go to download

Entando Engine: an agile, modern and user-centric open source Portal platform.

There is a newer version: 6.2.27
Show newest version
/*
 * Copyright 2015-Present Entando Inc. (http://www.entando.com) All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */
package com.agiletec.aps.system.common.notify;

import java.io.Serializable;
import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.context.ApplicationListener;

import com.agiletec.aps.system.SystemConstants;
import com.agiletec.aps.util.DateConverter;

/**
 * Servizio notificatore eventi.
 * @author M.Diana - E.Santoboni
 */
public class NotifyManager implements INotifyManager, ApplicationListener, 
BeanFactoryAware, ApplicationEventPublisherAware, Serializable {

	private static final Logger _logger = LoggerFactory.getLogger(NotifyManager.class);
	
	@Override
	public void onApplicationEvent(ApplicationEvent event) {
		if (event instanceof ApsEvent) {
			NotifyingEventThread thread = new NotifyingEventThread(this, (ApsEvent) event);
			thread.setName(NOTIFYING_THREAD_NAME + "_" + DateConverter.getFormattedDate(new Date(), "yyyy-MM-dd-HH-mm-ss"));
			thread.start();
			return;
		}
		_logger.debug("Unhandled generic event detected: {}", event.getClass().getName());
	}

	/**
	 * Notifica un evento ai corrispondenti servizi osservatori.
	 * @param event L'evento da notificare.
	 */
	protected void notify(ApsEvent event) {
		ListableBeanFactory factory = (ListableBeanFactory) this._beanFactory;
		String[] defNames = factory.getBeanNamesForType(event.getObserverInterface());
		for (int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy