/** * Copyright (C) 2021, Tim Holloway * * Date written: Dec 7, 2021 * Author: Tim Holloway */ package com.mousetech.gourmetj; import java.util.List; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import jakarta.inject.Named; import com.mousetech.gourmetj.persistence.service.RecipeService; /** * @author timh * @since Dec 7, 2021 */ @Named @ApplicationScoped public class CuisineBean { @Inject private RecipeService recipeService; private List cuisineList; /** * Return list of cuisines currently on file. Create it if * needed. */ public List getCuisineList() { if (this.cuisineList == null ) { this.cuisineList = loadCuisineList(); } return this.cuisineList; } private synchronized List loadCuisineList() { List list = this.recipeService.findCuisines(); return list; } public synchronized void registerCuisine(String cuisineString) { // search in-memory list. Add if needed. } }