com.ch.manager.SessionManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ch-mongo Show documentation
Show all versions of ch-mongo Show documentation
Persistence services for mongo collections.
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