Package org.milyn.delivery

Examples of org.milyn.delivery.ContentDeliveryConfig


        System.getProperties().remove("test.parameter");
    }

    public void test_system_property() {
        Smooks smooks = new Smooks();
        ContentDeliveryConfig deliveryConfig = smooks.createExecutionContext().getDeliveryConfig();

        assertEquals(null, ParameterAccessor.getStringParameter("test.parameter", deliveryConfig));

        System.setProperty("test.parameter", "xxxxxxx");
        assertEquals("xxxxxxx", ParameterAccessor.getStringParameter("test.parameter", deliveryConfig));
View Full Code Here


    }

    public void test_digest_05_simple_default_1() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("config_05.1.xml"));
        ExecutionContext execContext;
        ContentDeliveryConfig deliveryConf;
        List<SmooksResourceConfiguration> configList;

        // config_05.1.xml defines a default profile of "xxx", so creating the context without specifying
        // a profile should exclude the "aa" resource...
        execContext = smooks.createExecutionContext();
        deliveryConf = execContext.getDeliveryConfig();
        configList = deliveryConf.getSmooksResourceConfigurations("aa");
        assertNull(configList);

        // config_05.1.xml defines a default profile of "xxx", so creating the context by specifying
        // a profile of "xxx" should include the "aa" resource...
        execContext = smooks.createExecutionContext("xxx");
        deliveryConf = execContext.getDeliveryConfig();
        configList = deliveryConf.getSmooksResourceConfigurations("aa");
        assertNotNull(configList);

        // Make sure the resource has the other default settings...
        SmooksResourceConfiguration config = configList.get(0);
        assertEquals("http://an", config.getSelectorNamespaceURI());
View Full Code Here

    }

    public void test_digest_05_simple_default_2() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("config_05.2.xml"));
        ExecutionContext execContext;
        ContentDeliveryConfig deliveryConf;
        List<SmooksResourceConfiguration> configList;

        // config_05.2.xml defines a name attribute, so that should override the default...
        execContext = smooks.createExecutionContext("xxx");
        deliveryConf = execContext.getDeliveryConfig();
        configList = deliveryConf.getSmooksResourceConfigurations("j");
        assertNotNull(configList);

        // Make sure the resource has the other default settings...
        SmooksResourceConfiguration config = configList.get(0);
        assertEquals("http://an", config.getSelectorNamespaceURI());
View Full Code Here

     */
    private void parse(Source source, DOMBuilder contentHandler) throws SAXException, IOException {
      ExecutionContext executionContext = getExecContext();
     
      if(executionContext != null) {
      ContentDeliveryConfig deliveryConfig = executionContext.getDeliveryConfig();

        XMLReader domReader = getXMLReader(executionContext);

        try {
                if(domReader == null) {
                    domReader = deliveryConfig.getXMLReader();
                }
                if(domReader == null) {
                    domReader = createXMLReader();
                }

                if(domReader instanceof HierarchyChangeReader) {
                    ((HierarchyChangeReader)domReader).setHierarchyChangeListener(new XMLReaderHierarchyChangeListener(executionContext));
                }

                NamespaceDeclarationStack namespaceDeclarationStack = new NamespaceDeclarationStack();
                NamespaceMappings.setNamespaceDeclarationStack(namespaceDeclarationStack, executionContext);
                attachNamespaceDeclarationStack(domReader, executionContext);

                attachXMLReader(domReader, executionContext);
                configureReader(domReader, contentHandler, executionContext, source);
            domReader.parse(createInputSource(source, executionContext.getContentEncoding()));
        } finally {
                try {
                    if(domReader instanceof HierarchyChangeReader) {
                        ((HierarchyChangeReader)domReader).setHierarchyChangeListener(null);
                    }
                } finally {
                    try {
                        try {
                            detachXMLReader(executionContext);
                        } finally {
                            if(domReader != null) {
                                deliveryConfig.returnXMLReader(domReader);
                            }
                        }
                    } finally {
                        contentHandler.detachHandler();
                    }
View Full Code Here

    }

    protected Writer parse(Source source, Result result, ExecutionContext executionContext) throws SAXException, IOException {

        Writer writer = getWriter(result, executionContext);
        ContentDeliveryConfig deliveryConfig = executionContext.getDeliveryConfig();
        XMLReader saxReader = getXMLReader(executionContext);

        saxHandler = new SAXHandler(getExecContext(), writer);

        try {
            if(saxReader == null) {
                saxReader = deliveryConfig.getXMLReader();
            }
            if(saxReader == null) {
                saxReader = createXMLReader();
            }

            NamespaceDeclarationStack namespaceDeclarationStack = new NamespaceDeclarationStack();
            NamespaceMappings.setNamespaceDeclarationStack(namespaceDeclarationStack, executionContext);

            attachNamespaceDeclarationStack(saxReader, executionContext);
            attachXMLReader(saxReader, executionContext);

            configureReader(saxReader, saxHandler, executionContext, source);
            if(executionContext != null) {
                if(saxReader instanceof HierarchyChangeReader) {
                    ((HierarchyChangeReader)saxReader).setHierarchyChangeListener(new XMLReaderHierarchyChangeListener(executionContext));
                }
              saxReader.parse(createInputSource(source, executionContext.getContentEncoding()));
            } else {
                saxReader.parse(createInputSource(source, Charset.defaultCharset().name()));
            }
        } finally {
            try {
                if(executionContext != null && saxReader instanceof HierarchyChangeReader) {
                    ((HierarchyChangeReader)saxReader).setHierarchyChangeListener(null);
                }
            } finally {
                try {
                    if(saxReader != null) {
                        try {
                            detachXMLReader(executionContext);
                        } finally {
                            deliveryConfig.returnXMLReader(saxReader);
                        }
                    }
                } finally {
                    saxHandler.detachHandler();
                }
View Full Code Here

TOP

Related Classes of org.milyn.delivery.ContentDeliveryConfig

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.