View Javadoc

1   /**
2    * Copyright 2005-2008 the original author or authors.
3    *
4    * Licensed under the Gnu General Pubic License, Version 2.0 (the
5    * "License"); you may not use this file except in compliance with
6    * the License. You may obtain a copy of the License at
7    *
8    *      http://www.opensource.org/licenses/gpl-license.php
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13   * See the Gnu General Public License for more details.
14   */
15  package org.figure8.join.core.persistence;
16  
17  import org.figure8.join.core.EntityObject;
18  
19  import java.util.List;
20  /**
21   * This is an interface for defining an entity object Data Access Object.
22   * A Dao is the layer responsible for managing datastore access details.
23   * @author  <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
24   * @version $Revision: 1.3 $
25   */
26  public interface ObjectDao{
27     
28     // Public -------------------------------------------------------------------
29     
30     /**
31      * Save the given entity into underlying datastore.
32      * @param entityobject EntityObject to save
33      */
34     public abstract void save(EntityObject entityobject);
35     
36     /**
37      * Remove the given entity object from underlying datastore.
38      * @param entityobject EntityObject to remove
39      */
40     public abstract void remove(EntityObject entityobject);
41  
42     /**
43      * Re-read the content of the given entity from underlying datastore.
44      * @param entityobject EntityObject to refresh content
45      */
46     public abstract void refresh(EntityObject entityobject);
47  
48     /**
49      * Force initialization of the given entity from underlying datastore
50      * (this may involves initialization of lazily loaded relations fields)
51      * @param entityobject EntityObject to initialize
52      */
53     public abstract void initialize(EntityObject entityobject);
54  
55     /**
56      * Force initialization of the given entity association from underlying datastore
57      * @param entityobject EntityObject whose association shoud be initialized
58      * @param proxy A proxy object representing entoty association (this may be a collection)
59      */
60     public abstract void initializeAssociation(EntityObject entityobject, Object proxy);
61  
62     /**
63      * Check if an object (EntityObject or association proxy) is initialized from datastore
64      * @param object The object to check initialization for
65      * @return true if object has been loaded from datastore, false otherwise
66      */
67     public abstract boolean isInitialized(Object object);
68     
69     /**
70      * Persist the object state throughout the cluster.
71      * @param obj The object to replicate
72      */
73     public abstract void replicate(Object obj);
74  
75     /**
76      * Find all entity objects associated with this Dao.
77      * @return A List of EntityObjects
78      */
79     public abstract List findAll();
80  
81     /**
82      * Find all entity objects asscoiated with this Dao.
83      * The result list is sorted by <b>sortField</b> criteria.
84      * @param sortField Field for sorting criteria
85      * @return A List of EntityObjects
86      */
87     public abstract List findAllSorted(String sortField);
88  
89     /**
90      * Get the persistent class associated to this Dao.
91      * @return The class of the persistent object
92      */
93     public abstract Class getPersistentClass(); 
94  }