Package com.volantis.shared.dependency

Examples of com.volantis.shared.dependency.DependencyContext


    public Object startElement(
            DynamicProcess dynamicProcess, ExpandedName element,
            Attributes attributes) throws SAXException {

        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.
        value = attributes.getValue("cacheable");
        final boolean cacheable;
        if (value == null) {
            cacheable = true;
        } else {
            cacheable = "true".equalsIgnoreCase(value);
        }
        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));
        }

        Dependency dependency = new TestDependency(
                cacheability, timeToLive, freshness, revalidated);

        dependencyContext.addDependency(dependency);

        return null;
    }
View Full Code Here


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

        Dependency dependency = new TestDependency(cacheability, timeToLive,
                freshness, revalidated);
        DependencyContext dependencyContext = context.getDependencyContext();
        dependencyContext.addDependency(dependency);

        ExpressionFactory factory = context.getFactory();
        return factory.createStringValue("freshness = " + freshness + ", " +
                "revalidate = " + revalidated + ", " +
                "cacheable = " + cacheable + ", " +
View Full Code Here

                    (RecordingWithDependency) async.getValue();
                recording = value.getRecording();
                state = CacheBodyOperationProcessState.PLAYBACK_AND_SUPPRESS;

                // add the dependency to the dependency context
                final DependencyContext dependencyContext =
                    getPipelineContext().getDependencyContext();
                dependencyContext.addDependency(value.getDependency());
            } else {

                // We should check to see if this thread is responsible for
                // updating the cached result.
                final CacheEntry entry = async.getEntry();
                if (entry == null) {

                    // Previous result wasn't cached, this thread _isn't_
                    // responsible for updating the cached result, so just
                    // forward the events as is.
                    state = CacheBodyOperationProcessState.NO_CACHE_FORWARD_ONLY;
                } else {
                    final RecordingWithDependency value =
                        (RecordingWithDependency) async.getValue();
                    if (fixedExpiryMode || value == null) {
                        // fixed-age expiry mode or first retrieve for the key

                        // This thread _is_ responsible for updating the cached
                        // result, so record it along with forwarding the events
                        // to any downstream clients.
                        this.state =
                            CacheBodyOperationProcessState.RECORD_AND_FORWARD;
                    } else {
                        // auto mode
                        // check if the dependency is fresh or it can be
                        // revalidated
                        final DependencyContext dependencyContext =
                            getPipelineContext().getDependencyContext();
                        final Dependency dependency = value.getDependency();
                        Freshness freshness =
                            dependency.freshness(dependencyContext);
                        if (freshness == Freshness.REVALIDATE) {
                            freshness =
                                dependency.revalidate(dependencyContext);
                        }

                        // if the dependency is fresh, cache can play the
                        // content back
                        if (freshness == Freshness.FRESH) {
                            // Get the recording from the cache.
                            recording = value.getRecording();
                            this.state =
                                CacheBodyOperationProcessState.PLAYBACK_AND_SUPPRESS;

                            final SystemClock clock =
                                SystemClock.getDefaultInstance();
                            final Time currentTime = clock.getCurrentTime();
                            final PipelineCacheState pcs =
                                new PipelineCacheState(currentTime.addPeriod(
                                    dependency.getTimeToLive()));
                            dependencyContext.addDependency(dependency);

                            // update the cache with the old value so other
                            // threads don't need to wait the timeout period
                            ProviderResult result = new ProviderResult(
                                value, group, true, pcs);
View Full Code Here

                recording = recorder.stopRecording();
            }

            // Update the cachable result of this operation.
            final SystemClock clock = SystemClock.getDefaultInstance();
            final DependencyContext dependencyContext =
                getPipelineContext().getDependencyContext();
            dependencyContext.popDependencyTracker();
            final Dependency dependency;
            if (fixedExpiryMode) {
                dependency = new FixedTTLDependency(
                    clock, cacheControl.getTimeToLive());
            } else {
                dependency = dependencyContext.extractDependency();
            }
            dependencyContext.addDependency(dependency);

            // Set the result to cachable based on the inErrorRecoveryMode
            // state.
            final PipelineCacheState pcs = new PipelineCacheState(
                clock.getCurrentTime().addPeriod(dependency.getTimeToLive()));
View Full Code Here

        return accessor.getDevicePolicyValue(policyName);
    }

    public String getDependentPolicyValue(String policyName) {
        String value = accessor.getDevicePolicyValue(policyName);
        DependencyContext context = expressionContext.getDependencyContext();
        if (context.isTrackingDependencies()) {
            DevicePolicyDependency dependency = new DevicePolicyDependency(
                    policyName, value);
            context.addDependency(dependency);
        }

        return value;
    }
View Full Code Here

            }

            value = factory.createSequence(items);

            // Add dependency information if necessary.
            DependencyContext context = expressionContext.getDependencyContext();
            if (context.isTrackingDependencies()) {
                List list = Arrays.asList(params);
                context.addDependency(new RequestParametersDependency(name, list));
            }
        }

        return value;
    }
View Full Code Here

        if (header != null) {
            value = factory.createStringValue(header);
        }

        // Add dependency information if necessary.
        DependencyContext context = expressionContext.getDependencyContext();
        if (context.isTrackingDependencies()) {
            context.addDependency(new RequestHeaderDependency(name, header));
        }

        return value;
    }
View Full Code Here

            value = factory.createSequence(items);
        }

        // Add dependency information if necessary.
        DependencyContext context = expressionContext.getDependencyContext();
        if (context.isTrackingDependencies()) {
            context.addDependency(new RequestHeadersDependency(name, headers));
        }

        return value;
    }
View Full Code Here

        if (param != null) {
            value = factory.createStringValue(param);
        }

        // Add dependency information if necessary.
        DependencyContext context = expressionContext.getDependencyContext();
        if (context.isTrackingDependencies()) {
            context.addDependency(new RequestParameterDependency(name, param));
        }


        return value;
    }
View Full Code Here

            if (cachingDirectives.isEnabled() &&
                    !ResponseCachingDirectives.PRIORITY_NORMAL.isLower(
                        cachingDirectives.getExpiresPriority())) {
                final XMLPipelineContext pipelineContext =
                    environmentContext.getPipelineContext();
                final DependencyContext dependencyContext =
                    pipelineContext.getDependencyContext();
                if (dependencyContext.isTrackingDependencies()) {
                    final Dependency dependency =
                        dependencyContext.extractDependency();
                    if (dependency.getCacheability() == Cacheability.CACHEABLE) {
                        cachingDirectives.setMaxAge(dependency.getTimeToLive(),
                            ResponseCachingDirectives.PRIORITY_NORMAL);
                        cachingDirectives.enable();
                    } else {
View Full Code Here

TOP

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

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.