KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > services > cache > PersistenceCacheable


1 /*
2  * ____.
3  * __/\ ______| |__/\. _______
4  * __ .____| | \ | +----+ \
5  * _______| /--| | | - \ _ | : - \_________
6  * \\______: :---| : : | : | \________>
7  * |__\---\_____________:______: :____|____:_____\
8  * /_____|
9  *
10  * . . . i n j a h i a w e t r u s t . . .
11  *
12  *
13  *
14  * ----- BEGIN LICENSE BLOCK -----
15  * Version: JCSL 1.0
16  *
17  * The contents of this file are subject to the Jahia Community Source License
18  * 1.0 or later (the "License"); you may not use this file except in
19  * compliance with the License. You may obtain a copy of the License at
20  * http://www.jahia.org/license
21  *
22  * Software distributed under the License is distributed on an "AS IS" basis,
23  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
24  * for the rights, obligations and limitations governing use of the contents
25  * of the file. The Original and Upgraded Code is the Jahia CMS and Portal
26  * Server. The developer of the Original and Upgraded Code is JAHIA Ltd. JAHIA
27  * Ltd. owns the copyrights in the portions it created. All Rights Reserved.
28  *
29  * The Developer of the Shared Modifications is Jahia Solution Sarl.
30  * Portions created by the Initial Developer are Copyright (C) 2002 by the
31  * Initial Developer. All Rights Reserved.
32  *
33  * Contributor(s):
34  * 11-SEP-2003, Jahia Solutions Sarl, Serge Huber : Initial version
35  * 12-SEP-2003, Jahia Solutions Sarl, Fulco Houkes
36  *
37  * ----- END LICENSE BLOCK -----
38  */

39
40 package org.jahia.services.cache;
41
42 import org.jahia.exceptions.JahiaPersistenceException;
43
44 /**
45  * <p>Interface that defines loads and set to and from a persistence
46  * store. To be used in conjunction with the PersistenceCache implementation.</p>
47  * <p>The methods defined in the interface will be used by the
48  * PersistenceCache implementation to handle all loads and puts to and from
49  * the persistence store.</p>
50  *
51  * @author Serge Huber, Copyright (c) 2003 by Jahia Ltd.
52  * @author Fulco Houkes, Copyright (c) 2003 by Jahia Ltd.
53  * @since Jahia 4.0
54  */

55
56 public interface PersistenceCacheable {
57
58     /**
59      * This method must be implemented by a class that uses the PersistenceCache
60      * implementation to retrieve data from the persistence store.
61      * @param key the key for the object to retrieve. This is the same key as
62      * what is used to store the data in the Cache.
63      * @return an Object loaded from the persistence store, or null if the
64      * object does not exist. The null value is important because it will be
65      * used to mark the cache, telling it that this entry does not exist.
66      *
67      * @throws JahiaPersistenceException
68      * when any persistence error occured.
69      */

70     public Object JavaDoc getFromPersistence (Object JavaDoc key)
71             throws JahiaPersistenceException;
72
73
74     /**
75      * This method must be implemented by a class that uses the PersistenceCache
76      * implementation to store data into the persistence store.
77      *
78      * @param key the same key as what will be used to store the value object
79      * into the Cache.
80      * @param value the value object for the cache entry that will be stored
81      * in the persistence cache.
82      * @param newKey is set to true if this key is a new key in the cache,
83      * probably meaning that this object has never been sent to persistence
84      * before.
85      *
86      * @return <code>true</code> on success, or <code>false</code> when
87      * <code>key</code> and/or <code>value</code> is/are <code>null</code>.
88      *
89      * @throws JahiaPersistenceException
90      * when any persistence error occured.
91      */

92     public boolean setToPersistence (Object JavaDoc key, Object JavaDoc value, boolean newKey)
93             throws JahiaPersistenceException;
94
95
96     /**
97      * This method must be implemented by a class that uses the PersistenceCache
98      * implementation to update data into the persistence store.
99      *
100      * @param key the same key as what will be used to store the value object
101      * into the Cache.
102      * @param value the value object for the cache entry that will be stored
103      * in the persistence cache.
104      *
105      * @return <code>true</code> on success, or <code>false</code> when
106      * <code>key</code> and/or <code>value</code> is/are <code>null</code>.
107      *
108      * @throws JahiaPersistenceException
109      * when any persistence error occured.
110      */

111     public boolean updateToPersistence (Object JavaDoc key, Object JavaDoc value)
112             throws JahiaPersistenceException;
113
114
115     /**
116      * This method must be implemented by a class that uses the PersistenceCache
117      * implementation to remove data from the persistence store.
118      * @param key the key for the object to remove. This is the same key as
119      * what is used to store the data in the Cache.
120      *
121      * @return <code>true</code> on success, or <code>false</code> when
122      * <code>key</code> is <code>null</code>.
123      *
124      * @throws JahiaPersistenceException
125      * when any persistence error occured.
126      */

127     public boolean removeFromPersistence (Object JavaDoc key)
128             throws JahiaPersistenceException;
129 }
Popular Tags