src/main/java/de/uapcore/lightpit/DatabaseFacade.java

changeset 38
cf85ef18f231
parent 34
824d4042c857
child 50
2a90d105edec
--- a/src/main/java/de/uapcore/lightpit/DatabaseFacade.java	Sun May 10 10:58:31 2020 +0200
+++ b/src/main/java/de/uapcore/lightpit/DatabaseFacade.java	Mon May 11 19:09:06 2020 +0200
@@ -28,8 +28,6 @@
  */
 package de.uapcore.lightpit;
 
-import de.uapcore.lightpit.dao.DataAccessObjects;
-import de.uapcore.lightpit.dao.postgres.PGDataAccessObjects;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -91,29 +89,14 @@
 
     private static final String DS_JNDI_NAME = "jdbc/lightpit/app";
     private DataSource dataSource;
-    private DataAccessObjects dataAccessObjects;
 
     /**
      * Returns the data source.
-     * <p>
-     * The Optional returned should never be empty. However, if something goes
-     * wrong during initialization, the data source might be absent.
-     * Hence, users of this data source are forced to check the existence.
      *
      * @return a data source
      */
-    public Optional<DataSource> getDataSource() {
-        // TODO: this should not be an optional, if an empty optional is actually an exception
-        return Optional.ofNullable(dataSource);
-    }
-
-    /**
-     * Returns the data access objects.
-     *
-     * @return an interface to obtain the data access objects
-     */
-    public DataAccessObjects getDataAccessObjects() {
-        return dataAccessObjects;
+    public DataSource getDataSource() {
+        return dataSource;
     }
 
     public Dialect getSQLDialect() {
@@ -171,8 +154,6 @@
             }
         }
 
-        dataAccessObjects = createDataAccessObjects(dialect);
-
         try {
             LOG.debug("Trying to access JNDI context {}...", contextName);
             Context initialCtx = new InitialContext();
@@ -191,15 +172,6 @@
         LOG.info("Database facade injected into ServletContext.");
     }
 
-    private static DataAccessObjects createDataAccessObjects(Dialect dialect) {
-        switch (dialect) {
-            case Postgres:
-                return new PGDataAccessObjects();
-            default:
-                throw new AssertionError("Non-exhaustive switch - this is a bug.");
-        }
-    }
-
     @Override
     public void contextDestroyed(ServletContextEvent sce) {
         dataSource = null;

mercurial