KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jdon > controller > model > Model


1 /*
2  * Copyright 2003-2006 the original author or authors.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  *
15  */

16 package com.jdon.controller.model;
17
18
19 /**
20  * Base domain model it can be DTO or nested Model. it is the important message
21  * between business layer and view layer. in view layer, it is created by form
22  * object(such as ActionForm object);in business layer, it is created by
23  * business components(such as session bean).
24  *
25  * thi class can be cached, and setModified is important, this method can be
26  * used to refresh the cache.
27  *
28  * because setModified function ,so the class is designed for a class, but not a
29  * interface.
30  *
31  * the difference with setModified and setCacheable;
32  * setCacheable to false, the model will never exist in the cache.
33  * setModified to true, if the model exists in the cache, the client will not
34  * get it from cache, it is same as being deleted from cache .
35  * deleting the model from cache must have a condition that the deleting operator
36  * can access the cache of the container, if it cann't access the container,
37  * it cann't delete the model from cache. such it is EJB.
38  *
39  *
40  *
41  * @author banq
42  */

43 public class Model implements ModelIF{
44
45     /**
46      * if set false, this Model will not be saved to cache, so
47      * this model will not be got from the cache.
48      */

49     private boolean cacheable = true;
50
51     /**
52      * if set true, this model will not be got from the cache,
53      * because it must have been saved in the cache.
54      * this function is same as deleting the model from the cache.
55      */

56     private boolean modified;
57     
58
59     /**
60      * in the past version, this method name is isCacheble,
61      * now change it after 1.3 !
62      */

63     public boolean isCacheable() {
64         return cacheable;
65     }
66
67     /**
68      * in the past version, this method name is setCacheble,
69      * now change it after 1.3 !
70      */

71     public void setCacheable(boolean cacheable) {
72         this.cacheable = cacheable;
73     }
74
75     public boolean isModified() {
76         return modified;
77     }
78
79     /**
80      * set the property has been modified such as : setName(String name){
81      * this.name = name; setModified(true); }
82      */

83     public void setModified(boolean modified) {
84         this.modified = modified;
85     }
86     
87
88 }
89
Popular Tags