3.2TransfileClient.Java
用dom4jSAX解析器将config.XML读入内存,遍历文档,查找启用上传标志的directoryupload和fileupload节点,并将其作为参数调用配置中所指明的上传周期类(Everyday)进行下一步处理:
List list=document.selectNodes("//runflag");//引号中为XPath语言
Iterator iter=list.iterator();
while(iter.hasNext())
{
Element runelement=(Element)iter.next();
Attribute attribute;
Irunfrequency runfrequency=null;
if(runelement.getTextTrim().equals("0"))
{
Element runtrategy;
runtrategy=runelement.getParent().element("runtrategy"); if(runtrategy.attributeValue("runfrequency").equalsIgnoreCase("everyday"))
{
if(runelement.getParent().getName().equalsIgnoreCase("directoryupload"))
{
upload=new DirUpload(runelement.getParent());
}else if(runelement.getParent().getName().equalsIgnoreCase("fileupload"))
{
upload=new FileUpload(runelement.getParent());
}
runfrequency=new Everyday();
}
runfrequency.dojudge(runelement, runtrategy, hour, minute,upload);
}
}
3.3 Everyday.Java
判断设置的上传时间(精确到分钟)是否和系统当前时间匹配,是则置正在上传标志,同时创建上传处理线程:
list1=runtrategy.selectNodes("./time");
iter1=list1.iterator();
while(iter1.hasNext())
{
|