📄 jahiaobject.java
字号:
// $Id: JahiaObject.java,v 1.2 2002/04/04 08:13:24 pmartin Exp $//// ____.// __/\ ______| |__/\. _______// __ .____| | \ | +----+ \// _______| /--| | | - \ _ | : - \_________// \\______: :---| : : | : | \________>// |__\---\_____________:______: :____|____:_____\// /_____|//// . . . i n j a h i a w e t r u s t . . .//package org.jahia.data;import org.jahia.utils.Semaphore;import org.jahia.exceptions.JahiaException;/** * The JahiaObject class is the root of all the jahia object. The purpose of * this class is to avoid access to any kind of object (pages, containers, * fields, users, ....) while they have already been removed from the * database.<br/> * <br/> * Java Virtual Machines do not destroy an object as long as a reference exists * on the object. Therefore, for example, when a two users access a page, they * get both a reference on the page. Now suppose the first user delete this page, * it will be removed from the database permanently. The second user is not * aware the page does not exist anymore, and can try to edit this page too.<br/> * <br/> * On the developper side, the page object still exist, but has no associated * entry(ies) in the database anymore. It might leave the database in an * unconsistent state if when an object is deleted, all the accesses to the * object are denied.<br/> * <br/> * This class help to avoid this issue. Each object in Jahia should derive * from this class and call the {@link #isObjectAlive() isObjectAlive()} * method to know if the access can be performed or not. Also when an object * is deleted, a call to {@link #killObject() killObject()} should be done * in order to block the object for further accesses. * * @author Fulco Houkes * @version 1.0; */public class JahiaObject{ private boolean mObjectIsDEAD; //------------------------------------------------------------------------- /** Default constructor */ public JahiaObject () { mObjectIsDEAD = false; } //------------------------------------------------------------------------- /** Block the object for all furter accesses. */ public synchronized void killObject () { mObjectIsDEAD = true; } //------------------------------------------------------------------------- /** Test if the object is still alive or has been deleted previously * * @exception JahiaException Throws this exception when the object was * previously deleted and is currently unavailable. */ public synchronized void isObjectAlive () throws JahiaException { if (mObjectIsDEAD) { throw new JahiaException ("Access to an unexisting object", "An attempt of accessing an in-delete-process-object occured", JahiaException.OBJECT_ERROR, JahiaException.ERROR); } }} // finish class JahiaObject
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -