01: package org.apache.ojb.broker.util.sequence;
02:
03: /* Copyright 2002-2005 The Apache Software Foundation
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: import org.apache.ojb.broker.accesslayer.JdbcAccess;
19: import org.apache.ojb.broker.metadata.ClassDescriptor;
20: import org.apache.ojb.broker.metadata.FieldDescriptor;
21:
22: /**
23: * SequenceManagers are responsible for creating new unique
24: * ID's - unique accross all "extent" object declarations in OJB metadata.
25: * There are some standard sequence manager implementations in
26: * this package.
27: * <p/>
28: * SequenceManager objects are obtained from a factory class called
29: * {@link SequenceManagerFactory}.
30: * This Factory can be configured to provide instances of user defined
31: * implementors of this interface.
32: * <p/>
33: * NOTE: SequenceManagers should be aware of "extents" ("extent" is an OJB inheritance feature),
34: * that is: if you ask for an uid for an Interface (more exact for one implementor class)
35: * with several implementor classes, or a baseclass with several subclasses the returned uid
36: * should be unique accross all tables representing objects of the extent in question.
37: *
38: * @version $Id: SequenceManager.java,v 1.10.2.6 2005/12/21 22:28:41 tomdz Exp $
39: */
40: public interface SequenceManager {
41: /**
42: * This method is called to get an unique value <strong>before</strong> the object
43: * is written to persistent storage.
44: * <br/>
45: * Returns a unique object for the given field attribute.
46: * The returned value takes in account the jdbc-type
47: * and the FieldConversion.sql2java() conversion defined for <code>field</code>.
48: * The returned object is unique accross all tables of "extent" classes the
49: * field belongs to.
50: * <br/>
51: * Implementations using native identity columns should return a unique
52: * incremented counter object for temporary use by OJB.
53: */
54: public Object getUniqueValue(FieldDescriptor field)
55: throws SequenceManagerException;
56:
57: /**
58: * This method is called <strong>after</strong> the object was written to the persistent storage.
59: * <br/>
60: * This is to support native Identity columns (auto_increment columns) on the db side.
61: * Other implementations may ignore this method.
62: * @param dbAccess Current used {@link org.apache.ojb.broker.accesslayer.JdbcAccess} instance
63: * @param cld Descriptor for specified object
64: * @param obj The object to associate with identity value
65: */
66: public void afterStore(JdbcAccess dbAccess, ClassDescriptor cld,
67: Object obj) throws SequenceManagerException;
68: }
|