KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > pss > runtime > hibernate > lib > Session


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA & USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Alex Andrushchak.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.pss.runtime.hibernate.lib;
28
29 import org.objectweb.openccm.pss.runtime.common.lib.PIDHelper;
30
31 /**
32  * This class establish a session with a Hibernate implementation.
33  * It implements the org.objectweb.openccm.services.pss.api.Connector interface.
34  *
35  * @author <a HREF="mailto:pretend@ukr.net">Alex Andrushchak</a>
36  *
37  * @version 0.1
38  */

39
40 public class Session
41      extends org.objectweb.openccm.pss.runtime.hibernate.lib.CatalogBase
42   implements org.objectweb.openccm.pss.runtime.hibernate.api.Session
43 {
44     // ==================================================================
45
//
46
// Internal state.
47
//
48
// ==================================================================
49

50     // ==================================================================
51
//
52
// Constructor.
53
//
54
// ==================================================================
55

56     /**
57      * The default constructor.
58      *
59      * @param id - The catalog id.
60      * @param session - The associted Hibernate Session.
61      */

62     public Session(int id, net.sf.hibernate.Session session)
63     {
64         super(id, session);
65     }
66
67     // ==================================================================
68
//
69
// Internal methods.
70
//
71
// ==================================================================
72

73     // ==================================================================
74
//
75
// Public methods.
76
//
77
// ==================================================================
78

79     // ==================================================================
80
//
81
// Methods for org.omg.CosPersistentState.Catalog
82
//
83
// ==================================================================
84

85     /**
86      * Retrieve a storage object with its pid.
87      */

88     public java.lang.Object JavaDoc
89     find_by_pid(byte[] the_pid)
90     throws org.omg.CosPersistentState.NotFound
91     {
92         // System.out.println("Session.find_by_pid: the_pid=" + the_pid);
93
org.omg.CosPersistentState.StorageHomeBase sh = null;
94
95         // Get the object storage home with its Repository ID
96
sh = find_storage_home(PIDHelper.get_RID(the_pid));
97
98         return sh.find_by_short_pid(PIDHelper.get_short_pid(the_pid));
99     }
100
101     /**
102      * Operation flush
103      */

104     public void
105     flush()
106     {
107         commit_tx();
108     }
109
110     /**
111      * Operation refresh
112      */

113     public void
114     refresh()
115     {
116         rollback_tx();
117     }
118
119     /**
120      * Operation free_all
121      */

122     public void
123     free_all()
124     {
125         // For each Storage Home, free registered storage types incarnations
126
// TO DO
127
}
128
129     /**
130      * Operation close
131      */

132     public void
133     close()
134     {
135         flush();
136         try {
137             get_hibernate_session().close();
138         } catch (net.sf.hibernate.HibernateException ex) {
139             throw new RuntimeException JavaDoc(ex);
140         }
141     }
142
143     // ==================================================================
144
//
145
// Methods for org.objectweb.openccm.pss.runtime.common.api.CatalogBase
146
//
147
// ==================================================================
148

149     // ==================================================================
150
//
151
// Methods for org.objectweb.openccm.pss.runtime.hibernate.api.CatalogBase
152
//
153
// ==================================================================
154
}
155
Popular Tags