Search in sources :

Example 1 with FirestoreDao

use of com.example.getstarted.daos.FirestoreDao in project getting-started-java by GoogleCloudPlatform.

the class BookshelfContextListener method contextInitialized.

@Override
public void contextInitialized(ServletContextEvent event) {
    // This function is called when the application starts and will safely set a few required
    // context attributes such as the BookDao.
    BookDao dao = (BookDao) event.getServletContext().getAttribute("dao");
    if (dao == null) {
        dao = new FirestoreDao();
        event.getServletContext().setAttribute("dao", dao);
    }
    Boolean isCloudStorageConfigured = (Boolean) event.getServletContext().getAttribute("isCloudStorageConfigured");
    if (isCloudStorageConfigured == null) {
        event.getServletContext().setAttribute("isCloudStorageConfigured", !Strings.isNullOrEmpty(System.getenv("BOOKSHELF_BUCKET")));
    }
    CloudStorageHelper storageHelper = (CloudStorageHelper) event.getServletContext().getAttribute("storageHelper");
    if (storageHelper == null) {
        storageHelper = new CloudStorageHelper();
        event.getServletContext().setAttribute("storageHelper", storageHelper);
    }
}
Also used : FirestoreDao(com.example.getstarted.daos.FirestoreDao) BookDao(com.example.getstarted.daos.BookDao)

Aggregations

BookDao (com.example.getstarted.daos.BookDao)1 FirestoreDao (com.example.getstarted.daos.FirestoreDao)1