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

com.ch.manager.SessionManager Maven / Gradle / Ivy

The newest version!
package com.ch.manager;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.logging.Logger;

import com.ch.config.ConfigProperties;
import com.ch.exception.DAOException;
import com.ch.exception.ValidationException;
import com.ch.model.BaseEntity;
import com.ch.model.SessionReport;
import com.ch.mongo.TemplateDao;
import com.ch.validator.SessionReportValidator;

public class SessionManager {
	private static final Logger LOGGER = Logger.getLogger(SessionManager.class.getName());
	private TemplateDao sessionDao;

	private SessionManager(TemplateDao sessionDao) {
		super();
		this.sessionDao = sessionDao;
	}

	public static SessionManager getSessionManager(String name, ConfigProperties config)
			throws NoSuchMethodException, SecurityException, ClassNotFoundException, InstantiationException,
			IllegalAccessException, IllegalArgumentException, InvocationTargetException {
		Constructor cons = Class.forName(name).getConstructor(ConfigProperties.class);
		TemplateDao dao = (TemplateDao) cons.newInstance(config);
		LOGGER.finest("SessionDao class loaded.");
		return new SessionManager(dao);
	}

	public void createSessionReport(BaseEntity sessionReportDetails) throws DAOException, ValidationException {
		SessionReport sessionReport = (SessionReport) sessionReportDetails;
		SessionReportValidator.validate(sessionReport);
		sessionDao.saveEntity(sessionReport);
		LOGGER.finest("Data saved successfully.");
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy