【原】RSS工具开发手记(06)---Informa的impl.basic包

【原】RSS工具开发手记(06)---Informa的impl.basic包
在impl.basic包下,还有一个和Channel类息息相关的类:ChannelBuilder类,它负责直接构建Channel对象。其责职就是工厂模式中的工厂。

在ChannelBuilder下有几种类型的方法:
 ★构造方法和初始化方法:即创建Channel对象的方法及初始化的方法
 ★元素构建方法:即构建Channel子元素的方法
 ★事务控制方法:即控制构建,析构过程的方法

下面说一下第一类方法,Informa的ChannelBuilder构造方法比较奇怪:
     /** */ /**
     * Do nothing but only return null
     
*/

    
public  ChannelIF createChannel(String title, String location)  {
        
// TODO Auto-generated method stub
        return null;
    }


    
/** */ /**
     * Do nothing but only return null
     
*/

    
public  ChannelIF createChannel(Element channelElement, String title,
            String location) 
{
        
// TODO Auto-generated method stub
        return null;
    }


    
public  ChannelIF createChannel(String title)  {
        
return new Channel(title);
    }


    
public  ChannelIF createChannel(Element channelElement, String title)  {
        
return new Channel(channelElement, title);
    }

根据RSS 2.0规范,一个Channel有3个必选元素:title, link, description。实在不明白为什么在Informa的实现中为什么对第一个,第二个方法直接返回null,而且不给出任何提示?从代码的注释来看应该是靠IDE自动生成的,可能作者忘了实现。开源软件啊~~~,有时真的不知道怎么说好!

第二类方法方法是元素构造方法,这包括了一系列以createXxx形式的方法:


第三类方法就是事务控制方法,Informa中对于basic并没有提供真正的事务控制实现,它明确告诉我们“The following methods are only meaningful for persistent informa back end implementations such as Hibernate and are no-ops otherwise.”。也就是这些方法只在Informa使用Hibernate进行后端持久化时才有意义。对于其它情况下来说只是一个“no-ops”:停止操作命令。


-------------------------------------------------------------
生活就像打牌,不是要抓一手好牌,而是要尽力打好一手烂牌。

你可能感兴趣的:(【原】RSS工具开发手记(06)---Informa的impl.basic包)