Package com.volantis.mcs.context

Examples of com.volantis.mcs.context.EnvironmentContext


        // Perform default property processing.
        super.process(content, context, id, propertyName);

        // Disable caching
        final EnvironmentContext environmentContext =
            ContextInternals.getEnvironmentContext(
                context.getInitialRequestContext());
        final ResponseCachingDirectives cachingDirectives =
            environmentContext.getCachingDirectives();
        if (cachingDirectives != null) {
            cachingDirectives.disable();
        }
    }
View Full Code Here


        writeDocument(output);

        final MediaAgent mediaAgent = context.getMediaAgent(false);
        if (mediaAgent != null) {

            final EnvironmentContext environmentContext =
                context.getEnvironmentContext();
            final ResponseCachingDirectives cachingDirectives =
                environmentContext.getCachingDirectives();
            if (cachingDirectives != null && cachingDirectives.isEnabled()) {
                final Period timeToLive =
                    cachingDirectives.getTimeToLive();
               
                // According to HTTp specification we treat "never expires" as "expires in approx. 1 year.
View Full Code Here

     * then copies the caching parameters from the pipeline context if caching
     * is enabled.</p>
     */
    private void setResponseCacheHeaders() {

        final EnvironmentContext environmentContext =
            context.getEnvironmentContext();
        final ResponseCachingDirectives cachingDirectives =
            environmentContext.getCachingDirectives();
        if (cachingDirectives != null) {
            // disable caching if dissection is used
            if (isDissectionNeeded()) {
                cachingDirectives.disable();
            }
            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 {
                        cachingDirectives.disable();
                    }
                }
            }
        }
        environmentContext.applyCachingDirectives();
    }
View Full Code Here

     */
    private static synchronized void loadProject(MarinerPageContext pageContext)
            throws MarinerContextException {
       
        if (project == null) {
            EnvironmentContext ec = pageContext.getEnvironmentContext();
            ProjectManager pm =
                pageContext.getVolantisBean().getProjectManager();
           
            File projectFile = new File(ec.getRealPath(PROJECT_PATH));
            URI projectFileURI = projectFile.toURI().normalize();
            project = pm.getProject(projectFileURI.toString(), null);
        }
    }
View Full Code Here

        // Create a basic layout object
        RuntimeDeviceLayout deviceLayout = createDeviceLayout();

        RuntimeTestMarinerPageContext pageContext = new RuntimeTestMarinerPageContext();
        RuntimeTestMarinerRequestContext requestContext = new RuntimeTestMarinerRequestContext();
        EnvironmentContext environmentContext = new RuntimeTestEnvironmentContext();
        ((RuntimeTestEnvironmentContext)environmentContext)
                .setResponseWriter(writer);

        ApplicationContext applicationContext = new ApplicationContext(
            requestContext);

        pageContext.setDeviceLayout(deviceLayout);

        applicationContext.setDevice(device);
        applicationContext.setProtocol(protocol);
        applicationContext.setDissectionSupported(true);
        applicationContext.setFragmentationSupported(true);
        applicationContext.setCanvasTagSupported(true);
        applicationContext.setWMLCSupported(false);
        applicationContext.setEncodingManager(new EncodingManager());
        applicationContext.setPackager(new DefaultPackager());

        TestVolantis volantisBean = new TestVolantis();

        RuntimeDeviceTheme runtimeDeviceTheme = createRuntimeDeviceTheme();

        final VariantSelectionPolicyMock variantSelectionPolicyMock =
                new VariantSelectionPolicyMock("variantSelectionPolicyMock",
                        expectations);

        final SelectedVariantMock selectedVariantMock =
                new SelectedVariantMock("selectedVariantMock", expectations);
        selectedVariantMock.expects.getOldObject()
                .returns(runtimeDeviceTheme).any();

        final ProjectManagerMock projectManagerMock =
                new ProjectManagerMock("projectManagerMock", expectations);
        PolicyReferenceFactory referenceFactory =
                new PolicyReferenceFactoryImpl(projectManagerMock);

        variantSelectionPolicyMock.fuzzy
                .retrieveBestObject(mockFactory.expectsAny(),
                        mockFactory.expectsAny(),
                        mockFactory.expectsAny())
                .returns(selectedVariantMock).any();

        volantisBean.setVariantSelectionPolicy(variantSelectionPolicyMock);
        volantisBean.setPolicyReferenceFactory(referenceFactory);

        volantisBean.setPageHeadingMsg("Test Page Heading Message");

        ContextInternals.setMarinerPageContext(requestContext, pageContext);
        ContextInternals.setEnvironmentContext(requestContext,
            environmentContext);
        ContextInternals.setApplicationContext(requestContext,
            applicationContext);

        MarinerURL marinerRequestURL =
            new MarinerURL("http://localhost/volantis/test.jsp");
        RequestHeaders requestHeaders = null;

        // Get the parent request context if there is one.
        MarinerRequestContext parentRequest = null;
        if (parent != null) {
            parentRequest = parent.getRequestContext();
        }
        // Initialise expression context.

        ContextInternals.setEnvironmentContext(requestContext,
                environmentContext);

        ExpressionFactory expressionFactory = ExpressionFactory.getDefaultInstance();

        ExpressionContext expressionContext =
                expressionFactory.createExpressionContext(
                        null,
                        NamespaceFactory.getDefaultInstance()
                        .createPrefixTracker());

        expressionContext.setProperty(MarinerRequestContext.class,
                                      requestContext, false);

        RuntimeProject project = new RuntimeProjectMock("runtimeProjectMock",
                expectations);
        volantisBean.setDefaultProject(project);

        final CurrentProjectProviderMock projectProviderMock =
                new CurrentProjectProviderMock("projectProviderMock",
                        expectations);
        projectProviderMock.expects.getCurrentProject().returns(project).any();

        // Add a project provider in for resolving relative policy expressions
        // without a project into absolute IDs containing a project.
        expressionContext.setProperty(CurrentProjectProvider.class,
                projectProviderMock, false);

        environmentContext.setExpressionContext(expressionContext);

        // Initialise the page context.
        pageContext.initialisePage(volantisBean, requestContext, parentRequest,
            marinerRequestURL, requestHeaders);
View Full Code Here

                // The result must be absolute, or host relative.
                if (marinerURL.isAbsolute()) {
                    // Nothing more to do.
                } else if (marinerURL.containsHostRelativePath()) {
                    // May need to make it relative to the context.
                    EnvironmentContext environmentContext =
                            ContextInternals.getEnvironmentContext(
                                    requestContext);
                    MarinerURL contextPath =
                            environmentContext.getContextPathURL();
                    marinerURL = new MarinerURL(contextPath,
                            URLNormalizer.convertHostRelativeToDocumentRelative(
                                    marinerURL.getExternalForm()));
                } else {
                    throw new IllegalStateException("The rewritten URL " +
View Full Code Here

     */
    private static synchronized void loadProject(MarinerPageContext pageContext)
            throws MarinerContextException {

        if (project == null) {
            EnvironmentContext ec = pageContext.getEnvironmentContext();
            ProjectManager pm =
                pageContext.getVolantisBean().getProjectManager();

            File projectFile = new File(ec.getRealPath(PROJECT_PATH));
            baseAssetsPath = new File(ec.getRealPath("/")).getParentFile();
            URI projectFileURI = projectFile.toURI().normalize();
            project = pm.getProject(projectFileURI.toString(), null);
        }
    }
View Full Code Here

        if (charsetCode == null || generateWMLC == null) {
            throw new IllegalStateException(
                    "charsetCode and generateWMLC must be available");
        }

        EnvironmentContext envContext = context.getEnvironmentContext();
        if (Boolean.TRUE.equals(generateWMLC)) {
            // Generate binary WMLC.
            envContext.setContentType("application/vnd.wap.wmlc");
            producer = new WBXMLProducer(output.getOutputStream());
        } else {
            // For WML, the entity encoding is done now. The encoding writer
            // is passed to the producer to do the encoding.
            envContext.setContentType("text/vnd.wap.wml");
            Writer out = output.getWriter();
            Writer enc = new EncodingWriter(out, getCharacterEncoder());
            producer = new WMLProducer(out, enc);
        }
View Full Code Here

     * @return ExpressionContext
     */
    public static ExpressionContext getExpressionContext(
                MarinerRequestContext requestContext) {
        // This method was created to aid code readability.
        final EnvironmentContext environmentContext =
                ContextInternals.getEnvironmentContext(requestContext);

        // Make this a bit forgiving for the many tests that do not set up
        // an environment context. A hack really but no time to fix them all.
        if (environmentContext != null) {
            return environmentContext.getExpressionContext();
        } else {
            return null;
        }
    }
View Full Code Here

            MarinerRequestContext context) {

        ResponseCachingDirectives directives = null;

        // Lookup caching directives
        final EnvironmentContext environmentContext =
                ContextInternals.getEnvironmentContext(context);
        directives = environmentContext.getCachingDirectives();

        return directives;
    }
View Full Code Here

TOP

Related Classes of com.volantis.mcs.context.EnvironmentContext

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.