001 /** 002 * Copyright (c) 2000-present Liferay, Inc. All rights reserved. 003 * 004 * This library is free software; you can redistribute it and/or modify it under 005 * the terms of the GNU Lesser General Public License as published by the Free 006 * Software Foundation; either version 2.1 of the License, or (at your option) 007 * any later version. 008 * 009 * This library is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 011 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 012 * details. 013 */ 014 015 package com.liferay.portal.kernel.portlet.bridges.mvc; 016 017 import com.liferay.portal.kernel.util.StringPool; 018 019 import javax.portlet.PortletException; 020 import javax.portlet.RenderRequest; 021 import javax.portlet.RenderResponse; 022 023 /** 024 * Provides an interface to handle the render phase of the portlet. This 025 * interface can only be used when the portlet is based on {@link MVCPortlet}. 026 * 027 * <p> 028 * The render command that to be invoked is determined by two factors: 029 * </p> 030 * 031 * <ul> 032 * <li> 033 * The portlet name that the render URL is referring to. 034 * </li> 035 * <li> 036 * The parameter value <code>mvcRenderCommandName</code> of the render URL. 037 * </li> 038 * </ul> 039 * 040 * <p> 041 * Implementations of this interface must be OSGi components that are registered 042 * in the OSGi Registry with the following properties: 043 * </p> 044 * 045 * <ul> 046 * <li> 047 * <code>javax.portlet.name</code>: The portlet name associated to this render 048 * command. 049 * </li> 050 * <li> 051 * <code>mvc.command.name</code>: the command name that matches the 052 * parameter value <code>mvcRenderCommandName</code>. This name cannot contain 053 * any comma (<code>,</code>). 054 * </li> 055 * </ul> 056 * 057 * <p> 058 * The method {@link MVCPortlet#render(RenderRequest, RenderResponse)} searches 059 * the OSGi Registry for the render command that matches both the portlet name 060 * with the property <code>javax.portlet.name</code> and the parameter value 061 * <code>mvc.command.name</code> with the property 062 * <code>mvc.command.name</code>. 063 * </p> 064 * 065 * <p> 066 * When there are multiple render commands registered for the same portlet name 067 * and with the same command name, only the render command with the highest 068 * service ranking is invoked. 069 * </p> 070 * 071 * @author Sergio Gonz??lez 072 */ 073 public interface MVCRenderCommand extends MVCCommand { 074 075 public static final MVCRenderCommand EMPTY = new MVCRenderCommand() { 076 077 @Override 078 public String render( 079 RenderRequest renderRequest, RenderResponse renderResponse) { 080 081 return StringPool.BLANK; 082 } 083 084 }; 085 086 public static final String MVC_PATH_SKIP_DISPATCH = 087 MVCRenderCommand.class.getName() + "#MVC_PATH_SKIP_DISPATCH"; 088 089 /** 090 * Invoked by {@link MVCPortlet} to handle the render phase of the portlet. 091 * 092 * @param renderRequest the render request 093 * @param renderResponse the render response 094 * @return the path that should be dispatched 095 */ 096 public String render( 097 RenderRequest renderRequest, RenderResponse renderResponse) 098 throws PortletException; 099 100 }