KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > internal > sequencing > Sequencing


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2005, Oracle. All rights reserved.
22
package oracle.toplink.essentials.internal.sequencing;
23
24
25 /**
26  * <p>
27  * <b>Purpose</b>: Define interface to use sequencing.
28  * <p>
29  * <b>Description</b>: This interface accessed through Session.getSequencing() method.
30  * Used by TopLink internals to obtain sequencing values.
31  * <p>
32  * <b>Responsibilities</b>:
33  * <ul>
34  * <li> Provides sequencing objects and supporting APIs.
35  * </ul>
36  */

37 public interface Sequencing {
38     // Possible return values for whenShouldAcquireValueForAll() method:
39
// all classes should acquire sequencing value before insert;
40
public static final int BEFORE_INSERT = -1;
41
42     // some classes should acquire sequencing value before insert, some after;
43
public static final int UNDEFINED = 0;
44
45     // all classes should acquire sequencing value after insert;
46
public static final int AFTER_INSERT = 1;
47
48     /**
49     * INTERNAL:
50     * Indicates when sequencing value should be acqiured for all classes.
51     * There are just three possible return values:
52     * BEFORE_INSERT, UNDEFINED, AFTER_INSERT.
53     * Used as a shortcut to avoid individual checks for each class:
54     * shouldAcquireValueAfterInsert(Class cls).
55     * Currently UNDEFINED only happens in a case of a SessionBroker:
56     * session1 - BEFORE_INSERT, session2 - AFTER_INSERT
57     */

58     public int whenShouldAcquireValueForAll();
59
60     /**
61     * INTERNAL:
62     * Indicates whether sequencing value should be acqiured
63     * before or after INSERT
64     */

65     public boolean shouldAcquireValueAfterInsert(Class JavaDoc cls);
66
67     /**
68     * INTERNAL:
69     * Indicates whether existing attribute value should be overridden.
70     * This method is called in case an attribute mapped to PK of sequencing-using
71     * descriptor contains non-null value.
72     * @param seqName String is sequencing number field name
73     * @param existingValue Object is a non-null value of PK-mapped attribute.
74     */

75     public boolean shouldOverrideExistingValue(Class JavaDoc cls, Object JavaDoc existingValue);
76
77     /**
78     * INTERNAL:
79     * Return the newly-generated sequencing value.
80     * @param cls Class for which the sequencing value is generated.
81     */

82     public Object JavaDoc getNextValue(Class JavaDoc cls);
83 }
84
Popular Tags