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);
}
}
Aggregations