001 /*****************************************************************************
002 * Copyright (C) NanoContainer Organization. All rights reserved. *
003 * ------------------------------------------------------------------------- *
004 * The software in this package is published under the terms of the BSD *
005 * style license a copy of which has been included with this distribution in *
006 * the LICENSE.txt file. *
007 * *
008 *****************************************************************************/
009 package org.nanocontainer.nanowar.sample.service.defaults;
010
011 import java.io.Serializable;
012 import java.util.Collection;
013
014 import org.nanocontainer.nanowar.sample.dao.CheeseDao;
015 import org.nanocontainer.nanowar.sample.model.Cheese;
016 import org.nanocontainer.nanowar.sample.service.CheeseService;
017
018 /**
019 * Default implementation of CheeseService. Typically it will be used a proxy to
020 * delegate execution of the MVC-framework specific action.
021 *
022 * @author Stephen Molitor
023 * @author Mauro Talevi
024 */
025 public class DefaultCheeseService implements CheeseService, Serializable {
026
027 private final CheeseDao dao;
028
029 public DefaultCheeseService(CheeseDao dao) {
030 this.dao = dao;
031 }
032
033 public Collection getCheeses() {
034 return dao.all();
035 }
036
037 public Cheese find(Cheese example) {
038 return dao.get(example.getName());
039 }
040
041 public void save(Cheese cheese) {
042 dao.save(cheese);
043 }
044
045 public void remove(Cheese cheese) {
046 dao.remove(cheese);
047 }
048 }