PropertySet教程 2.Memory、map、XML方式
inkfish原创,请勿商业性质转载,转载请注明来源(http://blog.csdn.net/inkfish
)。
PropertySet(来源:http://blog.csdn.net/inkfish)
是由opensymphony组织开发的的一个开源项目,但是那个项目文档少,长时间没有更新,官方文档错误奇多,所以现在在项目中使用并不广泛。但这并不妨碍PropertySet成为一个优秀的key-value持久化模块,当前,PropertySet可以说已经够用。这里我整理书写了PropertySet的文档。(来源:http://blog.csdn.net/inkfish)
PropertySet最容易使用和上手的是memory方式,最常用的是xml、JDBC,另外Hibernate、EJB是较常用的方式。这里选择介绍memory、map、XML方式。(来源:http://blog.csdn.net/inkfish)
1.Demo
PropertySetDemo.java
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.HashMap;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import com.opensymphony.module.propertyset.PropertySet;
import com.opensymphony.module.propertyset.PropertySetManager;
import com.opensymphony.module.propertyset.xml.XMLPropertySet;
public class PropertySetDemo {
public static void main(String[] args) throws Exception {
PropertySetDemo demo = new PropertySetDemo();
demo.mapPsDemo();
demo.memoryPsDemo();
demo.xmlPsDemo();
}
public void memoryPsDemo() {
System.out.println(StringUtils.center("Memory PropertySet Demo", 80, '*'));
//memory是配置文件中定义的:<propertyset name="memory" class="com.opensymphony.module.propertyset.memory.MemoryPropertySet"/>
PropertySet ps = PropertySetManager.getInstance("memory", null);
ps.setBoolean("BooleanPS", true);
ps.setString("name", "Tom");
System.out.println(ps.getBoolean("BooleanPS"));
System.out.println(ps.getString("name"));
System.out.println(StringUtils.repeat("*", 80));
}
public void mapPsDemo() {
System.out.println(StringUtils.center("Map PropertySet Demo", 80, '*'));
@Sup
相关文档:
/// <summary>
/// 读取数据集并加入缓存
/// sea 2009-12-11
/// </summary>
&nb ......
protected void Button1_Click(object sender, EventArgs e)
{
//为response(star)节点 和 Cabins(f) cabin节点分别添加个
&nbs ......
Caused by: java.sql.SQLException: ORA-00918: column ambiguously defined
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/ibatis/jpetstore/persistence/sqlmapdao/sql/Item.xml.
--- The error occurred while applying a parameter map.&nbs ......
/* Author: 杨宇 yangyu@sina.cn */
/*
用法示例:
$cls_xml = new cls_xml();
if ($array){
$cls_xml->array2xml($array);
echo $cls_xml->getXml();
}else{
echo '';
}
*/
class cls_xml{
var $xml;
&nbs ......
DECLARE @XMLdoc XML
SET @XMLdoc =
'<Book name="SQL Server 2000 Fast Answers">
<Chapters>
<Chapter id="1" name="Installation, Upgrades">
<CreateDate>2009-12-30</CreateDate>
</Chapter>
<Chapter id="2" name="Configuring SQL Server"/>
<Chapter i ......