001 // Copyright 2005 The Apache Software Foundation
002 //
003 // Licensed under the Apache License, Version 2.0 (the "License");
004 // you may not use this file except in compliance with the License.
005 // You may obtain a copy of the License at
006 //
007 // http://www.apache.org/licenses/LICENSE-2.0
008 //
009 // Unless required by applicable law or agreed to in writing, software
010 // distributed under the License is distributed on an "AS IS" BASIS,
011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012 // See the License for the specific language governing permissions and
013 // limitations under the License.
014
015 package org.apache.tapestry.markup;
016
017 import java.io.PrintWriter;
018
019 import org.apache.tapestry.IMarkupWriter;
020 import org.apache.tapestry.json.IJSONWriter;
021 import org.apache.tapestry.util.ContentType;
022
023 /**
024 * Service interface for <code>tapestry.markup.MarkupWriterSource</code> service. A factory
025 * service that creates new instances of {@link org.apache.tapestry.IMarkupWriter}, configured for
026 * different content types;
027 *
028 * @author Howard M. Lewis Ship
029 * @since 4.0
030 */
031 public interface MarkupWriterSource
032 {
033 /**
034 * Creates and returns a new instance of {@link org.apache.tapestry.IMarkupWriter}. The content
035 * type is used to find the proper implemenation. Any additional content type data (after a ';')
036 * is ignored.
037 *
038 * @param writer
039 * The {@link PrintWriter} to which the markup writer should send output.
040 * @param contentType
041 * Used to locate the correct markup writer implementation (used to select a
042 * {@link MarkupFilter}.
043 * @return The configured markup writer instance.
044 */
045
046 IMarkupWriter newMarkupWriter(PrintWriter writer, ContentType contentType);
047
048 /**
049 * Creates and returns a new instance of {@link IJSONWriter}. The content type is used
050 * to find the proper implementation. Any additional content type data (after a ';')
051 * is ignored.
052 *
053 * @param writer
054 * The {@link PrintWriter} to which the markup writer should send output.
055 * @param contentType
056 * Used to locate the correct markup writer implementation (used to select a
057 * {@link MarkupFilter}.
058 * @return The configured json writer instance.
059 */
060 IJSONWriter newJSONWriter(PrintWriter writer, ContentType contentType);
061 }