Package org.apache.wicket.util.time

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


    return null;
  }

  protected Time findLastModified(List<IResourceStream> resources)
  {
    Time ret = null;
    for (IResourceStream curStream : resources)
    {
      Time curLastModified = curStream.lastModifiedTime();
      if (ret == null || curLastModified.after(ret))
        ret = curLastModified;
    }
    return ret;
  }
View Full Code Here


    {
      return null;
    }

    final String contentType = findContentType(resources);
    final Time lastModified = findLastModified(resources);
    final ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
    final long length = bytes.length;
    AbstractResourceStream ret = new AbstractResourceStream()
    {
      private static final long serialVersionUID = 1L;
View Full Code Here

      return sendResourceError(resourceResponse, HttpServletResponse.SC_NOT_FOUND,
          "Unable to find resource");
    }

    // add Last-Modified header (to support HEAD requests and If-Modified-Since)
    final Time lastModified = resourceStream.lastModifiedTime();

    resourceResponse.setLastModified(lastModified);

    if (resourceResponse.dataNeedsToBeWritten(attributes))
    {
View Full Code Here

    String name = resourceReference.getName();
    if (getApplication().getResourceSettings().getAddLastModifiedTimeToResourceReferenceUrl() &&
      !Strings.isEmpty(name) && !name.endsWith("/")) // test for / because it could be a
    // resource reference to a path..
    {
      Time time = resourceReference.lastModifiedTime();
      if (time != null)
      {
        if (parameters == null)
        {
          parameters = new ValueMap();
          parameters.put("w:lm", new Long(time.getMilliseconds() / 1000));
        }
      }
    }

    requestParameters.setParameters(parameters);
View Full Code Here

          // Get resource stream
          IResourceStream stream = resource.getResourceStream();

          // Get last modified time from stream
          Time time = stream.lastModifiedTime();

          try
          {
            stream.close();
          }
          catch (IOException e)
          {
            // ignore
          }

          return time != null ? time.getMilliseconds() : -1;
        }
        catch (AbortException e)
        {
          return -1;
        }
View Full Code Here

          // Get next entry
          final Entry entry = (Entry)iterator.next();

          // If the modifiable has been modified after the last known
          // modification time
          final Time modifiableLastModified = entry.modifiable.lastModifiedTime();

          if (modifiableLastModified.after(entry.lastModifiedTime))
          {
            // Notify all listeners that the modifiable was modified
            entry.listeners.notifyListeners();

            // Update timestamp
View Full Code Here

          final Logger log = getLog();

          while (!stop)
          {
            // Get the start of the current period
            final Time startOfPeriod = Time.now();

            if (log.isDebugEnabled())
            {
              log.debug("Run the job: " + code.toString());
            }
           
            try
            {
              // Run the user's code
              code.run(getLog());
            }
            catch (Exception e)
            {
              log.error("Unhandled exception thrown by user code in task "
                  + name, e);
            }
           
            if (log.isDebugEnabled())
            {
              log.debug("Finished with job: " + code.toString());
            }

            // Sleep until the period is over (or not at all if it's
            // already passed)
            startOfPeriod.add(frequency).fromNow().sleep();
          }
        }
      };

      // Start the thread
View Full Code Here

          // Get resource stream
          IResourceStream stream = resource.getResourceStream();

          // Get last modified time from stream
          Time time = stream.lastModifiedTime();

          try
          {
            stream.close();
          }
          catch (IOException e)
          {
            // ignore
          }

          return time != null ? time.getMilliseconds() : -1;
        }
      }
      catch (AbortException e)
      {
        return -1;
View Full Code Here

    RequestParameters requestParameters = new RequestParameters();
    requestParameters.setResourceKey(resourceReference.getSharedResourceKey());
    if (getApplication().getResourceSettings().getAddLastModifiedTimeToResourceReferenceUrl() &&
      !Strings.isEmpty(resourceReference.getName()))
    {
      Time time = resourceReference.lastModifiedTime();
      if (time != null)
      {
        if (parameters == null)
        {
          parameters = new ValueMap();
          parameters.put("wicket:lm", new Long(time.getMilliseconds()));
        }
      }
    }

    requestParameters.setParameters(parameters);
View Full Code Here

          try
          {
            while (!stop)
            {
              // Get the start of the current period
              final Time startOfPeriod = Time.now();

              if (log.isTraceEnabled())
              {
                log.trace("Run the job: " + code.toString());
              }

              try
              {
                // Run the user's code
                code.run(getLog());
              }
              catch (Exception e)
              {
                log.error(
                  "Unhandled exception thrown by user code in task " + name, e);
              }

              if (log.isTraceEnabled())
              {
                log.trace("Finished with job: " + code.toString());
              }

              // Sleep until the period is over (or not at all if it's
              // already passed)
              startOfPeriod.add(frequency).fromNow().sleep();
            }
          }
          catch (Throwable t)
          {
            log.error("Task " + name + " terminated", t);
View Full Code Here

TOP

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

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.