KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > portal > generic > Renderer


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  *
18  * 3. The end-user documentation included with the redistribution, if
19  * any, must include the following acknowlegement:
20  * "This product includes software developed by the
21  * Caucho Technology (http://www.caucho.com/)."
22  * Alternately, this acknowlegement may appear in the software itself,
23  * if and wherever such third-party acknowlegements normally appear.
24  *
25  * 4. The names "Hessian", "Resin", and "Caucho" must not be used to
26  * endorse or promote products derived from this software without prior
27  * written permission. For written permission, please contact
28  * info@caucho.com.
29  *
30  * 5. Products derived from this software may not be called "Resin"
31  * nor may "Resin" appear in their names without prior written
32  * permission of Caucho Technology.
33  *
34  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
35  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
36  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37  * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS
38  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
39  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
40  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
41  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
42  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
43  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
44  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45  *
46  * @author Sam
47  */

48
49
50 package com.caucho.portal.generic;
51
52 import javax.portlet.PortletMode;
53 import javax.portlet.PortletRequest;
54 import javax.portlet.RenderRequest;
55 import javax.portlet.WindowState;
56 import java.io.IOException JavaDoc;
57 import java.io.OutputStream JavaDoc;
58 import java.io.PrintWriter JavaDoc;
59
60 /**
61  * Classes can implement {@link AbstractRenderer} to protect from API changes.
62  */

63 public interface Renderer {
64   /**
65    * Return true if the WindowState is allowed.
66    * <code>portletRequest.getResponseContentType()</code> can be used
67    * if the allowed portlet modes depends on the mime type of the
68    * response.
69    */

70   public boolean isWindowStateAllowed( PortletRequest request,
71                                        WindowState windowState );
72
73   /**
74    * Return true if the PortletMode is allowed.
75    * <code>portletRequest.getResponseContentType()</code> can be used
76    * if the allowed portlet modes depends on the mime type of the
77    * response.
78    */

79   public boolean isPortletModeAllowed( PortletRequest request,
80                                        PortletMode portletMode );
81
82   /**
83    * If true the portal will always call getWriter(), even if the portlet does
84    * not call getWriter(), unless getOutputStream() has been called.
85    */

86   public boolean isAlwaysWrite();
87
88   /**
89    * If true the portal will always call getOutputStream(), even if the portlet
90    * does not call getOutputStream(), unless getWriter() has been called.
91    */

92   public boolean isAlwaysStream();
93
94   /**
95    * If {@link #isAlwaysWrite()} or {@link #isAlwaysStream()} is true, then a
96    * Writer or OutputStream might be obtained before the content type of the
97    * response has been set. IF that is the case, then this method is called to
98    * detrmine a default content type.
99    */

100   public String JavaDoc getDefaultContentType();
101
102   public int getBufferSize();
103
104   /**
105    * Return a Writer that wraps the passed PrintWriter, or null
106    * if there is no specialized writer for this request.
107    *
108    * <code>renderRequest.getResponseContentType()</code> can be used
109    * if the Renderer needs to know the content type.
110    *
111    * renderRequest.getAttribute("javax.portlet.title") may contain a title
112    * for the Window, if the portlet has set one.
113    */

114   public PrintWriter JavaDoc getWriter( PrintWriter JavaDoc out,
115                                 RenderRequest request,
116                                 String JavaDoc namespace )
117     throws IOException JavaDoc;
118   
119   /**
120    * Finish with a Writer produced by this factory.
121    * This may be called even if the writer threw an Exception.
122    *
123    * @param isDiscarded true if the portal discarded the output.
124    * Output is discarded when the portal wishes to discard any output
125    * that has been made for the window, with the intention that the
126    * window should not be rendered at all.
127    */

128   public void finish( PrintWriter JavaDoc writer,
129                       RenderRequest request,
130                       String JavaDoc namespace,
131                       boolean isDiscarded )
132     throws IOException JavaDoc;
133
134   /**
135    * Return an OutputStream that wraps the passed OutputStream, or null
136    * if there is no specialized writer for this request.
137    *
138    * <code>renderRequest.getResponseContentType()</code> can be used
139    * if the Renderer needs to know the content type.
140    *
141    * renderRequest.getAttribute("javax.portlet.title") may contain a title
142    * for the Window, if the portlet has set one.
143    */

144   public OutputStream JavaDoc getOutputStream( OutputStream JavaDoc out,
145                                        RenderRequest renderRequest,
146                                        String JavaDoc namespace )
147     throws IOException JavaDoc;
148   
149   /**
150    * Finish with an OutputStream produced by this factory.
151    * This may be called even if the outputStream threw an Exception.
152    *
153    * @param discarded true if the portal discarded the output, may occur
154    * Output is discarded when the portal wishes to discard any output
155    * that has been made for the window, with the intention that the
156    * window should not be rendered at all.
157    */

158   public void finish( OutputStream JavaDoc outputStream,
159                       RenderRequest renderRequest,
160                       String JavaDoc namespace,
161                       boolean isDiscarded )
162     throws IOException JavaDoc;
163 }
164
165
Popular Tags