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): Christophe Demarey. 23 Contributor(s): ______________________________________. 24 25 ====================================================================*/ 26 27 package org.objectweb.openccm.pss.runtime.jdo.lib; 28 29 /** 30 * This is a base class for Storage Objects implemented with JDO. 31 * 32 * @author <a HREF="mailto:Christophe.Demarey@lifl.fr">Christophe Demarey</a> 33 * 34 * @version 0.1 35 */ 36 public abstract class StorageObjectBase 37 extends org.objectweb.openccm.pss.runtime.common.lib.StorageObjectBase 38 implements org.objectweb.openccm.pss.runtime.jdo.api.StorageObject 39 { 40 // ================================================================== 41 // 42 // Internal state. 43 // 44 // ================================================================== 45 46 // ================================================================== 47 // 48 // Constructor. 49 // 50 // ================================================================== 51 52 /** 53 * The default constructor. 54 */ 55 public StorageObjectBase() 56 { 57 super(); 58 } 59 60 // ================================================================== 61 // 62 // Internal methods. 63 // 64 // ================================================================== 65 66 /** 67 * Create the short PID. 68 */ 69 private String 70 create_short_pid() 71 { 72 return javax.jdo.JDOHelper.getObjectId(this).toString(); 73 } 74 75 // ================================================================== 76 // 77 // Public methods. 78 // 79 // ================================================================== 80 81 // ================================================================== 82 // 83 // Methods for org.omg.CosPersistentState.StorageObject 84 // 85 // ================================================================== 86 87 /** 88 * Destroy the associated Storage Object. 89 */ 90 public void 91 destroy_object() 92 { 93 org.objectweb.openccm.pss.runtime.jdo.api.CatalogBase catalog = null; 94 javax.jdo.PersistenceManager pm = null; 95 96 // Get the persistent manager 97 catalog = (org.objectweb.openccm.pss.runtime.jdo.api.CatalogBase) 98 get_storage_home().get_catalog(); 99 pm = catalog.get_persistence_manager(); 100 101 // Remove the storage type 102 catalog.begin_tx(); 103 pm.deletePersistent(this); 104 catalog.commit_tx(); 105 } 106 107 // ================================================================== 108 // 109 // Methods for org.objectweb.openccm.pss.runtime.common.api.StorageObject 110 // 111 // ================================================================== 112 113 /** 114 * Get the PID. 115 */ 116 public byte[] 117 get_pid() 118 { 119 if (_pid == null) 120 { 121 org.objectweb.openccm.pss.runtime.jdo.api.StorageHomeBase sh = null; 122 123 sh = (org.objectweb.openccm.pss.runtime.jdo.api.StorageHomeBase) get_storage_home(); 124 _pid = sh.create_pid( create_short_pid() ); 125 } 126 return _pid; 127 } 128 129 // ================================================================== 130 // 131 // Methods for org.objectweb.openccm.pss.runtime.jdo.api.StorageObject 132 // 133 // ================================================================== 134 135 } 136