//# 0 errors, 130 messages
//#
/*
    //#newsfeedcontextlistener.java:1:1: class: net.sourceforge.pebble.aggregator.NewsFeedContextListener$1
    //#newsfeedcontextlistener.java:1:1: method: net.sourceforge.pebble.aggregator.NewsFeedContextListener$1.net.sourceforge.pebble.aggregator.NewsFeedContextListener$1__static_init
    //#newsfeedcontextlistener.java:1:1: class: net.sourceforge.pebble.aggregator.NewsFeedContextListener
    //#newsfeedcontextlistener.java:1: method: void net.sourceforge.pebble.aggregator.NewsFeedContextListener$1.net.sourceforge.pebble.aggregator.NewsFeedContextListener$1(NewsFeedContextListener)
    //#input(void net.sourceforge.pebble.aggregator.NewsFeedContextListener$1(NewsFeedContextListener)): Param_1
    //#input(void net.sourceforge.pebble.aggregator.NewsFeedContextListener$1(NewsFeedContextListener)): this
    //#output(void net.sourceforge.pebble.aggregator.NewsFeedContextListener$1(NewsFeedContextListener)): this.this$0
    //#post(void net.sourceforge.pebble.aggregator.NewsFeedContextListener$1(NewsFeedContextListener)): this.this$0 == Param_1
    //#post(void net.sourceforge.pebble.aggregator.NewsFeedContextListener$1(NewsFeedContextListener)): init'ed(this.this$0)
 * Copyright (c) 2003-2006, Simon Brown
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   - Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *
 *   - Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in
 *     the documentation and/or other materials provided with the
 *     distribution.
 *
 *   - Neither the name of Pebble nor the names of its contributors may
 *     be used to endorse or promote products derived from this software
 *     without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
package net.sourceforge.pebble.aggregator;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import javax.servlet.ServletContextListener;
import javax.servlet.ServletContextEvent;
import java.util.Timer;
import java.util.TimerTask;

/**
 * Manages a timer that regularly updates all news feeds that have been
 * subscribed to.
 *
 * @author    Simon Brown
 */
public class NewsFeedContextListener implements ServletContextListener {
    //#newsfeedcontextlistener.java:48: method: void net.sourceforge.pebble.aggregator.NewsFeedContextListener.net.sourceforge.pebble.aggregator.NewsFeedContextListener()
    //#newsfeedcontextlistener.java:48: end of method: void net.sourceforge.pebble.aggregator.NewsFeedContextListener.net.sourceforge.pebble.aggregator.NewsFeedContextListener()

  private static final long ONE_MINUTE = 1000 * 60;
  private static final Log log = LogFactory.getLog(NewsFeedContextListener.class);
    //#newsfeedcontextlistener.java:51: method: net.sourceforge.pebble.aggregator.NewsFeedContextListener.net.sourceforge.pebble.aggregator.NewsFeedContextListener__static_init
    //#newsfeedcontextlistener.java:51: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.aggregator.NewsFeedContextListener
    //#    method: net.sourceforge.pebble.aggregator.NewsFeedContextListener__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#output(net.sourceforge.pebble.aggregator.NewsFeedContextListener__static_init): __Descendant_Table[net/sourceforge/pebble/aggregator/NewsFeedContextListener]
    //#output(net.sourceforge.pebble.aggregator.NewsFeedContextListener__static_init): __Dispatch_Table.contextDestroyed(Ljavax/servlet/ServletContextEvent;)V
    //#output(net.sourceforge.pebble.aggregator.NewsFeedContextListener__static_init): __Dispatch_Table.contextInitialized(Ljavax/servlet/ServletContextEvent;)V
    //#output(net.sourceforge.pebble.aggregator.NewsFeedContextListener__static_init): log
    //#post(net.sourceforge.pebble.aggregator.NewsFeedContextListener__static_init): __Descendant_Table[net/sourceforge/pebble/aggregator/NewsFeedContextListener] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.aggregator.NewsFeedContextListener__static_init): __Dispatch_Table.contextDestroyed(Ljavax/servlet/ServletContextEvent;)V == &contextDestroyed
    //#post(net.sourceforge.pebble.aggregator.NewsFeedContextListener__static_init): __Dispatch_Table.contextInitialized(Ljavax/servlet/ServletContextEvent;)V == &contextInitialized
    //#post(net.sourceforge.pebble.aggregator.NewsFeedContextListener__static_init): init'ed(log)
    //#newsfeedcontextlistener.java:51: end of method: net.sourceforge.pebble.aggregator.NewsFeedContextListener.net.sourceforge.pebble.aggregator.NewsFeedContextListener__static_init
    //#newsfeedcontextlistener.java:51: method: Log net.sourceforge.pebble.aggregator.NewsFeedContextListener.access$0()
    //#input(Log access$0()): log
    //#output(Log access$0()): return_value
    //#post(Log access$0()): init'ed(return_value)
    //#newsfeedcontextlistener.java:51: end of method: Log net.sourceforge.pebble.aggregator.NewsFeedContextListener.access$0()

  private Timer timer;

  public void contextInitialized(ServletContextEvent servletContextEvent) {
    log.info("Starting newsfeed updater");
    //#newsfeedcontextlistener.java:56: method: void net.sourceforge.pebble.aggregator.NewsFeedContextListener.contextInitialized(ServletContextEvent)
    //#newsfeedcontextlistener.java:56: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:info(Object)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.aggregator.NewsFeedContextListener
    //#    method: void contextInitialized(ServletContextEvent)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:info(Object)
    //#input(void contextInitialized(ServletContextEvent)): log
    //#input(void contextInitialized(ServletContextEvent)): this
    //#output(void contextInitialized(ServletContextEvent)): new Timer(contextInitialized#1) num objects
    //#output(void contextInitialized(ServletContextEvent)): this.timer
    //#new obj(void contextInitialized(ServletContextEvent)): new Timer(contextInitialized#1)
    //#presumption(void contextInitialized(ServletContextEvent)): org.apache.commons.logging.LogFactory:getLog(...)@51 != null
    //#post(void contextInitialized(ServletContextEvent)): this.timer == &new Timer(contextInitialized#1)
    //#post(void contextInitialized(ServletContextEvent)): new Timer(contextInitialized#1) num objects == 1
    //#unanalyzed(void contextInitialized(ServletContextEvent)): Effects-of-calling:java.util.TimerTask
    timer = new Timer();
    timer.scheduleAtFixedRate(new TimerTask() {
    //#newsfeedcontextlistener.java:58: end of method: void net.sourceforge.pebble.aggregator.NewsFeedContextListener$1.net.sourceforge.pebble.aggregator.NewsFeedContextListener$1(NewsFeedContextListener)
      public void run() {
        try {
          NewsFeedCache.getInstance().refreshFeeds();
    //#newsfeedcontextlistener.java:61: method: void net.sourceforge.pebble.aggregator.NewsFeedContextListener$1.run()
    //#input(void run()): net.sourceforge.pebble.aggregator.NewsFeedCache__static_init.new NewsFeedCache(NewsFeedCache__static_init#1).__Tag
    //#input(void run()): net.sourceforge.pebble.aggregator.NewsFeedCache__static_init.new NewsFeedCache(NewsFeedCache__static_init#1).entries
    //#input(void run()): net.sourceforge.pebble.aggregator.NewsFeedCache__static_init.new NewsFeedCache(NewsFeedCache__static_init#1).feeds
    //#input(void run()): net.sourceforge.pebble.aggregator.NewsFeedCache__static_init.new NewsFeedCache(NewsFeedCache__static_init#1).subscriptions
    //#input(void run()): net/sourceforge/pebble/aggregator/NewsFeed.__Descendant_Table[net/sourceforge/pebble/aggregator/NewsFeed]
    //#input(void run()): net/sourceforge/pebble/aggregator/NewsFeed.__Descendant_Table[others]
    //#input(void run()): net/sourceforge/pebble/aggregator/NewsFeed.__Dispatch_Table.add(Lnet/sourceforge/pebble/aggregator/NewsFeedEntry;)V
    //#input(void run()): net/sourceforge/pebble/aggregator/NewsFeed.__Dispatch_Table.getEntries()Ljava/util/List;
    //#input(void run()): net/sourceforge/pebble/aggregator/NewsFeed.__Dispatch_Table.setLink(Ljava/lang/String;)V
    //#input(void run()): net/sourceforge/pebble/aggregator/NewsFeed.__Dispatch_Table.setTitle(Ljava/lang/String;)V
    //#input(void run()): net/sourceforge/pebble/aggregator/NewsFeedCache.__Descendant_Table[net/sourceforge/pebble/aggregator/NewsFeedCache]
    //#input(void run()): net/sourceforge/pebble/aggregator/NewsFeedCache.__Dispatch_Table.refreshFeeds()V
    //#input(void run()): net/sourceforge/pebble/aggregator/NewsFeedCache.instance
    //#input(void run()): net/sourceforge/pebble/aggregator/NewsFeedCache.log
    //#input(void run()): net/sourceforge/pebble/aggregator/NewsFeedContextListener.log
    //#input(void run()): net/sourceforge/pebble/aggregator/NewsFeedEntry.__Descendant_Table[net/sourceforge/pebble/aggregator/NewsFeedEntry]
    //#input(void run()): net/sourceforge/pebble/aggregator/NewsFeedEntry.__Descendant_Table[others]
    //#input(void run()): net/sourceforge/pebble/aggregator/NewsFeedEntry.__Dispatch_Table.setFeed(Lnet/sourceforge/pebble/aggregator/NewsFeed;)V
    //#presumption(void run()): org.apache.commons.logging.LogFactory:getLog(...)@51 != null
    //#unanalyzed(void run()): Effects-of-calling:java.util.Map:get
    //#unanalyzed(void run()): Effects-of-calling:java.util.HashSet
    //#unanalyzed(void run()): Effects-of-calling:java.util.Map:put
    //#unanalyzed(void run()): Effects-of-calling:java.util.LinkedList
    //#unanalyzed(void run()): Effects-of-calling:java.util.Map:keySet
    //#unanalyzed(void run()): Effects-of-calling:java.util.Set:iterator
    //#unanalyzed(void run()): Effects-of-calling:java.util.Iterator:hasNext
    //#unanalyzed(void run()): Effects-of-calling:java.util.Iterator:next
    //#unanalyzed(void run()): Effects-of-calling:updateFeed
    //#unanalyzed(void run()): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(void run()): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(void run()): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(void run()): Effects-of-calling:org.apache.commons.logging.Log:warn
    //#unanalyzed(void run()): Effects-of-calling:java.util.List:addAll
    //#unanalyzed(void run()): Effects-of-calling:java.util.Collections:sort
    //#unanalyzed(void run()): Effects-of-calling:java.util.List:size
    //#unanalyzed(void run()): Effects-of-calling:java.util.List:subList
    //#unanalyzed(void run()): Effects-of-calling:java.lang.System:currentTimeMillis
    //#unanalyzed(void run()): Effects-of-calling:org.apache.commons.logging.Log:debug
    //#unanalyzed(void run()): Effects-of-calling:com.sun.syndication.io.WireFeedInput
    //#unanalyzed(void run()): Effects-of-calling:java.net.URL
    //#unanalyzed(void run()): Effects-of-calling:com.sun.syndication.io.XmlReader
    //#unanalyzed(void run()): Effects-of-calling:com.sun.syndication.io.WireFeedInput:build
    //#unanalyzed(void run()): Effects-of-calling:com.sun.syndication.feed.WireFeed:getFeedType
    //#unanalyzed(void run()): Effects-of-calling:java.lang.String:startsWith
    //#unanalyzed(void run()): Effects-of-calling:com.sun.syndication.feed.rss.Channel:getTitle
    //#unanalyzed(void run()): Effects-of-calling:com.sun.syndication.feed.rss.Channel:getLink
    //#unanalyzed(void run()): Effects-of-calling:com.sun.syndication.feed.rss.Channel:getItems
    //#unanalyzed(void run()): Effects-of-calling:java.util.List:iterator
    //#unanalyzed(void run()): Effects-of-calling:com.sun.syndication.feed.rss.Item:getLink
    //#unanalyzed(void run()): Effects-of-calling:com.sun.syndication.feed.rss.Item:getTitle
    //#unanalyzed(void run()): Effects-of-calling:com.sun.syndication.feed.rss.Item:getDescription
    //#unanalyzed(void run()): Effects-of-calling:com.sun.syndication.feed.rss.Description:getValue
    //#unanalyzed(void run()): Effects-of-calling:com.sun.syndication.feed.rss.Item:getAuthor
    //#unanalyzed(void run()): Effects-of-calling:com.sun.syndication.feed.rss.Item:getPubDate
    //#unanalyzed(void run()): Effects-of-calling:java.util.List:contains
    //#unanalyzed(void run()): Effects-of-calling:java.util.List:add
    //#unanalyzed(void run()): Effects-of-calling:com.sun.syndication.feed.atom.Feed:getTitle
    //#unanalyzed(void run()): Effects-of-calling:com.sun.syndication.feed.atom.Feed:getAlternateLinks
    //#unanalyzed(void run()): Effects-of-calling:com.sun.syndication.feed.atom.Link:getType
    //#unanalyzed(void run()): Effects-of-calling:java.lang.String:equals
    //#unanalyzed(void run()): Effects-of-calling:com.sun.syndication.feed.atom.Link:getHref
    //#unanalyzed(void run()): Effects-of-calling:com.sun.syndication.feed.atom.Feed:getEntries
    //#unanalyzed(void run()): Effects-of-calling:com.sun.syndication.feed.atom.Entry:getAlternateLinks
    //#unanalyzed(void run()): Effects-of-calling:com.sun.syndication.feed.atom.Entry:getContents
    //#unanalyzed(void run()): Effects-of-calling:com.sun.syndication.feed.atom.Content:getType
    //#unanalyzed(void run()): Effects-of-calling:com.sun.syndication.feed.atom.Content:getValue
    //#unanalyzed(void run()): Effects-of-calling:com.sun.syndication.feed.atom.Entry:getSummary
    //#unanalyzed(void run()): Effects-of-calling:com.sun.syndication.feed.atom.Entry:getAuthors
    //#unanalyzed(void run()): Effects-of-calling:java.util.List:get
    //#unanalyzed(void run()): Effects-of-calling:java.lang.Object:toString
    //#unanalyzed(void run()): Effects-of-calling:com.sun.syndication.feed.atom.Entry:getTitle
    //#unanalyzed(void run()): Effects-of-calling:com.sun.syndication.feed.atom.Entry:getPublished
        } catch (Exception e) {
          log.error("Error while refreshing feeds " + e.getMessage());
    //#newsfeedcontextlistener.java:63: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:error(Object)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.aggregator.NewsFeedContextListener$1
    //#    method: void run()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:error(Object)
          e.printStackTrace();
        }
      }
    //#newsfeedcontextlistener.java:66: end of method: void net.sourceforge.pebble.aggregator.NewsFeedContextListener$1.run()
    }, 0, ONE_MINUTE * 15);
  }
    //#newsfeedcontextlistener.java:68: end of method: void net.sourceforge.pebble.aggregator.NewsFeedContextListener.contextInitialized(ServletContextEvent)

  public void contextDestroyed(ServletContextEvent servletContextEvent) {
    log.info("Stopping newsfeed updater");
    //#newsfeedcontextlistener.java:71: method: void net.sourceforge.pebble.aggregator.NewsFeedContextListener.contextDestroyed(ServletContextEvent)
    //#newsfeedcontextlistener.java:71: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:info(Object)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.aggregator.NewsFeedContextListener
    //#    method: void contextDestroyed(ServletContextEvent)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:info(Object)
    //#input(void contextDestroyed(ServletContextEvent)): log
    //#input(void contextDestroyed(ServletContextEvent)): this
    //#input(void contextDestroyed(ServletContextEvent)): this.timer
    //#pre[2] (void contextDestroyed(ServletContextEvent)): this.timer != null
    //#presumption(void contextDestroyed(ServletContextEvent)): org.apache.commons.logging.LogFactory:getLog(...)@51 != null
    timer.cancel();
  }
    //#newsfeedcontextlistener.java:73: end of method: void net.sourceforge.pebble.aggregator.NewsFeedContextListener.contextDestroyed(ServletContextEvent)

}
    //#output(net.sourceforge.pebble.aggregator.NewsFeedContextListener$1__static_init): __Descendant_Table[net/sourceforge/pebble/aggregator/NewsFeedContextListener$1]
    //#output(net.sourceforge.pebble.aggregator.NewsFeedContextListener$1__static_init): __Dispatch_Table.run()V
    //#post(net.sourceforge.pebble.aggregator.NewsFeedContextListener$1__static_init): __Descendant_Table[net/sourceforge/pebble/aggregator/NewsFeedContextListener$1] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.aggregator.NewsFeedContextListener$1__static_init): __Dispatch_Table.run()V == &run
    //#newsfeedcontextlistener.java:: end of method: net.sourceforge.pebble.aggregator.NewsFeedContextListener$1.net.sourceforge.pebble.aggregator.NewsFeedContextListener$1__static_init
    //#newsfeedcontextlistener.java:: end of class: net.sourceforge.pebble.aggregator.NewsFeedContextListener$1
    //#newsfeedcontextlistener.java:: end of class: net.sourceforge.pebble.aggregator.NewsFeedContextListener
