title: JSF receiving FacesContext outside request
body: <p>As far as i know, FacesContext is avalible only in request scope. I've created a thread that tries to receive instance of FacesContext, but it is returning null.</p>
  
  <p>My point is to update some application-scoped beans every 10 seconds.</p>
  
  <p>Thread's run method:</p>
  
  <pre><code>@Override
  public void run()
  {
      while (true)
      {
          try
          {
              TimeView timeView = (TimeView)FacesContext.getCurrentInstance().
                      getExternalContext().getApplicationMap().get("timeView"); 
              // FacesContext.getCurrentInstalce() returns null
  
              timeView.update();
              Thread.sleep(10000);
          }
          catch (InterruptedException ex)
          {
              System.out.println(ex);
          }
      }
  }
  </code></pre>
  
  <p>TimeView's header (I've skipped getters/setters):</p>
  
  <pre><code>@ManagedBean(eager=true, name="timeView")
  @ApplicationScoped
  public class TimeView implements Serializable
  {
      private int hour;
      private int minutes;
      private int seconds;
  
      public TimeView()
      {
          update();
      }
  
      public void update()
      {
          Date date = new Date();
          setHour(date.getHours());
          setMinutes(date.getMinutes());
          setSeconds(date.getSeconds());
      }
  </code></pre>
  
  <p>faces-config.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;faces-config
      xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
      http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
      version="2.0"&gt;
  
      &lt;managed-bean&gt;
          &lt;managed-bean-name&gt;timeView&lt;/managed-bean-name&gt;
          &lt;managed-bean-class&gt;foogame.viewBeans.TimeView&lt;/managed-bean-class&gt;
          &lt;managed-bean-scope&gt;application&lt;/managed-bean-scope&gt;
      &lt;/managed-bean&gt;
  &lt;/faces-config&gt;
  </code></pre>
  
  <p>So, is there a way to receive refference to my application-scoped beans in this thread?</p>