KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
30  * This is a base class for Storage Objects implemented with Hibernate.
31  *
32  * @author <a HREF="mailto:pretend@ukr.net">Alex Andrushchak</a>
33  *
34  * @version 0.1
35  */

36
37 public abstract class StorageObjectBase
38     extends org.objectweb.openccm.pss.runtime.common.lib.StorageObjectBase
39     implements org.objectweb.openccm.pss.runtime.hibernate.api.StorageObject
40 {
41     // ==================================================================
42
//
43
// Internal state.
44
//
45
// ==================================================================
46

47     // ==================================================================
48
//
49
// Constructor.
50
//
51
// ==================================================================
52

53     /**
54      * The default constructor.
55      */

56     public StorageObjectBase()
57     {
58         super();
59     }
60
61     // ==================================================================
62
//
63
// Internal methods.
64
//
65
// ==================================================================
66
/**
67      * Create the short PID.
68      */

69     private String JavaDoc
70     create_short_pid()
71     {
72         org.objectweb.openccm.pss.runtime.hibernate.api.CatalogBase catalog = null;
73         net.sf.hibernate.Session session = null;
74
75         // Get the persistent manager
76
catalog = (org.objectweb.openccm.pss.runtime.hibernate.api.CatalogBase)
77                         get_storage_home().get_catalog();
78         session = catalog.get_hibernate_session();
79
80         try {
81             return session.getIdentifier(this).toString();
82         } catch (net.sf.hibernate.HibernateException ex) {
83             throw new RuntimeException JavaDoc(ex);
84         }
85     }
86
87
88     // ==================================================================
89
//
90
// Public methods.
91
//
92
// ==================================================================
93

94     // ==================================================================
95
//
96
// Methods for org.omg.CosPersistentState.StorageObject
97
//
98
// ==================================================================
99

100     /**
101      * Destroy the associated Storage Object.
102      */

103     public void
104     destroy_object()
105     {
106         org.objectweb.openccm.pss.runtime.hibernate.api.CatalogBase catalog = null;
107         net.sf.hibernate.Session session = null;
108
109         // Get the persistent manager
110
catalog = (org.objectweb.openccm.pss.runtime.hibernate.api.CatalogBase)
111                         get_storage_home().get_catalog();
112         session = catalog.get_hibernate_session();
113
114         // Remove the storage type
115
catalog.begin_tx();
116         try {
117             session.delete(this);
118         } catch (net.sf.hibernate.HibernateException ex) {
119             throw new RuntimeException JavaDoc(ex);
120         }
121         catalog.commit_tx();
122    }
123
124     // ==================================================================
125
//
126
// Methods for org.objectweb.openccm.pss.runtime.common.api.StorageObject
127
//
128
// ==================================================================
129
/**
130      * Get the PID.
131      */

132     public byte[]
133     get_pid()
134     {
135         if (_pid == null)
136         {
137             org.objectweb.openccm.pss.runtime.hibernate.api.StorageHomeBase sh = null;
138
139             sh = (org.objectweb.openccm.pss.runtime.hibernate.api.StorageHomeBase) get_storage_home();
140             _pid = sh.create_pid( create_short_pid() );
141         }
142         return _pid;
143     }
144
145
146     // ==================================================================
147
//
148
// Methods for org.objectweb.openccm.pss.runtime.hibernate.api.StorageObject
149
//
150
// ==================================================================
151

152 }
153
Popular Tags