KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > sequencing > SequencingControl


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, 2006, Oracle. All rights reserved.
22
package oracle.toplink.essentials.sequencing;
23
24 import oracle.toplink.essentials.sessions.Login;
25
26 /**
27  * <p>
28  * <b>Purpose</b>: Define an interface to control sequencing functionality.
29  * <p>
30  * <b>Description</b>: This interface is accessed through DatabaseSession.getSequencingControl().
31  * It allows to create, re-create, customize Sequencing object
32  * which is available through DatabaseSession.getSequencing()
33  * and provides sequencing values for all descriptors that use sequencing.
34  *
35  * Here's the lifecycle of Sequencing object used by DatabaseSession:
36  * 1. DatabaseSession created - sequencing object doesn't yet exist;
37  * 2. DatabaseSession.login() causes creation of Sequencing object;
38  * 3. DatabaseSession.logout() causes destruction of Sequencing object.
39  *
40  * In case sequencing object doesn't yet exist all the set parameters' values will be used
41  * during its creation.
42  *
43  * In case sequencing object already exists:
44  * 1. The following methods don't alter sequencing object - the corresponding parameters will only
45  * be used in case a new sequencing object is created:
46  * setShouldUseSeparateConnection;
47  * setLogin;
48  * setMinPoolSize;
49  * setMaxPoolSize.
50  * 2. The following methods cause immediate destruction of the sequencing object and creation of a new one:
51  * setValueGenerationPolicy;
52  * setShouldUseNativeSequencing;
53  * setShouldUseTableSequencing;
54  * resetSequencing;
55  * 3. The following methods cause change immediately:
56  * setPreallocationSize (next sequencing preallocation will use the set parameter's value).
57  * <p>
58  * <b>Responsibilities</b>:
59  * <ul>
60  * <li> Define the APIs for controlling sequencing.
61  * </ul>
62  * @see Sequence
63  * @see oracle.toplink.essentials.publicinterface.DatabaseSession
64  */

65 public interface SequencingControl {
66
67     /**
68     * ADVANCED:
69     * Immediately re-create sequencing object.
70     * The only reason to use this method is to pick up all parameters'
71     * values that were changed after the original sequencing object has been created.
72     */

73     public void resetSequencing();
74
75     /**
76     * PUBLIC:
77     * Indicate whether separate connection(s) for sequencing could be used
78     * (by default it couldn't).
79     * If this flag is set to true then separate connection(s) for sequencing
80     * will be used in case getSequence().shouldUseSeparateConnection()
81     * returns true.
82     * @see Sequence
83     */

84     public boolean shouldUseSeparateConnection();
85
86     /**
87     * PUBLIC:
88     * Set whether separate connection(s) for sequencing could be used
89     * (by default it couldn't).
90     * If this flag is set to true then separate connection(s) for sequencing
91     * will be used in case getSequence().shouldUseSeparateConnection()
92     * returns true.
93     * @see Sequence
94     */

95     public void setShouldUseSeparateConnection(boolean shouldUseSeparateConnection);
96
97     /**
98     * PUBLIC:
99     * Indicates whether sequencing actually uses separate connection(s).
100     * Returns true if sequencing is connected and uses separate connection(s).
101     * Returns false if sequencing is not connected (getSequencing()==null).
102     * Note that if shouldUseSeparateConnection() returns false this method also returns false.
103     * However if shouldUseSeparateConnection() returns true this method
104     * returns false in the following two cases:
105     * sequencing is not connected;
106     * getSequence().shouldUseSeparateConnection() == false.
107     * @see Sequence
108     */

109     public boolean isConnectedUsingSeparateConnection();
110
111     /**
112     * ADVANCED:
113     * Return a DatabaseLogin to be used by separate sequencing connection(s).
114     * @see oracle.toplink.essentials.sessions.DatabaseLogin
115     */

116     public Login getLogin();
117
118     /**
119     * ADVANCED:
120     * Returns a DatabaseLogin to be used by separate sequencing connection(s)
121     * The set value is ignored if shouldUseSeparateConnection() returns false.
122     * The DatabaseLogin *MUST*:
123     * 1. specify *NON-JTS* connections (such as NON_JTS driver or read-only datasource);
124     * 2. sequenceLogin.shouldUseExternalTransactionController()==false
125     * In case this method is not called, but separate connection should be used,
126     * sequencing will use a clone of login owned by the DatabaseSession,
127     * or a clone of read login owned by ServerSession.
128     * @see oracle.toplink.essentials.sessions.DatabaseLogin
129     */

130     public void setLogin(Login login);
131
132     /**
133     * PUBLIC:
134     * Returns a minimum number of connections in sequencing connection pool.
135     * @see oracle.toplink.essentials.threetier.ConnectionPool
136     * @see oracle.toplink.essentials.threetier.ServerSession
137     */

138     public int getMinPoolSize();
139
140     /**
141     * PUBLIC:
142     * Sets a minimum number of connections in sequencing connection pool
143     * The set value is ignored if shouldUseSeparateConnection() returns false.
144     * The set value is ignored if SequencingControl has been obtained not from ServerSession.
145     * By default is 2.
146     * @see oracle.toplink.essentials.threetier.ConnectionPool
147     * @see oracle.toplink.essentials.threetier.ServerSession
148     */

149     public void setMinPoolSize(int size);
150
151     /**
152     * PUBLIC:
153     * Returns a maximum number of connections in sequencing connection pool
154     * @see oracle.toplink.essentials.threetier.ConnectionPool
155     * @see oracle.toplink.essentials.threetier.ServerSession
156     */

157     public int getMaxPoolSize();
158
159     /**
160     * PUBLIC:
161     * Sets a maximum number of connections in sequencing connection pool
162     * The set value is ignored if shouldUseSeparateConnection() returns false.
163     * The set value is ignored if SequencingControl has been obtained not from ServerSession.
164     * By default is 2.
165     * @see oracle.toplink.essentials.threetier.ConnectionPool
166     * @see oracle.toplink.essentials.threetier.ServerSession
167     */

168     public void setMaxPoolSize(int size);
169
170     /**
171     * ADVANCED:
172     * Removes all preallocated sequencing objects.
173     * Ignored if getSequencingValueGenarationPolicy().shouldUsePreallocation() returns false.
174     * This method is called internally after Sequencing object is destructed.
175     * @see Sequence
176     */

177     public void initializePreallocated();
178
179     /**
180     * ADVANCED:
181     * Removes all preallocated sequencing objects for the given sequence name.
182     * Ignored if getSequencingValueGenarationPolicy().shouldUsePreallocation() returns false.
183     * @see Sequence
184     */

185     public void initializePreallocated(String JavaDoc seqName);
186 }
187
Popular Tags