Package com.volantis.mcs.context

Examples of com.volantis.mcs.context.ApplicationContext


     */
    public ApplicationContext createApplicationContext(
            MarinerRequestContext requestContext)
                throws RepositoryException {

        ApplicationContext applicationContext = null;

        // Get the Volantis bean.
        Volantis volantisBean = Volantis.getInstance();
        if (volantisBean == null) {
            throw new IllegalStateException
View Full Code Here


            MarinerURL requestURL =
                    volantisBean.getClientAccessibleURL(
                            new MarinerURL("internalRequest"));

            ApplicationContext appContext;
            ApplicationContextFactory acf =
                    applicationRegistryContainer
                    .getInternalApplicationContextFactory();


            // Save away a reference to the enclosing MarinerRequestContext
            // if any.
            enclosingRequestContext = getCurrent(request);
            if (enclosingRequestContext != null) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Saving reference to "
                            + enclosingRequestContext
                            + " from " + request);
                }
            }

            // Get a MarinerPageContext object.
            final MarinerPageContext context;

            if (enclosingRequestContext != null) {
                context =
                        ContextInternals.getMarinerPageContext(
                                enclosingRequestContext);
            } else {
                context = volantisBean.createMarinerPageContext();
            }

            // Create and initialise the EnvironmentContext, do this after the
            // MarinerPageContext has been allocated but before it has been
            // initialised as this is needed during the initialisation.
            environmentContext.initialise(context);
            environmentContext.initialiseSession();

            ExpressionContext exprContext =
                    environmentContext.getExpressionContext();

            // If there is an expression context then it must have been associated
            // with an enclosing request context since we are still initialising
            // this instance of MarinerServletRequestContext. We now must associate
            // the expression context with this MarinerServletRequestContext.
            //
            // An expression context can be associated with more than one request
            // context, although not concurrently. When the request context is no
            // longer needed, the expression context (if any) should be reset to
            // the enclosing request context.
            if (exprContext == null) {
                ExpressionSupport.createExpressionEnv(this,
                        volantisBean, environmentContext,
                        context.getDevicePolicyAccessor());
            } else {
                exprContext.setProperty(MarinerRequestContext.class, this,
                        false);
            }

            ContextInternals.setEnvironmentContext(this, environmentContext);

            if (enclosingRequestContext != null) {
                // Copy our application context, as nothing has changed from an
                // application point of view.
                appContext =
                        ContextInternals.getApplicationContext(
                                enclosingRequestContext);
                if (logger.isDebugEnabled()) {
                    logger.debug("Retrieved applicationContext " + appContext);
                }
            } else {
                // We are the top level request so initialise an application context
                // for this application
                appContext = acf.createApplicationContext(this);
                if (logger.isDebugEnabled()) {
                    logger.debug(
                            "Created new applicationContext " + appContext);
                }
            }

            // Store the application context away as it is required to
            // initialise the page context.
            ContextInternals.setApplicationContext(this, appContext);

            // Save the reference away immediately so if a problem occurs during the
            // initialisation it is cleaned up properly.
            ContextInternals.setMarinerPageContext(this, context);

            // Initialise the page context.
            if (enclosingRequestContext == null) {
                context.initialisePage(volantisBean, this,
                        enclosingRequestContext,
                        requestURL, requestHeaders);
            } else {
                // Make this the current request context
                context.pushRequestContext(this);
            }


            // Select the best charset that we could find from the accept headers.
            EncodingManager encodingManager = appContext.getEncodingManager();
            AcceptCharsetSelector selector = new AcceptCharsetSelector(
                    encodingManager);
            HttpHeaders rHeaders = HttpFactory.getDefaultInstance()
                    .createHTTPHeaders();
            String charset = selector.selectCharset(rHeaders,
View Full Code Here

            }

            MarinerURL requestURL = createRequestURL(request);
            requestURL = volantisBean.getClientAccessibleURL(requestURL);

            ApplicationContext appContext;
            ApplicationContextFactory acf =
                    applicationRegistryContainer.getServletApplicationContextFactory();


            // Save away a reference to the enclosing MarinerRequestContext
            // if any.
            enclosingRequestContext = getCurrent(request);
            if (enclosingRequestContext != null) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Saving reference to "
                            + enclosingRequestContext
                            + " from " + request);
                }
            }

            // Get a MarinerPageContext object.
            final MarinerPageContext context;

            if (enclosingRequestContext != null) {
                context =
                        ContextInternals.getMarinerPageContext(
                                enclosingRequestContext);
            } else {
                context = volantisBean.createMarinerPageContext();
            }

            // Create and initialise the EnvironmentContext, do this after the
            // MarinerPageContext has been allocated but before it has been
            // initialised as this is needed during the initialisation.
            environmentContext.initialise(context);
            environmentContext.initialiseSession();

            ExpressionContext exprContext =
                    environmentContext.getExpressionContext();

            // If there is an expression context then it must have been associated
            // with an enclosing request context since we are still initialising
            // this instance of MarinerServletRequestContext. We now must associate
            // the expression context with this MarinerServletRequestContext.
            //
            // An expression context can be associated with more than one request
            // context, although not concurrently. When the request context is no
            // longer needed, the expression context (if any) should be reset to
            // the enclosing request context.
            if (exprContext == null) {
                ExpressionSupport.createExpressionEnv(this,
                        volantisBean, environmentContext,
                        context.getDevicePolicyAccessor());
            } else {
                exprContext.setProperty(MarinerRequestContext.class, this,
                        false);
            }

            ContextInternals.setEnvironmentContext(this, environmentContext);

            if (enclosingRequestContext != null) {
                // Copy our application context, as nothing has changed from an
                // application point of view.
                appContext =
                        ContextInternals.getApplicationContext(
                                enclosingRequestContext);
                if (logger.isDebugEnabled()) {
                    logger.debug("Retrieved applicationContext " + appContext);
                }
            } else {
                // We are the top level request so initialise an application context
                // for this application
                appContext = acf.createApplicationContext(this);
                if (logger.isDebugEnabled()) {
                    logger.debug(
                            "Created new applicationContext " + appContext);
                }
            }

            // Store the application context away as it is required to
            // initialise the page context.
            ContextInternals.setApplicationContext(this, appContext);

            // Save the reference away immediately so if a problem occurs during the
            // initialisation it is cleaned up properly.
            ContextInternals.setMarinerPageContext(this, context);

            // Initialise the page context.
            if (enclosingRequestContext == null) {
                context.initialisePage(volantisBean, this,
                        enclosingRequestContext,
                        requestURL, requestHeaders);
            } else {
                // Make this the current request context
                context.pushRequestContext(this);
            }


            // Select the best charset that we could find from the accept headers.
            EncodingManager encodingManager = appContext.getEncodingManager();
            AcceptCharsetSelector selector = new AcceptCharsetSelector(
                    encodingManager);
            HttpHeaders rHeaders = HttpServletFactory.
                    getDefaultInstance().getHTTPHeaders(request);
            String charset = selector.selectCharset(rHeaders,
View Full Code Here

        ContextInternals.setEnvironmentContext(requestContext,
                new TestEnvironmentContext());

        // Set up fragmentation specific prerequisites.
        // Set up an app context so we can enable fragmentation.
        ApplicationContext appContext = new ApplicationContext(requestContext);
        ContextInternals.setApplicationContext(requestContext, appContext);
        appContext.setFragmentationSupported(true);
        // Fragmentation needs a URL and rewriter for URL manipulation.
        pageContext.setRootPageURL(new MarinerURL());
        pageContext.setVolantis(new TestableVolantis() {
            public PageURLRewriter getLayoutURLRewriter() {
                return new PageURLRewriter() {
View Full Code Here

        ContextInternals.setEnvironmentContext(requestContext,
                new TestEnvironmentContext());

        // Set up fragmentation specific prerequisites.
        // Set up an app context so we can enable fragmentation.
        ApplicationContext appContext = new ApplicationContext(requestContext);
        ContextInternals.setApplicationContext(requestContext, appContext);
        appContext.setFragmentationSupported(true);
        // Fragmentation needs a URL and rewriter for URL manipulation.
        pageContext.setRootPageURL(new MarinerURL());
        pageContext.setVolantis(new TestableVolantis() {
            public PageURLRewriter getLayoutURLRewriter() {
                return new PageURLRewriter() {
View Full Code Here

     * @return true iff MCS will generate binary output for this request.
     */
    protected boolean willGenerateBinaryOutput(
            MarinerServletRequestContext context) {

        final ApplicationContext applicationContext =
                ContextInternals.getApplicationContext(context);

        return applicationContext.getProtocol().getOutputStyle() ==
                ContentStyle.BINARY;
    }
View Full Code Here

                                                           final int deviceWidth)
            throws Exception {
        TestMarinerRequestContext requestContext =
                new TestMarinerRequestContext();

        final ApplicationContext appContext =
                new ApplicationContext(requestContext);
        appContext.setEncodingManager(new EncodingManager());

        TestMarinerPageContext pageContext = new TestMarinerPageContext();
        pageContext.pushRequestContext(requestContext);

        final PolicyReferenceResolverMock referenceResolverMock =
                new PolicyReferenceResolverMock("referenceResolverMock",
                        expectations);
        pageContext.setPolicyReferenceResolver(referenceResolverMock);

        referenceResolverMock.expects.resolveQuotedTextExpression(null)
                .returns(null).any();

        EnvironmentContext envContext = new TestEnvironmentContext();
        ContextInternals.setEnvironmentContext(requestContext, envContext);

        ContextInternals.setMarinerPageContext(requestContext, pageContext);
        ContextInternals.setApplicationContext(requestContext, appContext);

        final Volantis volantis = new TestableVolantis() {
            public MarinerPageContext createMarinerPageContext() {
                return new TestMarinerPageContext();
            }

            public PluggableAssetTranscoder getAssetTranscoder() {
                return transcoder;
            }
        };

        pageContext.initialisePage(volantis, requestContext,
                null, null, null);

        final DefaultDevice dev = new DefaultDevice("myDevice", null, null);
        dev.setPolicyValue("protocol", "XHTMLBasic");
        dev.setPolicyValue("rendermode", "not-monochrome");
        dev.setPolicyValue("pixeldepth", "32");
        dev.setPolicyValue("jpeginpage", "true");
        dev.setPolicyValue("cjpeg24rule", rule);
        dev.setPolicyValue("preferredimagetype", "JPEG");

        // Set width on device.
        if (deviceWidth != 0) {
            dev.setPolicyValue("pixelsx",
                    StringConvertor.valueOf(deviceWidth));
        }

        final InternalDevice internalDevice =
            INTERNAL_DEVICE_FACTORY.createInternalDevice(dev);
        appContext.setDevice(internalDevice);
        pageContext.setDevice(internalDevice);

        ProtocolBuilder builder = new ProtocolBuilder();
        DOMProtocol domProtocol = (DOMProtocol) builder.build(
                new TestProtocolRegistry.TestDOMProtocolFactory(),
View Full Code Here

        MultipartPackageHandler handler) throws Exception {
        TestMarinerRequestContext requestContext =
            new TestMarinerRequestContext();
        TestMarinerPageContext pageContext = new TestMarinerPageContext();
        pageContext.setVolantis(volantis);
        ApplicationContext appContext =
            new MultipartApplicationContext(requestContext);
        TestEnvironmentContext envContext =
            new TestEnvironmentContext(getClass().getName() + ".message");

        pageContext.pushRequestContext(requestContext);
        ContextInternals.setEnvironmentContext(requestContext, envContext);
        ContextInternals.setMarinerPageContext(requestContext, pageContext);
        ContextInternals.setApplicationContext(requestContext, appContext);
        appContext.setPackager(handler);
        appContext.setAssetURLRewriter(handler);
        appContext.getPackageResources().setContentType("multipart/mixed");
        appContext.setEncodingManager(encodingManager);
        envContext.setContextPathURL("http://localhost:" + port);
        requestContext.setCharacterEncoding("iso-8859-1");
        return pageContext;
    }
View Full Code Here

        InternalDevice device = resolveDevice(
                volantisBean,
                requestContext);

        // Create the application context
        ApplicationContext applicationContext =
            new PrerendererApplicationContext(requestContext);

        // Initialize the application context.
        initializeApplicationContext(requestContext, volantisBean,
                applicationContext, device);
View Full Code Here

        // Let the base class create basic mocks
        super.setUp();       
        XDIMEContentHandler handler = getXDIMEContentHandler();
        MarinerRequestContextMock context =
            (MarinerRequestContextMock)handler.getCurrentRequestContext();
        ApplicationContext appContext = new ApplicationContext(context);
       
        context.expects.getApplicationContext().returns(appContext);

        addDefaultElementExpectations(MapLocationMarkerAttributes.class);
       
View Full Code Here

TOP

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

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.