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