sirius.web.templates.ContentHandler Maven / Gradle / Ivy
/*
* Made with all the love in the world
* by scireum in Remshalden, Germany
*
* Copyright by scireum GmbH
* http://www.scireum.de - [email protected]
*/
package sirius.web.templates;
import sirius.kernel.di.std.Priorized;
import java.io.OutputStream;
/**
* Used to effectively generate the output as described by a given {@link Templates.Generator}.
*
* Handlers can be registered in the component model an will be called one after another until one feels
* responsible to generate the effective output. The order of the handlers is defined by their
* {@link sirius.kernel.di.std.Priorized#getPriority()} (sorted ascending).
*
* Each handler should check if either the handler type matches its own, or if the defined template has an
* appropriate file extension.
*
* @see sirius.web.templates.Templates.Generator#getHandlerType()
* @see sirius.web.templates.Templates.Generator#isTemplateFileExtension(String)
*/
public interface ContentHandler extends Priorized {
/**
* Generates the appropriate output if the settings of the generator match.
*
* @param generator the generate settings given by the caller
* @param out the output stream used to write the generated content to
* @return true if output was generated, false if the settings didn't match
* @throws Exception if an error occurs while generating content
*/
boolean generate(Templates.Generator generator, OutputStream out) throws Exception;
}