Package org.apache.wicket.util.time

Examples of org.apache.wicket.util.time.Duration


  {
    BufferedWebResponse result = null;
    Value value = (Value)super.get(key);
    if (value != null)
    {
      Duration elapsedTime = Time.now().subtract(value.creationTime);
      if (lifetime.greaterThan(elapsedTime))
      {
        result = value.response;
      }
      else
View Full Code Here


    private static final long serialVersionUID = 1L;

    @Override
    protected PageAccessSynchronizer createInstance()
    {
      final Duration timeout;
      if (Application.exists())
      {
        timeout = Application.get().getRequestCycleSettings().getTimeout();
      }
      else
View Full Code Here

   */
  public IModificationWatcher getResourceWatcher(boolean start)
  {
    if (resourceWatcher == null && start)
    {
      final Duration pollFrequency = getResourcePollFrequency();
      if (pollFrequency != null)
      {
        resourceWatcher = new ModificationWatcher(pollFrequency);
      }
    }
View Full Code Here

    Boolean booleanValue = true;
    Integer integerValue = 42;
    Long longValue = integerValue * 1L;
    Double doubleValue = integerValue * 1.0D;
    Time timeValue = Time.now();
    Duration durationValue = Duration.hours(1);

    boolean defBoolean = !booleanValue;
    int defInteger = 10101;
    long defLong = defInteger * 1L;
    double defDouble = defInteger * 1.0D;
    Time defTime = Time.now();
    Duration defDuration = Duration.hours(42);

    vm.put("num", integerValue.toString());
    vm.put("num.bad", "xxx");
    vm.put("time", timeValue.toString());
    vm.put("time.bad", "xxx");
View Full Code Here

   */
  @Test
  public void testReentrant() throws Exception
  {
    final PageAccessSynchronizer sync = new PageAccessSynchronizer(Duration.seconds(5));
    final Duration hold = Duration.seconds(1);
    sync.lockPage(0);
    sync.lockPage(0);
  }
View Full Code Here

   */
  @Test
  public void testBlocking() throws Exception
  {
    final PageAccessSynchronizer sync = new PageAccessSynchronizer(Duration.seconds(5));
    final Duration hold = Duration.seconds(1);
    final Time t1locks[] = new Time[1];
    final Time t2locks[] = new Time[1];

    class T1 extends Thread
    {
      @Override
      public void run()
      {
        sync.lockPage(1);
        t1locks[0] = Time.now();
        hold.sleep();
        sync.unlockAllPages();
      }
    }

    class T2 extends Thread
View Full Code Here

        sync.lockPage(5);
      }
    }

    // set up a synchronizer and lock page 5 with locker1
    final Duration timeout = Duration.seconds(30);
    final PageAccessSynchronizer sync = new PageAccessSynchronizer(timeout);
    Locker locker1 = new Locker(sync);

    final long start = System.currentTimeMillis();
    locker1.run();
View Full Code Here

   */
  public ModificationWatcher getResourceWatcher(boolean start)
  {
    if (resourceWatcher == null && start)
    {
      final Duration pollFrequency = getResourcePollFrequency();
      if (pollFrequency != null)
      {
        resourceWatcher = new ModificationWatcher(pollFrequency);
      }
    }
View Full Code Here

   */
  public ModificationWatcher getResourceWatcher(boolean start)
  {
    if (resourceWatcher == null && start)
    {
      final Duration pollFrequency = getResourcePollFrequency();
      if (pollFrequency != null)
      {
        resourceWatcher = new ModificationWatcher(pollFrequency);
      }
    }
View Full Code Here

        long startTime = System.currentTimeMillis();

        // TODO For now only use the setting. Might be extended with
        // something overridable on request/ page/ request target level
        // later
        Duration timeout = Application.get().getRequestCycleSettings().getTimeout();

        PageMapsUsedInRequestEntry entry = (PageMapsUsedInRequestEntry)pageMapsUsedInRequest
            .get(pageMap);

        // Get page entry for id and version
        Thread t = entry != null ? entry.thread : null;
        while (t != null && t != Thread.currentThread())
        {
          if (isCurrentRequestValid(entry.requestCycle) == false)
          {
            // we need to ignore this request. That's because it is
            // an ajax request
            // while regular page request is being processed
            throw new IgnoreAjaxRequestException();
          }

          try
          {
            pageMapsUsedInRequest.wait(timeout.getMilliseconds());
          }
          catch (InterruptedException ex)
          {
            throw new WicketRuntimeException(ex);
          }

          entry = (PageMapsUsedInRequestEntry)pageMapsUsedInRequest.get(pageMap);
          t = entry != null ? entry.thread : null;

          if (t != null && t != Thread.currentThread() &&
              (startTime + timeout.getMilliseconds()) < System.currentTimeMillis())
          {
            // if it is still not the right thread..
            // This either points to long running code (a report
            // page?) or a deadlock or such
            throw new WicketRuntimeException("After " + timeout + " the Pagemap " +
View Full Code Here

TOP

Related Classes of org.apache.wicket.util.time.Duration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.