Package com.volantis.shared.time

Examples of com.volantis.shared.time.Period


        }

        Cacheability cacheability = dependency.getCacheability();
        generateSimpleElement(target, cacheability.toString(), "cacheability");

        Period timeToLive = dependency.getTimeToLive();
        generateSimpleElement(target, timeToLive.toString(), "time-to-live");

        Validity validity = context.checkValidity(dependency);
        generateSimpleElement(target, validity.toString(), "validity");
    }
View Full Code Here


        Cacheability cacheability =
                (cacheable ? Cacheability.CACHEABLE : Cacheability.UNCACHEABLE);

        // Get the time to live.
        value = attributes.getValue("time-to-live");
        final Period timeToLive;
        if (value == null || value.equals("indefinitely")) {
            timeToLive = Period.INDEFINITELY;
        } else {
            timeToLive = Period.inSeconds(Integer.parseInt(value));
        }
View Full Code Here

            throws ExpressionException {

        Freshness freshness = Freshness.FRESH;
        Freshness revalidated = Freshness.FRESH;
        boolean cacheable = true;
        Period timeToLive = Period.INDEFINITELY;

        int argCount = arguments.length;
        String value;
        if (argCount > 0) {
            value = arguments[0].stringValue().asJavaString();
View Full Code Here

     * @param headerName the name of the header
     * @return the Integer object or null
     */
    private Period getHeaderAsPeriod(final String headerName) {
        final Header header = getHeader(headerName);
        Period result = null;
        if (header != null) {
            try {
                final int seconds = Integer.parseInt(header.getValue());
                result = Period.inSeconds(seconds);
            } catch (NumberFormatException e) {
View Full Code Here

        Dependency aggregate = tracker.extractDependency();

        Cacheability cacheability = aggregate.getCacheability();
        assertEquals(Cacheability.UNCACHEABLE, cacheability);

        Period timeToLive = aggregate.getTimeToLive();
        assertEquals(Period.inSeconds(100), timeToLive);

        Freshness freshness = aggregate.freshness(contextMock);
        assertEquals(Freshness.REVALIDATE, freshness);
View Full Code Here

            (!info.isHttpsProtocol() || ccPublic) && cacheHeaderFound &&
            (vary == null || vary.length() == 0);

        // compute freshness lifetime
        // see http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.2.4
        final Period lifetime;
        if (pragmaNoCache || ccNoCache || !cacheable) {
            lifetime = Period.ZERO;
        }
        // Cache-Control/s-maxage overwrites both Cache-Control/max-age
        // and Expires
        else if (ccSMaxAge != null) {
            lifetime = ccSMaxAge;
        // Cache-Control/max-age overwrites Expires
        } else if (ccMaxAge != null) {
            lifetime = ccMaxAge;
        } else if (expires != null && info.getDate() != null) {
            lifetime = expires.getPeriodSince(info.getDate());
        // if freshness lifetime cannot be computed, return 0
        } else {
            lifetime = Period.ZERO;
        }
        freshnessLifetime = Period.max(Period.ZERO, lifetime);

        // compute corrected initial age
        // see http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.2.3
        Period apparentAge = Period.ZERO;
        if (info.getDate() != null) {
            apparentAge = Period.max(Period.ZERO,
                responseTime.getPeriodSince(info.getDate()));
        }
        Period correctedReceivedAge = apparentAge;
        if (age != null) {
            correctedReceivedAge = Period.max(apparentAge, age);
        }
        final Period responseDelay = Period.max(Period.ZERO,
            responseTime.getPeriodSince(info.getRequestTime()));
        correctedInitialAge = correctedReceivedAge.add(responseDelay);
    }
View Full Code Here

        return cacheable;
    }

    // javadoc inherited
    public boolean isStale(final Time currentTime) {
        final Period currentAge = getCurrentAge(currentTime);
        return Comparator.GE.compare(currentAge, freshnessLifetime);
    }
View Full Code Here

            // If the state requires it then wait until the state changes.
            if (state.mustWait()) {
                Countdown countdown = Countdown.getCountdown(timeout, clock);
                do {
                    try {
                        Period remaining = countdown.countdown();
                        entry.wait(remaining.inMillisTreatIndefinitelyAsZero());
                        state = entry.getState();
                    } catch (InterruptedException e) {
                        throw new ExtendedRuntimeException(e);
                    } catch (TimedOutException e) {
                        throw new ExtendedRuntimeException(e);
View Full Code Here

                        retrieveConfiguration(CacheProcessConfiguration.class);

        final String cacheName = attributes.getValue("name");
        final String cacheKeyString = attributes.getValue("key");
        // set max wait time
        final Period maxWaitTime = calculateMaxWaitTime(attributes.getValue("max-wait-time"));
       
        // set the expiry mode
        final String expiryMode = attributes.getValue("expiry-mode");
        final boolean fixedExpiryMode;
        if (expiryMode == null || expiryMode.length() == 0) {
View Full Code Here

     * @throws IllegalArgumentException if the string represents an integer
     *                                  which is less than 0
     */
    static Period calculateMaxWaitTime(String time) {

        Period result;

        if (time == null ) {
            result = CacheBodyOperationProcess.DEFAULT_MAX_WAIT_TIME;
        } else if (CacheControl.LIVE_FOREVER.equals(time)) {
            result = Period.INDEFINITELY;
View Full Code Here

TOP

Related Classes of com.volantis.shared.time.Period

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.