Package com.volantis.shared.dependency

Examples of com.volantis.shared.dependency.Freshness


    public Freshness freshness(DependencyContext context) {

        DependencyContext internal =
                context;

        Freshness aggregate = Freshness.FRESH;
        for (int i = 0; i < dependencies.length &&
                aggregate != Freshness.STALE; i++) {

            Dependency dependency = dependencies[i];

            // Make sure that the dependency updates the revalidation list
            // correctly.
            Freshness freshness = internal.checkFreshness(dependency);
            aggregate = aggregate.combine(freshness);
        }

        return aggregate;
    }
View Full Code Here


        return aggregate;
    }

    public Freshness revalidate(DependencyContext context) {

        Freshness aggregate = Freshness.FRESH;
        for (int i = 0; i < dependencies.length &&
                aggregate != Freshness.STALE; i++) {

            Dependency dependency = dependencies[i];
            Freshness freshness = dependency.revalidate(context);
            aggregate = aggregate.combine(freshness);
        }

        return aggregate;
    }
View Full Code Here

    }

    // Javadoc inherited.
    public Validity checkValidity(Dependency dependency) {

        Freshness freshness;
        checked = new HashMap();
        try {
            freshness = dependency.freshness(this);
            if (freshness == Freshness.REVALIDATE) {
View Full Code Here

        return validity;
    }

    // Javadoc inherited.
    public Freshness checkFreshness(Dependency dependency) {
        Freshness freshness = null;
        if (checked == null) {
            freshness = dependency.freshness(this);
        } else {
            freshness = (Freshness) checked.get(dependency);
            if (freshness == null) {
View Full Code Here

    // javadoc inherited
    public Freshness revalidate(final DependencyContext context) {
        final URLContent content =
            (URLContent) cache.retrieve(cacheKey, objectProvider);
        final Freshness freshness;
        if (!this.equals(content.getDependency())) {
            freshness = Freshness.STALE;
            context.setProperty(cacheKey, content);
        } else {
            freshness = freshness(context);
View Full Code Here

        context.popDependencyTracker();

        XMLProcess target = getTargetProcess(dynamicProcess);

        // Generate an element containing the freshness.
        Freshness freshness = dependency.freshness(context);
        generateSimpleElement(target, freshness.toString(),
                "freshness");

        // Generate an element containing the revalidated freshness.
        if (freshness == Freshness.REVALIDATE) {
            Freshness revalidated = dependency.revalidate(context);
            generateSimpleElement(target, revalidated.toString(),
                    "revalidated");
        }

        Cacheability cacheability = dependency.getCacheability();
        generateSimpleElement(target, cacheability.toString(), "cacheability");
View Full Code Here

        XMLPipelineContext context = dynamicProcess.getPipelineContext();
        DependencyContext dependencyContext = context.getDependencyContext();

        // Get the freshness.
        String value = attributes.getValue("freshness");
        final Freshness freshness = (Freshness) STRING_2_FRESHNESS.get(value);
        if (freshness == null) {
            forwardError(dynamicProcess, "Unknown freshness value: " + value);
        }

        // Get the revalidated.
        value = attributes.getValue("revalidated");
        final Freshness revalidated = (Freshness) STRING_2_FRESHNESS.get(value);
        if (revalidated == null) {
            forwardError(dynamicProcess, "Unknown revalidated value: " + value);
        }

        // Get the cacheable.
View Full Code Here

        Dependency aggregate = new Dependencies(Arrays.asList(
                new Dependency[] {
                    dependency1Mock, dependency2Mock
                }));

        Freshness actual = aggregate.freshness(contextMock);
        assertEquals(expected, actual);
    }
View Full Code Here

    // Javadoc inherited.
    public Value invoke(ExpressionContext context, Value[] arguments)
            throws ExpressionException {

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

        int argCount = arguments.length;
        String value;
View Full Code Here

        assertEquals(Cacheability.UNCACHEABLE, cacheability);

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

        Freshness freshness = aggregate.freshness(contextMock);
        assertEquals(Freshness.REVALIDATE, freshness);

        Freshness revalidate = aggregate.revalidate(contextMock);
        assertEquals(Freshness.FRESH, revalidate);
    }
View Full Code Here

TOP

Related Classes of com.volantis.shared.dependency.Freshness

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.