/*
* Created on Jun 5, 2003
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package org.xdev.base.core;
/**
* @author AYegorov
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
import org.xdev.base.core.*;
import org.xdev.base.core.object.*;
import org.xdev.base.log.LoggerWriter;
import org.xdev.base.xssl.XSSLAction;
import org.xdev.base.xssl.XSSLComponent;
import java.util.*;
import org.apache.log4j.Level;
public abstract class AbstractPersistance extends Configuration {
protected XSSLAction template = null;
protected boolean overwrite = true;
protected List constants = new ArrayList();
public AbstractPersistance(String id, HashMap properties) {
super(id, properties);
}
public void storeObject(String id, Object obj) {
boolean found = this.exists(id);
this.logDebug("Variable "+id+" is already declared: "+found);
this.logDebug("Variable overwrite is active: "+this.doOverwrite());
this.logDebug("Variable "+id+" will be overwritten: "+(found && this.doOverwrite()));
if (!this.constants.contains(id) && (found && this.doOverwrite()) || !found) {
try {
this.store(id, obj);
this.logDebug("Variable "+id+" has been assigned value "+obj);
}catch(Exception ex) {
this.logError(ex);
}
}
}
public void addConstant(String id) {
synchronized(this.constants) {
this.constants.add(id);
}
}
public boolean isConstant(String id) {
return this.constants.contains(id);
}
protected abstract void store(String id, Object obj) throws Exception;
public abstract boolean exists(String id);
public abstract Object get(String id);
public abstract Object remove(String id);
public void setOverwrite(boolean flag) {
this.overwrite = flag;
}
public boolean doOverwrite() {
return this.overwrite;
}
}
|