1 /* 2 * Enhydra Java Application Server Project 3 * 4 * The contents of this file are subject to the Enhydra Public License 5 * Version 1.1 (the "License"); you may not use this file except in 6 * compliance with the License. You may obtain a copy of the License on 7 * the Enhydra web site ( http://www.enhydra.org/ ). 8 * 9 * Software distributed under the License is distributed on an "AS IS" 10 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 11 * the License for the specific terms governing rights and limitations 12 * under the License. 13 * 14 * The Initial Developer of the Enhydra Application Server is Lutris 15 * Technologies, Inc. The Enhydra Application Server and portions created 16 * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc. 17 * All Rights Reserved. 18 * 19 */ 20 package org.enhydra.dods.cache; 21 22 import java.util.Map; 23 import org.enhydra.dods.cache.ConfigurationAdministration; 24 import com.lutris.dods.builder.generator.dataobject.GenericDO; 25 import org.enhydra.dods.exceptions.CacheObjectException; 26 27 /** 28 * This abstract class contains data and mechanisms needed for caching data 29 * objects (or DataStruct objects) by their OIDs and provides cache 30 * configuration and administration. 31 * 32 * @author Tanja Jovanovic 33 * @author Sinisa Milosevic 34 * @version 1.0 05.08.2003. 35 * 36 */ 37 public abstract class DOCache extends ConfigurationAdministration { 38 39 /** 40 * Creates DOCache instance. 41 * 42 * @return created data cache instance (for storing data (or DataStruct) 43 * objects. 44 */ 45 public abstract DOCache newInstance() throws CacheObjectException; 46 47 /** 48 * Returns cache (data or DataStruct) content. 49 * 50 * @return Cache content as <code>Map</code> of data objects (or DataStruct 51 * objects). 52 */ 53 public abstract Map getCacheContent(); 54 55 /** 56 * Returns information if multi databases are supported. 57 * 58 * @return true if multi databases are used, otherwise false. 59 */ 60 public abstract boolean isMulti(); 61 62 /** 63 * Checks wheather cache reconfiguration needs to be done. 64 * 65 * @return true if cache reconfiguration needs to be done, otherwise false. 66 */ 67 public abstract boolean toReconfigure(); 68 69 /** 70 * Adds DO (data object) to the cache. 71 * 72 * @param newDO Data object that will be added to the cache. 73 * 74 * @return Added data object. 75 */ 76 public abstract GenericDO addDO(GenericDO newDO); 77 78 /** 79 * Removes DO (data object) from the cache. 80 * 81 * @param DO Data object that will be removed from the cache. 82 * 83 * @return Removed data object, or <tt>null</tt> if there was no object 84 * removed from the cache. 85 */ 86 public abstract GenericDO removeDO(GenericDO DO); 87 88 /** 89 * Removes DO (data object) from the cache. 90 * 91 * @param handle Cache handle of DO (data object) that will be removed from 92 * the cache. The form of cache handle is: 93 * "<database_name>.<String_presentation_of_oid>". 94 * 95 * @return Removed data object, or <tt>null</tt> if there was no object 96 * removed from the cache. 97 */ 98 public abstract GenericDO removeDO(String handle); 99 100 /** 101 * Updates cached DO, or inserts DO in the cache if it didn't exist in the 102 * cache. 103 * 104 * @param DO Data object that will be updated (or inserted if didn't 105 * exist in the cache). 106 * 107 * @return Updated or inserted data object. 108 */ 109 public abstract GenericDO updateDO(GenericDO DO); 110 111 /** 112 * Deletes DO from the cache. 113 * 114 * @param DO Data object that will be deleted from the cache. 115 * 116 * @return Deleted data object, or <tt>null</tt> if there was no object 117 * deleted from the cache. 118 */ 119 public abstract GenericDO deleteDO(GenericDO DO); 120 121 /** 122 * Returns data object whose String representation of OID is parameter handle. 123 * 124 * @param handle String representation of OID of object that is being 125 * searched in the cache. 126 * 127 * @return Data object whose String representation of OID is handle. 128 */ 129 public abstract GenericDO getDOByHandle(String handle); 130 } 131