View Javadoc
1   /*******************************************************************************
2    *   Gisgraphy Project 
3    * 
4    *   This library is free software; you can redistribute it and/or
5    *   modify it under the terms of the GNU Lesser General Public
6    *   License as published by the Free Software Foundation; either
7    *   version 2.1 of the License, or (at your option) any later version.
8    * 
9    *   This library is distributed in the hope that it will be useful,
10   *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12   *   Lesser General Public License for more details.
13   * 
14   *   You should have received a copy of the GNU Lesser General Public
15   *   License along with this library; if not, write to the Free Software
16   *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
17   * 
18   *  Copyright 2008  Gisgraphy project 
19   *  David Masclet <davidmasclet@gisgraphy.com>
20   *  
21   *  
22   *******************************************************************************/
23  package com.gisgraphy.service;
24  
25  import java.io.Serializable;
26  import java.util.List;
27  
28  /**
29   * Business Facade interface.
30   * 
31   * @author <a href="mailto:matt@raibledesigns.com">Matt Raible</a>
32   *         Modifications and comments by <a href="mailto:bwnoll@gmail.com">Bryan
33   *         Noll</a> This thing used to be named simply 'GenericManager' in
34   *         versions of AppFuse prior to 2.0. It was renamed in an attempt to
35   *         distinguish and describe it as something different than
36   *         GenericManager. GenericManager is intended for subclassing, and was
37   *         named Generic because 1) it has very general functionality and 2) is
38   *         'generic' in the Java 5 sense of the word... aka... it uses Generics.
39   *         Implementations of this class are not intended for subclassing. You
40   *         most likely would want to subclass GenericManager. The only real
41   *         difference is that instances of java.lang.Class are passed into the
42   *         methods in this class, and they are part of the constructor in the
43   *         GenericManager, hence you'll have to do some casting if you use this
44   *         one.
45   */
46  public interface UniversalManager {
47      /**
48       * Generic method used to get a all objects of a particular type.
49       * 
50       * @param clazz
51       *                the type of objects
52       * @return List of populated objects
53       */
54      List<?> getAll(Class<?> clazz);
55  
56      /**
57       * Generic method to get an object based on class and identifier.
58       * 
59       * @param clazz
60       *                model class to lookup
61       * @param id
62       *                the identifier (primary key) of the class
63       * @return a populated object
64       * @see org.springframework.orm.ObjectRetrievalFailureException
65       */
66      Object get(Class<?> clazz, Serializable id);
67  
68      /**
69       * Generic method to save an object.
70       * 
71       * @param o
72       *                the object to save
73       * @return a populated object
74       */
75      Object save(Object o);
76  
77      /**
78       * Generic method to delete an object based on class and id
79       * 
80       * @param clazz
81       *                model class to lookup
82       * @param id
83       *                the identifier of the class
84       */
85      void remove(Class<?> clazz, Serializable id);
86  }