*/
public static Channel fetchChannel(int type, String url){
//get from the cache
if(channels!=null){
try {
Element channel = channels.get(url);
if(channel!=null)
return (Channel)channel.getValue();
} catch (IllegalStateException e) {
//occur when this element is expire
} catch (CacheException e) {
log.error("Exception occurred when get from cache "+url, e);
}
}
//fetch from http directly
try {
Channel channel = fetchChannelViaHTTP(url);
if(channels!=null && channel!=null){
channels.put(new Element(url, channel));
}
return channel;
} catch (Exception e) {
log.error("Exception occurred when fetch "+url, e);
}