01: /*
02: * Copyright 2002 (C) TJDO.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the TJDO License version 1.0.
06: * See the terms of the TJDO License in the documentation provided with this software.
07: *
08: * $Id: SchemaManager.java,v 1.4 2003/10/18 22:05:16 jackknifebarber Exp $
09: */
10:
11: package com.triactive.jdo;
12:
13: /**
14: * An interface to perform limited storage management on a database schema
15: * used by TJDO.
16: *
17: * @author <a href="mailto:mmartin5@austin.rr.com">Mike Martin</a>
18: * @version $Revision: 1.4 $
19: *
20: * @see SchemaManagerFactory
21: */
22:
23: public interface SchemaManager {
24: /**
25: * Returns the name of the database schema.
26: *
27: * @return The name of the database schema, or <code>null</code> if the
28: * DBMS does not support the concept of schemas.
29: */
30: String getSchemaName();
31:
32: /**
33: * Adds to the schema any database objects (tables, views, constraints,
34: * indexes, etc.) necessary to enable persistence of the given
35: * PersistenceCapable class(es).
36: * If any of the objects already exist, they are validated for structural
37: * correctness; that is, checked to ensure that they "match" the current
38: * class code and JDO metadata.
39: * <p>
40: * This method is primarily useful for applications that wish to perform all
41: * of their database initialization up front, rather than wait for the TJDO
42: * runtime to do it on-demand.
43: * <p>
44: * SQL identifiers for new database objects are chosen so as not to collide
45: * with any existing objects.
46: * Therefore it is always safe for TJDO and non-TJDO code to share the same
47: * database schema.
48: *
49: * @param classes The class(es) to be added.
50: *
51: * @exception SchemaValidationException
52: * If there is some mismatch between the current schema contents and
53: * those necessary to enable persistence of the given classes.
54: */
55: void addClasses(Class[] classes);
56:
57: /**
58: * Removes from the schema any existing database tables used in persisting
59: * the given PersistenceCapable class(es).
60: * <p>
61: * This method will fail if the relevant tables are depended upon by others
62: * used for classes that are not being removed.
63: * In case of failure, it is unspecified whether or not any tables were
64: * actually removed.
65: * <p>
66: * After dropping tables this method performs an implicit {@link #reset}.
67: *
68: * @param classes The class(es) whose tables are to be removed.
69: */
70: void dropTablesFor(Class[] classes);
71:
72: /**
73: * Drops all tables in the schema.
74: * This empties the schema of all database objects managed by TJDO.
75: * All objects not managed by TJDO are left untouched.
76: * <p>
77: * After dropping tables this method performs an implicit {@link #reset}.
78: */
79: void dropAllTables();
80:
81: /**
82: * Resets the schema manager back to its initial state.
83: * This method discards all knowledge of persistent classes and the state of
84: * the schema.
85: * After reset(), all initialization procedures such as schema validation
86: * etc. will be repeated as necessary as though the JVM were starting anew.
87: */
88: void reset();
89: }
|