KickJava   Java API By Example, From Geeks To Geeks.

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


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 import oracle.toplink.essentials.internal.sequencing.Sequencing;
25 import oracle.toplink.essentials.threetier.ClientSession;
26
27 /**
28  * ClientSessionSequencing is private to TopLink.
29  * It provides sequencing for ClientSession.
30  * It contains a reference to SequencingServer object owned by
31  * ClientSession's parent ServerSession.
32  *
33  * @see SequencingServer
34  * @see oracle.toplink.essentials.threetier.ClientSession
35  *
36  */

37 class ClientSessionSequencing implements Sequencing {
38     // ownerClientSession
39
protected ClientSession clientSession;
40
41     // SequencingServer owned by clientSession's parent SrverSession
42
protected SequencingServer sequencingServer;
43
44     /**
45     * INTERNAL:
46     * Takes a potential owner - ClientSession as an argument.
47     * This static method is called before an instance of this class is created.
48     * The goal is to verify whether the instance of ClientSessionSequencing should be created.
49     */

50     public static boolean sequencingServerExists(ClientSession cs) {
51         return cs.getParent().getSequencingServer() != null;
52     }
53
54     /**
55     * INTERNAL:
56     * Takes an owner - ClientSession as an argument.
57     */

58     public ClientSessionSequencing(ClientSession clientSession) {
59         this.clientSession = clientSession;
60         sequencingServer = clientSession.getParent().getSequencingServer();
61     }
62
63     /**
64     * INTERNAL:
65     * Simply calls the same method on SequencingServer
66     */

67     public boolean shouldAcquireValueAfterInsert(Class JavaDoc cls) {
68         return sequencingServer.shouldAcquireValueAfterInsert(cls);
69     }
70
71     /**
72     * INTERNAL:
73     * Simply calls the same method on SequencingServer
74     */

75     public int whenShouldAcquireValueForAll() {
76         return sequencingServer.whenShouldAcquireValueForAll();
77     }
78
79     /**
80     * INTERNAL:
81     * Simply calls the same method on SequencingServer
82     */

83     public boolean shouldOverrideExistingValue(Class JavaDoc cls, Object JavaDoc existingValue) {
84         return sequencingServer.shouldOverrideExistingValue(cls, existingValue);
85     }
86
87     /**
88     * INTERNAL:
89     * This method is the reason for this class to exist:
90     * SequencingServer.getNextValue takes two arguments
91     * the first argument being a session which owns write connection
92     * (either DatabaseSession or ClientSession).
93     */

94     public Object JavaDoc getNextValue(Class JavaDoc cls) {
95         return sequencingServer.getNextValue(clientSession, cls);
96     }
97 }
98
Popular Tags