I am using a singleton in my DAO. Would I be better off with static
methods? Also, should I be worried about synchronization of the singleton and my data structures?
public class RAMUserDAO implements GenericDAO<User, String, Boolean>
{
private static RAMUserDAO userDAO = null;
private Map<String, User> userList;
private Map<String, User> banList;
private static Logger log = LOG.PRODUCTION;
private RAMUserDAO()
{
userList = new ConcurrentHashMap<String, User>();
banList = new ConcurrentHashMap<String, User>();
}
public static RAMUserDAO getRAMUserDAO()
{
if (userDAO == null)
{
synchronized (RAMUserDAO.class)
{
if (userDAO == null)
{
userDAO = new RAMUserDAO();
}
}
}
return userDAO;
}
}