001: /**********************************************************************
002: Copyright (c) 2003 Andy Jefferson and others. All rights reserved.
003: Licensed under the Apache License, Version 2.0 (the "License");
004: you may not use this file except in compliance with the License.
005: You may obtain a copy of the License at
006:
007: http://www.apache.org/licenses/LICENSE-2.0
008:
009: Unless required by applicable law or agreed to in writing, software
010: distributed under the License is distributed on an "AS IS" BASIS,
011: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012: See the License for the specific language governing permissions and
013: limitations under the License.
014:
015:
016: Contributors:
017: 2004 Andy Jefferson - changed to use StoreData instead of AutoStartData
018: 2004 Erik Bengtson - added open()/close()/isOpen()
019: ...
020: **********************************************************************/package org.jpox.store;
021:
022: import java.util.Collection;
023:
024: import org.jpox.ClassLoaderResolver;
025: import org.jpox.store.exceptions.DatastoreInitialisationException;
026:
027: /**
028: * Interface defining an Auto-Start Mechanism.
029: * An Auto-Start Mechanism is a means of auto-populating the classes supported by a StoreManager.
030: * <P>
031: * If the user changes their persistence definition a problem can occur when starting up JPOX.
032: * JPOX loads up its existing data from a repository (e.g the table "JPOX_TABLES" for SchemaTableAutoStarter) and finds that a table/class
033: * required by the repository data no longer exists. There are 3 options for what JPOX will do in this situation.
034: * <ul>
035: * <li>Checked will mean that JPOX will throw an exception and the user will be expected to manually fix their datastore mismatch
036: * (perhaps by removing the existing tables).</li>
037: * <li>Quiet (the default) will simply remove the entry from the repository and continue without exception.</li>
038: * <li>Ignored will simply continue without doing anything.</li>
039: * </ul>
040: * </P>
041: *
042: * Implementations must have a public constructor taking the arguments {@link StoreManager} and {@link ClassLoaderResolver}
043: *
044: * @version $Revision: 1.6 $
045: **/
046: public interface AutoStartMechanism {
047: /** mechanism is disabled if None **/
048: public static final String NONE = "None";
049:
050: /** mechanism is in Quiet mode **/
051: public static final String MODE_QUIET = "Quiet";
052:
053: /** mechanism is in Checked mode **/
054: public static final String MODE_CHECKED = "Checked";
055:
056: /** mechanism is in Ignored mode **/
057: public static final String MODE_IGNORED = "Ignored";
058:
059: /**
060: * Accessor for the mode of operation.
061: * @return The mode of operation
062: **/
063: String getMode();
064:
065: /**
066: * Mutator for the mode of operation.
067: * @param mode The mode of operation
068: **/
069: void setMode(String mode);
070:
071: /**
072: * Accessor for the data for the classes that are currently auto started.
073: * @return Collection of {@link StoreData} elements
074: * @throws DatastoreInitialisationException
075: **/
076: Collection getAllClassData()
077: throws DatastoreInitialisationException;
078:
079: /**
080: * Starts a transaction for writing (add/delete) classes to the auto start mechanism.
081: */
082: void open();
083:
084: /**
085: * Closes a transaction for writing (add/delete) classes to the auto start mechanism.
086: */
087: void close();
088:
089: /**
090: * Whether it's open for writing (add/delete) classes to the auto start mechanism.
091: * @return whether this is open for writing
092: */
093: public boolean isOpen();
094:
095: /**
096: * Method to add a class/field (with its data) to the currently-supported list.
097: * @param data The data for the class.
098: **/
099: void addClass(StoreData data);
100:
101: /**
102: * Method to delete a class/field that is currently listed as supported in
103: * the internal storage.
104: * It does not drop the schema of the DatastoreClass
105: * neither the contents of it. It only removes the class from the
106: * AutoStart mechanism.
107: * TODO Rename this method to allow for deleting fields
108: * @param name The name of the class/field
109: **/
110: void deleteClass(String name);
111:
112: /**
113: * Method to delete all classes that are currently listed as supported in
114: * the internal storage. It does not drop the schema of the DatastoreClass
115: * neither the contents of it. It only removes the classes from the
116: * AutoStart mechanism.
117: **/
118: void deleteAllClasses();
119:
120: /**
121: * Utility to return a description of the storage for this mechanism.
122: * @return The storage description.
123: **/
124: String getStorageDescription();
125: }
|