KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opencms > template > cache > CmsUriLocator


1 /*
2 * File : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/template/cache/CmsUriLocator.java,v $
3 * Date : $Date: 2005/05/17 13:47:27 $
4 * Version: $Revision: 1.1 $
5 *
6 * This library is part of OpenCms -
7 * the Open Source Content Mananagement System
8 *
9 * Copyright (C) 2001 The OpenCms Group
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * For further information about OpenCms, please see the
22 * OpenCms Website: http://www.opencms.org
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this library; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 */

28
29 package com.opencms.template.cache;
30
31 import java.util.Vector JavaDoc;
32
33 /**
34  * The UriLocator is used to receive CmsUri-Objects. It is the Cache for these
35  * CmsUri-Objects. The CmsUri-Objects are stored in memory or - if they are not
36  * used a long time written to an external database. The locator manages all the
37  * reading, writing and management of the CmsUri's.
38  *
39  * @author Andreas Schouten
40  *
41  * @deprecated Will not be supported past the OpenCms 6 release.
42  */

43 public class CmsUriLocator {
44
45     /**
46      * A hashtable to store the uri's.
47      */

48     private CmsLruCache m_uris;
49
50     /**
51      * The default constructor for this locator.
52      */

53     CmsUriLocator(int cacheSize) {
54         if(cacheSize < 2){
55             cacheSize = 10000;
56         }
57         m_uris = new CmsLruCache(cacheSize);
58     }
59
60     /**
61      * Adds a new Uri to this locator.
62      * @param descriptor - the UriDescriptor for this uri.
63      * @param uri - the Uri to put in this locator.
64      */

65     public void put(CmsUriDescriptor desc, CmsUri uri) {
66         m_uris.put(desc, uri);
67     }
68
69     /**
70      * Gets a uri from this locator.
71      * @param desc - the descriptor to locate the uri.
72      * @return the uri that was found.
73      */

74     public CmsUri get(CmsUriDescriptor desc) {
75         return (CmsUri) m_uris.get(desc);
76     }
77
78     /**
79      * Deletes all invalid uris from cache.
80      * @param invalidUris A Vector with the names of the uris (String) to be deleted from cache.
81      */

82     public void deleteUris(Vector JavaDoc invalidUris){
83         for (int i = 0; i < invalidUris.size(); i++){
84             m_uris.deleteUri((String JavaDoc)invalidUris.elementAt(i));
85         }
86     }
87
88     /**
89      * Clears the cache compleatly.
90      */

91     public void clearCache(){
92         m_uris.clearCache();
93     }
94
95     /**
96      * Gets the Information of max size and size for the cache.
97      *
98      * @return a Vector whith informations about the size of the cache.
99      */

100     public Vector JavaDoc getCacheInfo(){
101         return m_uris.getCacheInfo();
102     }
103
104 }
Popular Tags