model.java

来自「一个非常好的FRAMWRK!是一个外国组织做的!不!」· Java 代码 · 共 92 行

JAVA
92
字号
/**
 * Copyright 2003-2005 the original author or authors.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.jdon.controller.model;

import java.io.*;
import com.jdon.controller.cache.Cacheable;

/**
 * Base domain model it can be DTO or nested Model. it is the important message
 * between business layer and view layer. in view layer, it is created by form
 * object(such as ActionForm object);in business layer, it is created by
 * business components(such as session bean).
 * 
 * thi class can be cached, and setModified is important, this method can be
 * used to refresh the cache.
 * 
 * because setModified function ,so the class is designed for a class, but not a
 * interface.
 * 
 * the difference with setModified and setCacheable;
 * setCacheable to false, the model will never exist in the cache.
 * setModified to true, if the model exists in the cache, the client will not 
 * get it from cache, it is same as being deleted from cache .
 * deleting the model from cache must have a condition that the deleting operator
 * can access the cache of the container, if it cann't access the container, 
 * it cann't delete the model from cache. such it is EJB. 
 * 
 * 
 * 
 * @author banq
 */
public abstract class Model implements Cacheable, Cloneable, Serializable {

    /**
     * if set false, this Model will not be saved to cache, so 
     * this model will not be got from the cache.
     */
    private boolean cacheable = true;

    /**
     * if set true, this model will not be got from the cache,  
     * because it must have been saved in the cache.
     * this function is same as deleting the model from the cache.
     */
    private boolean modified;

    /**
     * in the past version, this method name is isCacheble,
     * now change it after 1.3 !
     */
    public boolean isCacheable() {
        return cacheable;
    }

    /**
     * in the past version, this method name is setCacheble,
     * now change it  after 1.3 !
     */
    public void setCacheable(boolean cacheable) {
        this.cacheable = cacheable;
    }

    public boolean isModified() {
        return modified;
    }

    /**
     * set the property has been modified such as : setName(String name){
     * this.name = name; setModified(true); }
     * 
     * @param modified
     *            boolean
     */
    public void setModified(boolean modified) {
        this.modified = modified;
    }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?