Source code: org/enableit/db/daf/DataAbstractionFacade.java
1 package org.enableit.db.daf;
2
3 /**
4 * Abstraction interface for various data persistence technologies.
5 * As such this interface and its implementations are supposed to
6 * be thin wrappers over one of the various data persistence options
7 * (e.g. JDBC, Entity EJB, JDO etc...), <em>not</em>
8 * an alternative in their own right or an implementation of
9 * one of these technologes.
10 * <br>
11 * This allows UI applications to be written in a persistence impartial
12 * manner. That may sound similar to the purpose of the Sun JDO spec,
13 * but it is different because this toolkit is intended to be part of
14 * an application architecture, not part of the infrastructure.
15 * In this way it is hoped that this interface can protect application
16 * developers from the evolution of Java technologies. As new infrastructure
17 * technologies and optimisations become available from Sun and other
18 * infrastructure vendors they can be 'plugged in' by implementing
19 * this interface.
20 * <br>
21 * The other main purpose is to allow applications to be rapidly
22 * configured to the most appropriate persistence technology in a
23 * declarative manner (i.e. without code changes). For example a small
24 * web-application with direct JDBC persistence may 'scale-up' to
25 * Entity EJB data persistence simply by configuration of the
26 * data-abstraction.xml file.
27 * <br>
28 * Implementations of this interface have responsibility for encoding
29 * the data for the appropriate data store, but are not required to
30 * validate that data. This is the responsibility of application
31 * business objects of generic UI services such as the Struts validator.
32 *
33 * @author default
34 */
35 public interface DataAbstractionFacade
36 {
37 /**
38 * Test if the bean exists in the configured data store.
39 * <p>
40 * If the bean implements <code>org.enableit.db.daf.ComparableBean</code>
41 * then the Persistent datastore will be queried for an entry that matches
42 * just those properties defined by the <code>getEqualityPropertyList</code>.
43 * Otherwise every accessible property will be used in the query.
44 *
45 * @param bean
46 */
47 boolean exists (Object bean)
48 throws QueryException;
49
50 /** @param bean */
51 Object create (Object bean)
52 throws NotPersistedException;
53
54 /** @param bean */
55 Object modify (Object bean)
56 throws NotPersistedException;
57
58 /** @param bean */
59 Object remove (Object bean)
60 throws NotPersistedException;
61
62 /** @param bean */
63 Object load (Object bean)
64 throws QueryException;
65
66
67 }