Package org.apache.cocoon.environment

Examples of org.apache.cocoon.environment.Source


     *         component is currently not cacheable.
     */
    public CacheValidity generateValidity() {
        try {
            AggregatedCacheValidity v = new AggregatedCacheValidity();
            Source current;
            for (int i = 0; i < this.parts.size(); i++) {
                current = ((Part)this.parts.get(i)).source;
                if (current.getLastModified() == 0) {
                        return null;
                } else {
                    v.add(new TimeStampCacheValidity(current.getLastModified()));
                }
            }
            return v;
        } catch (Exception e) {
            getLogger().error("ContentAggregator: could not generateKey", e);
View Full Code Here


     */
    public void recycle() {
        super.recycle();
        this.rootElement = null;
        for (Iterator i = this.parts.iterator(); i.hasNext();) {
            final Source source = ((Part)i.next()).source;
            if ( null != source) source.recycle();
        }
        this.parts.clear();
        this.currentElement = null;
    }
View Full Code Here

                this.source.recycle();
            }
            this.source = new DelayedRefreshSourceWrapper(
                environment.resolve(this.sourceFileName), this.checkDelay);

            Source contextSource = null;
            try {
                contextSource = environment.resolve("");
                contextFileName = contextSource.getSystemId();
            } finally {
                if (contextSource != null) contextSource.recycle();
            }
        } finally {
            environment.setSourceHandler(oldSourceHandler);
        }
        if (!this.isRegenerationRunning) {
View Full Code Here

     */
    private Source getSource(String             uri,
                             Parameters         typeParameters,
                             SourceParameters resourceParameters)
    throws IOException, SAXException, ProcessingException {
        Source input;

        // Test: local uri (= same servlet/cocoon) ?
        if (uri.startsWith("/") == true) {
            // server-absolute url is transformed to absolute url
            Request request = ObjectModelHelper.getRequest(objectModel);
View Full Code Here

                                                   builder);
            filter = new IncludeXMLConsumer(consumer, consumer);
        } else {
            filter = new IncludeXMLConsumer(builder, builder);
        }
        Source input = null;
        try {
            input = this.getSource(uri, typeParameters, resourceParameters);

            if (input != null) {
                input.toSAX(filter);
            }
        } finally {
            if (input != null) input.recycle();
            input = null;
        }

        builder.endElement("", "sunShine", "sunShine");
        builder.endDocument();
View Full Code Here

        }
        DocumentFragment frag = null;

        long startTime = System.currentTimeMillis();

        Source input = null;
        try {
            input = this.resolver.resolve(fileName);

            DOMBuilder builder = new DOMBuilder();
            builder.startDocument();
            builder.startElement("", "sunShine", "sunShine", this.emptyAttributes);

            IncludeXMLConsumer filter = new IncludeXMLConsumer(builder, builder);
            input.toSAX(filter);

            builder.endElement("", "sunShine", "sunShine");
            builder.endDocument();

            // Create Document Fragment
            final Document doc = builder.getDocument();
            frag = doc.createDocumentFragment();
            final Node root = doc.getDocumentElement();
            Node child;
            while (root.hasChildNodes() == true) {
                child = root.getFirstChild();
                child.normalize();
                root.removeChild(child);
                frag.appendChild(child);
            }
        } finally {
            if (input != null) input.recycle();
            input = null;
        }


        if (this.getLogger().isDebugEnabled() == true) {
View Full Code Here

                        }
                    }
                }
            }

            Source input = null;
            try {
                Properties format = XMLUtils.defaultSerializeToXMLFormat(false);
                this.setOutputKeys(format, typeParameters);
                input = this.resolver.resolve(fileName);
                String absolutePath = input.getSystemId();
                if (absolutePath.startsWith("file:") == false) {
                    throw new ProcessingException("Saving to " + fileName + " is not possible.");
                }
                File file = new File(absolutePath.substring("file:".length()));
                if (file.exists() == false) {
                    File directory = file.getParentFile();
                    if (directory.exists() == false) {
                        directory.mkdirs();
                    }
                    file.createNewFile();
                }
                String xml = XMLUtils.serializeNode(fragment, format);
                Writer writer = new BufferedWriter(new FileWriter(file));;
                writer.write(xml);
                writer.flush();
                writer.close();
                writer = null;
            } finally {
                if (input != null) input.recycle();
                input = null;
            }

        } catch (IOException ioe) {
            throw new ProcessingException("saveXMLToFile: IOException: " + ioe, ioe);
View Full Code Here

        this.manager = manager;
    }
   
    public Source getSource(Environment environment, String location)
      throws ProcessingException, MalformedURLException, IOException {
        Source result = new BlobSource(location, this.manager);
        setupLogger(result);
        return result;
    }
View Full Code Here

            // FIXME (KP): Should we exclude not supported protocols, say 'context'?
            String url = this.source;

            // -- debug info --
            Source src = resolver.resolve(url);
            System.out.println("Resolved to: " + src);
            java.net.URL resURL = httpContext.getResource(".");
            System.out.println(". resource is: " + resURL);
            // -- end debug --
View Full Code Here

                              ", typeParams="+typeParameters+
                              ", file=" + fileName +
                              ", params="+resourceParameters);
        }
        try {
            Source input = null;
            try {
                input = this.resolver.resolve(fileName);
                String absolutePath = input.getSystemId();
                if (absolutePath.startsWith("file:") == false) {
                    throw new ProcessingException("Saving to " + fileName + " is not possible.");
                }
                File file = new File(absolutePath.substring("file:".length()));
                if (file.exists() == false) {
                    File directory = file.getParentFile();
                    if (directory.exists() == false) {
                        directory.mkdirs();
                    }
                    file.createNewFile();
                }
                Writer writer = new BufferedWriter(new FileWriter(file));
                writer.write(content);
                writer.flush();
                writer.close();
                writer = null;
            } finally {
                if (input != null) input.recycle();
                input = null;
            }

        } catch (IOException ioe) {
            throw new ProcessingException("saveContentToFile: IOException: " + ioe, ioe);
View Full Code Here

TOP

Related Classes of org.apache.cocoon.environment.Source

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.