Package com.volantis.xml.pipeline.sax.dynamic

Examples of com.volantis.xml.pipeline.sax.dynamic.EndElementAction


        // no cache name attribute set

        dynamicProcessMock.fuzzy.error(mockFactory.
                expectsInstanceOf(SAXParseException.class)).returns().any();

        EndElementAction action = (EndElementAction) cacheRule.startElement(
                dynamicProcessMock, elementName, attributes);
        assertNotNull(action);
        assertEquals(action, EndElementAction.DO_NOTHING);
    }
View Full Code Here


        // Prepare mocks
        contextMock.fuzzy.pushObject(mockFactory.
                expectsInstanceOf(CacheProperties.class), Boolean.FALSE);

        EndElementAction action = (EndElementAction) cacheRule.
                startElement(dynamicProcessMock, elementName, attributes);
        assertNotNull(action);
        assertNotEquals(action, EndElementAction.DO_NOTHING);

        // Prepare mocks
View Full Code Here

        dynamicProcessMock.expects.getPipeline().returns(pipeline);
        dynamicProcessMock.fuzzy.addProcess(mockFactory.
                expectsInstanceOf(CacheBodyOperationProcess.class));

        EndElementAction action = (EndElementAction) cacheRule.
                startElement(dynamicProcessMock, elementName, attributes);
        assertNotNull(action);
        assertNotEquals(action, EndElementAction.DO_NOTHING);

        // Prepare mocks
View Full Code Here

        // Prepare mocks
        contextMock.expects.findObject(CacheProperties.class).
                returns(properties).any();

        DynamicElementRule rule = new CacheKeyRule();
        EndElementAction action = (EndElementAction) rule.
                startElement(dynamicProcessMock, elementName, attributes);
        assertNull(action);

        rule.endElement(dynamicProcessMock, elementName, action);
View Full Code Here

                returns(null).any();
        dynamicProcessMock.fuzzy.error(mockFactory.
                expectsInstanceOf(SAXParseException.class));

        DynamicElementRule rule = new CacheKeyRule();
        EndElementAction action = (EndElementAction) rule.
                startElement(dynamicProcessMock, elementName, attributes);
        assertNull(action);
        rule.endElement(dynamicProcessMock, elementName, action);
    }
View Full Code Here

    // javadoc inherited from interface
    public Object startElement(DynamicProcess dynamicProcess,
                               ExpandedName element, Attributes attributes) throws SAXException {

        XMLPipelineContext context = dynamicProcess.getPipelineContext();
        EndElementAction action = EndElementAction.DO_NOTHING;

        CacheProperties properties = (CacheProperties) context.
                findObject(CacheProperties.class);

        if (properties != null) {


            CacheProcessConfiguration cpc =
                    (CacheProcessConfiguration) dynamicProcess.getPipelineContext().
                            getPipelineConfiguration().
                            retrieveConfiguration(CacheProcessConfiguration.class);

            final String cacheName = properties.getCacheName();
            final Cache cache = cpc.getCache(cacheName);

            // if properties is null then cacheBody element is used outside
            // cache element or cache element has key attribute set, so
            // recording process has been already started.
            CacheBodyOperationProcess operation =
                    new CacheBodyOperationProcess();

            XMLPipeline pipeline = dynamicProcess.getPipeline();

            operation.setCacheName(cacheName);
            operation.setCacheKey(properties.getCacheKey());
            final CacheControl cacheControl = properties.getCacheControl();
            if (cacheControl != null && cacheControl.getTimeToLive() == null) {
                // if no TTL period has been set, use the default value for this
                // cache
                cacheControl.setTimeToLive(cpc.getDefaultTimeToLive(cacheName));
            }
            operation.setCacheControl(cacheControl);
            operation.setPipeline(pipeline);
            operation.setCache(cache);
            operation.setFixedExpiryMode(properties.isFixedExpiryMode());
            operation.setMaxWaitTime(properties.getMaxWaitTime());

            try {
                CacheBodyOperationProcessState state =
                        operation.initializeProcessState();

                // If there is a cached recorder to playback from then we want
                // to suppress all of the content.
                if (state == CacheBodyOperationProcessState.
                        PLAYBACK_AND_SUPPRESS) {
                    // supress all content
                    context.getFlowControlManager().exitCurrentElement();
                }

                dynamicProcess.addProcess(operation);
                action = new EndElementAction() {
                    public void doAction(DynamicProcess dynamicProcess)
                            throws SAXException {
                        // Remove the process from the head, assume that it is
                        // the one that we added, should probably check.
                        dynamicProcess.removeProcess();
View Full Code Here

    // javadoc inherited from interface
    public void endElement(DynamicProcess dynamicProcess, ExpandedName element,
                           Object object) throws SAXException {
        // Perform the action.
        EndElementAction action = (EndElementAction) object;
        action.doAction(dynamicProcess);
    }
View Full Code Here

                               ExpandedName element,
                               Attributes attributes) throws SAXException {

        XMLPipelineContext context = dynamicProcess.getPipelineContext();

        EndElementAction action = EndElementAction.DO_NOTHING;

        final CacheProcessConfiguration cpc =
                (CacheProcessConfiguration) context.getPipelineConfiguration().
                        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) {
            // get the global expiry mode
            fixedExpiryMode = cpc.isFixedExpiryMode();
        } else {
            fixedExpiryMode = !"auto".equals(expiryMode);
        }

        if (cacheName == null || cacheName.length() == 0) {
            forwardError(dynamicProcess, "Cache name must be specified");
        }


        final Cache cache = cpc.getCache(cacheName);
        if (cache != null) {

            if (cacheKeyString != null) {
                // <cache name="cacheName" key="cacheKey">...
                // cacheInfo element is not expected
                // <cacheBody>? is optional


                // Need to populate the cache by doing the OperationProcess
                // at least once.
                CacheBodyOperationProcess operation =
                        new CacheBodyOperationProcess();

                final CacheControl cacheControl = new CacheControl();
                cacheControl.setTimeToLive(cpc.getDefaultTimeToLive(cacheName));
                operation.setCacheControl(cacheControl);

                operation.setCacheName(cacheName);
                operation.setCache(cache);
                CacheKey cacheKey = new CacheKey();
                cacheKey.addKey(cacheKeyString);
                operation.setCacheKey(cacheKey);
                XMLPipeline pipeline = dynamicProcess.getPipeline();
                operation.setPipeline(pipeline);
                operation.setFixedExpiryMode(fixedExpiryMode);
                operation.setMaxWaitTime(maxWaitTime);

                try {
                    CacheBodyOperationProcessState state =
                            operation.initializeProcessState();

                    // If there is a cached recorder to playback from
                    // then we want to suppress all of the content.
                    if (state == CacheBodyOperationProcessState.
                            PLAYBACK_AND_SUPPRESS) {
                        // supress all content
                        context.getFlowControlManager().
                                exitCurrentElement();
                    }

                    dynamicProcess.addProcess(operation);
                    action = new EndElementAction() {
                        public void doAction(DynamicProcess dynamicProcess)
                                throws SAXException {
                            // Remove the process from the head, assume
                            // that it is the one that we added,
                            // should probably check.
                            dynamicProcess.removeProcess();
                        }
                    };

                } catch (SAXException exc) {
                    forwardFatalError(dynamicProcess, "A problem was" +
                            " encountered starting the caching process.");
                }

            } else {
                CacheProperties properties = new CacheProperties();
                properties.setCacheName(cacheName);
                properties.setFixedExpiryMode(fixedExpiryMode);
                properties.setMaxWaitTime(maxWaitTime);
                context.pushObject(properties, false);

                action = new EndElementAction() {
                    public void doAction(DynamicProcess dynamicProcess)
                            throws SAXException {

                        XMLPipelineContext context = dynamicProcess.
                                getPipelineContext();
View Full Code Here

    //  javadoc inherited from interface
    public void endElement(DynamicProcess dynamicProcess, ExpandedName element,
                           Object object) throws SAXException {

        // Perform the action.
        EndElementAction action = (EndElementAction) object;
        action.doAction(dynamicProcess);
    }
View Full Code Here

TOP

Related Classes of com.volantis.xml.pipeline.sax.dynamic.EndElementAction

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.