/**
 *  Copyright ©2008-2009 DRIVER-II Project All Rights Reserved
 *
 */
package eu.dnetlib.common.ws;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import eu.dnetlib.common.interfaces.ws.IDriverService;
import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;

public abstract class DriverServiceImpl implements IDriverService {

	protected static final Log log = LogFactory.getLog(DriverServiceImpl.class);
	
	protected NotificationHandler notificationHandler;
	protected String serviceVersion;
	
	
	/* (non-Javadoc)
	 * @see org.driver.ws.DriverService#identify()
	 */
	public String identify() {
		log.debug("identify: " + serviceVersion);
		return serviceVersion;
	}

	/* (non-Javadoc)
	 * @see org.driver.ws.DriverService#notify(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
	 */
	public boolean notify(String subscrId, String topic, String isId,
			String message) {
		boolean returnValue = false;
		log.debug("---- service got notification ----");
		log.debug("subscrId: " + subscrId);
		log.debug("topic " + topic);
		log.debug("isId " + isId);
		log.debug("msg: " + message);
		log.debug("____ now processing the notification ____");

		if (notificationHandler != null){
			notificationHandler.notified(subscrId, topic, isId, message);
		}
		return returnValue;
	}
	
	public String getServiceVersion() {
		return serviceVersion;
	}

	public void setServiceVersion(String serviceVersion) {
		this.serviceVersion = serviceVersion;
	}

	/**
	 * @param notificationHandler the notificationHandler to set
	 */
	public void setNotificationHandler(NotificationHandler notificationHandler) {
		this.notificationHandler = notificationHandler;
	}

	/**
	 * @return the notificationHandler
	 */
	public NotificationHandler getNotificationHandler() {
		return notificationHandler;
	}

}
