1
|
/**
|
2
|
* Copyright (C) 2015 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.model;
|
10
|
|
11
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
12
|
import eu.etaxonomy.cdm.model.term.DefinedTermBase;
|
13
|
|
14
|
/**
|
15
|
* @author cmathew
|
16
|
* @since 19 Feb 2015
|
17
|
*/
|
18
|
public interface ICdmCacher {
|
19
|
|
20
|
/**
|
21
|
* Retrieves the cached version of the passed entity from the cache if it
|
22
|
* exists in there.
|
23
|
*
|
24
|
* @param cdmBase
|
25
|
* the cdm entity to find in the cache
|
26
|
*
|
27
|
* @return the cached version of the passed entity or <code>null</code>
|
28
|
*/
|
29
|
public <T extends CdmBase> T getFromCache(T cdmBase);
|
30
|
|
31
|
/**
|
32
|
* Puts the passed <code>cdmEntity</code> into the cache as long it does not
|
33
|
* yet exist in the cache.
|
34
|
*
|
35
|
* @param cdmEntity
|
36
|
*/
|
37
|
public void putToCache(CdmBase cdmEntity);
|
38
|
|
39
|
/**
|
40
|
* Load into the cache and return the entity from the cache. The entity
|
41
|
* might already exist in the cache. In this case the entity in the cache might
|
42
|
* get updated whereas the returned entity represents the entity from the
|
43
|
* cache not the <code>cdmEntity</code> passed to this method.
|
44
|
*
|
45
|
* @param cdmEntity
|
46
|
* @return
|
47
|
*/
|
48
|
public <T extends CdmBase> T load(T cdmEntity);
|
49
|
|
50
|
/**
|
51
|
*
|
52
|
* @param cdmEntity
|
53
|
* @return returns true if the <code>cdmEntity</code> is cachable by the
|
54
|
* implementation
|
55
|
*/
|
56
|
public boolean isCachable(CdmBase cdmEntity);
|
57
|
|
58
|
/**
|
59
|
* @param cdmBase
|
60
|
* @return returns true if the <code>cdmEntity</code> is found in the cache
|
61
|
*/
|
62
|
public boolean exists(CdmBase cdmBase);
|
63
|
|
64
|
public void dispose();
|
65
|
|
66
|
/**
|
67
|
* For certain entities like {@link DefinedTermBase defined terms} some
|
68
|
* caches do want to stop recursive loading. In this case this method
|
69
|
* should return <code>true</code>, <code>false</code> otherwise.
|
70
|
*/
|
71
|
public boolean ignoreRecursiveLoad(CdmBase cdmBase);
|
72
|
|
73
|
}
|