Package org.apache.wicket.util.time

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


  /**
   * Tests timer behavior in a component added to an AjaxRequestTarget
   */
  public void testAddToAjaxUpdate()
  {
    Duration dur = Duration.seconds(20);
    final MyAjaxSelfUpdatingTimerBehavior timer = new MyAjaxSelfUpdatingTimerBehavior(dur);
    final MockPageWithLinkAndComponent page = new MockPageWithLinkAndComponent();

    page.add(new WebComponent(MockPageWithLinkAndComponent.COMPONENT_ID).setOutputMarkupId(true));

View Full Code Here


  /**
   * tests timer behavior in a WebPage.
   */
  public void testAddToWebPage()
  {
    Duration dur = Duration.seconds(20);
    final MyAjaxSelfUpdatingTimerBehavior timer = new MyAjaxSelfUpdatingTimerBehavior(dur);
    final MockPageWithLinkAndComponent page = new MockPageWithLinkAndComponent();
    Label label = new Label(MockPageWithLinkAndComponent.COMPONENT_ID, "Hello");
    page.add(label);
    page.add(new Link(MockPageWithLinkAndComponent.LINK_ID)
View Full Code Here

  {
    boolean removed = super.removeEldestEntry(eldest);
    if (removed == false)
    {
      Value value = (Value)eldest.getValue();
      Duration elapsedTime = Time.now().subtract(value.creationTime);
      if (lifetime.lessThanOrEqual(elapsedTime))
      {
        removedValue = value.response;
        removed = true;
      }
View Full Code Here

  {
    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

   *            request attributes
   */
  protected void configureCache(final WebRequest request, final WebResponse response,
    final ResourceResponse data, final Attributes attributes)
  {
      Duration duration = data.getCacheDuration();

    if(duration.compareTo(Duration.NONE) > 0)
    {
      response.enableCaching(duration, data.getCacheScope());
    }
    else
    {
View Full Code Here

   * @throws CouldNotLockPageException
   *             if lock could not be acquired
   */
  public void lockPage(int pageId) throws CouldNotLockPageException
  {
    final Duration timeout = this.timeout.get();
    final Thread thread = Thread.currentThread();
    final PageLock lock = new PageLock(pageId, thread);
    final Time start = Time.now();

    boolean locked = false;
View Full Code Here

  {
    Response response = attributes.getResponse();

    if (response instanceof WebResponse)
    {
      Duration duration = data.getCacheDuration();
      WebResponse webResponse = (WebResponse)response;
      if (duration.compareTo(Duration.NONE) > 0)
      {
        webResponse.enableCaching(duration, data.getCacheScope());
      }
      else
      {
View Full Code Here

     * @see IResourceSettings#setDefaultCacheDuration(org.apache.wicket.util.time.Duration)
     * @see IResourceSettings#getDefaultCacheDuration()
     */
    public Duration getCacheDuration()
    {
      Duration duration = cacheDuration;
      if (duration == null && Application.exists())
      {
        duration = Application.get().getResourceSettings().getDefaultCacheDuration();
      }

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

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.