|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
com.caucho.portal.generic.PortletServlet
public class PortletServlet
A servlet that uses a class implementing javax.portlet.Portlet. This servlet supports the following configuration items. Items marked with a * can be set as init-param.
Portal, default is an instance of
GenericPortal.
portal
Portal as
an application attribute. This is an alternative to using
portal and is useful when more than one portlet
servlet share a Portal.
Portlet, required
portlet
PortletConfig.getPortletName(),
the default is ServletConfig.getServletName()
PortletConfig.getResourceBundle(Locale)
Renderer, used to add decorations like headers
footers and controls to the portlet, the default is no renderer. See
AbstractRenderer.
renderer
setRenderer(Renderer).
<servlet servlet-name="portal"
servlet-class="com.caucho.portal.generic.PortletServlet">
<init>
...
<portlet-preferences>
<preference name="colour" value="green" read-only="true"/>
or
<preference>
<name>colour</name>
<value>green</value>
<read-only>true</read-only>
</preference>
</portlet-preferences>
...
</init>
</servlet>
| Field Summary | |
|---|---|
protected static java.util.logging.Logger |
log
|
| Constructor Summary | |
|---|---|
PortletServlet()
|
|
| Method Summary | |
|---|---|
void |
addInitParam(NameValuePair nameValuePair)
|
void |
addInitParam(java.lang.String name,
java.lang.String value)
Add an init-param for the portlet. |
void |
destroy()
Called when the servlet (and the application) shuts down. |
protected void |
doGet(HttpServletRequest req,
HttpServletResponse res)
Process a GET or HEAD request |
protected void |
doPost(HttpServletRequest req,
HttpServletResponse res)
Process a POST request |
protected void |
doRequest(HttpServletRequest httpRequest,
HttpServletResponse httpResponse)
|
int |
getBufferSize()
Return a preferred buffer size, may be overridden by the portlet if it calls setBufferSize(). |
java.util.ArrayList<Constraint> |
getConstraints()
Return a list of Constraint that are applied before the
processAction() and render() of the portlet are called, null if there
are no Constraints. |
PortletPreferences |
getDefaultPreferences()
Return the default preferences for the portlet, null if there are no default preferences. |
int |
getExpirationCache()
Time in seconds, 0 disables caching and -1 means never expire. |
java.lang.String |
getInitParameter(java.lang.String name)
Returns an initialization parameter. |
java.util.Enumeration |
getInitParameterNames()
Enumerates all the initialization parameter. |
PortletConfig |
getPortletConfig()
|
PortletContext |
getPortletContext()
|
java.lang.String |
getPortletName()
|
java.util.ArrayList<PreferencesValidator> |
getPreferencesValidators()
Return the preferences validators for the portlet, null if there are no preference validators. |
Renderer |
getRenderer()
|
java.util.ResourceBundle |
getResourceBundle(java.util.Locale locale)
|
java.util.Map<java.lang.String,java.lang.String> |
getRoleRefMap()
Return a map that map's role names used by the portlet to the role names recognized by the portal, null if the role names used by the portlet are to be used unchanged. |
java.util.Set<java.lang.String> |
getSupportedContentTypes(PortletMode portletMode)
Return the content types supported for the mode, null if all content types are permitted. |
java.util.Set<java.util.Locale> |
getSupportedLocales()
Return the Locales supported, null if all Locales are permitted. |
void |
handleConstraintFailure(RenderRequest request,
RenderResponse response,
ConstraintFailureEvent event)
Optionally handle a constraint failure by sending some output to the client using the response or by hiding the window. |
void |
handleException(RenderRequest request,
RenderResponse response,
ExceptionEvent event)
Optionally handle an exception by sending some output to the client using the response or by hiding the window. |
PortletMode |
handlePortletModeFailure(PortletRequest request,
PortletMode notAllowed)
This is called when a request arrives requesting a PortletMode that does not pass the isPortletModeAllowed() tests. |
WindowState |
handleWindowStateFailure(PortletRequest request,
WindowState notAllowed)
This is called when a request arrives requesting a WindowState that does not pass the isWindowStateAllowed() tests. |
void |
init(ServletConfig servletConfig)
Initialize the servlet. |
boolean |
isPortletModeAllowed(PortletRequest request,
PortletMode portletMode)
Return true if the PortletMode is allowed. |
boolean |
isPrivate()
Return true if the contents of the portlet are private. |
boolean |
isWindowStateAllowed(PortletRequest request,
WindowState windowState)
Return true if the WindowState is allowed. |
protected java.lang.Object |
newInstance(java.lang.Class targetClass,
java.lang.String className)
|
void |
setBufferSize(int bufferSize)
Default is 0 |
void |
setExpirationCache(int expirationCache)
Enable caching of the response and set the expiration time in seconds. |
void |
setNamespace(java.lang.String namespace)
The namespace is used to uniquely identify this usage of the portlet, the default is "" (the empty string). |
void |
setPortal(Portal portal)
Default is an instance of GenericPortal. |
void |
setPortalClass(java.lang.String className)
An alternative to setPortal(Portal), specify the class
name of an object to instantiate |
void |
setPortalRef(java.lang.String attributeName)
An alternative to setPortal(Portal), specify the name
of an attribute to lookup in the ServletContext. |
void |
setPortlet(Portlet portlet)
The portlet, required. |
void |
setPortletClass(java.lang.String className)
An alternative to setPortlet(Portlet), specify the class
name of an object to instantiate |
void |
setPortletName(java.lang.String portletName)
The default is the value of ServletConfig.getServletName() |
void |
setPortletPreferences(GenericPortletPreferences defaultPreferences)
Set the default preferences. |
void |
setPrivate(boolean isPrivate)
If true then the response is private, indicating that it contains information that should only be provided to the current client, default is false. |
void |
setRenderer(Renderer renderer)
A Renderer wraps decorations around the portlet, see AbstractRenderer. |
void |
setRendererClass(java.lang.String className)
An alternative to setRenderer(Renderer), specify the class
name of an object to instantiate |
void |
setResourceBundle(java.lang.String name)
Set a resource bundle name, used to instantiate an instance of ResourceBundleFactory. |
void |
setResourceBundleFactory(ResourceBundleFactory factory)
|
| Methods inherited from class javax.servlet.http.HttpServlet |
|---|
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service |
| Methods inherited from class javax.servlet.GenericServlet |
|---|
getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final java.util.logging.Logger log
| Constructor Detail |
|---|
public PortletServlet()
| Method Detail |
|---|
public void setPortal(Portal portal)
GenericPortal.
public void setPortalClass(java.lang.String className)
setPortal(Portal), specify the class
name of an object to instantiate
public void setPortalRef(java.lang.String attributeName)
setPortal(Portal), specify the name
of an attribute to lookup in the ServletContext. This is useful
for sharing a Portal amongst different servlets.
public void setNamespace(java.lang.String namespace)
public void setPortlet(Portlet portlet)
public void setPortletClass(java.lang.String className)
setPortlet(Portlet), specify the class
name of an object to instantiate
public void setPortletName(java.lang.String portletName)
public void addInitParam(java.lang.String name,
java.lang.String value)
public void addInitParam(NameValuePair nameValuePair)
public void setPortletPreferences(GenericPortletPreferences defaultPreferences)
public void setExpirationCache(int expirationCache)
public void setPrivate(boolean isPrivate)
public void setResourceBundle(java.lang.String name)
public void setResourceBundleFactory(ResourceBundleFactory factory)
public void setRenderer(Renderer renderer)
AbstractRenderer.
public void setRendererClass(java.lang.String className)
setRenderer(Renderer), specify the class
name of an object to instantiate
public void setBufferSize(int bufferSize)
public void init(ServletConfig servletConfig)
throws ServletException
GenericServletinit() instead.
init in interface Servletinit in class GenericServletservletConfig - the servlet's configuration
ServletException
protected java.lang.Object newInstance(java.lang.Class targetClass,
java.lang.String className)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentExceptionpublic PortletConfig getPortletConfig()
getPortletConfig in interface Windowpublic java.lang.String getInitParameter(java.lang.String name)
GenericServlet
<servlet servlet-name='myservlet'
servlet-class='test.MyServlet'>
<init-param param1='value1'/>
<init-param param2='value2'/>
</servlet>
getInitParameter in interface PortletConfiggetInitParameter in interface ServletConfiggetInitParameter in class GenericServletname - of the parameter
public java.util.Enumeration getInitParameterNames()
GenericServlet
getInitParameterNames in interface PortletConfiggetInitParameterNames in interface ServletConfiggetInitParameterNames in class GenericServletpublic int getExpirationCache()
getExpirationCache in interface Windowpublic boolean isPrivate()
isPrivate in interface Window
public boolean isWindowStateAllowed(PortletRequest request,
WindowState windowState)
portletRequest.getResponseContentType() can be used
if the allowed portlet modes depends on the mime type of the
response.
This implementation returns true.
isWindowStateAllowed in interface Window
public boolean isPortletModeAllowed(PortletRequest request,
PortletMode portletMode)
portletRequest.getResponseContentType() can be used
if the allowed portlet modes depends on the mime type of the
response.
This implementation returns true.
isPortletModeAllowed in interface Windowpublic java.util.Set<java.lang.String> getSupportedContentTypes(PortletMode portletMode)
getSupportedContentTypes in interface Windowpublic java.util.Set<java.util.Locale> getSupportedLocales()
getSupportedLocales in interface Windowpublic PortletPreferences getDefaultPreferences()
getDefaultPreferences in interface Windowpublic java.util.ArrayList<PreferencesValidator> getPreferencesValidators()
getPreferencesValidators in interface Windowpublic java.util.Map<java.lang.String,java.lang.String> getRoleRefMap()
getRoleRefMap in interface Windowpublic java.util.ArrayList<Constraint> getConstraints()
Constraint that are applied before the
processAction() and render() of the portlet are called, null if there
are no Constraints.
This implementation returns null.
getConstraints in interface Windowpublic Renderer getRenderer()
getRenderer in interface Window
public PortletMode handlePortletModeFailure(PortletRequest request,
PortletMode notAllowed)
handleException to handle
PortletModeException.
This implementation returns PortletMode.VIEW.
handlePortletModeFailure in interface Window
public WindowState handleWindowStateFailure(PortletRequest request,
WindowState notAllowed)
handleException to handle
WindowStateException.
This implementation returns WindowState.NORMAL.
handleWindowStateFailure in interface Window
public void handleConstraintFailure(RenderRequest request,
RenderResponse response,
ConstraintFailureEvent event)
PortletConnection#handleConstraintFailure() is called.
Implementations of this method can change that behaviour by using the
event.setHandled(boolean hideWindow) callback method.
See Window.handleException(javax.portlet.RenderRequest, javax.portlet.RenderResponse, com.caucho.portal.generic.ExceptionEvent) for more information.
This implementation does nothing.
handleConstraintFailure in interface Window
public void handleException(RenderRequest request,
RenderResponse response,
ExceptionEvent event)
PortletConnection#handleException()
is called.
Implementations of this method can change that behaviour by using the
event.setHandled(boolean hideWindow) callback method.
public void handleException(RenderRequest request, RenderResponse response, ExceptionEvent event)
throws PortletException, IOException
{
if (event.getException() instanceof UnavailableException) {
PrintWriter out = response.getWriter();
response.setContentType("text/html");
out.println("This service is currently unavailable.");
event.setHandled(false);
}
}
If an implementation is handling an exception that can occur after the
Portlet has written some content already, it should call response.reset()
before it writes anything to the response.
public void handleException(RenderRequest request, RenderResponse response, ExceptionEvent event)
throws PortletException, IOException
{
response.reset();
response.setContentType("text/html");
PrintWriter out = response.getWriter();
printFancyExceptionMessage(event.getException());
event.setHandled(false);
}
public void handleException(ExceptionEvent event)
throws PortletException, IOException
{
log.log(Level.WARNING, ex.toString(), ex);
event.setHandled(true);
}
This implementation does nothing.
handleException in interface Windowpublic java.lang.String getPortletName()
getPortletName in interface PortletConfigpublic PortletContext getPortletContext()
getPortletContext in interface PortletConfigpublic java.util.ResourceBundle getResourceBundle(java.util.Locale locale)
getResourceBundle in interface PortletConfigpublic int getBufferSize()
getBufferSize in interface Window
protected void doGet(HttpServletRequest req,
HttpServletResponse res)
throws ServletException,
java.io.IOException
HttpServlet
doGet in class HttpServletreq - the client requestres - response to the client
ServletException
java.io.IOException
protected void doPost(HttpServletRequest req,
HttpServletResponse res)
throws ServletException,
java.io.IOException
HttpServlet
doPost in class HttpServletreq - the client requestres - response to the client
ServletException
java.io.IOException
protected void doRequest(HttpServletRequest httpRequest,
HttpServletResponse httpResponse)
throws ServletException,
java.io.IOException
ServletException
java.io.IOExceptionpublic void destroy()
GenericServlet
destroy in interface Servletdestroy in class GenericServlet
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||